@agentmonitors/cli 0.5.0 → 0.6.0
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/dist/index.cjs +25 -9
- package/dist/index.cjs.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -32690,6 +32690,7 @@ var AgentMonitorRuntime = class {
|
|
|
32690
32690
|
const now = /* @__PURE__ */ new Date();
|
|
32691
32691
|
const emittedEventIds = [];
|
|
32692
32692
|
const evaluated = [];
|
|
32693
|
+
const erroredObservations = [];
|
|
32693
32694
|
for (const parsed of result.monitors) {
|
|
32694
32695
|
const monitor = parsed.monitor;
|
|
32695
32696
|
const sourceName = monitor.frontmatter.watch.type;
|
|
@@ -32714,13 +32715,15 @@ var AgentMonitorRuntime = class {
|
|
|
32714
32715
|
}
|
|
32715
32716
|
);
|
|
32716
32717
|
} catch (observeError) {
|
|
32718
|
+
const message = observeError instanceof Error ? observeError.message : String(observeError);
|
|
32719
|
+
erroredObservations.push({ monitorId: monitor.id, message });
|
|
32717
32720
|
try {
|
|
32718
32721
|
this.store.recordObservationHistory({
|
|
32719
32722
|
monitorId: monitor.id,
|
|
32720
32723
|
sourceName,
|
|
32721
32724
|
result: "errored",
|
|
32722
32725
|
observationData: {
|
|
32723
|
-
error:
|
|
32726
|
+
error: message
|
|
32724
32727
|
}
|
|
32725
32728
|
});
|
|
32726
32729
|
} catch {
|
|
@@ -32736,13 +32739,15 @@ var AgentMonitorRuntime = class {
|
|
|
32736
32739
|
})
|
|
32737
32740
|
);
|
|
32738
32741
|
} catch (ingestError) {
|
|
32742
|
+
const message = ingestError instanceof Error ? ingestError.message : String(ingestError);
|
|
32743
|
+
erroredObservations.push({ monitorId: monitor.id, message });
|
|
32739
32744
|
try {
|
|
32740
32745
|
this.store.recordObservationHistory({
|
|
32741
32746
|
monitorId: monitor.id,
|
|
32742
32747
|
sourceName,
|
|
32743
32748
|
result: "errored",
|
|
32744
32749
|
observationData: {
|
|
32745
|
-
error:
|
|
32750
|
+
error: message
|
|
32746
32751
|
}
|
|
32747
32752
|
});
|
|
32748
32753
|
} catch {
|
|
@@ -32750,7 +32755,11 @@ var AgentMonitorRuntime = class {
|
|
|
32750
32755
|
}
|
|
32751
32756
|
}
|
|
32752
32757
|
this.refreshWorkspaceSessions(workspacePath);
|
|
32753
|
-
return {
|
|
32758
|
+
return {
|
|
32759
|
+
evaluatedMonitors: evaluated,
|
|
32760
|
+
emittedEventIds,
|
|
32761
|
+
erroredObservations
|
|
32762
|
+
};
|
|
32754
32763
|
}
|
|
32755
32764
|
/**
|
|
32756
32765
|
* Funnel a batch of observations through notify dispatch, persist the updated
|
|
@@ -35525,6 +35534,11 @@ function shouldReap(s) {
|
|
|
35525
35534
|
|
|
35526
35535
|
// src/commands/daemon.ts
|
|
35527
35536
|
var DEFAULT_REAP_AFTER_MS = 5 * 60 * 1e3;
|
|
35537
|
+
function appendErroredLines(summary, errored) {
|
|
35538
|
+
if (errored.length === 0) return summary;
|
|
35539
|
+
const lines = errored.map((e) => ` ${e.monitorId}: ${e.message}`);
|
|
35540
|
+
return [summary, ...lines].join("\n");
|
|
35541
|
+
}
|
|
35528
35542
|
async function runLoop(monitorsDir, workspacePath, pollMs, socketPath, reapAfterMs) {
|
|
35529
35543
|
const runtime = createRuntime();
|
|
35530
35544
|
let stopping = false;
|
|
@@ -35570,10 +35584,12 @@ async function runLoop(monitorsDir, workspacePath, pollMs, socketPath, reapAfter
|
|
|
35570
35584
|
while (!isStoppingRequested()) {
|
|
35571
35585
|
try {
|
|
35572
35586
|
const result = await runtime.tick(monitorsDir, workspacePath);
|
|
35573
|
-
if (result.emittedEventIds.length > 0) {
|
|
35574
|
-
|
|
35575
|
-
`Emitted ${String(result.emittedEventIds.length)} event(s) from ${String(result.evaluatedMonitors.length)} monitor(s)
|
|
35587
|
+
if (result.emittedEventIds.length > 0 || result.erroredObservations.length > 0) {
|
|
35588
|
+
const summary = appendErroredLines(
|
|
35589
|
+
`Emitted ${String(result.emittedEventIds.length)} event(s) from ${String(result.evaluatedMonitors.length)} monitor(s)${result.erroredObservations.length > 0 ? `, ${String(result.erroredObservations.length)} errored:` : "."}`,
|
|
35590
|
+
result.erroredObservations
|
|
35576
35591
|
);
|
|
35592
|
+
console.log(summary);
|
|
35577
35593
|
}
|
|
35578
35594
|
} catch (error2) {
|
|
35579
35595
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
@@ -35639,9 +35655,9 @@ daemonCommand.command("once").description("Run one runtime observation cycle").a
|
|
|
35639
35655
|
console.log(JSON.stringify(result, null, 2));
|
|
35640
35656
|
return;
|
|
35641
35657
|
}
|
|
35642
|
-
|
|
35643
|
-
|
|
35644
|
-
);
|
|
35658
|
+
const erroredCount = result.erroredObservations.length;
|
|
35659
|
+
const base = `Evaluated ${String(result.evaluatedMonitors.length)} monitor(s), emitted ${String(result.emittedEventIds.length)} event(s)${erroredCount > 0 ? `, ${String(erroredCount)} errored:` : "."}`;
|
|
35660
|
+
console.log(appendErroredLines(base, result.erroredObservations));
|
|
35645
35661
|
} catch (error2) {
|
|
35646
35662
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
35647
35663
|
reportError(message, options2.format === "json");
|