@ouro.bot/cli 0.1.0-alpha.1463 → 0.1.0-alpha.1465

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.
Files changed (44) hide show
  1. package/README.md +2 -2
  2. package/changelog.json +14 -0
  3. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
  4. package/deploy/unraid/sanctuary.xml +1 -1
  5. package/dist/heart/daemon/cli-commands/mail.js +0 -1
  6. package/dist/heart/daemon/cli-exec.js +0 -33
  7. package/dist/heart/daemon/cli-help.js +0 -13
  8. package/dist/heart/daemon/cli-parse.js +0 -3
  9. package/dist/heart/daemon/cli-render.js +0 -7
  10. package/dist/heart/daemon/daemon-entry.js +1 -1
  11. package/dist/heart/daemon/daemon.js +0 -63
  12. package/dist/heart/{mailbox/mailbox-supervision.js → shepherd/supervision-read.js} +4 -4
  13. package/dist/nerves/coverage/file-completeness.js +0 -11
  14. package/dist/nerves/observation.js +2 -4
  15. package/dist/repertoire/tools-mail.js +2 -2
  16. package/dist/senses/cli/ouro-tui.js +2 -2
  17. package/dist/senses/shepherd/operations.js +2 -2
  18. package/npm-shrinkwrap.json +2 -2
  19. package/package.json +2 -4
  20. package/skills/sense-setup.md +1 -1
  21. package/dist/heart/mailbox/mailbox-http-hooks.js +0 -99
  22. package/dist/heart/mailbox/mailbox-http-response.js +0 -7
  23. package/dist/heart/mailbox/mailbox-http-routes.js +0 -406
  24. package/dist/heart/mailbox/mailbox-http-static.js +0 -103
  25. package/dist/heart/mailbox/mailbox-http-transport.js +0 -272
  26. package/dist/heart/mailbox/mailbox-http.js +0 -99
  27. package/dist/heart/mailbox/mailbox-read.js +0 -41
  28. package/dist/heart/mailbox/mailbox-types.js +0 -27
  29. package/dist/heart/mailbox/mailbox-view.js +0 -197
  30. package/dist/heart/mailbox/readers/agent-machine.js +0 -428
  31. package/dist/heart/mailbox/readers/continuity-readers.js +0 -329
  32. package/dist/heart/mailbox/readers/mail.js +0 -375
  33. package/dist/heart/mailbox/readers/runtime-readers.js +0 -823
  34. package/dist/heart/mailbox/readers/sessions.js +0 -231
  35. package/dist/heart/mailbox/readers/shared.js +0 -111
  36. package/dist/mailbox-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  37. package/dist/mailbox-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  38. package/dist/mailbox-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  39. package/dist/mailbox-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  40. package/dist/mailbox-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  41. package/dist/mailbox-ui/assets/index-BQYBPyiH.js +0 -5
  42. package/dist/mailbox-ui/assets/index-UZ85Lvxp.css +0 -1
  43. package/dist/mailbox-ui/assets/vendor-BfcLUM_P.js +0 -65
  44. package/dist/mailbox-ui/index.html +0 -18
