4c33f210da
Runtime control has no top-level enabled field; derive section status from agent resolve, injection mode, and lifecycle flags so the admin page matches saved production config. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
939 B
TypeScript
35 lines
939 B
TypeScript
import type { MemoryV2AdminSection } from '../../types';
|
|
|
|
type CapabilityKey =
|
|
| 'candidateMemory'
|
|
| 'runtimeControl'
|
|
| 'policy'
|
|
| 'retriever'
|
|
| 'lifecycle'
|
|
| 'persona'
|
|
| 'graph'
|
|
| 'userMemory'
|
|
| 'pluginHealth';
|
|
|
|
function modeEnabled(value: unknown) {
|
|
const mode = String(value ?? 'off').trim().toLowerCase();
|
|
return mode !== '' && mode !== 'off';
|
|
}
|
|
|
|
export function isMemoryV2SectionEnabled(
|
|
sectionKey: CapabilityKey,
|
|
section: MemoryV2AdminSection | undefined,
|
|
): boolean {
|
|
const config = section ?? {};
|
|
if (sectionKey === 'runtimeControl') {
|
|
return Boolean(config.agentResolveEnabled)
|
|
|| modeEnabled(config.agentInjectionMode)
|
|
|| Boolean(config.promotionEnabled)
|
|
|| Boolean(config.compactionV2Enabled)
|
|
|| Boolean(config.reflectionEnabled)
|
|
|| Boolean(config.lifecycleWorkerEnabled)
|
|
|| modeEnabled(config.lifecycleRolloutMode);
|
|
}
|
|
return Boolean(config.enabled);
|
|
}
|