@tpsdev-ai/agent 0.5.3 → 0.6.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/dist/bin.js +47 -2
- package/dist/bin.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/io/flair.d.ts +43 -0
- package/dist/io/flair.d.ts.map +1 -0
- package/dist/io/flair.js +143 -0
- package/dist/io/flair.js.map +1 -0
- package/dist/io/mail.d.ts +24 -2
- package/dist/io/mail.d.ts.map +1 -1
- package/dist/io/mail.js +168 -15
- package/dist/io/mail.js.map +1 -1
- package/dist/lib/signEnvelope.d.ts +67 -0
- package/dist/lib/signEnvelope.d.ts.map +1 -0
- package/dist/lib/signEnvelope.js +244 -0
- package/dist/lib/signEnvelope.js.map +1 -0
- package/dist/llm/provider.d.ts +21 -1
- package/dist/llm/provider.d.ts.map +1 -1
- package/dist/llm/provider.js +422 -23
- package/dist/llm/provider.js.map +1 -1
- package/dist/runtime/agent.d.ts +2 -0
- package/dist/runtime/agent.d.ts.map +1 -1
- package/dist/runtime/agent.js +50 -3
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/event-loop.d.ts +44 -2
- package/dist/runtime/event-loop.d.ts.map +1 -1
- package/dist/runtime/event-loop.js +478 -56
- package/dist/runtime/event-loop.js.map +1 -1
- package/dist/runtime/types.d.ts +27 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/telemetry/events.d.ts +57 -0
- package/dist/telemetry/events.d.ts.map +1 -0
- package/dist/telemetry/events.js +37 -0
- package/dist/telemetry/events.js.map +1 -0
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +94 -16
- package/dist/tools/edit.js.map +1 -1
- package/package.json +10 -2
- package/src/bin.ts +56 -3
- package/src/config.ts +10 -1
- package/src/index.ts +8 -0
- package/src/io/flair.ts +183 -0
- package/src/io/mail.ts +184 -19
- package/src/lib/signEnvelope.ts +332 -0
- package/src/llm/provider.ts +454 -22
- package/src/runtime/agent.ts +55 -3
- package/src/runtime/event-loop.ts +523 -44
- package/src/runtime/types.ts +32 -1
- package/src/telemetry/events.ts +101 -0
- package/src/tools/edit.ts +108 -17
- package/test/bin-launch-id.test.ts +104 -0
- package/test/core-loop.test.ts +240 -0
- package/test/events.test.ts +33 -0
- package/test/flair-context.test.ts +102 -0
- package/test/governance.test.ts +103 -2
- package/test/io.test.ts +8 -8
- package/test/provider.test.ts +471 -0
- package/test/security/mail-trust.test.ts +266 -0
package/src/io/flair.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flair context provider for the agent package.
|
|
3
|
+
*
|
|
4
|
+
* Provides Flair-backed system prompt bootstrapping and memory writes.
|
|
5
|
+
* Uses the same TPS-Ed25519 signing scheme as the CLI FlairClient.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import crypto from "node:crypto";
|
|
9
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import type { FlairConfig } from "../runtime/types.js";
|
|
13
|
+
|
|
14
|
+
export interface FlairAgent {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
publicKey: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface FlairMemory {
|
|
21
|
+
id: string;
|
|
22
|
+
agentId: string;
|
|
23
|
+
content: string;
|
|
24
|
+
type?: string;
|
|
25
|
+
score?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FlairSoulEntry {
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class FlairContextProvider {
|
|
34
|
+
private readonly url: string;
|
|
35
|
+
private readonly agentId: string;
|
|
36
|
+
private readonly keyPath: string;
|
|
37
|
+
|
|
38
|
+
constructor(agentId: string, config: FlairConfig = {}) {
|
|
39
|
+
this.url = (config.url ?? process.env.FLAIR_URL ?? "http://127.0.0.1:9926").replace(/\/$/, "");
|
|
40
|
+
this.agentId = agentId;
|
|
41
|
+
this.keyPath =
|
|
42
|
+
config.keyPath ??
|
|
43
|
+
join(homedir(), ".tps", "identity", `${agentId}.key`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ─── Auth ──────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
private sign(method: string, path: string): string {
|
|
49
|
+
const ts = Date.now().toString();
|
|
50
|
+
const nonce = crypto.randomUUID();
|
|
51
|
+
const payload = `${this.agentId}:${ts}:${nonce}:${method}:${path}`;
|
|
52
|
+
|
|
53
|
+
if (!existsSync(this.keyPath)) {
|
|
54
|
+
throw new Error(`Flair key not found at ${this.keyPath}. Run: tps agent create --id ${this.agentId}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const raw = readFileSync(this.keyPath, "utf-8").trim();
|
|
58
|
+
let key;
|
|
59
|
+
if (raw.startsWith("-----")) {
|
|
60
|
+
key = crypto.createPrivateKey(raw);
|
|
61
|
+
} else {
|
|
62
|
+
key = crypto.createPrivateKey({ key: Buffer.from(raw, "base64"), format: "der", type: "pkcs8" });
|
|
63
|
+
}
|
|
64
|
+
const sig = crypto.sign(null, Buffer.from(payload), key);
|
|
65
|
+
return `TPS-Ed25519 ${this.agentId}:${ts}:${nonce}:${sig.toString("base64")}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private async req<T>(method: string, path: string, body?: unknown): Promise<T> {
|
|
69
|
+
const res = await fetch(`${this.url}${path}`, {
|
|
70
|
+
method,
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
Authorization: this.sign(method, path),
|
|
74
|
+
},
|
|
75
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
76
|
+
});
|
|
77
|
+
if (!res.ok) {
|
|
78
|
+
const txt = await res.text().catch(() => "");
|
|
79
|
+
throw new Error(`Flair ${method} ${path} → ${res.status}: ${txt}`);
|
|
80
|
+
}
|
|
81
|
+
if (res.status === 204) return undefined as T;
|
|
82
|
+
return res.json() as Promise<T>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ─── Public API ────────────────────────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
async ping(): Promise<boolean> {
|
|
88
|
+
try {
|
|
89
|
+
const res = await fetch(`${this.url}/Health`, { signal: AbortSignal.timeout(3000) });
|
|
90
|
+
return res.ok;
|
|
91
|
+
} catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async getAgent(name: string): Promise<FlairAgent | null> {
|
|
97
|
+
try {
|
|
98
|
+
return await this.req<FlairAgent>("GET", `/Agent/${name}`);
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async getSoul(): Promise<FlairSoulEntry[]> {
|
|
105
|
+
const entries = await this.req<Array<{ key: string; value: string }>>(
|
|
106
|
+
"GET",
|
|
107
|
+
`/Soul?agentId=${encodeURIComponent(this.agentId)}`,
|
|
108
|
+
);
|
|
109
|
+
return entries;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async searchMemories(query: string, limit = 5): Promise<FlairMemory[]> {
|
|
113
|
+
return this.req<FlairMemory[]>(
|
|
114
|
+
"GET",
|
|
115
|
+
`/MemorySearch?agentId=${encodeURIComponent(this.agentId)}&q=${encodeURIComponent(query)}&limit=${limit}`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async listRecentMemories(days = 3): Promise<FlairMemory[]> {
|
|
120
|
+
return this.req<FlairMemory[]>(
|
|
121
|
+
"GET",
|
|
122
|
+
`/Memory?agentId=${encodeURIComponent(this.agentId)}&limit=${days * 3}`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async writeMemory(id: string, content: string, type = "conversation"): Promise<void> {
|
|
127
|
+
const existing = await this.req("GET", `/Memory/${id}`).catch(() => null);
|
|
128
|
+
const payload = {
|
|
129
|
+
id,
|
|
130
|
+
agentId: this.agentId,
|
|
131
|
+
content,
|
|
132
|
+
type,
|
|
133
|
+
durability: "standard",
|
|
134
|
+
updatedAt: new Date().toISOString(),
|
|
135
|
+
};
|
|
136
|
+
if (existing) {
|
|
137
|
+
await this.req("PUT", `/Memory/${id}`, payload);
|
|
138
|
+
} else {
|
|
139
|
+
await this.req("POST", "/Memory", { ...payload, createdAt: new Date().toISOString() });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Build a system prompt supplement from Flair — soul + recent context.
|
|
145
|
+
* Returns empty string if Flair is offline (graceful degradation).
|
|
146
|
+
*/
|
|
147
|
+
async buildContextBlock(query?: string): Promise<string> {
|
|
148
|
+
if (!(await this.ping())) return "";
|
|
149
|
+
|
|
150
|
+
const parts: string[] = [];
|
|
151
|
+
|
|
152
|
+
// Soul entries → identity block
|
|
153
|
+
try {
|
|
154
|
+
const soul = await this.getSoul();
|
|
155
|
+
if (soul.length > 0) {
|
|
156
|
+
parts.push("## Agent Identity (from Flair)");
|
|
157
|
+
for (const entry of soul) {
|
|
158
|
+
parts.push(`${entry.key}: ${entry.value}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
// non-fatal
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Semantic search if query provided
|
|
166
|
+
if (query) {
|
|
167
|
+
try {
|
|
168
|
+
const results = await this.searchMemories(query, 5);
|
|
169
|
+
if (results.length > 0) {
|
|
170
|
+
parts.push("\n## Relevant Memory");
|
|
171
|
+
for (const r of results) {
|
|
172
|
+
const score = r.score ? ` [${r.score.toFixed(3)}]` : "";
|
|
173
|
+
parts.push(`${score} ${r.id}: ${r.content.slice(0, 500)}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} catch {
|
|
177
|
+
// non-fatal
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return parts.join("\n");
|
|
182
|
+
}
|
|
183
|
+
}
|
package/src/io/mail.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readdirSync, renameSync, readFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, renameSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import type { EventLogger } from "../telemetry/events.js";
|
|
4
|
+
import { sanitizeError } from "../telemetry/events.js";
|
|
5
|
+
import { verifyEnvelope, type FlairClient } from "../lib/signEnvelope.js";
|
|
3
6
|
|
|
4
7
|
export interface MailMessage {
|
|
5
8
|
filename: string;
|
|
6
9
|
body: string;
|
|
7
10
|
receivedAt: Date;
|
|
11
|
+
/** Trust/routing headers from bridge envelope */
|
|
12
|
+
headers: Record<string, string>;
|
|
13
|
+
/** Sender agent ID */
|
|
14
|
+
from: string;
|
|
8
15
|
}
|
|
9
16
|
|
|
10
17
|
/**
|
|
@@ -15,19 +22,29 @@ export interface MailMessage {
|
|
|
15
22
|
export class MailClient {
|
|
16
23
|
private inboxNew: string;
|
|
17
24
|
private inboxCur: string;
|
|
25
|
+
private inboxDlq: string;
|
|
18
26
|
private outboxNew: string;
|
|
19
27
|
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
constructor(
|
|
29
|
+
public readonly mailDir: string,
|
|
30
|
+
private readonly events?: EventLogger,
|
|
31
|
+
private readonly agentId = "unknown",
|
|
32
|
+
private readonly flairClient?: FlairClient,
|
|
33
|
+
) {
|
|
34
|
+
this.inboxNew = join(mailDir, agentId, "new");
|
|
35
|
+
this.inboxCur = join(mailDir, agentId, "cur");
|
|
36
|
+
this.inboxDlq = join(mailDir, agentId, "dlq");
|
|
37
|
+
this.outboxNew = join(mailDir, agentId, "outbox");
|
|
38
|
+
for (const dir of [this.inboxNew, this.inboxCur, this.inboxDlq, this.outboxNew]) {
|
|
26
39
|
mkdirSync(dir, { recursive: true });
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Return all messages in inbox/new and move them to inbox/cur.
|
|
45
|
+
* When a FlairClient is provided, signed envelopes are verified
|
|
46
|
+
* before promotion; invalid/malformed messages go to dlq/.
|
|
47
|
+
*/
|
|
31
48
|
async checkNewMail(): Promise<MailMessage[]> {
|
|
32
49
|
if (!existsSync(this.inboxNew)) return [];
|
|
33
50
|
|
|
@@ -35,11 +52,58 @@ export class MailClient {
|
|
|
35
52
|
const messages: MailMessage[] = [];
|
|
36
53
|
|
|
37
54
|
for (const file of files) {
|
|
55
|
+
const started = Date.now();
|
|
38
56
|
const srcPath = join(this.inboxNew, file);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
try {
|
|
58
|
+
const body = readFileSync(srcPath, "utf-8");
|
|
59
|
+
|
|
60
|
+
// Envelope verification (strict when FlairClient is available).
|
|
61
|
+
if (this.flairClient) {
|
|
62
|
+
const verifyResult = await this.verifyMailBody(body, file);
|
|
63
|
+
if (!verifyResult.pass) {
|
|
64
|
+
const dlqPath = join(this.inboxDlq, file);
|
|
65
|
+
renameSync(srcPath, dlqPath);
|
|
66
|
+
writeFileSync(join(this.inboxDlq, `${file}.reject`), verifyResult.reason, "utf-8");
|
|
67
|
+
this.events?.emit({
|
|
68
|
+
type: "mail.receive",
|
|
69
|
+
agent: this.agentId,
|
|
70
|
+
status: "rejected",
|
|
71
|
+
from: verifyResult.from ?? "unknown",
|
|
72
|
+
durationMs: Date.now() - started,
|
|
73
|
+
error: verifyResult.reason,
|
|
74
|
+
});
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Promote to cur/
|
|
80
|
+
const dstPath = join(this.inboxCur, file);
|
|
81
|
+
renameSync(srcPath, dstPath);
|
|
82
|
+
let headers: Record<string, string> = {};
|
|
83
|
+
let from = "unknown";
|
|
84
|
+
try {
|
|
85
|
+
const parsed = JSON.parse(body);
|
|
86
|
+
headers = parsed.headers ?? {};
|
|
87
|
+
from = parsed.from ?? "unknown";
|
|
88
|
+
} catch {}
|
|
89
|
+
messages.push({ filename: file, body, receivedAt: new Date(), headers, from });
|
|
90
|
+
this.events?.emit({
|
|
91
|
+
type: "mail.receive",
|
|
92
|
+
agent: this.agentId,
|
|
93
|
+
status: "ok",
|
|
94
|
+
from,
|
|
95
|
+
durationMs: Date.now() - started,
|
|
96
|
+
});
|
|
97
|
+
} catch (err) {
|
|
98
|
+
this.events?.emit({
|
|
99
|
+
type: "mail.receive",
|
|
100
|
+
agent: this.agentId,
|
|
101
|
+
status: "error",
|
|
102
|
+
from: "unknown",
|
|
103
|
+
durationMs: Date.now() - started,
|
|
104
|
+
error: sanitizeError(err),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
43
107
|
}
|
|
44
108
|
|
|
45
109
|
return messages;
|
|
@@ -47,12 +111,113 @@ export class MailClient {
|
|
|
47
111
|
|
|
48
112
|
/** Write a message to outbox/new for relay delivery. */
|
|
49
113
|
async sendMail(to: string, body: string): Promise<void> {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
114
|
+
const started = Date.now();
|
|
115
|
+
try {
|
|
116
|
+
const { writeFileSync } = await import("node:fs");
|
|
117
|
+
const filename = `${Date.now()}-${Math.random().toString(36).slice(2)}.json`;
|
|
118
|
+
writeFileSync(
|
|
119
|
+
join(this.outboxNew, filename),
|
|
120
|
+
JSON.stringify({ to, body, sentAt: new Date().toISOString() }, null, 2),
|
|
121
|
+
"utf-8"
|
|
122
|
+
);
|
|
123
|
+
this.events?.emit({
|
|
124
|
+
type: "mail.send",
|
|
125
|
+
agent: this.agentId,
|
|
126
|
+
to,
|
|
127
|
+
status: "ok",
|
|
128
|
+
durationMs: Date.now() - started,
|
|
129
|
+
});
|
|
130
|
+
} catch (err) {
|
|
131
|
+
this.events?.emit({
|
|
132
|
+
type: "mail.send",
|
|
133
|
+
agent: this.agentId,
|
|
134
|
+
to,
|
|
135
|
+
status: "error",
|
|
136
|
+
durationMs: Date.now() - started,
|
|
137
|
+
error: sanitizeError(err),
|
|
138
|
+
});
|
|
139
|
+
throw err;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Deliver all messages in outbox to recipient inboxes (local relay). */
|
|
144
|
+
deliverOutbox(): void {
|
|
145
|
+
if (!existsSync(this.outboxNew)) return;
|
|
146
|
+
const files = readdirSync(this.outboxNew).filter(f => !f.startsWith("."));
|
|
147
|
+
for (const file of files) {
|
|
148
|
+
const srcPath = join(this.outboxNew, file);
|
|
149
|
+
try {
|
|
150
|
+
const raw = readFileSync(srcPath, "utf-8");
|
|
151
|
+
const msg = JSON.parse(raw) as { to: string; body: string; sentAt: string };
|
|
152
|
+
if (!msg.to || !/^[a-zA-Z0-9_-]{1,64}$/.test(msg.to)) {
|
|
153
|
+
continue; // skip invalid recipients
|
|
154
|
+
}
|
|
155
|
+
const recipientInbox = join(this.mailDir, msg.to, "new");
|
|
156
|
+
mkdirSync(recipientInbox, { recursive: true });
|
|
157
|
+
const destFile = `${msg.sentAt.replace(/[:.]/g, "-")}-${file}`;
|
|
158
|
+
renameSync(srcPath, join(recipientInbox, destFile));
|
|
159
|
+
} catch {
|
|
160
|
+
// Leave in outbox on error
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Verify a mail body against the v1 signed envelope spec.
|
|
167
|
+
* Returns { pass: true } if verified, or { pass: false, reason: "..." } on failure.
|
|
168
|
+
* Requires flairClient to be set.
|
|
169
|
+
*/
|
|
170
|
+
private async verifyMailBody(
|
|
171
|
+
body: string,
|
|
172
|
+
filename: string,
|
|
173
|
+
): Promise<{ pass: true } | { pass: false; reason: string; from?: string }> {
|
|
174
|
+
const client = this.flairClient!;
|
|
175
|
+
|
|
176
|
+
// 1. Parse the mail file as JSON
|
|
177
|
+
let mailMsg: { from?: string; body: string };
|
|
178
|
+
try {
|
|
179
|
+
mailMsg = JSON.parse(body);
|
|
180
|
+
} catch {
|
|
181
|
+
return { pass: false, reason: "json parse error: invalid JSON" };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!mailMsg.body || typeof mailMsg.body !== "string") {
|
|
185
|
+
return { pass: false, reason: "json parse error: missing body field" };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 2. Parse the body field as an envelope
|
|
189
|
+
let envelope: unknown;
|
|
190
|
+
try {
|
|
191
|
+
envelope = JSON.parse(mailMsg.body);
|
|
192
|
+
} catch {
|
|
193
|
+
return { pass: false, reason: "json parse error: invalid envelope body", from: mailMsg.from };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (envelope == null || typeof envelope !== "object" || Array.isArray(envelope)) {
|
|
197
|
+
return { pass: false, reason: "unsigned envelope (v1 required)", from: mailMsg.from };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const env = envelope as Record<string, unknown>;
|
|
201
|
+
if (
|
|
202
|
+
typeof env.v !== "number" ||
|
|
203
|
+
!Array.isArray(env.delegationChain) ||
|
|
204
|
+
typeof env.signature !== "string"
|
|
205
|
+
) {
|
|
206
|
+
return { pass: false, reason: "unsigned envelope (v1 required)", from: mailMsg.from };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 3. Verify the envelope using the canonical verifyEnvelope
|
|
210
|
+
try {
|
|
211
|
+
const vr = await verifyEnvelope(env as any, client);
|
|
212
|
+
if (!vr.ok) {
|
|
213
|
+
return { pass: false, reason: vr.reason, from: mailMsg.from };
|
|
214
|
+
}
|
|
215
|
+
} catch (err: any) {
|
|
216
|
+
// verifyEnvelope threw (e.g. Flair network error).
|
|
217
|
+
// Don't drop the message — pass it through and log.
|
|
218
|
+
console.warn(`[MailClient] verifyEnvelope error for ${filename}: ${err?.message ?? err}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return { pass: true };
|
|
57
222
|
}
|
|
58
223
|
}
|