pi-mega-compact 0.13.5 → 0.13.7
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/registry.js +50 -0
- package/dist/extensions/dashboard-server/api-contracts/rag-metrics.js +1 -0
- package/dist/extensions/dashboard-server/api-contracts/rag-settings.js +3 -3
- package/dist/extensions/dashboard-server/api-contracts/wiki.js +1 -0
- package/dist/extensions/dashboard-server/index-reader.js +3 -1
- package/dist/extensions/dashboard-server/resolve-snapshot.js +81 -0
- package/dist/extensions/dashboard-server/routes-core.js +8 -3
- package/dist/extensions/dashboard-server/routes-rag-metrics.js +60 -0
- package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +167 -0
- package/dist/extensions/dashboard-server/routes-rag-settings.js +136 -77
- package/dist/extensions/dashboard-server/routes-repo.js +5 -1
- package/dist/extensions/dashboard-server/routes-sessions.js +6 -3
- package/dist/extensions/dashboard-server/routes-wiki-helpers.js +97 -0
- package/dist/extensions/dashboard-server/routes-wiki.js +330 -0
- package/dist/extensions/dashboard-server/routes.js +2 -0
- package/dist/extensions/dashboard-server/server.js +17 -3
- package/dist/extensions/mega-events/context-handler/afterCompact.js +35 -2
- package/dist/extensions/mega-pipeline/recall.js +31 -0
- package/dist/extensions/mega-runtime/capture-model.js +5 -2
- package/dist/extensions/mega-turn-store.js +2 -1
- package/dist/src/config/turns.js +10 -0
- package/dist/src/config.js +2 -0
- package/dist/src/pricing.js +8 -0
- package/dist/src/recall/async.js +10 -1
- package/dist/src/recall/format.js +10 -1
- package/dist/src/recall/hydeTelemetry.js +22 -0
- package/dist/src/recall/sync.js +28 -2
- package/dist/src/store/turns/hydeStore.js +32 -0
- package/dist/src/store/turns/index.js +1 -0
- package/dist/src/store/turns/schema.js +102 -1
- package/dist/src/store/turns/sqlite-store/rows.js +23 -0
- package/dist/src/store/turns/sqlite-store/write.js +7 -3
- package/dist/src/topics/durability.js +187 -0
- package/dist/src/topics/index.js +2 -1
- package/dist/src/topics/store.js +28 -9
- package/dist/src/wiki/curation-helpers.js +71 -0
- package/dist/src/wiki/curation.js +147 -0
- package/dist/src/wiki/incremental.js +126 -0
- package/dist/src/wiki/index.js +5 -0
- package/extensions/dashboard-client/dist/assets/AreaChart-j2VOSRp6.js +70 -0
- package/extensions/dashboard-client/dist/assets/{SessionsTab-C30AwyoF.js.map → AreaChart-j2VOSRp6.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/CacheTab-Dr1HeMfc.js +2 -0
- package/extensions/dashboard-client/dist/assets/CacheTab-Dr1HeMfc.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/EventsTab-DRG2k7FS.js +2 -0
- package/extensions/dashboard-client/dist/assets/EventsTab-DRG2k7FS.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/HealthTab-DGE9PpW3.js +2 -0
- package/extensions/dashboard-client/dist/assets/HealthTab-DGE9PpW3.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/MaintenanceTab-DeYRhF4q.js +2 -0
- package/extensions/dashboard-client/dist/assets/MaintenanceTab-DeYRhF4q.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/MemoryMapTab-DSnSO3nG.js +2 -0
- package/extensions/dashboard-client/dist/assets/MemoryMapTab-DSnSO3nG.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/MetricsTab-RIzNc1Uj.js +2 -0
- package/extensions/dashboard-client/dist/assets/MetricsTab-RIzNc1Uj.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/OverviewTab-_1BJ4Bmh.js +2 -0
- package/extensions/dashboard-client/dist/assets/OverviewTab-_1BJ4Bmh.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/ReposTab-DkU7ywZB.js +2 -0
- package/extensions/dashboard-client/dist/assets/ReposTab-DkU7ywZB.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/SessionsTab-Bq_F_aOk.js +2 -0
- package/extensions/dashboard-client/dist/assets/SessionsTab-Bq_F_aOk.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-BkBD2Y97.js +2 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-BkBD2Y97.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-BXzFKU7C.js +2 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-BXzFKU7C.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TurnsTab-Bjpp3vBH.js +5 -0
- package/extensions/dashboard-client/dist/assets/TurnsTab-Bjpp3vBH.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/WikiTab-dBN2EA5G.js +2 -0
- package/extensions/dashboard-client/dist/assets/WikiTab-dBN2EA5G.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/button-Bt0b5QVp.js +2 -0
- package/extensions/dashboard-client/dist/assets/button-Bt0b5QVp.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/card-D5CafXtg.js +2 -0
- package/extensions/dashboard-client/dist/assets/card-D5CafXtg.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/index-CUA6EDRF.css +1 -0
- package/extensions/dashboard-client/dist/assets/index-GPHRnEN7.js +137 -0
- package/extensions/dashboard-client/dist/assets/index-GPHRnEN7.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/pricing-DkYp8-vi.js +2 -0
- package/extensions/dashboard-client/dist/assets/pricing-DkYp8-vi.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/switch-CY5Gwj1o.js +2 -0
- package/extensions/dashboard-client/dist/assets/switch-CY5Gwj1o.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/toggle-C9HpkIfH.js +2 -0
- package/extensions/dashboard-client/dist/assets/toggle-C9HpkIfH.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{useSSE-p1pOI_-P.js → useSSE-2JFrLDlE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-p1pOI_-P.js.map → useSSE-2JFrLDlE.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +2 -2
- package/extensions/dashboard-client/package-lock.json +1995 -191
- package/extensions/dashboard-client/package.json +12 -1
- package/extensions/dashboard-client/postcss.config.js +6 -0
- package/extensions/dashboard-client/src/App.tsx +127 -88
- package/extensions/dashboard-client/src/api/client.ts +109 -10
- package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +15 -7
- package/extensions/dashboard-client/src/components/ActiveSessionsTable.tsx +67 -55
- package/extensions/dashboard-client/src/components/CacheHitRateTrendCard.tsx +17 -13
- package/extensions/dashboard-client/src/components/CacheHitsCard.tsx +35 -30
- package/extensions/dashboard-client/src/components/CacheStatusPerModel.tsx +33 -28
- package/extensions/dashboard-client/src/components/EventCategoryFilter.tsx +5 -6
- package/extensions/dashboard-client/src/components/EventStream.tsx +17 -13
- package/extensions/dashboard-client/src/components/HydeDetailPanel.tsx +173 -0
- package/extensions/dashboard-client/src/components/LegendCard.tsx +16 -9
- package/extensions/dashboard-client/src/components/PerfCards.tsx +28 -20
- package/extensions/dashboard-client/src/components/PerfChart.tsx +9 -6
- package/extensions/dashboard-client/src/components/ProviderCacheCard.tsx +15 -7
- package/extensions/dashboard-client/src/components/RagDashboard.tsx +253 -0
- package/extensions/dashboard-client/src/components/RepoAllSessionsCard.tsx +15 -10
- package/extensions/dashboard-client/src/components/RepoContextStack.tsx +24 -16
- package/extensions/dashboard-client/src/components/RepoDetailModal.tsx +52 -49
- package/extensions/dashboard-client/src/components/RepoTable.tsx +26 -17
- package/extensions/dashboard-client/src/components/SessionContextGauges.tsx +11 -14
- package/extensions/dashboard-client/src/components/SessionInfo.tsx +20 -15
- package/extensions/dashboard-client/src/components/SessionsMemoryChart.tsx +8 -5
- package/extensions/dashboard-client/src/components/SummaryTiles.tsx +26 -17
- package/extensions/dashboard-client/src/components/TabBar.tsx +1 -3
- package/extensions/dashboard-client/src/components/layout/AppShell.tsx +42 -0
- package/extensions/dashboard-client/src/components/layout/BottomBar.tsx +88 -0
- package/extensions/dashboard-client/src/components/layout/Sidebar.tsx +83 -0
- package/extensions/dashboard-client/src/components/ui/badge.tsx +30 -0
- package/extensions/dashboard-client/src/components/ui/button.tsx +44 -0
- package/extensions/dashboard-client/src/components/ui/card.tsx +32 -0
- package/extensions/dashboard-client/src/components/ui/select.tsx +64 -0
- package/extensions/dashboard-client/src/components/ui/switch.tsx +26 -0
- package/extensions/dashboard-client/src/components/ui/tabs.tsx +36 -0
- package/extensions/dashboard-client/src/components/ui/toggle.tsx +28 -0
- package/extensions/dashboard-client/src/components/ui/tooltip.tsx +27 -0
- package/extensions/dashboard-client/src/config.ts +10 -0
- package/extensions/dashboard-client/src/main.tsx +2 -2
- package/extensions/dashboard-client/src/memory-map-layout.ts +1 -2
- package/extensions/dashboard-client/src/styles/index.css +79 -0
- package/extensions/dashboard-client/src/tabs/CacheTab.tsx +33 -26
- package/extensions/dashboard-client/src/tabs/EventsTab.tsx +22 -7
- package/extensions/dashboard-client/src/tabs/HealthTab.tsx +77 -46
- package/extensions/dashboard-client/src/tabs/MaintenanceTab/ActionsCard.tsx +60 -50
- package/extensions/dashboard-client/src/tabs/MaintenanceTab/DbStatsCard.tsx +61 -35
- package/extensions/dashboard-client/src/tabs/MaintenanceTab/DebugBundleCard.tsx +34 -23
- package/extensions/dashboard-client/src/tabs/MaintenanceTab/HealthMitigationCard.tsx +62 -43
- package/extensions/dashboard-client/src/tabs/MaintenanceTab/SchemaHealthCard.tsx +53 -32
- package/extensions/dashboard-client/src/tabs/MaintenanceTab.tsx +2 -2
- package/extensions/dashboard-client/src/tabs/MemoryMapTab/MemoryMapView.tsx +29 -46
- package/extensions/dashboard-client/src/tabs/MemoryMapTab/RaptorTreeView.tsx +10 -34
- package/extensions/dashboard-client/src/tabs/MemoryMapTab.tsx +14 -34
- package/extensions/dashboard-client/src/tabs/MetricsTab.tsx +5 -2
- package/extensions/dashboard-client/src/tabs/OverviewTab.tsx +11 -5
- package/extensions/dashboard-client/src/tabs/ReposTab.tsx +5 -5
- package/extensions/dashboard-client/src/tabs/SessionsTab.tsx +47 -33
- package/extensions/dashboard-client/src/tabs/SetupTab/EmbedderSetup.tsx +6 -2
- package/extensions/dashboard-client/src/tabs/SetupTab/RagHealthCard.tsx +78 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/SettingsPanel.tsx +198 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/SettingsSection.tsx +50 -0
- package/extensions/dashboard-client/src/tabs/SetupTab.tsx +21 -59
- package/extensions/dashboard-client/src/tabs/TopicsTab.tsx +75 -40
- package/extensions/dashboard-client/src/tabs/TurnsTab.tsx +150 -112
- package/extensions/dashboard-client/src/tabs/WikiTab/TopicEvolutionGraph.tsx +274 -0
- package/extensions/dashboard-client/src/tabs/WikiTab/TopicEvolutionView.tsx +71 -0
- package/extensions/dashboard-client/src/tabs/WikiTab/TopicTimeline.tsx +103 -0
- package/extensions/dashboard-client/src/tabs/WikiTab/WikiPage.tsx +213 -0
- package/extensions/dashboard-client/src/tabs/WikiTab/WikiPageControls.tsx +188 -0
- package/extensions/dashboard-client/src/tabs/WikiTab.tsx +222 -0
- package/extensions/dashboard-client/src/tabs/registry.ts +57 -0
- package/extensions/dashboard-client/src/utils/cn.ts +7 -0
- package/extensions/dashboard-client/tailwind.config.js +46 -0
- package/extensions/dashboard-server/api-contracts/core.ts +59 -0
- package/extensions/dashboard-server/api-contracts/endpoints/registry.ts +79 -0
- package/extensions/dashboard-server/api-contracts/index.ts +48 -2
- package/extensions/dashboard-server/api-contracts/rag-metrics.ts +22 -0
- package/extensions/dashboard-server/api-contracts/rag-settings.ts +30 -20
- package/extensions/dashboard-server/api-contracts/wiki.ts +138 -0
- package/extensions/dashboard-server/index-reader.ts +3 -1
- package/extensions/dashboard-server/resolve-snapshot.ts +98 -0
- package/extensions/dashboard-server/routes-core.ts +8 -3
- package/extensions/dashboard-server/routes-rag-metrics.ts +82 -0
- package/extensions/dashboard-server/routes-rag-settings-helpers.ts +314 -0
- package/extensions/dashboard-server/routes-rag-settings.ts +147 -97
- package/extensions/dashboard-server/routes-repo.ts +5 -1
- package/extensions/dashboard-server/routes-sessions.ts +6 -3
- package/extensions/dashboard-server/routes-wiki-helpers.ts +126 -0
- package/extensions/dashboard-server/routes-wiki.ts +376 -0
- package/extensions/dashboard-server/routes.ts +2 -0
- package/extensions/dashboard-server/server.ts +18 -2
- package/extensions/mega-events/context-handler/afterCompact.ts +44 -1
- package/extensions/mega-pipeline/recall.ts +31 -0
- package/extensions/mega-runtime/capture-model.ts +5 -2
- package/extensions/mega-turn-store.ts +13 -0
- package/package.json +1 -1
- package/src/config/turns.ts +17 -0
- package/src/config.ts +3 -0
- package/src/pricing.ts +8 -0
- package/src/recall/async.ts +10 -1
- package/src/recall/format.ts +15 -2
- package/src/recall/hydeTelemetry.ts +44 -0
- package/src/recall/sync.ts +34 -2
- package/src/recall/types.ts +36 -0
- package/src/store/turns/hydeStore.ts +82 -0
- package/src/store/turns/index.ts +4 -0
- package/src/store/turns/schema.ts +126 -1
- package/src/store/turns/sqlite-store/rows.ts +25 -0
- package/src/store/turns/sqlite-store/write.ts +20 -2
- package/src/store/turns/types.ts +33 -0
- package/src/topics/durability.ts +231 -0
- package/src/topics/index.ts +7 -1
- package/src/topics/store.ts +35 -9
- package/src/wiki/curation-helpers.ts +140 -0
- package/src/wiki/curation.ts +217 -0
- package/src/wiki/incremental.ts +164 -0
- package/src/wiki/index.ts +13 -0
- package/extensions/dashboard-client/dist/assets/CacheTab-Cqnc7lMg.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Cqnc7lMg.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/EventsTab-tYk3VFAp.js +0 -2
- package/extensions/dashboard-client/dist/assets/EventsTab-tYk3VFAp.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/HealthTab-D2_kjgxw.js +0 -2
- package/extensions/dashboard-client/dist/assets/HealthTab-D2_kjgxw.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/MaintenanceTab-Bc-uPYrz.js +0 -2
- package/extensions/dashboard-client/dist/assets/MaintenanceTab-Bc-uPYrz.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/MemoryMapTab-D1V9g_NC.js +0 -2
- package/extensions/dashboard-client/dist/assets/MemoryMapTab-D1V9g_NC.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/MetricsTab-DT_XfL96.js +0 -2
- package/extensions/dashboard-client/dist/assets/MetricsTab-DT_XfL96.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-BY6KZCme.js +0 -2
- package/extensions/dashboard-client/dist/assets/OverviewTab-BY6KZCme.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/ReposTab-CeS-tpDM.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-CeS-tpDM.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/SessionsTab-C30AwyoF.js +0 -70
- package/extensions/dashboard-client/dist/assets/SetupTab-BJUHOVK2.js +0 -2
- package/extensions/dashboard-client/dist/assets/SetupTab-BJUHOVK2.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-p55K1tFP.js +0 -2
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-p55K1tFP.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TopicsTab-D8FqyAbK.js +0 -2
- package/extensions/dashboard-client/dist/assets/TopicsTab-D8FqyAbK.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-ju-nXDys.js +0 -2
- package/extensions/dashboard-client/dist/assets/TurnsTab-ju-nXDys.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-BEj1Zahy.js +0 -42
- package/extensions/dashboard-client/dist/assets/index-BEj1Zahy.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-CUNn22iV.css +0 -1
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js +0 -2
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js.map +0 -1
- package/extensions/dashboard-client/src/styles/metrics-extra.css +0 -69
- package/extensions/dashboard-client/src/styles/turns.css +0 -142
- package/extensions/dashboard-client/src/tabs/SetupTab/RagSettingsCard.tsx +0 -160
|
@@ -1,42 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* api-contracts/rag-settings.ts —
|
|
2
|
+
* api-contracts/rag-settings.ts — comprehensive settings API response types.
|
|
3
3
|
*
|
|
4
|
-
* Types for the /api/rag-settings endpoint used by the dashboard
|
|
5
|
-
*
|
|
4
|
+
* Types for the /api/rag-settings endpoint used by the dashboard Setup panel to
|
|
5
|
+
* read and update every adjustable MEGACOMPACT_* setting, grouped by category.
|
|
6
6
|
*
|
|
7
7
|
* PREVENT-PI-004: type definitions only, no network code.
|
|
8
8
|
* PREVENT-011: no `any` type — all types are explicit.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
export interface
|
|
13
|
-
/** Env var key without the _DISABLED suffix, e.g. "MEGACOMPACT_HYDE". */
|
|
11
|
+
/** A single configurable setting's metadata + current value. */
|
|
12
|
+
export interface SettingState {
|
|
14
13
|
readonly key: string;
|
|
15
|
-
/** Short human-readable label, e.g. "HyDE (Hypothetical Document Embeddings)". */
|
|
16
14
|
readonly label: string;
|
|
17
|
-
/** One-line description of what the flag does. */
|
|
18
15
|
readonly description: string;
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
|
|
16
|
+
readonly category: string;
|
|
17
|
+
readonly type: "boolean" | "number" | "string";
|
|
18
|
+
readonly value: string | number | boolean;
|
|
19
|
+
readonly default: string | number | boolean;
|
|
20
|
+
readonly disabledConvention: boolean;
|
|
22
21
|
readonly requiresLlm: boolean;
|
|
22
|
+
readonly unit?: string;
|
|
23
|
+
readonly min?: number;
|
|
24
|
+
readonly max?: number;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
/** Response for GET /api/rag-settings. */
|
|
26
|
-
export interface
|
|
27
|
-
readonly
|
|
28
|
-
/** Whether an HttpEmbedder (LLM) is currently active — gates HyDE toggle. */
|
|
27
|
+
/** Response for GET /api/rag-settings — all settings grouped by category. */
|
|
28
|
+
export interface SettingsResponse {
|
|
29
|
+
readonly categories: ReadonlyArray<{ name: string; settings: SettingState[] }>;
|
|
29
30
|
readonly llmActive: boolean;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
/** Request body for POST /api/rag-settings. */
|
|
33
|
-
export interface
|
|
34
|
-
|
|
35
|
-
readonly
|
|
33
|
+
/** Request body for POST /api/rag-settings — update a single setting. */
|
|
34
|
+
export interface SettingsUpdateRequest {
|
|
35
|
+
readonly key: string;
|
|
36
|
+
readonly value: string;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/** Response for POST /api/rag-settings. */
|
|
39
|
-
export interface
|
|
40
|
+
export interface SettingsResponsePost {
|
|
40
41
|
readonly envPath: string;
|
|
41
42
|
readonly restartRequired: boolean;
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
/** @deprecated Use SettingState instead */
|
|
46
|
+
export type RagFlagState = SettingState;
|
|
47
|
+
/** @deprecated Use SettingsResponse instead */
|
|
48
|
+
export type RagSettingsResponse = SettingsResponse;
|
|
49
|
+
/** @deprecated Use SettingsUpdateRequest instead */
|
|
50
|
+
export type RagSettingsRequest = SettingsUpdateRequest;
|
|
51
|
+
/** @deprecated Use SettingsResponsePost instead */
|
|
52
|
+
export type RagSettingsResponsePost = SettingsResponsePost;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* api-contracts/wiki.ts — W2 wiki revival contract types.
|
|
3
|
+
*
|
|
4
|
+
* Shapes for the 7 wiki endpoints plus the SSE events the mutations emit.
|
|
5
|
+
* `CurationResult` is the canonical type from src/wiki/curation.ts (single
|
|
6
|
+
* source of truth), re-exported here for route + client parity. Type-only —
|
|
7
|
+
* no network (PREVENT-PI-004), no `any` (PREVENT-011).
|
|
8
|
+
*/
|
|
9
|
+
import type { CurationResult } from "../../../src/wiki/curation.js";
|
|
10
|
+
|
|
11
|
+
/** One topic row in the wiki index (with resolved custom label). */
|
|
12
|
+
export interface WikiIndexEntry {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
memoryCount: number;
|
|
16
|
+
lastUpdated: number;
|
|
17
|
+
/** True when the label is a user override, not the auto-generated one. */
|
|
18
|
+
edited: boolean;
|
|
19
|
+
/** Cumulative override kinds for badge provenance. */
|
|
20
|
+
overrideKinds: Array<"label" | "merge" | "split">;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** GET /api/wiki/index — wiki landing page payload. */
|
|
24
|
+
export interface WikiIndexResponse {
|
|
25
|
+
topics: WikiIndexEntry[];
|
|
26
|
+
totalTopics: number;
|
|
27
|
+
totalMemories: number;
|
|
28
|
+
lastRebuildAt: number | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Provenance for one memory within a wiki topic. */
|
|
32
|
+
export interface MemoryProvenance {
|
|
33
|
+
memoryId: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
assignedAt: number;
|
|
36
|
+
method: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** GET /api/wiki/topic/:topicId — single topic page. */
|
|
40
|
+
export interface WikiPageResponse {
|
|
41
|
+
topic: WikiIndexEntry;
|
|
42
|
+
summary: string;
|
|
43
|
+
keyMemories: Array<{
|
|
44
|
+
memoryId: string;
|
|
45
|
+
content: string;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
importance: number;
|
|
48
|
+
}>;
|
|
49
|
+
provenance: MemoryProvenance[];
|
|
50
|
+
relatedTopicIds: string[];
|
|
51
|
+
generatedAt: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** PUT /api/wiki/topic/:topicId/label — rename request body. */
|
|
55
|
+
export interface RenameTopicRequest {
|
|
56
|
+
label: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** POST /api/wiki/merge — merge source into target. */
|
|
60
|
+
export interface MergeTopicsRequest {
|
|
61
|
+
sourceTopicId: string;
|
|
62
|
+
targetTopicId: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** POST /api/wiki/topic/:topicId/split — split request body. */
|
|
66
|
+
export interface SplitTopicRequest {
|
|
67
|
+
memoryIds: string[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** One flat node row in the D3 evolution graph. */
|
|
71
|
+
export interface TopicEvolutionNode {
|
|
72
|
+
id: string;
|
|
73
|
+
label: string;
|
|
74
|
+
memoryCount: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** One edge between evolved topics. */
|
|
78
|
+
export interface TopicEvolutionEdge {
|
|
79
|
+
source: string;
|
|
80
|
+
target: string;
|
|
81
|
+
kind: "merge" | "split";
|
|
82
|
+
at: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** GET /api/wiki/evolution — nodes + edges + time buckets for D3. */
|
|
86
|
+
export interface TopicEvolutionResponse {
|
|
87
|
+
nodes: TopicEvolutionNode[];
|
|
88
|
+
edges: TopicEvolutionEdge[];
|
|
89
|
+
buckets: Array<{ bucket: number; count: number }>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** GET /api/wiki/topic/:topicId/timeline — per-topic time buckets. */
|
|
93
|
+
export interface TopicTimelineResponse {
|
|
94
|
+
topicId: string;
|
|
95
|
+
buckets: Array<{ bucket: number; count: number }>;
|
|
96
|
+
total: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** SSE: wiki model rebuilt. */
|
|
100
|
+
export interface SseWikiRebuilt {
|
|
101
|
+
type: "wiki_rebuilt";
|
|
102
|
+
ts: string;
|
|
103
|
+
topicCount: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** SSE: a topic was renamed. */
|
|
107
|
+
export interface SseWikiTopicRenamed {
|
|
108
|
+
type: "wiki_topic_renamed";
|
|
109
|
+
ts: string;
|
|
110
|
+
topicId: string;
|
|
111
|
+
label: string;
|
|
112
|
+
edited: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** SSE: two topics were merged. */
|
|
116
|
+
export interface SseWikiTopicsMerged {
|
|
117
|
+
type: "wiki_topics_merged";
|
|
118
|
+
ts: string;
|
|
119
|
+
sourceTopicId: string;
|
|
120
|
+
targetTopicId: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** SSE: a topic was split. */
|
|
124
|
+
export interface SseWikiTopicSplit {
|
|
125
|
+
type: "wiki_topic_split";
|
|
126
|
+
ts: string;
|
|
127
|
+
fromTopicId: string;
|
|
128
|
+
toTopicId: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Union of all wiki SSE events. */
|
|
132
|
+
export type WikiSseEvent =
|
|
133
|
+
| SseWikiRebuilt
|
|
134
|
+
| SseWikiTopicRenamed
|
|
135
|
+
| SseWikiTopicsMerged
|
|
136
|
+
| SseWikiTopicSplit;
|
|
137
|
+
|
|
138
|
+
export type { CurationResult };
|
|
@@ -17,6 +17,7 @@ import type { IndexRepo, IndexIndex } from "./types.js";
|
|
|
17
17
|
import {
|
|
18
18
|
readProviderCacheForRepo,
|
|
19
19
|
} from "../../src/store/sqlite/perf-samples.js";
|
|
20
|
+
import { lookupModelInputRate } from "../../src/pricing.js";
|
|
20
21
|
|
|
21
22
|
export function getIndexDir(): string {
|
|
22
23
|
const override = process.env.MEGACOMPACT_INDEX_DIR;
|
|
@@ -51,7 +52,8 @@ export function readIndex(): IndexIndex | null {
|
|
|
51
52
|
provider: (r.provider as string | null) ?? null,
|
|
52
53
|
providerName: (r.provider_name as string | null) ?? null,
|
|
53
54
|
modelName: (r.model_name as string | null) ?? null,
|
|
54
|
-
inputRate: (r.input_rate as number | null)
|
|
55
|
+
inputRate: ((r.input_rate as number | null) ||
|
|
56
|
+
lookupModelInputRate(String(r.model_name ?? ""))) ?? null,
|
|
55
57
|
outputRate: (r.output_rate as number | null) ?? null,
|
|
56
58
|
lastSeen: Number(r.last_seen ?? 0),
|
|
57
59
|
// Defaults — enriched below from each repo's own store.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/resolve-snapshot.ts — dynamic per-repo snapshot resolver.
|
|
3
|
+
*
|
|
4
|
+
* The dashboard server is launched with a single static stateDir, but the
|
|
5
|
+
* active pi session may be running in a different repo. This module queries
|
|
6
|
+
* the repo registry to find the most recently active repo's dashboard.json,
|
|
7
|
+
* so the Overview always shows live data from the repo pi is actually running
|
|
8
|
+
* in — not the stale launcher dir.
|
|
9
|
+
*
|
|
10
|
+
* Resolution order:
|
|
11
|
+
* 1. Most recently seen repo (by last_seen in repo_registry) whose
|
|
12
|
+
* dashboard.json exists and has a non-null updatedAt
|
|
13
|
+
* 2. The static launch stateDir's dashboard.json (original behavior)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { existsSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { createRequire } from "node:module";
|
|
19
|
+
import { readSnapshot } from "./snapshot.js";
|
|
20
|
+
import type { Snapshot } from "./types.js";
|
|
21
|
+
import { getIndexDir } from "./index-reader.js";
|
|
22
|
+
|
|
23
|
+
export interface ResolvedSnapshot {
|
|
24
|
+
snapshot: Snapshot;
|
|
25
|
+
/** The stateDir that produced this snapshot. */
|
|
26
|
+
stateDir: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const require = createRequire(import.meta.url);
|
|
30
|
+
|
|
31
|
+
interface RepoRegistryRow {
|
|
32
|
+
state_dir: string;
|
|
33
|
+
last_seen: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Find the most recently active repo's stateDir by scanning the repo registry
|
|
38
|
+
* for repos whose dashboard.json exists and was written recently. Returns null
|
|
39
|
+
* if no suitable repo is found.
|
|
40
|
+
*/
|
|
41
|
+
function mostRecentRepoStateDir(staticStateDir: string): string | null {
|
|
42
|
+
const indexPath = join(getIndexDir(), "index.sqlite");
|
|
43
|
+
if (!existsSync(indexPath)) return null;
|
|
44
|
+
let db;
|
|
45
|
+
try {
|
|
46
|
+
const { DatabaseSync } = require("node:sqlite") as typeof import("node:sqlite");
|
|
47
|
+
db = new DatabaseSync(indexPath, { readOnly: true });
|
|
48
|
+
const rows = db
|
|
49
|
+
.prepare(
|
|
50
|
+
`SELECT state_dir, last_seen FROM repo_registry
|
|
51
|
+
WHERE state_dir IS NOT NULL AND state_dir != ?
|
|
52
|
+
ORDER BY last_seen DESC`,
|
|
53
|
+
)
|
|
54
|
+
.all(staticStateDir) as unknown as RepoRegistryRow[];
|
|
55
|
+
for (const r of rows) {
|
|
56
|
+
const dashPath = join(r.state_dir, "dashboard.json");
|
|
57
|
+
if (!existsSync(dashPath)) continue;
|
|
58
|
+
const snap = readSnapshot(dashPath);
|
|
59
|
+
if (snap.updatedAt) {
|
|
60
|
+
return r.state_dir;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
} finally {
|
|
67
|
+
try {
|
|
68
|
+
db?.close();
|
|
69
|
+
} catch {
|
|
70
|
+
/* ignore */
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resolve the best snapshot to serve. Tries the most recently active repo's
|
|
77
|
+
* dashboard.json first, then falls back to the static launch path.
|
|
78
|
+
*/
|
|
79
|
+
export function resolveSnapshot(
|
|
80
|
+
staticSnapshotPath: string,
|
|
81
|
+
staticStateDir: string,
|
|
82
|
+
): ResolvedSnapshot {
|
|
83
|
+
// Try the most recently active repo first.
|
|
84
|
+
const activeDir = mostRecentRepoStateDir(staticStateDir);
|
|
85
|
+
if (activeDir) {
|
|
86
|
+
const activePath = join(activeDir, "dashboard.json");
|
|
87
|
+
const snap = readSnapshot(activePath);
|
|
88
|
+
if (snap.updatedAt) {
|
|
89
|
+
return { snapshot: snap, stateDir: activeDir };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Fall back to the static launch path.
|
|
93
|
+
return {
|
|
94
|
+
snapshot: readSnapshot(staticSnapshotPath),
|
|
95
|
+
stateDir: staticStateDir,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { ServerResponse } from "node:http";
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { resolveSnapshot } from "./resolve-snapshot.js";
|
|
12
12
|
import type { IndexIndex, Snapshot } from "./types.js";
|
|
13
13
|
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
@@ -53,14 +53,19 @@ function makeOverlayCurrentRepo(
|
|
|
53
53
|
): (idx: IndexIndex | null) => void {
|
|
54
54
|
return (idx: IndexIndex | null): void => {
|
|
55
55
|
if (!idx || !idx.repos.length) return;
|
|
56
|
+
// Dynamically resolve the most recently active repo's snapshot so the
|
|
57
|
+
// overlay matches what /api/snapshot serves (not the stale launch dir).
|
|
56
58
|
let snap: Snapshot | null = null;
|
|
59
|
+
let activeStateDir = stateDir;
|
|
57
60
|
try {
|
|
58
|
-
|
|
61
|
+
const resolved = resolveSnapshot(snapshotPath, stateDir);
|
|
62
|
+
snap = resolved.snapshot;
|
|
63
|
+
activeStateDir = resolved.stateDir;
|
|
59
64
|
} catch {
|
|
60
65
|
return;
|
|
61
66
|
}
|
|
62
67
|
if (!snap || !snap.repo) return;
|
|
63
|
-
const cur = idx.repos.find((r) => r.stateDir ===
|
|
68
|
+
const cur = idx.repos.find((r) => r.stateDir === activeStateDir);
|
|
64
69
|
if (!cur) return;
|
|
65
70
|
const prevSaved = cur.tokensSaved;
|
|
66
71
|
const prevCp = cur.checkpointCount;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard-server/routes-rag-metrics.ts — GET /api/rag-metrics route (H2).
|
|
3
|
+
*
|
|
4
|
+
* Aggregates the H1 HyDE + recall-quality telemetry columns from turns.db into
|
|
5
|
+
* a compact response (flags, totals, recent rows, daily series).
|
|
6
|
+
*
|
|
7
|
+
* Guardrails: PREVENT-PI-004 (loopback-only), PREVENT-002 (parameterized),
|
|
8
|
+
* PREVENT-011 (no `any`).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
12
|
+
import type { DatabaseSync } from "node:sqlite";
|
|
13
|
+
import type { RouteContext } from "./routes-core.js";
|
|
14
|
+
import { openTurnStore } from "../../src/store/turns/connection.js";
|
|
15
|
+
import {
|
|
16
|
+
listTelemetryTurns,
|
|
17
|
+
aggregateDailyTelemetry,
|
|
18
|
+
} from "../../src/store/turns/hydeStore.js";
|
|
19
|
+
import { RAG_HYDE_ENABLED, RAG_RECALL_METRICS } from "../../src/config.js";
|
|
20
|
+
import type { RagMetricsResponse } from "./api-contracts/rag-metrics.js";
|
|
21
|
+
|
|
22
|
+
function sendJson(res: ServerResponse, status: number, body: unknown): void {
|
|
23
|
+
// guardrails-allow PREVENT-PI-004: loopback dashboard response (local)
|
|
24
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
25
|
+
res.end(JSON.stringify(body));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function handleRagMetrics(
|
|
29
|
+
req: IncomingMessage,
|
|
30
|
+
res: ServerResponse,
|
|
31
|
+
ctx: RouteContext,
|
|
32
|
+
): boolean {
|
|
33
|
+
const url = req.url ?? "";
|
|
34
|
+
if (url !== "/api/rag-metrics" || req.method !== "GET") return false;
|
|
35
|
+
|
|
36
|
+
let db: DatabaseSync | null;
|
|
37
|
+
try {
|
|
38
|
+
db = openTurnStore(ctx.stateDir);
|
|
39
|
+
} catch {
|
|
40
|
+
db = null;
|
|
41
|
+
}
|
|
42
|
+
const recent = db ? listTelemetryTurns(db, { limit: 200 }) : [];
|
|
43
|
+
const daily = db ? aggregateDailyTelemetry(db, 14) : [];
|
|
44
|
+
|
|
45
|
+
const hydeRanTurns = recent.filter((t) => t.hydeRan === 1).length;
|
|
46
|
+
const liftSum = recent.reduce((s, t) => s + t.hydeLift, 0);
|
|
47
|
+
const genSum = recent.reduce((s, t) => s + t.hydeGenerationMs, 0);
|
|
48
|
+
const scored = recent.filter(
|
|
49
|
+
(t) => t.recallScore > 0 || t.recallPass === 1,
|
|
50
|
+
);
|
|
51
|
+
const avgScore =
|
|
52
|
+
scored.length > 0
|
|
53
|
+
? Math.round(
|
|
54
|
+
(scored.reduce((s, t) => s + t.recallScore, 0) / scored.length) * 100,
|
|
55
|
+
) / 100
|
|
56
|
+
: null;
|
|
57
|
+
const passCount = scored.filter((t) => t.recallPass === 1).length;
|
|
58
|
+
const recentPassRate =
|
|
59
|
+
scored.length > 0 ? Math.round((passCount / scored.length) * 100) / 100 : 0;
|
|
60
|
+
|
|
61
|
+
const body: RagMetricsResponse = {
|
|
62
|
+
flags: {
|
|
63
|
+
hydeEnabled: RAG_HYDE_ENABLED(),
|
|
64
|
+
recallMetricsEnabled: RAG_RECALL_METRICS(),
|
|
65
|
+
},
|
|
66
|
+
totals: {
|
|
67
|
+
telemetryTurns: recent.length,
|
|
68
|
+
hydeRanTurns,
|
|
69
|
+
avgLift:
|
|
70
|
+
recent.length > 0
|
|
71
|
+
? Math.round((liftSum / recent.length) * 100) / 100
|
|
72
|
+
: 0,
|
|
73
|
+
avgScore,
|
|
74
|
+
avgGenerationMs: recent.length > 0 ? Math.round(genSum / recent.length) : 0,
|
|
75
|
+
recentPassRate,
|
|
76
|
+
},
|
|
77
|
+
recent: recent.slice(0, 50),
|
|
78
|
+
daily,
|
|
79
|
+
};
|
|
80
|
+
sendJson(res, 200, body);
|
|
81
|
+
return true;
|
|
82
|
+
}
|