agent-mailbox-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/database.d.ts +7 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/format.d.ts +10 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +556 -0
- package/dist/mailbox.d.ts +66 -0
- package/dist/mailbox.d.ts.map +1 -0
- package/dist/plugin.d.ts +149 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +13111 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +63 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for Agent Mailbox
|
|
3
|
+
*/
|
|
4
|
+
/** Message priority levels */
|
|
5
|
+
export type Priority = "high" | "normal" | "low";
|
|
6
|
+
/** Message delivery status */
|
|
7
|
+
export type DeliveryStatus = "pending" | "delivered" | "read" | "acked" | "expired" | "dead";
|
|
8
|
+
/** Configuration options for the mailbox */
|
|
9
|
+
export interface MailboxConfig {
|
|
10
|
+
/** Path to SQLite database file. Defaults to ':memory:' */
|
|
11
|
+
dbPath?: string;
|
|
12
|
+
/** Default message TTL in seconds. Defaults to 86400 (24h) */
|
|
13
|
+
defaultTTL?: number;
|
|
14
|
+
/** Visibility timeout in seconds after message is fetched. Defaults to 300 (5min) */
|
|
15
|
+
visibilityTimeout?: number;
|
|
16
|
+
/** Max retry attempts before moving to DLQ. Defaults to 3 */
|
|
17
|
+
maxRetries?: number;
|
|
18
|
+
/** Max message body size in bytes. Defaults to 65536 (64KB) */
|
|
19
|
+
maxBodySize?: number;
|
|
20
|
+
/** Rate limit: max messages per agent per minute. Defaults to 60 */
|
|
21
|
+
rateLimitPerMinute?: number;
|
|
22
|
+
/** Enable WAL mode for better concurrency. Defaults to true */
|
|
23
|
+
walMode?: boolean;
|
|
24
|
+
/** Cleanup interval in seconds. 0 disables auto-cleanup. Defaults to 300 (5min) */
|
|
25
|
+
cleanupInterval?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Resolved config with all defaults applied */
|
|
28
|
+
export interface ResolvedConfig {
|
|
29
|
+
dbPath: string;
|
|
30
|
+
defaultTTL: number;
|
|
31
|
+
visibilityTimeout: number;
|
|
32
|
+
maxRetries: number;
|
|
33
|
+
maxBodySize: number;
|
|
34
|
+
rateLimitPerMinute: number;
|
|
35
|
+
walMode: boolean;
|
|
36
|
+
cleanupInterval: number;
|
|
37
|
+
}
|
|
38
|
+
/** A message in the mailbox */
|
|
39
|
+
export interface Message {
|
|
40
|
+
id: number;
|
|
41
|
+
from_agent: string;
|
|
42
|
+
to_agent: string;
|
|
43
|
+
subject: string;
|
|
44
|
+
body: string;
|
|
45
|
+
thread_id: string;
|
|
46
|
+
priority: Priority;
|
|
47
|
+
status: DeliveryStatus;
|
|
48
|
+
ttl_seconds: number;
|
|
49
|
+
idempotency_key: string | null;
|
|
50
|
+
trace_id: string | null;
|
|
51
|
+
receive_count: number;
|
|
52
|
+
visible_after: string | null;
|
|
53
|
+
session_id: string;
|
|
54
|
+
created_at: string;
|
|
55
|
+
read_at: string | null;
|
|
56
|
+
ack_at: string | null;
|
|
57
|
+
expires_at: string;
|
|
58
|
+
}
|
|
59
|
+
/** Options for sending a message */
|
|
60
|
+
export interface SendOptions {
|
|
61
|
+
from: string;
|
|
62
|
+
to: string;
|
|
63
|
+
subject: string;
|
|
64
|
+
body: string;
|
|
65
|
+
threadId?: string;
|
|
66
|
+
priority?: Priority;
|
|
67
|
+
ttlSeconds?: number;
|
|
68
|
+
idempotencyKey?: string;
|
|
69
|
+
traceId?: string;
|
|
70
|
+
sessionId?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Options for reading inbox */
|
|
73
|
+
export interface InboxOptions {
|
|
74
|
+
agent: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
includeRead?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** Options for searching messages */
|
|
79
|
+
export interface SearchOptions {
|
|
80
|
+
query: string;
|
|
81
|
+
limit?: number;
|
|
82
|
+
agent?: string;
|
|
83
|
+
}
|
|
84
|
+
/** A conversation thread */
|
|
85
|
+
export interface Thread {
|
|
86
|
+
id: string;
|
|
87
|
+
subject: string;
|
|
88
|
+
participants: string;
|
|
89
|
+
message_count: number;
|
|
90
|
+
unread_count: number;
|
|
91
|
+
last_message_at: string;
|
|
92
|
+
}
|
|
93
|
+
/** Result of sending a message */
|
|
94
|
+
export interface SendResult {
|
|
95
|
+
messageId: number;
|
|
96
|
+
threadId: string;
|
|
97
|
+
idempotencyKey: string | null;
|
|
98
|
+
}
|
|
99
|
+
/** Dead letter entry */
|
|
100
|
+
export interface DeadLetter {
|
|
101
|
+
id: number;
|
|
102
|
+
original_message_id: number;
|
|
103
|
+
from_agent: string;
|
|
104
|
+
to_agent: string;
|
|
105
|
+
subject: string;
|
|
106
|
+
body: string;
|
|
107
|
+
thread_id: string;
|
|
108
|
+
reason: string;
|
|
109
|
+
moved_at: string;
|
|
110
|
+
}
|
|
111
|
+
/** Metrics snapshot */
|
|
112
|
+
export interface MailboxMetrics {
|
|
113
|
+
totalMessages: number;
|
|
114
|
+
pendingMessages: number;
|
|
115
|
+
deliveredMessages: number;
|
|
116
|
+
deadLetters: number;
|
|
117
|
+
activeThreads: number;
|
|
118
|
+
messagesPerAgent: Record<string, number>;
|
|
119
|
+
avgDeliveryTimeMs: number | null;
|
|
120
|
+
}
|
|
121
|
+
/** Agent info for registry */
|
|
122
|
+
export interface AgentInfo {
|
|
123
|
+
name: string;
|
|
124
|
+
role?: string;
|
|
125
|
+
lastActive: string | null;
|
|
126
|
+
messageCount: number;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.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rB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,wBAAwB;AACxB,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,uBAAuB;AACvB,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,8BAA8B;AAC9B,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-mailbox-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Production-grade inter-agent messaging for multi-agent AI systems. SQLite-backed with FTS5 search, visibility timeouts, dead letter queues, typed payloads, and more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./plugin": {
|
|
14
|
+
"import": "./dist/plugin.js",
|
|
15
|
+
"types": "./dist/plugin.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "bun build ./src/index.ts --outdir dist --target bun && bun build ./src/plugin.ts --outdir dist --target bun && bun x tsc --emitDeclarationOnly --outDir dist",
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"lint": "bun x tsc --noEmit",
|
|
27
|
+
"prepublishOnly": "bun run build"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"agent",
|
|
31
|
+
"mailbox",
|
|
32
|
+
"multi-agent",
|
|
33
|
+
"messaging",
|
|
34
|
+
"sqlite",
|
|
35
|
+
"fts5",
|
|
36
|
+
"queue",
|
|
37
|
+
"ai",
|
|
38
|
+
"llm",
|
|
39
|
+
"opencode",
|
|
40
|
+
"plugin",
|
|
41
|
+
"inter-agent",
|
|
42
|
+
"communication"
|
|
43
|
+
],
|
|
44
|
+
"author": "lleontor705",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/lleontor705/agent-mailbox.git"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@opencode-ai/plugin": ">=1.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@opencode-ai/plugin": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@opencode-ai/plugin": "^1.2.26",
|
|
60
|
+
"@types/bun": "^1.2.0",
|
|
61
|
+
"typescript": "^5.7.0"
|
|
62
|
+
}
|
|
63
|
+
}
|