@ouro.bot/cli 0.1.0-alpha.1464 → 0.1.0-alpha.1465

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.
Files changed (44) hide show
  1. package/README.md +2 -2
  2. package/changelog.json +8 -0
  3. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
  4. package/deploy/unraid/sanctuary.xml +1 -1
  5. package/dist/heart/daemon/cli-commands/mail.js +0 -1
  6. package/dist/heart/daemon/cli-exec.js +0 -33
  7. package/dist/heart/daemon/cli-help.js +0 -13
  8. package/dist/heart/daemon/cli-parse.js +0 -3
  9. package/dist/heart/daemon/cli-render.js +0 -7
  10. package/dist/heart/daemon/daemon-entry.js +1 -1
  11. package/dist/heart/daemon/daemon.js +0 -63
  12. package/dist/heart/{mailbox/mailbox-supervision.js → shepherd/supervision-read.js} +4 -4
  13. package/dist/nerves/coverage/file-completeness.js +0 -11
  14. package/dist/nerves/observation.js +2 -4
  15. package/dist/repertoire/tools-mail.js +2 -2
  16. package/dist/senses/cli/ouro-tui.js +2 -2
  17. package/dist/senses/shepherd/operations.js +2 -2
  18. package/npm-shrinkwrap.json +2 -2
  19. package/package.json +2 -4
  20. package/skills/sense-setup.md +1 -1
  21. package/dist/heart/mailbox/mailbox-http-hooks.js +0 -99
  22. package/dist/heart/mailbox/mailbox-http-response.js +0 -7
  23. package/dist/heart/mailbox/mailbox-http-routes.js +0 -406
  24. package/dist/heart/mailbox/mailbox-http-static.js +0 -103
  25. package/dist/heart/mailbox/mailbox-http-transport.js +0 -272
  26. package/dist/heart/mailbox/mailbox-http.js +0 -99
  27. package/dist/heart/mailbox/mailbox-read.js +0 -41
  28. package/dist/heart/mailbox/mailbox-types.js +0 -27
  29. package/dist/heart/mailbox/mailbox-view.js +0 -197
  30. package/dist/heart/mailbox/readers/agent-machine.js +0 -428
  31. package/dist/heart/mailbox/readers/continuity-readers.js +0 -329
  32. package/dist/heart/mailbox/readers/mail.js +0 -375
  33. package/dist/heart/mailbox/readers/runtime-readers.js +0 -823
  34. package/dist/heart/mailbox/readers/sessions.js +0 -231
  35. package/dist/heart/mailbox/readers/shared.js +0 -111
  36. package/dist/mailbox-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  37. package/dist/mailbox-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  38. package/dist/mailbox-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  39. package/dist/mailbox-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  40. package/dist/mailbox-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  41. package/dist/mailbox-ui/assets/index-BQYBPyiH.js +0 -5
  42. package/dist/mailbox-ui/assets/index-UZ85Lvxp.css +0 -1
  43. package/dist/mailbox-ui/assets/vendor-BfcLUM_P.js +0 -65
  44. package/dist/mailbox-ui/index.html +0 -18
