pi-mega-compact 0.11.4 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/dashboard-server/api-contracts/cache-stripes.js +8 -0
- package/dist/extensions/dashboard-server/api-contracts/endpoints.js +32 -0
- package/dist/extensions/dashboard-server/api-contracts/memory-map.js +1 -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 +135 -47
- package/dist/extensions/dashboard-server/routes-game.js +3 -0
- package/dist/extensions/dashboard-server/routes-memory-map.js +50 -0
- 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 +267 -0
- package/dist/extensions/dashboard-server/routes.js +4 -0
- package/dist/extensions/dashboard-server/server.js +13 -1
- package/dist/extensions/mega-commands.js +189 -1
- package/dist/extensions/mega-compact.js +5 -0
- package/dist/extensions/mega-config.js +7 -0
- package/dist/extensions/mega-events/agent-handlers.js +19 -4
- package/dist/extensions/mega-events/compact-handlers.js +1 -0
- package/dist/extensions/mega-events/context-handler.js +45 -92
- package/dist/extensions/mega-events/context-hwm.js +51 -0
- package/dist/extensions/mega-events/error-classifier.js +16 -5
- package/dist/extensions/mega-events/mirror-append.js +107 -0
- package/dist/extensions/mega-events/outage-advisor.js +7 -1
- package/dist/extensions/mega-events/perf-handler.js +134 -2
- package/dist/extensions/mega-events/recall-tail.js +59 -0
- package/dist/extensions/mega-events/separated-prompt.js +248 -0
- package/dist/extensions/mega-events/session-handlers.js +15 -8
- package/dist/extensions/mega-runtime/env-loader.js +56 -0
- package/dist/extensions/mega-runtime/reset-runtime.js +6 -0
- package/dist/extensions/mega-runtime/runtime-snapshot.js +1 -0
- package/dist/extensions/mega-runtime/runtime.js +7 -0
- package/dist/extensions/mega-runtime/snapshot.js +1 -0
- package/dist/extensions/mega-runtime/widget.js +5 -0
- package/dist/src/cache-stripe-impl.js +288 -0
- package/dist/src/cache-stripe.js +11 -0
- package/dist/src/config/stopwords.js +24 -0
- package/dist/src/config.js +17 -0
- package/dist/src/embedder.js +41 -2
- package/dist/src/memoryGraph.js +299 -0
- package/dist/src/memoryStats.js +75 -0
- package/dist/src/monitoring.js +13 -0
- package/dist/src/prefix-break.js +43 -0
- package/dist/src/pricing.js +1 -1
- package/dist/src/queryExpansion.js +163 -0
- package/dist/src/queryReformulation/cache.js +123 -0
- package/dist/src/queryReformulation/rrf.js +29 -0
- package/dist/src/queryReformulation/tfidf.js +61 -0
- package/dist/src/queryReformulation/vagueness.js +33 -0
- package/dist/src/queryReformulation.js +225 -0
- package/dist/src/recallMetrics.js +258 -0
- package/dist/src/store/sqlite/cache-stripes.js +133 -0
- package/dist/src/store/sqlite/fts5-search.js +68 -0
- package/dist/src/store/sqlite/perf-samples.js +145 -16
- package/dist/src/store/sqlite/schema.js +60 -1
- package/dist/src/store/sqlite.js +1 -0
- 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 +55 -10
- package/dist/src/tiered-router/types.js +18 -0
- package/dist/src/tieredRouter.js +421 -0
- package/dist/src/vectorStore.js +8 -6
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js → AchievementTiles-DR9cLGDL.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js.map → AchievementTiles-DR9cLGDL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/AchievementsTab-svNUgJ1e.js +2 -0
- package/extensions/dashboard-client/dist/assets/{AchievementsTab-DjxfYrDc.js.map → AchievementsTab-svNUgJ1e.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/CacheTab-ASwhOMjR.js +2 -0
- package/extensions/dashboard-client/dist/assets/CacheTab-ASwhOMjR.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js → ConfigTab-CmmWheuW.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js.map → ConfigTab-CmmWheuW.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js → EventsTab-CFE7jLsa.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js.map → EventsTab-CFE7jLsa.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/GameTab-CJAX_th_.js +2 -0
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js.map → GameTab-CJAX_th_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js → MaintenanceTab-P4SUsvMf.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js.map → MaintenanceTab-P4SUsvMf.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/MemoryMapTab-BBiH76eF.js +2 -0
- package/extensions/dashboard-client/dist/assets/MemoryMapTab-BBiH76eF.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js → MetricsTab-CHQscixy.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js.map → MetricsTab-CHQscixy.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-DBs4DJdd.js +2 -0
- package/extensions/dashboard-client/dist/assets/{OverviewTab-D4kGvsiQ.js.map → OverviewTab-DBs4DJdd.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/ReposTab-DeFz76L5.js +2 -0
- package/extensions/dashboard-client/dist/assets/ReposTab-DeFz76L5.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js → SessionsTab-BWNsj1OB.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js.map → SessionsTab-BWNsj1OB.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-uS6A0xmw.js +2 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-uS6A0xmw.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-CiqCOQuL.js +2 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-CiqCOQuL.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js → TopicsTab-BWWQxltv.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js.map → TopicsTab-BWWQxltv.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js → TurnsTab-CVz4f4-o.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js.map → TurnsTab-CVz4f4-o.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-CUNn22iV.css +1 -0
- package/extensions/dashboard-client/dist/assets/index-DrktNOoT.js +42 -0
- package/extensions/dashboard-client/dist/assets/index-DrktNOoT.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-Bf5LOLSi.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js.map → useSSE-Bf5LOLSi.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +2 -2
- package/extensions/dashboard-client/src/App.tsx +28 -8
- package/extensions/dashboard-client/src/api/client.ts +29 -0
- package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +21 -12
- package/extensions/dashboard-client/src/components/CacheHitRateTrendCard.tsx +100 -0
- 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/components/StripeDistributionCard.tsx +110 -0
- package/extensions/dashboard-client/src/components/TabBar.tsx +49 -4
- package/extensions/dashboard-client/src/main.tsx +1 -0
- package/extensions/dashboard-client/src/styles/base.css +30 -0
- package/extensions/dashboard-client/src/styles/cache.css +167 -0
- package/extensions/dashboard-client/src/tabs/CacheTab.tsx +75 -12
- package/extensions/dashboard-client/src/tabs/MemoryMapTab.tsx +440 -0
- package/extensions/dashboard-client/src/tabs/SetupTab.tsx +418 -0
- package/extensions/dashboard-client/tsconfig.json +3 -2
- package/extensions/dashboard-client/vite.config.ts +2 -0
- package/extensions/dashboard-server/api-contracts/cache-stripes.ts +49 -0
- package/extensions/dashboard-server/api-contracts/endpoints.ts +66 -3
- package/extensions/dashboard-server/api-contracts/index.ts +22 -0
- package/extensions/dashboard-server/api-contracts/memory-map.ts +50 -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 +80 -0
- package/extensions/dashboard-server/index-reader.ts +138 -121
- package/extensions/dashboard-server/routes-cache.ts +186 -75
- package/extensions/dashboard-server/routes-game.ts +3 -0
- package/extensions/dashboard-server/routes-memory-map.ts +105 -0
- 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 +293 -0
- package/extensions/dashboard-server/routes.ts +4 -0
- package/extensions/dashboard-server/server.ts +12 -0
- package/extensions/mega-commands.ts +211 -1
- package/extensions/mega-compact.ts +5 -0
- package/extensions/mega-config.ts +27 -0
- package/extensions/mega-events/agent-handlers.ts +20 -4
- package/extensions/mega-events/compact-handlers.ts +1 -0
- package/extensions/mega-events/context-handler.ts +53 -110
- package/extensions/mega-events/context-hwm.ts +85 -0
- package/extensions/mega-events/error-classifier.ts +15 -4
- package/extensions/mega-events/mirror-append.ts +155 -0
- package/extensions/mega-events/outage-advisor.ts +11 -5
- package/extensions/mega-events/perf-handler.ts +190 -6
- package/extensions/mega-events/recall-tail.ts +88 -0
- package/extensions/mega-events/separated-prompt.ts +329 -0
- package/extensions/mega-events/session-handlers.ts +14 -7
- package/extensions/mega-runtime/env-loader.ts +55 -0
- package/extensions/mega-runtime/helpers.ts +14 -0
- package/extensions/mega-runtime/reset-runtime.ts +6 -0
- package/extensions/mega-runtime/runtime-snapshot.ts +1 -0
- package/extensions/mega-runtime/runtime.ts +7 -0
- package/extensions/mega-runtime/snapshot.ts +6 -0
- package/extensions/mega-runtime/widget-types.ts +3 -0
- package/extensions/mega-runtime/widget.ts +5 -0
- package/package.json +5 -2
- package/src/cache-stripe-impl.ts +385 -0
- package/src/cache-stripe.ts +18 -0
- package/src/config/stopwords.ts +25 -0
- package/src/config.ts +26 -0
- package/src/embedder.ts +42 -2
- package/src/memoryGraph.ts +438 -0
- package/src/memoryStats.ts +107 -0
- package/src/monitoring.ts +35 -0
- package/src/prefix-break.ts +83 -0
- package/src/pricing.ts +2 -2
- package/src/queryExpansion.ts +206 -0
- package/src/queryReformulation/cache.ts +169 -0
- package/src/queryReformulation/rrf.ts +51 -0
- package/src/queryReformulation/tfidf.ts +79 -0
- package/src/queryReformulation/vagueness.ts +38 -0
- package/src/queryReformulation.ts +355 -0
- package/src/recallMetrics.ts +388 -0
- package/src/store/sqlite/cache-stripes.ts +196 -0
- package/src/store/sqlite/fts5-search.ts +90 -0
- package/src/store/sqlite/perf-samples.ts +218 -23
- package/src/store/sqlite/schema.ts +60 -1
- package/src/store/sqlite.ts +1 -0
- 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 +71 -11
- package/src/tiered-router/types.ts +64 -0
- package/src/tieredRouter.ts +489 -0
- package/src/vectorStore.ts +9 -5
- 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 -1383
- 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/GameTab-BLDudcO5.js +0 -2
- 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-BEdKlpAB.css +0 -1
- package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js +0 -42
- 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 -1433
- 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
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* extensions/mega-events/separated-prompt.ts — A1+A2 PLAN_V2 Phase 2+3
|
|
3
|
+
* Message Separation + Cache-Optimized Prompt Builder:
|
|
4
|
+
* - buildSeparatedPrompt(): Basic 4-layer message separation (Phase 2).
|
|
5
|
+
* - buildCacheOptimizedPrompt(): Insert Layer 2 (vector-optimized stable
|
|
6
|
+
* context) between summary (Layer 1) and thread (Layer 3), ordered by
|
|
7
|
+
* stripe stability DESC (Phase 3).
|
|
8
|
+
* - detectTopicShift(): Cosine-similarity-based topic-shift detection.
|
|
9
|
+
* - cosineSimilarity(): cosine similarity of two Float32Array embeddings.
|
|
10
|
+
*
|
|
11
|
+
* Layer order (Phase 3): 0 (system) -> 1 (summary) -> 2 (cache stripes) ->
|
|
12
|
+
* 3 (thread: user/assistant turns) -> 4 (tool results at tail).
|
|
13
|
+
*
|
|
14
|
+
* Feature-gated by MEGACOMPACT_CACHE_STRIPING (default OFF).
|
|
15
|
+
* MEGACOMPACT_MESSAGE_SEPARATION must also be ON for any layering to occur.
|
|
16
|
+
* Flag-OFF = byte-identical to pre-sprint — returns messages unchanged.
|
|
17
|
+
*/
|
|
18
|
+
import { openStore } from "../../src/store/sqlite/utils.js";
|
|
19
|
+
import { getStateDir } from "../../src/store.js";
|
|
20
|
+
// ─── Constants ───────────────────────────────────────────────────────────────
|
|
21
|
+
/** Default stripe limit: top 10 most stable chunks. */
|
|
22
|
+
const DEFAULT_STRIPE_LIMIT = 10;
|
|
23
|
+
/** Topic-shift threshold: similarity below this triggers a stripe refresh. */
|
|
24
|
+
const TOPIC_SHIFT_THRESHOLD = 0.7;
|
|
25
|
+
// ─── Build separated prompt (Phase 2) ────────────────────────────────────────
|
|
26
|
+
/**
|
|
27
|
+
* Reorganize messages into stable layers for better prompt caching.
|
|
28
|
+
*
|
|
29
|
+
* Layer order: 0 (system) -> 1 (summary) -> 3 (thread: user/assistant turns) ->
|
|
30
|
+
* 4 (tool results at tail).
|
|
31
|
+
*
|
|
32
|
+
* Feature gate: MEGACOMPACT_MESSAGE_SEPARATION env var. When OFF (default),
|
|
33
|
+
* returns `messages` unchanged (byte-identical to pre-sprint).
|
|
34
|
+
*/
|
|
35
|
+
export function buildSeparatedPrompt(messages, _opts) {
|
|
36
|
+
const flag = process.env.MEGACOMPACT_MESSAGE_SEPARATION;
|
|
37
|
+
if (flag === "0" || flag === "false" || flag === undefined || flag === "") {
|
|
38
|
+
return messages;
|
|
39
|
+
}
|
|
40
|
+
// pi's AgentMessage union has no "system" role — the system prompt lives in
|
|
41
|
+
// AgentState.systemPrompt, separate from this array. The cache-relevant,
|
|
42
|
+
// low-risk transformation is moving volatile tool results/executions to the
|
|
43
|
+
// tail so the stable prefix (user/assistant/summaries/custom) stays contiguous.
|
|
44
|
+
// Discriminate by role only — never reach into `.content`/`.tool_calls`,
|
|
45
|
+
// which are variant-specific and require narrowing.
|
|
46
|
+
const main = [];
|
|
47
|
+
const tail = [];
|
|
48
|
+
for (const m of messages) {
|
|
49
|
+
if (m.role === "toolResult" || m.role === "bashExecution") {
|
|
50
|
+
tail.push(m);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
main.push(m);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (tail.length === 0)
|
|
57
|
+
return messages; // nothing to reorder — byte-identical
|
|
58
|
+
return [...main, ...tail];
|
|
59
|
+
}
|
|
60
|
+
// ─── Cosine similarity ───────────────────────────────────────────────────────
|
|
61
|
+
/**
|
|
62
|
+
* Compute cosine similarity between two Float32Array embeddings.
|
|
63
|
+
* Returns a value in [0, 1] where 1 = identical direction.
|
|
64
|
+
* Returns 0 if either vector is zero or inputs are mismatched.
|
|
65
|
+
*/
|
|
66
|
+
export function cosineSimilarity(a, b) {
|
|
67
|
+
if (a.length !== b.length || a.length === 0)
|
|
68
|
+
return 0;
|
|
69
|
+
let dot = 0;
|
|
70
|
+
let normA = 0;
|
|
71
|
+
let normB = 0;
|
|
72
|
+
for (let i = 0; i < a.length; i++) {
|
|
73
|
+
dot += a[i] * b[i];
|
|
74
|
+
normA += a[i] * a[i];
|
|
75
|
+
normB += b[i] * b[i];
|
|
76
|
+
}
|
|
77
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
78
|
+
if (denom === 0)
|
|
79
|
+
return 0;
|
|
80
|
+
return dot / denom;
|
|
81
|
+
}
|
|
82
|
+
// ─── Buffer ↔ Float32Array helpers ───────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* Decode a Float32Array from a Buffer (little-endian float32 blob).
|
|
85
|
+
* Returns null on empty/undefined input.
|
|
86
|
+
*/
|
|
87
|
+
export function decodeEmbeddingBlob(buf) {
|
|
88
|
+
if (!buf || buf.length === 0)
|
|
89
|
+
return null;
|
|
90
|
+
return new Float32Array(buf.buffer, buf.byteOffset, buf.byteLength / 4);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Encode a Float32Array into a Buffer for DB storage.
|
|
94
|
+
*/
|
|
95
|
+
export function encodeEmbeddingBlob(vec) {
|
|
96
|
+
return Buffer.from(vec.buffer, vec.byteOffset, vec.byteLength);
|
|
97
|
+
}
|
|
98
|
+
// ─── Topic-shift detection ───────────────────────────────────────────────────
|
|
99
|
+
/**
|
|
100
|
+
* Detect whether the conversation topic has shifted between the current turn
|
|
101
|
+
* and the previous turn. Uses cosine similarity between topic embeddings.
|
|
102
|
+
*
|
|
103
|
+
* Returns `true` when similarity < TOPIC_SHIFT_THRESHOLD (0.7), meaning the
|
|
104
|
+
* stable cache prefix may need reordering.
|
|
105
|
+
*
|
|
106
|
+
* Returns `false` (no shift) when either embedding is missing.
|
|
107
|
+
*/
|
|
108
|
+
export function detectTopicShift(currentEmb, previousEmb) {
|
|
109
|
+
if (!currentEmb || !previousEmb)
|
|
110
|
+
return false;
|
|
111
|
+
return cosineSimilarity(currentEmb, previousEmb) < TOPIC_SHIFT_THRESHOLD;
|
|
112
|
+
}
|
|
113
|
+
// ─── Load embeddings from store ──────────────────────────────────────────────
|
|
114
|
+
/**
|
|
115
|
+
* Load the topic embedding for a given turn from the embedding_cache table.
|
|
116
|
+
* Returns null if no embedding is stored for that turn.
|
|
117
|
+
*/
|
|
118
|
+
export function loadTopicEmbedding(stateDir, conversationId, turnIndex) {
|
|
119
|
+
const db = openStore(stateDir);
|
|
120
|
+
try {
|
|
121
|
+
const row = db.prepare(`SELECT embedding FROM embedding_cache WHERE content_hash = ?`).get(`topic:${conversationId}:${turnIndex}`);
|
|
122
|
+
if (!row)
|
|
123
|
+
return null;
|
|
124
|
+
return decodeEmbeddingBlob(row.embedding);
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
db.close();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Store a topic embedding for a given turn in the embedding_cache table.
|
|
132
|
+
* Idempotent (INSERT OR REPLACE).
|
|
133
|
+
*/
|
|
134
|
+
export function storeTopicEmbedding(stateDir, conversationId, turnIndex, embedding) {
|
|
135
|
+
const db = openStore(stateDir);
|
|
136
|
+
try {
|
|
137
|
+
const contentHash = `topic:${conversationId}:${turnIndex}`;
|
|
138
|
+
const blob = encodeEmbeddingBlob(embedding);
|
|
139
|
+
db.prepare(`INSERT OR REPLACE INTO embedding_cache (content_hash, embedding, computed_at) VALUES (?, ?, ?)`).run(contentHash, blob, Date.now());
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
db.close();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ─── Cache stripe management ─────────────────────────────────────────────────
|
|
146
|
+
/**
|
|
147
|
+
* Refresh cache stripe assignments from the cache_stripes table for a given
|
|
148
|
+
* conversation/epoch. Returns rows ordered by stability DESC.
|
|
149
|
+
*
|
|
150
|
+
* This is called at the start of each turn (or on topic-shift) to ensure the
|
|
151
|
+
* stripe assignments reflect the latest stability scores.
|
|
152
|
+
*/
|
|
153
|
+
export function refreshStripeAssignments(stateDir, epochId, limit = DEFAULT_STRIPE_LIMIT) {
|
|
154
|
+
const db = openStore(stateDir);
|
|
155
|
+
try {
|
|
156
|
+
const rows = db.prepare(`SELECT chunk_id, stripe, stability, assigned_at, epoch_id
|
|
157
|
+
FROM cache_stripes
|
|
158
|
+
WHERE epoch_id = ?
|
|
159
|
+
ORDER BY stability DESC
|
|
160
|
+
LIMIT ?`).all(epochId, limit);
|
|
161
|
+
return rows;
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
db.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// ─── Build cache-optimized prompt (Phase 3) ──────────────────────────────────
|
|
168
|
+
/**
|
|
169
|
+
* Build a cache-optimized prompt with 5 layers:
|
|
170
|
+
* 0 (system) -> 1 (summary) -> 2 (cache stripes) -> 3 (thread) -> 4 (tool)
|
|
171
|
+
*
|
|
172
|
+
* Feature gate: MEGACOMPACT_CACHE_STRIPING (default OFF). When OFF, delegates
|
|
173
|
+
* to buildSeparatedPrompt (byte-identical to Phase 2 behavior).
|
|
174
|
+
*
|
|
175
|
+
* When ON but MEGACOMPACT_MESSAGE_SEPARATION is OFF, also delegates to
|
|
176
|
+
* buildSeparatedPrompt (which returns messages unchanged).
|
|
177
|
+
*/
|
|
178
|
+
export function buildCacheOptimizedPrompt(messages, opts) {
|
|
179
|
+
const flag = process.env.MEGACOMPACT_CACHE_STRIPING;
|
|
180
|
+
if (flag === "0" || flag === "false" || flag === undefined || flag === "") {
|
|
181
|
+
// Flag OFF: delegate to buildSeparatedPrompt (byte-identical).
|
|
182
|
+
return buildSeparatedPrompt(messages, opts);
|
|
183
|
+
}
|
|
184
|
+
// Build the base 4-layer structure first.
|
|
185
|
+
const base = buildSeparatedPrompt(messages, opts);
|
|
186
|
+
// If base equals messages, separation is OFF — return unchanged.
|
|
187
|
+
if (base === messages)
|
|
188
|
+
return base;
|
|
189
|
+
const stateDir = opts?.stateDir ?? getStateDir();
|
|
190
|
+
// Layer 1 = leading branch/compaction summaries (the stable summary layer).
|
|
191
|
+
// There is no "system" role in pi's AgentMessage union, so Layer 0 is empty.
|
|
192
|
+
// Count leading summaries to find where to insert the cache-stripe layer.
|
|
193
|
+
let layer1End = 0;
|
|
194
|
+
for (let i = 0; i < base.length; i++) {
|
|
195
|
+
const r = base[i].role;
|
|
196
|
+
if (r === "branchSummary" || r === "compactionSummary") {
|
|
197
|
+
layer1End = i + 1;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// Lay out the result: Layer 1 (summaries) first.
|
|
204
|
+
const result = base.slice(0, layer1End);
|
|
205
|
+
// Insert Layer 2: cache stripes (stable context ordered by stability DESC).
|
|
206
|
+
// Try to find the most recent epoch.
|
|
207
|
+
const db = openStore(stateDir);
|
|
208
|
+
let epochId = null;
|
|
209
|
+
try {
|
|
210
|
+
const epoch = db.prepare(`SELECT epoch_id FROM checkpoint_epochs ORDER BY created_at DESC LIMIT 1`).get();
|
|
211
|
+
epochId = epoch?.epoch_id ?? null;
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
db.close();
|
|
215
|
+
}
|
|
216
|
+
if (epochId) {
|
|
217
|
+
const stripes = refreshStripeAssignments(stateDir, epochId);
|
|
218
|
+
if (stripes.length > 0) {
|
|
219
|
+
// Build a single user message with concatenated stripe content.
|
|
220
|
+
const stripeBlocks = [];
|
|
221
|
+
for (const s of stripes) {
|
|
222
|
+
// Load chunk content from context_chunks table.
|
|
223
|
+
const db2 = openStore(stateDir);
|
|
224
|
+
try {
|
|
225
|
+
const chunk = db2.prepare(`SELECT normalized_text FROM context_chunks WHERE id = ?`).get(s.chunk_id);
|
|
226
|
+
if (chunk?.normalized_text) {
|
|
227
|
+
stripeBlocks.push(chunk.normalized_text);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
db2.close();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (stripeBlocks.length > 0) {
|
|
235
|
+
result.push({
|
|
236
|
+
role: "user",
|
|
237
|
+
content: stripeBlocks.join("\n\n---\n\n"),
|
|
238
|
+
timestamp: Date.now(),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Append remaining layers (3: thread, 4: tool results).
|
|
244
|
+
for (let i = layer1End; i < base.length; i++) {
|
|
245
|
+
result.push(base[i]);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
@@ -149,14 +149,21 @@ export function registerSessionHandlers(pi, runtime, config) {
|
|
|
149
149
|
catch {
|
|
150
150
|
/* non-fatal: intent polling never breaks the agent loop */
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
// S53: when recallTailInject is ON, the staged blocks are injected as a
|
|
153
|
+
// user-role tail message by the context handler (recall-tail.ts), NOT
|
|
154
|
+
// here. This prepend path is the legacy behavior (flag OFF = byte-
|
|
155
|
+
// identical pre-sprint). captureModel + rewind-intent consumption above
|
|
156
|
+
// stay unconditional regardless of the flag.
|
|
157
|
+
if (!config.recallTailInject) {
|
|
158
|
+
const cpBlock = runtime.pendingRecallBlock;
|
|
159
|
+
const memBlock = runtime.pendingMemoryRecallBlock;
|
|
160
|
+
if (!cpBlock && !memBlock)
|
|
161
|
+
return;
|
|
162
|
+
runtime.pendingRecallBlock = undefined;
|
|
163
|
+
runtime.pendingMemoryRecallBlock = undefined;
|
|
164
|
+
const composed = [cpBlock, memBlock].filter(Boolean).join("\n\n");
|
|
165
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${composed}` };
|
|
166
|
+
}
|
|
160
167
|
});
|
|
161
168
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
162
169
|
runtime.setStatus(ctx, undefined);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mega-runtime/env-loader.ts — load `.mega-compact.env` from the state dir.
|
|
3
|
+
*
|
|
4
|
+
* The /mega-setup wizard and the dashboard Setup tab write a `.mega-compact.env`
|
|
5
|
+
* file with the user's chosen embedder configuration. Without a loader, that
|
|
6
|
+
* file is write-only dead weight — config is read from process.env at startup
|
|
7
|
+
* (mega-config.ts:loadConfig), so the file was never applied.
|
|
8
|
+
*
|
|
9
|
+
* This loader runs BEFORE loadConfig in the extension entry. It parses the
|
|
10
|
+
* file (KEY=VALUE lines, # comments, quoted values) and applies each key to
|
|
11
|
+
* process.env ONLY if it is not already set — so shell profile / inline env
|
|
12
|
+
* vars always win over the file (the user can override without editing it).
|
|
13
|
+
*
|
|
14
|
+
* Non-fatal: a missing or malformed file never breaks the extension.
|
|
15
|
+
*
|
|
16
|
+
* PREVENT-PI-004: reads a local file only — no network.
|
|
17
|
+
* PREVENT-001: no JSON here; line parser is null/empty-safe.
|
|
18
|
+
*/
|
|
19
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
/**
|
|
22
|
+
* Load `.mega-compact.env` from `stateDir` into `process.env`.
|
|
23
|
+
* Keys already set in the environment win (file does not override shell).
|
|
24
|
+
*/
|
|
25
|
+
export function loadMegaEnv(stateDir) {
|
|
26
|
+
const envPath = join(stateDir, ".mega-compact.env");
|
|
27
|
+
if (!existsSync(envPath))
|
|
28
|
+
return;
|
|
29
|
+
let content;
|
|
30
|
+
try {
|
|
31
|
+
content = readFileSync(envPath, "utf-8");
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return; // unreadable — non-fatal
|
|
35
|
+
}
|
|
36
|
+
for (const line of content.split("\n")) {
|
|
37
|
+
const trimmed = line.trim();
|
|
38
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
39
|
+
continue;
|
|
40
|
+
const eq = trimmed.indexOf("=");
|
|
41
|
+
if (eq < 0)
|
|
42
|
+
continue;
|
|
43
|
+
const key = trimmed.slice(0, eq).trim();
|
|
44
|
+
if (!key)
|
|
45
|
+
continue;
|
|
46
|
+
let val = trimmed.slice(eq + 1).trim();
|
|
47
|
+
if ((val.startsWith('"') && val.endsWith('"')) ||
|
|
48
|
+
(val.startsWith("'") && val.endsWith("'"))) {
|
|
49
|
+
val = val.slice(1, -1);
|
|
50
|
+
}
|
|
51
|
+
// Shell / inline env vars win over the file.
|
|
52
|
+
if (process.env[key] === undefined) {
|
|
53
|
+
process.env[key] = val;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -24,6 +24,10 @@ export function resetRuntimeImpl(self, sessionId) {
|
|
|
24
24
|
dedupAttempts: 0,
|
|
25
25
|
tokensSaved: 0,
|
|
26
26
|
lastCompactAt: null,
|
|
27
|
+
lastRecallAt: null,
|
|
28
|
+
lastInjectAt: null,
|
|
29
|
+
_prevCacheHitPct: null,
|
|
30
|
+
_lastCacheHealthScore: undefined,
|
|
27
31
|
lastNativeCompactAt: null,
|
|
28
32
|
compactCount: 0,
|
|
29
33
|
recallInjections: 0,
|
|
@@ -40,7 +44,9 @@ export function resetRuntimeImpl(self, sessionId) {
|
|
|
40
44
|
poisonedAdviseSent: false,
|
|
41
45
|
providerOutageAdvised: false,
|
|
42
46
|
poisonedCompactSignatures: new Set(),
|
|
47
|
+
recallInjectedThisTurn: false,
|
|
43
48
|
poisonedCount: 0,
|
|
49
|
+
extensionInitiatedTurn: false,
|
|
44
50
|
};
|
|
45
51
|
self.trimCache = null; // v0.8.6: never replay a stale trim into a new session
|
|
46
52
|
self.statusKey = undefined;
|
|
@@ -176,6 +176,7 @@ export function snapshotImpl(self, ctx) {
|
|
|
176
176
|
armed,
|
|
177
177
|
modelSnap,
|
|
178
178
|
providerCachePct,
|
|
179
|
+
perTurnCacheHitPct: self.rt._prevCacheHitPct ?? undefined,
|
|
179
180
|
});
|
|
180
181
|
self.widgetData = _snapResult.widgetData;
|
|
181
182
|
// S33: consume the flare after copying it into widgetData so it fires
|
|
@@ -49,6 +49,10 @@ export class MegaRuntime {
|
|
|
49
49
|
dedupAttempts: 0,
|
|
50
50
|
tokensSaved: 0,
|
|
51
51
|
lastCompactAt: null,
|
|
52
|
+
lastRecallAt: null,
|
|
53
|
+
lastInjectAt: null,
|
|
54
|
+
_prevCacheHitPct: null,
|
|
55
|
+
_lastCacheHealthScore: undefined,
|
|
52
56
|
lastNativeCompactAt: null,
|
|
53
57
|
compactCount: 0,
|
|
54
58
|
recallInjections: 0,
|
|
@@ -65,7 +69,10 @@ export class MegaRuntime {
|
|
|
65
69
|
poisonedAdviseSent: false,
|
|
66
70
|
providerOutageAdvised: false,
|
|
67
71
|
poisonedCompactSignatures: new Set(),
|
|
72
|
+
// S53: tracks whether withRecallTail injected this turn (consumed at turn_end).
|
|
73
|
+
recallInjectedThisTurn: false,
|
|
68
74
|
poisonedCount: 0,
|
|
75
|
+
extensionInitiatedTurn: false,
|
|
69
76
|
};
|
|
70
77
|
// v0.8.6 cache-stability: the cached live-trim view for the current
|
|
71
78
|
// compaction epoch. Set after a fresh runCompact + computeLiveTrimCut, and
|
|
@@ -131,6 +131,7 @@ export function computeMegaSnapshot(p) {
|
|
|
131
131
|
cachePct,
|
|
132
132
|
megaCacheFlare: p.megaCacheFlare,
|
|
133
133
|
megaCacheFlarePct: p.megaCacheFlarePct,
|
|
134
|
+
perTurnCacheHitPct: p.perTurnCacheHitPct ?? cachePct,
|
|
134
135
|
levelUpFlare: p.levelUpFlare,
|
|
135
136
|
achievementFlare: p.achievementFlare,
|
|
136
137
|
achievementFlareTitles: p.achievementFlareTitles,
|
|
@@ -87,6 +87,11 @@ export function buildWidgetLines(wd, width, activeAgents) {
|
|
|
87
87
|
`${C.gray}mem${C.reset} ${wd.embedderName} · ${wd.chk} chunks · ${C.blue}comp ${wd.compStr}${C.reset}`,
|
|
88
88
|
`${C.gray}drift${C.reset} ${wd.driftStatus === "ok" ? C.green : C.amber}${wd.driftStatus}${C.reset}`,
|
|
89
89
|
`${C.gray}compact${C.reset} ${sinceCompactStr(wd.sinceCompact)}`,
|
|
90
|
+
...(wd.perTurnCacheHitPct != null
|
|
91
|
+
? [
|
|
92
|
+
`${C.gray}cache hit${C.reset} this turn ${C.green}${Math.round(wd.perTurnCacheHitPct)}%${C.reset}`,
|
|
93
|
+
]
|
|
94
|
+
: []),
|
|
90
95
|
].join(sep);
|
|
91
96
|
// Wrap to terminal width and pad each line
|
|
92
97
|
const wrapped = wrapLine(content, width - 2, panelBg); // 2-char indent
|