@ouro.bot/cli 0.1.0-alpha.1464 → 0.1.0-alpha.1466
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 +2 -2
- package/changelog.json +14 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/cli-commands/mail.js +0 -1
- package/dist/heart/daemon/cli-exec.js +0 -33
- package/dist/heart/daemon/cli-help.js +0 -13
- package/dist/heart/daemon/cli-parse.js +0 -3
- package/dist/heart/daemon/cli-render.js +0 -7
- package/dist/heart/daemon/daemon-entry.js +1 -1
- package/dist/heart/daemon/daemon.js +0 -63
- package/dist/heart/{mailbox/mailbox-supervision.js → shepherd/supervision-read.js} +4 -4
- package/dist/nerves/coverage/file-completeness.js +0 -11
- package/dist/nerves/observation.js +2 -4
- package/dist/repertoire/tools-mail.js +2 -2
- package/dist/senses/cli/ouro-tui.js +2 -2
- package/dist/senses/shepherd/operations.js +2 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -4
- package/skills/sense-setup.md +1 -1
- package/dist/heart/mailbox/mailbox-http-hooks.js +0 -99
- package/dist/heart/mailbox/mailbox-http-response.js +0 -7
- package/dist/heart/mailbox/mailbox-http-routes.js +0 -406
- package/dist/heart/mailbox/mailbox-http-static.js +0 -103
- package/dist/heart/mailbox/mailbox-http-transport.js +0 -272
- package/dist/heart/mailbox/mailbox-http.js +0 -99
- package/dist/heart/mailbox/mailbox-read.js +0 -41
- package/dist/heart/mailbox/mailbox-types.js +0 -27
- package/dist/heart/mailbox/mailbox-view.js +0 -197
- package/dist/heart/mailbox/readers/agent-machine.js +0 -428
- package/dist/heart/mailbox/readers/continuity-readers.js +0 -329
- package/dist/heart/mailbox/readers/mail.js +0 -375
- package/dist/heart/mailbox/readers/runtime-readers.js +0 -823
- package/dist/heart/mailbox/readers/sessions.js +0 -231
- package/dist/heart/mailbox/readers/shared.js +0 -111
- package/dist/mailbox-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/mailbox-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/mailbox-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/mailbox-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/mailbox-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/mailbox-ui/assets/index-BQYBPyiH.js +0 -5
- package/dist/mailbox-ui/assets/index-UZ85Lvxp.css +0 -1
- package/dist/mailbox-ui/assets/vendor-BfcLUM_P.js +0 -65
- package/dist/mailbox-ui/index.html +0 -18
|
@@ -1,428 +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.readObligationSummary = readObligationSummary;
|
|
37
|
-
exports.readMailboxAgentState = readMailboxAgentState;
|
|
38
|
-
exports.readMailboxMachineState = readMailboxMachineState;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const runtime_1 = require("../../../nerves/runtime");
|
|
42
|
-
const obligations_1 = require("../../../arc/obligations");
|
|
43
|
-
const session_activity_1 = require("../../session-activity");
|
|
44
|
-
const identity_1 = require("../../identity");
|
|
45
|
-
const agent_discovery_1 = require("../../daemon/agent-discovery");
|
|
46
|
-
const runtime_metadata_1 = require("../../daemon/runtime-metadata");
|
|
47
|
-
const provider_visibility_1 = require("../../provider-visibility");
|
|
48
|
-
const thoughts_1 = require("../../daemon/thoughts");
|
|
49
|
-
const mailbox_types_1 = require("../mailbox-types");
|
|
50
|
-
const shared_1 = require("./shared");
|
|
51
|
-
function emptyByStatus() {
|
|
52
|
-
return {
|
|
53
|
-
drafting: 0,
|
|
54
|
-
processing: 0,
|
|
55
|
-
validating: 0,
|
|
56
|
-
collaborating: 0,
|
|
57
|
-
paused: 0,
|
|
58
|
-
blocked: 0,
|
|
59
|
-
cancelled: 0,
|
|
60
|
-
done: 0,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function readAgentConfig(agentRoot) {
|
|
64
|
-
const configPath = path.join(agentRoot, "agent.json");
|
|
65
|
-
try {
|
|
66
|
-
const raw = fs.readFileSync(configPath, "utf-8");
|
|
67
|
-
const parsed = JSON.parse(raw);
|
|
68
|
-
const senses = Object.entries(parsed.senses ?? {})
|
|
69
|
-
.filter(([, value]) => value && typeof value.enabled === "boolean" && value.enabled)
|
|
70
|
-
.map(([name]) => name)
|
|
71
|
-
.sort((left, right) => left.localeCompare(right));
|
|
72
|
-
return {
|
|
73
|
-
summary: {
|
|
74
|
-
enabled: typeof parsed.enabled === "boolean" ? parsed.enabled : true,
|
|
75
|
-
provider: typeof parsed.provider === "string" ? parsed.provider : null,
|
|
76
|
-
senses,
|
|
77
|
-
},
|
|
78
|
-
issues: [],
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
return {
|
|
83
|
-
summary: {
|
|
84
|
-
enabled: false,
|
|
85
|
-
provider: null,
|
|
86
|
-
senses: [],
|
|
87
|
-
},
|
|
88
|
-
issues: [(0, shared_1.issue)("agent-config-unreadable", `${configPath}: ${error instanceof Error ? error.message : String(error)}`)],
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// W6 Unit 8a: built-in task module reads removed; mailbox surface keeps
|
|
93
|
-
// MailboxTaskSummary shape but reports zero counts. The desk MCP server is
|
|
94
|
-
// the new source of truth — its read surface will be wired into mailbox in
|
|
95
|
-
// a follow-up unit (8b). For now consumers see "no tasks tracked" which is
|
|
96
|
-
// the correct steady state until desk-side reads are in place.
|
|
97
|
-
function readTaskSummary(_agentRoot) {
|
|
98
|
-
return {
|
|
99
|
-
summary: {
|
|
100
|
-
totalCount: 0,
|
|
101
|
-
liveCount: 0,
|
|
102
|
-
blockedCount: 0,
|
|
103
|
-
byStatus: emptyByStatus(),
|
|
104
|
-
liveTaskNames: [],
|
|
105
|
-
actionRequired: [],
|
|
106
|
-
activeBridges: [],
|
|
107
|
-
},
|
|
108
|
-
issues: [],
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
const STALE_CODING_SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
112
|
-
function buildLiveCodingSurfaceLabels(agentRoot) {
|
|
113
|
-
return new Set(readCodingSummary(agentRoot).items
|
|
114
|
-
.filter((item) => shared_1.ACTIVE_CODING_STATUSES.has(item.status))
|
|
115
|
-
.map((item) => `${item.runner} ${item.id}`));
|
|
116
|
-
}
|
|
117
|
-
function normalizeObligationCurrentSurface(currentSurface, updatedAt, liveCodingSurfaceLabels) {
|
|
118
|
-
if (!currentSurface || currentSurface.kind !== "coding")
|
|
119
|
-
return currentSurface;
|
|
120
|
-
const liveLabel = currentSurface.label.trim();
|
|
121
|
-
if (!liveLabel)
|
|
122
|
-
return null;
|
|
123
|
-
if (liveCodingSurfaceLabels.has(liveLabel))
|
|
124
|
-
return currentSurface;
|
|
125
|
-
const updatedAtMs = Date.parse(updatedAt);
|
|
126
|
-
const recentlyTouched = Number.isFinite(updatedAtMs)
|
|
127
|
-
&& (Date.now() - updatedAtMs) <= STALE_CODING_SURFACE_WINDOW_MS;
|
|
128
|
-
return recentlyTouched ? currentSurface : null;
|
|
129
|
-
}
|
|
130
|
-
function legacyObligationTimestamp(obligation) {
|
|
131
|
-
if (typeof obligation.updatedAt === "string")
|
|
132
|
-
return obligation.updatedAt;
|
|
133
|
-
if (typeof obligation.createdAt === "string")
|
|
134
|
-
return obligation.createdAt;
|
|
135
|
-
return "";
|
|
136
|
-
}
|
|
137
|
-
function legacyObligationStatus(obligation) {
|
|
138
|
-
return typeof obligation.status === "string" ? obligation.status : "pending";
|
|
139
|
-
}
|
|
140
|
-
function readObligationSummary(agentRoot) {
|
|
141
|
-
const liveCodingSurfaceLabels = buildLiveCodingSurfaceLabels(agentRoot);
|
|
142
|
-
const items = (0, obligations_1.readPendingObligations)(agentRoot)
|
|
143
|
-
.map((obligation) => {
|
|
144
|
-
const updatedAt = legacyObligationTimestamp(obligation);
|
|
145
|
-
return {
|
|
146
|
-
id: obligation.id,
|
|
147
|
-
status: legacyObligationStatus(obligation),
|
|
148
|
-
content: obligation.content,
|
|
149
|
-
updatedAt,
|
|
150
|
-
nextAction: obligation.nextAction ?? null,
|
|
151
|
-
/* v8 ignore start */
|
|
152
|
-
origin: obligation.origin ?? null,
|
|
153
|
-
currentSurface: normalizeObligationCurrentSurface(obligation.currentSurface ?? null, updatedAt, liveCodingSurfaceLabels),
|
|
154
|
-
/* v8 ignore stop */
|
|
155
|
-
};
|
|
156
|
-
})
|
|
157
|
-
.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
158
|
-
return { items };
|
|
159
|
-
}
|
|
160
|
-
function readSessionSummary(agentName, agentRoot, now) {
|
|
161
|
-
const items = (0, session_activity_1.listSessionActivity)({
|
|
162
|
-
sessionsDir: path.join(agentRoot, "state", "sessions"),
|
|
163
|
-
friendsDir: path.join(agentRoot, "friends"),
|
|
164
|
-
agentName,
|
|
165
|
-
nowMs: now.getTime(),
|
|
166
|
-
})
|
|
167
|
-
.filter((session) => !(session.friendId === "self" && session.channel === "inner"))
|
|
168
|
-
.map((session) => ({
|
|
169
|
-
friendId: session.friendId,
|
|
170
|
-
friendName: session.friendName,
|
|
171
|
-
channel: session.channel,
|
|
172
|
-
key: session.key,
|
|
173
|
-
sessionPath: session.sessionPath,
|
|
174
|
-
lastActivityAt: session.lastActivityAt,
|
|
175
|
-
activitySource: session.activitySource,
|
|
176
|
-
}));
|
|
177
|
-
return { items };
|
|
178
|
-
}
|
|
179
|
-
function readInnerSummary(agentRoot) {
|
|
180
|
-
const sessionPath = (0, thoughts_1.getPrivateRuntimeSessionPath)(agentRoot);
|
|
181
|
-
const pendingDir = path.join(agentRoot, "state", "pending", "self", "inner", "dialog");
|
|
182
|
-
const { pendingMessages, turns, runtimeState } = (0, thoughts_1.readPrivateRuntimeRawData)(sessionPath, pendingDir);
|
|
183
|
-
const job = (0, thoughts_1.deriveInnerJob)(pendingMessages, turns, runtimeState);
|
|
184
|
-
const surfacedSummary = job.surfacedResult ? (0, thoughts_1.formatSurfacedValue)(job.surfacedResult) : null;
|
|
185
|
-
const latestPendingTimestamp = pendingMessages.length > 0
|
|
186
|
-
? new Date(Math.max(...pendingMessages.map((message) => message.timestamp))).toISOString()
|
|
187
|
-
: null;
|
|
188
|
-
const latestActivityAt = latestPendingTimestamp
|
|
189
|
-
?? runtimeState?.startedAt
|
|
190
|
-
?? runtimeState?.lastCompletedAt
|
|
191
|
-
?? null;
|
|
192
|
-
// Read the return-obligation queue so the Private Runtime tab can show what the
|
|
193
|
-
// agent is actually holding right now. Before this, the private-runtime work
|
|
194
|
-
// panel only consulted the pending-messages dir (inbox-style), so it
|
|
195
|
-
// looked empty even when dozens of held items were sitting in
|
|
196
|
-
// arc/obligations/inner/ waiting to be reinjected next turn.
|
|
197
|
-
const returnObligationQueue = readReturnObligationQueueSummary(agentRoot);
|
|
198
|
-
return {
|
|
199
|
-
summary: {
|
|
200
|
-
visibility: mailbox_types_1.MAILBOX_DEFAULT_INNER_VISIBILITY,
|
|
201
|
-
status: job.status,
|
|
202
|
-
hasPending: pendingMessages.length > 0,
|
|
203
|
-
surfacedSummary,
|
|
204
|
-
origin: job.origin,
|
|
205
|
-
obligationStatus: job.obligationStatus,
|
|
206
|
-
latestActivityAt,
|
|
207
|
-
returnObligationQueue,
|
|
208
|
-
},
|
|
209
|
-
issues: [],
|
|
210
|
-
latestActivityAt,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function readReturnObligationQueueSummary(agentRoot) {
|
|
214
|
-
const dir = path.join(agentRoot, "arc", "obligations", "inner");
|
|
215
|
-
let names = [];
|
|
216
|
-
try {
|
|
217
|
-
names = fs.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
218
|
-
}
|
|
219
|
-
catch {
|
|
220
|
-
return { queuedCount: 0, runningCount: 0, oldestActiveAt: null };
|
|
221
|
-
}
|
|
222
|
-
let queuedCount = 0;
|
|
223
|
-
let runningCount = 0;
|
|
224
|
-
let oldestActiveAt = null;
|
|
225
|
-
for (const name of names) {
|
|
226
|
-
let parsed = null;
|
|
227
|
-
try {
|
|
228
|
-
parsed = JSON.parse(fs.readFileSync(path.join(dir, name), "utf-8"));
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if (!parsed)
|
|
234
|
-
continue;
|
|
235
|
-
const status = parsed.status;
|
|
236
|
-
if (status === "queued")
|
|
237
|
-
queuedCount += 1;
|
|
238
|
-
else if (status === "running")
|
|
239
|
-
runningCount += 1;
|
|
240
|
-
else
|
|
241
|
-
continue;
|
|
242
|
-
const createdAt = typeof parsed.createdAt === "number" ? parsed.createdAt : null;
|
|
243
|
-
if (createdAt !== null && (oldestActiveAt === null || createdAt < oldestActiveAt)) {
|
|
244
|
-
oldestActiveAt = createdAt;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return { queuedCount, runningCount, oldestActiveAt };
|
|
248
|
-
}
|
|
249
|
-
function readCodingSummary(agentRoot) {
|
|
250
|
-
const stateFilePath = path.join(agentRoot, "state", "coding", "sessions.json");
|
|
251
|
-
const issues = [];
|
|
252
|
-
if (!fs.existsSync(stateFilePath)) {
|
|
253
|
-
return { items: [], issues };
|
|
254
|
-
}
|
|
255
|
-
let parsed;
|
|
256
|
-
try {
|
|
257
|
-
parsed = JSON.parse(fs.readFileSync(stateFilePath, "utf-8"));
|
|
258
|
-
}
|
|
259
|
-
catch (error) {
|
|
260
|
-
issues.push((0, shared_1.issue)("coding-state-unreadable", `${stateFilePath}: ${error instanceof Error ? error.message : String(error)}`));
|
|
261
|
-
return { items: [], issues };
|
|
262
|
-
}
|
|
263
|
-
const items = Array.isArray(parsed.records)
|
|
264
|
-
? parsed.records.flatMap((record) => {
|
|
265
|
-
const session = record?.session;
|
|
266
|
-
if (!session || typeof session.id !== "string" || typeof session.runner !== "string" || typeof session.status !== "string" || typeof session.workdir !== "string" || typeof session.lastActivityAt !== "string") {
|
|
267
|
-
return [];
|
|
268
|
-
}
|
|
269
|
-
const checkpoint = typeof session.checkpoint === "string"
|
|
270
|
-
? session.checkpoint
|
|
271
|
-
: typeof session.stderrTail === "string" && session.stderrTail.trim().length > 0
|
|
272
|
-
? session.stderrTail.trim()
|
|
273
|
-
: typeof session.stdoutTail === "string" && session.stdoutTail.trim().length > 0
|
|
274
|
-
? session.stdoutTail.trim()
|
|
275
|
-
: null;
|
|
276
|
-
const originSession = session.originSession;
|
|
277
|
-
const normalizedOrigin = originSession
|
|
278
|
-
&& typeof originSession.friendId === "string"
|
|
279
|
-
&& typeof originSession.channel === "string"
|
|
280
|
-
&& typeof originSession.key === "string"
|
|
281
|
-
? {
|
|
282
|
-
friendId: originSession.friendId,
|
|
283
|
-
channel: originSession.channel,
|
|
284
|
-
key: originSession.key,
|
|
285
|
-
}
|
|
286
|
-
: null;
|
|
287
|
-
return [{
|
|
288
|
-
id: session.id,
|
|
289
|
-
runner: session.runner,
|
|
290
|
-
status: session.status,
|
|
291
|
-
checkpoint,
|
|
292
|
-
taskRef: typeof session.taskRef === "string" ? session.taskRef : null,
|
|
293
|
-
workdir: session.workdir,
|
|
294
|
-
originSession: normalizedOrigin,
|
|
295
|
-
lastActivityAt: session.lastActivityAt,
|
|
296
|
-
}];
|
|
297
|
-
})
|
|
298
|
-
: [];
|
|
299
|
-
return { items, issues };
|
|
300
|
-
}
|
|
301
|
-
function collectLatestActivityTimestamps(input) {
|
|
302
|
-
const timestamps = [];
|
|
303
|
-
for (const item of input.obligations)
|
|
304
|
-
timestamps.push(item.updatedAt);
|
|
305
|
-
for (const item of input.sessions)
|
|
306
|
-
timestamps.push(item.lastActivityAt);
|
|
307
|
-
for (const item of input.coding)
|
|
308
|
-
timestamps.push(item.lastActivityAt);
|
|
309
|
-
if (input.innerLatestActivityAt)
|
|
310
|
-
timestamps.push(input.innerLatestActivityAt);
|
|
311
|
-
return timestamps
|
|
312
|
-
.filter((value) => Number.isFinite(Date.parse(value)));
|
|
313
|
-
}
|
|
314
|
-
function summarizeFreshness(latestActivityAt, now) {
|
|
315
|
-
if (!latestActivityAt) {
|
|
316
|
-
return {
|
|
317
|
-
status: "unknown",
|
|
318
|
-
latestActivityAt: null,
|
|
319
|
-
ageMs: null,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
const ageMs = now.getTime() - Date.parse(latestActivityAt);
|
|
323
|
-
return {
|
|
324
|
-
status: ageMs > shared_1.STALE_THRESHOLD_MS ? "stale" : "fresh",
|
|
325
|
-
latestActivityAt,
|
|
326
|
-
ageMs,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function summarizeDegraded(issues) {
|
|
330
|
-
return {
|
|
331
|
-
status: issues.length > 0 ? "degraded" : "ok",
|
|
332
|
-
issues,
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function summarizeAgent(state) {
|
|
336
|
-
return {
|
|
337
|
-
agentName: state.agentName,
|
|
338
|
-
enabled: state.enabled,
|
|
339
|
-
providers: state.providers,
|
|
340
|
-
freshness: state.freshness,
|
|
341
|
-
degraded: state.degraded,
|
|
342
|
-
tasks: {
|
|
343
|
-
liveCount: state.tasks.liveCount,
|
|
344
|
-
blockedCount: state.tasks.blockedCount,
|
|
345
|
-
},
|
|
346
|
-
obligations: {
|
|
347
|
-
openCount: state.obligations.openCount,
|
|
348
|
-
},
|
|
349
|
-
coding: {
|
|
350
|
-
activeCount: state.coding.activeCount,
|
|
351
|
-
blockedCount: state.coding.blockedCount,
|
|
352
|
-
},
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function readMailboxAgentState(agentName, options = {}) {
|
|
356
|
-
const bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
357
|
-
const now = options.now?.() ?? new Date();
|
|
358
|
-
const agentRoot = path.join(bundlesRoot, `${agentName}.ouro`);
|
|
359
|
-
const issues = [];
|
|
360
|
-
const config = readAgentConfig(agentRoot);
|
|
361
|
-
issues.push(...config.issues);
|
|
362
|
-
const tasks = readTaskSummary(agentRoot);
|
|
363
|
-
issues.push(...tasks.issues);
|
|
364
|
-
const obligations = readObligationSummary(agentRoot);
|
|
365
|
-
const sessions = readSessionSummary(agentName, agentRoot, now);
|
|
366
|
-
const inner = readInnerSummary(agentRoot);
|
|
367
|
-
issues.push(...inner.issues);
|
|
368
|
-
const coding = readCodingSummary(agentRoot);
|
|
369
|
-
issues.push(...coding.issues);
|
|
370
|
-
const providers = (0, provider_visibility_1.buildAgentProviderVisibility)({ agentName, agentRoot, homeDir: options.homeDir });
|
|
371
|
-
const latestActivityAt = collectLatestActivityTimestamps({
|
|
372
|
-
obligations: obligations.items,
|
|
373
|
-
sessions: sessions.items,
|
|
374
|
-
innerLatestActivityAt: inner.latestActivityAt,
|
|
375
|
-
coding: coding.items,
|
|
376
|
-
}).sort((left, right) => right.localeCompare(left))[0] ?? null;
|
|
377
|
-
return {
|
|
378
|
-
productName: mailbox_types_1.MAILBOX_PRODUCT_NAME,
|
|
379
|
-
agentName,
|
|
380
|
-
agentRoot,
|
|
381
|
-
enabled: config.summary.enabled,
|
|
382
|
-
provider: config.summary.provider,
|
|
383
|
-
providers,
|
|
384
|
-
senses: config.summary.senses,
|
|
385
|
-
freshness: summarizeFreshness(latestActivityAt, now),
|
|
386
|
-
degraded: summarizeDegraded(issues),
|
|
387
|
-
tasks: tasks.summary,
|
|
388
|
-
obligations: {
|
|
389
|
-
openCount: obligations.items.length,
|
|
390
|
-
items: obligations.items,
|
|
391
|
-
},
|
|
392
|
-
sessions: {
|
|
393
|
-
liveCount: sessions.items.length,
|
|
394
|
-
items: sessions.items,
|
|
395
|
-
},
|
|
396
|
-
inner: inner.summary,
|
|
397
|
-
coding: {
|
|
398
|
-
totalCount: coding.items.length,
|
|
399
|
-
activeCount: coding.items.filter((item) => shared_1.ACTIVE_CODING_STATUSES.has(item.status)).length,
|
|
400
|
-
blockedCount: coding.items.filter((item) => shared_1.BLOCKED_CODING_STATUSES.has(item.status)).length,
|
|
401
|
-
items: coding.items,
|
|
402
|
-
},
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
function readMailboxMachineState(options = {}) {
|
|
406
|
-
/* v8 ignore next */
|
|
407
|
-
(0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.mailbox_read", message: "reading mailbox machine state", meta: {} });
|
|
408
|
-
const bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
409
|
-
const now = options.now?.() ?? new Date();
|
|
410
|
-
const runtime = options.runtimeMetadata ?? (0, runtime_metadata_1.getRuntimeMetadata)({ bundlesRoot });
|
|
411
|
-
const agentNames = options.agentNames ?? (0, agent_discovery_1.listEnabledBundleAgents)({ bundlesRoot });
|
|
412
|
-
const agentStates = agentNames.map((agentName) => readMailboxAgentState(agentName, { ...options, bundlesRoot, now: () => now }));
|
|
413
|
-
const degradedIssues = agentStates
|
|
414
|
-
.flatMap((state) => state.degraded.issues.map((problem) => (0, shared_1.issue)("agent-degraded", `${state.agentName}: ${problem.detail}`)));
|
|
415
|
-
const freshest = agentStates
|
|
416
|
-
.map((state) => state.freshness.latestActivityAt)
|
|
417
|
-
.filter((value) => typeof value === "string")
|
|
418
|
-
.sort((left, right) => right.localeCompare(left))[0] ?? null;
|
|
419
|
-
return {
|
|
420
|
-
productName: mailbox_types_1.MAILBOX_PRODUCT_NAME,
|
|
421
|
-
observedAt: now.toISOString(),
|
|
422
|
-
runtime,
|
|
423
|
-
agentCount: agentStates.length,
|
|
424
|
-
freshness: summarizeFreshness(freshest, now),
|
|
425
|
-
degraded: summarizeDegraded(degradedIssues),
|
|
426
|
-
agents: agentStates.map(summarizeAgent),
|
|
427
|
-
};
|
|
428
|
-
}
|