@@ -1,375 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readMailView = readMailView;
4
- exports.readMailMessageView = readMailMessageView;
5
- const runtime_1 = require("../../../nerves/runtime");
6
- const file_store_1 = require("../../../mailroom/file-store");
7
- const reader_1 = require("../../../mailroom/reader");
8
- const core_1 = require("../../../mailroom/core");
9
- const MAILBOX_MAIL_LIST_LIMIT = 50;
10
- const MAILBOX_MAIL_SUMMARY_LIMIT = MAILBOX_MAIL_LIST_LIMIT;
11
- // Cap the outbound list returned to the UI. The Mailbox tab renders a
12
- // bounded recent-outbound view; surfacing the entire outbound history is
13
- // what makes the tab hang on a loading spinner for large mailboxes.
14
- const MAILBOX_MAIL_OUTBOUND_LIMIT = 50;
15
- const MAILBOX_MAIL_BODY_LIMIT = 12_000;
16
- function emptyFolders() {
17
- return [
18
- { id: "imbox", label: "Imbox", count: 0 },
19
- { id: "screener", label: "Screener", count: 0 },
20
- { id: "discarded", label: "Discarded", count: 0 },
21
- { id: "quarantine", label: "Quarantine", count: 0 },
22
- { id: "draft", label: "Drafts", count: 0 },
23
- { id: "sent", label: "Sent", count: 0 },
24
- { id: "delegated", label: "Delegated", count: 0 },
25
- { id: "native", label: "Native", count: 0 },
26
- ];
27
- }
28
- function emptyRecovery() {
29
- return { discardedCount: 0, quarantineCount: 0, undecryptableCount: 0, missingKeyIds: [] };
30
- }
31
- function unavailableMailView(agentName, status, error) {
32
- return {
33
- status,
34
- agentName,
35
- mailboxAddress: null,
36
- generatedAt: new Date().toISOString(),
37
- store: null,
38
- folders: emptyFolders(),
39
- messages: [],
40
- screener: [],
41
- outbound: [],
42
- recovery: emptyRecovery(),
43
- accessLog: [],
44
- error,
45
- };
46
- }
47
- function unavailableMessageView(agentName, status, error) {
48
- return {
49
- status,
50
- agentName,
51
- mailboxAddress: null,
52
- generatedAt: new Date().toISOString(),
53
- message: null,
54
- accessLog: [],
55
- error,
56
- };
57
- }
58
- function mailSummary(message) {
59
- const provenance = {
60
- placement: message.placement,
61
- compartmentKind: message.compartmentKind,
62
- ownerEmail: message.ownerEmail ?? null,
63
- source: message.source ?? null,
64
- recipient: message.recipient,
65
- mailboxId: message.mailboxId,
66
- grantId: message.grantId ?? null,
67
- trustReason: message.trustReason,
68
- };
69
- return {
70
- id: message.id,
71
- subject: message.private.subject,
72
- from: message.private.from,
73
- to: message.private.to,
74
- cc: message.private.cc,
75
- date: message.private.date ?? null,
76
- receivedAt: message.receivedAt,
77
- snippet: message.private.snippet,
78
- placement: message.placement,
79
- compartmentKind: message.compartmentKind,
80
- ownerEmail: message.ownerEmail ?? null,
81
- source: message.source ?? null,
82
- recipient: message.recipient,
83
- attachmentCount: message.private.attachments.length,
84
- untrustedContentWarning: message.private.untrustedContentWarning,
85
- provenance,
86
- };
87
- }
88
- function missingPrivateMailKeyId(error) {
89
- /* v8 ignore next -- non-Error throw branch: decryptMessages only ever throws Error subclasses (MissingPrivateMailKeyError or crypto errors); this guard is defensive. @preserve */
90
- if (!(error instanceof Error))
91
- return null;
92
- const errorWithKeyId = error;
93
- return typeof errorWithKeyId.keyId === "string" && errorWithKeyId.keyId.length > 0
94
- ? errorWithKeyId.keyId
95
- : null;
96
- }
97
- function decryptVisibleMessages(messages, privateKeys) {
98
- const decrypted = [];
99
- const skipped = [];
100
- for (const message of messages) {
101
- try {
102
- decrypted.push((0, file_store_1.decryptMessages)([message], privateKeys)[0]);
103
- }
104
- catch (error) {
105
- const keyId = missingPrivateMailKeyId(error);
106
- if (!keyId)
107
- throw error;
108
- skipped.push({ messageId: message.id, keyId });
109
- }
110
- }
111
- return { decrypted, skipped };
112
- }
113
- function buildFolders(messages, outbound) {
114
- const folders = [
115
- { id: "imbox", label: "Imbox", count: messages.filter((message) => message.placement === "imbox").length },
116
- { id: "screener", label: "Screener", count: messages.filter((message) => message.placement === "screener").length },
117
- { id: "discarded", label: "Discarded", count: messages.filter((message) => message.placement === "discarded").length },
118
- { id: "quarantine", label: "Quarantine", count: messages.filter((message) => message.placement === "quarantine").length },
119
- { id: "draft", label: "Drafts", count: outbound.filter((record) => record.status === "draft").length },
120
- { id: "sent", label: "Sent", count: outbound.filter((record) => record.status !== "draft").length },
121
- { id: "delegated", label: "Delegated", count: messages.filter((message) => message.compartmentKind === "delegated").length },
122
- { id: "native", label: "Native", count: messages.filter((message) => message.compartmentKind === "native").length },
123
- ];
124
- const sourceCounts = new Map();
125
- const sourceOwnerCounts = new Map();
126
- for (const message of messages) {
127
- if (!message.source)
128
- continue;
129
- sourceCounts.set(message.source, (sourceCounts.get(message.source) ?? 0) + 1);
130
- const owner = message.ownerEmail ?? "";
131
- const ownerCounts = sourceOwnerCounts.get(message.source) ?? new Map();
132
- ownerCounts.set(owner, (ownerCounts.get(owner) ?? 0) + 1);
133
- sourceOwnerCounts.set(message.source, ownerCounts);
134
- }
135
- for (const [source, count] of [...sourceCounts.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
136
- const ownerCounts = sourceOwnerCounts.get(source);
137
- if (!ownerCounts || ownerCounts.size <= 1) {
138
- folders.push({ id: `source:${source}`, label: source.toUpperCase(), count });
139
- continue;
140
- }
141
- for (const [owner, ownerCount] of [...ownerCounts.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
142
- const ownerLabel = owner || "unknown owner";
143
- const ownerId = owner || "unknown-owner";
144
- folders.push({ id: `source:${source}:${ownerId}`, label: `${source.toUpperCase()} / ${ownerLabel}`, count: ownerCount });
145
- }
146
- }
147
- return folders;
148
- }
149
- function screenerCandidate(candidate) {
150
- return {
151
- id: candidate.id,
152
- messageId: candidate.messageId,
153
- senderEmail: candidate.senderEmail,
154
- senderDisplay: candidate.senderDisplay,
155
- recipient: candidate.recipient,
156
- source: candidate.source ?? null,
157
- ownerEmail: candidate.ownerEmail ?? null,
158
- status: candidate.status,
159
- placement: candidate.placement,
160
- trustReason: candidate.trustReason,
161
- firstSeenAt: candidate.firstSeenAt,
162
- lastSeenAt: candidate.lastSeenAt,
163
- messageCount: candidate.messageCount,
164
- };
165
- }
166
- function outboundRecord(record) {
167
- const policyDecision = record.policyDecision;
168
- return {
169
- id: record.id,
170
- status: record.status,
171
- mailboxRole: record.mailboxRole ?? "agent-native-mailbox",
172
- sendAuthority: record.sendAuthority ?? "agent-native",
173
- ownerEmail: record.ownerEmail ?? null,
174
- source: record.source ?? null,
175
- from: record.from,
176
- to: record.to,
177
- cc: record.cc,
178
- bcc: record.bcc,
179
- subject: record.subject,
180
- createdAt: record.createdAt,
181
- updatedAt: record.updatedAt,
182
- sentAt: record.sentAt ?? null,
183
- submittedAt: record.submittedAt ?? null,
184
- acceptedAt: record.acceptedAt ?? null,
185
- deliveredAt: record.deliveredAt ?? null,
186
- failedAt: record.failedAt ?? null,
187
- sendMode: record.sendMode ?? null,
188
- policyDecision: policyDecision
189
- ? {
190
- allowed: policyDecision.allowed,
191
- mode: policyDecision.mode,
192
- code: policyDecision.code,
193
- reason: policyDecision.reason,
194
- evaluatedAt: policyDecision.evaluatedAt,
195
- recipients: policyDecision.recipients,
196
- fallback: policyDecision.fallback,
197
- policyId: policyDecision.policyId ?? null,
198
- remainingSendsInWindow: policyDecision.remainingSendsInWindow ?? null,
199
- }
200
- : null,
201
- provider: record.provider ?? null,
202
- providerMessageId: record.providerMessageId ?? null,
203
- providerRequestId: record.providerRequestId ?? null,
204
- operationLocation: record.operationLocation ?? null,
205
- deliveryEvents: (record.deliveryEvents ?? []).map((event) => ({
206
- provider: event.provider,
207
- providerEventId: event.providerEventId,
208
- providerMessageId: event.providerMessageId,
209
- outcome: event.outcome,
210
- recipient: event.recipient ?? null,
211
- occurredAt: event.occurredAt,
212
- receivedAt: event.receivedAt,
213
- bodySafeSummary: event.bodySafeSummary,
214
- providerStatus: event.providerStatus ?? null,
215
- })),
216
- transport: record.transport ?? null,
217
- reason: record.reason,
218
- };
219
- }
220
- function buildRecovery(messages, skipped = []) {
221
- return {
222
- discardedCount: messages.filter((message) => message.placement === "discarded").length,
223
- quarantineCount: messages.filter((message) => message.placement === "quarantine").length,
224
- undecryptableCount: skipped.length,
225
- missingKeyIds: [...new Set(skipped.map((entry) => entry.keyId))].sort(),
226
- };
227
- }
228
- function accessEntries(entries) {
229
- return entries
230
- .slice()
231
- .sort((left, right) => right.accessedAt.localeCompare(left.accessedAt))
232
- .slice(0, 20)
233
- .map((entry) => ({
234
- id: entry.id,
235
- messageId: entry.messageId ?? null,
236
- threadId: entry.threadId ?? null,
237
- tool: entry.tool,
238
- reason: entry.reason,
239
- mailboxRole: entry.mailboxRole ?? null,
240
- compartmentKind: entry.compartmentKind ?? null,
241
- ownerEmail: entry.ownerEmail ?? null,
242
- source: entry.source ?? null,
243
- accessedAt: entry.accessedAt,
244
- }));
245
- }
246
- function accessProvenance(message) {
247
- const provenance = (0, core_1.describeMailProvenance)(message);
248
- return {
249
- mailboxRole: provenance.mailboxRole,
250
- compartmentKind: message.compartmentKind,
251
- ownerEmail: provenance.ownerEmail,
252
- source: provenance.source,
253
- };
254
- }
255
- function emitMailRead(agentName, mode, status) {
256
- (0, runtime_1.emitNervesEvent)({
257
- component: "heart",
258
- event: "heart.mailbox_mail_read",
259
- message: "reading Mailbox mail surface",
260
- meta: { agentName, mode, status },
261
- });
262
- }
263
- function statusFromReaderFailure(reason) {
264
- return reason;
265
- }
266
- async function readMailView(agentName) {
267
- const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)(agentName);
268
- if (!resolved.ok) {
269
- const status = statusFromReaderFailure(resolved.reason);
270
- emitMailRead(agentName, "list", status);
271
- return unavailableMailView(agentName, status, resolved.error);
272
- }
273
- try {
274
- const stored = await resolved.store.listMessages({ agentId: agentName, limit: MAILBOX_MAIL_SUMMARY_LIMIT });
275
- const result = decryptVisibleMessages(stored, resolved.config.privateKeys);
276
- const summaries = result.decrypted.map(mailSummary);
277
- const screener = (await resolved.store.listScreenerCandidates({ agentId: agentName, status: "pending", limit: 100 }))
278
- .map(screenerCandidate);
279
- // Cap outbound records returned to the UI. The mailbox tab shows a
280
- // bounded recent-outbound view; pulling the entire history blocks the
281
- // Mailbox tab on a loading spinner while the blob/file store grinds
282
- // through every outbound record the agent has ever written.
283
- const outbound = (await resolved.store.listMailOutbound(agentName, { limit: MAILBOX_MAIL_OUTBOUND_LIMIT })).map(outboundRecord);
284
- await resolved.store.recordAccess({
285
- agentId: agentName,
286
- tool: "mailbox_mail_list",
287
- reason: "mailbox read-only mailbox",
288
- });
289
- const accessLog = accessEntries(await resolved.store.listAccessLog(agentName));
290
- emitMailRead(agentName, "list", "ready");
291
- return {
292
- status: "ready",
293
- agentName,
294
- mailboxAddress: resolved.config.mailboxAddress,
295
- generatedAt: new Date().toISOString(),
296
- store: {
297
- kind: resolved.storeKind,
298
- label: resolved.storeLabel,
299
- },
300
- folders: buildFolders(summaries, outbound),
301
- messages: summaries.slice(0, MAILBOX_MAIL_LIST_LIMIT),
302
- screener,
303
- outbound,
304
- recovery: buildRecovery(summaries, result.skipped),
305
- accessLog,
306
- error: null,
307
- };
308
- }
309
- catch (error) {
310
- const message = error instanceof Error ? error.message : String(error);
311
- emitMailRead(agentName, "list", "error");
312
- return unavailableMailView(agentName, "error", message);
313
- }
314
- }
315
- async function readMailMessageView(agentName, messageId) {
316
- const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)(agentName);
317
- if (!resolved.ok) {
318
- const status = statusFromReaderFailure(resolved.reason);
319
- emitMailRead(agentName, "message", status);
320
- return unavailableMessageView(agentName, status, resolved.error);
321
- }
322
- try {
323
- const stored = await resolved.store.getMessage(messageId);
324
- if (!stored || stored.agentId !== agentName) {
325
- emitMailRead(agentName, "message", "not-found");
326
- return {
327
- status: "not-found",
328
- agentName,
329
- mailboxAddress: resolved.config.mailboxAddress,
330
- generatedAt: new Date().toISOString(),
331
- message: null,
332
- accessLog: accessEntries(await resolved.store.listAccessLog(agentName)),
333
- error: `No visible mail message found for ${messageId}.`,
334
- };
335
- }
336
- const decrypted = (0, file_store_1.decryptMessages)([stored], resolved.config.privateKeys)[0];
337
- const access = await resolved.store.recordAccess({
338
- agentId: agentName,
339
- messageId,
340
- tool: "mailbox_mail_message",
341
- reason: "mailbox read-only message body",
342
- ...accessProvenance(decrypted),
343
- });
344
- const body = decrypted.private.text.length > MAILBOX_MAIL_BODY_LIMIT
345
- ? decrypted.private.text.slice(0, MAILBOX_MAIL_BODY_LIMIT)
346
- : decrypted.private.text;
347
- const detail = {
348
- ...mailSummary(decrypted),
349
- text: body,
350
- htmlAvailable: typeof decrypted.private.html === "string" && decrypted.private.html.length > 0,
351
- bodyTruncated: decrypted.private.text.length > MAILBOX_MAIL_BODY_LIMIT,
352
- attachments: decrypted.private.attachments,
353
- access: {
354
- tool: access.tool,
355
- reason: access.reason,
356
- accessedAt: access.accessedAt,
357
- },
358
- };
359
- emitMailRead(agentName, "message", "ready");
360
- return {
361
- status: "ready",
362
- agentName,
363
- mailboxAddress: resolved.config.mailboxAddress,
364
- generatedAt: new Date().toISOString(),
365
- message: detail,
366
- accessLog: accessEntries(await resolved.store.listAccessLog(agentName)),
367
- error: null,
368
- };
369
- }
370
- catch (error) {
371
- const message = error instanceof Error ? error.message : String(error);
372
- emitMailRead(agentName, "message", "error");
373
- return unavailableMessageView(agentName, "error", message);
374
- }
375
- }