206 lines
6.6 KiB
JSON
206 lines
6.6 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://aps.local/contracts/events.schema.json",
|
|
"title": "PlatformEvent",
|
|
"description": "协议 v1 的全部事件类型。新增事件类型必须同时改这里、contracts/events.ts 与 docs/spec/protocol.md。",
|
|
"$ref": "#/$defs/event",
|
|
"$defs": {
|
|
"envelope": {
|
|
"allOf": [{ "$ref": "envelope.schema.json#/$defs/envelope" }]
|
|
},
|
|
"messageDelta": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "message.delta" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["messageId", "text"],
|
|
"properties": {
|
|
"messageId": { "type": "string" },
|
|
"text": { "type": "string" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"messageUser": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "message.user" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["messageId", "text"],
|
|
"properties": {
|
|
"messageId": { "type": "string" },
|
|
"text": { "type": "string" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
}, "messageCompleted": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "message.completed" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["messageId"],
|
|
"properties": {
|
|
"messageId": { "type": "string" },
|
|
"finishReason": { "type": "string", "enum": ["stop", "cancelled", "error", "length"] }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"toolCall": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "tool.call" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["callId", "capabilityId", "argsDigest"],
|
|
"properties": {
|
|
"callId": { "type": "string" },
|
|
"capabilityId": { "type": "string" },
|
|
"argsDigest": { "type": "string", "description": "参数摘要,不是参数明文" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"toolResult": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "tool.result" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["callId", "executionId", "status"],
|
|
"properties": {
|
|
"callId": { "type": "string" },
|
|
"executionId": { "type": "string" },
|
|
"status": { "$ref": "envelope.schema.json#/$defs/status" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"executionUpdated": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "execution.updated" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["executionId", "status"],
|
|
"properties": {
|
|
"executionId": { "type": "string" },
|
|
"status": { "$ref": "envelope.schema.json#/$defs/status" },
|
|
"errorKind": { "type": "string" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"approvalRequested": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "approval.requested" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["approvalId", "capabilityId", "paramsDigest", "impactSummary", "revision", "expiresAt"],
|
|
"properties": {
|
|
"approvalId": { "type": "string" },
|
|
"capabilityId": { "type": "string" },
|
|
"paramsDigest": { "type": "string" },
|
|
"impactSummary": { "type": "string", "description": "确认卡正文:影响范围与关键参数摘要" },
|
|
"revision": { "type": "integer", "minimum": 0, "description": "目标数据版本;版本变了确认就失效" },
|
|
"expiresAt": { "type": "integer" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"approvalResolved": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "approval.resolved" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["approvalId", "decision"],
|
|
"properties": {
|
|
"approvalId": { "type": "string" },
|
|
"decision": { "type": "string", "enum": ["approved", "rejected", "expired"] }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"runState": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "run.state" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["state"],
|
|
"properties": {
|
|
"state": { "type": "string", "enum": ["idle", "running", "cancelling", "cancelled"] }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"sessionUpdated": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "session.updated" },
|
|
"data": {
|
|
"type": "object",
|
|
"properties": {
|
|
"title": { "type": "string" },
|
|
"status": { "type": "string", "enum": ["active", "archived"] }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"error": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "error" },
|
|
"data": {
|
|
"type": "object",
|
|
"required": ["code", "message", "retryable"],
|
|
"properties": {
|
|
"code": { "type": "string" },
|
|
"message": { "type": "string" },
|
|
"retryable": { "type": "boolean" },
|
|
"errorKind": { "type": "string" }
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
},
|
|
"heartbeat": {
|
|
"allOf": [{ "$ref": "#/$defs/envelope" }],
|
|
"properties": {
|
|
"type": { "const": "heartbeat" },
|
|
"data": { "type": "object", "additionalProperties": false }
|
|
}
|
|
},
|
|
"event": {
|
|
"oneOf": [
|
|
{ "$ref": "#/$defs/messageUser" },
|
|
{ "$ref": "#/$defs/messageDelta" },
|
|
{ "$ref": "#/$defs/messageCompleted" },
|
|
{ "$ref": "#/$defs/toolCall" },
|
|
{ "$ref": "#/$defs/toolResult" },
|
|
{ "$ref": "#/$defs/executionUpdated" },
|
|
{ "$ref": "#/$defs/approvalRequested" },
|
|
{ "$ref": "#/$defs/approvalResolved" },
|
|
{ "$ref": "#/$defs/runState" },
|
|
{ "$ref": "#/$defs/sessionUpdated" },
|
|
{ "$ref": "#/$defs/error" },
|
|
{ "$ref": "#/$defs/heartbeat" }
|
|
]
|
|
}
|
|
}
|
|
} |