dsh-aimail 0.1.27 → 0.1.29
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/inbound.js +29 -12
- package/lib/register-cli.js +6 -3
- package/package.json +3 -3
package/lib/inbound.js
CHANGED
|
@@ -26,7 +26,7 @@ import { createServer } from 'node:http';
|
|
|
26
26
|
import { randomUUID } from 'node:crypto';
|
|
27
27
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
28
28
|
import { processInboundMail, verifySignature, routeAddressFromHeaders, updateAgentConfig, loadAgentConfig, saveAgentConfig, startAgentPullEntries, INBOUND_PATH, INBOUND_PORTS } from '@aimail/mail-core';
|
|
29
|
-
import {
|
|
29
|
+
import { notifyInboundForSystem, formatInboundNotifyLine, isInboundNotifyWarning } from '@aimail/mail-core';
|
|
30
30
|
export const name = 'mail-inbound';
|
|
31
31
|
export const inject = ['mail', 'agents'];
|
|
32
32
|
function writeJson(res, code, body) {
|
|
@@ -282,25 +282,26 @@ export function apply(ctx, config = {}) {
|
|
|
282
282
|
// stops them with the listener — the host lifecycle owns both.
|
|
283
283
|
let pullHandles = [];
|
|
284
284
|
server.listen(port, host, () => {
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
|
|
285
|
+
// Inbound notification (owner ruling 2026-09-28, SDK 去桥化): the listener is
|
|
286
|
+
// up, so this host tells the environment master (the `aimail` CLI) — once per
|
|
287
|
+
// address it serves — that inbound is live:
|
|
288
|
+
// aimail address -a <addr> --inbound-live
|
|
289
|
+
// The CLI owns the environment (routes included) and decides what that means;
|
|
290
|
+
// the SDK speaks no bridge. Best-effort by contract: argv only, 4s timeout,
|
|
291
|
+
// never blocks this callback, never throws into the host (a missing CLI is one
|
|
292
|
+
// debug line — the host keeps serving and self-registering).
|
|
293
|
+
void notifyInboundForSystem('live')
|
|
293
294
|
.then((outcomes) => {
|
|
294
295
|
for (const o of outcomes) {
|
|
295
|
-
const line = `[dsh-aimail] ${
|
|
296
|
-
if (
|
|
296
|
+
const line = `[dsh-aimail] ${formatInboundNotifyLine(o, 'live')}`;
|
|
297
|
+
if (isInboundNotifyWarning(o))
|
|
297
298
|
console.warn(line);
|
|
298
299
|
else
|
|
299
300
|
console.log(line);
|
|
300
301
|
}
|
|
301
302
|
})
|
|
302
303
|
.catch((e) => {
|
|
303
|
-
console.warn(`[dsh-aimail]
|
|
304
|
+
console.warn(`[dsh-aimail] inbound notify failed (non-fatal): ${e instanceof Error ? e.message : String(e)}`);
|
|
304
305
|
});
|
|
305
306
|
// Pull entry: inbound is live ⇒ the pulled mail can enter the same chain.
|
|
306
307
|
// Only agent-scope (address-code) bindings arm a loop (mail-core decides).
|
|
@@ -313,6 +314,22 @@ export function apply(ctx, config = {}) {
|
|
|
313
314
|
});
|
|
314
315
|
});
|
|
315
316
|
return () => {
|
|
317
|
+
// Inbound down (owner ruling 2026-09-28): this host stops serving, so it says
|
|
318
|
+
// so per address — `aimail address -a <addr> --inbound-down`. Best-effort,
|
|
319
|
+
// fire-and-forget: the CLI decides, and a missing CLI changes nothing here.
|
|
320
|
+
void notifyInboundForSystem('down')
|
|
321
|
+
.then((outcomes) => {
|
|
322
|
+
for (const o of outcomes) {
|
|
323
|
+
const line = `[dsh-aimail] ${formatInboundNotifyLine(o, 'down')}`;
|
|
324
|
+
if (isInboundNotifyWarning(o))
|
|
325
|
+
console.warn(line);
|
|
326
|
+
else
|
|
327
|
+
console.log(line);
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
.catch((e) => {
|
|
331
|
+
console.warn(`[dsh-aimail] inbound down notify failed (non-fatal): ${e instanceof Error ? e.message : String(e)}`);
|
|
332
|
+
});
|
|
316
333
|
for (const h of pullHandles)
|
|
317
334
|
h.stop();
|
|
318
335
|
pullHandles = [];
|
package/lib/register-cli.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* [--force]
|
|
22
22
|
*/
|
|
23
23
|
import { randomUUID } from 'node:crypto';
|
|
24
|
-
import { autoBind, emailForAgent, inboundUrl, INBOUND_PORTS, listSystemDirs, loadAgentConfig, readSystemConfig, registerAddress,
|
|
24
|
+
import { autoBind, emailForAgent, inboundUrl, INBOUND_PORTS, listSystemDirs, loadAgentConfig, readSystemConfig, registerAddress, resolveRegisterWebhook, saveBinding, } from '@aimail/mail-core';
|
|
25
25
|
function arg(argv, name) {
|
|
26
26
|
const i = argv.indexOf(name);
|
|
27
27
|
return i >= 0 && i + 1 < argv.length ? argv[i + 1] : '';
|
|
@@ -88,7 +88,8 @@ async function main() {
|
|
|
88
88
|
// secret 捕获为一个值:云端注册与本地落盘必须同一 secret
|
|
89
89
|
// (此前内联表达式生成的 secret 只上送云端,落盘的是旧/空值 → verifySignature 恒 401)
|
|
90
90
|
const webhookSecret = existing.webhook_secret || randomUUID().replace(/-/g, '') + randomUUID().replace(/-/g, '');
|
|
91
|
-
// 注册参数三态(push/pull
|
|
91
|
+
// 注册参数三态(环境声明的 push / 显式 pull / 本机端点)与 install 主链一致——
|
|
92
|
+
// force 路径不绕过 webhook_host 语义
|
|
92
93
|
const regUrl = resolveRegisterWebhook(gw, localWebhook);
|
|
93
94
|
const reg = await registerAddress({
|
|
94
95
|
systemId,
|
|
@@ -108,7 +109,9 @@ async function main() {
|
|
|
108
109
|
extra: { session_id: sessionId || randomUUID().replace(/-/g, ''), preset },
|
|
109
110
|
gateway: gw,
|
|
110
111
|
});
|
|
111
|
-
|
|
112
|
+
// SDK 去桥化(owner 裁决 2026-09-28): no route step here — the SDK speaks no
|
|
113
|
+
// bridge, and the environment master (the `aimail` CLI) pushes the route once
|
|
114
|
+
// this host's inbound is actually serving (`aimail address --inbound-live`).
|
|
112
115
|
console.log(JSON.stringify({ ok: true, email, system_id: systemId, registered: true, config_path: configPath }));
|
|
113
116
|
return 0;
|
|
114
117
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-aimail",
|
|
3
3
|
"description": "AIMail plugin for dsh — install via: dsh plugin --profile web add dsh-aimail",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.29",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": true
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@deepseek-ai/dsh-tools": "^0.0.1-rc.1"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@aimail/mail-core": "^0.1.
|
|
55
|
-
"@aimail/mail": "^0.1.
|
|
54
|
+
"@aimail/mail-core": "^0.1.29",
|
|
55
|
+
"@aimail/mail": "^0.1.29"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@deepseek-ai/cordis": "^4.0.1",
|