Files
go-sip/contracts/upstream/v1/mq.schema.json
T

957 lines
21 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://go-sip.local/contracts/v1/mq.schema.json",
"title": "agent-call MQ command and event envelope",
"oneOf": [
{
"$ref": "#/$defs/command"
},
{
"$ref": "#/$defs/event"
},
{
"$ref": "#/$defs/request"
},
{
"$ref": "#/$defs/response"
}
],
"$defs": {
"aiConfigResult": {
"type": "object",
"additionalProperties": false,
"required": [
"snapshot",
"authorization"
],
"properties": {
"snapshot": {
"$ref": "#/$defs/ai_AgentVersion"
},
"authorization": {
"$ref": "ai-authorization.schema.json"
}
}
},
"ai_AgentVersion": {
"type": "object",
"required": [
"tenant_id",
"agent_version_id",
"status",
"immutable",
"content_sha256",
"config"
],
"properties": {
"tenant_id": {
"type": "string"
},
"agent_version_id": {
"type": "string"
},
"status": {
"enum": [
"published",
"reused"
]
},
"immutable": {
"const": true
},
"content_sha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
},
"config": {
"$ref": "ai-config.schema.json"
}
}
},
"callReplay": {
"type": "object",
"additionalProperties": false,
"required": [
"reason",
"call_id"
],
"properties": {
"reason": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"call_id": {
"$ref": "#/$defs/id"
}
}
},
"command": {
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"command_type",
"command_id",
"tenant_id",
"tenant_key",
"trace_id",
"issued_at",
"not_after",
"payload",
"dispatcher_id"
],
"properties": {
"schema_version": {
"const": "2.0"
},
"command_type": {
"enum": [
"call.execute",
"task.control",
"call.replay",
"command.replay"
]
},
"command_id": {
"$ref": "#/$defs/id"
},
"tenant_id": {
"$ref": "#/$defs/id"
},
"tenant_key": {
"$ref": "#/$defs/tenantKey"
},
"trace_id": {
"$ref": "#/$defs/id"
},
"issued_at": {
"$ref": "#/$defs/time"
},
"not_after": {
"$ref": "#/$defs/time"
},
"payload": {
"type": "object"
},
"dispatcher_id": {
"$ref": "#/$defs/dispatcherId"
}
},
"allOf": [
{
"if": {
"properties": {
"command_type": {
"const": "call.execute"
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "#/$defs/executePayload"
}
}
}
},
{
"if": {
"properties": {
"command_type": {
"const": "task.control"
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "#/$defs/taskControl"
}
}
}
},
{
"if": {
"properties": {
"command_type": {
"const": "call.replay"
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "#/$defs/callReplay"
}
}
}
},
{
"if": {
"properties": {
"command_type": {
"const": "command.replay"
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "#/$defs/commandReplay"
}
}
}
}
]
},
"commandReplay": {
"type": "object",
"additionalProperties": false,
"required": [
"reason",
"source_command_id"
],
"properties": {
"reason": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"source_command_id": {
"$ref": "#/$defs/id"
}
}
},
"dispatcherId": {
"type": "string",
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
},
"event": {
"$ref": "event-payloads.schema.json"
},
"executePayload": {
"type": "object",
"additionalProperties": false,
"required": [
"execution_id",
"task_id",
"task_item_id",
"task_revision",
"callee",
"route_policy_id",
"caller_profile_id",
"agent_version_id",
"variables",
"ring_timeout_ms",
"max_call_duration_ms"
],
"properties": {
"execution_id": {
"$ref": "#/$defs/id"
},
"task_id": {
"$ref": "#/$defs/id"
},
"task_item_id": {
"$ref": "#/$defs/id"
},
"task_revision": {
"type": "integer",
"minimum": 1
},
"callee": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"route_policy_id": {
"$ref": "#/$defs/id"
},
"caller_profile_id": {
"$ref": "#/$defs/id"
},
"agent_version_id": {
"$ref": "#/$defs/id"
},
"variables": {
"type": "object",
"additionalProperties": true
},
"ring_timeout_ms": {
"type": "integer",
"minimum": 1
},
"max_call_duration_ms": {
"type": "integer",
"minimum": 1
}
}
},
"executor_Call": {
"type": "object",
"required": [
"call_id",
"execution_id",
"call_state",
"call_version",
"attempts",
"transcript",
"recordings",
"delivery",
"snapshot_at"
],
"properties": {
"call_id": {
"type": "string"
},
"execution_id": {
"type": "string"
},
"task_id": {
"type": "string"
},
"task_item_id": {
"type": "string"
},
"call_state": {
"type": "string"
},
"call_version": {
"type": "integer"
},
"reason_code": {
"type": [
"string",
"null"
]
},
"outcome": {
"type": [
"string",
"null"
]
},
"started_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"ended_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"duration_ms": {
"type": [
"integer",
"null"
]
},
"attempts": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "event-payloads.schema.json"
},
{
"properties": {
"event_type": {
"enum": [
"call.status"
]
}
}
}
]
}
},
"transcript": {
"type": "object",
"additionalProperties": false,
"required": [
"events"
],
"properties": {
"events": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "event-payloads.schema.json"
},
{
"properties": {
"event_type": {
"enum": [
"transcript.updated",
"transcript.failed"
]
}
}
}
]
}
}
}
},
"recordings": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "event-payloads.schema.json"
},
{
"properties": {
"event_type": {
"enum": [
"recording.uploaded",
"recording.failed"
]
}
}
}
]
}
},
"delivery": {
"type": "object",
"additionalProperties": false,
"required": [
"pending",
"retry",
"dispatching",
"published"
],
"properties": {
"pending": {
"type": "integer",
"minimum": 0
},
"retry": {
"type": "integer",
"minimum": 0
},
"dispatching": {
"type": "integer",
"minimum": 0
},
"published": {
"type": "integer",
"minimum": 0
}
}
},
"snapshot_at": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
},
"executor_Command": {
"type": "object",
"required": [
"command_id",
"command_type",
"tenant_id",
"tenant_key",
"status",
"aggregate_version"
],
"properties": {
"command_id": {
"$ref": "#/$defs/executor_Id"
},
"command_type": {
"type": "string"
},
"tenant_id": {
"type": "string"
},
"tenant_key": {
"type": "string"
},
"task_id": {
"type": [
"string",
"null"
]
},
"execution_id": {
"type": [
"string",
"null"
]
},
"call_id": {
"type": [
"string",
"null"
]
},
"status": {
"type": "string"
},
"reason_code": {
"type": [
"string",
"null"
]
},
"wait_reason_code": {
"type": [
"string",
"null"
]
},
"accepted_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"waiting_since": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"admission_deadline": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"requested_task_revision": {
"type": [
"integer",
"null"
]
},
"applied_task_revision": {
"type": [
"integer",
"null"
]
},
"task_state": {
"type": [
"string",
"null"
]
},
"updated_at": {
"type": "string",
"format": "date-time"
},
"aggregate_version": {
"type": "integer",
"minimum": 1
}
},
"additionalProperties": false
},
"executor_Id": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"pattern": "^[^\\s/\\\\]+$"
},
"id": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"pattern": "^[^\\s/\\\\]+$"
},
"request": {
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"message_type",
"message_id",
"dispatcher_id",
"tenant_id",
"tenant_key",
"trace_id",
"issued_at",
"not_after",
"payload"
],
"properties": {
"schema_version": {
"const": "2.0"
},
"message_type": {
"enum": [
"command.query",
"call.query",
"ai.config.request"
]
},
"message_id": {
"$ref": "#/$defs/id"
},
"dispatcher_id": {
"$ref": "#/$defs/dispatcherId"
},
"tenant_id": {
"$ref": "#/$defs/id"
},
"tenant_key": {
"$ref": "#/$defs/tenantKey"
},
"trace_id": {
"$ref": "#/$defs/id"
},
"issued_at": {
"type": "string",
"format": "date-time"
},
"not_after": {
"type": "string",
"format": "date-time"
},
"payload": {
"type": "object"
}
},
"allOf": [
{
"if": {
"properties": {
"message_type": {
"const": "command.query"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"command_id"
],
"properties": {
"command_id": {
"$ref": "#/$defs/id"
}
}
}
}
}
},
{
"if": {
"properties": {
"message_type": {
"const": "call.query"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"call_id"
],
"properties": {
"call_id": {
"$ref": "#/$defs/id"
}
}
}
}
}
},
{
"if": {
"properties": {
"message_type": {
"const": "ai.config.request"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"agent_version_id"
],
"properties": {
"agent_version_id": {
"$ref": "#/$defs/id"
}
}
}
}
}
}
]
},
"response": {
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"message_type",
"message_id",
"dispatcher_id",
"tenant_id",
"tenant_key",
"trace_id",
"issued_at",
"correlation_id",
"status",
"reason_code",
"payload"
],
"properties": {
"schema_version": {
"const": "2.0"
},
"message_type": {
"enum": [
"command.query.result",
"call.query.result",
"ai.config.result"
]
},
"message_id": {
"$ref": "#/$defs/id"
},
"dispatcher_id": {
"$ref": "#/$defs/dispatcherId"
},
"tenant_id": {
"$ref": "#/$defs/id"
},
"tenant_key": {
"$ref": "#/$defs/tenantKey"
},
"trace_id": {
"$ref": "#/$defs/id"
},
"issued_at": {
"type": "string",
"format": "date-time"
},
"correlation_id": {
"$ref": "#/$defs/id"
},
"status": {
"enum": [
"ok",
"pending",
"rejected"
]
},
"reason_code": {
"type": "string"
},
"payload": {
"type": "object"
}
},
"allOf": [
{
"if": {
"properties": {
"status": {
"const": "pending"
}
}
},
"then": {
"properties": {
"reason_code": {
"const": "waiting"
},
"payload": {
"type": "object",
"additionalProperties": false,
"required": [],
"properties": {}
}
}
}
},
{
"if": {
"properties": {
"status": {
"const": "rejected"
}
}
},
"then": {
"properties": {
"reason_code": {
"enum": [
"invalid_request",
"not_found",
"conflict",
"expired",
"not_authorized",
"unavailable",
"unsupported"
]
},
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"detail",
"retryable"
],
"properties": {
"detail": {
"type": "string",
"maxLength": 1024
},
"retryable": {
"type": "boolean"
}
}
}
}
}
},
{
"if": {
"properties": {
"status": {
"const": "ok"
},
"message_type": {
"const": "command.query.result"
}
}
},
"then": {
"properties": {
"reason_code": {
"const": "ok"
},
"payload": {
"$ref": "#/$defs/executor_Command"
}
}
}
},
{
"if": {
"properties": {
"status": {
"const": "ok"
},
"message_type": {
"const": "call.query.result"
}
}
},
"then": {
"properties": {
"reason_code": {
"const": "ok"
},
"payload": {
"$ref": "#/$defs/executor_Call"
}
}
}
},
{
"if": {
"properties": {
"status": {
"const": "ok"
},
"message_type": {
"const": "ai.config.result"
}
}
},
"then": {
"properties": {
"reason_code": {
"const": "ok"
},
"payload": {
"$ref": "#/$defs/aiConfigResult"
}
}
}
}
]
},
"taskControl": {
"type": "object",
"additionalProperties": false,
"required": [
"action",
"expected_task_revision",
"reason",
"task_id"
],
"properties": {
"action": {
"type": "string",
"enum": [
"pause",
"resume",
"stop"
]
},
"expected_task_revision": {
"type": "integer",
"minimum": 1
},
"active_call_policy": {
"type": "string",
"enum": [
"drain",
"hangup"
]
},
"reason": {
"type": "string",
"minLength": 1,
"maxLength": 512
},
"task_id": {
"$ref": "#/$defs/id"
}
}
},
"tenantKey": {
"type": "string",
"minLength": 1,
"maxLength": 196,
"not": {
"pattern": "(^|\\.)[*#](\\.|$)"
},
"$comment": "Runtime also enforces 196 UTF-8 bytes and each AMQP resource's 255-byte budget."
},
"time": {
"type": "string",
"format": "date-time"
}
}
}