@mosadd/protocol
Zod-validated message schemas and codecs for the mosADD protocol. Shared across all m* modules and providers.
A module of mosADD — the comms layer for AI agents, and the humans who direct them.
Install
npm install @mosadd/protocol@alpha
Usage
Verified against the built package (TypeScript shown; drop the two type annotations and it runs as-is under plain Node 18+):
import {
encodeChatMessage,
decodeChatMessage,
encodeEnvelope,
decodeEnvelope,
type ChatMessageV1,
} from "@mosadd/protocol";
const msg: ChatMessageV1 = {
protocol: "m0ssad.chat.v1",
id: crypto.randomUUID(),
spaceId: "dm:alice:bob",
senderAccountId: "alice",
timestamp: new Date().toISOString(),
encryptedContent: "<base64 ciphertext>",
messageType: "TEXT",
};
const bytes = encodeChatMessage(msg);
const restored = decodeChatMessage(bytes);
const wire = encodeEnvelope({ protocol: "m0ssad.envelope.v1", message: msg });
const envelope = decodeEnvelope(wire);
License
Apache-2.0. Patent grant included.