{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://mas.coulomb.social/schema/mas-modes-v0.1.schema.json", "title": "MAS mode contract v0.1 message", "type": "object", "required": [ "type" ], "properties": { "type": { "enum": [ "handoff.request", "handoff.update", "handoff.cancel", "handoff.status", "case.intake", "case.assign", "case.message", "case.policy", "handoff.requested", "mail.send" ] } }, "allOf": [ { "if": { "properties": { "type": { "const": "handoff.request" } } }, "then": { "$ref": "#/$defs/handoff.request" } }, { "if": { "properties": { "type": { "const": "handoff.update" } } }, "then": { "$ref": "#/$defs/handoff.update" } }, { "if": { "properties": { "type": { "const": "handoff.cancel" } } }, "then": { "$ref": "#/$defs/handoff.cancel" } }, { "if": { "properties": { "type": { "const": "handoff.status" } } }, "then": { "$ref": "#/$defs/handoff.status" } }, { "if": { "properties": { "type": { "const": "case.intake" } } }, "then": { "$ref": "#/$defs/case.intake" } }, { "if": { "properties": { "type": { "const": "case.assign" } } }, "then": { "$ref": "#/$defs/case.assign" } }, { "if": { "properties": { "type": { "const": "case.message" } } }, "then": { "$ref": "#/$defs/case.message" } }, { "if": { "properties": { "type": { "const": "case.policy" } } }, "then": { "$ref": "#/$defs/case.policy" } }, { "if": { "properties": { "type": { "const": "handoff.requested" } } }, "then": { "$ref": "#/$defs/handoff.requested" } }, { "if": { "properties": { "type": { "const": "mail.send" } } }, "then": { "$ref": "#/$defs/mail.send" } } ], "$defs": { "case": { "type": "object", "required": [ "address", "key" ], "properties": { "address": { "type": "string", "minLength": 1 }, "key": { "type": "string", "minLength": 1 } }, "additionalProperties": false }, "status": { "enum": [ "requested", "negotiating", "scheduled", "attempted", "running", "completed", "failed", "expired", "refused", "cancelled", "timed-out" ] }, "handoff.request": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "handoff_id", "mode", "details", "status_url" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "handoff.request" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "handoff_id": { "type": "string", "minLength": 1 }, "mode": { "type": "string", "minLength": 1 }, "details": { "type": "object", "additionalProperties": { "type": [ "string", "number", "boolean" ] } }, "status_url": { "type": "string", "format": "uri" }, "participant": { "type": "object", "required": [ "address" ], "properties": { "address": { "type": "string", "minLength": 1 } }, "additionalProperties": false } }, "additionalProperties": false }, "handoff.update": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "handoff_id", "details" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "handoff.update" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "handoff_id": { "type": "string", "minLength": 1 }, "details": { "type": "object", "additionalProperties": { "type": [ "string", "number", "boolean" ] } } }, "additionalProperties": false }, "handoff.cancel": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "handoff_id" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "handoff.cancel" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "handoff_id": { "type": "string", "minLength": 1 }, "reason": { "type": "string", "minLength": 1 } }, "additionalProperties": false }, "handoff.status": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "handoff_id", "seq", "status" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "handoff.status" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "handoff_id": { "type": "string", "minLength": 1 }, "seq": { "type": "integer", "minimum": 1 }, "status": { "$ref": "#/$defs/status" }, "needs": { "type": "array", "items": { "type": "string", "minLength": 1 }, "minItems": 1 }, "at": { "type": "string" }, "outcome": { "type": "string", "minLength": 1 }, "reason": { "type": "string", "minLength": 1 }, "detail": { "type": "string" } }, "additionalProperties": false, "allOf": [ { "if": { "properties": { "status": { "const": "negotiating" } } }, "then": { "required": [ "needs" ] } }, { "if": { "properties": { "status": { "const": "refused" } } }, "then": { "required": [ "reason" ], "properties": { "reason": { "enum": [ "mode-unavailable", "mode-not-enabled", "declined", "out-of-hours", "blocked" ] } } } }, { "if": { "properties": { "status": { "const": "attempted" } } }, "then": { "required": [ "outcome" ] } } ] }, "case.intake": { "type": "object", "required": [ "mas_modes_version", "type", "id", "intake_ref", "resource_type", "event" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "case.intake" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "intake_ref": { "type": "string", "minLength": 1 }, "resource_type": { "type": "string", "minLength": 1 }, "event": { "type": "object" }, "requested_mode": { "type": [ "string", "null" ] } }, "additionalProperties": false }, "case.assign": { "type": "object", "required": [ "mas_modes_version", "type", "id", "intake_ref", "resource_id" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "case.assign" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "intake_ref": { "type": "string", "minLength": 1 }, "resource_id": { "type": "string", "minLength": 1 }, "policy": { "$ref": "#/$defs/policy" } }, "additionalProperties": false }, "case.message": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "event", "message_ref" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "case.message" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "event": { "type": "object" }, "message_ref": { "type": "string", "minLength": 1 } }, "additionalProperties": false }, "case.policy": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "case.policy" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "autonomous_send": { "type": "boolean" }, "transfers": { "$ref": "#/$defs/policy/properties/transfers" } }, "additionalProperties": false }, "handoff.requested": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "handoff_id", "mode", "forwarded" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "handoff.requested" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "handoff_id": { "type": "string", "minLength": 1 }, "mode": { "type": "string", "minLength": 1 }, "forwarded": { "type": "boolean" } }, "additionalProperties": false }, "mail.send": { "type": "object", "required": [ "mas_modes_version", "type", "id", "case", "in_reply_to", "body" ], "properties": { "mas_modes_version": { "const": "0.1" }, "type": { "const": "mail.send" }, "id": { "type": "string", "minLength": 1 }, "case": { "$ref": "#/$defs/case" }, "in_reply_to": { "type": "string", "minLength": 1 }, "subject": { "type": "string", "minLength": 1 }, "body": { "type": "string" } }, "additionalProperties": false }, "policy": { "type": "object", "properties": { "autonomous_send": { "type": "boolean" }, "transfers": { "oneOf": [ { "const": "block" }, { "type": "object", "required": [ "webhook", "peer" ], "properties": { "webhook": { "type": "string", "format": "uri" }, "peer": { "type": "string", "minLength": 1 } }, "additionalProperties": false } ] } }, "additionalProperties": false } } }