重构仓库目录为统一的 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

@ -0,0 +1,29 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/agent.json",
"title": "AgentParams",
"type": "object",
"additionalProperties": false,
"required": ["message", "idempotencyKey"],
"properties": {
"message": { "type": "string", "minLength": 1 },
"agentId": { "type": "string", "minLength": 1 },
"provider": { "type": "string", "minLength": 1 },
"model": { "type": "string", "minLength": 1 },
"to": { "type": "string", "minLength": 1 },
"replyTo": { "type": "string", "minLength": 1 },
"sessionId": { "type": "string", "minLength": 1 },
"sessionKey": { "type": "string", "minLength": 1 },
"thinking": { "type": "string" },
"deliver": { "type": "boolean" },
"attachments": { "type": "array", "items": {} },
"channel": { "type": "string" },
"timeout": { "type": "integer", "minimum": 0 },
"extraSystemPrompt": { "type": "string" },
"bootstrapContextMode": { "enum": ["full", "lightweight"] },
"bootstrapContextRunKind": { "enum": ["default", "heartbeat", "cron"] },
"idempotencyKey": { "type": "string", "minLength": 1 },
"label": { "type": "string" }
}
}

View file

@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/agent_wait.json",
"title": "AgentWaitParams",
"type": "object",
"additionalProperties": false,
"required": ["runId"],
"properties": {
"runId": { "type": "string", "minLength": 1 },
"timeoutMs": { "type": "integer", "minimum": 0 }
}
}

View file

@ -0,0 +1,45 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/chat.json",
"title": "ChatParams",
"$defs": {
"NonEmptyString": { "type": "string", "minLength": 1 },
"ChatSendParams": {
"type": "object",
"additionalProperties": false,
"required": ["sessionKey", "message", "idempotencyKey"],
"properties": {
"sessionKey": { "$ref": "#/$defs/NonEmptyString" },
"message": { "type": "string" },
"thinking": { "type": "string" },
"interaction_mode": { "type": "string" },
"specialist": { "type": "string" },
"relay_share_envelope": { "type": "object" },
"acp_parent_run_id": { "type": "string" },
"acp_child_run_id": { "type": "string" },
"attachments": { "type": "array", "items": {} },
"timeoutMs": { "type": "integer", "minimum": 0 },
"idempotencyKey": { "$ref": "#/$defs/NonEmptyString" }
}
},
"ChatHistoryParams": {
"type": "object",
"additionalProperties": false,
"required": ["sessionKey"],
"properties": {
"sessionKey": { "$ref": "#/$defs/NonEmptyString" },
"limit": { "type": "integer", "minimum": 1 },
"maxChars": { "type": "integer", "minimum": 1 }
}
},
"ChatAbortParams": {
"type": "object",
"additionalProperties": false,
"required": ["sessionKey"],
"properties": {
"sessionKey": { "$ref": "#/$defs/NonEmptyString" },
"runId": { "type": "string", "minLength": 1 }
}
}
}
}

View file

@ -0,0 +1,61 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/connect.json",
"title": "ConnectParams",
"type": "object",
"additionalProperties": false,
"required": ["minProtocol", "maxProtocol", "client"],
"properties": {
"minProtocol": { "type": "integer", "minimum": 1 },
"maxProtocol": { "type": "integer", "minimum": 1 },
"client": {
"type": "object",
"additionalProperties": false,
"required": ["id", "version", "platform", "mode"],
"properties": {
"id": { "type": "string", "minLength": 1 },
"displayName": { "type": "string", "minLength": 1 },
"version": { "type": "string", "minLength": 1 },
"platform": { "type": "string", "minLength": 1 },
"deviceFamily": { "type": "string", "minLength": 1 },
"modelIdentifier": { "type": "string", "minLength": 1 },
"mode": { "type": "string", "minLength": 1 },
"instanceId": { "type": "string", "minLength": 1 }
}
},
"caps": { "type": "array", "items": { "type": "string", "minLength": 1 } },
"commands": { "type": "array", "items": { "type": "string", "minLength": 1 } },
"permissions": {
"type": "object",
"additionalProperties": { "type": "boolean" }
},
"pathEnv": { "type": "string" },
"role": { "type": "string", "minLength": 1 },
"scopes": { "type": "array", "items": { "type": "string", "minLength": 1 } },
"auth": {
"type": "object",
"additionalProperties": false,
"properties": {
"token": { "type": "string" },
"bootstrapToken": { "type": "string" },
"deviceToken": { "type": "string" },
"password": { "type": "string" }
}
},
"device": {
"type": "object",
"additionalProperties": false,
"required": ["id", "publicKey", "signature", "signedAt", "nonce"],
"properties": {
"id": { "type": "string", "minLength": 1 },
"publicKey": { "type": "string", "minLength": 1 },
"signature": { "type": "string", "minLength": 1 },
"signedAt": { "type": "integer", "minimum": 0 },
"nonce": { "type": "string", "minLength": 1 }
}
},
"locale": { "type": "string" },
"userAgent": { "type": "string" }
}
}

