@ouro.bot/cli 0.1.0-alpha.454 → 0.1.0-alpha.456
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 +16 -0
- package/dist/heart/daemon/cli-exec.js +161 -66
- package/dist/heart/daemon/cli-help.js +12 -0
- package/dist/heart/daemon/cli-parse.js +13 -0
- package/dist/heart/daemon/runtime-logging.js +1 -1
- package/dist/heart/daemon/sense-manager.js +10 -2
- package/dist/heart/outlook/readers/mail.js +72 -2
- package/dist/mailroom/attention.js +154 -0
- package/dist/mailroom/blob-store.js +150 -2
- package/dist/mailroom/core.js +160 -9
- package/dist/mailroom/file-store.js +164 -2
- package/dist/mailroom/outbound.js +177 -0
- package/dist/mailroom/policy.js +263 -0
- package/dist/mailroom/reader.js +16 -0
- package/dist/mailroom/travel-extract.js +89 -0
- package/dist/mind/prompt.js +1 -1
- package/dist/outlook-ui/assets/index-BBM5EysT.js +61 -0
- package/dist/outlook-ui/assets/index-BPr5vNuM.css +1 -0
- package/dist/outlook-ui/index.html +2 -2
- package/dist/repertoire/guardrails.js +25 -0
- package/dist/repertoire/tools-base.js +2 -0
- package/dist/repertoire/tools-mail.js +480 -4
- package/dist/senses/mail-entry.js +66 -0
- package/dist/senses/mail.js +224 -0
- package/package.json +1 -1
- package/dist/outlook-ui/assets/index-BXw3xmUo.js +0 -61
- package/dist/outlook-ui/assets/index-D4Wg-o8Z.css +0 -1
|
@@ -0,0 +1,224 @@
|
|
|
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.startMailSenseApp = startMailSenseApp;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const runtime_1 = require("../nerves/runtime");
|
|
40
|
+
const identity_1 = require("../heart/identity");
|
|
41
|
+
const runtime_credentials_1 = require("../heart/runtime-credentials");
|
|
42
|
+
const pending_1 = require("../mind/pending");
|
|
43
|
+
const attention_1 = require("../mailroom/attention");
|
|
44
|
+
const reader_1 = require("../mailroom/reader");
|
|
45
|
+
const smtp_ingress_1 = require("../mailroom/smtp-ingress");
|
|
46
|
+
function readRegistry(registryPath) {
|
|
47
|
+
return JSON.parse(fs.readFileSync(registryPath, "utf-8"));
|
|
48
|
+
}
|
|
49
|
+
function validPort(value) {
|
|
50
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 65535 ? value : 0;
|
|
51
|
+
}
|
|
52
|
+
function serverAddress(server) {
|
|
53
|
+
const direct = server;
|
|
54
|
+
if (typeof direct.address === "function")
|
|
55
|
+
return direct.address();
|
|
56
|
+
const wrapped = server;
|
|
57
|
+
if (typeof wrapped.server?.address === "function")
|
|
58
|
+
return wrapped.server.address();
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function serverPort(server) {
|
|
62
|
+
const address = serverAddress(server);
|
|
63
|
+
if (!address || typeof address !== "object")
|
|
64
|
+
return null;
|
|
65
|
+
return typeof address.port === "number" ? address.port : null;
|
|
66
|
+
}
|
|
67
|
+
function listeningServer(server) {
|
|
68
|
+
const wrapped = server;
|
|
69
|
+
if (typeof wrapped.server?.once === "function")
|
|
70
|
+
return wrapped.server;
|
|
71
|
+
const direct = server;
|
|
72
|
+
return typeof direct.once === "function" ? direct : null;
|
|
73
|
+
}
|
|
74
|
+
function waitForListening(server) {
|
|
75
|
+
if (serverAddress(server))
|
|
76
|
+
return Promise.resolve();
|
|
77
|
+
const listening = listeningServer(server);
|
|
78
|
+
if (!listening)
|
|
79
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
80
|
+
if (listening.listening)
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
return new Promise((resolve) => listening.once?.("listening", resolve));
|
|
83
|
+
}
|
|
84
|
+
function runtimeStatePath(agentName) {
|
|
85
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "senses", "mail", "runtime.json");
|
|
86
|
+
}
|
|
87
|
+
function attentionStatePath(agentName) {
|
|
88
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "senses", "mail", "attention.json");
|
|
89
|
+
}
|
|
90
|
+
function writeRuntimeState(filePath, state) {
|
|
91
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
92
|
+
fs.writeFileSync(filePath, `${JSON.stringify(state, null, 2)}\n`, "utf-8");
|
|
93
|
+
(0, runtime_1.emitNervesEvent)({
|
|
94
|
+
component: "senses",
|
|
95
|
+
event: "senses.mail_sense_runtime_state_written",
|
|
96
|
+
message: "mail sense runtime state written",
|
|
97
|
+
meta: { agentName: state.agentName, status: state.status, lastQueuedCount: state.lastQueuedCount },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function closeServer(server) {
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
server.close(resolve);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async function startMailSenseApp(options) {
|
|
106
|
+
const now = options.now ?? (() => Date.now());
|
|
107
|
+
/* v8 ignore next -- production wiring uses the default vault refresh; tests inject a deterministic refresh. @preserve */
|
|
108
|
+
const refreshRuntime = options.refreshRuntime ?? runtime_credentials_1.refreshRuntimeCredentialConfig;
|
|
109
|
+
await refreshRuntime(options.agentName, { preserveCachedOnFailure: true }).catch(() => undefined);
|
|
110
|
+
const resolved = options.resolveReader
|
|
111
|
+
? options.resolveReader(options.agentName)
|
|
112
|
+
: (0, reader_1.resolveMailroomReader)(options.agentName);
|
|
113
|
+
if (!resolved.ok) {
|
|
114
|
+
throw new Error(resolved.error);
|
|
115
|
+
}
|
|
116
|
+
if (!resolved.config.registryPath) {
|
|
117
|
+
throw new Error(`missing mailroom.registryPath for ${options.agentName}; run 'ouro connect mail --agent ${options.agentName}' again`);
|
|
118
|
+
}
|
|
119
|
+
const registry = readRegistry(resolved.config.registryPath);
|
|
120
|
+
const host = resolved.config.host ?? "127.0.0.1";
|
|
121
|
+
const ingress = (options.startIngress ?? smtp_ingress_1.startMailroomIngress)({
|
|
122
|
+
registry,
|
|
123
|
+
store: resolved.store,
|
|
124
|
+
smtpPort: validPort(resolved.config.smtpPort),
|
|
125
|
+
httpPort: validPort(resolved.config.httpPort),
|
|
126
|
+
host,
|
|
127
|
+
});
|
|
128
|
+
await Promise.all([
|
|
129
|
+
waitForListening(ingress.smtp),
|
|
130
|
+
waitForListening(ingress.health),
|
|
131
|
+
]);
|
|
132
|
+
const runtimePath = runtimeStatePath(options.agentName);
|
|
133
|
+
const attentionPath = attentionStatePath(options.agentName);
|
|
134
|
+
let lastScanAt = null;
|
|
135
|
+
let lastQueuedCount = 0;
|
|
136
|
+
const scan = async () => {
|
|
137
|
+
try {
|
|
138
|
+
const scanStartedAt = new Date(now()).toISOString();
|
|
139
|
+
const result = await (0, attention_1.scanMailScreenerAttention)({
|
|
140
|
+
agentName: options.agentName,
|
|
141
|
+
store: resolved.store,
|
|
142
|
+
pendingDir: (0, pending_1.getInnerDialogPendingDir)(options.agentName),
|
|
143
|
+
statePath: attentionPath,
|
|
144
|
+
now,
|
|
145
|
+
});
|
|
146
|
+
lastScanAt = scanStartedAt;
|
|
147
|
+
lastQueuedCount = result.queued.length;
|
|
148
|
+
writeRuntimeState(runtimePath, {
|
|
149
|
+
schemaVersion: 1,
|
|
150
|
+
agentName: options.agentName,
|
|
151
|
+
status: "running",
|
|
152
|
+
mailboxAddress: resolved.config.mailboxAddress,
|
|
153
|
+
smtpPort: serverPort(ingress.smtp),
|
|
154
|
+
httpPort: serverPort(ingress.health),
|
|
155
|
+
host,
|
|
156
|
+
storeKind: resolved.storeKind,
|
|
157
|
+
storeLabel: resolved.storeLabel,
|
|
158
|
+
lastScanAt,
|
|
159
|
+
lastQueuedCount,
|
|
160
|
+
updatedAt: new Date(now()).toISOString(),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
(0, runtime_1.emitNervesEvent)({
|
|
165
|
+
level: "error",
|
|
166
|
+
component: "senses",
|
|
167
|
+
event: "senses.mail_sense_scan_error",
|
|
168
|
+
message: "mail sense attention scan failed",
|
|
169
|
+
meta: { agentName: options.agentName, error: error instanceof Error ? error.message : String(error) },
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
await scan();
|
|
174
|
+
const intervalMs = Math.max(5_000, resolved.config.attentionIntervalMs ?? 30_000);
|
|
175
|
+
const timer = (options.setIntervalFn ?? ((callback, ms) => setInterval(callback, ms)))(() => {
|
|
176
|
+
void scan();
|
|
177
|
+
}, intervalMs);
|
|
178
|
+
(0, runtime_1.emitNervesEvent)({
|
|
179
|
+
component: "senses",
|
|
180
|
+
event: "senses.mail_sense_started",
|
|
181
|
+
message: "mail sense started",
|
|
182
|
+
meta: {
|
|
183
|
+
agentName: options.agentName,
|
|
184
|
+
mailboxAddress: resolved.config.mailboxAddress,
|
|
185
|
+
smtpPort: serverPort(ingress.smtp),
|
|
186
|
+
httpPort: serverPort(ingress.health),
|
|
187
|
+
intervalMs,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
runtimeStatePath: runtimePath,
|
|
192
|
+
attentionStatePath: attentionPath,
|
|
193
|
+
smtpPort: serverPort(ingress.smtp),
|
|
194
|
+
httpPort: serverPort(ingress.health),
|
|
195
|
+
async stop() {
|
|
196
|
+
;
|
|
197
|
+
(options.clearIntervalFn ?? ((activeTimer) => clearInterval(activeTimer)))(timer);
|
|
198
|
+
await Promise.all([
|
|
199
|
+
closeServer(ingress.smtp),
|
|
200
|
+
closeServer(ingress.health),
|
|
201
|
+
]);
|
|
202
|
+
writeRuntimeState(runtimePath, {
|
|
203
|
+
schemaVersion: 1,
|
|
204
|
+
agentName: options.agentName,
|
|
205
|
+
status: "stopped",
|
|
206
|
+
mailboxAddress: resolved.config.mailboxAddress,
|
|
207
|
+
smtpPort: serverPort(ingress.smtp),
|
|
208
|
+
httpPort: serverPort(ingress.health),
|
|
209
|
+
host,
|
|
210
|
+
storeKind: resolved.storeKind,
|
|
211
|
+
storeLabel: resolved.storeLabel,
|
|
212
|
+
lastScanAt,
|
|
213
|
+
lastQueuedCount,
|
|
214
|
+
updatedAt: new Date(now()).toISOString(),
|
|
215
|
+
});
|
|
216
|
+
(0, runtime_1.emitNervesEvent)({
|
|
217
|
+
component: "senses",
|
|
218
|
+
event: "senses.mail_sense_stopped",
|
|
219
|
+
message: "mail sense stopped",
|
|
220
|
+
meta: { agentName: options.agentName },
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|