@aimail/mail 0.1.0-rc.7
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/lib/index.d.ts +34 -0
- package/lib/index.js +40 -0
- package/package.json +37 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aimail/mail — host-layer AgentMail service (ctx.mail).
|
|
3
|
+
*
|
|
4
|
+
* Provides per-session agentmail config resolution for tool-mail / mail-inbound:
|
|
5
|
+
* session_id (exec.agent.id) → agentmail.json → ToolCtx {systemId, email}.
|
|
6
|
+
* Config identity = agentmail.json only (single source of truth); the optional
|
|
7
|
+
* AMAIL_SYSTEM_ID env narrows the scan scope.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
10
|
+
import { type AgentConfig } from '@aimail/mail-core';
|
|
11
|
+
export declare const name = "mail";
|
|
12
|
+
export declare const inject: never[];
|
|
13
|
+
/** Session-level tool context handed to mail-core tool functions. */
|
|
14
|
+
export interface MailToolCtx {
|
|
15
|
+
systemId: string;
|
|
16
|
+
email?: string;
|
|
17
|
+
}
|
|
18
|
+
/** The ctx.mail service surface. */
|
|
19
|
+
export interface MailService {
|
|
20
|
+
/** Optional explicit system scope (AMAIL_SYSTEM_ID); empty = scan all. */
|
|
21
|
+
readonly systemId: string;
|
|
22
|
+
/** Resolve config for a dsh session id (uuid). Throws when unbound. */
|
|
23
|
+
resolveConfig(sessionId: string): Promise<AgentConfig>;
|
|
24
|
+
/** Resolve config by agent email address (inbound routing). Throws when unbound. */
|
|
25
|
+
resolveByEmail(email: string): Promise<AgentConfig>;
|
|
26
|
+
/** Resolve a tool context for a session id. Throws when unbound. */
|
|
27
|
+
resolveCtx(sessionId: string): Promise<MailToolCtx>;
|
|
28
|
+
}
|
|
29
|
+
/** Service identity used by consumers (ctx.get('mail')). */
|
|
30
|
+
export declare const MAIL_SERVICE = "mail";
|
|
31
|
+
export declare function apply(ctx: Context, config?: {
|
|
32
|
+
systemId?: string;
|
|
33
|
+
}): void;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { loadConfigByAgentId, loadConfigByEmail, loadConfigBySessionId, } from '@aimail/mail-core';
|
|
2
|
+
export const name = 'mail';
|
|
3
|
+
export const inject = [];
|
|
4
|
+
/** Service identity used by consumers (ctx.get('mail')). */
|
|
5
|
+
export const MAIL_SERVICE = 'mail';
|
|
6
|
+
export function apply(ctx, config = {}) {
|
|
7
|
+
const systemId = config.systemId ?? process.env.AMAIL_SYSTEM_ID ?? '';
|
|
8
|
+
const service = {
|
|
9
|
+
systemId,
|
|
10
|
+
async resolveConfig(sessionId) {
|
|
11
|
+
if (!sessionId)
|
|
12
|
+
throw new Error('no session id to resolve agentmail config');
|
|
13
|
+
let cfg = systemId
|
|
14
|
+
? await loadConfigBySessionId(systemId, sessionId)
|
|
15
|
+
: await loadConfigBySessionId('', sessionId);
|
|
16
|
+
if (!cfg && systemId) {
|
|
17
|
+
cfg = await loadConfigByAgentId(systemId, sessionId);
|
|
18
|
+
}
|
|
19
|
+
if (!cfg) {
|
|
20
|
+
throw new Error(`no agentmail binding for session ${sessionId} — run bind_agent.py first`);
|
|
21
|
+
}
|
|
22
|
+
return cfg;
|
|
23
|
+
},
|
|
24
|
+
async resolveCtx(sessionId) {
|
|
25
|
+
const cfg = await service.resolveConfig(sessionId);
|
|
26
|
+
return { systemId: cfg.system_id, email: cfg.email };
|
|
27
|
+
},
|
|
28
|
+
async resolveByEmail(email) {
|
|
29
|
+
const cfg = systemId
|
|
30
|
+
? await loadConfigByEmail(email, systemId)
|
|
31
|
+
: await loadConfigByEmail(email);
|
|
32
|
+
if (!cfg) {
|
|
33
|
+
throw new Error(`no agentmail binding for ${email} — run bind_agent.py first`);
|
|
34
|
+
}
|
|
35
|
+
return cfg;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
ctx.provide(MAIL_SERVICE, service);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aimail/mail",
|
|
3
|
+
"description": "AgentMail host service: config resolution + gateway client provisioning for dsh sessions.",
|
|
4
|
+
"version": "0.1.0-rc.7",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/metercai/dsh-aimail.git",
|
|
11
|
+
"directory": "packages/mail"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib/**/*.js",
|
|
25
|
+
"lib/**/*.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aimail/mail-core": "workspace:^"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
36
|
+
}
|
|
37
|
+
}
|