@ouro.bot/cli 0.1.0-alpha.730 → 0.1.0-alpha.732
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/README.md +8 -0
- package/changelog.json +18 -0
- package/dist/heart/daemon/cli-exec.js +38 -4
- package/dist/heart/daemon/cli-help.js +9 -4
- package/dist/heart/daemon/cli-parse.js +30 -6
- package/dist/heart/daemon/doctor.js +294 -28
- package/dist/heart/daemon/freshness.js +4 -2
- package/dist/heart/daemon/logs-prune.js +26 -4
- package/dist/heart/daemon/prunable-bundle.js +144 -0
- package/dist/mailroom/blob-store.js +102 -6
- package/dist/mailroom/cache-sync-cli.js +54 -0
- package/dist/mailroom/hosted-cache-sync.js +249 -0
- package/dist/mailroom/reader.js +59 -0
- package/dist/mailroom/search-cache.js +76 -6
- package/dist/repertoire/guardrails.js +674 -0
- package/dist/repertoire/tools-mail.js +5 -152
- package/package.json +1 -1
|
@@ -36,6 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.MAIL_SEARCH_TEXT_PROJECTION_VERSION = void 0;
|
|
37
37
|
exports.buildMailSearchCacheDocument = buildMailSearchCacheDocument;
|
|
38
38
|
exports.upsertMailSearchCacheDocument = upsertMailSearchCacheDocument;
|
|
39
|
+
exports.inspectMailSearchCacheFiles = inspectMailSearchCacheFiles;
|
|
40
|
+
exports.reloadMailSearchCache = reloadMailSearchCache;
|
|
41
|
+
exports.removeMailSearchCacheDocument = removeMailSearchCacheDocument;
|
|
42
|
+
exports.removeMailSearchCacheFile = removeMailSearchCacheFile;
|
|
39
43
|
exports.syncMailSearchCacheMetadata = syncMailSearchCacheMetadata;
|
|
40
44
|
exports.searchMailSearchCache = searchMailSearchCache;
|
|
41
45
|
exports.snapshotMailSearchCacheForFilters = snapshotMailSearchCacheForFilters;
|
|
@@ -96,6 +100,17 @@ function readJsonDocument(filePath) {
|
|
|
96
100
|
return null;
|
|
97
101
|
}
|
|
98
102
|
}
|
|
103
|
+
function writeJsonAtomically(filePath, value) {
|
|
104
|
+
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
105
|
+
try {
|
|
106
|
+
fs.writeFileSync(tempPath, `${JSON.stringify(value)}\n`, "utf-8");
|
|
107
|
+
fs.renameSync(tempPath, filePath);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
if (fs.existsSync(tempPath))
|
|
111
|
+
fs.unlinkSync(tempPath);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
99
114
|
function cacheState(agentId, options) {
|
|
100
115
|
const key = `${agentId}:${cacheDir(agentId, options)}`;
|
|
101
116
|
let state = cacheStates.get(key);
|
|
@@ -123,8 +138,10 @@ function loadCache(agentId, options) {
|
|
|
123
138
|
}
|
|
124
139
|
return state.docs;
|
|
125
140
|
}
|
|
126
|
-
function buildMailSearchCacheDocument(message, privateEnvelope) {
|
|
141
|
+
function buildMailSearchCacheDocument(message, privateEnvelope, provenance = {}) {
|
|
127
142
|
const readableText = (0, core_1.privateMailEnvelopeReadableText)(privateEnvelope);
|
|
143
|
+
const decryptionKeyId = provenance.decryptionKeyId
|
|
144
|
+
?? (message.bodyForm === "encrypted" ? message.privateEnvelope?.keyId : undefined);
|
|
128
145
|
return {
|
|
129
146
|
schemaVersion: 1,
|
|
130
147
|
messageId: message.id,
|
|
@@ -142,13 +159,14 @@ function buildMailSearchCacheDocument(message, privateEnvelope) {
|
|
|
142
159
|
searchText: normalizeSearchText(privateEnvelope),
|
|
143
160
|
textProjectionVersion: exports.MAIL_SEARCH_TEXT_PROJECTION_VERSION,
|
|
144
161
|
attachmentCount: privateEnvelope.attachments.length,
|
|
162
|
+
...(decryptionKeyId ? { decryptionKeyId } : {}),
|
|
145
163
|
};
|
|
146
164
|
}
|
|
147
|
-
function upsertMailSearchCacheDocument(message, privateEnvelope, options) {
|
|
148
|
-
const document = buildMailSearchCacheDocument(message, privateEnvelope);
|
|
165
|
+
function upsertMailSearchCacheDocument(message, privateEnvelope, options, provenance) {
|
|
166
|
+
const document = buildMailSearchCacheDocument(message, privateEnvelope, provenance);
|
|
149
167
|
const dir = cacheDir(message.agentId, options);
|
|
150
168
|
fs.mkdirSync(dir, { recursive: true });
|
|
151
|
-
|
|
169
|
+
writeJsonAtomically(cachePath(message.agentId, message.id, options), document);
|
|
152
170
|
const state = cacheState(message.agentId, options);
|
|
153
171
|
if (state.loaded)
|
|
154
172
|
state.docs.set(document.messageId, document);
|
|
@@ -165,6 +183,58 @@ function upsertMailSearchCacheDocument(message, privateEnvelope, options) {
|
|
|
165
183
|
});
|
|
166
184
|
return document;
|
|
167
185
|
}
|
|
186
|
+
function inspectMailSearchCacheFiles(agentId, options) {
|
|
187
|
+
const dir = cacheDir(agentId, options);
|
|
188
|
+
if (!fs.existsSync(dir))
|
|
189
|
+
return [];
|
|
190
|
+
return fs.readdirSync(dir, { withFileTypes: true })
|
|
191
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
192
|
+
.map((entry) => {
|
|
193
|
+
const filePath = path.join(dir, entry.name);
|
|
194
|
+
return { fileName: entry.name, filePath, document: readJsonDocument(filePath) };
|
|
195
|
+
})
|
|
196
|
+
.sort((left, right) => left.fileName.localeCompare(right.fileName));
|
|
197
|
+
}
|
|
198
|
+
function reloadMailSearchCache(agentId, options) {
|
|
199
|
+
const state = cacheState(agentId, options);
|
|
200
|
+
state.loaded = false;
|
|
201
|
+
state.docs.clear();
|
|
202
|
+
}
|
|
203
|
+
function removeMailSearchCacheDocument(agentId, messageId, options) {
|
|
204
|
+
const filePath = cachePath(agentId, messageId, options);
|
|
205
|
+
let removed = false;
|
|
206
|
+
try {
|
|
207
|
+
if (fs.lstatSync(filePath).isFile()) {
|
|
208
|
+
fs.unlinkSync(filePath);
|
|
209
|
+
removed = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
if (!(typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT"))
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
const state = cacheState(agentId, options);
|
|
217
|
+
if (state.loaded)
|
|
218
|
+
state.docs.delete(messageId);
|
|
219
|
+
return removed;
|
|
220
|
+
}
|
|
221
|
+
function removeMailSearchCacheFile(agentId, fileName, options) {
|
|
222
|
+
if (path.basename(fileName) !== fileName || !fileName.endsWith(".json"))
|
|
223
|
+
return false;
|
|
224
|
+
const filePath = path.join(cacheDir(agentId, options), fileName);
|
|
225
|
+
try {
|
|
226
|
+
if (!fs.lstatSync(filePath).isFile())
|
|
227
|
+
return false;
|
|
228
|
+
fs.unlinkSync(filePath);
|
|
229
|
+
reloadMailSearchCache(agentId, options);
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
if (!(typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT"))
|
|
234
|
+
throw error;
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
168
238
|
function syncMailSearchCacheMetadata(message, options) {
|
|
169
239
|
const existing = readJsonDocument(cachePath(message.agentId, message.id, options));
|
|
170
240
|
if (!existing)
|
|
@@ -177,7 +247,7 @@ function syncMailSearchCacheMetadata(message, options) {
|
|
|
177
247
|
...(message.ownerEmail ? { ownerEmail: message.ownerEmail } : {}),
|
|
178
248
|
...(message.source ? { source: message.source } : {}),
|
|
179
249
|
};
|
|
180
|
-
|
|
250
|
+
writeJsonAtomically(cachePath(message.agentId, message.id, options), updated);
|
|
181
251
|
const state = cacheState(message.agentId, options);
|
|
182
252
|
if (state.loaded)
|
|
183
253
|
state.docs.set(updated.messageId, updated);
|
|
@@ -312,7 +382,7 @@ function writeMailSearchCoverageRecord(record, options) {
|
|
|
312
382
|
...(record.newestReceivedAt ? { newestReceivedAt: record.newestReceivedAt } : {}),
|
|
313
383
|
};
|
|
314
384
|
fs.mkdirSync(coverageDir(document.agentId, options), { recursive: true });
|
|
315
|
-
|
|
385
|
+
writeJsonAtomically(coveragePath(document, options), document);
|
|
316
386
|
(0, runtime_1.emitNervesEvent)({
|
|
317
387
|
component: "senses",
|
|
318
388
|
event: "senses.mail_search_coverage_written",
|