@@ -1,272 +0,0 @@
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.createSseBroadcaster = createSseBroadcaster;
37
- exports.createStateChangedBroadcast = createStateChangedBroadcast;
38
- exports.createBundleWatcher = createBundleWatcher;
39
- const fs = __importStar(require("fs"));
40
- const path = __importStar(require("path"));
41
- const runtime_1 = require("../../nerves/runtime");
42
- const DEFAULT_BUNDLE_WATCHER_DEPS = {
43
- platform: process.platform,
44
- existsSync: fs.existsSync,
45
- watch: (targetPath, options, listener) => fs.watch(targetPath, options, listener),
46
- readdir: (targetPath) => fs.promises.readdir(targetPath, { withFileTypes: true }),
47
- setTimeout,
48
- clearTimeout,
49
- };
50
- function createSseBroadcaster() {
51
- let nextId = 1;
52
- const clients = new Set();
53
- function add(response) {
54
- const client = { id: nextId++, response };
55
- clients.add(client);
56
- response.on("close", () => clients.delete(client));
57
- return client;
58
- }
59
- function broadcast(event, data = {}) {
60
- const payload = `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`;
61
- for (const client of clients) {
62
- try {
63
- client.response.write(payload);
64
- }
65
- catch {
66
- clients.delete(client);
67
- }
68
- }
69
- }
70
- function disconnectAll() {
71
- for (const client of clients) {
72
- try {
73
- client.response.end();
74
- }
75
- catch {
76
- // The client may already have closed between the loop snapshot and end.
77
- }
78
- }
79
- clients.clear();
80
- }
81
- return { add, broadcast, disconnectAll };
82
- }
83
- function createStateChangedBroadcast(sse) {
84
- return () => {
85
- sse.broadcast("state-changed", { at: new Date().toISOString() });
86
- };
87
- }
88
- const BUNDLE_WATCH_DEBOUNCE_MS = 500;
89
- // A continuous event stream must not postpone onChange forever.
90
- const BUNDLE_WATCH_MAX_WAIT_MS = 3_000;
91
- const BUNDLE_WATCH_DEGRADED_LOG_INTERVAL_MS = 60_000;
92
- const BUNDLE_WATCH_SKIPPED_DIRECTORIES = new Set([".git", "node_modules"]);
93
- function closeQuietly(handle) {
94
- try {
95
- handle.close();
96
- }
97
- catch {
98
- // Already closed.
99
- }
100
- }
101
- /**
102
- * Report "something under the bundles root changed" to Mailbox, debounced.
103
- *
104
- * On Linux, Node implements `fs.watch(root, { recursive: true })` in JavaScript: it stats and
105
- * inotify-watches every file in the tree before returning (7-10 s of blocked event loop for a
106
- * 12k-file bundle), and it answers every file event on a directory by re-reading that whole
107
- * directory. A host-side `chown -R` of a bundle holding directories of ~3.5k receipts therefore
108
- * keeps the daemon's event loop busy for ~150 s, long enough to fail the container healthcheck.
109
- *
110
- * So on Linux we watch each directory (not each file) non-recursively. The tree is discovered
111
- * with async readdir, and event callbacks never touch the filesystem: they only schedule a
112
- * debounced onChange, plus, for create/delete/rename events, a debounced async re-read of that
113
- * one directory to pick up added or removed subdirectories. macOS and Windows have a native
114
- * recursive watcher that is cheap, so they keep it. Symlinked directories are not followed, and
115
- * .git and node_modules are not watched.
116
- */
117
- function createBundleWatcher(bundlesRoot, onChange, deps = DEFAULT_BUNDLE_WATCHER_DEPS) {
118
- const watchers = new Map();
119
- const pendingDirectories = new Set();
120
- let debounceTimer = null;
121
- let rescanTimer = null;
122
- let maxWaitTimer = null;
123
- let rescanRunning = false;
124
- let stopped = false;
125
- let resourceExhausted = false;
126
- let lastDegradedLogAt = Number.NEGATIVE_INFINITY;
127
- function flushOnChange() {
128
- if (debounceTimer)
129
- deps.clearTimeout(debounceTimer);
130
- if (maxWaitTimer)
131
- deps.clearTimeout(maxWaitTimer);
132
- debounceTimer = null;
133
- maxWaitTimer = null;
134
- onChange();
135
- }
136
- function debouncedOnChange() {
137
- if (debounceTimer)
138
- deps.clearTimeout(debounceTimer);
139
- debounceTimer = deps.setTimeout(flushOnChange, BUNDLE_WATCH_DEBOUNCE_MS);
140
- if (!maxWaitTimer)
141
- maxWaitTimer = deps.setTimeout(flushOnChange, BUNDLE_WATCH_MAX_WAIT_MS);
142
- }
143
- function reportWatchDegraded(targetPath, error) {
144
- const code = error?.code;
145
- if (code === "ENOSPC" || code === "EMFILE")
146
- resourceExhausted = true;
147
- const now = Date.now();
148
- if (now - lastDegradedLogAt < BUNDLE_WATCH_DEGRADED_LOG_INTERVAL_MS)
149
- return;
150
- lastDegradedLogAt = now;
151
- const reason = typeof code === "string" ? code : error instanceof Error ? error.message : String(error);
152
- (0, runtime_1.emitNervesEvent)({
153
- level: "warn",
154
- component: "daemon",
155
- event: "daemon.mailbox_watch_degraded",
156
- message: `mailbox watch degraded: ${reason} at ${targetPath}`,
157
- meta: { path: targetPath, reason },
158
- });
159
- }
160
- function watchPath(targetPath, recursive, listener) {
161
- try {
162
- const handle = deps.watch(targetPath, { recursive }, listener);
163
- handle.on?.("error", (error) => {
164
- closeQuietly(handle);
165
- if (watchers.get(targetPath) === handle)
166
- watchers.delete(targetPath);
167
- if (stopped)
168
- return;
169
- reportWatchDegraded(targetPath, error);
170
- debouncedOnChange();
171
- });
172
- watchers.set(targetPath, handle);
173
- return true;
174
- }
175
- catch (error) {
176
- // Watching is best-effort; manual broadcasts still keep Mailbox usable.
177
- reportWatchDegraded(targetPath, error);
178
- return false;
179
- }
180
- }
181
- function unwatchTree(directory) {
182
- for (const [watched, handle] of watchers) {
183
- if (watched === directory || watched.startsWith(`${directory}${path.sep}`)) {
184
- closeQuietly(handle);
185
- watchers.delete(watched);
186
- }
187
- }
188
- }
189
- function scheduleRescan(directory) {
190
- pendingDirectories.add(directory);
191
- if (rescanTimer)
192
- return;
193
- rescanTimer = deps.setTimeout(() => {
194
- rescanTimer = null;
195
- void drainRescans();
196
- }, BUNDLE_WATCH_DEBOUNCE_MS);
197
- }
198
- async function drainRescans() {
199
- if (rescanRunning)
200
- return;
201
- rescanRunning = true;
202
- try {
203
- while (!stopped && pendingDirectories.size > 0) {
204
- const [directory] = pendingDirectories;
205
- pendingDirectories.delete(directory);
206
- await reconcileDirectory(directory, true);
207
- }
208
- }
209
- finally {
210
- rescanRunning = false;
211
- }
212
- }
213
- function watchDirectory(directory) {
214
- return watchPath(directory, false, (eventType) => {
215
- debouncedOnChange();
216
- if (eventType === "rename")
217
- scheduleRescan(directory);
218
- });
219
- }
220
- // catchUp is true for rescans after boot: files written into a directory before its watch existed
221
- // produced no event, so a newly watched directory reports one change itself.
222
- async function reconcileDirectory(directory, catchUp) {
223
- let entries;
224
- try {
225
- entries = await deps.readdir(directory);
226
- }
227
- catch {
228
- unwatchTree(directory);
229
- return;
230
- }
231
- if (stopped)
232
- return;
233
- const subdirectories = new Set(entries.filter((entry) => entry.isDirectory() && !BUNDLE_WATCH_SKIPPED_DIRECTORIES.has(entry.name)).map((entry) => path.join(directory, entry.name)));
234
- for (const watched of [...watchers.keys()]) {
235
- if (path.dirname(watched) === directory && !subdirectories.has(watched))
236
- unwatchTree(watched);
237
- }
238
- for (const subdirectory of subdirectories) {
239
- if (stopped || resourceExhausted)
240
- return;
241
- if (watchers.has(subdirectory) || !watchDirectory(subdirectory))
242
- continue;
243
- if (catchUp)
244
- debouncedOnChange();
245
- await reconcileDirectory(subdirectory, catchUp);
246
- }
247
- }
248
- if (deps.existsSync(bundlesRoot)) {
249
- if (deps.platform === "linux") {
250
- if (watchDirectory(bundlesRoot))
251
- void reconcileDirectory(bundlesRoot, false);
252
- }
253
- else {
254
- watchPath(bundlesRoot, true, debouncedOnChange);
255
- }
256
- }
257
- return {
258
- stop() {
259
- stopped = true;
260
- if (debounceTimer)
261
- deps.clearTimeout(debounceTimer);
262
- if (maxWaitTimer)
263
- deps.clearTimeout(maxWaitTimer);
264
- if (rescanTimer)
265
- deps.clearTimeout(rescanTimer);
266
- pendingDirectories.clear();
267
- for (const handle of watchers.values())
268
- closeQuietly(handle);
269
- watchers.clear();
270
- },
271
- };
272
- }
@@ -1,99 +0,0 @@
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.startMailboxHttpServer = startMailboxHttpServer;
37
- const http = __importStar(require("http"));
38
- const runtime_1 = require("../../nerves/runtime");
39
- const mailbox_read_1 = require("./mailbox-read");
40
- const mailbox_http_hooks_1 = require("./mailbox-http-hooks");
41
- const mailbox_http_routes_1 = require("./mailbox-http-routes");
42
- const mailbox_http_transport_1 = require("./mailbox-http-transport");
43
- async function startMailboxHttpServer(options = {}) {
44
- const host = options.host ?? "127.0.0.1";
45
- const port = options.port ?? 0;
46
- const bundlesRoot = options.bundlesRoot;
47
- const opts = bundlesRoot ? { bundlesRoot } : undefined;
48
- const readMachineState = options.readMachineState ?? (() => (0, mailbox_read_1.readMailboxMachineState)(opts));
49
- const readMachineView = options.readMachineView;
50
- const readAgentState = options.readAgentState ?? ((agentName) => {
51
- if (opts)
52
- return (0, mailbox_read_1.readMailboxAgentState)(agentName, opts);
53
- return (0, mailbox_read_1.readMailboxAgentState)(agentName);
54
- });
55
- const readAgentView = options.readAgentView;
56
- const hooks = (0, mailbox_http_hooks_1.createMailboxHttpReadHooks)(options);
57
- const sse = (0, mailbox_http_transport_1.createSseBroadcaster)();
58
- const bundleWatcher = bundlesRoot ? (0, mailbox_http_transport_1.createBundleWatcher)(bundlesRoot, (0, mailbox_http_transport_1.createStateChangedBroadcast)(sse)) : null;
59
- let server;
60
- server = http.createServer((0, mailbox_http_routes_1.createMailboxHttpRequestHandler)({
61
- host,
62
- getPort: () => server.address().port,
63
- readMachineState,
64
- readMachineView,
65
- readAgentState,
66
- readAgentView,
67
- hooks,
68
- sse,
69
- }));
70
- await new Promise((resolve, reject) => {
71
- server.once("error", reject);
72
- server.listen(port, host, () => resolve());
73
- });
74
- const address = server.address();
75
- const origin = `http://${host}:${address.port}`;
76
- (0, runtime_1.emitNervesEvent)({
77
- component: "daemon",
78
- event: "daemon.mailbox_http_started",
79
- message: "started Mailbox HTTP server",
80
- meta: { origin },
81
- });
82
- return {
83
- origin,
84
- broadcast(event, data) {
85
- sse.broadcast(event, data);
86
- },
87
- async stop() {
88
- bundleWatcher?.stop();
89
- sse.disconnectAll();
90
- await new Promise((resolve) => server.close(() => resolve()));
91
- (0, runtime_1.emitNervesEvent)({
92
- component: "daemon",
93
- event: "daemon.mailbox_http_stopped",
94
- message: "stopped Mailbox HTTP server",
95
- meta: { origin },
96
- });
97
- },
98
- };
99
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readSelfFixView = exports.readMailboxContinuity = exports.readOrientationView = exports.readObligationDetailView = exports.readNoteDecisionView = exports.readSentinelView = exports.readContextLossGauntletView = exports.readChangesView = exports.readNeedsMeView = exports.readNotesView = exports.readLogView = exports.readContextPacketView = exports.readContextPacketListView = exports.readHabitView = exports.readHabitRunView = exports.readHabitRunReceiptView = exports.readHabitSessionSummaryView = exports.readHabitSessionSummaryListView = exports.readFriendView = exports.readDeskPrefs = exports.readDaemonHealthDeep = exports.readCodingDeep = exports.readBridgeInventory = exports.readAttentionView = exports.readMailView = exports.readMailMessageView = exports.readSessionTranscript = exports.readSessionInventory = exports.readMailboxMachineState = exports.readMailboxAgentState = exports.readObligationSummary = exports.readMailboxSupervision = void 0;
4
- var mailbox_supervision_1 = require("./mailbox-supervision");
5
- Object.defineProperty(exports, "readMailboxSupervision", { enumerable: true, get: function () { return mailbox_supervision_1.readMailboxSupervision; } });
6
- var agent_machine_1 = require("./readers/agent-machine");
7
- Object.defineProperty(exports, "readObligationSummary", { enumerable: true, get: function () { return agent_machine_1.readObligationSummary; } });
8
- Object.defineProperty(exports, "readMailboxAgentState", { enumerable: true, get: function () { return agent_machine_1.readMailboxAgentState; } });
9
- Object.defineProperty(exports, "readMailboxMachineState", { enumerable: true, get: function () { return agent_machine_1.readMailboxMachineState; } });
10
- var sessions_1 = require("./readers/sessions");
11
- Object.defineProperty(exports, "readSessionInventory", { enumerable: true, get: function () { return sessions_1.readSessionInventory; } });
12
- Object.defineProperty(exports, "readSessionTranscript", { enumerable: true, get: function () { return sessions_1.readSessionTranscript; } });
13
- var mail_1 = require("./readers/mail");
14
- Object.defineProperty(exports, "readMailMessageView", { enumerable: true, get: function () { return mail_1.readMailMessageView; } });
15
- Object.defineProperty(exports, "readMailView", { enumerable: true, get: function () { return mail_1.readMailView; } });
16
- var runtime_readers_1 = require("./readers/runtime-readers");
17
- Object.defineProperty(exports, "readAttentionView", { enumerable: true, get: function () { return runtime_readers_1.readAttentionView; } });
18
- Object.defineProperty(exports, "readBridgeInventory", { enumerable: true, get: function () { return runtime_readers_1.readBridgeInventory; } });
19
- Object.defineProperty(exports, "readCodingDeep", { enumerable: true, get: function () { return runtime_readers_1.readCodingDeep; } });
20
- Object.defineProperty(exports, "readDaemonHealthDeep", { enumerable: true, get: function () { return runtime_readers_1.readDaemonHealthDeep; } });
21
- Object.defineProperty(exports, "readDeskPrefs", { enumerable: true, get: function () { return runtime_readers_1.readDeskPrefs; } });
22
- Object.defineProperty(exports, "readFriendView", { enumerable: true, get: function () { return runtime_readers_1.readFriendView; } });
23
- Object.defineProperty(exports, "readHabitSessionSummaryListView", { enumerable: true, get: function () { return runtime_readers_1.readHabitSessionSummaryListView; } });
24
- Object.defineProperty(exports, "readHabitSessionSummaryView", { enumerable: true, get: function () { return runtime_readers_1.readHabitSessionSummaryView; } });
25
- Object.defineProperty(exports, "readHabitRunReceiptView", { enumerable: true, get: function () { return runtime_readers_1.readHabitRunReceiptView; } });
26
- Object.defineProperty(exports, "readHabitRunView", { enumerable: true, get: function () { return runtime_readers_1.readHabitRunView; } });
27
- Object.defineProperty(exports, "readHabitView", { enumerable: true, get: function () { return runtime_readers_1.readHabitView; } });
28
- Object.defineProperty(exports, "readContextPacketListView", { enumerable: true, get: function () { return runtime_readers_1.readContextPacketListView; } });
29
- Object.defineProperty(exports, "readContextPacketView", { enumerable: true, get: function () { return runtime_readers_1.readContextPacketView; } });
30
- Object.defineProperty(exports, "readLogView", { enumerable: true, get: function () { return runtime_readers_1.readLogView; } });
31
- Object.defineProperty(exports, "readNotesView", { enumerable: true, get: function () { return runtime_readers_1.readNotesView; } });
32
- Object.defineProperty(exports, "readNeedsMeView", { enumerable: true, get: function () { return runtime_readers_1.readNeedsMeView; } });
33
- var continuity_readers_1 = require("./readers/continuity-readers");
34
- Object.defineProperty(exports, "readChangesView", { enumerable: true, get: function () { return continuity_readers_1.readChangesView; } });
35
- Object.defineProperty(exports, "readContextLossGauntletView", { enumerable: true, get: function () { return continuity_readers_1.readContextLossGauntletView; } });
36
- Object.defineProperty(exports, "readSentinelView", { enumerable: true, get: function () { return continuity_readers_1.readSentinelView; } });
37
- Object.defineProperty(exports, "readNoteDecisionView", { enumerable: true, get: function () { return continuity_readers_1.readNoteDecisionView; } });
38
- Object.defineProperty(exports, "readObligationDetailView", { enumerable: true, get: function () { return continuity_readers_1.readObligationDetailView; } });
39
- Object.defineProperty(exports, "readOrientationView", { enumerable: true, get: function () { return continuity_readers_1.readOrientationView; } });
40
- Object.defineProperty(exports, "readMailboxContinuity", { enumerable: true, get: function () { return continuity_readers_1.readMailboxContinuity; } });
41
- Object.defineProperty(exports, "readSelfFixView", { enumerable: true, get: function () { return continuity_readers_1.readSelfFixView; } });
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAILBOX_DEFAULT_PORT = exports.MAILBOX_DEFAULT_INNER_VISIBILITY = exports.MAILBOX_RELEASE_INTERACTION_MODEL = exports.MAILBOX_PRODUCT_NAME = void 0;
4
- exports.getMailboxTranscriptMessageText = getMailboxTranscriptMessageText;
5
- exports.getMailboxTranscriptTimestamp = getMailboxTranscriptTimestamp;
6
- exports.MAILBOX_PRODUCT_NAME = "Ouro Mailbox";
7
- exports.MAILBOX_RELEASE_INTERACTION_MODEL = "read-only";
8
- exports.MAILBOX_DEFAULT_INNER_VISIBILITY = "summary";
9
- exports.MAILBOX_DEFAULT_PORT = 6876;
10
- function transcriptContentText(content) {
11
- if (typeof content === "string")
12
- return content;
13
- if (!Array.isArray(content))
14
- return "";
15
- return content
16
- .map((part) => (part.type === "text" && typeof part.text === "string"
17
- ? part.text
18
- : ""))
19
- .filter((text) => text.length > 0)
20
- .join("");
21
- }
22
- function getMailboxTranscriptMessageText(message) {
23
- return transcriptContentText(message.content);
24
- }
25
- function getMailboxTranscriptTimestamp(message) {
26
- return message.time.authoredAt ?? message.time.observedAt ?? message.time.recordedAt;
27
- }
@@ -1,197 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildMailboxMachineView = buildMailboxMachineView;
4
- exports.buildMailboxAgentView = buildMailboxAgentView;
5
- const runtime_1 = require("../../nerves/runtime");
6
- const mailbox_types_1 = require("./mailbox-types");
7
- function deriveAttention(agent) {
8
- if (agent.degraded.status === "degraded") {
9
- return { level: "degraded", label: "Degraded" };
10
- }
11
- if (agent.freshness.status === "stale") {
12
- return { level: "stale", label: "Stale" };
13
- }
14
- if (agent.tasks.blockedCount > 0 || agent.coding.blockedCount > 0) {
15
- return { level: "blocked", label: "Blocked" };
16
- }
17
- if (agent.tasks.liveCount > 0 || agent.coding.activeCount > 0 || agent.obligations.openCount > 0) {
18
- return { level: "active", label: "Active" };
19
- }
20
- return { level: "idle", label: "Idle" };
21
- }
22
- function deriveAgentAttention(agent) {
23
- return deriveAttention({
24
- agentName: agent.agentName,
25
- enabled: agent.enabled,
26
- freshness: agent.freshness,
27
- degraded: agent.degraded,
28
- tasks: {
29
- liveCount: agent.tasks.liveCount,
30
- blockedCount: agent.tasks.blockedCount,
31
- },
32
- obligations: {
33
- openCount: agent.obligations.openCount,
34
- },
35
- coding: {
36
- activeCount: agent.coding.activeCount,
37
- blockedCount: agent.coding.blockedCount,
38
- },
39
- });
40
- }
41
- function buildTotals(machine) {
42
- return machine.agents.reduce((totals, agent) => ({
43
- agents: totals.agents + 1,
44
- enabledAgents: totals.enabledAgents + (agent.enabled ? 1 : 0),
45
- degradedAgents: totals.degradedAgents + (agent.degraded.status === "degraded" ? 1 : 0),
46
- staleAgents: totals.staleAgents + (agent.freshness.status === "stale" ? 1 : 0),
47
- liveTasks: totals.liveTasks + agent.tasks.liveCount,
48
- blockedTasks: totals.blockedTasks + agent.tasks.blockedCount,
49
- openObligations: totals.openObligations + agent.obligations.openCount,
50
- activeCodingAgents: totals.activeCodingAgents + (agent.coding.activeCount > 0 ? 1 : 0),
51
- blockedCodingAgents: totals.blockedCodingAgents + (agent.coding.blockedCount > 0 ? 1 : 0),
52
- }), {
53
- agents: 0,
54
- enabledAgents: 0,
55
- degradedAgents: 0,
56
- staleAgents: 0,
57
- liveTasks: 0,
58
- blockedTasks: 0,
59
- openObligations: 0,
60
- activeCodingAgents: 0,
61
- blockedCodingAgents: 0,
62
- });
63
- }
64
- function deriveMood(machine, daemon) {
65
- if (machine.degraded.status === "degraded" || daemon.health === "warn") {
66
- return "strained";
67
- }
68
- if (machine.freshness.status === "stale") {
69
- return "watchful";
70
- }
71
- return "calm";
72
- }
73
- function buildMailboxMachineView(input) {
74
- const totals = buildTotals(input.machine);
75
- const agents = input.machine.agents
76
- .map((agent) => ({
77
- ...agent,
78
- attention: deriveAttention(agent),
79
- }))
80
- .sort((left, right) => {
81
- const leftAt = left.freshness.latestActivityAt ?? "";
82
- const rightAt = right.freshness.latestActivityAt ?? "";
83
- return rightAt.localeCompare(leftAt);
84
- });
85
- return {
86
- overview: {
87
- productName: mailbox_types_1.MAILBOX_PRODUCT_NAME,
88
- observedAt: input.machine.observedAt,
89
- primaryEntryPoint: input.daemon.mailboxUrl,
90
- daemon: input.daemon,
91
- runtime: input.machine.runtime,
92
- freshness: input.machine.freshness,
93
- degraded: input.machine.degraded,
94
- totals,
95
- mood: deriveMood(input.machine, input.daemon),
96
- entrypoints: [
97
- { kind: "web", label: "Open Mailbox", target: input.daemon.mailboxUrl },
98
- { kind: "cli", label: "CLI JSON", target: "ouro mailbox --json" },
99
- ],
100
- },
101
- agents,
102
- };
103
- }
104
- function normalizeViewer(viewer) {
105
- return {
106
- kind: viewer?.kind ?? "human",
107
- agentName: viewer?.agentName,
108
- innerDetail: viewer?.innerDetail ?? "summary",
109
- };
110
- }
111
- function buildInnerView(inner, viewer) {
112
- if (viewer.innerDetail === "deep") {
113
- return {
114
- mode: "deep",
115
- status: inner.status,
116
- summary: inner.surfacedSummary,
117
- hasPending: inner.hasPending,
118
- origin: inner.origin,
119
- obligationStatus: inner.obligationStatus,
120
- returnObligationQueue: inner.returnObligationQueue,
121
- };
122
- }
123
- return {
124
- mode: "summary",
125
- status: inner.status,
126
- summary: inner.surfacedSummary,
127
- hasPending: inner.hasPending,
128
- returnObligationQueue: inner.returnObligationQueue,
129
- };
130
- }
131
- function buildRecentActivity(agent) {
132
- const items = [
133
- ...agent.coding.items.map((item) => ({
134
- kind: "coding",
135
- at: item.lastActivityAt,
136
- label: item.checkpoint ?? `${item.runner} ${item.status}`,
137
- detail: item.workdir,
138
- })),
139
- ...agent.sessions.items.map((item) => ({
140
- kind: "session",
141
- at: item.lastActivityAt,
142
- label: `${item.friendName} via ${item.channel}`,
143
- detail: item.key,
144
- })),
145
- ...agent.obligations.items.map((item) => ({
146
- kind: "obligation",
147
- at: item.updatedAt,
148
- label: item.content,
149
- detail: item.nextAction ?? item.status,
150
- })),
151
- ];
152
- if (agent.inner.latestActivityAt) {
153
- items.push({
154
- kind: "inner",
155
- at: agent.inner.latestActivityAt,
156
- label: agent.inner.surfacedSummary ?? agent.inner.status,
157
- detail: agent.inner.hasPending ? "pending private-runtime work" : agent.inner.obligationStatus ?? "no linked obligation",
158
- });
159
- }
160
- return items
161
- .filter((item) => Number.isFinite(Date.parse(item.at)))
162
- .sort((left, right) => right.at.localeCompare(left.at))
163
- .slice(0, 4);
164
- }
165
- function buildMailboxAgentView(input) {
166
- /* v8 ignore next */
167
- (0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.mailbox_view_agent", message: `building mailbox view for ${input.agent.agentName}`, meta: { agent: input.agent.agentName } });
168
- const viewer = normalizeViewer(input.viewer);
169
- return {
170
- productName: mailbox_types_1.MAILBOX_PRODUCT_NAME,
171
- interactionModel: mailbox_types_1.MAILBOX_RELEASE_INTERACTION_MODEL,
172
- viewer,
173
- agent: {
174
- agentName: input.agent.agentName,
175
- agentRoot: input.agent.agentRoot,
176
- enabled: input.agent.enabled,
177
- provider: input.agent.provider,
178
- providers: input.agent.providers ?? null,
179
- senses: input.agent.senses,
180
- freshness: input.agent.freshness,
181
- degraded: input.agent.degraded,
182
- attention: deriveAgentAttention(input.agent),
183
- },
184
- work: {
185
- tasks: input.agent.tasks,
186
- obligations: input.agent.obligations,
187
- sessions: input.agent.sessions,
188
- coding: input.agent.coding,
189
- bridges: input.agent.tasks.activeBridges,
190
- },
191
- inner: buildInnerView(input.agent.inner, viewer),
192
- activity: {
193
- freshness: input.agent.freshness,
194
- recent: buildRecentActivity(input.agent),
195
- },
196
- };
197
- }