View file

@ -0,0 +1,70 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/frames.json",
"title": "GatewayFrame",
"type": "object",
"oneOf": [
{ "$ref": "#/$defs/RequestFrame" },
{ "$ref": "#/$defs/ResponseFrame" },
{ "$ref": "#/$defs/EventFrame" }
],
"$defs": {
"NonEmptyString": { "type": "string", "minLength": 1 },
"ErrorShape": {
"type": "object",
"additionalProperties": false,
"required": ["code", "message"],
"properties": {
"code": { "$ref": "#/$defs/NonEmptyString" },
"message": { "$ref": "#/$defs/NonEmptyString" },
"details": {},
"retryable": { "type": "boolean" },
"retryAfterMs": { "type": "integer", "minimum": 0 }
}
},
"RequestFrame": {
"type": "object",
"additionalProperties": false,
"required": ["type", "id", "method"],
"properties": {
"type": { "const": "req" },
"id": { "$ref": "#/$defs/NonEmptyString" },
"method": { "$ref": "#/$defs/NonEmptyString" },
"params": {}
}
},
"ResponseFrame": {
"type": "object",
"additionalProperties": false,
"required": ["type", "id", "ok"],
"properties": {
"type": { "const": "res" },
"id": { "$ref": "#/$defs/NonEmptyString" },
"ok": { "type": "boolean" },
"payload": {},
"error": { "$ref": "#/$defs/ErrorShape" }
}
},
"EventFrame": {
"type": "object",
"additionalProperties": false,
"required": ["type", "event"],
"properties": {
"type": { "const": "event" },
"event": { "$ref": "#/$defs/NonEmptyString" },
"payload": {},
"seq": { "type": "integer", "minimum": 0 },
"stateVersion": {
"type": "object",
"additionalProperties": false,
"required": ["presence", "health"],
"properties": {
"presence": { "type": "integer", "minimum": 0 },
"health": { "type": "integer", "minimum": 0 }
}
}
}
}
}
}

View file

@ -0,0 +1,86 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/hello_ok.json",
"title": "HelloOk",
"type": "object",
"additionalProperties": false,
"required": ["type", "protocol", "server", "features", "snapshot", "policy"],
"properties": {
"type": { "const": "hello-ok" },
"protocol": { "type": "integer", "minimum": 1 },
"server": {
"type": "object",
"additionalProperties": false,
"required": ["version", "connId"],
"properties": {
"version": { "type": "string", "minLength": 1 },
"connId": { "type": "string", "minLength": 1 }
}
},
"features": {
"type": "object",
"additionalProperties": false,
"required": ["methods", "events"],
"properties": {
"methods": { "type": "array", "items": { "type": "string", "minLength": 1 } },
"events": { "type": "array", "items": { "type": "string", "minLength": 1 } }
}
},
"snapshot": {
"type": "object",
"additionalProperties": false,
"required": ["presence", "health", "stateVersion", "uptimeMs"],
"properties": {
"presence": { "type": "array", "items": { "type": "object" } },
"health": {},
"stateVersion": {
"type": "object",
"additionalProperties": false,
"required": ["presence", "health"],
"properties": {
"presence": { "type": "integer", "minimum": 0 },
"health": { "type": "integer", "minimum": 0 }
}
},
"uptimeMs": { "type": "integer", "minimum": 0 }
}
},
"policy": {
"type": "object",
"additionalProperties": false,
"required": ["maxPayload", "maxBufferedBytes", "tickIntervalMs"],
"properties": {
"maxPayload": { "type": "integer", "minimum": 1 },
"maxBufferedBytes": { "type": "integer", "minimum": 1 },
"tickIntervalMs": { "type": "integer", "minimum": 1 }
}
},
"canvasHostUrl": { "type": "string", "minLength": 1 },
"auth": {
"type": "object",
"additionalProperties": false,
"required": ["role", "scopes"],
"properties": {
"deviceToken": { "type": "string", "minLength": 1 },
"role": { "type": "string", "minLength": 1 },
"scopes": { "type": "array", "items": { "type": "string", "minLength": 1 } },
"issuedAtMs": { "type": "integer", "minimum": 0 },
"deviceTokens": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["deviceToken", "role", "scopes", "issuedAtMs"],
"properties": {
"deviceToken": { "type": "string", "minLength": 1 },
"role": { "type": "string", "minLength": 1 },
"scopes": { "type": "array", "items": { "type": "string", "minLength": 1 } },
"issuedAtMs": { "type": "integer", "minimum": 0 }
}
}
}
}
}
}
}

