(raw)
| 5037 | } |
| 5038 | |
| 5039 | function parseUnifiedMemoryRecallRoute(raw) { |
| 5040 | try { |
| 5041 | const parsed = JSON.parse(String(raw || "").match(/\{[\s\S]*\}/)?.[0] || raw); |
| 5042 | const source = ["desktop_recent", "desktop_topic", "mobile_context", "unified", "none"].includes(parsed.source) ? parsed.source : "none"; |
| 5043 | return { |
| 5044 | needsRecall: Boolean(parsed.needsRecall) && source !== "none", |
| 5045 | source, |
| 5046 | query: String(parsed.query || "").trim().slice(0, 160), |
| 5047 | confidence: Math.max(0, Math.min(1, Number(parsed.confidence || 0.5))), |
| 5048 | reason: "model" |
| 5049 | }; |
| 5050 | } catch { |
| 5051 | return { needsRecall: false, source: "none", query: "", confidence: 0.35, reason: "parse_failed" }; |
| 5052 | } |
| 5053 | } |
| 5054 | |
| 5055 | async function judgeUnifiedMemoryForIMessage(event) { |
| 5056 | const ruleDecision = judgeUnifiedMemoryByRules({ |
no outgoing calls
no test coverage detected