aamp-sdk 0.1.5
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/README.md +43 -0
- package/dist/client.d.ts +91 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +196 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/jmap-push.d.ts +104 -0
- package/dist/jmap-push.d.ts.map +1 -0
- package/dist/jmap-push.js +634 -0
- package/dist/jmap-push.js.map +1 -0
- package/dist/parser.d.ts +65 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +187 -0
- package/dist/parser.js.map +1 -0
- package/dist/smtp-sender.d.ts +57 -0
- package/dist/smtp-sender.d.ts.map +1 -0
- package/dist/smtp-sender.js +282 -0
- package/dist/smtp-sender.js.map +1 -0
- package/dist/types.d.ts +168 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AAMP SDK Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
export type AampIntent = 'task.dispatch' | 'task.result' | 'task.help' | 'task.ack';
|
|
5
|
+
export type TaskStatus = 'pending' | 'running' | 'completed' | 'rejected' | 'failed' | 'timeout' | 'help_needed';
|
|
6
|
+
export declare const AAMP_HEADER: {
|
|
7
|
+
readonly INTENT: "X-AAMP-Intent";
|
|
8
|
+
readonly TASK_ID: "X-AAMP-TaskId";
|
|
9
|
+
readonly TIMEOUT: "X-AAMP-Timeout";
|
|
10
|
+
readonly CONTEXT_LINKS: "X-AAMP-ContextLinks";
|
|
11
|
+
readonly STATUS: "X-AAMP-Status";
|
|
12
|
+
readonly OUTPUT: "X-AAMP-Output";
|
|
13
|
+
readonly ERROR_MSG: "X-AAMP-ErrorMsg";
|
|
14
|
+
readonly STRUCTURED_RESULT: "X-AAMP-StructuredResult";
|
|
15
|
+
readonly QUESTION: "X-AAMP-Question";
|
|
16
|
+
readonly BLOCKED_REASON: "X-AAMP-BlockedReason";
|
|
17
|
+
readonly SUGGESTED_OPTIONS: "X-AAMP-SuggestedOptions";
|
|
18
|
+
readonly PARENT_TASK_ID: "X-AAMP-ParentTaskId";
|
|
19
|
+
};
|
|
20
|
+
export interface StructuredResultField {
|
|
21
|
+
fieldKey: string;
|
|
22
|
+
fieldTypeKey: string;
|
|
23
|
+
value?: unknown;
|
|
24
|
+
fieldAlias?: string;
|
|
25
|
+
index?: string;
|
|
26
|
+
attachmentFilenames?: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface TaskDispatch {
|
|
29
|
+
intent: 'task.dispatch';
|
|
30
|
+
taskId: string;
|
|
31
|
+
title: string;
|
|
32
|
+
timeoutSecs: number;
|
|
33
|
+
contextLinks: string[];
|
|
34
|
+
parentTaskId?: string;
|
|
35
|
+
from: string;
|
|
36
|
+
to: string;
|
|
37
|
+
messageId: string;
|
|
38
|
+
subject: string;
|
|
39
|
+
/** Plain-text body of the email (task description) */
|
|
40
|
+
bodyText: string;
|
|
41
|
+
/** Attachments received with this dispatch (use blobId to download) */
|
|
42
|
+
attachments?: ReceivedAttachment[];
|
|
43
|
+
}
|
|
44
|
+
export interface TaskResult {
|
|
45
|
+
intent: 'task.result';
|
|
46
|
+
taskId: string;
|
|
47
|
+
status: 'completed' | 'rejected';
|
|
48
|
+
output: string;
|
|
49
|
+
errorMsg?: string;
|
|
50
|
+
structuredResult?: StructuredResultField[];
|
|
51
|
+
from: string;
|
|
52
|
+
to: string;
|
|
53
|
+
/** True when the reply came from a standard email client (no X-AAMP-Intent header).
|
|
54
|
+
* taskId was resolved via In-Reply-To → Message-ID reverse lookup. */
|
|
55
|
+
isHumanReply?: boolean;
|
|
56
|
+
/** Attachments received with this result (use blobId to download) */
|
|
57
|
+
attachments?: ReceivedAttachment[];
|
|
58
|
+
}
|
|
59
|
+
export interface HumanReply {
|
|
60
|
+
/** Message-ID of the email being replied to — use this to look up the taskId */
|
|
61
|
+
inReplyTo: string;
|
|
62
|
+
/** This reply email's own Message-ID */
|
|
63
|
+
messageId: string;
|
|
64
|
+
from: string;
|
|
65
|
+
to: string;
|
|
66
|
+
subject: string;
|
|
67
|
+
/** Plain-text body of the reply */
|
|
68
|
+
bodyText: string;
|
|
69
|
+
}
|
|
70
|
+
export interface TaskHelp {
|
|
71
|
+
intent: 'task.help';
|
|
72
|
+
taskId: string;
|
|
73
|
+
question: string;
|
|
74
|
+
blockedReason: string;
|
|
75
|
+
suggestedOptions: string[];
|
|
76
|
+
from: string;
|
|
77
|
+
to: string;
|
|
78
|
+
}
|
|
79
|
+
export interface TaskAck {
|
|
80
|
+
intent: 'task.ack';
|
|
81
|
+
taskId: string;
|
|
82
|
+
from: string;
|
|
83
|
+
to: string;
|
|
84
|
+
}
|
|
85
|
+
/** Attachment for sending (binary content) */
|
|
86
|
+
export interface AampAttachment {
|
|
87
|
+
filename: string;
|
|
88
|
+
contentType: string;
|
|
89
|
+
content: Buffer | string;
|
|
90
|
+
size?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Attachment metadata received via JMAP (use blobId to download) */
|
|
93
|
+
export interface ReceivedAttachment {
|
|
94
|
+
filename: string;
|
|
95
|
+
contentType: string;
|
|
96
|
+
size: number;
|
|
97
|
+
blobId: string;
|
|
98
|
+
}
|
|
99
|
+
export type AampMessage = TaskDispatch | TaskResult | TaskHelp | TaskAck | HumanReply;
|
|
100
|
+
export interface AampClientConfig {
|
|
101
|
+
/** Node email address, e.g. codereviewer-abc123@aamp.yourdomain.com */
|
|
102
|
+
email: string;
|
|
103
|
+
/** Base64(email:smtpPassword) — returned by management service on agent creation */
|
|
104
|
+
jmapToken: string;
|
|
105
|
+
/** Stalwart base URL, e.g. http://localhost:8080 */
|
|
106
|
+
jmapUrl: string;
|
|
107
|
+
/** Optional HTTP send base URL. Defaults to jmapUrl and is used for same-domain send fallback via /api/send. */
|
|
108
|
+
httpSendBaseUrl?: string;
|
|
109
|
+
/** SMTP submission host */
|
|
110
|
+
smtpHost: string;
|
|
111
|
+
/** SMTP submission port (default: 587) */
|
|
112
|
+
smtpPort?: number;
|
|
113
|
+
/** SMTP password (returned by management service on agent creation) */
|
|
114
|
+
smtpPassword: string;
|
|
115
|
+
/** How often to retry failed JMAP connection (ms, default: 5000) */
|
|
116
|
+
reconnectInterval?: number;
|
|
117
|
+
/** Whether to reject unauthorized TLS certificates (default: true).
|
|
118
|
+
* Set to false only for development with self-signed certificates. */
|
|
119
|
+
rejectUnauthorized?: boolean;
|
|
120
|
+
}
|
|
121
|
+
export interface SendTaskOptions {
|
|
122
|
+
/** Target node email */
|
|
123
|
+
to: string;
|
|
124
|
+
title: string;
|
|
125
|
+
timeoutSecs?: number;
|
|
126
|
+
contextLinks?: string[];
|
|
127
|
+
parentTaskId?: string;
|
|
128
|
+
/** Attachments to include with the dispatch email */
|
|
129
|
+
attachments?: AampAttachment[];
|
|
130
|
+
}
|
|
131
|
+
export interface SendResultOptions {
|
|
132
|
+
/** Send to: the original from address of the dispatch email */
|
|
133
|
+
to: string;
|
|
134
|
+
taskId: string;
|
|
135
|
+
status: 'completed' | 'rejected';
|
|
136
|
+
output: string;
|
|
137
|
+
errorMsg?: string;
|
|
138
|
+
structuredResult?: StructuredResultField[];
|
|
139
|
+
/** Message-ID of the dispatch email, for In-Reply-To threading */
|
|
140
|
+
inReplyTo?: string;
|
|
141
|
+
/** Attachments to include with the result email */
|
|
142
|
+
attachments?: AampAttachment[];
|
|
143
|
+
}
|
|
144
|
+
export interface SendHelpOptions {
|
|
145
|
+
/** Send to: the original from address of the dispatch email */
|
|
146
|
+
to: string;
|
|
147
|
+
taskId: string;
|
|
148
|
+
question: string;
|
|
149
|
+
blockedReason: string;
|
|
150
|
+
suggestedOptions: string[];
|
|
151
|
+
/** Message-ID of the dispatch email, for In-Reply-To threading */
|
|
152
|
+
inReplyTo?: string;
|
|
153
|
+
/** Attachments to include with the help email */
|
|
154
|
+
attachments?: AampAttachment[];
|
|
155
|
+
}
|
|
156
|
+
export interface AampClientEvents {
|
|
157
|
+
'task.dispatch': (task: TaskDispatch) => void;
|
|
158
|
+
'task.result': (result: TaskResult) => void;
|
|
159
|
+
'task.help': (help: TaskHelp) => void;
|
|
160
|
+
'task.ack': (ack: TaskAck) => void;
|
|
161
|
+
/** Emitted when a standard email reply (no X-AAMP headers) is received for a known thread.
|
|
162
|
+
* Use inReplyTo to look up the taskId in your own store (Redis / DB). */
|
|
163
|
+
'reply': (reply: HumanReply) => void;
|
|
164
|
+
connected: () => void;
|
|
165
|
+
disconnected: (reason: string) => void;
|
|
166
|
+
error: (err: Error) => void;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAA;AAEnF,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,SAAS,GACT,WAAW,GACX,UAAU,GACV,QAAQ,GACR,SAAS,GACT,aAAa,CAAA;AAKjB,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAad,CAAA;AAEV,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC/B;AAKD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,C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M,KAAK,IAAI,CAAA;IACtC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;CAC5B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AAMP SDK Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
// =====================================================
|
|
5
|
+
// AAMP Header constants
|
|
6
|
+
// =====================================================
|
|
7
|
+
export const AAMP_HEADER = {
|
|
8
|
+
INTENT: 'X-AAMP-Intent',
|
|
9
|
+
TASK_ID: 'X-AAMP-TaskId',
|
|
10
|
+
TIMEOUT: 'X-AAMP-Timeout',
|
|
11
|
+
CONTEXT_LINKS: 'X-AAMP-ContextLinks',
|
|
12
|
+
STATUS: 'X-AAMP-Status',
|
|
13
|
+
OUTPUT: 'X-AAMP-Output',
|
|
14
|
+
ERROR_MSG: 'X-AAMP-ErrorMsg',
|
|
15
|
+
STRUCTURED_RESULT: 'X-AAMP-StructuredResult',
|
|
16
|
+
QUESTION: 'X-AAMP-Question',
|
|
17
|
+
BLOCKED_REASON: 'X-AAMP-BlockedReason',
|
|
18
|
+
SUGGESTED_OPTIONS: 'X-AAMP-SuggestedOptions',
|
|
19
|
+
PARENT_TASK_ID: 'X-AAMP-ParentTaskId',
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,wDAAwD;AACxD,wBAAwB;AACxB,wDAAwD;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,eAAe;IACxB,OAAO,EAAE,gBAAgB;IACzB,aAAa,EAAE,qBAAqB;IACpC,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,eAAe;IACvB,SAAS,EAAE,iBAAiB;IAC5B,iBAAiB,EAAE,yBAAyB;IAC5C,QAAQ,EAAE,iBAAiB;IAC3B,cAAc,EAAE,sBAAsB;IACtC,iBAAiB,EAAE,yBAAyB;IAC5C,cAAc,EAAE,qBAAqB;CAC7B,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aamp-sdk",
|
|
3
|
+
"files": [
|
|
4
|
+
"dist"
|
|
5
|
+
],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"version": "0.1.5",
|
|
8
|
+
"description": "AAMP SDK — Node.js client for Agent-to-Agent task collaboration over email",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "tsx watch src/index.ts",
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"lint": "eslint src --ext .ts"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"ws": "^8.16.0",
|
|
27
|
+
"nodemailer": "^6.9.10"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.11.30",
|
|
31
|
+
"@types/nodemailer": "^6.4.14",
|
|
32
|
+
"@types/ws": "^8.5.10",
|
|
33
|
+
"tsx": "^4.7.1",
|
|
34
|
+
"typescript": "^5.4.3",
|
|
35
|
+
"vitest": "^1.4.0"
|
|
36
|
+
}
|
|
37
|
+
}
|