{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://sandbox-agent/schemas/pi.json",
  "title": "Pi RPC Schema",
  "definitions": {
    "RpcEvent": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "sessionId": {
          "type": "string"
        },
        "messageId": {
          "type": "string"
        },
        "message": {
          "$ref": "#/definitions/RpcMessage"
        },
        "assistantMessageEvent": {
          "$ref": "#/definitions/AssistantMessageEvent"
        },
        "toolCallId": {
          "type": "string"
        },
        "toolName": {
          "type": "string"
        },
        "args": {},
        "partialResult": {},
        "result": {
          "$ref": "#/definitions/ToolResult"
        },
        "isError": {
          "type": "boolean"
        },
        "error": {}
      },
      "required": ["type"]
    },
    "RpcMessage": {
      "type": "object",
      "properties": {
        "role": {
          "type": "string"
        },
        "content": {}
      }
    },
    "AssistantMessageEvent": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "delta": {
          "type": "string"
        },
        "content": {},
        "partial": {},
        "messageId": {
          "type": "string"
        }
      }
    },
    "ToolResult": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        },
        "content": {
          "type": "string"
        },
        "text": {
          "type": "string"
        }
      }
    },
    "RpcResponse": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "response"
        },
        "id": {
          "type": "integer"
        },
        "success": {
          "type": "boolean"
        },
        "data": {},
        "error": {}
      },
      "required": ["type"]
    },
    "RpcCommand": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "command"
        },
        "id": {
          "type": "integer"
        },
        "command": {
          "type": "string"
        },
        "params": {}
      },
      "required": ["type", "command"]
    }
  }
}
