@ouro.bot/cli 0.1.0-alpha.1318 → 0.1.0-alpha.1319

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 CHANGED
@@ -1,6 +1,12 @@
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.1319",
6
+ "changes": [
7
+ "The in-turn mail tools now carry Ouro AX cards, and their refusals end with a code the card names."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1318",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1318",
2
+ "runtimeVersion": "0.1.0-alpha.1319",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1318</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1319</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -10,6 +10,7 @@ exports.searchSuccessfulImportArchives = searchSuccessfulImportArchives;
10
10
  exports.mailToolsEnabled = mailToolsEnabled;
11
11
  const node_fs_1 = __importDefault(require("node:fs"));
12
12
  const node_path_1 = __importDefault(require("node:path"));
13
+ const tools_base_1 = require("./tools-base");
13
14
  const friends_1 = require("@ouro.bot/friends");
14
15
  const file_store_1 = require("../mailroom/file-store");
15
16
  const reader_1 = require("../mailroom/reader");
@@ -882,15 +883,20 @@ exports.mailToolDefinitions = [
882
883
  parameters: { type: "object", properties: {} },
883
884
  },
884
885
  },
886
+ ax: { id: "tool:mail_status", group: "turn-mail", when: "Pick this to see which mailboxes are connected and whether the latest mail import worked, before trusting what the mail looks like.", effect: "write", errors: [
887
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
888
+ { code: "family-only", means: "Mail status includes your owner's delegated mailbox, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
889
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
890
+ ] },
885
891
  handler: async (_args, ctx) => {
886
892
  if (!trustAllowsMailRead(ctx))
887
- return "mail is private; this tool is only available in trusted contexts.";
893
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
888
894
  const blocked = delegatedHumanMailBlocked(ctx);
889
895
  if (blocked)
890
- return blocked;
896
+ return (0, tools_base_1.withCode)(blocked, "family-only");
891
897
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
892
898
  if (!resolved.ok)
893
- return resolved.error;
899
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
894
900
  await resolved.store.recordAccess({
895
901
  agentId: resolved.agentName,
896
902
  tool: "mail_status",
@@ -924,18 +930,24 @@ exports.mailToolDefinitions = [
924
930
  },
925
931
  },
926
932
  },
933
+ ax: { id: "tool:mail_recent", group: "turn-mail", when: "Pick this to skim the newest mail by sender and subject, like checking the inbox; to look for something specific, use mail_search.", effect: "write", errors: [
934
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
935
+ { code: "family-only", means: "Delegated or all scope includes your owner's own mailbox, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
936
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
937
+ { code: "invalid-arguments", means: "placement or scope wasn't one of its listed values.", fix: "Leave that filter out, or use one of the listed values." },
938
+ ] },
927
939
  handler: async (args, ctx) => {
928
940
  if (!trustAllowsMailRead(ctx))
929
- return "mail is private; this tool is only available in trusted contexts.";
941
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
930
942
  const requestedScope = args.scope === "all" ? "all" : parseScope(args.scope);
931
943
  if (requestedScope === "delegated" || requestedScope === "all") {
932
944
  const blocked = delegatedHumanMailBlocked(ctx);
933
945
  if (blocked)
934
- return blocked;
946
+ return (0, tools_base_1.withCode)(blocked, "family-only");
935
947
  }
936
948
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
937
949
  if (!resolved.ok)
938
- return resolved.error;
950
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
939
951
  const cacheOptions = mailSearchCacheOptionsForStore(resolved.store);
940
952
  const scope = requestedScope === "all"
941
953
  ? undefined
@@ -992,12 +1004,17 @@ exports.mailToolDefinitions = [
992
1004
  },
993
1005
  },
994
1006
  },
1007
+ ax: { id: "tool:mail_compose", group: "turn-mail", when: "Pick this to write an email someone asked you to send, as a draft they can check; it goes out only after mail_send.", effect: "write", errors: [
1008
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1009
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1010
+ { code: "compose-failed", means: "The draft couldn't be made, for example no recipient was given; the text says why.", fix: "Fix what the text names, usually the to addresses, and compose again." },
1011
+ ] },
995
1012
  handler: async (args, ctx) => {
996
1013
  if (!trustAllowsMailRead(ctx))
997
- return "mail is private; this tool is only available in trusted contexts.";
1014
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
998
1015
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
999
1016
  if (!resolved.ok)
1000
- return resolved.error;
1017
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1001
1018
  try {
1002
1019
  const draft = await (0, outbound_1.createMailDraft)({
1003
1020
  store: resolved.store,
@@ -1025,7 +1042,7 @@ exports.mailToolDefinitions = [
1025
1042
  ].join("\n");
1026
1043
  }
1027
1044
  catch (error) {
1028
- return error instanceof Error ? error.message : /* v8 ignore next -- defensive: draft creation throws Error instances. @preserve */ String(error);
1045
+ return (0, tools_base_1.withCode)(error instanceof Error ? error.message : /* v8 ignore next -- defensive: draft creation throws Error instances. @preserve */ String(error), "compose-failed");
1029
1046
  }
1030
1047
  },
1031
1048
  summaryKeys: ["to", "subject"],
@@ -1049,18 +1066,25 @@ exports.mailToolDefinitions = [
1049
1066
  },
1050
1067
  },
1051
1068
  },
1069
+ ax: { id: "tool:mail_send", group: "turn-mail", when: "Pick this only once someone has clearly approved a drafted email going out; write it first with mail_compose.", effect: "write", errors: [
1070
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1071
+ { code: "family-only", means: "Sending mail needs a family member or the agent itself; this conversation is neither.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1072
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1073
+ { code: "missing-draft-id", means: "draft_id was empty.", fix: "Call again with the draft id mail_compose returned." },
1074
+ { code: "send-failed", means: "The send was refused or failed: no confirmation, no such draft, policy said no, or the transport broke; the text says which.", fix: "If confirmation was missing, ask for approval and pass CONFIRM_SEND; otherwise tell the person it didn't send." },
1075
+ ] },
1052
1076
  handler: async (args, ctx) => {
1053
1077
  if (!trustAllowsMailRead(ctx))
1054
- return "mail is private; this tool is only available in trusted contexts.";
1078
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1055
1079
  const blocked = outboundSendBlocked(ctx);
1056
1080
  if (blocked)
1057
- return blocked;
1081
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1058
1082
  const draftId = (args.draft_id ?? "").trim();
1059
1083
  if (!draftId)
1060
- return "draft_id is required.";
1084
+ return (0, tools_base_1.withCode)("draft_id is required.", "missing-draft-id");
1061
1085
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1062
1086
  if (!resolved.ok)
1063
- return resolved.error;
1087
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1064
1088
  try {
1065
1089
  const transport = (0, outbound_1.resolveOutboundTransport)(resolved.config);
1066
1090
  const sent = await (0, outbound_1.confirmMailDraftSend)({
@@ -1098,7 +1122,7 @@ exports.mailToolDefinitions = [
1098
1122
  ].join("\n");
1099
1123
  }
1100
1124
  catch (error) {
1101
- return error instanceof Error ? error.message : /* v8 ignore next -- defensive: send confirmation throws Error instances. @preserve */ String(error);
1125
+ return (0, tools_base_1.withCode)(error instanceof Error ? error.message : /* v8 ignore next -- defensive: send confirmation throws Error instances. @preserve */ String(error), "send-failed");
1102
1126
  }
1103
1127
  },
1104
1128
  summaryKeys: ["draft_id"],
@@ -1124,13 +1148,18 @@ exports.mailToolDefinitions = [
1124
1148
  },
1125
1149
  },
1126
1150
  },
1151
+ ax: { id: "tool:mail_outbox", group: "turn-mail", when: "Pick this to check what you have already drafted or sent, and whether a sent email was delivered or bounced.", effect: "write", errors: [
1152
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1153
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1154
+ { code: "invalid-arguments", means: "status wasn't one of its listed values.", fix: "Leave that filter out, or use one of the listed values." },
1155
+ ] },
1127
1156
  handler: async (args, ctx) => {
1128
1157
  if (!trustAllowsMailRead(ctx))
1129
- return "mail is private; this tool is only available in trusted contexts.";
1158
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1130
1159
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1131
1160
  /* v8 ignore next -- defensive: reader resolution covered separately for read tools; mail_outbox tests use cached config @preserve */
1132
1161
  if (!resolved.ok)
1133
- return resolved.error;
1162
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1134
1163
  const limit = numberArg(args.limit, 20, 1, 50);
1135
1164
  const records = await resolved.store.listMailOutbound(resolved.agentName);
1136
1165
  const filtered = args.status
@@ -1190,21 +1219,28 @@ exports.mailToolDefinitions = [
1190
1219
  },
1191
1220
  },
1192
1221
  },
1222
+ ax: { id: "tool:mail_search", group: "turn-mail", when: "Pick this to look up a particular email by words in it, a sender or a topic; to browse the latest, use mail_recent.", effect: "write", errors: [
1223
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1224
+ { code: "family-only", means: "Searching delegated or all mail includes your owner's own mailbox, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1225
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1226
+ { code: "missing-query", means: "query was empty.", fix: "Call again with the words to look for." },
1227
+ { code: "invalid-arguments", means: "placement or scope wasn't one of its listed values.", fix: "Leave that filter out, or use one of the listed values." },
1228
+ ] },
1193
1229
  handler: async (args, ctx) => {
1194
1230
  if (!trustAllowsMailRead(ctx))
1195
- return "mail is private; this tool is only available in trusted contexts.";
1231
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1196
1232
  const query = (args.query ?? "").trim().toLowerCase();
1197
1233
  if (!query)
1198
- return "query is required.";
1234
+ return (0, tools_base_1.withCode)("query is required.", "missing-query");
1199
1235
  const terms = mailSearchTerms(query);
1200
1236
  const requestedScope = args.scope === "all" ? "all" : parseScope(args.scope);
1201
1237
  const explicitScope = (args.scope ?? "").trim().length > 0;
1202
1238
  if (!familyOrAgentSelf(ctx) && explicitScope && requestedScope !== "native") {
1203
- return "delegated human mail requires family trust.";
1239
+ return (0, tools_base_1.withCode)("delegated human mail requires family trust.", "family-only");
1204
1240
  }
1205
1241
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1206
1242
  if (!resolved.ok)
1207
- return resolved.error;
1243
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1208
1244
  const cacheOptions = mailSearchCacheOptionsForStore(resolved.store);
1209
1245
  const scope = requestedScope === "all"
1210
1246
  ? undefined
@@ -1423,18 +1459,24 @@ exports.mailToolDefinitions = [
1423
1459
  },
1424
1460
  },
1425
1461
  },
1462
+ ax: { id: "tool:mail_index_refresh", group: "turn-mail", when: "Pick this when mail_search finds nothing in your owner's delegated mail but it probably exists, before saying it isn't there.", effect: "write", errors: [
1463
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1464
+ { code: "family-only", means: "Refreshing delegated mail touches your owner's own mailbox, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1465
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1466
+ { code: "index-refresh-failed", means: "Rebuilding the search index failed; the text gives the reason.", fix: "Retry once; if it fails again, tell your owner search may be missing recent mail." },
1467
+ ] },
1426
1468
  handler: async (args, ctx) => {
1427
1469
  if (!trustAllowsMailRead(ctx))
1428
- return "mail is private; this tool is only available in trusted contexts.";
1470
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1429
1471
  const requestedScope = args.scope === "all" ? "all" : parseScope(args.scope);
1430
1472
  if (requestedScope === "delegated" || requestedScope === "all" || args.source?.trim()) {
1431
1473
  const blocked = delegatedHumanMailBlocked(ctx);
1432
1474
  if (blocked)
1433
- return blocked;
1475
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1434
1476
  }
1435
1477
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1436
1478
  if (!resolved.ok)
1437
- return resolved.error;
1479
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1438
1480
  const placement = parsePlacement(args.placement);
1439
1481
  const scope = requestedScope === "all"
1440
1482
  ? undefined
@@ -1480,7 +1522,7 @@ exports.mailToolDefinitions = [
1480
1522
  }
1481
1523
  catch (error) {
1482
1524
  const message = error instanceof Error ? error.message : String(error);
1483
- return `mail search index refresh failed: ${message}`;
1525
+ return (0, tools_base_1.withCode)(`mail search index refresh failed: ${message}`, "index-refresh-failed");
1484
1526
  }
1485
1527
  },
1486
1528
  summaryKeys: ["scope", "source", "placement"],
@@ -1502,22 +1544,29 @@ exports.mailToolDefinitions = [
1502
1544
  },
1503
1545
  },
1504
1546
  },
1547
+ ax: { id: "tool:mail_body", group: "turn-mail", when: "Pick this to read the full text of one email you found; to follow a whole back-and-forth, use mail_thread.", effect: "write", errors: [
1548
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1549
+ { code: "family-only", means: "That message is in your owner's delegated mailbox, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1550
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1551
+ { code: "missing-message-id", means: "message_id was empty.", fix: "Call again with an id from mail_recent or mail_search." },
1552
+ { code: "message-not-found", means: "No mail you can see has that id.", fix: "Find the current id with mail_recent or mail_search, then retry." },
1553
+ ] },
1505
1554
  handler: async (args, ctx) => {
1506
1555
  if (!trustAllowsMailRead(ctx))
1507
- return "mail is private; this tool is only available in trusted contexts.";
1556
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1508
1557
  const messageId = (args.message_id ?? "").trim();
1509
1558
  if (!messageId)
1510
- return "message_id is required.";
1559
+ return (0, tools_base_1.withCode)("message_id is required.", "missing-message-id");
1511
1560
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1512
1561
  if (!resolved.ok)
1513
- return resolved.error;
1562
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1514
1563
  const cached = (0, body_cache_1.getCachedMailBody)(messageId);
1515
1564
  if (cached && cached.agentId === resolved.agentName) {
1516
1565
  /* v8 ignore start -- cached delegated-blocked path: same trust check as the uncached branch (line 1198), narrow to the cache-hit + delegated + non-trusted-for-delegated combination @preserve */
1517
1566
  if (cached.compartmentKind === "delegated") {
1518
1567
  const blocked = delegatedHumanMailBlocked(ctx);
1519
1568
  if (blocked)
1520
- return blocked;
1569
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1521
1570
  }
1522
1571
  /* v8 ignore stop */
1523
1572
  await resolved.store.recordAccess({
@@ -1547,12 +1596,12 @@ exports.mailToolDefinitions = [
1547
1596
  }
1548
1597
  const message = await resolved.store.getMessage(messageId);
1549
1598
  if (!message || message.agentId !== resolved.agentName)
1550
- return `No visible mail message found for ${messageId}.`;
1599
+ return (0, tools_base_1.withCode)(`No visible mail message found for ${messageId}.`, "message-not-found");
1551
1600
  if (message.compartmentKind === "delegated") {
1552
1601
  const blocked = delegatedHumanMailBlocked(ctx);
1553
1602
  /* v8 ignore next -- same delegated trust gate as cached body and search paths; focused tests cover the blocked behavior. @preserve */
1554
1603
  if (blocked)
1555
- return blocked;
1604
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1556
1605
  }
1557
1606
  await resolved.store.recordAccess({
1558
1607
  agentId: resolved.agentName,
@@ -1607,22 +1656,29 @@ exports.mailToolDefinitions = [
1607
1656
  },
1608
1657
  },
1609
1658
  },
1659
+ ax: { id: "tool:mail_thread", group: "turn-mail", when: "Pick this to follow a whole email conversation, oldest first, around one message; then open single messages with mail_body.", effect: "write", errors: [
1660
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1661
+ { code: "family-only", means: "Delegated or all scope includes your owner's own mailbox, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1662
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1663
+ { code: "missing-message-id", means: "message_id was empty.", fix: "Call again with an id from mail_recent or mail_search." },
1664
+ { code: "invalid-arguments", means: "scope wasn't native, delegated or all.", fix: "Leave that filter out, or use one of the listed values." },
1665
+ ] },
1610
1666
  handler: async (args, ctx) => {
1611
1667
  /* v8 ignore start -- mail_thread arg + pool-assembly defensive branches: parseScope branching, delegated-block early returns, seedStored null path, agentId mismatch, non-family scope cascade, seedById merge variants — incidental shape, real coverage via integration tests above @preserve */
1612
1668
  if (!trustAllowsMailRead(ctx))
1613
- return "mail is private; this tool is only available in trusted contexts.";
1669
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1614
1670
  const messageId = (args.message_id ?? "").trim();
1615
1671
  if (!messageId)
1616
- return "message_id is required.";
1672
+ return (0, tools_base_1.withCode)("message_id is required.", "missing-message-id");
1617
1673
  const requestedScope = args.scope === "all" ? "all" : parseScope(args.scope);
1618
1674
  if (requestedScope === "delegated" || requestedScope === "all") {
1619
1675
  const blocked = delegatedHumanMailBlocked(ctx);
1620
1676
  if (blocked)
1621
- return blocked;
1677
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1622
1678
  }
1623
1679
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1624
1680
  if (!resolved.ok)
1625
- return resolved.error;
1681
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1626
1682
  const seedStored = await resolved.store.getMessage(messageId);
1627
1683
  const seedById = seedStored && seedStored.agentId === resolved.agentName ? seedStored : null;
1628
1684
  const scope = requestedScope === "all" ? undefined : requestedScope ?? (familyOrAgentSelf(ctx) ? undefined : "native");
@@ -1701,15 +1757,21 @@ exports.mailToolDefinitions = [
1701
1757
  },
1702
1758
  },
1703
1759
  },
1760
+ ax: { id: "tool:mail_screener", group: "turn-mail", when: "Pick this to see mail from unknown senders waiting for a decision, so you can ask family whether to let each one through.", effect: "write", errors: [
1761
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1762
+ { code: "family-only", means: "The Screener can include your owner's delegated mail, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1763
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1764
+ { code: "invalid-arguments", means: "status or placement wasn't one of its listed values.", fix: "Leave that filter out, or use one of the listed values." },
1765
+ ] },
1704
1766
  handler: async (args, ctx) => {
1705
1767
  if (!trustAllowsMailRead(ctx))
1706
- return "mail is private; this tool is only available in trusted contexts.";
1768
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1707
1769
  const blocked = delegatedHumanMailBlocked(ctx);
1708
1770
  if (blocked)
1709
- return blocked;
1771
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1710
1772
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1711
1773
  if (!resolved.ok)
1712
- return resolved.error;
1774
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1713
1775
  const candidates = await resolved.store.listScreenerCandidates({
1714
1776
  agentId: resolved.agentName,
1715
1777
  status: parseCandidateStatus(args.status) ?? "pending",
@@ -1746,21 +1808,31 @@ exports.mailToolDefinitions = [
1746
1808
  },
1747
1809
  },
1748
1810
  },
1811
+ ax: { id: "tool:mail_decide", group: "turn-mail", when: "Pick this after family tells you what to do with mail from an unknown sender: let it in, link it to a friend, or discard it.", effect: "write", errors: [
1812
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1813
+ { code: "family-only", means: "Screener decisions need a family member or the agent itself; this conversation is neither.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1814
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1815
+ { code: "invalid-action", means: "action was empty or not one of the listed decisions.", fix: "Call again with one decision, such as allow-sender or discard." },
1816
+ { code: "missing-reason", means: "reason was empty.", fix: "Call again saying who decided this and why." },
1817
+ { code: "missing-candidate", means: "Neither candidate_id nor message_id was given.", fix: "Call again with a candidate_id from mail_screener." },
1818
+ { code: "candidate-not-found", means: "No Screener candidate has that id.", fix: "Call mail_screener for the current ids, then retry." },
1819
+ { code: "message-not-found", means: "No mail you can see has that id.", fix: "Find the current id with mail_recent or mail_search, then retry." },
1820
+ ] },
1749
1821
  handler: async (args, ctx) => {
1750
1822
  if (!trustAllowsMailRead(ctx))
1751
- return "mail is private; this tool is only available in trusted contexts.";
1823
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1752
1824
  const blocked = screenerDecisionBlocked(ctx);
1753
1825
  if (blocked)
1754
- return blocked;
1826
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1755
1827
  const action = parseDecisionAction(args.action);
1756
1828
  if (!action)
1757
- return "action is required and must be a supported mail decision.";
1829
+ return (0, tools_base_1.withCode)("action is required and must be a supported mail decision.", "invalid-action");
1758
1830
  const reason = (args.reason ?? "").trim();
1759
1831
  if (!reason)
1760
- return "reason is required.";
1832
+ return (0, tools_base_1.withCode)("reason is required.", "missing-reason");
1761
1833
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1762
1834
  if (!resolved.ok)
1763
- return resolved.error;
1835
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1764
1836
  let messageId = (args.message_id ?? "").trim();
1765
1837
  const candidateId = (args.candidate_id ?? "").trim();
1766
1838
  let candidate;
@@ -1768,14 +1840,14 @@ exports.mailToolDefinitions = [
1768
1840
  const candidates = await resolved.store.listScreenerCandidates({ agentId: resolved.agentName, limit: 200 });
1769
1841
  candidate = candidates.find((entry) => entry.id === candidateId);
1770
1842
  if (!candidate)
1771
- return `No Screener candidate found for ${candidateId}.`;
1843
+ return (0, tools_base_1.withCode)(`No Screener candidate found for ${candidateId}.`, "candidate-not-found");
1772
1844
  messageId = candidate.messageId;
1773
1845
  }
1774
1846
  if (!messageId)
1775
- return "candidate_id or message_id is required.";
1847
+ return (0, tools_base_1.withCode)("candidate_id or message_id is required.", "missing-candidate");
1776
1848
  const message = await resolved.store.getMessage(messageId);
1777
1849
  if (!message || message.agentId !== resolved.agentName)
1778
- return `No visible mail message found for ${messageId}.`;
1850
+ return (0, tools_base_1.withCode)(`No visible mail message found for ${messageId}.`, "message-not-found");
1779
1851
  const decision = await (0, policy_1.applyMailDecision)({
1780
1852
  store: resolved.store,
1781
1853
  agentId: resolved.agentName,
@@ -1826,15 +1898,21 @@ exports.mailToolDefinitions = [
1826
1898
  parameters: { type: "object", properties: {} },
1827
1899
  },
1828
1900
  },
1901
+ ax: { id: "tool:mail_access_log", group: "turn-mail", when: "Pick this when someone asks who or what opened mail lately, and why, to audit reading rather than to read mail itself.", effect: "read", idempotent: true, errors: [
1902
+ { code: "not-trusted", means: "Mail is private, and this conversation isn't with someone trusted enough to see it.", fix: "Tell them you can't share mail here; your owner can ask from a trusted chat." },
1903
+ { code: "family-only", means: "The access log covers your owner's delegated mail, which only family can see.", fix: "Ask your owner for it from a family chat, or stick to your own native mailbox." },
1904
+ { code: "mail-unavailable", means: "The mailbox isn't set up or its vault credentials can't be read; the text says what is missing.", fix: "If the text names an ouro connect mail command, run it; otherwise tell your owner mail needs setting up." },
1905
+ ] },
1906
+ riskProfile: { mutates: "none", risk: "low" },
1829
1907
  handler: async (_args, ctx) => {
1830
1908
  if (!trustAllowsMailRead(ctx))
1831
- return "mail is private; this tool is only available in trusted contexts.";
1909
+ return (0, tools_base_1.withCode)("mail is private; this tool is only available in trusted contexts.", "not-trusted");
1832
1910
  const blocked = delegatedHumanMailBlocked(ctx);
1833
1911
  if (blocked)
1834
- return blocked;
1912
+ return (0, tools_base_1.withCode)(blocked, "family-only");
1835
1913
  const resolved = await (0, reader_1.resolveMailroomReaderWithRefresh)();
1836
1914
  if (!resolved.ok)
1837
- return resolved.error;
1915
+ return (0, tools_base_1.withCode)(resolved.error, "mail-unavailable");
1838
1916
  return renderAccessLog(await resolved.store.listAccessLog(resolved.agentName));
1839
1917
  },
1840
1918
  summaryKeys: [],
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1318",
3
+ "version": "0.1.0-alpha.1319",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1318",
9
+ "version": "0.1.0-alpha.1319",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1318",
3
+ "version": "0.1.0-alpha.1319",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },