Skip to main content

SCHEMA_JSON

Constant SCHEMA_JSON 

Source
pub const SCHEMA_JSON: &str = "{\n  \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n  \"$id\": \"https://agent-protocols.dev/schemas/agent-mail/1.0.schema.json\",\n  \"title\": \"Agent Mail Protocol 1.0\",\n  \"description\": \"Structural definitions for owner-signed cards, sender-signed encrypted packets, plaintext messages and HTTP records. Signatures, sender/recipient/AAD binding, canonical encoding, time, size, sender policy and logical message deduplication require semantic validation.\",\n  \"$defs\": {\n    \"agentId\": {\n      \"type\": \"string\",\n      \"pattern\": \"^did:agent:[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$(?![\\\\s\\\\S])\"\n    },\n    \"hash32\": {\n      \"type\": \"string\",\n      \"pattern\": \"^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$(?![\\\\s\\\\S])\"\n    },\n    \"id16\": {\n      \"type\": \"string\",\n      \"pattern\": \"^[A-Za-z0-9_-]{21}[AQgw]$(?![\\\\s\\\\S])\"\n    },\n    \"signature\": {\n      \"type\": \"string\",\n      \"pattern\": \"^[A-Za-z0-9_-]{85}[AQgw]$(?![\\\\s\\\\S])\"\n    },\n    \"base64url\": {\n      \"type\": \"string\",\n      \"pattern\": \"^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-][AQgw]|[A-Za-z0-9_-]{2}[AEIMQUYcgkosw048])?$(?![\\\\s\\\\S])\"\n    },\n    \"timestampMs\": {\n      \"type\": \"integer\",\n      \"minimum\": 0,\n      \"maximum\": 9007199254740991\n    },\n    \"positiveSafeInteger\": {\n      \"type\": \"integer\",\n      \"minimum\": 1,\n      \"maximum\": 9007199254740991\n    },\n    \"httpsOrigin\": {\n      \"type\": \"string\",\n      \"pattern\": \"^https://[^/?#@\\\\s]+$(?![\\\\s\\\\S])\",\n      \"not\": {\n        \"pattern\": \":443$(?![\\\\s\\\\S])\"\n      },\n      \"description\": \"Approximate syntax only. Identity canonical HTTPS origin parsing and serialization are a semantic requirement.\"\n    },\n    \"mailboxCardPayload\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"mailbox_id\",\n        \"expires_at\",\n        \"receive_until\",\n        \"public_key\",\n        \"routes\",\n        \"max_packet_bytes\"\n      ],\n      \"properties\": {\n        \"mailbox_id\": {\n          \"$ref\": \"#/$defs/id16\"\n        },\n        \"expires_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"receive_until\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"public_key\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"routes\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/$defs/httpsOrigin\"\n          },\n          \"minItems\": 0,\n          \"maxItems\": 8,\n          \"uniqueItems\": true\n        },\n        \"max_packet_bytes\": {\n          \"type\": \"integer\",\n          \"minimum\": 4096,\n          \"maximum\": 1048576\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"part\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"media_type\",\n        \"data\"\n      ],\n      \"properties\": {\n        \"media_type\": {\n          \"type\": \"string\",\n          \"maxLength\": 127,\n          \"pattern\": \"^[a-z0-9][a-z0-9!#$&^_.+\\\\-]*/[a-z0-9][a-z0-9!#$&^_.+\\\\-]*$(?![\\\\s\\\\S])\"\n        },\n        \"data\": {\n          \"$ref\": \"#/$defs/base64url\"\n        },\n        \"name\": {\n          \"type\": \"string\",\n          \"minLength\": 1,\n          \"maxLength\": 255\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"messagePayload\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"message_id\",\n        \"from\",\n        \"created_at\",\n        \"to\",\n        \"expires_at\",\n        \"thread_id\",\n        \"parts\"\n      ],\n      \"properties\": {\n        \"message_id\": {\n          \"$ref\": \"#/$defs/id16\"\n        },\n        \"from\": {\n          \"$ref\": \"#/$defs/agentId\"\n        },\n        \"created_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"to\": {\n          \"$ref\": \"#/$defs/agentId\"\n        },\n        \"expires_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"thread_id\": {\n          \"$ref\": \"#/$defs/id16\"\n        },\n        \"parts\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/$defs/part\"\n          },\n          \"minItems\": 1,\n          \"maxItems\": 32\n        },\n        \"subject\": {\n          \"type\": \"string\",\n          \"maxLength\": 1024\n        },\n        \"in_reply_to\": {\n          \"$ref\": \"#/$defs/id16\"\n        },\n        \"reply_card\": {\n          \"$ref\": \"#/$defs/mailboxCardEnvelope\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"mailboxCardEvent\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"protocol\",\n        \"type\",\n        \"actor\",\n        \"created_at\",\n        \"nonce\",\n        \"payload\"\n      ],\n      \"properties\": {\n        \"protocol\": {\n          \"const\": \"agent-mail/1.0\"\n        },\n        \"type\": {\n          \"const\": \"mailbox.publish\"\n        },\n        \"actor\": {\n          \"$ref\": \"#/$defs/agentId\"\n        },\n        \"created_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"nonce\": {\n          \"$ref\": \"#/$defs/positiveSafeInteger\"\n        },\n        \"payload\": {\n          \"$ref\": \"#/$defs/mailboxCardPayload\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"mailboxCardEnvelope\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"event\",\n        \"hash\",\n        \"signature\"\n      ],\n      \"properties\": {\n        \"event\": {\n          \"$ref\": \"#/$defs/mailboxCardEvent\"\n        },\n        \"hash\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"signature\": {\n          \"$ref\": \"#/$defs/signature\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"envelope\": {\n      \"oneOf\": [\n        {\n          \"$ref\": \"#/$defs/mailboxCardEnvelope\"\n        },\n        {\n          \"$ref\": \"#/$defs/packetEnvelope\"\n        }\n      ]\n    },\n    \"packetHeader\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"mailbox_id\",\n        \"card_hash\",\n        \"expires_at\"\n      ],\n      \"properties\": {\n        \"mailbox_id\": {\n          \"$ref\": \"#/$defs/id16\"\n        },\n        \"card_hash\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"expires_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"packetPayload\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"header\",\n        \"enc\",\n        \"ciphertext\"\n      ],\n      \"properties\": {\n        \"header\": {\n          \"$ref\": \"#/$defs/packetHeader\"\n        },\n        \"enc\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"ciphertext\": {\n          \"allOf\": [\n            {\n              \"$ref\": \"#/$defs/base64url\"\n            }\n          ],\n          \"minLength\": 1387,\n          \"maxLength\": 1048576,\n          \"description\": \"Decoded length must be >= 1040 and 16 modulo 1024. Total JCS(packet) length must fit the card and protocol limits; these are semantic checks.\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"cardAcceptedRecord\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"envelope\",\n        \"accepted_at\"\n      ],\n      \"properties\": {\n        \"envelope\": {\n          \"$ref\": \"#/$defs/mailboxCardEnvelope\"\n        },\n        \"accepted_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"deliveryResult\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"packet_id\",\n        \"accepted_at\"\n      ],\n      \"properties\": {\n        \"packet_id\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"accepted_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"packetRecord\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"packet_id\",\n        \"packet\",\n        \"accepted_at\",\n        \"seq\"\n      ],\n      \"properties\": {\n        \"packet_id\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"packet\": {\n          \"$ref\": \"#/$defs/packetEnvelope\"\n        },\n        \"accepted_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"seq\": {\n          \"$ref\": \"#/$defs/positiveSafeInteger\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"packetList\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"result\"\n      ],\n      \"properties\": {\n        \"result\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/$defs/packetRecord\"\n          },\n          \"minItems\": 0,\n          \"maxItems\": 1000\n        },\n        \"next_cursor\": {\n          \"type\": \"string\",\n          \"minLength\": 1\n        }\n      },\n      \"additionalProperties\": true\n    },\n    \"discoveryDocument\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"protocol\",\n        \"service\"\n      ],\n      \"properties\": {\n        \"protocol\": {\n          \"const\": \"agent-mail/1.0\"\n        },\n        \"service\": {\n          \"$ref\": \"#/$defs/httpsOrigin\"\n        },\n        \"features\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"uniqueItems\": true\n        }\n      },\n      \"additionalProperties\": true,\n      \"description\": \"Mail defines no endpoint names; delivery paths are fixed at each card route. Other members are inert extensions.\"\n    },\n    \"packetEvent\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"protocol\",\n        \"type\",\n        \"actor\",\n        \"created_at\",\n        \"nonce\",\n        \"payload\"\n      ],\n      \"properties\": {\n        \"protocol\": {\n          \"const\": \"agent-mail/1.0\"\n        },\n        \"type\": {\n          \"const\": \"mail.submit\"\n        },\n        \"actor\": {\n          \"$ref\": \"#/$defs/agentId\"\n        },\n        \"created_at\": {\n          \"$ref\": \"#/$defs/timestampMs\"\n        },\n        \"nonce\": {\n          \"$ref\": \"#/$defs/positiveSafeInteger\"\n        },\n        \"payload\": {\n          \"$ref\": \"#/$defs/packetPayload\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"packetEnvelope\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"event\",\n        \"hash\",\n        \"signature\"\n      ],\n      \"properties\": {\n        \"event\": {\n          \"$ref\": \"#/$defs/packetEvent\"\n        },\n        \"hash\": {\n          \"$ref\": \"#/$defs/hash32\"\n        },\n        \"signature\": {\n          \"$ref\": \"#/$defs/signature\"\n        }\n      },\n      \"additionalProperties\": false\n    }\n  },\n  \"$ref\": \"#/$defs/envelope\"\n}\n";