AstrBot-Desktop/docs/protocol/v1/schemas/gateway-event.schema.json

422 行
8 KiB
JSON

{
"$defs": {
"AgentStatusPayload": {
"additionalProperties": false,
"properties": {
"detail": {
"type": [
"string",
"null"
]
},
"state": {
"type": "string"
}
},
"required": [
"state"
],
"type": "object"
},
"CapabilityLimits": {
"additionalProperties": false,
"properties": {
"maxActiveConnections": {
"format": "uint8",
"maximum": 255,
"minimum": 0,
"type": "integer"
},
"maxEventBytes": {
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"maxMessageBytes": {
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"replayWindowEvents": {
"format": "uint32",
"minimum": 0,
"type": "integer"
}
},
"required": [
"maxEventBytes",
"maxMessageBytes",
"replayWindowEvents",
"maxActiveConnections"
],
"type": "object"
},
"FinishReason": {
"enum": [
"stop",
"cancelled",
"error"
],
"type": "string"
},
"GatewayErrorPayload": {
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
},
"required": [
"code",
"message",
"retryable"
],
"type": "object"
},
"HeartbeatPayload": {
"additionalProperties": false,
"properties": {
"intervalMs": {
"format": "uint64",
"minimum": 0,
"type": "integer"
}
},
"required": [
"intervalMs"
],
"type": "object"
},
"MessageCompletedPayload": {
"additionalProperties": false,
"properties": {
"content": {
"type": [
"string",
"null"
]
},
"finishReason": {
"$ref": "#/$defs/FinishReason"
}
},
"required": [
"finishReason"
],
"type": "object"
},
"MessageDeltaPayload": {
"additionalProperties": false,
"properties": {
"delta": {
"type": "string"
},
"index": {
"format": "uint32",
"minimum": 0,
"type": "integer"
}
},
"required": [
"delta",
"index"
],
"type": "object"
},
"ProactiveMessagePayload": {
"additionalProperties": false,
"properties": {
"content": {
"type": "string"
},
"notificationTitle": {
"type": [
"string",
"null"
]
}
},
"required": [
"content"
],
"type": "object"
},
"RiskLevel": {
"enum": [
"read",
"reversible-write",
"destructive"
],
"type": "string"
},
"ServerCapabilities": {
"additionalProperties": false,
"properties": {
"features": {
"items": {
"type": "string"
},
"type": "array"
},
"limits": {
"$ref": "#/$defs/CapabilityLimits"
},
"localActionTools": {
"default": [],
"items": {
"type": "string"
},
"type": "array"
},
"protocolVersions": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"protocolVersions",
"features",
"limits"
],
"type": "object"
},
"ToolProposal": {
"additionalProperties": false,
"properties": {
"actionId": {
"type": "string"
},
"arguments": true,
"expiresAt": {
"type": "string"
},
"reason": {
"type": "string"
},
"requestedAt": {
"type": "string"
},
"requiresApproval": {
"type": "boolean"
},
"riskLevel": {
"$ref": "#/$defs/RiskLevel"
},
"toolName": {
"type": "string"
}
},
"required": [
"actionId",
"toolName",
"reason",
"riskLevel",
"arguments",
"requestedAt",
"expiresAt",
"requiresApproval"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"properties": {
"eventType": {
"const": "system.heartbeat",
"type": "string"
},
"payload": {
"$ref": "#/$defs/HeartbeatPayload"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "message.delta",
"type": "string"
},
"payload": {
"$ref": "#/$defs/MessageDeltaPayload"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "message.completed",
"type": "string"
},
"payload": {
"$ref": "#/$defs/MessageCompletedPayload"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "message.proactive",
"type": "string"
},
"payload": {
"$ref": "#/$defs/ProactiveMessagePayload"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "agent.status",
"type": "string"
},
"payload": {
"$ref": "#/$defs/AgentStatusPayload"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "tool.proposal",
"type": "string"
},
"payload": {
"$ref": "#/$defs/ToolProposal"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "capabilities.changed",
"type": "string"
},
"payload": {
"$ref": "#/$defs/ServerCapabilities"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
},
{
"properties": {
"eventType": {
"const": "error",
"type": "string"
},
"payload": {
"$ref": "#/$defs/GatewayErrorPayload"
}
},
"required": [
"eventType",
"payload"
],
"type": "object"
}
],
"properties": {
"conversationId": {
"type": [
"string",
"null"
]
},
"eventId": {
"type": "string"
},
"messageId": {
"type": [
"string",
"null"
]
},
"profileId": {
"description": "Untrusted server hint. Local routing must use `BoundGatewayEvent.profile_id`.",
"type": [
"string",
"null"
]
},
"protocolVersion": {
"type": "string"
},
"requestId": {
"type": [
"string",
"null"
]
},
"sequence": {
"format": "uint64",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"serverInstanceId": {
"type": "string"
},
"sessionId": {
"type": [
"string",
"null"
]
},
"timestamp": {
"type": "string"
}
},
"required": [
"protocolVersion",
"eventId",
"serverInstanceId",
"timestamp"
],
"title": "GatewayEvent",
"type": "object"
}