pi-mega-compact 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/extensions/dashboard-server/api-contracts/endpoints.js +95 -47
- package/dist/extensions/dashboard-server/api-contracts/index.js +1 -1
- package/dist/extensions/dashboard-server/api-contracts/turns.js +10 -0
- package/dist/extensions/dashboard-server/api-contracts.test.js +3 -2
- package/dist/extensions/dashboard-server/routes-topics.js +87 -0
- package/dist/extensions/dashboard-server/routes-turns.js +264 -0
- package/dist/extensions/dashboard-server/routes.js +3 -1
- package/dist/extensions/dashboard-server/server.js +6 -2
- package/dist/extensions/mega-compact.js +10 -6
- package/dist/extensions/mega-config.js +4 -0
- package/dist/extensions/mega-events/agent-handlers.js +62 -49
- package/dist/extensions/mega-events/context-handler.js +48 -2
- package/dist/extensions/mega-events/session-handlers.js +25 -1
- package/dist/extensions/mega-metrics-cmds.js +90 -0
- package/dist/extensions/mega-pipeline/recall.js +47 -17
- package/dist/extensions/mega-topics-cmds.js +111 -0
- package/dist/extensions/mega-turn-store.js +110 -0
- package/dist/extensions/mega-turn-store.test.js +68 -0
- package/dist/src/config/turns.js +48 -0
- package/dist/src/fork.js +33 -0
- package/dist/src/fork.test.js +81 -0
- package/dist/src/intent.js +51 -0
- package/dist/src/intent.test.js +78 -0
- package/dist/src/metrics/index.js +4 -0
- package/dist/src/metrics/turns.js +118 -0
- package/dist/src/metrics/turns.test.js +152 -0
- package/dist/src/store/sqlite/raw-transcript.js +5 -3
- package/dist/src/store/sqlite.dbmirror.test.js +9 -0
- package/dist/src/store/turns/connection.js +123 -0
- package/dist/src/store/turns/contract-compliance.test.js +428 -0
- package/dist/src/store/turns/index.js +31 -0
- package/dist/src/store/turns/memory-store.js +357 -0
- package/dist/src/store/turns/memory-store.test.js +9 -0
- package/dist/src/store/turns/migrations.js +178 -0
- package/dist/src/store/turns/migrations.test.js +138 -0
- package/dist/src/store/turns/schema.js +115 -0
- package/dist/src/store/turns/sqlite-store.js +455 -0
- package/dist/src/store/turns/sqlite-store.test.js +144 -0
- package/dist/src/store/turns/types.js +16 -0
- package/dist/src/topics/cluster.js +141 -0
- package/dist/src/topics/cluster.test.js +150 -0
- package/dist/src/topics/index.js +6 -0
- package/dist/src/topics/kselection.js +142 -0
- package/dist/src/topics/labels.js +56 -0
- package/dist/src/topics/store.js +119 -0
- package/dist/src/topics/store.test.js +117 -0
- package/dist/src/topics/types.js +8 -0
- package/dist/src/wiki.js +133 -0
- package/dist/src/wiki.test.js +171 -0
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-QPo46Pwg.js → AchievementTiles-DZp_xQOW.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-QPo46Pwg.js.map → AchievementTiles-DZp_xQOW.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{AchievementsTab-BDJxRXRY.js → AchievementsTab-BzFHpAHM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AchievementsTab-BDJxRXRY.js.map → AchievementsTab-BzFHpAHM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-CUMqXQjd.js → CacheTab-DEQbTq2T.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-CUMqXQjd.js.map → CacheTab-DEQbTq2T.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ConfigTab-j1dRzurG.js → ConfigTab-DQ4FG33J.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-j1dRzurG.js.map → ConfigTab-DQ4FG33J.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-CMglXK4p.js → EventsTab-D5HoEVYo.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-CMglXK4p.js.map → EventsTab-D5HoEVYo.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{GameTab-fpaDoyxi.js → GameTab-Jzsc4yeY.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{GameTab-fpaDoyxi.js.map → GameTab-Jzsc4yeY.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CWG2crG_.js → MetricsTab-D_XnsEYX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-CWG2crG_.js.map → MetricsTab-D_XnsEYX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BaV2D2nf.js → OverviewTab-BMREvAth.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-BaV2D2nf.js.map → OverviewTab-BMREvAth.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-C-0kuZ_0.js → ReposTab-DuyhOktG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-C-0kuZ_0.js.map → ReposTab-DuyhOktG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CSYhddCA.js → SessionsTab-mz_vz8i2.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-CSYhddCA.js.map → SessionsTab-mz_vz8i2.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Dy4KRjSM.js → TimeSavedCard-B8AIjNTY.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Dy4KRjSM.js.map → TimeSavedCard-B8AIjNTY.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/TopicsTab-DKuct4oD.js +2 -0
- package/extensions/dashboard-client/dist/assets/TopicsTab-DKuct4oD.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TurnsTab-11MGLxY8.js +2 -0
- package/extensions/dashboard-client/dist/assets/TurnsTab-11MGLxY8.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{index-D_WtU2TV.js → index-CqLN7STl.js} +10 -10
- package/extensions/dashboard-client/dist/assets/index-CqLN7STl.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{index-og3ghxyY.css → index-gn66lYD2.css} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-C9yVJlGP.js → useSSE-CXrQSbVY.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-C9yVJlGP.js.map → useSSE-CXrQSbVY.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +2 -2
- package/extensions/dashboard-client/src/App.tsx +10 -2
- package/extensions/dashboard-client/src/api/client.ts +90 -1
- package/extensions/dashboard-client/src/main.tsx +1 -0
- package/extensions/dashboard-client/src/styles/turns.css +142 -0
- package/extensions/dashboard-client/src/tabs/TopicsTab.tsx +186 -0
- package/extensions/dashboard-client/src/tabs/TurnsTab.tsx +336 -0
- package/extensions/dashboard-server/api-contracts/endpoints.ts +394 -291
- package/extensions/dashboard-server/api-contracts/game-types.ts +141 -88
- package/extensions/dashboard-server/api-contracts/index.ts +153 -133
- package/extensions/dashboard-server/api-contracts/turns.ts +114 -0
- package/extensions/dashboard-server/api-contracts.test.ts +920 -919
- package/extensions/dashboard-server/routes-topics.ts +119 -0
- package/extensions/dashboard-server/routes-turns.ts +305 -0
- package/extensions/dashboard-server/routes.ts +8 -1
- package/extensions/dashboard-server/server.ts +6 -2
- package/extensions/mega-compact.ts +75 -59
- package/extensions/mega-config.ts +232 -220
- package/extensions/mega-events/agent-handlers.ts +194 -151
- package/extensions/mega-events/context-handler.ts +50 -1
- package/extensions/mega-events/session-handlers.ts +26 -5
- package/extensions/mega-metrics-cmds.ts +114 -0
- package/extensions/mega-pipeline/recall.ts +215 -152
- package/extensions/mega-topics-cmds.ts +151 -0
- package/extensions/mega-turn-store.test.ts +108 -0
- package/extensions/mega-turn-store.ts +169 -0
- package/package.json +3 -1
- package/src/config/turns.ts +69 -0
- package/src/fork.test.ts +94 -0
- package/src/fork.ts +78 -0
- package/src/intent.test.ts +87 -0
- package/src/intent.ts +115 -0
- package/src/metrics/index.ts +9 -0
- package/src/metrics/turns.test.ts +165 -0
- package/src/metrics/turns.ts +201 -0
- package/src/store/sqlite/raw-transcript.ts +9 -3
- package/src/store/sqlite.dbmirror.test.ts +10 -0
- package/src/store/turns/connection.ts +137 -0
- package/src/store/turns/contract-compliance.test.ts +562 -0
- package/src/store/turns/index.ts +65 -0
- package/src/store/turns/memory-store.test.ts +15 -0
- package/src/store/turns/memory-store.ts +469 -0
- package/src/store/turns/migrations.test.ts +161 -0
- package/src/store/turns/migrations.ts +203 -0
- package/src/store/turns/schema.ts +158 -0
- package/src/store/turns/sqlite-store.test.ts +161 -0
- package/src/store/turns/sqlite-store.ts +656 -0
- package/src/store/turns/types.ts +181 -0
- package/src/topics/cluster.test.ts +176 -0
- package/src/topics/cluster.ts +191 -0
- package/src/topics/index.ts +18 -0
- package/src/topics/kselection.ts +182 -0
- package/src/topics/labels.ts +67 -0
- package/src/topics/store.test.ts +132 -0
- package/src/topics/store.ts +208 -0
- package/src/topics/types.ts +64 -0
- package/src/wiki.test.ts +217 -0
- package/src/wiki.ts +198 -0
- package/dist/extensions/openclaw-mega-compact.js +0 -291
- package/dist/src/minilm.js +0 -92
- package/dist/src/wordpiece.js +0 -129
- package/extensions/dashboard-client/dist/assets/index-D_WtU2TV.js.map +0 -1
|
@@ -9,36 +9,52 @@
|
|
|
9
9
|
* PREVENT-011: no `any` type — all types are explicit.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { EndpointDef } from
|
|
13
|
-
import type { SnapshotResponse } from
|
|
14
|
-
import type { IndexesIndexRow, IndexesSummaryResponse } from
|
|
15
|
-
import type { GameStateResponse } from
|
|
16
|
-
import type { SseEvent } from
|
|
12
|
+
import type { EndpointDef } from "./core.js";
|
|
13
|
+
import type { SnapshotResponse } from "./snapshot.js";
|
|
14
|
+
import type { IndexesIndexRow, IndexesSummaryResponse } from "./multi-repo.js";
|
|
15
|
+
import type { GameStateResponse } from "./game.js";
|
|
16
|
+
import type { SseEvent } from "./index.js";
|
|
17
|
+
import type {
|
|
18
|
+
TurnsResponse,
|
|
19
|
+
ConversationTurnsResponse,
|
|
20
|
+
RewindIntentsResponse,
|
|
21
|
+
ForkRequest,
|
|
22
|
+
ForkResponse,
|
|
23
|
+
PostIntentRequest,
|
|
24
|
+
PruneRequest,
|
|
25
|
+
PruneTurnsResponse,
|
|
26
|
+
TopicMemoriesResponse,
|
|
27
|
+
} from "./turns.js";
|
|
17
28
|
|
|
18
29
|
import type {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
GameScoreRow,
|
|
31
|
+
GameScoresQuery,
|
|
32
|
+
AchievementRow,
|
|
33
|
+
SessionsResponse,
|
|
34
|
+
SessionTimeseriesQuery,
|
|
35
|
+
SessionTimeseriesResponse,
|
|
36
|
+
GameStatePatch,
|
|
37
|
+
SseEndpointDef,
|
|
38
|
+
TopicsResponse,
|
|
39
|
+
} from "./game-types.js";
|
|
28
40
|
|
|
29
41
|
export type {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
GameScoreRow,
|
|
43
|
+
GameScoresQuery,
|
|
44
|
+
AchievementRow,
|
|
45
|
+
ActiveSession,
|
|
46
|
+
SessionsResponse,
|
|
47
|
+
SessionDataPoint,
|
|
48
|
+
SessionSeries,
|
|
49
|
+
SessionTimeseriesQuery,
|
|
50
|
+
SessionTimeseriesResponse,
|
|
51
|
+
GameStatePatch,
|
|
52
|
+
SseEndpointDef,
|
|
53
|
+
TopicRow,
|
|
54
|
+
TopicAssignmentRow,
|
|
55
|
+
TopicsResponse,
|
|
56
|
+
TopicDetailResponse,
|
|
57
|
+
} from "./game-types.js";
|
|
42
58
|
|
|
43
59
|
// ─── New Response Types (inline) ───────────────────────────────────────────
|
|
44
60
|
|
|
@@ -47,8 +63,8 @@ export type {
|
|
|
47
63
|
* so the launcher can detect stale servers from older builds.
|
|
48
64
|
*/
|
|
49
65
|
export interface VersionResponse {
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
/** Semver-style version string of the running dashboard server. */
|
|
67
|
+
readonly version: string;
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
/**
|
|
@@ -56,8 +72,11 @@ export interface VersionResponse {
|
|
|
56
72
|
* Used by GET /api/summary for lightweight header tiles.
|
|
57
73
|
*/
|
|
58
74
|
export type IndexSummary = Pick<
|
|
59
|
-
|
|
60
|
-
|
|
75
|
+
IndexesSummaryResponse,
|
|
76
|
+
| "totalRepos"
|
|
77
|
+
| "totalCheckpoints"
|
|
78
|
+
| "totalTokensSaved"
|
|
79
|
+
| "totalCompressedOriginalBytes"
|
|
61
80
|
>;
|
|
62
81
|
|
|
63
82
|
/**
|
|
@@ -65,12 +84,12 @@ export type IndexSummary = Pick<
|
|
|
65
84
|
* (no index.sqlite file or read error). All fields are null/empty.
|
|
66
85
|
*/
|
|
67
86
|
export interface IndexFallbackResponse {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
/** Always null — no index data available. */
|
|
88
|
+
readonly updatedAt: null;
|
|
89
|
+
/** Always null — no summary available. */
|
|
90
|
+
readonly summary: null;
|
|
91
|
+
/** Always an empty array — no repos registered. */
|
|
92
|
+
readonly repos: IndexesIndexRow[];
|
|
74
93
|
}
|
|
75
94
|
|
|
76
95
|
/**
|
|
@@ -78,8 +97,8 @@ export interface IndexFallbackResponse {
|
|
|
78
97
|
* seen within the last N hours (format: "<N>h", e.g. "24h").
|
|
79
98
|
*/
|
|
80
99
|
export interface ReposQuery {
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
/** Active-window filter in format "<hours>h" (e.g. "24h"). Optional. */
|
|
101
|
+
readonly active?: string;
|
|
83
102
|
}
|
|
84
103
|
|
|
85
104
|
/**
|
|
@@ -87,12 +106,12 @@ export interface ReposQuery {
|
|
|
87
106
|
* active-window filter applied.
|
|
88
107
|
*/
|
|
89
108
|
export interface ReposResponse {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
/** ISO timestamp of the last index update, or null if unavailable. */
|
|
110
|
+
readonly updatedAt: string | null;
|
|
111
|
+
/** Array of repo index rows. */
|
|
112
|
+
readonly repos: IndexesIndexRow[];
|
|
113
|
+
/** Number of repos in the response (after filtering). */
|
|
114
|
+
readonly count: number;
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
/**
|
|
@@ -100,51 +119,51 @@ export interface ReposResponse {
|
|
|
100
119
|
* repo list (keeps payload small for embed scenarios).
|
|
101
120
|
*/
|
|
102
121
|
export interface SummaryResponse {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
/** ISO timestamp of the last index update, or null if unavailable. */
|
|
123
|
+
readonly updatedAt: string | null;
|
|
124
|
+
/** Aggregate index summary, or null if no index exists. */
|
|
125
|
+
readonly summary: IndexSummary | null;
|
|
126
|
+
/** Number of repos active within the last 24 hours. */
|
|
127
|
+
readonly activeRepos: number;
|
|
128
|
+
/** Total number of repos in the registry. */
|
|
129
|
+
readonly totalRepos: number;
|
|
111
130
|
}
|
|
112
131
|
|
|
113
132
|
// ─── Drift Report Types ─────────────────────────────────────────────────────
|
|
114
133
|
|
|
115
134
|
/** Severity level for a drift signal. */
|
|
116
|
-
export type DriftSeverity =
|
|
135
|
+
export type DriftSeverity = "warn" | "info";
|
|
117
136
|
|
|
118
137
|
/**
|
|
119
138
|
* A single drift signal for a repo.
|
|
120
139
|
*/
|
|
121
140
|
export interface DriftSignal {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
/** The kind of drift detected. */
|
|
142
|
+
readonly kind: "stale" | "compaction_lag" | "model_churn";
|
|
143
|
+
/** Severity level of the signal. */
|
|
144
|
+
readonly severity: DriftSeverity;
|
|
145
|
+
/** Human-readable detail describing the drift. */
|
|
146
|
+
readonly detail: string;
|
|
128
147
|
}
|
|
129
148
|
|
|
130
149
|
/**
|
|
131
150
|
* Drift classification for a single repo.
|
|
132
151
|
*/
|
|
133
152
|
export interface RepoDrift {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
/** Absolute path to the repo root. */
|
|
154
|
+
readonly repoRoot: string;
|
|
155
|
+
/** Display name of the repo. */
|
|
156
|
+
readonly displayName: string;
|
|
157
|
+
/** Unix timestamp (seconds) of the last dashboard activity. */
|
|
158
|
+
readonly lastSeen: number;
|
|
159
|
+
/** Unix timestamp (seconds) of the last compaction, or null if never. */
|
|
160
|
+
readonly lastCompactedAt: number | null;
|
|
161
|
+
/** Unix timestamp (seconds) of the last model capture, or null. */
|
|
162
|
+
readonly modelCapturedAt: number | null;
|
|
163
|
+
/** Array of drift signals detected for this repo. */
|
|
164
|
+
readonly signals: DriftSignal[];
|
|
165
|
+
/** Highest severity across signals; "ok" if none. */
|
|
166
|
+
readonly status: "ok" | "warn";
|
|
148
167
|
}
|
|
149
168
|
|
|
150
169
|
/**
|
|
@@ -152,23 +171,23 @@ export interface RepoDrift {
|
|
|
152
171
|
* repo_registry, flagging stale repos, compaction lag, and model churn.
|
|
153
172
|
*/
|
|
154
173
|
export interface DriftReportResponse {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
/** Unix timestamp (seconds) when the report was generated. */
|
|
175
|
+
readonly generatedAt: number;
|
|
176
|
+
/** Aggregate counts by status/signal. */
|
|
177
|
+
readonly totals: {
|
|
178
|
+
/** Repos with no drift signals. */
|
|
179
|
+
readonly ok: number;
|
|
180
|
+
/** Repos with at least one warning signal. */
|
|
181
|
+
readonly warn: number;
|
|
182
|
+
/** Repos with the "stale" signal. */
|
|
183
|
+
readonly stale: number;
|
|
184
|
+
/** Repos with the "compaction_lag" signal. */
|
|
185
|
+
readonly compactionLag: number;
|
|
186
|
+
/** Repos with the "model_churn" signal. */
|
|
187
|
+
readonly modelChurn: number;
|
|
188
|
+
};
|
|
189
|
+
/** Per-repo drift classifications. */
|
|
190
|
+
readonly repos: RepoDrift[];
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
// ─── Servers Types ──────────────────────────────────────────────────────────
|
|
@@ -178,40 +197,49 @@ export interface DriftReportResponse {
|
|
|
178
197
|
* recently-active repo with its live dashboard snapshot data.
|
|
179
198
|
*/
|
|
180
199
|
export interface ServerEntry {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
200
|
+
/** Absolute path to the repo root. */
|
|
201
|
+
readonly repoRoot: string;
|
|
202
|
+
/** Display name of the repo. */
|
|
203
|
+
readonly displayName: string;
|
|
204
|
+
/** Model name, or null if not set. */
|
|
205
|
+
readonly model: string | null;
|
|
206
|
+
/** Provider display name, or null if not set. */
|
|
207
|
+
readonly provider: string | null;
|
|
208
|
+
/** Unix timestamp (seconds) of the last dashboard activity. */
|
|
209
|
+
readonly lastSeen: number;
|
|
210
|
+
/** Unix timestamp (seconds) of the last compaction, or null. */
|
|
211
|
+
readonly lastCompactedAt: number | null;
|
|
212
|
+
/** Current compaction tier, or null if no live snapshot. Present when a live dashboard.json exists. */
|
|
213
|
+
readonly tier?: string | null;
|
|
214
|
+
/** Current context pressure percentage (0–100), or null. Present when a live snapshot has context data. */
|
|
215
|
+
readonly contextPct?: number | null;
|
|
216
|
+
/** Current session state string, or null. Present when a live snapshot has session data. */
|
|
217
|
+
readonly state?: string | null;
|
|
218
|
+
/** Cache hit counters from the live snapshot, or null. Present when a live snapshot has cacheHits. */
|
|
219
|
+
readonly cacheHits?: {
|
|
220
|
+
readonly session: number;
|
|
221
|
+
readonly total: number;
|
|
222
|
+
readonly sessionTokensSaved: number;
|
|
223
|
+
readonly totalTokensSaved: number;
|
|
224
|
+
} | null;
|
|
225
|
+
/** Compaction counters from the live snapshot, or null. Present when a live snapshot has compacts. */
|
|
226
|
+
readonly compacts?: {
|
|
227
|
+
readonly session: number;
|
|
228
|
+
readonly total: number;
|
|
229
|
+
} | null;
|
|
230
|
+
/** Time saved counters from the live snapshot, or null. Present when a live snapshot has timeSaved. */
|
|
231
|
+
readonly timeSaved?: {
|
|
232
|
+
readonly compact: {
|
|
233
|
+
readonly sessionSec: number;
|
|
234
|
+
readonly totalSec: number;
|
|
235
|
+
};
|
|
236
|
+
readonly cacheHit: {
|
|
237
|
+
readonly sessionSec: number;
|
|
238
|
+
readonly totalSec: number;
|
|
239
|
+
};
|
|
240
|
+
} | null;
|
|
241
|
+
/** ISO timestamp of the live snapshot, or null. Present when a live snapshot has updatedAt. */
|
|
242
|
+
readonly updatedAt?: string | null;
|
|
215
243
|
}
|
|
216
244
|
|
|
217
245
|
/**
|
|
@@ -219,58 +247,58 @@ export interface ServerEntry {
|
|
|
219
247
|
* live snapshot data.
|
|
220
248
|
*/
|
|
221
249
|
export interface ServersResponse {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
250
|
+
/** ISO timestamp when the response was generated. */
|
|
251
|
+
readonly updatedAt: string;
|
|
252
|
+
/** Array of server entries, sorted by lastSeen descending. */
|
|
253
|
+
readonly servers: ServerEntry[];
|
|
226
254
|
}
|
|
227
255
|
|
|
228
256
|
// ─── Perf Types ─────────────────────────────────────────────────────────────
|
|
229
257
|
|
|
230
258
|
/** Percentile statistics for a latency metric (in milliseconds). */
|
|
231
259
|
export interface PerfPercentile {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
260
|
+
/** 50th percentile (median) in milliseconds. */
|
|
261
|
+
readonly p50: number;
|
|
262
|
+
/** 95th percentile in milliseconds. */
|
|
263
|
+
readonly p95: number;
|
|
264
|
+
/** Number of samples in the window. */
|
|
265
|
+
readonly n: number;
|
|
238
266
|
}
|
|
239
267
|
|
|
240
268
|
/** Average statistics for a rate metric. */
|
|
241
269
|
export interface PerfAverage {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
270
|
+
/** Average value across all samples in the window. */
|
|
271
|
+
readonly avg: number;
|
|
272
|
+
/** Number of samples in the window. */
|
|
273
|
+
readonly n: number;
|
|
246
274
|
}
|
|
247
275
|
|
|
248
276
|
/** Latest-value statistics for a gauge metric. */
|
|
249
277
|
export interface PerfLatest {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
278
|
+
/** Most recent value in the window. */
|
|
279
|
+
readonly latest: number;
|
|
280
|
+
/** Number of samples in the window. */
|
|
281
|
+
readonly n: number;
|
|
254
282
|
}
|
|
255
283
|
|
|
256
284
|
/** Average + latest statistics for cache hit percentage. */
|
|
257
285
|
export interface PerfCacheHit {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
286
|
+
/** Average cache hit percentage (0–100). */
|
|
287
|
+
readonly avg: number;
|
|
288
|
+
/** Most recent cache hit percentage (0–100). */
|
|
289
|
+
readonly latest: number;
|
|
290
|
+
/** Number of samples in the window. */
|
|
291
|
+
readonly n: number;
|
|
264
292
|
}
|
|
265
293
|
|
|
266
294
|
/** Diagnostic counters from the live dashboard snapshot. */
|
|
267
295
|
export interface PerfDiag {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
296
|
+
/** Number of fast-gate context trim fires. */
|
|
297
|
+
readonly ctxFastGate: number;
|
|
298
|
+
/** Number of live trim fires. */
|
|
299
|
+
readonly liveTrimFires: number;
|
|
300
|
+
/** Number of live trim replays. */
|
|
301
|
+
readonly liveTrimReplays: number;
|
|
274
302
|
}
|
|
275
303
|
|
|
276
304
|
/**
|
|
@@ -278,8 +306,8 @@ export interface PerfDiag {
|
|
|
278
306
|
* rolling window size.
|
|
279
307
|
*/
|
|
280
308
|
export interface PerfQuery {
|
|
281
|
-
|
|
282
|
-
|
|
309
|
+
/** Rolling window size in minutes (default: 30, max: 1440). Optional. */
|
|
310
|
+
readonly minutes?: number;
|
|
283
311
|
}
|
|
284
312
|
|
|
285
313
|
/**
|
|
@@ -287,34 +315,34 @@ export interface PerfQuery {
|
|
|
287
315
|
* with per-kind p50/p95, latest rss/heap, cpu counters, and diagnostic data.
|
|
288
316
|
*/
|
|
289
317
|
export interface PerfResponse {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
/** ISO timestamp when the response was generated. */
|
|
319
|
+
readonly updatedAt: string;
|
|
320
|
+
/** Rolling window size in minutes. */
|
|
321
|
+
readonly windowMinutes: number;
|
|
322
|
+
/** Total number of perf samples in the window. */
|
|
323
|
+
readonly sampleCount: number;
|
|
324
|
+
/** Turn latency statistics in milliseconds. */
|
|
325
|
+
readonly turn_latency_ms: PerfPercentile;
|
|
326
|
+
/** Provider latency statistics in milliseconds. */
|
|
327
|
+
readonly provider_latency_ms: PerfPercentile;
|
|
328
|
+
/** Tokens-per-second statistics. */
|
|
329
|
+
readonly tps: PerfAverage;
|
|
330
|
+
/** Cache hit percentage statistics. */
|
|
331
|
+
readonly cache_hit_pct: PerfCacheHit;
|
|
332
|
+
/** Database recompute duration statistics in milliseconds. */
|
|
333
|
+
readonly db_recompute_ms: PerfPercentile;
|
|
334
|
+
/** Disk write duration statistics in milliseconds. */
|
|
335
|
+
readonly disk_write_ms: PerfPercentile;
|
|
336
|
+
/** RSS memory usage in MB (latest value). */
|
|
337
|
+
readonly rss_mb: PerfLatest;
|
|
338
|
+
/** Heap memory usage in MB (latest value). */
|
|
339
|
+
readonly heap_mb: PerfLatest;
|
|
340
|
+
/** CPU user time in milliseconds (latest value). */
|
|
341
|
+
readonly cpu_user_ms: PerfLatest;
|
|
342
|
+
/** CPU system time in milliseconds (latest value). */
|
|
343
|
+
readonly cpu_sys_ms: PerfLatest;
|
|
344
|
+
/** Diagnostic counters from the live snapshot, or null if unavailable. */
|
|
345
|
+
readonly diag: PerfDiag | null;
|
|
318
346
|
}
|
|
319
347
|
|
|
320
348
|
// ─── Game Score & Achievement Types ─────────────────────────────────────────
|
|
@@ -329,7 +357,6 @@ export interface PerfResponse {
|
|
|
329
357
|
// ─── SSE Endpoint Definition ────────────────────────────────────────────────
|
|
330
358
|
// (moved to game-types.ts; re-exported for backwards compatibility)
|
|
331
359
|
|
|
332
|
-
|
|
333
360
|
// ─── ENDPOINTS Registry ─────────────────────────────────────────────────────
|
|
334
361
|
|
|
335
362
|
/**
|
|
@@ -344,110 +371,186 @@ export interface PerfResponse {
|
|
|
344
371
|
* ENDPOINTS.snapshot.method // 'GET'
|
|
345
372
|
*/
|
|
346
373
|
export const ENDPOINTS = {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
374
|
+
/** GET /api/snapshot — Full session, store, compression, and context snapshot. */
|
|
375
|
+
snapshot: {
|
|
376
|
+
method: "GET",
|
|
377
|
+
path: "/api/snapshot",
|
|
378
|
+
description: "Full session, store, compression, and context snapshot.",
|
|
379
|
+
} as const satisfies EndpointDef<"GET", undefined, SnapshotResponse>,
|
|
380
|
+
|
|
381
|
+
/** GET /api/version — Dashboard server version string. */
|
|
382
|
+
version: {
|
|
383
|
+
method: "GET",
|
|
384
|
+
path: "/api/version",
|
|
385
|
+
description: "Dashboard server version for stale-server detection.",
|
|
386
|
+
} as const satisfies EndpointDef<"GET", undefined, VersionResponse>,
|
|
387
|
+
|
|
388
|
+
/** GET /api/index — Multi-repo aggregate index (or fallback when unavailable). */
|
|
389
|
+
index: {
|
|
390
|
+
method: "GET",
|
|
391
|
+
path: "/api/index",
|
|
392
|
+
description:
|
|
393
|
+
"Machine-wide multi-repo registry with checkpoints, tokens, and model info.",
|
|
394
|
+
} as const satisfies EndpointDef<
|
|
395
|
+
"GET",
|
|
396
|
+
undefined,
|
|
397
|
+
IndexesSummaryResponse | IndexFallbackResponse
|
|
398
|
+
>,
|
|
399
|
+
|
|
400
|
+
/** GET /api/repos — Registry list with optional active-window filter. */
|
|
401
|
+
repos: {
|
|
402
|
+
method: "GET",
|
|
403
|
+
path: "/api/repos",
|
|
404
|
+
description: "Repo registry list, optionally filtered by recent activity.",
|
|
405
|
+
} as const satisfies EndpointDef<"GET", ReposQuery, ReposResponse>,
|
|
406
|
+
|
|
407
|
+
/** GET /api/summary — Lightweight header tiles without the full repo list. */
|
|
408
|
+
summary: {
|
|
409
|
+
method: "GET",
|
|
410
|
+
path: "/api/summary",
|
|
411
|
+
description:
|
|
412
|
+
"Aggregate summary with active/total repo counts (no repo list).",
|
|
413
|
+
} as const satisfies EndpointDef<"GET", undefined, SummaryResponse>,
|
|
414
|
+
|
|
415
|
+
/** GET /api/drift — Cross-repo drift report. */
|
|
416
|
+
drift: {
|
|
417
|
+
method: "GET",
|
|
418
|
+
path: "/api/drift",
|
|
419
|
+
description:
|
|
420
|
+
"Cross-repo drift report flagging stale repos, compaction lag, and model churn.",
|
|
421
|
+
} as const satisfies EndpointDef<"GET", undefined, DriftReportResponse>,
|
|
422
|
+
|
|
423
|
+
/** GET /api/servers — Recently-active repo servers with live snapshot data. */
|
|
424
|
+
servers: {
|
|
425
|
+
method: "GET",
|
|
426
|
+
path: "/api/servers",
|
|
427
|
+
description: "Recently-active repo servers with live snapshot data.",
|
|
428
|
+
} as const satisfies EndpointDef<"GET", undefined, ServersResponse>,
|
|
429
|
+
|
|
430
|
+
/** GET /api/events — SSE stream of dashboard events. */
|
|
431
|
+
events: {
|
|
432
|
+
type: "sse",
|
|
433
|
+
method: "GET",
|
|
434
|
+
path: "/api/events",
|
|
435
|
+
description: "Server-Sent Events stream of all dashboard events.",
|
|
436
|
+
event: "data",
|
|
437
|
+
} as const satisfies SseEndpointDef<SseEvent>,
|
|
438
|
+
|
|
439
|
+
/** GET /api/game-state — Current game-mode settings. */
|
|
440
|
+
getGameState: {
|
|
441
|
+
method: "GET",
|
|
442
|
+
path: "/api/game-state",
|
|
443
|
+
description: "Current game-mode configuration and active ritual state.",
|
|
444
|
+
} as const satisfies EndpointDef<"GET", undefined, GameStateResponse>,
|
|
445
|
+
|
|
446
|
+
/** PUT /api/game-state — Apply a partial patch to game-mode settings. */
|
|
447
|
+
putGameState: {
|
|
448
|
+
method: "PUT",
|
|
449
|
+
path: "/api/game-state",
|
|
450
|
+
description:
|
|
451
|
+
"Apply a partial patch to game-mode settings and return the updated state.",
|
|
452
|
+
} as const satisfies EndpointDef<"PUT", GameStatePatch, GameStateResponse>,
|
|
453
|
+
|
|
454
|
+
/** GET /api/game-scores — High-score leaderboard for a metric. */
|
|
455
|
+
gameScores: {
|
|
456
|
+
method: "GET",
|
|
457
|
+
path: "/api/game-scores",
|
|
458
|
+
description: "High-score leaderboard for a game metric.",
|
|
459
|
+
} as const satisfies EndpointDef<"GET", GameScoresQuery, GameScoreRow[]>,
|
|
460
|
+
|
|
461
|
+
/** GET /api/perf — Rolling-window performance aggregates. */
|
|
462
|
+
perf: {
|
|
463
|
+
method: "GET",
|
|
464
|
+
path: "/api/perf",
|
|
465
|
+
description: "Rolling-window performance aggregates over perf_samples.",
|
|
466
|
+
} as const satisfies EndpointDef<"GET", PerfQuery, PerfResponse>,
|
|
467
|
+
|
|
468
|
+
/** GET /api/achievements — Achievement tiles with unlock state. */
|
|
469
|
+
achievements: {
|
|
470
|
+
method: "GET",
|
|
471
|
+
path: "/api/achievements",
|
|
472
|
+
description: "All achievement rows with unlock state.",
|
|
473
|
+
} as const satisfies EndpointDef<"GET", undefined, AchievementRow[]>,
|
|
474
|
+
|
|
475
|
+
/** GET /api/sessions — Active sessions with latest token usage (S39). */
|
|
476
|
+
sessions: {
|
|
477
|
+
method: "GET",
|
|
478
|
+
path: "/api/sessions",
|
|
479
|
+
description: "Active pi sessions with latest token usage + heartbeat.",
|
|
480
|
+
} as const satisfies EndpointDef<"GET", undefined, SessionsResponse>,
|
|
481
|
+
|
|
482
|
+
/** GET /api/sessions/timeseries — Stacked per-session token timeseries (S39). */
|
|
483
|
+
sessionTimeseries: {
|
|
484
|
+
method: "GET",
|
|
485
|
+
path: "/api/sessions/timeseries",
|
|
486
|
+
description:
|
|
487
|
+
"Recharts-ready per-session token timeseries for the stacked memory graph.",
|
|
488
|
+
} as const satisfies EndpointDef<
|
|
489
|
+
"GET",
|
|
490
|
+
SessionTimeseriesQuery,
|
|
491
|
+
SessionTimeseriesResponse
|
|
492
|
+
>,
|
|
493
|
+
|
|
494
|
+
/** GET /api/topics — Auto-categorizing wiki topics (S51). */
|
|
495
|
+
topics: {
|
|
496
|
+
method: "GET",
|
|
497
|
+
path: "/api/topics",
|
|
498
|
+
description:
|
|
499
|
+
"Auto-categorized wiki topics from k-means + TF-IDF over real embeddings.",
|
|
500
|
+
} as const satisfies EndpointDef<"GET", undefined, TopicsResponse>,
|
|
501
|
+
|
|
502
|
+
/** GET /api/turns — Turn-by-turn memory tracking + recall (S52). */
|
|
503
|
+
turns: {
|
|
504
|
+
method: "GET",
|
|
505
|
+
path: "/api/turns",
|
|
506
|
+
description:
|
|
507
|
+
"Per-conversation turn list with recall + epoch provenance (turn-by-turn memory tracking).",
|
|
508
|
+
} as const satisfies EndpointDef<"GET", undefined, TurnsResponse>,
|
|
509
|
+
|
|
510
|
+
/** GET /api/turns/conversation/:convId — per-turn detail + recall hits. */
|
|
511
|
+
conversationTurns: {
|
|
512
|
+
method: "GET",
|
|
513
|
+
path: "/api/turns/conversation/:convId",
|
|
514
|
+
description:
|
|
515
|
+
"Per-turn metrics + injected-checkpoint recall provenance for one conversation.",
|
|
516
|
+
} as const satisfies EndpointDef<"GET", undefined, ConversationTurnsResponse>,
|
|
517
|
+
|
|
518
|
+
/** GET /api/turns/intents — pending rewind intents (S52A). */
|
|
519
|
+
turnIntents: {
|
|
520
|
+
method: "GET",
|
|
521
|
+
path: "/api/turns/intents",
|
|
522
|
+
description:
|
|
523
|
+
"Pending rewind intents queued by the dashboard for the host to consume.",
|
|
524
|
+
} as const satisfies EndpointDef<"GET", undefined, RewindIntentsResponse>,
|
|
525
|
+
|
|
526
|
+
/** POST /api/turns/intent — post a rewind intent. */
|
|
527
|
+
postTurnIntent: {
|
|
528
|
+
method: "POST",
|
|
529
|
+
path: "/api/turns/intent",
|
|
530
|
+
description:
|
|
531
|
+
"Queue a rewind-to-turn-N intent for the host to apply at before_agent_start.",
|
|
532
|
+
} as const satisfies EndpointDef<"POST", PostIntentRequest, unknown>,
|
|
533
|
+
|
|
534
|
+
/** POST /api/fork — fork a conversation at a turn. */
|
|
535
|
+
fork: {
|
|
536
|
+
method: "POST",
|
|
537
|
+
path: "/api/fork",
|
|
538
|
+
description:
|
|
539
|
+
"Branch a child conversation off a parent turn + return the recall set to rehydrate.",
|
|
540
|
+
} as const satisfies EndpointDef<"POST", ForkRequest, ForkResponse>,
|
|
541
|
+
|
|
542
|
+
/** POST /api/turns/prune — admin prune (capability-gated). */
|
|
543
|
+
pruneTurns: {
|
|
544
|
+
method: "POST",
|
|
545
|
+
path: "/api/turns/prune",
|
|
546
|
+
description:
|
|
547
|
+
"Prune old turns (admin capability — dashboard uses asAdmin()).",
|
|
548
|
+
} as const satisfies EndpointDef<"POST", PruneRequest, PruneTurnsResponse>,
|
|
549
|
+
|
|
550
|
+
/** GET /api/topics/:topicId/memories — wiki topic drill-down (S52). */
|
|
551
|
+
topicMemories: {
|
|
552
|
+
method: "GET",
|
|
553
|
+
path: "/api/topics/:topicId/memories",
|
|
554
|
+
description: "Member memories assigned to a wiki topic (drill-down).",
|
|
555
|
+
} as const satisfies EndpointDef<"GET", undefined, TopicMemoriesResponse>,
|
|
453
556
|
} as const;
|