@skillkit/messaging

Inter-agent messaging for SkillKit - Asynchronous communication between AI agents across the mesh network.
Installation
npm install @skillkit/messaging
Key Features
- Agent-to-Agent Messaging: Send messages between AI coding agents
- Inbox/Outbox Pattern: Persistent message storage with read tracking
- Message Threading: Reply chains and conversation threads
- Priority Levels: Urgent, normal, and low priority messages
- Mesh Integration: Built on @skillkit/mesh for secure delivery
- Offline Queuing: Messages queued when recipient offline
- Message Archiving: Archive old messages for reference
Usage
Initialize Messaging
import { MessagingClient } from '@skillkit/messaging';
import { MeshHost } from '@skillkit/mesh';
const messaging = new MessagingClient({
meshHost: host,
storagePath: '~/.skillkit/messages',
});
await messaging.init();
Send Messages
await messaging.send({
to: 'claude@laptop',
subject: 'Code review completed',
body: 'I reviewed the authentication module. See attached suggestions.',
priority: 'normal',
attachments: [{ type: 'diff', content: '...' }],
});
await messaging.reply(messageId, {
body: 'Thanks! I will apply the suggestions.',
});
Read Inbox
const inbox = await messaging.getInbox({
unreadOnly: false,
limit: 20,
});
const unreadCount = await messaging.getUnreadCount();
const message = await messaging.read(messageId);
await messaging.markAsRead(messageId);
Message Management
await messaging.archive(messageId);
const sent = await messaging.getSent({ limit: 10 });
await messaging.delete(messageId);
const results = await messaging.search('authentication');
Event Handling
messaging.on('message', (msg) => {
console.log('New message from:', msg.from);
console.log('Subject:', msg.subject);
});
messaging.on('delivered', (msgId) => {
console.log('Message delivered:', msgId);
});
API Reference
MessagingClient
interface MessagingClient {
init(): Promise<void>;
send(message: OutgoingMessage): Promise<string>;
reply(messageId: string, reply: ReplyMessage): Promise<string>;
getInbox(options?: InboxOptions): Promise<Message[]>;
getSent(options?: SentOptions): Promise<Message[]>;
read(messageId: string): Promise<Message>;
markAsRead(messageId: string): Promise<void>;
archive(messageId: string): Promise<void>;
delete(messageId: string): Promise<void>;
search(query: string): Promise<Message[]>;
getUnreadCount(): Promise<number>;
on(event: 'message' | 'delivered' | 'error', handler: Function): void;
close(): Promise<void>;
}
Types
interface Message {
id: string;
from: string;
to: string;
subject: string;
body: string;
priority: 'urgent' | 'normal' | 'low';
timestamp: Date;
read: boolean;
archived: boolean;
threadId?: string;
attachments?: Attachment[];
}
interface OutgoingMessage {
to: string;
subject: string;
body: string;
priority?: 'urgent' | 'normal' | 'low';
threadId?: string;
attachments?: Attachment[];
}
interface Attachment {
type: 'file' | 'diff' | 'skill' | 'code';
name?: string;
content: string;
}
interface InboxOptions {
unreadOnly?: boolean;
limit?: number;
offset?: number;
since?: Date;
}
CLI Commands
skillkit message send
skillkit message inbox
skillkit message read <id>
skillkit message reply <id>
skillkit message archive <id>
skillkit message sent
skillkit message status
Documentation
Full documentation: https://github.com/rohitg00/skillkit
License
Apache-2.0