()
| 65 | } |
| 66 | |
| 67 | export async function loadMemoryConfig(): Promise<MemoryConfig> { |
| 68 | try { |
| 69 | const res = await requestJson(API_ENDPOINTS.memory.config.load, { |
| 70 | method: "GET", |
| 71 | headers: getAuthHeaders(), |
| 72 | }); |
| 73 | |
| 74 | // Backend returns plain config object directly |
| 75 | const cfg = res || {}; |
| 76 | |
| 77 | const memorySwitchVal: string = |
| 78 | cfg.MEMORY_SWITCH ?? cfg.memory_switch ?? "Y"; |
| 79 | const shareVal: string = |
| 80 | cfg.MEMORY_AGENT_SHARE ?? cfg.memory_agent_share ?? "always"; |
| 81 | const disableAgentIds: string[] = |
| 82 | cfg.DISABLE_AGENT_ID ?? cfg.disable_agent_id ?? []; |
| 83 | const disableUserAgentIds: string[] = |
| 84 | cfg.DISABLE_USERAGENT_ID ?? cfg.disable_useragent_id ?? []; |
| 85 | |
| 86 | return { |
| 87 | memoryEnabled: memorySwitchVal === "Y", |
| 88 | shareOption: (shareVal || "always") as "always" | "ask" | "never", |
| 89 | disableAgentIds, |
| 90 | disableUserAgentIds, |
| 91 | }; |
| 92 | } catch (e) { |
| 93 | log.error("loadMemoryConfig error", e); |
| 94 | // fall back to defaults |
| 95 | return { |
| 96 | memoryEnabled: true, |
| 97 | shareOption: "always", |
| 98 | disableAgentIds: [], |
| 99 | disableUserAgentIds: [], |
| 100 | }; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | export async function setMemorySwitch(enabled: boolean): Promise<boolean> { |
| 105 | try { |
no test coverage detected