Files
go-sip/contracts/local/mq.schema.json
T

106 lines
7.1 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://go-sip.local/contracts/current/mq.schema.json",
"title": "Project-local Dispatcher MQ messages; external SaaS compatibility unverified",
"oneOf": [
{"$ref": "#/$defs/sip_change"},
{"$ref": "#/$defs/control_in"},
{"$ref": "#/$defs/control_ack"},
{"$ref": "#/$defs/execute_in"},
{"$ref": "#/$defs/execute_ack"},
{"$ref": "#/$defs/execute_result"}
],
"$defs": {
"event_id": {"type": "string", "minLength": 1},
"dispatcher_id": {"type": "string", "format": "uuid"},
"tenant_id": {"type": "integer", "minimum": 1},
"issued_at": {"type": "string", "format": "date-time"},
"task_id": {"type": "string", "pattern": "^[A-Za-z0-9_-]{1,128}$"},
"sip_change": {
"type": "object", "additionalProperties": false,
"required": ["event_id", "event_type", "dispatcher_id", "payload"],
"properties": {
"event_id": {"$ref": "#/$defs/event_id"},
"event_type": {"const": "sip.config"},
"dispatcher_id": {"$ref": "#/$defs/dispatcher_id"},
"payload": {"type": "object", "additionalProperties": false, "required": ["trunk_id", "change_type", "revision"], "properties": {
"trunk_id": {"type": "string", "minLength": 1}, "change_type": {"enum": ["enabled", "disabled", "removed", "created"]}, "revision": {"type": "integer", "minimum": 1}
}}
}
},
"control_in": {
"type": "object", "additionalProperties": false,
"required": ["event_id", "event_type", "dispatcher_id", "tenant_id", "issued_at", "payload"],
"properties": {
"event_id": {"$ref": "#/$defs/event_id"}, "event_type": {"const": "task.control"}, "dispatcher_id": {"$ref": "#/$defs/dispatcher_id"}, "tenant_id": {"$ref": "#/$defs/tenant_id"}, "issued_at": {"$ref": "#/$defs/issued_at"},
"payload": {"type": "object", "additionalProperties": false, "required": ["task_id", "action", "reason"], "properties": {
"task_id": {"$ref": "#/$defs/task_id"}, "action": {"enum": ["pause", "resume", "stop"]}, "reason": {"type": "string", "minLength": 1},
"options": {"type": "object", "additionalProperties": false, "properties": {"active_call_policy": {"enum": ["drain", "hangup"]}}}
}}
}
},
"control_ack": {
"type": "object", "additionalProperties": false,
"required": ["event_id", "event_type", "dispatcher_id", "tenant_id", "payload"],
"properties": {
"event_id": {"$ref": "#/$defs/event_id"}, "event_type": {"const": "task.control"}, "dispatcher_id": {"$ref": "#/$defs/dispatcher_id"}, "tenant_id": {"$ref": "#/$defs/tenant_id"},
"payload": {"type": "object", "additionalProperties": false, "required": ["status"], "properties": {"status": {"type": "string", "minLength": 1}}}
}
},
"execute_in": {
"type": "object", "additionalProperties": false,
"required": ["event_id", "event_type", "dispatcher_id", "tenant_id", "issued_at", "payload"],
"properties": {
"event_id": {"$ref": "#/$defs/event_id"}, "event_type": {"const": "call.execute"}, "dispatcher_id": {"$ref": "#/$defs/dispatcher_id"}, "tenant_id": {"$ref": "#/$defs/tenant_id"}, "issued_at": {"$ref": "#/$defs/issued_at"},
"payload": {"type": "object", "additionalProperties": false, "required": ["task_id", "callee"], "properties": {"task_id": {"$ref": "#/$defs/task_id"}, "callee": {"type": "string", "minLength": 1}}}
}
},
"execute_ack": {
"type": "object", "additionalProperties": false,
"required": ["event_id", "event_type", "dispatcher_id", "tenant_id", "issued_at", "payload"],
"properties": {
"event_id": {"$ref": "#/$defs/event_id"}, "event_type": {"const": "call.execute"}, "dispatcher_id": {"$ref": "#/$defs/dispatcher_id"}, "tenant_id": {"$ref": "#/$defs/tenant_id"}, "issued_at": {"$ref": "#/$defs/issued_at"},
"payload": {"oneOf": [
{"type": "object", "additionalProperties": false, "required": ["status"], "properties": {"status": {"const": "dispatched"}}},
{"type": "object", "additionalProperties": false, "required": ["status", "reason_code", "reason_message"], "properties": {"status": {"const": "rejected"}, "reason_code": {"type": "null"}, "reason_message": {"type": "string", "minLength": 1}}}
]}
}
},
"execute_result": {
"type": "object", "additionalProperties": false,
"required": ["event_id", "event_type", "dispatcher_id", "tenant_id", "issued_at", "payload"],
"properties": {
"event_id": {"$ref": "#/$defs/event_id"}, "event_type": {"const": "call.execute.result"}, "dispatcher_id": {"$ref": "#/$defs/dispatcher_id"}, "tenant_id": {"$ref": "#/$defs/tenant_id"}, "issued_at": {"$ref": "#/$defs/issued_at"},
"payload": {"type": "object", "additionalProperties": false,
"required": ["task_id", "caller_profile_id", "callee", "trunk_id", "started_at", "ended_at", "duration_ms", "outcome", "reason_code", "transcript", "opt_out", "recording"],
"properties": {
"task_id": {"$ref": "#/$defs/task_id"}, "caller_profile_id": {"type": "string", "minLength": 1}, "callee": {"type": "string", "minLength": 1}, "trunk_id": {"type": "string", "minLength": 1},
"started_at": {"$ref": "#/$defs/issued_at"}, "ended_at": {"$ref": "#/$defs/issued_at"}, "duration_ms": {"type": "integer", "minimum": 0},
"outcome": {"enum": ["answered", "no_answer", "failed"]},
"reason_code": {"type": ["integer", "null"], "minimum": 100, "maximum": 699},
"reason_message": {"type": "string", "minLength": 1},
"transcript": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["turn_id", "segment_id", "role", "text", "start_ms", "end_ms"], "properties": {
"turn_id": {"type": "string", "minLength": 1}, "segment_id": {"type": "string", "minLength": 1}, "role": {"enum": ["user", "assistant"]}, "text": {"type": "string"}, "start_ms": {"type": "integer", "minimum": 0}, "end_ms": {"type": "integer", "minimum": 0}
}}},
"opt_out": {"type": "boolean"},
"recording": {"oneOf": [
{"type": "object", "additionalProperties": false, "maxProperties": 0},
{"$ref": "#/$defs/recording_uploaded"}
]}
},
"allOf": [
{"if": {"properties": {"reason_code": {"type": "null"}}, "required": ["reason_code"]}, "then": {"required": ["reason_message"]}}
]
}
}
},
"recording_uploaded": {
"type": "object", "additionalProperties": false,
"required": ["status", "bucket", "object_key", "format", "channels", "sample_rate_hz", "duration_ms", "size_bytes", "checksum_sha256"],
"properties": {
"status": {"const": "uploaded"}, "bucket": {"type": "string", "minLength": 1}, "object_key": {"type": "string", "minLength": 1}, "format": {"type": "string", "minLength": 1}, "channels": {"type": "integer", "minimum": 1}, "sample_rate_hz": {"type": "integer", "minimum": 1}, "duration_ms": {"type": "integer", "minimum": 0}, "size_bytes": {"type": "integer", "minimum": 0}, "checksum_sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
}
}
}
}