AsyncAPI 3.0
CapWorks 实时 API
会话事件、成果协作和实时转写共用正式登录会话。客户端应实现断线续传、幂等更新以及 1008 鉴权关闭处理。
WebSocket
/v1/sessions/{sessionId}/events会话快照、事件补发、心跳、在线状态与协作草稿
Client → Server
客户端会话消息
RealtimeClientMessage查看消息 Schema
{
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "resume"
},
"afterSequence": {
"type": "number"
}
},
"required": [
"kind",
"afterSequence"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ping"
},
"sentAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"kind",
"sentAt"
],
"additionalProperties": false
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.join"
},
"clientId": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"clientId",
"kind",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.update"
},
"clientId": {
"type": "string"
},
"updateId": {
"type": "string"
},
"updateBase64": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"clientId",
"kind",
"updateBase64",
"updateId",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.checkpoint"
},
"clientId": {
"type": "string"
},
"checkpointId": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"checkpointId",
"clientId",
"kind",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.leave"
},
"clientId": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"clientId",
"kind",
"workObjectId"
]
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "presence"
},
"page": {
"type": "string"
},
"clientId": {
"type": "string"
},
"surfaceId": {
"type": "string"
},
"cursor": {
"anyOf": [
{
"type": "object",
"properties": {
"x": {
"type": "number"
},
"y": {
"type": "number"
}
},
"required": [
"x",
"y"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"viewport": {
"anyOf": [
{
"$ref": "#/components/schemas/RealtimePresenceViewport"
},
{
"type": "null"
}
]
},
"selection": {
"anyOf": [
{
"$ref": "#/components/schemas/RealtimePresenceSelection"
},
{
"type": "null"
}
]
},
"editing": {
"anyOf": [
{
"$ref": "#/components/schemas/RealtimePresenceSelection"
},
{
"type": "null"
}
]
},
"intent": {
"$ref": "#/components/schemas/RealtimePresenceIntent"
},
"sentAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"kind",
"page",
"sentAt"
],
"additionalProperties": false
}
]
}Server → Client
服务端会话消息
RealtimeServerMessage查看消息 Schema
{
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "snapshot"
},
"snapshot": {
"$ref": "#/components/schemas/SessionSnapshot"
}
},
"required": [
"kind",
"snapshot"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "event"
},
"event": {
"$ref": "#/components/schemas/CapWorksEvent"
}
},
"required": [
"kind",
"event"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "replay-complete"
},
"lastSequence": {
"type": "number"
}
},
"required": [
"kind",
"lastSequence"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ping"
},
"sentAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"kind",
"sentAt"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "error"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
},
"required": [
"kind",
"code",
"message",
"retryable"
],
"additionalProperties": false
}
]
}WebSocket
/v1/conversations/{conversationId}/events成果集快照、工作对象事件、在线状态与协作草稿
Client → Server
客户端会话消息
RealtimeClientMessage查看消息 Schema
{
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "resume"
},
"afterSequence": {
"type": "number"
}
},
"required": [
"kind",
"afterSequence"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ping"
},
"sentAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"kind",
"sentAt"
],
"additionalProperties": false
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.join"
},
"clientId": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"clientId",
"kind",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.update"
},
"clientId": {
"type": "string"
},
"updateId": {
"type": "string"
},
"updateBase64": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"clientId",
"kind",
"updateBase64",
"updateId",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.checkpoint"
},
"clientId": {
"type": "string"
},
"checkpointId": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"checkpointId",
"clientId",
"kind",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.leave"
},
"clientId": {
"type": "string"
}
},
"required": [
"baseRevisionId",
"clientId",
"kind",
"workObjectId"
]
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "presence"
},
"page": {
"type": "string"
},
"clientId": {
"type": "string"
},
"surfaceId": {
"type": "string"
},
"cursor": {
"anyOf": [
{
"type": "object",
"properties": {
"x": {
"type": "number"
},
"y": {
"type": "number"
}
},
"required": [
"x",
"y"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"viewport": {
"anyOf": [
{
"$ref": "#/components/schemas/RealtimePresenceViewport"
},
{
"type": "null"
}
]
},
"selection": {
"anyOf": [
{
"$ref": "#/components/schemas/RealtimePresenceSelection"
},
{
"type": "null"
}
]
},
"editing": {
"anyOf": [
{
"$ref": "#/components/schemas/RealtimePresenceSelection"
},
{
"type": "null"
}
]
},
"intent": {
"$ref": "#/components/schemas/RealtimePresenceIntent"
},
"sentAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"kind",
"page",
"sentAt"
],
"additionalProperties": false
}
]
}Server → Client
服务端成果协作消息
RealtimeServerMessageV2查看消息 Schema
{
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "workset-snapshot"
},
"snapshot": {
"$ref": "#/components/schemas/WorkSetDetailResponse"
}
},
"required": [
"kind",
"snapshot"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "event"
},
"event": {
"$ref": "#/components/schemas/CapWorksEventV2"
}
},
"required": [
"kind",
"event"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "presence-snapshot"
},
"presence": {
"type": "array",
"items": {
"$ref": "#/components/schemas/RealtimePresence"
}
}
},
"required": [
"kind",
"presence"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "presence"
},
"presence": {
"$ref": "#/components/schemas/RealtimePresence"
}
},
"required": [
"kind",
"presence"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "presence-leave"
},
"userId": {
"$ref": "#/components/schemas/Identifier"
},
"clientId": {
"type": "string"
},
"conversationId": {
"$ref": "#/components/schemas/Identifier"
}
},
"required": [
"kind",
"userId",
"conversationId"
],
"additionalProperties": false
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.snapshot"
},
"updateBase64": {
"type": "string"
},
"updatedAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"baseRevisionId",
"kind",
"updateBase64",
"updatedAt",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.update"
},
"updateId": {
"type": "string"
},
"updateBase64": {
"type": "string"
},
"userId": {
"$ref": "#/components/schemas/Identifier"
},
"updatedAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"baseRevisionId",
"kind",
"updateBase64",
"updateId",
"updatedAt",
"userId",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.ack"
},
"updateId": {
"type": "string"
},
"duplicate": {
"type": "boolean"
},
"updatedAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"baseRevisionId",
"duplicate",
"kind",
"updateId",
"updatedAt",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.checkpointed"
},
"checkpointId": {
"type": "string"
},
"workObject": {
"$ref": "#/components/schemas/WorkObject"
},
"revision": {
"$ref": "#/components/schemas/WorkObjectRevision"
},
"updatedAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"baseRevisionId",
"checkpointId",
"kind",
"revision",
"updatedAt",
"workObject",
"workObjectId"
]
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "draft.rebase-required"
},
"checkpointId": {
"type": "string"
},
"latestWorkObject": {
"$ref": "#/components/schemas/WorkObject"
},
"latestRevision": {
"$ref": "#/components/schemas/WorkObjectRevision"
},
"updatedAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"baseRevisionId",
"checkpointId",
"kind",
"latestRevision",
"latestWorkObject",
"updatedAt",
"workObjectId"
]
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "replay-complete"
},
"lastSequence": {
"type": "number"
},
"hasMore": {
"type": "boolean"
}
},
"required": [
"kind",
"lastSequence"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ping"
},
"sentAt": {
"$ref": "#/components/schemas/ISO8601Timestamp"
}
},
"required": [
"kind",
"sentAt"
],
"additionalProperties": false
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"workObjectId": {
"$ref": "#/components/schemas/Identifier"
},
"baseRevisionId": {
"$ref": "#/components/schemas/Identifier"
},
"kind": {
"type": "string",
"const": "error"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
},
"required": [
"code",
"kind",
"message",
"retryable"
]
}
]
}WebSocket
/v1/sessions/{sessionId}/transcription-stream实时音频、转写增量、提交结果和说话人识别
Client → Server
客户端实时音频消息
TranscriptionClientMessage查看消息 Schema
{
"oneOf": [
{
"type": "object",
"required": [
"type",
"audio"
],
"properties": {
"type": {
"const": "input_audio_buffer.append"
},
"audio": {
"type": "string",
"contentEncoding": "base64"
},
"startMs": {
"type": "integer"
},
"endMs": {
"type": "integer"
}
}
},
{
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"enum": [
"input_audio_buffer.commit",
"input_audio_buffer.clear"
]
}
}
},
{
"type": "object",
"required": [
"type",
"startMs",
"endMs",
"score"
],
"properties": {
"type": {
"const": "capworks.speaker.self_match"
},
"startMs": {
"type": "integer"
},
"endMs": {
"type": "integer"
},
"score": {
"type": "number"
},
"profileRevision": {
"type": "integer"
},
"modelVersion": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"type",
"startMs",
"endMs",
"modelVersion",
"embedding"
],
"properties": {
"type": {
"const": "capworks.speaker.embedding"
},
"startMs": {
"type": "integer"
},
"endMs": {
"type": "integer"
},
"modelVersion": {
"type": "string"
},
"embedding": {
"type": "array",
"minItems": 192,
"maxItems": 192,
"items": {
"type": "number"
}
}
}
}
]
}Server → Client
服务端实时转写消息
TranscriptionServerMessage查看消息 Schema
{
"oneOf": [
{
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"const": "session.created"
}
}
},
{
"type": "object",
"required": [
"type",
"transcript"
],
"properties": {
"type": {
"const": "conversation.item.input_audio_transcription.completed"
},
"transcript": {
"type": "string"
},
"segments": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
}
},
{
"type": "object",
"required": [
"type",
"transcript"
],
"properties": {
"type": {
"enum": [
"capworks.transcript.partial",
"capworks.transcription.committed"
]
},
"transcript": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"const": "capworks.speaker.identity"
},
"speakerId": {
"type": "string"
},
"confidence": {
"type": "number"
}
}
},
{
"type": "object",
"required": [
"type",
"message"
],
"properties": {
"type": {
"const": "capworks.error"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
}
}
}
]
}原始 AsyncAPI 3.0 规范:下载 JSON