@femtomc/mu-agent 26.2.119 → 26.2.120
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-log.d.ts","sourceRoot":"","sources":["../../src/extensions/event-log.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"event-log.d.ts","sourceRoot":"","sources":["../../src/extensions/event-log.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,+BAA+B,CAAC;AAqCpF,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,QAmIjD;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { registerMuSubcommand } from "./mu-command-dispatcher.js";
|
|
9
9
|
import { clampInt, fetchMuJson, muServerUrl } from "./shared.js";
|
|
10
|
+
const EVENT_LOG_FETCH_TIMEOUT_MS = 2_000;
|
|
10
11
|
function eventTime(tsMs) {
|
|
11
12
|
return new Date(tsMs).toLocaleTimeString();
|
|
12
13
|
}
|
|
@@ -19,7 +20,9 @@ async function fetchTail(n) {
|
|
|
19
20
|
if (!muServerUrl())
|
|
20
21
|
return [];
|
|
21
22
|
try {
|
|
22
|
-
return await fetchMuJson(`/api/control-plane/events/tail?n=${n}`, {
|
|
23
|
+
return await fetchMuJson(`/api/control-plane/events/tail?n=${n}`, {
|
|
24
|
+
timeoutMs: EVENT_LOG_FETCH_TIMEOUT_MS,
|
|
25
|
+
});
|
|
23
26
|
}
|
|
24
27
|
catch {
|
|
25
28
|
return [];
|
|
@@ -29,11 +32,17 @@ export function eventLogExtension(pi) {
|
|
|
29
32
|
let watchEnabled = false;
|
|
30
33
|
let pollTimer = null;
|
|
31
34
|
let activeCtx = null;
|
|
35
|
+
let refreshInFlight = null;
|
|
32
36
|
async function refresh(ctx, opts = {}) {
|
|
33
|
-
|
|
37
|
+
const isActiveUiContext = () => activeCtx === ctx && ctx.hasUI;
|
|
38
|
+
if (!isActiveUiContext()) {
|
|
34
39
|
return;
|
|
40
|
+
}
|
|
35
41
|
const tail = clampInt(opts.tail, 8, 1, 50);
|
|
36
42
|
const events = await fetchTail(tail);
|
|
43
|
+
if (!isActiveUiContext()) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
37
46
|
if (events.length === 0) {
|
|
38
47
|
ctx.ui.setStatus("mu-events", ctx.ui.theme.fg("dim", "events: none"));
|
|
39
48
|
if (watchEnabled) {
|
|
@@ -48,6 +57,14 @@ export function eventLogExtension(pi) {
|
|
|
48
57
|
ctx.ui.setWidget("mu-events", lines, { placement: "belowEditor" });
|
|
49
58
|
}
|
|
50
59
|
}
|
|
60
|
+
function requestRefresh(ctx, opts = {}) {
|
|
61
|
+
if (refreshInFlight) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
refreshInFlight = refresh(ctx, opts).finally(() => {
|
|
65
|
+
refreshInFlight = null;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
51
68
|
function stopPolling() {
|
|
52
69
|
if (!pollTimer)
|
|
53
70
|
return;
|
|
@@ -60,7 +77,7 @@ export function eventLogExtension(pi) {
|
|
|
60
77
|
pollTimer = setInterval(() => {
|
|
61
78
|
if (!activeCtx)
|
|
62
79
|
return;
|
|
63
|
-
|
|
80
|
+
requestRefresh(activeCtx);
|
|
64
81
|
}, 8_000);
|
|
65
82
|
}
|
|
66
83
|
function setWatchEnabled(next) {
|
|
@@ -68,7 +85,7 @@ export function eventLogExtension(pi) {
|
|
|
68
85
|
if (watchEnabled) {
|
|
69
86
|
ensurePolling();
|
|
70
87
|
if (activeCtx) {
|
|
71
|
-
|
|
88
|
+
requestRefresh(activeCtx);
|
|
72
89
|
}
|
|
73
90
|
return;
|
|
74
91
|
}
|
|
@@ -77,24 +94,25 @@ export function eventLogExtension(pi) {
|
|
|
77
94
|
}
|
|
78
95
|
stopPolling();
|
|
79
96
|
}
|
|
80
|
-
pi.on("session_start",
|
|
97
|
+
pi.on("session_start", (_event, ctx) => {
|
|
81
98
|
activeCtx = ctx;
|
|
82
99
|
if (!ctx.hasUI)
|
|
83
100
|
return;
|
|
84
|
-
|
|
101
|
+
requestRefresh(ctx);
|
|
85
102
|
if (watchEnabled)
|
|
86
103
|
ensurePolling();
|
|
87
104
|
});
|
|
88
|
-
pi.on("session_switch",
|
|
105
|
+
pi.on("session_switch", (_event, ctx) => {
|
|
89
106
|
activeCtx = ctx;
|
|
90
107
|
if (!ctx.hasUI)
|
|
91
108
|
return;
|
|
92
|
-
|
|
109
|
+
requestRefresh(ctx);
|
|
93
110
|
if (watchEnabled)
|
|
94
111
|
ensurePolling();
|
|
95
112
|
});
|
|
96
113
|
pi.on("session_shutdown", async () => {
|
|
97
114
|
stopPolling();
|
|
115
|
+
refreshInFlight = null;
|
|
98
116
|
activeCtx = null;
|
|
99
117
|
});
|
|
100
118
|
registerMuSubcommand(pi, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@femtomc/mu-agent",
|
|
3
|
-
"version": "26.2.
|
|
3
|
+
"version": "26.2.120",
|
|
4
4
|
"description": "Shared operator runtime for mu assistant sessions and serve extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mu",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"themes/**"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@femtomc/mu-core": "26.2.
|
|
27
|
+
"@femtomc/mu-core": "26.2.120",
|
|
28
28
|
"@mariozechner/pi-agent-core": "^0.54.2",
|
|
29
29
|
"@mariozechner/pi-ai": "^0.54.2",
|
|
30
30
|
"@mariozechner/pi-coding-agent": "^0.54.2",
|