@ouro.bot/cli 0.1.0-alpha.585 → 0.1.0-alpha.586
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/changelog.json +8 -0
- package/dist/mailroom/search-cache.js +12 -0
- package/dist/repertoire/tools-mail.js +62 -8
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.586",
|
|
6
|
+
"changes": [
|
|
7
|
+
"`mail_status`, `mail_recent`, `mail_search`, and `mail_index_refresh` now flag a 'mail substrate divergence' when the encrypted mailroom store reports zero visible messages but the on-disk search cache still holds documents from prior imports — the post-rotation / hosted→local-fallback / wiped-store state that previously rendered as a silent 'no mail' answer indistinguishable from a clean onboarding.",
|
|
8
|
+
"Mail absence answers from a divergent runtime now point at vault inspection (`mailroom.mode`, `mailroom.azureAccountUrl`, `mailroom.storePath`) and re-import recovery, so agents stop treating a broken substrate as evidence that the human inbox is empty.",
|
|
9
|
+
"The substrate-divergence snapshot counts cache `.json` entries via `readdir` and ignores subdirectories and non-json files, so the diagnostic stays cheap on bundles holding tens of thousands of cached documents."
|
|
10
|
+
]
|
|
11
|
+
},
|
|
4
12
|
{
|
|
5
13
|
"version": "0.1.0-alpha.585",
|
|
6
14
|
"changes": [
|
|
@@ -38,6 +38,7 @@ exports.buildMailSearchCacheDocument = buildMailSearchCacheDocument;
|
|
|
38
38
|
exports.upsertMailSearchCacheDocument = upsertMailSearchCacheDocument;
|
|
39
39
|
exports.syncMailSearchCacheMetadata = syncMailSearchCacheMetadata;
|
|
40
40
|
exports.searchMailSearchCache = searchMailSearchCache;
|
|
41
|
+
exports.snapshotMailSearchCache = snapshotMailSearchCache;
|
|
41
42
|
exports.readMailSearchCoverageRecord = readMailSearchCoverageRecord;
|
|
42
43
|
exports.writeMailSearchCoverageRecord = writeMailSearchCoverageRecord;
|
|
43
44
|
exports.resetMailSearchCacheForTests = resetMailSearchCacheForTests;
|
|
@@ -208,6 +209,17 @@ function searchMailSearchCache(filters, options) {
|
|
|
208
209
|
}
|
|
209
210
|
return typeof filters.limit === "number" ? ordered.slice(0, filters.limit) : ordered;
|
|
210
211
|
}
|
|
212
|
+
function snapshotMailSearchCache(agentId, options) {
|
|
213
|
+
const dir = cacheDir(agentId, options);
|
|
214
|
+
if (!fs.existsSync(dir))
|
|
215
|
+
return { totalDocuments: 0 };
|
|
216
|
+
let total = 0;
|
|
217
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
218
|
+
if (entry.isFile() && entry.name.endsWith(".json"))
|
|
219
|
+
total += 1;
|
|
220
|
+
}
|
|
221
|
+
return { totalDocuments: total };
|
|
222
|
+
}
|
|
211
223
|
function readMailSearchCoverageRecord(key, options) {
|
|
212
224
|
const document = readJsonDocument(coveragePath(key, options));
|
|
213
225
|
if (!document || document.schemaVersion !== 1 || document.agentId !== key.agentId)
|
|
@@ -519,13 +519,42 @@ async function renderSourceGrantStatus(config, agentId) {
|
|
|
519
519
|
];
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* When the encrypted mail store is empty but the on-disk search cache holds
|
|
524
|
+
* decrypted documents from prior imports, the agent has lost access to mail it
|
|
525
|
+
* previously had — typically because mail keys were rotated, the hosted blob
|
|
526
|
+
* pointer was dropped from the vault, or the encrypted store was wiped. The
|
|
527
|
+
* tools used to silently report "0 messages" in that state, which is the same
|
|
528
|
+
* answer they give for a fresh onboarding — so the agent could not tell a
|
|
529
|
+
* substrate failure from a clean slate. Surface the divergence loudly so the
|
|
530
|
+
* agent treats absence answers as suspect until the substrate is repaired.
|
|
531
|
+
*/
|
|
532
|
+
function describeMailSubstrateDivergence(input) {
|
|
533
|
+
if (input.visibleMessageCount > 0)
|
|
534
|
+
return null;
|
|
535
|
+
const snapshot = input.snapshot ?? (0, search_cache_1.snapshotMailSearchCache)(input.agentId);
|
|
536
|
+
if (snapshot.totalDocuments === 0)
|
|
537
|
+
return null;
|
|
538
|
+
return [
|
|
539
|
+
`mail substrate divergence: encrypted ${input.storeKind} store at ${input.storeLabel} has 0 visible messages, but the on-disk search cache for ${input.agentId} holds ${snapshot.totalDocuments} document(s).`,
|
|
540
|
+
"interpretation: this is not a fresh onboarding — prior imports populated the cache, then the encrypted store became unreachable (common causes: mail key rotation, hosted-store pointer dropped from vault during repair, encrypted store wiped). Mail absence answers from this runtime are not authoritative until the substrate is repaired.",
|
|
541
|
+
`agent next move: inspect runtime credentials (mailroom.mode, mailroom.azureAccountUrl, mailroom.storePath) — if the agent was previously hosted, the vault is missing the hosted pointer; coordinate with the human to restore it. If local mode is correct, re-import via 'ouro mail import-mbox --agent ${input.agentId} --owner-email <human-email> --source <source> --discover' so the encrypted store catches up to the cache.`,
|
|
542
|
+
].join("\n");
|
|
543
|
+
}
|
|
522
544
|
async function renderEmptyMailResult(input) {
|
|
523
545
|
const anyVisible = await input.store.listMessages({ agentId: input.agentId, limit: 1 });
|
|
524
546
|
if (anyVisible.length === 0) {
|
|
525
547
|
const sourceGrantStatus = await renderSourceGrantStatus(input.config, input.agentId);
|
|
548
|
+
const divergence = describeMailSubstrateDivergence({
|
|
549
|
+
agentId: input.agentId,
|
|
550
|
+
storeKind: input.storeKind,
|
|
551
|
+
storeLabel: input.storeLabel,
|
|
552
|
+
visibleMessageCount: 0,
|
|
553
|
+
});
|
|
526
554
|
return [
|
|
527
555
|
"No visible mail yet.",
|
|
528
556
|
`mail onboarding status: Mailroom is provisioned for ${input.config.mailboxAddress}, but this agent's encrypted store has 0 messages.`,
|
|
557
|
+
...(divergence ? [divergence] : []),
|
|
529
558
|
...sourceGrantStatus,
|
|
530
559
|
"interpretation: this is not evidence that the human's HEY inbox is empty; Agent Mail has not yet received or imported mail visible to this agent.",
|
|
531
560
|
`agent next move: guide setup from docs/agent-mail-setup.md. If HEY mail is needed, ensure the delegated hey alias exists, first try ouro mail import-mbox --agent ${input.agentId} --owner-email <human-email> --source hey --discover so Ouro can find a browser-downloaded export in .playwright-mcp or Downloads. Only ask the human for a file path if discovery cannot find a unique MBOX, then run ouro mail import-mbox --agent ${input.agentId} --owner-email <human-email> --source hey --file <mbox-path>. Verify with mail_recent/mail_search/Ouro Mailbox.`,
|
|
@@ -932,8 +961,8 @@ async function searchSuccessfulImportArchives(input) {
|
|
|
932
961
|
}
|
|
933
962
|
return matches.sort((left, right) => right.receivedAt.localeCompare(left.receivedAt));
|
|
934
963
|
}
|
|
935
|
-
async function renderMailStatus(
|
|
936
|
-
const sourceGrantStatus = await renderSourceGrantStatus(config, agentId);
|
|
964
|
+
async function renderMailStatus(input) {
|
|
965
|
+
const sourceGrantStatus = await renderSourceGrantStatus(input.config, input.agentId);
|
|
937
966
|
const delegatedLines = sourceGrantStatus
|
|
938
967
|
.flatMap((line) => line.startsWith("delegated source aliases: ")
|
|
939
968
|
? line
|
|
@@ -949,16 +978,24 @@ async function renderMailStatus(agentId, config, storeLabel) {
|
|
|
949
978
|
: `- delegated: ${grant}`;
|
|
950
979
|
})
|
|
951
980
|
: [`- ${line}`]);
|
|
981
|
+
const visible = await input.store.listMessages({ agentId: input.agentId, limit: 1 });
|
|
982
|
+
const divergence = describeMailSubstrateDivergence({
|
|
983
|
+
agentId: input.agentId,
|
|
984
|
+
storeKind: input.storeKind,
|
|
985
|
+
storeLabel: input.storeLabel,
|
|
986
|
+
visibleMessageCount: visible.length,
|
|
987
|
+
});
|
|
952
988
|
return [
|
|
953
|
-
`mailbox: ${config.mailboxAddress}`,
|
|
954
|
-
`store: ${storeLabel}`,
|
|
989
|
+
`mailbox: ${input.config.mailboxAddress}`,
|
|
990
|
+
`store: ${input.storeLabel}`,
|
|
991
|
+
...(divergence ? [divergence] : []),
|
|
955
992
|
"lane map:",
|
|
956
|
-
`- native: ${config.mailboxAddress}`,
|
|
993
|
+
`- native: ${input.config.mailboxAddress}`,
|
|
957
994
|
...delegatedLines,
|
|
958
995
|
"recent archives:",
|
|
959
|
-
...renderRecentArchiveStatus(agentId),
|
|
996
|
+
...renderRecentArchiveStatus(input.agentId),
|
|
960
997
|
"recent imports:",
|
|
961
|
-
...renderRecentImportOperations(agentId),
|
|
998
|
+
...renderRecentImportOperations(input.agentId),
|
|
962
999
|
].join("\n");
|
|
963
1000
|
}
|
|
964
1001
|
exports.mailToolDefinitions = [
|
|
@@ -985,7 +1022,13 @@ exports.mailToolDefinitions = [
|
|
|
985
1022
|
tool: "mail_status",
|
|
986
1023
|
reason: "mail operating model overview",
|
|
987
1024
|
});
|
|
988
|
-
return renderMailStatus(
|
|
1025
|
+
return renderMailStatus({
|
|
1026
|
+
agentId: resolved.agentName,
|
|
1027
|
+
config: resolved.config,
|
|
1028
|
+
store: resolved.store,
|
|
1029
|
+
storeKind: resolved.storeKind,
|
|
1030
|
+
storeLabel: resolved.storeLabel,
|
|
1031
|
+
});
|
|
989
1032
|
},
|
|
990
1033
|
summaryKeys: [],
|
|
991
1034
|
},
|
|
@@ -1039,6 +1082,8 @@ exports.mailToolDefinitions = [
|
|
|
1039
1082
|
agentId: resolved.agentName,
|
|
1040
1083
|
config: resolved.config,
|
|
1041
1084
|
store: resolved.store,
|
|
1085
|
+
storeKind: resolved.storeKind,
|
|
1086
|
+
storeLabel: resolved.storeLabel,
|
|
1042
1087
|
...(scope ? { scope } : {}),
|
|
1043
1088
|
...(args.source ? { source: args.source } : {}),
|
|
1044
1089
|
});
|
|
@@ -1394,6 +1439,8 @@ exports.mailToolDefinitions = [
|
|
|
1394
1439
|
agentId: resolved.agentName,
|
|
1395
1440
|
config: resolved.config,
|
|
1396
1441
|
store: resolved.store,
|
|
1442
|
+
storeKind: resolved.storeKind,
|
|
1443
|
+
storeLabel: resolved.storeLabel,
|
|
1397
1444
|
...(scope ? { scope } : {}),
|
|
1398
1445
|
...(args.source ? { source: args.source } : {}),
|
|
1399
1446
|
}), {
|
|
@@ -1485,6 +1532,12 @@ exports.mailToolDefinitions = [
|
|
|
1485
1532
|
reason: args.reason || "refresh mail search index",
|
|
1486
1533
|
});
|
|
1487
1534
|
const { coverage } = refreshed;
|
|
1535
|
+
const divergence = describeMailSubstrateDivergence({
|
|
1536
|
+
agentId: resolved.agentName,
|
|
1537
|
+
storeKind: resolved.storeKind,
|
|
1538
|
+
storeLabel: resolved.storeLabel,
|
|
1539
|
+
visibleMessageCount: coverage.visibleMessageCount,
|
|
1540
|
+
});
|
|
1488
1541
|
return [
|
|
1489
1542
|
"mail search index refreshed.",
|
|
1490
1543
|
`scope: ${scope ?? "all"}${args.source ? `; source: ${args.source}` : ""}${placement ? `; placement: ${placement}` : ""}`,
|
|
@@ -1496,6 +1549,7 @@ exports.mailToolDefinitions = [
|
|
|
1496
1549
|
`indexed at: ${coverage.indexedAt}`,
|
|
1497
1550
|
...(coverage.oldestReceivedAt ? [`oldest: ${coverage.oldestReceivedAt}`] : []),
|
|
1498
1551
|
...(coverage.newestReceivedAt ? [`newest: ${coverage.newestReceivedAt}`] : []),
|
|
1552
|
+
...(divergence ? [divergence] : []),
|
|
1499
1553
|
].join("\n");
|
|
1500
1554
|
}
|
|
1501
1555
|
catch (error) {
|