@0xmaxma/claude-gateway 2.0.5 → 2.0.6
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/agent/runner.d.ts +14 -0
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +75 -71
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/session-compaction-scheduler.d.ts +22 -0
- package/dist/agent/session-compaction-scheduler.d.ts.map +1 -0
- package/dist/agent/session-compaction-scheduler.js +40 -0
- package/dist/agent/session-compaction-scheduler.js.map +1 -0
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +100 -10
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/memory-activity.d.ts +18 -0
- package/dist/api/memory-activity.d.ts.map +1 -0
- package/dist/api/memory-activity.js +97 -0
- package/dist/api/memory-activity.js.map +1 -0
- package/dist/orchestration/agent-tool-schemas.js +1 -1
- package/dist/orchestration/agent-tool-schemas.js.map +1 -1
- package/dist/orchestration/bridge.js +1 -1
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/compact-measurements.d.ts +21 -0
- package/dist/orchestration/compact-measurements.d.ts.map +1 -0
- package/dist/orchestration/compact-measurements.js +62 -0
- package/dist/orchestration/compact-measurements.js.map +1 -0
- package/dist/orchestration/config.d.ts +4 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +1 -1
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/context-delivery.d.ts +32 -0
- package/dist/orchestration/context-delivery.d.ts.map +1 -0
- package/dist/orchestration/context-delivery.js +101 -0
- package/dist/orchestration/context-delivery.js.map +1 -0
- package/dist/orchestration/conversation-intake.d.ts +10 -6
- package/dist/orchestration/conversation-intake.d.ts.map +1 -1
- package/dist/orchestration/conversation-intake.js +22 -8
- package/dist/orchestration/conversation-intake.js.map +1 -1
- package/dist/orchestration/dashboard-charts.d.ts +32 -0
- package/dist/orchestration/dashboard-charts.d.ts.map +1 -0
- package/dist/orchestration/dashboard-charts.js +77 -0
- package/dist/orchestration/dashboard-charts.js.map +1 -0
- package/dist/orchestration/dashboard-reader-worker.js +21 -3
- package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
- package/dist/orchestration/dashboard-reader.d.ts +1 -1
- package/dist/orchestration/dashboard-reader.d.ts.map +1 -1
- package/dist/orchestration/dashboard-reader.js +2 -2
- package/dist/orchestration/dashboard-reader.js.map +1 -1
- package/dist/orchestration/decision-context.d.ts +1 -1
- package/dist/orchestration/decision-context.d.ts.map +1 -1
- package/dist/orchestration/decision-context.js +2 -2
- package/dist/orchestration/decision-context.js.map +1 -1
- package/dist/orchestration/mutation-recovery.d.ts +3 -2
- package/dist/orchestration/mutation-recovery.d.ts.map +1 -1
- package/dist/orchestration/mutation-recovery.js +8 -0
- package/dist/orchestration/mutation-recovery.js.map +1 -1
- package/dist/orchestration/native-compact.d.ts +4 -1
- package/dist/orchestration/native-compact.d.ts.map +1 -1
- package/dist/orchestration/native-compact.js +6 -2
- package/dist/orchestration/native-compact.js.map +1 -1
- package/dist/orchestration/process-turn.d.ts +1 -0
- package/dist/orchestration/process-turn.d.ts.map +1 -1
- package/dist/orchestration/process-turn.js +1 -1
- package/dist/orchestration/process-turn.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +13 -1
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +161 -18
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/session-compaction.d.ts +59 -0
- package/dist/orchestration/session-compaction.d.ts.map +1 -0
- package/dist/orchestration/session-compaction.js +212 -0
- package/dist/orchestration/session-compaction.js.map +1 -0
- package/dist/orchestration/tasks/driver.js +1 -1
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/token-ledger.d.ts +7 -0
- package/dist/orchestration/token-ledger.d.ts.map +1 -1
- package/dist/orchestration/token-ledger.js +1 -0
- package/dist/orchestration/token-ledger.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/dashboard-charts.d.ts +3 -0
- package/dist/ui/dashboard-charts.d.ts.map +1 -0
- package/dist/ui/dashboard-charts.js +130 -0
- package/dist/ui/dashboard-charts.js.map +1 -0
- package/dist/ui/dashboard-client.d.ts.map +1 -1
- package/dist/ui/dashboard-client.js +10 -14
- package/dist/ui/dashboard-client.js.map +1 -1
- package/dist/ui/dashboard-controls.d.ts +4 -0
- package/dist/ui/dashboard-controls.d.ts.map +1 -0
- package/dist/ui/dashboard-controls.js +27 -0
- package/dist/ui/dashboard-controls.js.map +1 -0
- package/dist/ui/dashboard-presentation.d.ts +3 -0
- package/dist/ui/dashboard-presentation.d.ts.map +1 -1
- package/dist/ui/dashboard-presentation.js +11 -5
- package/dist/ui/dashboard-presentation.js.map +1 -1
- package/dist/ui/dashboard-range.d.ts +3 -3
- package/dist/ui/dashboard-range.d.ts.map +1 -1
- package/dist/ui/dashboard-range.js +21 -5
- package/dist/ui/dashboard-range.js.map +1 -1
- package/dist/ui/dashboard-theme.d.ts +3 -1
- package/dist/ui/dashboard-theme.d.ts.map +1 -1
- package/dist/ui/dashboard-theme.js +80 -3
- package/dist/ui/dashboard-theme.js.map +1 -1
- package/dist/ui/memory-activity.d.ts +4 -0
- package/dist/ui/memory-activity.d.ts.map +1 -0
- package/dist/ui/memory-activity.js +115 -0
- package/dist/ui/memory-activity.js.map +1 -0
- package/dist/ui/token-report-client.d.ts +1 -1
- package/dist/ui/token-report-client.d.ts.map +1 -1
- package/dist/ui/token-report-client.js +1 -1
- package/dist/ui/token-report.d.ts +1 -0
- package/dist/ui/token-report.d.ts.map +1 -1
- package/dist/ui/token-report.js +18 -15
- package/dist/ui/token-report.js.map +1 -1
- package/dist/ui/web-ui.d.ts +1 -1
- package/dist/ui/web-ui.d.ts.map +1 -1
- package/dist/ui/web-ui.js +15 -238
- package/dist/ui/web-ui.js.map +1 -1
- package/mcp/tools/telegram/receiver-server.ts +31 -17
- package/mcp/tools/telegram/session-browser.ts +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ResolvedSessionCompaction } from '../orchestration/session-compaction';
|
|
2
|
+
export declare class SessionCompactionScheduler {
|
|
3
|
+
private agentId;
|
|
4
|
+
private settings;
|
|
5
|
+
private run;
|
|
6
|
+
private failed;
|
|
7
|
+
private timer?;
|
|
8
|
+
nextRunAt: number | null;
|
|
9
|
+
private stopped;
|
|
10
|
+
private generation;
|
|
11
|
+
constructor(agentId: string, settings: () => {
|
|
12
|
+
config: ResolvedSessionCompaction;
|
|
13
|
+
hour: number;
|
|
14
|
+
minute: number;
|
|
15
|
+
timezone: string;
|
|
16
|
+
stagger: number;
|
|
17
|
+
}, run: () => Promise<unknown>, failed: (error: unknown) => void);
|
|
18
|
+
start(): void;
|
|
19
|
+
private schedule;
|
|
20
|
+
stop(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=session-compaction-scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-compaction-scheduler.d.ts","sourceRoot":"","sources":["../../src/agent/session-compaction-scheduler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAErF,qBAAa,0BAA0B;IAKzB,OAAO,CAAC,OAAO;IAAQ,OAAO,CAAC,QAAQ;IAAiG,OAAO,CAAC,GAAG;IAAsB,OAAO,CAAC,MAAM;IAJnM,OAAO,CAAC,KAAK,CAAC,CAAgB;IAC9B,SAAS,EAAC,MAAM,GAAC,IAAI,CAAM;IAC3B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,UAAU,CAAG;gBACD,OAAO,EAAC,MAAM,EAAS,QAAQ,EAAC,MAAI;QAAC,MAAM,EAAC,yBAAyB,CAAC;QAAA,IAAI,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,CAAC;QAAA,QAAQ,EAAC,MAAM,CAAC;QAAA,OAAO,EAAC,MAAM,CAAA;KAAC,EAAS,GAAG,EAAC,MAAI,OAAO,CAAC,OAAO,CAAC,EAAS,MAAM,EAAC,CAAC,KAAK,EAAC,OAAO,KAAG,IAAI;IACzN,KAAK,IAAG,IAAI;IAIZ,OAAO,CAAC,QAAQ;IAYhB,IAAI,IAAG,IAAI;CACZ"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionCompactionScheduler = void 0;
|
|
4
|
+
const cleanup_1 = require("../history/cleanup");
|
|
5
|
+
const dreaming_1 = require("./dreaming");
|
|
6
|
+
class SessionCompactionScheduler {
|
|
7
|
+
constructor(agentId, settings, run, failed) {
|
|
8
|
+
this.agentId = agentId;
|
|
9
|
+
this.settings = settings;
|
|
10
|
+
this.run = run;
|
|
11
|
+
this.failed = failed;
|
|
12
|
+
this.nextRunAt = null;
|
|
13
|
+
this.stopped = true;
|
|
14
|
+
this.generation = 0;
|
|
15
|
+
}
|
|
16
|
+
start() {
|
|
17
|
+
this.stop();
|
|
18
|
+
this.stopped = false;
|
|
19
|
+
this.schedule();
|
|
20
|
+
}
|
|
21
|
+
schedule(generation = this.generation) {
|
|
22
|
+
const cfg = this.settings();
|
|
23
|
+
if (this.stopped || generation !== this.generation || !cfg.config.enabled)
|
|
24
|
+
return;
|
|
25
|
+
const delay = (0, cleanup_1.msUntilNextTime)(cfg.hour, cfg.minute, cfg.timezone) + (0, dreaming_1.agentJitterMs)(this.agentId, cfg.stagger);
|
|
26
|
+
this.nextRunAt = Date.now() + delay;
|
|
27
|
+
this.timer = setTimeout(() => {
|
|
28
|
+
if (this.stopped || generation !== this.generation)
|
|
29
|
+
return;
|
|
30
|
+
this.timer = undefined;
|
|
31
|
+
this.nextRunAt = null;
|
|
32
|
+
void this.run().catch(this.failed).finally(() => this.schedule(generation));
|
|
33
|
+
}, delay);
|
|
34
|
+
this.timer.unref();
|
|
35
|
+
}
|
|
36
|
+
stop() { this.generation++; this.stopped = true; if (this.timer)
|
|
37
|
+
clearTimeout(this.timer); this.timer = undefined; this.nextRunAt = null; }
|
|
38
|
+
}
|
|
39
|
+
exports.SessionCompactionScheduler = SessionCompactionScheduler;
|
|
40
|
+
//# sourceMappingURL=session-compaction-scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-compaction-scheduler.js","sourceRoot":"","sources":["../../src/agent/session-compaction-scheduler.ts"],"names":[],"mappings":";;;AAAA,gDAAqD;AACrD,yCAA2C;AAG3C,MAAa,0BAA0B;IAKrC,YAAoB,OAAc,EAAS,QAAwG,EAAS,GAAwB,EAAS,MAA4B;QAArM,YAAO,GAAP,OAAO,CAAO;QAAS,aAAQ,GAAR,QAAQ,CAAgG;QAAS,QAAG,GAAH,GAAG,CAAqB;QAAS,WAAM,GAAN,MAAM,CAAsB;QAHzN,cAAS,GAAa,IAAI,CAAC;QACnB,YAAO,GAAC,IAAI,CAAC;QACb,eAAU,GAAC,CAAC,CAAC;IACsM,CAAC;IAC5N,KAAK;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;QAAA,IAAI,CAAC,OAAO,GAAC,KAAK,CAAC;QAC/B,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IACO,QAAQ,CAAC,UAAU,GAAC,IAAI,CAAC,UAAU;QACzC,MAAM,GAAG,GAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC1B,IAAG,IAAI,CAAC,OAAO,IAAE,UAAU,KAAG,IAAI,CAAC,UAAU,IAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAAC,OAAO;QAC1E,MAAM,KAAK,GAAC,IAAA,yBAAe,EAAC,GAAG,CAAC,IAAI,EAAC,GAAG,CAAC,MAAM,EAAC,GAAG,CAAC,QAAQ,CAAC,GAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,OAAO,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtG,IAAI,CAAC,SAAS,GAAC,IAAI,CAAC,GAAG,EAAE,GAAC,KAAK,CAAC;QAChC,IAAI,CAAC,KAAK,GAAC,UAAU,CAAC,GAAE,EAAE;YACxB,IAAG,IAAI,CAAC,OAAO,IAAE,UAAU,KAAG,IAAI,CAAC,UAAU;gBAAC,OAAO;YACrD,IAAI,CAAC,KAAK,GAAC,SAAS,CAAC;YAAA,IAAI,CAAC,SAAS,GAAC,IAAI,CAAC;YACzC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAE,EAAE,CAAA,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QAC5E,CAAC,EAAC,KAAK,CAAC,CAAC;QACT,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IACD,IAAI,KAAS,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA,IAAI,CAAC,OAAO,GAAC,IAAI,CAAC,CAAA,IAAG,IAAI,CAAC,KAAK;QAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA,IAAI,CAAC,KAAK,GAAC,SAAS,CAAC,CAAA,IAAI,CAAC,SAAS,GAAC,IAAI,CAAC,CAAA,CAAC;CACnI;AAvBD,gEAuBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-router.d.ts","sourceRoot":"","sources":["../../src/api/gateway-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gateway-router.d.ts","sourceRoot":"","sources":["../../src/api/gateway-router.ts"],"names":[],"mappings":"AAGA,OAAO,OAA8B,MAAM,SAAS,CAAC;AASrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAmB,MAAM,UAAU,CAAC;A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;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IASvD;;OAEG;IACH,UAAU,IAAI,WAAW,EAAE;IAI3B;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAMtC;;OAEG;IACH,aAAa,IAAI,UAAU,EAAE;CAe9B"}
|
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.GatewayRouter = void 0;
|
|
40
40
|
exports.resolveBindHost = resolveBindHost;
|
|
41
|
+
const memory_activity_1 = require("./memory-activity");
|
|
41
42
|
const dashboard_range_1 = require("../ui/dashboard-range");
|
|
42
43
|
const dashboard_reader_1 = require("../orchestration/dashboard-reader");
|
|
43
44
|
const express_1 = __importDefault(require("express"));
|
|
@@ -815,10 +816,10 @@ class GatewayRouter {
|
|
|
815
816
|
delete require.cache[webUiPath];
|
|
816
817
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
817
818
|
const { generateDashboardHtml: fresh } = require('../ui/web-ui');
|
|
818
|
-
res.send(fresh());
|
|
819
|
+
res.send(fresh(this.gatewayConfig?.gateway?.timezone));
|
|
819
820
|
}
|
|
820
821
|
else {
|
|
821
|
-
res.send((0, web_ui_1.generateDashboardHtml)());
|
|
822
|
+
res.send((0, web_ui_1.generateDashboardHtml)(this.gatewayConfig?.gateway?.timezone));
|
|
822
823
|
}
|
|
823
824
|
});
|
|
824
825
|
// Reports expose cross-agent usage/tool inventories: the same admin gate as status.
|
|
@@ -857,7 +858,7 @@ class GatewayRouter {
|
|
|
857
858
|
}
|
|
858
859
|
try {
|
|
859
860
|
const source = runner.getDashboardSource?.();
|
|
860
|
-
let report = source ? await this.dashboardReader.read('report', source.filename, { workspace: source.workspace, sessionId, offset, since: (0, dashboard_range_1.dashboardSince)(req.query.scope ?? (reportPath === '/token-report' ? 'all' : '24h')), historyFilename: source.historyFilename }) : await runner.getTokenReport(sessionId);
|
|
861
|
+
let report = source ? await this.dashboardReader.read('report', source.filename, { workspace: source.workspace, sessionId, offset, since: (0, dashboard_range_1.dashboardSince)(req.query.scope ?? (reportPath === '/token-report' ? 'all' : '24h'), Date.now(), this.gatewayConfig?.gateway?.timezone), historyFilename: source.historyFilename }) : await runner.getTokenReport(sessionId);
|
|
861
862
|
if (!report) {
|
|
862
863
|
res.status(404).json({ error: 'No recorded session token report' });
|
|
863
864
|
return;
|
|
@@ -869,7 +870,7 @@ class GatewayRouter {
|
|
|
869
870
|
if (reportPath === '/token-report')
|
|
870
871
|
res.json(report);
|
|
871
872
|
else
|
|
872
|
-
res.type('html').send((0, token_report_1.generateTokenReportHtml)(agentId, { ...report, scope: (0, dashboard_range_1.dashboardRange)(req.query.scope), sessionStatus: runner.agentSessionLiveStatus?.(sessionId) ?? 'stopped' }));
|
|
873
|
+
res.type('html').send((0, token_report_1.generateTokenReportHtml)(agentId, { ...report, timezone: this.gatewayConfig?.gateway?.timezone, scope: (0, dashboard_range_1.dashboardRange)(req.query.scope), sessionStatus: runner.agentSessionLiveStatus?.(sessionId) ?? 'stopped' }));
|
|
873
874
|
}
|
|
874
875
|
catch {
|
|
875
876
|
res.status(500).json({ error: 'Unable to load session token report' });
|
|
@@ -892,7 +893,7 @@ class GatewayRouter {
|
|
|
892
893
|
return;
|
|
893
894
|
}
|
|
894
895
|
try {
|
|
895
|
-
const detail = await this.dashboardReader.read('session', source.filename, { sessionId, offset, since: (0, dashboard_range_1.dashboardSince)(req.query.scope), historyFilename: source.historyFilename });
|
|
896
|
+
const detail = await this.dashboardReader.read('session', source.filename, { sessionId, offset, since: (0, dashboard_range_1.dashboardSince)(req.query.scope, Date.now(), this.gatewayConfig?.gateway?.timezone), historyFilename: source.historyFilename });
|
|
896
897
|
if (!detail) {
|
|
897
898
|
res.status(404).json({ error: 'Session not found' });
|
|
898
899
|
return;
|
|
@@ -923,7 +924,7 @@ class GatewayRouter {
|
|
|
923
924
|
return;
|
|
924
925
|
}
|
|
925
926
|
try {
|
|
926
|
-
const task = await this.dashboardReader.read('task', source.filename, { sessionId, taskId, offset, since: (0, dashboard_range_1.dashboardSince)(req.query.scope) });
|
|
927
|
+
const task = await this.dashboardReader.read('task', source.filename, { sessionId, taskId, offset, since: (0, dashboard_range_1.dashboardSince)(req.query.scope, Date.now(), this.gatewayConfig?.gateway?.timezone) });
|
|
927
928
|
if (!task) {
|
|
928
929
|
res.status(404).json({ error: 'Task not found in this session' });
|
|
929
930
|
return;
|
|
@@ -1161,6 +1162,66 @@ class GatewayRouter {
|
|
|
1161
1162
|
res.status(500).json({ error: 'Failed to list knowledge sources' });
|
|
1162
1163
|
}
|
|
1163
1164
|
});
|
|
1165
|
+
let memorySnapshot;
|
|
1166
|
+
let memorySnapshotUntil = 0;
|
|
1167
|
+
this.app.get('/dashboard/memory-activity', async (req, res) => {
|
|
1168
|
+
if (!this.requireDashOrApiKey(req, res))
|
|
1169
|
+
return;
|
|
1170
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
1171
|
+
const { agentId, kind, status, id, scope, completedOnly } = req.query, page = Number(req.query.page ?? 0);
|
|
1172
|
+
if (!Number.isSafeInteger(page) || page < 0 || page > 1000000 ||
|
|
1173
|
+
[agentId, kind, status, id, scope].some(v => v !== undefined && (typeof v !== 'string' || v.length > 256)) ||
|
|
1174
|
+
(completedOnly !== undefined && completedOnly !== 'true' && completedOnly !== 'false') ||
|
|
1175
|
+
(kind !== undefined && !['all', 'memory_dream', 'session_compaction'].includes(String(kind))) ||
|
|
1176
|
+
(status !== undefined && !String(status).split(',').every(s => ['all', 'none', 'pending', 'running', 'completed', 'failed', 'partial_failure', 'interrupted', 'skipped'].includes(s))) ||
|
|
1177
|
+
(scope !== undefined && !['24h', '7d', '30d', '90d', 'all'].includes(String(scope)))) {
|
|
1178
|
+
res.status(400).json({ error: 'Invalid activity filters' });
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
if (agentId && !this.agents.has(String(agentId))) {
|
|
1182
|
+
res.status(404).json({ error: 'Unknown agent' });
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
try {
|
|
1186
|
+
if (!memorySnapshot || Date.now() >= memorySnapshotUntil) {
|
|
1187
|
+
memorySnapshotUntil = Infinity;
|
|
1188
|
+
const snapshot = (0, memory_activity_1.readMemoryActivity)(this.agents, this.agentsRoot(), (filename, agentId) => this.dashboardReader.read('compaction', filename, { agentId })).then(data => { if (memorySnapshot === snapshot)
|
|
1189
|
+
memorySnapshotUntil = Date.now() + 5000; return data; }, error => { if (memorySnapshot === snapshot)
|
|
1190
|
+
memorySnapshot = undefined; throw error; });
|
|
1191
|
+
memorySnapshot = snapshot;
|
|
1192
|
+
}
|
|
1193
|
+
const data = await memorySnapshot;
|
|
1194
|
+
if (id) {
|
|
1195
|
+
let run = data.runs.find(r => r.id === id && r.agent === agentId);
|
|
1196
|
+
if (!run) {
|
|
1197
|
+
res.status(404).json({ error: 'Activity not found' });
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const source = this.agents.get(String(agentId))?.getDashboardSource?.();
|
|
1201
|
+
if (run.kind === 'session_compaction' && source)
|
|
1202
|
+
run = await this.dashboardReader.read('compaction', source.filename, { agentId, runId: id });
|
|
1203
|
+
if (!run) {
|
|
1204
|
+
res.status(404).json({ error: 'Activity not found' });
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
if (completedOnly === 'true' && run.kind === 'session_compaction') {
|
|
1208
|
+
run = { ...run, items: (run.items ?? []).filter((item) => item.status === 'completed'), itemCount: run.completedSessions };
|
|
1209
|
+
}
|
|
1210
|
+
res.json({ run });
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const timezone = this.gatewayConfig?.gateway?.timezone || 'UTC';
|
|
1214
|
+
const since = (0, dashboard_range_1.dashboardSince)(scope, Date.now(), timezone);
|
|
1215
|
+
const runs = data.runs.filter(r => (completedOnly !== 'true' || r.kind !== 'session_compaction' || r.completedSessions > 0 || (r.items ?? []).some((i) => i.status === 'completed')) && (!agentId || r.agent === agentId) && (!kind || kind === 'all' || r.kind === kind) && (!status || status === 'all' || String(status).split(',').includes(r.status)) && r.startedAt >= since);
|
|
1216
|
+
res.json({ timezone, since, runs: runs.slice(page * 25, page * 25 + 25).map(memory_activity_1.activitySummary), total: runs.length, page, pageSize: 25,
|
|
1217
|
+
agents: data.agents, schedules: data.schedules.filter(s => !agentId || s.agent === agentId), unavailable: data.unavailable,
|
|
1218
|
+
counts: { compactedSessions: runs.reduce((n, r) => n + (r.completedSessions ?? r.items?.filter((i) => i.status === 'completed').length ?? 0), 0), measuredReduction: runs.reduce((n, r) => n + ((0, memory_activity_1.activitySummary)(r).measuredReduction ?? 0), 0), measuredSessions: runs.reduce((n, r) => n + ((0, memory_activity_1.activitySummary)(r).measuredSessions ?? 0), 0), runs: runs.length, pendingProposals: runs.reduce((n, r) => n + (r.pendingProposals ?? 0), 0), failed: runs.filter(r => ['failed', 'partial_failure', 'interrupted'].includes(r.status)).length },
|
|
1219
|
+
historyLimit: 100 });
|
|
1220
|
+
}
|
|
1221
|
+
catch {
|
|
1222
|
+
res.status(503).json({ error: 'Memory activity temporarily unavailable' });
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1164
1225
|
// Nightly dreaming report — parses every agent's `.dreaming/` audit trail
|
|
1165
1226
|
// (DREAMS.md + promotions.jsonl) into newest-first runs for the dashboard's
|
|
1166
1227
|
// "Nightly dreaming" tab. Auth: dashboard session cookie OR API key. Payload is
|
|
@@ -1175,7 +1236,7 @@ class GatewayRouter {
|
|
|
1175
1236
|
const runs = [];
|
|
1176
1237
|
const agents = [];
|
|
1177
1238
|
for (const id of this.agents.keys()) {
|
|
1178
|
-
const dir = path.join(root, id, 'workspace', audit_1.DREAMING_DIR);
|
|
1239
|
+
const dir = path.join(this.agents.get(id)?.workspacePath ?? path.join(root, id, 'workspace'), audit_1.DREAMING_DIR);
|
|
1179
1240
|
let dreams;
|
|
1180
1241
|
try {
|
|
1181
1242
|
dreams = fs.readFileSync(path.join(dir, 'DREAMS.md'), 'utf8');
|
|
@@ -1231,6 +1292,7 @@ class GatewayRouter {
|
|
|
1231
1292
|
this.app.post('/knowledge/dreams/apply', (req, res) => {
|
|
1232
1293
|
if (!this.requireDashOrApiKey(req, res))
|
|
1233
1294
|
return;
|
|
1295
|
+
memorySnapshot = undefined;
|
|
1234
1296
|
try {
|
|
1235
1297
|
const body = (req.body ?? {});
|
|
1236
1298
|
const agentId = typeof body.agentId === 'string' ? body.agentId : '';
|
|
@@ -1254,7 +1316,7 @@ class GatewayRouter {
|
|
|
1254
1316
|
}
|
|
1255
1317
|
indexes = body.indexes;
|
|
1256
1318
|
}
|
|
1257
|
-
const workspaceDir = path.join(this.agentsRoot(), agentId, 'workspace');
|
|
1319
|
+
const workspaceDir = this.agents.get(agentId)?.workspacePath ?? path.join(this.agentsRoot(), agentId, 'workspace');
|
|
1258
1320
|
const budget = (0, workspace_loader_1.resolveMemoryBudget)({
|
|
1259
1321
|
...this.gatewayConfig?.gateway?.memory,
|
|
1260
1322
|
...this.configs.get(agentId)?.memory,
|
|
@@ -1337,7 +1399,7 @@ class GatewayRouter {
|
|
|
1337
1399
|
const source = runner.getDashboardSource?.();
|
|
1338
1400
|
const legacySessions = runner.getSessionsSummary();
|
|
1339
1401
|
const liveSessionIds = new Set(runner.liveSessionIds?.() ?? []);
|
|
1340
|
-
const orchestration = source ? (source.enabled ? await this.dashboardReader.read('summary', source.filename, { ...source, offset, since: (0, dashboard_range_1.dashboardSince)(scope), legacyIds: legacySessions.map(s => s.sessionId) }) : undefined) : runner.getOrchestrationSummary?.();
|
|
1402
|
+
const orchestration = source ? (source.enabled ? await this.dashboardReader.read('summary', source.filename, { ...source, timezone: this.gatewayConfig?.gateway?.timezone, offset, since: (0, dashboard_range_1.dashboardSince)(scope, Date.now(), this.gatewayConfig?.gateway?.timezone), legacyIds: legacySessions.map(s => s.sessionId) }) : undefined) : runner.getOrchestrationSummary?.();
|
|
1341
1403
|
const managedSessions = (orchestration?.sessions ?? []).map((s) => ({
|
|
1342
1404
|
...s,
|
|
1343
1405
|
// Live liveness from the runner's in-memory map: the DB-derived status
|
|
@@ -1347,7 +1409,7 @@ class GatewayRouter {
|
|
|
1347
1409
|
...(runner.isSessionCompacting?.(s.sessionId) ? { status: 'compacting', isRunning: true } : {}),
|
|
1348
1410
|
}));
|
|
1349
1411
|
const managedIds = new Set([...managedSessions.map((s) => s.sessionId), ...(orchestration?.managedLegacyIds ?? [])]);
|
|
1350
|
-
const sessions = [...legacySessions.filter(s => !managedIds.has(s.sessionId) && (!(0, dashboard_range_1.dashboardSince)(scope) || Number(s.updatedAt || s.spawnedAt || 0) >= (0, dashboard_range_1.dashboardSince)(scope))), ...managedSessions].map((s) => ({
|
|
1412
|
+
const sessions = [...legacySessions.filter(s => !managedIds.has(s.sessionId) && (!(0, dashboard_range_1.dashboardSince)(scope, Date.now(), this.gatewayConfig?.gateway?.timezone) || Number(s.updatedAt || s.spawnedAt || 0) >= (0, dashboard_range_1.dashboardSince)(scope, Date.now(), this.gatewayConfig?.gateway?.timezone))), ...managedSessions].map((s) => ({
|
|
1351
1413
|
...s,
|
|
1352
1414
|
hasPtyStream: pty_stream_registry_1.ptyStreamRegistry.hasSockets(s.sessionId),
|
|
1353
1415
|
}));
|
|
@@ -1383,6 +1445,34 @@ class GatewayRouter {
|
|
|
1383
1445
|
watchers: (0, factory_1.getWatcherHealth)(),
|
|
1384
1446
|
};
|
|
1385
1447
|
};
|
|
1448
|
+
this.app.get('/dashboard/charts', async (req, res) => {
|
|
1449
|
+
if (!this.requireDashOrApiKey(req, res))
|
|
1450
|
+
return;
|
|
1451
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
1452
|
+
const scope = req.query.scope ?? '24h';
|
|
1453
|
+
if (typeof scope !== 'string' || !['24h', '7d', '30d', '90d'].includes(scope)) {
|
|
1454
|
+
res.status(400).json({ error: 'Invalid chart range' });
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
const timezone = this.gatewayConfig?.gateway?.timezone || 'UTC';
|
|
1458
|
+
// Stable snapshot timestamp coalesces all four cards and concurrent browsers.
|
|
1459
|
+
const now = Math.floor(Date.now() / 10000) * 10000;
|
|
1460
|
+
try {
|
|
1461
|
+
const agents = [];
|
|
1462
|
+
for (const [id, runner] of this.agents) {
|
|
1463
|
+
const source = runner.getDashboardSource?.();
|
|
1464
|
+
if (!source?.enabled)
|
|
1465
|
+
continue;
|
|
1466
|
+
const usage = await this.dashboardReader.read('charts', source.filename, { scope, timezone, now });
|
|
1467
|
+
if (usage)
|
|
1468
|
+
agents.push({ id, ...usage });
|
|
1469
|
+
}
|
|
1470
|
+
res.json({ scope, timezone, asOf: now, since: (0, dashboard_range_1.dashboardSince)(scope, now, timezone), agents });
|
|
1471
|
+
}
|
|
1472
|
+
catch {
|
|
1473
|
+
res.status(503).json({ error: 'Chart data temporarily unavailable' });
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1386
1476
|
this.app.get('/status', async (req, res) => {
|
|
1387
1477
|
if (!this.requireDashOrApiKey(req, res))
|
|
1388
1478
|
return;
|