View file

@ -0,0 +1,38 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "oclaw://schemas/sessions.json",
"title": "SessionsParams",
"$defs": {
"NonEmptyString": { "type": "string", "minLength": 1 },
"SessionsListParams": {
"type": "object",
"additionalProperties": false,
"properties": {
"limit": { "type": "integer", "minimum": 1 },
"search": { "type": "string" }
}
},
"SessionsGetParams": {
"type": "object",
"additionalProperties": false,
"required": ["key"],
"properties": { "key": { "$ref": "#/$defs/NonEmptyString" } }
},
"SessionsSendParams": {
"type": "object",
"additionalProperties": false,
"required": ["key", "message"],
"properties": {
"key": { "$ref": "#/$defs/NonEmptyString" },
"message": { "type": "string" },
"thinking": { "type": "string" },
"attachments": { "type": "array", "items": {} },
"timeoutMs": { "type": "integer", "minimum": 0 },
"idempotencyKey": { "$ref": "#/$defs/NonEmptyString" },
"interaction_mode": { "$ref": "#/$defs/NonEmptyString" },
"specialist": { "$ref": "#/$defs/NonEmptyString" }
}
}
}
}

View file

@ -32,7 +32,7 @@ from oclaw.interfaces.ws.runtime_loop import close_ws as close_ws_impl, run_conn
from oclaw.interfaces.ws.server_methods_bridge import build_gateway_context, dispatch_via_server_methods
from oclaw.interfaces.ws.turn_runner import run_agent_turn_via_bridge
from oclaw.interfaces.ws.ws_schema import format_validation_errors, get_ws_schemas, validate_or_errors
from oclaw.openclaw_runtime.relay_pointer import validate_relay_share_envelope
from oclaw.runtime.relay_pointer import validate_relay_share_envelope
class OclawWsGatewayConnection:

View file

@ -2,14 +2,13 @@ from __future__ import annotations
import json
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from jsonschema import Draft202012Validator
from oclaw.platform.config.paths import PROJECT_ROOT
from oclaw.platform.config.runtime_paths import ws_protocol_schemas_root
_SCHEMA_DIR = Path(PROJECT_ROOT) / "oclaw" / "openclaw_protocol_schemas"
_SCHEMA_DIR = ws_protocol_schemas_root()
def _load_schema(name: str) -> dict[str, Any]:

View file

@ -105,7 +105,7 @@ def build_gateway_context(
rid = str(run_id or "").strip()
if not rid:
return {"status": "error", "runId": rid, "summary": "runId required"}
run = store.openclaw_run_get(run_id=rid)
run = store.oclaw_run_get(run_id=rid)
if not run:
return {"status": "pending", "runId": rid, "summary": "run not finished", "pollAfterMs": 250}
status = str(run.status or "").strip().lower()

View file

@ -5,9 +5,9 @@ import threading
import uuid
from typing import Any, Callable
from oclaw.agents.factory import build_gateway_executor
from oclaw.openclaw_runtime.gateway import OpenClawGateway
from oclaw.openclaw_runtime.types import StandardMessage
from oclaw.runtime.agents.factory import build_gateway_executor
from oclaw.runtime.gateway import OclawGateway
from oclaw.runtime.types import StandardMessage
from oclaw.platform.config.paths import db_path
from oclaw.platform.persistence.sqlite_store import SqliteStore
@ -27,7 +27,7 @@ async def run_agent_turn_via_bridge(
msg_text = str(p.get("message") or "").strip()
attachments = list(p.get("attachments") or [])
store = SqliteStore(db_path())
gw = OpenClawGateway(store=store)
gw = OclawGateway(store=store)
ctx = conn.auth_ctx or {}
tenant_id = str(ctx.get("tenant_id") or "")