@aimail/mail 0.1.0-rc.9 → 0.1.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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @aimail/mail
2
+
3
+ Platform-neutral AIMail config resolution for TypeScript: session id / email
4
+ / recipient → `agentmail.json` → `AgentConfig`. Pure functions — no framework
5
+ imports, no host wiring.
6
+
7
+ [![npm](https://img.shields.io/npm/v/@aimail/mail)](https://www.npmjs.com/package/@aimail/mail)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @aimail/mail
13
+ ```
14
+
15
+ ## What it does
16
+
17
+ Every adapter needs the same three lookups, sourced from the per-address
18
+ `agentmail.json` bindings under `$AIMAIL_HOME` (default `~/.aimail`):
19
+
20
+ - `resolveBySessionId(sessionId)` — session-file match first, then agent_id
21
+ field match. For dsh session uuids and OpenClaw/pi agent ids.
22
+ - `resolveByEmail(email)` — exact registered-address match. Throws when
23
+ unbound.
24
+ - `resolveByRecipient(recipient)` — exact match first, then persona-strip
25
+ fallback (recipient local part ends with `.<registered local part>`),
26
+ mirroring the Python `route_agent_for_email` semantics. Inbound routing for
27
+ single-in-multi-out platforms (one gateway hosts many agents; mail can
28
+ arrive at role aliases).
29
+ - `resolveConfig()`-style composition is left to each adapter: the identity
30
+ source (pointer file / factory ctx / env) is platform-specific by design.
31
+
32
+ ## Scope narrowing
33
+
34
+ `ResolveOptions.systemId` narrows the scan to one system; when omitted the
35
+ `AIMAIL_SYSTEM_ID` env is used; when that is also empty, all systems under
36
+ `$AIMAIL_HOME/systems/` are scanned (two-level traversal:
37
+ `systems/{system_id}/{address_dir}/agentmail.json`).
38
+
39
+ Unbound resolutions throw loudly (`no aimail binding for …`) — callers
40
+ surface that to the model/user instead of guessing an identity.
41
+
42
+ ## Related repositories
43
+
44
+ - [metercai/aimail](https://github.com/metercai/aimail) — the AIMail monorepo:
45
+ CLI (`cli/`), Python SDK (`pysdk/`), TypeScript SDK (`tssdk/`, you are here),
46
+ bridge distributions.
47
+ - [metercai/aimail-gateway](https://github.com/metercai/aimail-gateway) — the
48
+ AIMail gateway: SMTP/HTTP mail service and the address & activation APIs
49
+ that create the bindings being resolved here.
package/lib/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface MailToolCtx {
6
6
  }
7
7
  /** Resolution options shared by every resolver. */
8
8
  export interface ResolveOptions {
9
- /** Explicit system scope; defaults to the AMAIL_SYSTEM_ID env (empty = scan all). */
9
+ /** Explicit system scope; defaults to the AIMAIL_SYSTEM_ID env (empty = scan all). */
10
10
  systemId?: string;
11
11
  }
12
12
  /**
package/lib/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  /**
2
- * @aimail/mail — platform-neutral AgentMail config resolution.
2
+ * @aimail/mail — platform-neutral AIMail config resolution.
3
3
  *
4
4
  * Pure functions: sessionId / email / agentId → agentmail.json → AgentConfig.
5
5
  * No framework imports (no cordis, no dsh-sdk); each platform adapter
6
6
  * (dsh-aimail, openclaw-aimail) binds these to its own identity source.
7
7
  *
8
8
  * Identity = agentmail.json only (single source of truth); the optional
9
- * AMAIL_SYSTEM_ID env narrows the scan scope. Unbound resolutions throw.
9
+ * AIMAIL_SYSTEM_ID env narrows the scan scope. Unbound resolutions throw.
10
10
  */
11
11
  import { promises as fs } from 'node:fs';
12
12
  import * as path from 'node:path';
13
13
  import { cleanAddr, loadConfigByAgentId, loadConfigByEmail, loadConfigBySessionId, systemDir, } from '@aimail/mail-core';
14
14
  function systemIdFrom(opts) {
15
- return opts.systemId ?? process.env.AMAIL_SYSTEM_ID ?? '';
15
+ return opts.systemId ?? process.env.AIMAIL_SYSTEM_ID ?? '';
16
16
  }
17
17
  function unbound(what) {
18
- return new Error(`no agentmail binding for ${what} — run bind_agent.py first`);
18
+ return new Error(`no aimail binding for ${what} — run bind_agent.py first`);
19
19
  }
20
20
  /** Scan one system dir (or all systems) for every bound AgentConfig. */
21
21
  async function scanAllConfigs(systemId) {
@@ -59,7 +59,7 @@ async function scanAllConfigs(systemId) {
59
59
  */
60
60
  export async function resolveBySessionId(sessionId, opts = {}) {
61
61
  if (!sessionId)
62
- throw new Error('no session id to resolve agentmail config');
62
+ throw new Error('no session id to resolve aimail config');
63
63
  const systemId = systemIdFrom(opts);
64
64
  let cfg = await loadConfigBySessionId(systemId, sessionId);
65
65
  if (!cfg && systemId)
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@aimail/mail",
3
- "description": "AgentMail platform-neutral config resolution: sessionId/email/recipient → agentmail.json → AgentConfig (pure functions, no framework deps).",
4
- "version": "0.1.0-rc.9",
3
+ "description": "AIMail platform-neutral config resolution: sessionId/email/recipient → agentmail.json → AgentConfig (pure functions, no framework deps).",
4
+ "version": "0.1.7",
5
5
  "publishConfig": {
6
- "access": "public"
6
+ "access": "public",
7
+ "provenance": true
7
8
  },
8
9
  "repository": {
9
10
  "type": "git",
10
- "url": "git+https://github.com/metercai/aimail-sdk-ts.git",
11
- "directory": "packages/mail"
11
+ "url": "https://github.com/metercai/aimail"
12
12
  },
13
13
  "type": "module",
14
14
  "main": "lib/index.js",
@@ -27,7 +27,14 @@
27
27
  "license": "MIT",
28
28
  "peerDependencies": {},
29
29
  "dependencies": {
30
- "@aimail/mail-core": "^0.1.0-rc.9"
30
+ "@aimail/mail-core": "^0.1.7"
31
31
  },
32
- "devDependencies": {}
33
- }
32
+ "devDependencies": {},
33
+ "keywords": [
34
+ "aimail",
35
+ "agent-mail",
36
+ "config",
37
+ "resolution",
38
+ "binding"
39
+ ]
40
+ }