@ouro.bot/cli 0.1.0-alpha.485 → 0.1.0-alpha.488

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.
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getBlueBubblesProcessedLogPath = getBlueBubblesProcessedLogPath;
37
+ exports.hasProcessedBlueBubblesMessage = hasProcessedBlueBubblesMessage;
38
+ exports.recordProcessedBlueBubblesMessage = recordProcessedBlueBubblesMessage;
39
+ const fs = __importStar(require("node:fs"));
40
+ const path = __importStar(require("node:path"));
41
+ const config_1 = require("../../heart/config");
42
+ const identity_1 = require("../../heart/identity");
43
+ const runtime_1 = require("../../nerves/runtime");
44
+ function getBlueBubblesProcessedLogPath(agentName, sessionKey) {
45
+ return path.join((0, identity_1.getAgentRoot)(agentName), "state", "senses", "bluebubbles", "processed", `${(0, config_1.sanitizeKey)(sessionKey)}.ndjson`);
46
+ }
47
+ function readEntries(filePath) {
48
+ try {
49
+ const raw = fs.readFileSync(filePath, "utf-8");
50
+ return raw
51
+ .split("\n")
52
+ .map((line) => line.trim())
53
+ .filter(Boolean)
54
+ .map((line) => JSON.parse(line))
55
+ .filter((entry) => typeof entry.messageGuid === "string" && typeof entry.sessionKey === "string");
56
+ }
57
+ catch {
58
+ return [];
59
+ }
60
+ }
61
+ function hasProcessedBlueBubblesMessage(agentName, sessionKey, messageGuid) {
62
+ if (!messageGuid.trim())
63
+ return false;
64
+ const filePath = getBlueBubblesProcessedLogPath(agentName, sessionKey);
65
+ return readEntries(filePath).some((entry) => entry.messageGuid === messageGuid);
66
+ }
67
+ function recordProcessedBlueBubblesMessage(agentName, event, source, outcome) {
68
+ const filePath = getBlueBubblesProcessedLogPath(agentName, event.chat.sessionKey);
69
+ try {
70
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
71
+ if (event.messageGuid.trim() && readEntries(filePath).some((entry) => entry.messageGuid === event.messageGuid)) {
72
+ return filePath;
73
+ }
74
+ fs.appendFileSync(filePath, JSON.stringify({
75
+ recordedAt: new Date().toISOString(),
76
+ messageGuid: event.messageGuid,
77
+ sessionKey: event.chat.sessionKey,
78
+ source,
79
+ outcome,
80
+ }) + "\n", "utf-8");
81
+ }
82
+ catch (error) {
83
+ (0, runtime_1.emitNervesEvent)({
84
+ level: "warn",
85
+ component: "senses",
86
+ event: "senses.bluebubbles_processed_log_error",
87
+ message: "failed to record bluebubbles processed sidecar log",
88
+ meta: {
89
+ agentName,
90
+ messageGuid: event.messageGuid,
91
+ sessionKey: event.chat.sessionKey,
92
+ reason: error instanceof Error ? error.message : String(error),
93
+ },
94
+ });
95
+ return filePath;
96
+ }
97
+ (0, runtime_1.emitNervesEvent)({
98
+ component: "senses",
99
+ event: "senses.bluebubbles_processed_logged",
100
+ message: "recorded handled bluebubbles message to processed sidecar log",
101
+ meta: {
102
+ agentName,
103
+ messageGuid: event.messageGuid,
104
+ sessionKey: event.chat.sessionKey,
105
+ source,
106
+ outcome,
107
+ path: filePath,
108
+ },
109
+ });
110
+ return filePath;
111
+ }
@@ -135,14 +135,29 @@ function stringArray(value) {
135
135
  return [];
136
136
  return value.filter((entry) => typeof entry === "string" && entry.trim().length > 0);
137
137
  }
138
- function renderImportDiscoveryContent(candidatePaths) {
138
+ function candidateDescriptors(value) {
139
+ if (!Array.isArray(value))
140
+ return [];
141
+ return value
142
+ .filter((entry) => !!entry && typeof entry === "object" && !Array.isArray(entry))
143
+ .map((entry) => ({
144
+ path: typeof entry.path === "string" ? entry.path : "",
145
+ originKind: typeof entry.originKind === "string" ? entry.originKind : undefined,
146
+ originLabel: typeof entry.originLabel === "string" ? entry.originLabel : undefined,
147
+ }))
148
+ .filter((entry) => entry.path.trim().length > 0);
149
+ }
150
+ function renderImportDiscoveryContent(candidatePaths, descriptors) {
151
+ const renderedCandidates = descriptors.length > 0
152
+ ? descriptors.map((descriptor) => `- [${descriptor.originLabel ?? descriptor.originKind ?? "filesystem"}] ${descriptor.path}`)
153
+ : candidatePaths.map((candidatePath) => `- ${candidatePath}`);
139
154
  return [
140
155
  "[Mail Import Ready]",
141
156
  "A local MBOX archive is ready for delegated-mail backfill.",
142
157
  "This may live in a worktree-local Playwright sandbox rather than ~/Downloads.",
143
158
  "",
144
159
  "recent candidates:",
145
- ...candidatePaths.map((candidatePath) => `- ${candidatePath}`),
160
+ ...renderedCandidates,
146
161
  "",
147
162
  "If this matches an expected mailbox backfill, run `ouro mail import-mbox --discover --owner-email <email> --source hey --agent <agent>` first so Ouro can pick the matching archive or report ambiguity.",
148
163
  ].join("\n");
@@ -170,6 +185,7 @@ async function scanMailImportDiscoveryAttention(input) {
170
185
  ? discovered.spec.fingerprint
171
186
  : null;
172
187
  const candidatePaths = stringArray(discovered?.spec?.candidatePaths);
188
+ const descriptors = candidateDescriptors(discovered?.spec?.candidateDescriptors);
173
189
  const shouldQueue = Boolean(discovered && fingerprint && fingerprint !== state.lastNotifiedFingerprint);
174
190
  if (shouldQueue) {
175
191
  (0, pending_1.queuePendingMessage)(pendingDir, {
@@ -177,7 +193,7 @@ async function scanMailImportDiscoveryAttention(input) {
177
193
  friendId: "self",
178
194
  channel: "mail",
179
195
  key: "import-ready",
180
- content: renderImportDiscoveryContent(candidatePaths),
196
+ content: renderImportDiscoveryContent(candidatePaths, descriptors),
181
197
  timestamp: nowMs,
182
198
  mode: "reflect",
183
199
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.485",
3
+ "version": "0.1.0-alpha.488",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",