pi-mega-compact 0.11.3 → 0.11.5
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/extensions/dashboard-server/api-contracts/endpoints.js +19 -0
- package/dist/extensions/dashboard-server/api-contracts/memory.js +8 -0
- package/dist/extensions/dashboard-server/api-contracts/provider-cache.js +1 -0
- package/dist/extensions/dashboard-server/api-contracts/setup.js +10 -0
- package/dist/extensions/dashboard-server/index-reader.js +6 -2
- package/dist/extensions/dashboard-server/routes-cache.js +115 -55
- package/dist/extensions/dashboard-server/routes-memory.js +51 -0
- package/dist/extensions/dashboard-server/routes-repo.js +2 -2
- package/dist/extensions/dashboard-server/routes-setup.js +162 -0
- package/dist/extensions/dashboard-server/routes.js +2 -0
- package/dist/extensions/dashboard-server/server.js +7 -1
- package/dist/extensions/mega-commands.js +189 -1
- package/dist/extensions/mega-config.js +3 -0
- package/dist/extensions/mega-events/agent-handlers.js +41 -6
- package/dist/extensions/mega-events/compact-handlers.js +1 -0
- package/dist/extensions/mega-events/context-handler.js +37 -92
- package/dist/extensions/mega-events/context-hwm.js +51 -0
- package/dist/extensions/mega-events/error-classifier.js +118 -128
- package/dist/extensions/mega-events/mirror-append.js +107 -0
- package/dist/extensions/mega-events/outage-advisor.js +59 -0
- package/dist/extensions/mega-events/perf-handler.js +51 -1
- package/dist/extensions/mega-events/recall-tail.js +59 -0
- package/dist/extensions/mega-events/session-handlers.js +15 -8
- package/dist/extensions/mega-runtime/reset-runtime.js +6 -0
- package/dist/extensions/mega-runtime/runtime.js +7 -0
- package/dist/src/embedder.js +41 -2
- package/dist/src/memoryStats.js +75 -0
- package/dist/src/prefix-break.js +43 -0
- package/dist/src/pricing.js +1 -1
- package/dist/src/store/sqlite/perf-samples.js +144 -16
- package/dist/src/store/turns/memory-store.js +8 -0
- package/dist/src/store/turns/sqlite-store.js +14 -3
- package/dist/src/store/turns/types.js +18 -1
- package/dist/src/store/vectorIndex.js +26 -5
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js → AchievementTiles-BoL7qBOJ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js.map → AchievementTiles-BoL7qBOJ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/AchievementsTab-BFDE3HYc.js +2 -0
- package/extensions/dashboard-client/dist/assets/{AchievementsTab-DjxfYrDc.js.map → AchievementsTab-BFDE3HYc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js +2 -0
- package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js → ConfigTab-DDFE-ckA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js.map → ConfigTab-DDFE-ckA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js → EventsTab-B6UxZ7PM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js.map → EventsTab-B6UxZ7PM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js → GameTab-DehUX-KE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js.map → GameTab-DehUX-KE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js → MaintenanceTab-0GWRt4wn.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js.map → MaintenanceTab-0GWRt4wn.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js → MetricsTab-C3rwMVsN.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js.map → MetricsTab-C3rwMVsN.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-39O9_x5j.js +2 -0
- package/extensions/dashboard-client/dist/assets/{OverviewTab-D4kGvsiQ.js.map → OverviewTab-39O9_x5j.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js +2 -0
- package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js → SessionsTab-DXDTCi3r.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js.map → SessionsTab-DXDTCi3r.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js +2 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js +2 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js → TopicsTab-BAw972BV.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js.map → TopicsTab-BAw972BV.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js → TurnsTab-Cf5mGIdl.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js.map → TurnsTab-Cf5mGIdl.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js +2 -0
- package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{index-BX0bcgLu.js → index-4gQ7auad.js} +10 -10
- package/extensions/dashboard-client/dist/assets/index-4gQ7auad.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js +2 -0
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js → useSSE-DNgMuyP6.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js.map → useSSE-DNgMuyP6.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/App.tsx +4 -0
- package/extensions/dashboard-client/src/api/client.ts +14 -0
- package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +21 -12
- package/extensions/dashboard-client/src/components/ProviderCacheCard.tsx +56 -0
- package/extensions/dashboard-client/src/components/SavingsByModelTable.tsx +38 -57
- package/extensions/dashboard-client/src/tabs/CacheTab.tsx +1 -0
- package/extensions/dashboard-client/src/tabs/SetupTab.tsx +355 -0
- package/extensions/dashboard-client/tsconfig.json +3 -2
- package/extensions/dashboard-client/vite.config.ts +2 -0
- package/extensions/dashboard-server/api-contracts/endpoints.ts +36 -3
- package/extensions/dashboard-server/api-contracts/index.ts +7 -0
- package/extensions/dashboard-server/api-contracts/memory.ts +27 -0
- package/extensions/dashboard-server/api-contracts/multi-repo.ts +231 -231
- package/extensions/dashboard-server/api-contracts/provider-cache.ts +37 -0
- package/extensions/dashboard-server/api-contracts/setup.ts +58 -0
- package/extensions/dashboard-server/index-reader.ts +138 -121
- package/extensions/dashboard-server/routes-cache.ts +161 -85
- package/extensions/dashboard-server/routes-memory.ts +63 -0
- package/extensions/dashboard-server/routes-repo.ts +36 -36
- package/extensions/dashboard-server/routes-setup.ts +181 -0
- package/extensions/dashboard-server/routes.ts +2 -0
- package/extensions/dashboard-server/server.ts +6 -0
- package/extensions/mega-commands.ts +211 -1
- package/extensions/mega-config.ts +18 -0
- package/extensions/mega-events/agent-handlers.ts +44 -5
- package/extensions/mega-events/compact-handlers.ts +1 -0
- package/extensions/mega-events/context-handler.ts +45 -110
- package/extensions/mega-events/context-hwm.ts +85 -0
- package/extensions/mega-events/error-classifier.ts +156 -124
- package/extensions/mega-events/mirror-append.ts +155 -0
- package/extensions/mega-events/outage-advisor.ts +79 -0
- package/extensions/mega-events/perf-handler.ts +79 -5
- package/extensions/mega-events/recall-tail.ts +88 -0
- package/extensions/mega-events/session-handlers.ts +14 -7
- package/extensions/mega-runtime/helpers.ts +14 -0
- package/extensions/mega-runtime/reset-runtime.ts +6 -0
- package/extensions/mega-runtime/runtime.ts +7 -0
- package/package.json +5 -2
- package/src/embedder.ts +42 -2
- package/src/memoryStats.ts +107 -0
- package/src/prefix-break.ts +83 -0
- package/src/pricing.ts +2 -2
- package/src/store/sqlite/perf-samples.ts +215 -22
- package/src/store/turns/memory-store.ts +10 -1
- package/src/store/turns/sqlite-store.ts +27 -15
- package/src/store/turns/types.ts +21 -0
- package/src/store/vectorIndex.ts +33 -4
- package/dist/extensions/conflict-scan.test.js +0 -115
- package/dist/extensions/dashboard-server/api-contracts.test.js +0 -884
- package/dist/extensions/dashboard-server/html.test.js +0 -52
- package/dist/extensions/dashboard-server/perf-server.test.js +0 -80
- package/dist/extensions/dashboard-server/routes-cache.test.js +0 -248
- package/dist/extensions/dashboard-server/server.test.js +0 -120
- package/dist/extensions/dashboard-server-s32.test.js +0 -181
- package/dist/extensions/dashboard-server.test.js +0 -339
- package/dist/extensions/mega-cache-replay.test.js +0 -400
- package/dist/extensions/mega-compact-s38.test.js +0 -820
- package/dist/extensions/mega-compact.test.js +0 -1112
- package/dist/extensions/mega-events.test.js +0 -47
- package/dist/extensions/mega-game-cmds.test.js +0 -163
- package/dist/extensions/mega-runtime/snapshot.test.js +0 -127
- package/dist/extensions/mega-runtime/state.test.js +0 -266
- package/dist/extensions/mega-runtime/widget.test.js +0 -343
- package/dist/extensions/mega-shutdown-widget.test.js +0 -121
- package/dist/extensions/mega-teamrun.test.js +0 -156
- package/dist/extensions/mega-trim.test.js +0 -58
- package/dist/extensions/mega-turn-store.test.js +0 -68
- package/dist/src/boundary.test.js +0 -170
- package/dist/src/compact.test.js +0 -78
- package/dist/src/config/themes.test.js +0 -94
- package/dist/src/dedup/dedup.test.js +0 -41
- package/dist/src/dedup/l1.test.js +0 -50
- package/dist/src/dedup/raptor/buildHistory.test.js +0 -292
- package/dist/src/dedup/raptor/multilevel-serve.test.js +0 -229
- package/dist/src/dedup/raptor/multilevel.test.js +0 -238
- package/dist/src/dedup/raptor/promote.test.js +0 -69
- package/dist/src/dedup/raptor/raptor.test.js +0 -248
- package/dist/src/dedup/raptor/retrieval.test.js +0 -95
- package/dist/src/dedup/raptor/serve-gate.test.js +0 -298
- package/dist/src/dedup/sprint12.test.js +0 -219
- package/dist/src/dedup-engine.test.js +0 -472
- package/dist/src/driftDetection.test.js +0 -87
- package/dist/src/e2e.test.js +0 -698
- package/dist/src/engine.test.js +0 -111
- package/dist/src/extractive.test.js +0 -147
- package/dist/src/fork.test.js +0 -81
- package/dist/src/game/scoring.test.js +0 -98
- package/dist/src/httpEmbedder.test.js +0 -277
- package/dist/src/importance.test.js +0 -372
- package/dist/src/intent.test.js +0 -78
- package/dist/src/log.test.js +0 -42
- package/dist/src/mechanical-fix.test.js +0 -65
- package/dist/src/memory.test.js +0 -70
- package/dist/src/memoryConsolidate.test.js +0 -38
- package/dist/src/memoryOps.test.js +0 -129
- package/dist/src/memoryRecall.test.js +0 -171
- package/dist/src/memoryRoundtrip.test.js +0 -137
- package/dist/src/metrics/turns.test.js +0 -152
- package/dist/src/mirror/mirror.test.js +0 -185
- package/dist/src/raptor-inject-summaries.test.js +0 -162
- package/dist/src/ratio.bench.test.js +0 -897
- package/dist/src/recall.integration.test.js +0 -77
- package/dist/src/recall.test.js +0 -379
- package/dist/src/sprint14.test.js +0 -219
- package/dist/src/sprint4x-rag-verification.test.js +0 -93
- package/dist/src/store/compression.test.js +0 -139
- package/dist/src/store/memoryIndex.test.js +0 -51
- package/dist/src/store/migrate.test.js +0 -139
- package/dist/src/store/pgOpenGuard.test.js +0 -74
- package/dist/src/store/phase01.test.js +0 -81
- package/dist/src/store/phase04.test.js +0 -54
- package/dist/src/store/sprint10.test.js +0 -186
- package/dist/src/store/sqlite/game-achievements.test.js +0 -67
- package/dist/src/store/sqlite/game-scores.test.js +0 -106
- package/dist/src/store/sqlite/game-state.test.js +0 -76
- package/dist/src/store/sqlite/global-index.test.js +0 -136
- package/dist/src/store/sqlite/mechanical-fix.test.js +0 -146
- package/dist/src/store/sqlite/perf-samples.test.js +0 -146
- package/dist/src/store/sqlite/raptor.test.js +0 -106
- package/dist/src/store/sqlite/turns.test.js +0 -183
- package/dist/src/store/sqlite.cachehit.test.js +0 -55
- package/dist/src/store/sqlite.dbmaint.test.js +0 -158
- package/dist/src/store/sqlite.dbmirror.test.js +0 -184
- package/dist/src/store/turns/contract-compliance.test.js +0 -428
- package/dist/src/store/turns/memory-store.test.js +0 -9
- package/dist/src/store/turns/migrations.test.js +0 -138
- package/dist/src/store/turns/sqlite-store.test.js +0 -144
- package/dist/src/store/vectorIndex.test.js +0 -123
- package/dist/src/store.test.js +0 -161
- package/dist/src/supersede.test.js +0 -36
- package/dist/src/topics/cluster.test.js +0 -150
- package/dist/src/topics/store.test.js +0 -117
- package/dist/src/types.test.js +0 -9
- package/dist/src/vector-search-cache.test.js +0 -157
- package/dist/src/vectorStore.test.js +0 -479
- package/dist/src/wiki.test.js +0 -171
- package/extensions/conflict-scan.test.ts +0 -129
- package/extensions/dashboard-client/dist/assets/AchievementsTab-DjxfYrDc.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-D4kGvsiQ.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js +0 -2
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js.map +0 -1
- package/extensions/dashboard-server/api-contracts.test.ts +0 -1065
- package/extensions/dashboard-server/html.test.ts +0 -62
- package/extensions/dashboard-server/perf-server.test.ts +0 -101
- package/extensions/dashboard-server/routes-cache.test.ts +0 -302
- package/extensions/dashboard-server/server.test.ts +0 -131
- package/extensions/dashboard-server-s32.test.ts +0 -195
- package/extensions/dashboard-server.test.ts +0 -382
- package/extensions/mega-cache-replay.test.ts +0 -526
- package/extensions/mega-compact-s38.test.ts +0 -872
- package/extensions/mega-compact.test.ts +0 -1509
- package/extensions/mega-events.test.ts +0 -55
- package/extensions/mega-game-cmds.test.ts +0 -197
- package/extensions/mega-runtime/snapshot.test.ts +0 -139
- package/extensions/mega-runtime/state.test.ts +0 -262
- package/extensions/mega-runtime/widget.test.ts +0 -468
- package/extensions/mega-shutdown-widget.test.ts +0 -141
- package/extensions/mega-teamrun.test.ts +0 -176
- package/extensions/mega-trim.test.ts +0 -64
- package/extensions/mega-turn-store.test.ts +0 -108
- package/src/boundary.test.ts +0 -187
- package/src/compact.test.ts +0 -99
- package/src/config/themes.test.ts +0 -116
- package/src/dedup/dedup.test.ts +0 -46
- package/src/dedup/l1.test.ts +0 -57
- package/src/dedup/raptor/buildHistory.test.ts +0 -353
- package/src/dedup/raptor/multilevel-serve.test.ts +0 -273
- package/src/dedup/raptor/multilevel.test.ts +0 -325
- package/src/dedup/raptor/promote.test.ts +0 -82
- package/src/dedup/raptor/raptor.test.ts +0 -297
- package/src/dedup/raptor/retrieval.test.ts +0 -118
- package/src/dedup/raptor/serve-gate.test.ts +0 -348
- package/src/dedup/sprint12.test.ts +0 -242
- package/src/dedup-engine.test.ts +0 -670
- package/src/driftDetection.test.ts +0 -100
- package/src/e2e.test.ts +0 -843
- package/src/engine.test.ts +0 -123
- package/src/extractive.test.ts +0 -174
- package/src/fork.test.ts +0 -94
- package/src/game/scoring.test.ts +0 -103
- package/src/httpEmbedder.test.ts +0 -286
- package/src/importance.test.ts +0 -538
- package/src/intent.test.ts +0 -87
- package/src/log.test.ts +0 -47
- package/src/mechanical-fix.test.ts +0 -70
- package/src/memory.test.ts +0 -92
- package/src/memoryConsolidate.test.ts +0 -47
- package/src/memoryOps.test.ts +0 -148
- package/src/memoryRecall.test.ts +0 -194
- package/src/memoryRoundtrip.test.ts +0 -155
- package/src/metrics/turns.test.ts +0 -165
- package/src/mirror/mirror.test.ts +0 -240
- package/src/raptor-inject-summaries.test.ts +0 -228
- package/src/ratio.bench.test.ts +0 -1316
- package/src/recall.integration.test.ts +0 -96
- package/src/recall.test.ts +0 -467
- package/src/sprint14.test.ts +0 -245
- package/src/sprint4x-rag-verification.test.ts +0 -119
- package/src/store/compression.test.ts +0 -168
- package/src/store/memoryIndex.test.ts +0 -61
- package/src/store/migrate.test.ts +0 -158
- package/src/store/pgOpenGuard.test.ts +0 -89
- package/src/store/phase01.test.ts +0 -88
- package/src/store/phase04.test.ts +0 -58
- package/src/store/sprint10.test.ts +0 -214
- package/src/store/sqlite/game-achievements.test.ts +0 -80
- package/src/store/sqlite/game-scores.test.ts +0 -132
- package/src/store/sqlite/game-state.test.ts +0 -89
- package/src/store/sqlite/global-index.test.ts +0 -222
- package/src/store/sqlite/mechanical-fix.test.ts +0 -162
- package/src/store/sqlite/perf-samples.test.ts +0 -169
- package/src/store/sqlite/raptor.test.ts +0 -139
- package/src/store/sqlite/turns.test.ts +0 -218
- package/src/store/sqlite.cachehit.test.ts +0 -68
- package/src/store/sqlite.dbmaint.test.ts +0 -193
- package/src/store/sqlite.dbmirror.test.ts +0 -229
- package/src/store/turns/contract-compliance.test.ts +0 -562
- package/src/store/turns/memory-store.test.ts +0 -15
- package/src/store/turns/migrations.test.ts +0 -161
- package/src/store/turns/sqlite-store.test.ts +0 -161
- package/src/store/vectorIndex.test.ts +0 -140
- package/src/store.test.ts +0 -191
- package/src/supersede.test.ts +0 -42
- package/src/topics/cluster.test.ts +0 -176
- package/src/topics/store.test.ts +0 -132
- package/src/types.test.ts +0 -10
- package/src/vector-search-cache.test.ts +0 -190
- package/src/vectorStore.test.ts +0 -533
- package/src/wiki.test.ts +0 -217
|
@@ -196,4 +196,23 @@ export const ENDPOINTS = {
|
|
|
196
196
|
path: "/api/provider-cache",
|
|
197
197
|
description: "Lifetime provider prompt cache hit-rate aggregates + dollar savings estimate.",
|
|
198
198
|
},
|
|
199
|
+
// ─── Memory Effectiveness (S53B) ───────────────────────────────────────
|
|
200
|
+
/** GET /api/memory-status — Memory store aggregate statistics. */
|
|
201
|
+
memoryStatus: {
|
|
202
|
+
method: "GET",
|
|
203
|
+
path: "/api/memory-status",
|
|
204
|
+
description: "Memory store statistics: total count, 30-day window, top-N stable memories, avg recall score.",
|
|
205
|
+
},
|
|
206
|
+
/** GET /api/setup-status — Current embedder configuration. */
|
|
207
|
+
setupStatus: {
|
|
208
|
+
method: "GET",
|
|
209
|
+
path: "/api/setup-status",
|
|
210
|
+
description: "Current embedder configuration (which embedder is active, embedding URL, cache, MiniLM flag).",
|
|
211
|
+
},
|
|
212
|
+
/** GET /api/setup-detect — Detect available local embedder backends. */
|
|
213
|
+
setupDetect: {
|
|
214
|
+
method: "GET",
|
|
215
|
+
path: "/api/setup-detect",
|
|
216
|
+
description: "Best-effort detection of local embedder backends (ollama, llama.cpp, ONNX) available on the machine.",
|
|
217
|
+
},
|
|
199
218
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api-contracts/memory.ts — Memory effectiveness stats contract (S53B).
|
|
3
|
+
*
|
|
4
|
+
* Response shape for GET /api/memory-status: aggregate memory-store statistics
|
|
5
|
+
* including total count, 30-day window, top-N stable memories by recall, and
|
|
6
|
+
* average recall score.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api-contracts/setup.ts — Setup wizard API response types.
|
|
3
|
+
*
|
|
4
|
+
* Types for the /api/setup-status and /api/setup-detect endpoints used
|
|
5
|
+
* by the /megasetup command and dashboard Setup tab.
|
|
6
|
+
*
|
|
7
|
+
* PREVENT-PI-004: type definitions only, no network code.
|
|
8
|
+
* PREVENT-011: no `any` type — all types are explicit.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -123,7 +123,9 @@ export function readIndex() {
|
|
|
123
123
|
// paths that should never have been real repos, and collapse duplicate
|
|
124
124
|
// display names to the most-recently-seen row (rows are last_seen DESC, so
|
|
125
125
|
// the first occurrence wins). Keeps the All-repos list readable.
|
|
126
|
-
const isTransient = (p) => /^\/tmp\//.test(p) ||
|
|
126
|
+
const isTransient = (p) => /^\/tmp\//.test(p) ||
|
|
127
|
+
/^\/private\/tmp\//.test(p) ||
|
|
128
|
+
/^\/var\/folders\//.test(p) ||
|
|
127
129
|
/\/mc-(ext|e2e|resume|recall)-/.test(p);
|
|
128
130
|
const seenName = new Set();
|
|
129
131
|
const repos = [];
|
|
@@ -150,6 +152,8 @@ export function readIndex() {
|
|
|
150
152
|
try {
|
|
151
153
|
db?.close();
|
|
152
154
|
}
|
|
153
|
-
catch {
|
|
155
|
+
catch {
|
|
156
|
+
/* ignore */
|
|
157
|
+
}
|
|
154
158
|
}
|
|
155
159
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* GET /api/provider-cache — Lifetime provider prompt cache hit-rate aggregates
|
|
5
5
|
* plus dollar savings estimate (priced from latest model snapshot).
|
|
6
|
+
* Accepts optional ?minutes=N, ?since=<epoch-ms>, ?until=<epoch-ms> (S53A).
|
|
6
7
|
*
|
|
7
8
|
* Guardrails: PREVENT-PI-004 (loopback-only), PREVENT-001 (null-safe JSON parse),
|
|
8
9
|
* PREVENT-002 (parameterized SQL). Loopback-only localhost dashboard endpoint.
|
|
@@ -15,66 +16,125 @@ import { computeCacheSavings } from "../../src/pricing.js";
|
|
|
15
16
|
export function handleProviderCache(req, res, ctx) {
|
|
16
17
|
if (!req.url?.startsWith("/api/provider-cache"))
|
|
17
18
|
return false;
|
|
18
|
-
const { stateDir } = ctx;
|
|
19
|
-
// /api/provider-cache — GET returns lifetime provider prompt cache aggregates
|
|
20
|
-
// from perf_samples (cache_hit_pct rows with meta JSON) plus an optional
|
|
21
|
-
// dollar savings estimate priced from the latest model snapshot. The dashboard
|
|
22
|
-
// server is a detached child with no MegaRuntime ref, so it reads via a
|
|
23
|
-
// require()'d sqlite helper (same pattern as /api/perf). Non-GET → 405.
|
|
24
|
-
// PREVENT-PI-004: loopback.
|
|
25
|
-
const pfReq = createRequire(import.meta.url);
|
|
26
|
-
const { readProviderCacheLifetime, latestModelSnapshot } = pfReq("../../src/store/sqlite.js");
|
|
27
|
-
if (req.method !== "GET") {
|
|
28
|
-
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
29
|
-
res.writeHead(405, { "Content-Type": "application/json" });
|
|
30
|
-
res.end(JSON.stringify({ error: "method_not_allowed" }));
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
19
|
try {
|
|
34
|
-
const
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
20
|
+
const stateDir = ctx.stateDir;
|
|
21
|
+
// PREVENT-PI-004: loopback.
|
|
22
|
+
const pfReq = createRequire(import.meta.url);
|
|
23
|
+
const { readProviderCacheLifetime, readProviderCacheWindow, latestModelSnapshot } = pfReq("../../src/store/sqlite.js");
|
|
24
|
+
if (req.method !== "GET") {
|
|
25
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
26
|
+
res.writeHead(405, { "Content-Type": "application/json" });
|
|
27
|
+
res.end(JSON.stringify({ error: "method_not_allowed" }));
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// Parse query params: ?minutes=N | ?since=&until= (mutually exclusive).
|
|
31
|
+
let windowMinutes = null;
|
|
32
|
+
let sinceTs = 0;
|
|
33
|
+
let untilTs = 0;
|
|
34
|
+
if (req.url) {
|
|
35
|
+
const qIdx = req.url.indexOf("?");
|
|
36
|
+
if (qIdx !== -1) {
|
|
37
|
+
const params = new URLSearchParams(req.url.slice(qIdx));
|
|
38
|
+
const m = params.get("minutes");
|
|
39
|
+
if (m != null) {
|
|
40
|
+
const n = parseInt(m, 10);
|
|
41
|
+
if (Number.isFinite(n) && n > 0 && String(n) === m.trim()) {
|
|
42
|
+
windowMinutes = n;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// S53A: ?since=&until= epoch-ms timestamps.
|
|
46
|
+
const s = params.get("since");
|
|
47
|
+
const u = params.get("until");
|
|
48
|
+
if (s != null) {
|
|
49
|
+
const sn = Number(s);
|
|
50
|
+
if (Number.isFinite(sn) && sn >= 0)
|
|
51
|
+
sinceTs = sn;
|
|
52
|
+
}
|
|
53
|
+
if (u != null) {
|
|
54
|
+
const un = Number(u);
|
|
55
|
+
if (Number.isFinite(un) && un > 0)
|
|
56
|
+
untilTs = un;
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
}
|
|
60
|
+
// S53A: read prefix_break samples in the same window as the aggregates.
|
|
61
|
+
// Import lazily to avoid a circular dependency in the test harness.
|
|
62
|
+
let prefixBreaks = [];
|
|
63
|
+
try {
|
|
64
|
+
// guardrails-allow PREVENT-PI-004: local SQLite read (loopback dashboard)
|
|
65
|
+
const { readPrefixBreaks } = pfReq("../../src/store/sqlite/perf-samples.js");
|
|
66
|
+
// When ?since=&until= is used, pass those directly; otherwise derive
|
|
67
|
+
// from windowMinutes or 0 (no bounds = lifetime).
|
|
68
|
+
const pSince = sinceTs > 0 ? sinceTs : (windowMinutes != null ? Date.now() - windowMinutes * 60_000 : 0);
|
|
69
|
+
const pUntil = untilTs > 0 ? untilTs : (windowMinutes != null ? Date.now() : 0);
|
|
70
|
+
const rows = readPrefixBreaks(stateDir, pSince, pUntil);
|
|
71
|
+
prefixBreaks = rows.map((r) => ({
|
|
72
|
+
id: r.id,
|
|
73
|
+
ts: r.ts,
|
|
74
|
+
cause: r.meta.cause,
|
|
75
|
+
confidence: r.meta.confidence,
|
|
76
|
+
prevHitPct: r.meta.prevHitPct,
|
|
77
|
+
currHitPct: r.meta.currHitPct,
|
|
78
|
+
breakAt: r.meta.breakAt,
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
51
81
|
catch {
|
|
52
|
-
/*
|
|
82
|
+
/* prefix-break read unavailable — response still returns empty array */
|
|
53
83
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
try {
|
|
85
|
+
const lifetime = windowMinutes != null
|
|
86
|
+
? readProviderCacheWindow(stateDir, windowMinutes)
|
|
87
|
+
: readProviderCacheLifetime(stateDir); // guardrails-allow PREVENT-PI-004: local SQLite read (loopback dashboard)
|
|
88
|
+
// D3: compute dollar savings from the latest model snapshot. Null-safe:
|
|
89
|
+
// when no snapshot or zero input rate, savings stays null (UI shows "—").
|
|
90
|
+
let savings = null;
|
|
91
|
+
try {
|
|
92
|
+
const snap = latestModelSnapshot(stateDir); // guardrails-allow PREVENT-PI-004: local SQLite read (loopback dashboard)
|
|
93
|
+
if (snap && snap.inputRate > 0) {
|
|
94
|
+
const s = computeCacheSavings(lifetime.totalCacheRead, lifetime.totalCacheWrite, snap.inputRate);
|
|
95
|
+
savings = {
|
|
96
|
+
cacheReadSaved: s.cacheReadSaved,
|
|
97
|
+
cacheWriteCost: s.cacheWriteCost,
|
|
98
|
+
netSaved: s.netSaved,
|
|
99
|
+
model: snap.modelName ?? snap.modelId ?? "unknown",
|
|
100
|
+
inputRate: snap.inputRate,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
/* pricing unavailable — savings stays null */
|
|
106
|
+
}
|
|
107
|
+
const body = {
|
|
108
|
+
cache: {
|
|
109
|
+
avgHitPct: lifetime.avgHitPct,
|
|
110
|
+
turnCount: lifetime.sampleCount,
|
|
111
|
+
totalCacheRead: lifetime.totalCacheRead,
|
|
112
|
+
totalCacheWrite: lifetime.totalCacheWrite,
|
|
113
|
+
totalInput: lifetime.totalInput,
|
|
114
|
+
firstTurnAt: lifetime.firstSampleAt,
|
|
115
|
+
latestTurnAt: lifetime.latestSampleAt,
|
|
116
|
+
byModel: lifetime.byModel,
|
|
117
|
+
},
|
|
118
|
+
savings,
|
|
119
|
+
updatedAt: new Date().toISOString(),
|
|
120
|
+
windowMinutes,
|
|
121
|
+
prefixBreaks,
|
|
122
|
+
};
|
|
123
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
124
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
125
|
+
res.end(JSON.stringify(body));
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
129
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
130
|
+
res.end(JSON.stringify({
|
|
131
|
+
error: "provider_cache_unavailable",
|
|
132
|
+
detail: String(e),
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
70
136
|
}
|
|
71
|
-
catch
|
|
72
|
-
|
|
73
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
74
|
-
res.end(JSON.stringify({
|
|
75
|
-
error: "provider_cache_unavailable",
|
|
76
|
-
detail: String(e),
|
|
77
|
-
}));
|
|
137
|
+
catch {
|
|
138
|
+
return false;
|
|
78
139
|
}
|
|
79
|
-
return true;
|
|
80
140
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-memory.ts — Memory effectiveness stats route handler (S53B).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/memory-status — Returns memoryStats() aggregated data:
|
|
5
|
+
* totalMemories, memoriesInLast30Days, topStableMemories, avgRecallScore.
|
|
6
|
+
*
|
|
7
|
+
* Guardrails: PREVENT-PI-004 (loopback-only), PREVENT-001 (null-safe JSON),
|
|
8
|
+
* PREVENT-002 (parameterized SQL — memoryStats uses openStore internally).
|
|
9
|
+
* Loopback-only localhost dashboard endpoint.
|
|
10
|
+
*/
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
// PREVENT-PI-004: memoryStats is a pure local module (no network, no side-effects at import time).
|
|
13
|
+
// guardrails-allow PREVENT-PI-004: local TypeScript module import (loopback-only).
|
|
14
|
+
const { memoryStats } = createRequire(import.meta.url)("../../src/memoryStats.js");
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// handleMemoryStatus — "/api/memory-status"
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
export function handleMemoryStatus(req, res, ctx) {
|
|
19
|
+
if (!req.url?.startsWith("/api/memory-status"))
|
|
20
|
+
return false;
|
|
21
|
+
if (req.method !== "GET") {
|
|
22
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
23
|
+
res.writeHead(405, { "Content-Type": "application/json" });
|
|
24
|
+
res.end(JSON.stringify({ error: "method_not_allowed" }));
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
// PREVENT-PI-004: loopback-only — memoryStats reads from local SQLite store.
|
|
28
|
+
memoryStats(ctx.stateDir)
|
|
29
|
+
.then((stats) => {
|
|
30
|
+
const body = {
|
|
31
|
+
totalMemories: stats.totalMemories,
|
|
32
|
+
memoriesInLast30Days: stats.memoriesInLast30Days,
|
|
33
|
+
topStableMemories: stats.topStableMemories.map((m) => ({
|
|
34
|
+
id: m.id,
|
|
35
|
+
text: m.text,
|
|
36
|
+
recallCount: m.recallCount,
|
|
37
|
+
lastRecalledAt: m.lastRecalledAt,
|
|
38
|
+
})),
|
|
39
|
+
avgRecallScore: stats.avgRecallScore,
|
|
40
|
+
};
|
|
41
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
42
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
43
|
+
res.end(JSON.stringify(body));
|
|
44
|
+
})
|
|
45
|
+
.catch(() => {
|
|
46
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
47
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
48
|
+
res.end(JSON.stringify({ error: "memory_stats_unavailable" }));
|
|
49
|
+
});
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
@@ -8,7 +8,7 @@ import { dashboardHtml } from "./html.js";
|
|
|
8
8
|
import { readIndex, getIndexDir } from "./index-reader.js";
|
|
9
9
|
import { ACTIVE_WINDOW_SEC } from "./types.js";
|
|
10
10
|
import { readProviderCacheForRepo } from "../../src/store/sqlite/perf-samples.js";
|
|
11
|
-
import { computeCacheSavings, lookupModelInputRate } from "../../src/pricing.js";
|
|
11
|
+
import { computeCacheSavings, lookupModelInputRate, } from "../../src/pricing.js";
|
|
12
12
|
import { latestModelSnapshot } from "../../src/store/sqlite/model-snapshots.js";
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
// handleIndex — "/" | "/index.html" | "/api/snapshot" | "/api/version"
|
|
@@ -142,7 +142,7 @@ export function handleRepoIndex(req, res, ctx) {
|
|
|
142
142
|
const modelSnap = latestModelSnapshot(r.stateDir);
|
|
143
143
|
const inputRate = modelSnap
|
|
144
144
|
? modelSnap.inputRate
|
|
145
|
-
: lookupModelInputRate(r.modelName ?? "") ?? 0;
|
|
145
|
+
: (lookupModelInputRate(r.modelName ?? "") ?? 0);
|
|
146
146
|
const savings = computeCacheSavings(pc.totalCacheRead, pc.totalCacheWrite, inputRate);
|
|
147
147
|
out.providerCache = {
|
|
148
148
|
avgHitPct: pc.avgHitPct,
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-setup.ts — Setup wizard route handlers.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/setup-status — Returns current embedder configuration from env.
|
|
5
|
+
* GET /api/setup-detect — Runs best-effort detection of local embedder backends.
|
|
6
|
+
*
|
|
7
|
+
* Guardrails: PREVENT-PI-004 (loopback-only), PREVENT-001 (null-safe JSON).
|
|
8
|
+
* The detection commands run local subprocesses via spawnSync, NOT network calls.
|
|
9
|
+
* Each decoration line carries a guardrails-allow annotation.
|
|
10
|
+
*/
|
|
11
|
+
import { spawnSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: local subprocess detection only
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// handleSetupStatus — "/api/setup-status"
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
function detectCurrentEmbedder() {
|
|
17
|
+
const url = process.env["MEGACOMPACT_EMBEDDING_URL"];
|
|
18
|
+
const minilm = process.env["MEGACOMPACT_MINILM"];
|
|
19
|
+
if (url && url.trim().length > 0)
|
|
20
|
+
return "http";
|
|
21
|
+
if (minilm && ["1", "true", "yes"].includes(minilm.trim().toLowerCase()))
|
|
22
|
+
return "minilm";
|
|
23
|
+
return "trigram";
|
|
24
|
+
}
|
|
25
|
+
export function handleSetupStatus(req, res, _ctx) {
|
|
26
|
+
if (req.url !== "/api/setup-status")
|
|
27
|
+
return false;
|
|
28
|
+
if (req.method !== "GET") {
|
|
29
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
30
|
+
res.writeHead(405, { "Content-Type": "application/json" });
|
|
31
|
+
res.end(JSON.stringify({ error: "method_not_allowed" }));
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
const body = {
|
|
35
|
+
currentEmbedder: detectCurrentEmbedder(),
|
|
36
|
+
embeddingUrl: process.env["MEGACOMPACT_EMBEDDING_URL"] ?? null,
|
|
37
|
+
embedCache: process.env["MEGACOMPACT_EMBED_CACHE"] ?? null,
|
|
38
|
+
minilm: ["1", "true", "yes"].includes((process.env["MEGACOMPACT_MINILM"] ?? "").trim().toLowerCase()),
|
|
39
|
+
};
|
|
40
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
41
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
42
|
+
res.end(JSON.stringify(body));
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// handleSetupDetect — "/api/setup-detect"
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
function detectOllama() {
|
|
49
|
+
try {
|
|
50
|
+
const version = spawnSync("ollama", ["--version"], {
|
|
51
|
+
timeout: 5000,
|
|
52
|
+
encoding: "utf-8",
|
|
53
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
54
|
+
});
|
|
55
|
+
if (version.status !== 0) {
|
|
56
|
+
return { installed: false, models: [], running: false, detail: version.stderr?.trim() || "not found" };
|
|
57
|
+
}
|
|
58
|
+
// Check for running server
|
|
59
|
+
let running = false;
|
|
60
|
+
let models = [];
|
|
61
|
+
try {
|
|
62
|
+
const listResult = spawnSync("ollama", ["list"], {
|
|
63
|
+
timeout: 5000,
|
|
64
|
+
encoding: "utf-8",
|
|
65
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
66
|
+
});
|
|
67
|
+
if (listResult.status === 0) {
|
|
68
|
+
running = true;
|
|
69
|
+
// Parse lines: NAME ID SIZE MODIFIED
|
|
70
|
+
const lines = listResult.stdout?.split("\n") ?? [];
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
const name = line.split(/\s+/)[0];
|
|
73
|
+
if (name && name !== "NAME")
|
|
74
|
+
models.push(name);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// ollama list failed — server may not be running
|
|
80
|
+
running = false;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
installed: true,
|
|
84
|
+
models,
|
|
85
|
+
running,
|
|
86
|
+
detail: version.stdout?.trim() || null,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return { installed: false, models: [], running: false, detail: "detection error" };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function detectLlamaCpp() {
|
|
94
|
+
try {
|
|
95
|
+
const which = spawnSync("which", ["llama-server", "llama.cpp"], {
|
|
96
|
+
timeout: 3000,
|
|
97
|
+
encoding: "utf-8",
|
|
98
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
99
|
+
});
|
|
100
|
+
const installed = which.status === 0 && which.stdout.trim().length > 0;
|
|
101
|
+
return {
|
|
102
|
+
installed,
|
|
103
|
+
detail: installed ? which.stdout.trim() : null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return { installed: false, detail: "detection error" };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function detectOnnx() {
|
|
111
|
+
try {
|
|
112
|
+
// Check for onnxruntime-node in a parent node_modules
|
|
113
|
+
const req = createRequire(import.meta.url);
|
|
114
|
+
try {
|
|
115
|
+
req.resolve("onnxruntime-node");
|
|
116
|
+
return { installed: true, detail: "onnxruntime-node found in node_modules" };
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return { installed: false, detail: "onnxruntime-node not found in node_modules" };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return { installed: false, detail: "detection error" };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function handleSetupDetect(req, res, _ctx) {
|
|
127
|
+
if (req.url !== "/api/setup-detect")
|
|
128
|
+
return false;
|
|
129
|
+
if (req.method !== "GET") {
|
|
130
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
131
|
+
res.writeHead(405, { "Content-Type": "application/json" });
|
|
132
|
+
res.end(JSON.stringify({ error: "method_not_allowed" }));
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
let error = null;
|
|
136
|
+
let ollama = null;
|
|
137
|
+
let llamaCpp = null;
|
|
138
|
+
let onnx = null;
|
|
139
|
+
try {
|
|
140
|
+
ollama = detectOllama();
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
error = `ollama detection failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
llamaCpp = detectLlamaCpp();
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
error = error ?? `llama.cpp detection failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
onnx = detectOnnx();
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
error = error ?? `onnx detection failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
156
|
+
}
|
|
157
|
+
const body = { ollama, llamaCpp, onnx, error };
|
|
158
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
159
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
160
|
+
res.end(JSON.stringify(body));
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
@@ -12,3 +12,5 @@ export { handleTopics } from "./routes-topics.js";
|
|
|
12
12
|
export { handleTurns } from "./routes-turns.js";
|
|
13
13
|
export { handleMaintenance } from "./routes-maintenance.js";
|
|
14
14
|
export { handleProviderCache } from "./routes-cache.js";
|
|
15
|
+
export { handleMemoryStatus } from "./routes-memory.js";
|
|
16
|
+
export { handleSetupStatus, handleSetupDetect } from "./routes-setup.js";
|
|
@@ -12,7 +12,7 @@ import { join, dirname } from "node:path";
|
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { createRequire } from "node:module";
|
|
14
14
|
import { log, setLogPath, setDashboardServerVersion } from "./state.js";
|
|
15
|
-
import { buildRouteContext, handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerf, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleStatic, } from "./routes.js";
|
|
15
|
+
import { buildRouteContext, handleIndex, handleRepoIndex, handleEvents, handleGameState, handleGameScores, handlePerf, handleAchievements, handleSessions, handleTopics, handleTurns, handleMaintenance, handleProviderCache, handleMemoryStatus, handleSetupStatus, handleSetupDetect, handleStatic, } from "./routes.js";
|
|
16
16
|
export async function launchDashboardServer(stateDir) {
|
|
17
17
|
// Our own package version — exposed at /api/version so the launcher can
|
|
18
18
|
// detect a stale server (started by an older build) and replace it on
|
|
@@ -195,6 +195,12 @@ export async function launchDashboardServer(stateDir) {
|
|
|
195
195
|
return;
|
|
196
196
|
if (handleProviderCache(req, res, ctx))
|
|
197
197
|
return;
|
|
198
|
+
if (handleMemoryStatus(req, res, ctx))
|
|
199
|
+
return;
|
|
200
|
+
if (handleSetupStatus(req, res, ctx))
|
|
201
|
+
return;
|
|
202
|
+
if (handleSetupDetect(req, res, ctx))
|
|
203
|
+
return;
|
|
198
204
|
handleStatic(req, res, ctx);
|
|
199
205
|
});
|
|
200
206
|
// Bind base + range are env-configurable so tests can use a private,
|