@remnic/core 9.3.761 → 9.3.762
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/access-admin-ops-surface.js +9 -8
- package/dist/access-boundary.js +10 -9
- package/dist/access-cli.js +44 -43
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.js +16 -15
- package/dist/access-identity-continuity-surface.js +9 -8
- package/dist/access-lcm-surface.js +9 -8
- package/dist/access-mcp.js +13 -12
- package/dist/access-observe-write-surface.js +9 -8
- package/dist/access-operations-batch.js +11 -10
- package/dist/access-operations.js +12 -11
- package/dist/access-recall-surface.js +9 -8
- package/dist/access-service.js +9 -8
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/briefing.js +4 -3
- package/dist/causal-consolidation.js +5 -4
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-4WOXD56B.js → chunk-2KYXXMTE.js} +5 -5
- package/dist/{chunk-HP23UD6W.js → chunk-2PGB63VU.js} +2 -2
- package/dist/{chunk-2B3BTQN4.js → chunk-4HYJETVO.js} +2 -2
- package/dist/{chunk-APJQ6UEA.js → chunk-AGNBY3VG.js} +4 -4
- package/dist/{chunk-ICVNVSKN.js → chunk-BRYPUVJU.js} +2 -2
- package/dist/{chunk-IRFHFRHP.js → chunk-DB647OZ4.js} +24 -24
- package/dist/{chunk-LG2MCUBC.js → chunk-DPZ5GJMD.js} +2 -2
- package/dist/chunk-DQC3ZZYM.js +35 -0
- package/dist/chunk-DQC3ZZYM.js.map +1 -0
- package/dist/{chunk-W4ADKEIY.js → chunk-EDC7RZCW.js} +22 -22
- package/dist/{chunk-DUU4VLOW.js → chunk-ES3GAMSQ.js} +2 -2
- package/dist/{chunk-5AZQZFJG.js → chunk-ESDBHQY6.js} +5 -5
- package/dist/{chunk-IV4INTAU.js → chunk-HDFS6RWQ.js} +2 -2
- package/dist/{chunk-P7UA66OG.js → chunk-HDYFNXVO.js} +2 -2
- package/dist/{chunk-YU4CLTZY.js → chunk-HMUEAKSD.js} +2 -2
- package/dist/{chunk-XDFWMY4X.js → chunk-IIURIWJG.js} +102 -12
- package/dist/chunk-IIURIWJG.js.map +1 -0
- package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
- package/dist/{chunk-Y3XEN5TL.js → chunk-JU6BKZHX.js} +3 -3
- package/dist/{chunk-NPZTEHR7.js → chunk-KZWUJC7Y.js} +2 -2
- package/dist/{chunk-3CBSKDRL.js → chunk-LAJIXABF.js} +8 -8
- package/dist/{chunk-3QLPBCFG.js → chunk-NKP6II6G.js} +4 -4
- package/dist/{chunk-742MWWVL.js → chunk-OQ6F3WBX.js} +2 -2
- package/dist/{chunk-3DAIQSVS.js → chunk-P7W4CDX6.js} +13 -6
- package/dist/chunk-P7W4CDX6.js.map +1 -0
- package/dist/{chunk-HHCMZEUC.js → chunk-PNFN7SIN.js} +2 -2
- package/dist/{chunk-P7N2DQLC.js → chunk-QPFO54VC.js} +3 -3
- package/dist/{chunk-ZAIU7ZEA.js → chunk-QWIE43BS.js} +2 -2
- package/dist/chunk-TEKTCF2V.js +118 -0
- package/dist/chunk-TEKTCF2V.js.map +1 -0
- package/dist/{chunk-CFHDI5CV.js → chunk-TIWRP5NW.js} +4 -4
- package/dist/{chunk-CXW6Y7SI.js → chunk-V5RVMULT.js} +4 -4
- package/dist/{chunk-6S2C5FQ4.js → chunk-VHYFY3JI.js} +2 -2
- package/dist/{chunk-JYH3XYWM.js → chunk-WAIMHMO3.js} +3 -3
- package/dist/{chunk-OCPVA4TH.js → chunk-ZTBH2OHD.js} +2 -2
- package/dist/cli.js +33 -32
- package/dist/compounding/engine.js +4 -3
- package/dist/connectors/codex-materialize-runner.js +4 -3
- package/dist/connectors/index.js +4 -3
- package/dist/entity-retrieval.js +4 -3
- package/dist/{forget-OEE5OELK.js → forget-WYLR4ZFV.js} +2 -2
- package/dist/index.js +46 -45
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +4 -4
- package/dist/maintenance/memory-governance.js +4 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +11 -1
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -3
- package/dist/maintenance/rebuild-memory-projection.d.ts +22 -1
- package/dist/maintenance/rebuild-memory-projection.js +5 -4
- package/dist/namespaces/migrate.js +8 -7
- package/dist/namespaces/search.js +3 -3
- package/dist/namespaces/storage.js +4 -3
- package/dist/operator-toolkit.js +11 -10
- package/dist/orchestration/maintenance.js +6 -5
- package/dist/orchestrator.js +44 -43
- package/dist/schemas.d.ts +22 -22
- package/dist/search/factory.js +2 -2
- package/dist/search/index.js +4 -4
- package/dist/semantic-consolidation.js +5 -4
- package/dist/semantic-rule-promotion.js +4 -3
- package/dist/semantic-rule-verifier.js +4 -3
- package/dist/storage-guards.d.ts +9 -0
- package/dist/storage-guards.js +11 -0
- package/dist/storage-guards.js.map +1 -0
- package/dist/storage.js +3 -2
- package/dist/transfer/import-sqlite.js +2 -2
- package/dist/transfer/types.d.ts +12 -12
- package/dist/verified-recall.js +4 -3
- package/package.json +2 -2
- package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +59 -8
- package/src/maintenance/rebuild-memory-projection.ts +149 -9
- package/src/storage-guards.ts +30 -0
- package/src/storage.ts +8 -8
- package/dist/chunk-3DAIQSVS.js.map +0 -1
- package/dist/chunk-GYJESQS5.js +0 -77
- package/dist/chunk-GYJESQS5.js.map +0 -1
- package/dist/chunk-XDFWMY4X.js.map +0 -1
- /package/dist/{chunk-4WOXD56B.js.map → chunk-2KYXXMTE.js.map} +0 -0
- /package/dist/{chunk-HP23UD6W.js.map → chunk-2PGB63VU.js.map} +0 -0
- /package/dist/{chunk-2B3BTQN4.js.map → chunk-4HYJETVO.js.map} +0 -0
- /package/dist/{chunk-APJQ6UEA.js.map → chunk-AGNBY3VG.js.map} +0 -0
- /package/dist/{chunk-ICVNVSKN.js.map → chunk-BRYPUVJU.js.map} +0 -0
- /package/dist/{chunk-IRFHFRHP.js.map → chunk-DB647OZ4.js.map} +0 -0
- /package/dist/{chunk-LG2MCUBC.js.map → chunk-DPZ5GJMD.js.map} +0 -0
- /package/dist/{chunk-W4ADKEIY.js.map → chunk-EDC7RZCW.js.map} +0 -0
- /package/dist/{chunk-DUU4VLOW.js.map → chunk-ES3GAMSQ.js.map} +0 -0
- /package/dist/{chunk-5AZQZFJG.js.map → chunk-ESDBHQY6.js.map} +0 -0
- /package/dist/{chunk-IV4INTAU.js.map → chunk-HDFS6RWQ.js.map} +0 -0
- /package/dist/{chunk-P7UA66OG.js.map → chunk-HDYFNXVO.js.map} +0 -0
- /package/dist/{chunk-YU4CLTZY.js.map → chunk-HMUEAKSD.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-Y3XEN5TL.js.map → chunk-JU6BKZHX.js.map} +0 -0
- /package/dist/{chunk-NPZTEHR7.js.map → chunk-KZWUJC7Y.js.map} +0 -0
- /package/dist/{chunk-3CBSKDRL.js.map → chunk-LAJIXABF.js.map} +0 -0
- /package/dist/{chunk-3QLPBCFG.js.map → chunk-NKP6II6G.js.map} +0 -0
- /package/dist/{chunk-742MWWVL.js.map → chunk-OQ6F3WBX.js.map} +0 -0
- /package/dist/{chunk-HHCMZEUC.js.map → chunk-PNFN7SIN.js.map} +0 -0
- /package/dist/{chunk-P7N2DQLC.js.map → chunk-QPFO54VC.js.map} +0 -0
- /package/dist/{chunk-ZAIU7ZEA.js.map → chunk-QWIE43BS.js.map} +0 -0
- /package/dist/{chunk-CFHDI5CV.js.map → chunk-TIWRP5NW.js.map} +0 -0
- /package/dist/{chunk-CXW6Y7SI.js.map → chunk-V5RVMULT.js.map} +0 -0
- /package/dist/{chunk-6S2C5FQ4.js.map → chunk-VHYFY3JI.js.map} +0 -0
- /package/dist/{chunk-JYH3XYWM.js.map → chunk-WAIMHMO3.js.map} +0 -0
- /package/dist/{chunk-OCPVA4TH.js.map → chunk-ZTBH2OHD.js.map} +0 -0
- /package/dist/{forget-OEE5OELK.js.map → forget-WYLR4ZFV.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/causal-consolidation.ts"],"sourcesContent":["/**\n * causal-consolidation.ts — CMC Phase 2: LLM-Assisted Causal Consolidation\n *\n * Uses an LLM to analyze causal trajectory patterns across sessions.\n * The LLM receives the causal chain graph as context — connected trajectories\n * from different sessions — and identifies recurring behavioral patterns,\n * preference signals, and actionable rules.\n *\n * This is the core CMC innovation: the LLM gets cross-session causal context\n * that no other memory system provides. It can see that a user investigated\n * a bug in session 1, attempted a fix in session 2, and succeeded in session 3 —\n * and synthesize a rule or preference from that chain.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { resolveCausalTrajectoryStoreDir, type CausalTrajectoryRecord } from \"./causal-trajectory.js\";\nimport { readChainIndex, resolveChainsDir, type CausalChainIndex, type CausalEdge } from \"./causal-chain.js\";\nimport { listJsonFiles, readJsonFile } from \"./json-store.js\";\nimport { isRecord } from \"./store-contract.js\";\nimport { FallbackLlmClient, fallbackLlmRuntimeContextFromConfig } from \"./fallback-llm.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, MemoryFile, PluginConfig } from \"./types.js\";\nimport path from \"node:path\";\nimport { log } from \"./logger.js\";\nimport { runPostConsolidationMaterialize } from \"./connectors/codex-materialize-runner.js\";\nimport type { MaterializeResult, RolloutSummaryInput } from \"./connectors/codex-materialize.js\";\nimport { buildExtensionsBlockForConsolidation } from \"./semantic-consolidation.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CausalPatternCandidate {\n id: string;\n sourceType: \"causal-pattern\";\n subject: string;\n category: \"principle\" | \"rule\" | \"preference\";\n content: string;\n score: number;\n rationale: string;\n outcome: null;\n provenance: string[];\n agent: string | null;\n workflow: string | null;\n}\n\nexport interface ConsolidationConfig {\n minRecurrence: number;\n minSessions: number;\n successThreshold: number;\n}\n\nexport interface LlmConsolidationResult {\n rules: Array<{\n content: string;\n category: \"rule\" | \"principle\" | \"preference\";\n confidence: number;\n evidence: string[];\n }>;\n preferences: Array<{\n statement: string;\n confidence: number;\n evidence: string[];\n }>;\n}\n\nconst CAUSAL_RULE_CATEGORIES = new Set([\"rule\", \"principle\", \"preference\"]);\n\ninterface ConsolidationLlmClient {\n isAvailable(options?: { agentId?: string; modelChain?: AgentPersonaModelConfig }): boolean;\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: { temperature?: number; maxTokens?: number; agentId?: string; modelChain?: AgentPersonaModelConfig },\n ): Promise<{ content: string } | null>;\n}\n\n// ─── Trajectory Reading ──────────────────────────────────────────────────────\n\nasync function readAllTrajectories(\n memoryDir: string,\n causalTrajectoryStoreDir?: string,\n): Promise<CausalTrajectoryRecord[]> {\n const root = resolveCausalTrajectoryStoreDir(memoryDir, causalTrajectoryStoreDir);\n const trajectoriesDir = path.join(root, \"trajectories\");\n\n const files = await listJsonFiles(trajectoriesDir).catch(() => [] as string[]);\n const results: CausalTrajectoryRecord[] = [];\n\n for (const filePath of files) {\n try {\n const raw = await readJsonFile(filePath);\n if (isRecord(raw) && typeof raw.trajectoryId === \"string\") {\n results.push(raw as unknown as CausalTrajectoryRecord);\n }\n } catch {\n // skip invalid\n }\n }\n\n return results;\n}\n\n// ─── Context Formatting ──────────────────────────────────────────────────────\n\n/**\n * Format trajectories and their causal connections as a readable context\n * for the LLM. Groups by session and shows chain connections.\n */\nfunction formatCausalContext(\n trajectories: CausalTrajectoryRecord[],\n chainIndex: CausalChainIndex,\n maxChars: number = 8000,\n): string {\n // Group trajectories by session\n const bySession = new Map<string, CausalTrajectoryRecord[]>();\n for (const t of trajectories) {\n const list = bySession.get(t.sessionKey) ?? [];\n list.push(t);\n bySession.set(t.sessionKey, list);\n }\n\n const lines: string[] = [];\n lines.push(`## Causal Trajectories (${trajectories.length} across ${bySession.size} sessions)`);\n lines.push(\"\");\n\n // Format each session's trajectories\n for (const [sessionKey, sessionTrajs] of bySession) {\n lines.push(`### Session: ${sessionKey}`);\n for (const t of sessionTrajs.slice(0, 5)) {\n const outcome = t.outcomeKind === \"success\" ? \"+\" : t.outcomeKind === \"failure\" ? \"-\" : \"~\";\n lines.push(`[${outcome}] Goal: ${t.goal}`);\n lines.push(` Action: ${t.actionSummary}`);\n lines.push(` Outcome: ${t.outcomeSummary}`);\n if (t.followUpSummary) lines.push(` Follow-up: ${t.followUpSummary}`);\n if (t.entityRefs?.length) lines.push(` Entities: ${t.entityRefs.join(\", \")}`);\n }\n lines.push(\"\");\n }\n\n // Format causal chain connections\n const edgeCount = Object.keys(chainIndex.edges).length;\n if (edgeCount > 0) {\n lines.push(`## Cross-Session Causal Chains (${edgeCount} connections)`);\n lines.push(\"\");\n\n const trajectoryMap = new Map(trajectories.map((t) => [t.trajectoryId, t]));\n const shown = new Set<string>();\n\n for (const [edgeId, edge] of Object.entries(chainIndex.edges)) {\n if (shown.size >= 10) break; // limit output size\n const from = trajectoryMap.get(edge.fromTrajectoryId);\n const to = trajectoryMap.get(edge.toTrajectoryId);\n if (!from || !to) continue;\n\n lines.push(`${edge.edgeType}: \"${from.goal}\" (${from.sessionKey}) → \"${to.goal}\" (${to.sessionKey})`);\n shown.add(edgeId);\n }\n lines.push(\"\");\n }\n\n const result = lines.join(\"\\n\");\n return result.length > maxChars ? result.slice(0, maxChars) + \"\\n[truncated]\" : result;\n}\n\n// ─── LLM Consolidation ──────────────────────────────────────────────────────\n\nconst CONSOLIDATION_PROMPT = `You are analyzing a user's causal trajectory history across multiple sessions. Trajectories record what the user tried to do (goal), what they did (action), and what happened (outcome).\n\nYour job is to identify:\n1. BEHAVIORAL RULES: Recurring patterns where the same approach consistently succeeds or fails. These should be actionable guidance for future sessions.\n2. PREFERENCES: What the user cares about, prefers, or consistently chooses — even if never explicitly stated. Infer preferences from what they repeatedly do, retry until successful, or always include in their workflow.\n\nIMPORTANT:\n- Look for CROSS-SESSION patterns — things that repeat across different sessions are more significant than within-session patterns.\n- A user who retries the same goal across sessions has a strong implicit preference for that outcome.\n- Consistent action choices reveal preferences even when the user never says \"I prefer X.\"\n- Frame preferences as \"The user would prefer responses that...\" when applicable.\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\"content\": \"actionable rule text\", \"category\": \"rule|principle\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ],\n \"preferences\": [\n {\"statement\": \"The user would prefer...\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ]\n}\n\nIf no clear patterns exist, return {\"rules\": [], \"preferences\": []}.`;\n\nasync function consolidateWithLlm(\n context: string,\n llm: ConsolidationLlmClient,\n options: { agentId?: string; modelChain?: AgentPersonaModelConfig } = {},\n): Promise<LlmConsolidationResult> {\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CONSOLIDATION_PROMPT },\n { role: \"user\", content: context },\n ],\n { temperature: 0.2, maxTokens: 2000, agentId: options.agentId, modelChain: options.modelChain },\n );\n\n if (!response?.content) {\n return { rules: [], preferences: [] };\n }\n\n try {\n // Extract JSON from response (may have markdown code fences)\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n const rawPreferences: unknown[] = Array.isArray(parsed.preferences) ? parsed.preferences : [];\n return {\n rules: rawRules\n .map(parseLlmRule)\n .filter((rule): rule is LlmConsolidationResult[\"rules\"][number] => !!rule),\n preferences: rawPreferences\n .map(parseLlmPreference)\n .filter((pref): pref is LlmConsolidationResult[\"preferences\"][number] => !!pref),\n };\n } catch {\n log.warn(\"[cmc] failed to parse LLM consolidation response\");\n return { rules: [], preferences: [] };\n }\n}\n\n// ─── Candidate Generation ────────────────────────────────────────────────────\n\nfunction stablePatternId(content: string): string {\n const digest = createHash(\"sha256\")\n .update(`causal-pattern\\0${content}`)\n .digest(\"hex\")\n .slice(0, 16);\n return `causal-pattern:${digest}`;\n}\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidence(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction parseLlmRule(raw: unknown): LlmConsolidationResult[\"rules\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const r = raw as Record<string, unknown>;\n const content = typeof r.content === \"string\" ? r.content.trim() : \"\";\n const category = typeof r.category === \"string\" ? r.category : \"\";\n const confidence = parseConfidence(r.confidence);\n if (content.length <= 5 || !CAUSAL_RULE_CATEGORIES.has(category) || confidence === undefined) {\n return undefined;\n }\n return {\n content,\n category: category as \"rule\" | \"principle\" | \"preference\",\n confidence,\n evidence: parseEvidence(r.evidence),\n };\n}\n\nfunction parseLlmPreference(raw: unknown): LlmConsolidationResult[\"preferences\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n const statement = typeof p.statement === \"string\" ? p.statement.trim() : \"\";\n const confidence = parseConfidence(p.confidence);\n if (statement.length <= 5 || confidence === undefined) return undefined;\n return {\n statement,\n confidence,\n evidence: parseEvidence(p.evidence),\n };\n}\n\nfunction llmResultToCandidates(result: LlmConsolidationResult): CausalPatternCandidate[] {\n const candidates: CausalPatternCandidate[] = [];\n\n for (const rule of result.rules) {\n const category =\n rule.category === \"principle\" || rule.category === \"preference\"\n ? rule.category\n : \"rule\";\n candidates.push({\n id: stablePatternId(rule.content),\n sourceType: \"causal-pattern\",\n subject: rule.content.slice(0, 80),\n category,\n content: rule.content,\n score: Math.min(1, rule.confidence ?? 0.7),\n rationale: \"LLM-identified causal pattern from cross-session trajectory analysis\",\n outcome: null,\n provenance: (rule.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n for (const preference of result.preferences) {\n candidates.push({\n id: stablePatternId(preference.statement),\n sourceType: \"causal-pattern\",\n subject: preference.statement.slice(0, 80),\n category: \"preference\",\n content: preference.statement,\n score: Math.min(1, preference.confidence ?? 0.7),\n rationale: \"LLM-identified preference from cross-session trajectory analysis\",\n outcome: null,\n provenance: (preference.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n return candidates;\n}\n\nfunction normalizePositiveInteger(value: number, fallback: number): number {\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;\n}\n\nfunction normalizeSuccessThreshold(value: number): number {\n if (!Number.isFinite(value) || value <= 0) return 0;\n return Math.min(1, value);\n}\n\nfunction trajectorySuccessScore(trajectory: CausalTrajectoryRecord): number {\n if (trajectory.outcomeKind === \"success\") return 1;\n if (trajectory.outcomeKind === \"partial\") return 0.5;\n return 0;\n}\n\nfunction averageSuccessScore(trajectories: CausalTrajectoryRecord[]): number {\n if (trajectories.length === 0) return 0;\n const total = trajectories.reduce((sum, trajectory) => sum + trajectorySuccessScore(trajectory), 0);\n return total / trajectories.length;\n}\n\nfunction passesConsolidationGates(\n trajectories: CausalTrajectoryRecord[],\n config: ConsolidationConfig,\n): boolean {\n const minRecurrence = normalizePositiveInteger(config.minRecurrence, 1);\n if (trajectories.length < minRecurrence) return false;\n\n const minSessions = normalizePositiveInteger(config.minSessions, 1);\n const sessionCount = new Set(trajectories.map((trajectory) => trajectory.sessionKey)).size;\n if (sessionCount < minSessions) return false;\n\n const successThreshold = normalizeSuccessThreshold(config.successThreshold);\n if (successThreshold > 0 && averageSuccessScore(trajectories) < successThreshold) {\n return false;\n }\n\n return true;\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Run LLM-assisted consolidation: read trajectories, format causal context,\n * ask LLM to identify patterns and preferences.\n */\nexport async function deriveCausalPromotionCandidates(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n config: ConsolidationConfig;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n llmClient?: ConsolidationLlmClient;\n}): Promise<CausalPatternCandidate[]> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (!passesConsolidationGates(trajectories, options.config)) return [];\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n\n // Format the causal context for the LLM\n let context = formatCausalContext(trajectories, chainIndex);\n\n // Append memory extensions block if available (#382)\n if (options.pluginConfig) {\n const extBlock = await buildExtensionsBlockForConsolidation(options.pluginConfig);\n if (extBlock.length > 0) {\n context += \"\\n\\n\" + extBlock;\n }\n }\n\n // If no LLM available, fall back to empty (no deterministic fallback)\n const llm = options.llmClient ?? new FallbackLlmClient(\n options.gatewayConfig,\n options.pluginConfig\n ? fallbackLlmRuntimeContextFromConfig(options.pluginConfig, {\n workspaceDir: options.workspaceDir ?? options.pluginConfig.workspaceDir,\n })\n : { workspaceDir: options.workspaceDir },\n );\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) {\n log.debug(\"[cmc] no LLM available for consolidation — skipping\");\n return [];\n }\n\n // Call LLM for pattern analysis\n const result = await consolidateWithLlm(context, llm, llmOptions);\n const candidates = llmResultToCandidates(result);\n\n log.debug(`[cmc] LLM consolidation produced ${candidates.length} rule(s) and ${result.preferences.length} preference(s)`);\n return candidates;\n } catch (error) {\n log.warn(`[cmc] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n}\n\n/**\n * Get LLM-synthesized preferences from causal trajectory analysis.\n * Returns formatted preference statements for recall injection.\n */\nexport async function synthesizeCausalPreferencesViaLlm(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n minTrajectories?: number;\n}): Promise<string | null> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (trajectories.length < (options.minTrajectories ?? 2)) return null;\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n const context = formatCausalContext(trajectories, chainIndex);\n\n const llm = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) return null;\n\n const result = await consolidateWithLlm(context, llm, llmOptions);\n if (result.preferences.length === 0 && result.rules.length === 0) return null;\n\n const lines: string[] = [\"## Behavioral Insights (from Causal Chain Analysis)\", \"\"];\n\n for (const pref of result.preferences) {\n lines.push(`- ${pref.statement}`);\n }\n\n for (const rule of result.rules) {\n lines.push(`- ${rule.content}`);\n }\n\n lines.push(\"\");\n return lines.join(\"\\n\");\n } catch (error) {\n log.warn(`[cmc] preference synthesis failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return null;\n }\n}\n\n/**\n * Optional post-consolidation hook — materializes Codex-native memory artifacts\n * after a causal consolidation run. Guarded by `codexMaterializeMemories` and\n * `codexMaterializeOnConsolidation`. Returns `null` when disabled or when the\n * sentinel is missing (honors user hand-edits).\n *\n * Split from the orchestrator-owned flow so #378 avoids touching\n * orchestrator.ts while Wave 1 edits are in flight.\n */\nexport async function materializeAfterCausalConsolidation(options: {\n config: PluginConfig;\n namespace?: string;\n memories?: MemoryFile[];\n memoryDir?: string;\n codexHome?: string;\n rolloutSummaries?: RolloutSummaryInput[];\n now?: Date;\n}): Promise<MaterializeResult | null> {\n // Delegates to the shared post-consolidation helper — see\n // runPostConsolidationMaterialize in codex-materialize-runner.ts.\n return runPostConsolidation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AO,EAAE;AAAA,IAChC;AAEA,UAAM,KAAK,EAAE;AACb,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB,SAAS,OAAO;AACd,QAAI,KAAK,kDAAkD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AACnH,WAAO;AAAA,EACT;AACF;AAWA,eAAsB,oCAAoC,SAQpB;AAGpC,SAAO,gCAAgC,SAAS,OAAO;AACzD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/causal-consolidation.ts"],"sourcesContent":["/**\n * causal-consolidation.ts — CMC Phase 2: LLM-Assisted Causal Consolidation\n *\n * Uses an LLM to analyze causal trajectory patterns across sessions.\n * The LLM receives the causal chain graph as context — connected trajectories\n * from different sessions — and identifies recurring behavioral patterns,\n * preference signals, and actionable rules.\n *\n * This is the core CMC innovation: the LLM gets cross-session causal context\n * that no other memory system provides. It can see that a user investigated\n * a bug in session 1, attempted a fix in session 2, and succeeded in session 3 —\n * and synthesize a rule or preference from that chain.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { resolveCausalTrajectoryStoreDir, type CausalTrajectoryRecord } from \"./causal-trajectory.js\";\nimport { readChainIndex, resolveChainsDir, type CausalChainIndex, type CausalEdge } from \"./causal-chain.js\";\nimport { listJsonFiles, readJsonFile } from \"./json-store.js\";\nimport { isRecord } from \"./store-contract.js\";\nimport { FallbackLlmClient, fallbackLlmRuntimeContextFromConfig } from \"./fallback-llm.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, MemoryFile, PluginConfig } from \"./types.js\";\nimport path from \"node:path\";\nimport { log } from \"./logger.js\";\nimport { runPostConsolidationMaterialize } from \"./connectors/codex-materialize-runner.js\";\nimport type { MaterializeResult, RolloutSummaryInput } from \"./connectors/codex-materialize.js\";\nimport { buildExtensionsBlockForConsolidation } from \"./semantic-consolidation.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CausalPatternCandidate {\n id: string;\n sourceType: \"causal-pattern\";\n subject: string;\n category: \"principle\" | \"rule\" | \"preference\";\n content: string;\n score: number;\n rationale: string;\n outcome: null;\n provenance: string[];\n agent: string | null;\n workflow: string | null;\n}\n\nexport interface ConsolidationConfig {\n minRecurrence: number;\n minSessions: number;\n successThreshold: number;\n}\n\nexport interface LlmConsolidationResult {\n rules: Array<{\n content: string;\n category: \"rule\" | \"principle\" | \"preference\";\n confidence: number;\n evidence: string[];\n }>;\n preferences: Array<{\n statement: string;\n confidence: number;\n evidence: string[];\n }>;\n}\n\nconst CAUSAL_RULE_CATEGORIES = new Set([\"rule\", \"principle\", \"preference\"]);\n\ninterface ConsolidationLlmClient {\n isAvailable(options?: { agentId?: string; modelChain?: AgentPersonaModelConfig }): boolean;\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: { temperature?: number; maxTokens?: number; agentId?: string; modelChain?: AgentPersonaModelConfig },\n ): Promise<{ content: string } | null>;\n}\n\n// ─── Trajectory Reading ──────────────────────────────────────────────────────\n\nasync function readAllTrajectories(\n memoryDir: string,\n causalTrajectoryStoreDir?: string,\n): Promise<CausalTrajectoryRecord[]> {\n const root = resolveCausalTrajectoryStoreDir(memoryDir, causalTrajectoryStoreDir);\n const trajectoriesDir = path.join(root, \"trajectories\");\n\n const files = await listJsonFiles(trajectoriesDir).catch(() => [] as string[]);\n const results: CausalTrajectoryRecord[] = [];\n\n for (const filePath of files) {\n try {\n const raw = await readJsonFile(filePath);\n if (isRecord(raw) && typeof raw.trajectoryId === \"string\") {\n results.push(raw as unknown as CausalTrajectoryRecord);\n }\n } catch {\n // skip invalid\n }\n }\n\n return results;\n}\n\n// ─── Context Formatting ──────────────────────────────────────────────────────\n\n/**\n * Format trajectories and their causal connections as a readable context\n * for the LLM. Groups by session and shows chain connections.\n */\nfunction formatCausalContext(\n trajectories: CausalTrajectoryRecord[],\n chainIndex: CausalChainIndex,\n maxChars: number = 8000,\n): string {\n // Group trajectories by session\n const bySession = new Map<string, CausalTrajectoryRecord[]>();\n for (const t of trajectories) {\n const list = bySession.get(t.sessionKey) ?? [];\n list.push(t);\n bySession.set(t.sessionKey, list);\n }\n\n const lines: string[] = [];\n lines.push(`## Causal Trajectories (${trajectories.length} across ${bySession.size} sessions)`);\n lines.push(\"\");\n\n // Format each session's trajectories\n for (const [sessionKey, sessionTrajs] of bySession) {\n lines.push(`### Session: ${sessionKey}`);\n for (const t of sessionTrajs.slice(0, 5)) {\n const outcome = t.outcomeKind === \"success\" ? \"+\" : t.outcomeKind === \"failure\" ? \"-\" : \"~\";\n lines.push(`[${outcome}] Goal: ${t.goal}`);\n lines.push(` Action: ${t.actionSummary}`);\n lines.push(` Outcome: ${t.outcomeSummary}`);\n if (t.followUpSummary) lines.push(` Follow-up: ${t.followUpSummary}`);\n if (t.entityRefs?.length) lines.push(` Entities: ${t.entityRefs.join(\", \")}`);\n }\n lines.push(\"\");\n }\n\n // Format causal chain connections\n const edgeCount = Object.keys(chainIndex.edges).length;\n if (edgeCount > 0) {\n lines.push(`## Cross-Session Causal Chains (${edgeCount} connections)`);\n lines.push(\"\");\n\n const trajectoryMap = new Map(trajectories.map((t) => [t.trajectoryId, t]));\n const shown = new Set<string>();\n\n for (const [edgeId, edge] of Object.entries(chainIndex.edges)) {\n if (shown.size >= 10) break; // limit output size\n const from = trajectoryMap.get(edge.fromTrajectoryId);\n const to = trajectoryMap.get(edge.toTrajectoryId);\n if (!from || !to) continue;\n\n lines.push(`${edge.edgeType}: \"${from.goal}\" (${from.sessionKey}) → \"${to.goal}\" (${to.sessionKey})`);\n shown.add(edgeId);\n }\n lines.push(\"\");\n }\n\n const result = lines.join(\"\\n\");\n return result.length > maxChars ? result.slice(0, maxChars) + \"\\n[truncated]\" : result;\n}\n\n// ─── LLM Consolidation ──────────────────────────────────────────────────────\n\nconst CONSOLIDATION_PROMPT = `You are analyzing a user's causal trajectory history across multiple sessions. Trajectories record what the user tried to do (goal), what they did (action), and what happened (outcome).\n\nYour job is to identify:\n1. BEHAVIORAL RULES: Recurring patterns where the same approach consistently succeeds or fails. These should be actionable guidance for future sessions.\n2. PREFERENCES: What the user cares about, prefers, or consistently chooses — even if never explicitly stated. Infer preferences from what they repeatedly do, retry until successful, or always include in their workflow.\n\nIMPORTANT:\n- Look for CROSS-SESSION patterns — things that repeat across different sessions are more significant than within-session patterns.\n- A user who retries the same goal across sessions has a strong implicit preference for that outcome.\n- Consistent action choices reveal preferences even when the user never says \"I prefer X.\"\n- Frame preferences as \"The user would prefer responses that...\" when applicable.\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\"content\": \"actionable rule text\", \"category\": \"rule|principle\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ],\n \"preferences\": [\n {\"statement\": \"The user would prefer...\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ]\n}\n\nIf no clear patterns exist, return {\"rules\": [], \"preferences\": []}.`;\n\nasync function consolidateWithLlm(\n context: string,\n llm: ConsolidationLlmClient,\n options: { agentId?: string; modelChain?: AgentPersonaModelConfig } = {},\n): Promise<LlmConsolidationResult> {\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CONSOLIDATION_PROMPT },\n { role: \"user\", content: context },\n ],\n { temperature: 0.2, maxTokens: 2000, agentId: options.agentId, modelChain: options.modelChain },\n );\n\n if (!response?.content) {\n return { rules: [], preferences: [] };\n }\n\n try {\n // Extract JSON from response (may have markdown code fences)\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n const rawPreferences: unknown[] = Array.isArray(parsed.preferences) ? parsed.preferences : [];\n return {\n rules: rawRules\n .map(parseLlmRule)\n .filter((rule): rule is LlmConsolidationResult[\"rules\"][number] => !!rule),\n preferences: rawPreferences\n .map(parseLlmPreference)\n .filter((pref): pref is LlmConsolidationResult[\"preferences\"][number] => !!pref),\n };\n } catch {\n log.warn(\"[cmc] failed to parse LLM consolidation response\");\n return { rules: [], preferences: [] };\n }\n}\n\n// ─── Candidate Generation ────────────────────────────────────────────────────\n\nfunction stablePatternId(content: string): string {\n const digest = createHash(\"sha256\")\n .update(`causal-pattern\\0${content}`)\n .digest(\"hex\")\n .slice(0, 16);\n return `causal-pattern:${digest}`;\n}\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidence(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction parseLlmRule(raw: unknown): LlmConsolidationResult[\"rules\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const r = raw as Record<string, unknown>;\n const content = typeof r.content === \"string\" ? r.content.trim() : \"\";\n const category = typeof r.category === \"string\" ? r.category : \"\";\n const confidence = parseConfidence(r.confidence);\n if (content.length <= 5 || !CAUSAL_RULE_CATEGORIES.has(category) || confidence === undefined) {\n return undefined;\n }\n return {\n content,\n category: category as \"rule\" | \"principle\" | \"preference\",\n confidence,\n evidence: parseEvidence(r.evidence),\n };\n}\n\nfunction parseLlmPreference(raw: unknown): LlmConsolidationResult[\"preferences\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n const statement = typeof p.statement === \"string\" ? p.statement.trim() : \"\";\n const confidence = parseConfidence(p.confidence);\n if (statement.length <= 5 || confidence === undefined) return undefined;\n return {\n statement,\n confidence,\n evidence: parseEvidence(p.evidence),\n };\n}\n\nfunction llmResultToCandidates(result: LlmConsolidationResult): CausalPatternCandidate[] {\n const candidates: CausalPatternCandidate[] = [];\n\n for (const rule of result.rules) {\n const category =\n rule.category === \"principle\" || rule.category === \"preference\"\n ? rule.category\n : \"rule\";\n candidates.push({\n id: stablePatternId(rule.content),\n sourceType: \"causal-pattern\",\n subject: rule.content.slice(0, 80),\n category,\n content: rule.content,\n score: Math.min(1, rule.confidence ?? 0.7),\n rationale: \"LLM-identified causal pattern from cross-session trajectory analysis\",\n outcome: null,\n provenance: (rule.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n for (const preference of result.preferences) {\n candidates.push({\n id: stablePatternId(preference.statement),\n sourceType: \"causal-pattern\",\n subject: preference.statement.slice(0, 80),\n category: \"preference\",\n content: preference.statement,\n score: Math.min(1, preference.confidence ?? 0.7),\n rationale: \"LLM-identified preference from cross-session trajectory analysis\",\n outcome: null,\n provenance: (preference.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n return candidates;\n}\n\nfunction normalizePositiveInteger(value: number, fallback: number): number {\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;\n}\n\nfunction normalizeSuccessThreshold(value: number): number {\n if (!Number.isFinite(value) || value <= 0) return 0;\n return Math.min(1, value);\n}\n\nfunction trajectorySuccessScore(trajectory: CausalTrajectoryRecord): number {\n if (trajectory.outcomeKind === \"success\") return 1;\n if (trajectory.outcomeKind === \"partial\") return 0.5;\n return 0;\n}\n\nfunction averageSuccessScore(trajectories: CausalTrajectoryRecord[]): number {\n if (trajectories.length === 0) return 0;\n const total = trajectories.reduce((sum, trajectory) => sum + trajectorySuccessScore(trajectory), 0);\n return total / trajectories.length;\n}\n\nfunction passesConsolidationGates(\n trajectories: CausalTrajectoryRecord[],\n config: ConsolidationConfig,\n): boolean {\n const minRecurrence = normalizePositiveInteger(config.minRecurrence, 1);\n if (trajectories.length < minRecurrence) return false;\n\n const minSessions = normalizePositiveInteger(config.minSessions, 1);\n const sessionCount = new Set(trajectories.map((trajectory) => trajectory.sessionKey)).size;\n if (sessionCount < minSessions) return false;\n\n const successThreshold = normalizeSuccessThreshold(config.successThreshold);\n if (successThreshold > 0 && averageSuccessScore(trajectories) < successThreshold) {\n return false;\n }\n\n return true;\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Run LLM-assisted consolidation: read trajectories, format causal context,\n * ask LLM to identify patterns and preferences.\n */\nexport async function deriveCausalPromotionCandidates(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n config: ConsolidationConfig;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n llmClient?: ConsolidationLlmClient;\n}): Promise<CausalPatternCandidate[]> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (!passesConsolidationGates(trajectories, options.config)) return [];\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n\n // Format the causal context for the LLM\n let context = formatCausalContext(trajectories, chainIndex);\n\n // Append memory extensions block if available (#382)\n if (options.pluginConfig) {\n const extBlock = await buildExtensionsBlockForConsolidation(options.pluginConfig);\n if (extBlock.length > 0) {\n context += \"\\n\\n\" + extBlock;\n }\n }\n\n // If no LLM available, fall back to empty (no deterministic fallback)\n const llm = options.llmClient ?? new FallbackLlmClient(\n options.gatewayConfig,\n options.pluginConfig\n ? fallbackLlmRuntimeContextFromConfig(options.pluginConfig, {\n workspaceDir: options.workspaceDir ?? options.pluginConfig.workspaceDir,\n })\n : { workspaceDir: options.workspaceDir },\n );\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) {\n log.debug(\"[cmc] no LLM available for consolidation — skipping\");\n return [];\n }\n\n // Call LLM for pattern analysis\n const result = await consolidateWithLlm(context, llm, llmOptions);\n const candidates = llmResultToCandidates(result);\n\n log.debug(`[cmc] LLM consolidation produced ${candidates.length} rule(s) and ${result.preferences.length} preference(s)`);\n return candidates;\n } catch (error) {\n log.warn(`[cmc] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n}\n\n/**\n * Get LLM-synthesized preferences from causal trajectory analysis.\n * Returns formatted preference statements for recall injection.\n */\nexport async function synthesizeCausalPreferencesViaLlm(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n minTrajectories?: number;\n}): Promise<string | null> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (trajectories.length < (options.minTrajectories ?? 2)) return null;\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n const context = formatCausalContext(trajectories, chainIndex);\n\n const llm = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) return null;\n\n const result = await consolidateWithLlm(context, llm, llmOptions);\n if (result.preferences.length === 0 && result.rules.length === 0) return null;\n\n const lines: string[] = [\"## Behavioral Insights (from Causal Chain Analysis)\", \"\"];\n\n for (const pref of result.preferences) {\n lines.push(`- ${pref.statement}`);\n }\n\n for (const rule of result.rules) {\n lines.push(`- ${rule.content}`);\n }\n\n lines.push(\"\");\n return lines.join(\"\\n\");\n } catch (error) {\n log.warn(`[cmc] preference synthesis failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return null;\n }\n}\n\n/**\n * Optional post-consolidation hook — materializes Codex-native memory artifacts\n * after a causal consolidation run. Guarded by `codexMaterializeMemories` and\n * `codexMaterializeOnConsolidation`. Returns `null` when disabled or when the\n * sentinel is missing (honors user hand-edits).\n *\n * Split from the orchestrator-owned flow so #378 avoids touching\n * orchestrator.ts while Wave 1 edits are in flight.\n */\nexport async function materializeAfterCausalConsolidation(options: {\n config: PluginConfig;\n namespace?: string;\n memories?: MemoryFile[];\n memoryDir?: string;\n codexHome?: string;\n rolloutSummaries?: RolloutSummaryInput[];\n now?: Date;\n}): Promise<MaterializeResult | null> {\n // Delegates to the shared post-consolidation helper — see\n // runPostConsolidationMaterialize in codex-materialize-runner.ts.\n return runPostConsolidationMaterialize(\"[cmc]\", options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAO3B,OAAO,UAAU;AA0CjB,IAAM,yBAAyB,oBAAI,IAAI,CAAC,QAAQ,aAAa,YAAY,CAAC;AAY1E,eAAe,oBACb,WACA,0BACmC;AACnC,QAAM,OAAO,gCAAgC,WAAW,wBAAwB;AAChF,QAAM,kBAAkB,KAAK,KAAK,MAAM,cAAc;AAEtD,QAAM,QAAQ,MAAM,cAAc,eAAe,EAAE,MAAM,MAAM,CAAC,CAAa;AAC7E,QAAM,UAAoC,CAAC;AAE3C,aAAW,YAAY,OAAO;AAC5B,QAAI;AACF,YAAM,MAAM,MAAM,aAAa,QAAQ;AACvC,UAAI,SAAS,GAAG,KAAK,OAAO,IAAI,iBAAiB,UAAU;AACzD,gBAAQ,KAAK,GAAwC;AAAA,MACvD;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,SAAO;AACT;AAQA,SAAS,oBACP,cACA,YACA,WAAmB,KACX;AAER,QAAM,YAAY,oBAAI,IAAsC;AAC5D,aAAW,KAAK,cAAc;AAC5B,UAAM,OAAO,UAAU,IAAI,EAAE,UAAU,KAAK,CAAC;AAC7C,SAAK,KAAK,CAAC;AACX,cAAU,IAAI,EAAE,YAAY,IAAI;AAAA,EAClC;AAEA,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,2BAA2B,aAAa,MAAM,WAAW,UAAU,IAAI,YAAY;AAC9F,QAAM,KAAK,EAAE;AAGb,aAAW,CAAC,YAAY,YAAY,KAAK,WAAW;AAClD,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,CAAC,uDAAuD,EAAE;AAElF,eAAW,QAAQ,OAAO,aAAa;AACrC,YAAM,KAAK,KAAK,KAAK,SAAS,EAAE;AAAA,IAClC;AAEA,eAAW,QAAQ,OAAO,OAAO;AAC/B,YAAM,KAAK,KAAK,KAAK,OAAO,EAAE;AAAA,IAChC;AAEA,UAAM,KAAK,EAAE;AACb,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB,SAAS,OAAO;AACd,QAAI,KAAK,kDAAkD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AACnH,WAAO;AAAA,EACT;AACF;AAWA,eAAsB,oCAAoC,SAQpB;AAGpC,SAAO,gCAAgC,SAAS,OAAO;AACzD;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-7WV3F5DQ.js";
|
|
4
4
|
import {
|
|
5
5
|
AdapterRegistry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JBPKEARU.js";
|
|
7
7
|
import {
|
|
8
8
|
EngramMcpServer,
|
|
9
9
|
cleanupExpiredChatSessions,
|
|
@@ -11,17 +11,17 @@ import {
|
|
|
11
11
|
processChatMessage,
|
|
12
12
|
sessionBelongsToPrincipal,
|
|
13
13
|
subscribeChatTranscript
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-WAIMHMO3.js";
|
|
15
15
|
import {
|
|
16
16
|
validateRequest
|
|
17
17
|
} from "./chunk-2MR3MFQB.js";
|
|
18
18
|
import {
|
|
19
19
|
getOperation
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-DPZ5GJMD.js";
|
|
21
21
|
import {
|
|
22
22
|
CorrectionContractError,
|
|
23
23
|
EngramAccessInputError
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LAJIXABF.js";
|
|
25
25
|
import {
|
|
26
26
|
isTrustZoneName
|
|
27
27
|
} from "./chunk-JGSKJHF7.js";
|
|
@@ -2627,4 +2627,4 @@ function positiveIntQueryParam(value, label) {
|
|
|
2627
2627
|
export {
|
|
2628
2628
|
EngramAccessHttpServer
|
|
2629
2629
|
};
|
|
2630
|
-
//# sourceMappingURL=chunk-
|
|
2630
|
+
//# sourceMappingURL=chunk-2KYXXMTE.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDefaultNamespaceRoot,
|
|
3
3
|
resolveNamespaceStorageRoot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PNFN7SIN.js";
|
|
5
5
|
import {
|
|
6
6
|
getConfiguredNamespaces
|
|
7
7
|
} from "./chunk-BAVVI5GP.js";
|
|
@@ -2042,4 +2042,4 @@ export {
|
|
|
2042
2042
|
runNamespaceMaintenancePlan,
|
|
2043
2043
|
runNamespaceMaintenanceBatchPlan
|
|
2044
2044
|
};
|
|
2045
|
-
//# sourceMappingURL=chunk-
|
|
2045
|
+
//# sourceMappingURL=chunk-2PGB63VU.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-7FL4CNPV.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P7W4CDX6.js";
|
|
7
7
|
import {
|
|
8
8
|
getCachedEpisodeMap,
|
|
9
9
|
setCachedEpisodeMap
|
|
@@ -107,4 +107,4 @@ export {
|
|
|
107
107
|
compareVerifiedEpisodeResults,
|
|
108
108
|
searchVerifiedEpisodes
|
|
109
109
|
};
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-4HYJETVO.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SQLITE_SCHEMA_VERSION
|
|
3
|
+
} from "./chunk-Z734BLO3.js";
|
|
1
4
|
import {
|
|
2
5
|
parseConflictPolicy,
|
|
3
6
|
validateManifestRecords
|
|
4
7
|
} from "./chunk-G4IAEX6D.js";
|
|
5
|
-
import {
|
|
6
|
-
SQLITE_SCHEMA_VERSION
|
|
7
|
-
} from "./chunk-Z734BLO3.js";
|
|
8
8
|
import {
|
|
9
9
|
openBetterSqlite3
|
|
10
10
|
} from "./chunk-6KYMPV2O.js";
|
|
@@ -84,4 +84,4 @@ async function importSqlite(opts) {
|
|
|
84
84
|
export {
|
|
85
85
|
importSqlite
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-AGNBY3VG.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSearchBackend
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NKP6II6G.js";
|
|
4
4
|
import {
|
|
5
5
|
namespaceIdentityToken,
|
|
6
6
|
normalizeNamespaceIdentity
|
|
@@ -404,4 +404,4 @@ export {
|
|
|
404
404
|
namespaceCollectionName,
|
|
405
405
|
NamespaceSearchRouter
|
|
406
406
|
};
|
|
407
|
-
//# sourceMappingURL=chunk-
|
|
407
|
+
//# sourceMappingURL=chunk-BRYPUVJU.js.map
|
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
openclawReplayNormalizer
|
|
9
9
|
} from "./chunk-7F7Z6MOS.js";
|
|
10
|
+
import {
|
|
11
|
+
exportSqlite
|
|
12
|
+
} from "./chunk-7VFZTJ7K.js";
|
|
10
13
|
import {
|
|
11
14
|
importMarkdownBundle
|
|
12
15
|
} from "./chunk-HDDRVXX4.js";
|
|
13
16
|
import {
|
|
14
17
|
importSqlite
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-AGNBY3VG.js";
|
|
16
19
|
import {
|
|
17
20
|
detectImportFormat
|
|
18
21
|
} from "./chunk-OZKVVUJB.js";
|
|
@@ -29,8 +32,8 @@ import {
|
|
|
29
32
|
exportMarkdownBundle
|
|
30
33
|
} from "./chunk-765K3SAT.js";
|
|
31
34
|
import {
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
WebDavServer
|
|
36
|
+
} from "./chunk-PYIFUBRK.js";
|
|
34
37
|
import {
|
|
35
38
|
buildReplayNormalizerRegistry,
|
|
36
39
|
clampBatchSize,
|
|
@@ -43,29 +46,26 @@ import {
|
|
|
43
46
|
import {
|
|
44
47
|
RoutingRulesStore
|
|
45
48
|
} from "./chunk-WIWPSQYU.js";
|
|
49
|
+
import {
|
|
50
|
+
rebuildObservations
|
|
51
|
+
} from "./chunk-LZZNTPLR.js";
|
|
46
52
|
import {
|
|
47
53
|
TailscaleHelper
|
|
48
54
|
} from "./chunk-EEC4PCG5.js";
|
|
49
55
|
import {
|
|
50
|
-
|
|
51
|
-
} from "./chunk-
|
|
56
|
+
archiveObservations
|
|
57
|
+
} from "./chunk-WMWVO45V.js";
|
|
52
58
|
import {
|
|
53
59
|
migrateObservations
|
|
54
60
|
} from "./chunk-D6RIFG4O.js";
|
|
55
61
|
import {
|
|
56
62
|
rebuildMemoryLifecycleLedger
|
|
57
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-TEKTCF2V.js";
|
|
58
64
|
import {
|
|
59
65
|
rebuildMemoryProjection,
|
|
60
66
|
repairMemoryProjection,
|
|
61
67
|
verifyMemoryProjection
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import {
|
|
64
|
-
rebuildObservations
|
|
65
|
-
} from "./chunk-LZZNTPLR.js";
|
|
66
|
-
import {
|
|
67
|
-
archiveObservations
|
|
68
|
-
} from "./chunk-WMWVO45V.js";
|
|
68
|
+
} from "./chunk-IIURIWJG.js";
|
|
69
69
|
import {
|
|
70
70
|
getBulkImportSource,
|
|
71
71
|
listBulkImportSources,
|
|
@@ -85,16 +85,16 @@ import {
|
|
|
85
85
|
} from "./chunk-TERNBNJB.js";
|
|
86
86
|
import {
|
|
87
87
|
searchVerifiedEpisodes
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-4HYJETVO.js";
|
|
89
89
|
import {
|
|
90
90
|
ThreadingManager
|
|
91
91
|
} from "./chunk-QRDOSYOR.js";
|
|
92
92
|
import {
|
|
93
93
|
promoteSemanticRuleFromMemory
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-KZWUJC7Y.js";
|
|
95
95
|
import {
|
|
96
96
|
searchVerifiedSemanticRules
|
|
97
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-ES3GAMSQ.js";
|
|
98
98
|
import {
|
|
99
99
|
resolveAgentAccessAuthToken
|
|
100
100
|
} from "./chunk-TGQ2NTWH.js";
|
|
@@ -126,12 +126,12 @@ import {
|
|
|
126
126
|
runOperatorInventory,
|
|
127
127
|
runOperatorRepair,
|
|
128
128
|
runOperatorSetup
|
|
129
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-ESDBHQY6.js";
|
|
130
130
|
import {
|
|
131
131
|
listNamespaces,
|
|
132
132
|
runNamespaceMigration,
|
|
133
133
|
verifyNamespaces
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-QPFO54VC.js";
|
|
135
135
|
import {
|
|
136
136
|
analyzeSessionIntegrity,
|
|
137
137
|
applySessionRepair,
|
|
@@ -213,7 +213,7 @@ import {
|
|
|
213
213
|
} from "./chunk-OADWQ5CR.js";
|
|
214
214
|
import {
|
|
215
215
|
EngramAccessHttpServer
|
|
216
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-2KYXXMTE.js";
|
|
217
217
|
import {
|
|
218
218
|
WearablesInputError
|
|
219
219
|
} from "./chunk-7WV3F5DQ.js";
|
|
@@ -226,10 +226,10 @@ import {
|
|
|
226
226
|
createProductionChatLlmAdapter,
|
|
227
227
|
loadChatSession,
|
|
228
228
|
sessionBelongsToPrincipal
|
|
229
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-WAIMHMO3.js";
|
|
230
230
|
import {
|
|
231
231
|
EngramAccessService
|
|
232
|
-
} from "./chunk-
|
|
232
|
+
} from "./chunk-LAJIXABF.js";
|
|
233
233
|
import {
|
|
234
234
|
WorkStorage
|
|
235
235
|
} from "./chunk-GDB4J2H3.js";
|
|
@@ -252,7 +252,7 @@ import {
|
|
|
252
252
|
readMemoryGovernanceRunArtifact,
|
|
253
253
|
restoreMemoryGovernanceRun,
|
|
254
254
|
runMemoryGovernance
|
|
255
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-HDYFNXVO.js";
|
|
256
256
|
import {
|
|
257
257
|
getObjectiveStateStoreStatus
|
|
258
258
|
} from "./chunk-6HMYUWXR.js";
|
|
@@ -3590,7 +3590,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
3590
3590
|
const idArg = typeof args[0] === "string" ? args[0] : "";
|
|
3591
3591
|
const options = args[1] ?? {};
|
|
3592
3592
|
const reason = typeof options.reason === "string" && options.reason.trim().length > 0 ? options.reason.trim() : void 0;
|
|
3593
|
-
const { forgetMemory } = await import("./forget-
|
|
3593
|
+
const { forgetMemory } = await import("./forget-WYLR4ZFV.js");
|
|
3594
3594
|
try {
|
|
3595
3595
|
const result = await forgetMemory(orchestrator.storage, {
|
|
3596
3596
|
id: idArg,
|
|
@@ -7520,4 +7520,4 @@ export {
|
|
|
7520
7520
|
listMemoryMarkdownFilePaths,
|
|
7521
7521
|
registerCli
|
|
7522
7522
|
};
|
|
7523
|
-
//# sourceMappingURL=chunk-
|
|
7523
|
+
//# sourceMappingURL=chunk-DB647OZ4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EngramAccessInputError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LAJIXABF.js";
|
|
4
4
|
import {
|
|
5
5
|
expandTildePath
|
|
6
6
|
} from "./chunk-EYIEWJNI.js";
|
|
@@ -130,4 +130,4 @@ export {
|
|
|
130
130
|
listRegisteredOperations,
|
|
131
131
|
__resetRegistryForTest
|
|
132
132
|
};
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
133
|
+
//# sourceMappingURL=chunk-DPZ5GJMD.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
log
|
|
3
|
+
} from "./chunk-NU3CSQ4H.js";
|
|
4
|
+
|
|
5
|
+
// src/storage-guards.ts
|
|
6
|
+
var PROJECTION_FALLBACK_WARN_INTERVAL_MS = 5 * 6e4;
|
|
7
|
+
var projectionFallbackWarnedAt = /* @__PURE__ */ new Map();
|
|
8
|
+
function assertMemoryFrontmatterId(fm) {
|
|
9
|
+
if (typeof fm.id !== "string" || fm.id.trim().length === 0) {
|
|
10
|
+
const context = [
|
|
11
|
+
fm.category ? `category=${fm.category}` : null,
|
|
12
|
+
fm.created ? `created=${fm.created}` : null,
|
|
13
|
+
fm.entityRef ? `entityRef=${fm.entityRef}` : null
|
|
14
|
+
].filter(Boolean).join(" ");
|
|
15
|
+
throw new Error(
|
|
16
|
+
`memory frontmatter id must not be blank${context ? ` (${context})` : ""}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function warnProjectionFallback(memoryDir, consumer) {
|
|
21
|
+
const key = `${memoryDir}\0${consumer}`;
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
const warnedAt = projectionFallbackWarnedAt.get(key) ?? 0;
|
|
24
|
+
if (now - warnedAt >= PROJECTION_FALLBACK_WARN_INTERVAL_MS) {
|
|
25
|
+
projectionFallbackWarnedAt.set(key, now);
|
|
26
|
+
log.warn(`storage.${consumer}: memory projection absent or empty; falling back to full corpus`);
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
assertMemoryFrontmatterId,
|
|
33
|
+
warnProjectionFallback
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-DQC3ZZYM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage-guards.ts"],"sourcesContent":["import { log } from \"./logger.js\";\n\nconst PROJECTION_FALLBACK_WARN_INTERVAL_MS = 5 * 60_000;\nconst projectionFallbackWarnedAt = new Map<string, number>();\n\nexport function assertMemoryFrontmatterId(\n fm: { id: string; category?: string; created?: string; entityRef?: string },\n): void {\n if (typeof fm.id !== \"string\" || fm.id.trim().length === 0) {\n const context = [\n fm.category ? `category=${fm.category}` : null,\n fm.created ? `created=${fm.created}` : null,\n fm.entityRef ? `entityRef=${fm.entityRef}` : null,\n ].filter(Boolean).join(\" \");\n throw new Error(\n `memory frontmatter id must not be blank${context ? ` (${context})` : \"\"}`,\n );\n }\n}\n\nexport function warnProjectionFallback(memoryDir: string, consumer: string): null {\n const key = `${memoryDir}\\0${consumer}`;\n const now = Date.now();\n const warnedAt = projectionFallbackWarnedAt.get(key) ?? 0;\n if (now - warnedAt >= PROJECTION_FALLBACK_WARN_INTERVAL_MS) {\n projectionFallbackWarnedAt.set(key, now);\n log.warn(`storage.${consumer}: memory projection absent or empty; falling back to full corpus`);\n }\n return null;\n}\n"],"mappings":";;;;;AAEA,IAAM,uCAAuC,IAAI;AACjD,IAAM,6BAA6B,oBAAI,IAAoB;AAEpD,SAAS,0BACd,IACM;AACN,MAAI,OAAO,GAAG,OAAO,YAAY,GAAG,GAAG,KAAK,EAAE,WAAW,GAAG;AAC1D,UAAM,UAAU;AAAA,MACd,GAAG,WAAW,YAAY,GAAG,QAAQ,KAAK;AAAA,MAC1C,GAAG,UAAU,WAAW,GAAG,OAAO,KAAK;AAAA,MACvC,GAAG,YAAY,aAAa,GAAG,SAAS,KAAK;AAAA,IAC/C,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC1B,UAAM,IAAI;AAAA,MACR,0CAA0C,UAAU,KAAK,OAAO,MAAM,EAAE;AAAA,IAC1E;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,WAAmB,UAAwB;AAChF,QAAM,MAAM,GAAG,SAAS,KAAK,QAAQ;AACrC,QAAM,MAAM,KAAK,IAAI;AACrB,QAAM,WAAW,2BAA2B,IAAI,GAAG,KAAK;AACxD,MAAI,MAAM,YAAY,sCAAsC;AAC1D,+BAA2B,IAAI,KAAK,GAAG;AACvC,QAAI,KAAK,WAAW,QAAQ,kEAAkE;AAAA,EAChG;AACA,SAAO;AACT;","names":[]}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-5QANTTY2.js";
|
|
11
11
|
import {
|
|
12
12
|
MaintenanceScheduler
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QWIE43BS.js";
|
|
14
14
|
import {
|
|
15
15
|
runPeerProfileReasoner
|
|
16
16
|
} from "./chunk-I74SUMNI.js";
|
|
@@ -19,20 +19,20 @@ import {
|
|
|
19
19
|
} from "./chunk-7HYPN2GC.js";
|
|
20
20
|
import {
|
|
21
21
|
LcmEngine
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-V5RVMULT.js";
|
|
23
|
+
import {
|
|
24
|
+
chunkTranscriptEntries
|
|
25
|
+
} from "./chunk-TECVW3JP.js";
|
|
23
26
|
import {
|
|
24
27
|
cleanupConversationChunks
|
|
25
28
|
} from "./chunk-O7GOFAM3.js";
|
|
26
29
|
import {
|
|
27
30
|
CompoundingEngine,
|
|
28
31
|
defaultTierMigrationCycleBudget
|
|
29
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-HMUEAKSD.js";
|
|
30
33
|
import {
|
|
31
34
|
SharedContextManager
|
|
32
35
|
} from "./chunk-JRZV3767.js";
|
|
33
|
-
import {
|
|
34
|
-
chunkTranscriptEntries
|
|
35
|
-
} from "./chunk-TECVW3JP.js";
|
|
36
36
|
import {
|
|
37
37
|
applyUtilityPromotionRuntimePolicy,
|
|
38
38
|
applyUtilityRankingRuntimeDelta,
|
|
@@ -58,6 +58,9 @@ import {
|
|
|
58
58
|
import {
|
|
59
59
|
renderEpistemicHedge
|
|
60
60
|
} from "./chunk-YN2UN7N3.js";
|
|
61
|
+
import {
|
|
62
|
+
HourlySummarizer
|
|
63
|
+
} from "./chunk-NNL4LJAD.js";
|
|
61
64
|
import {
|
|
62
65
|
buildTargetedFactRecallSection,
|
|
63
66
|
shouldRecallTargetedFactEvidence
|
|
@@ -65,9 +68,6 @@ import {
|
|
|
65
68
|
import {
|
|
66
69
|
CODEX_THREAD_KEY_PREFIX
|
|
67
70
|
} from "./chunk-4EX5WZ4M.js";
|
|
68
|
-
import {
|
|
69
|
-
HourlySummarizer
|
|
70
|
-
} from "./chunk-NNL4LJAD.js";
|
|
71
71
|
import {
|
|
72
72
|
SessionObserverState
|
|
73
73
|
} from "./chunk-DKTSR7EK.js";
|
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
buildEntityRecallSection,
|
|
192
192
|
entityRecentTranscriptLookbackHours,
|
|
193
193
|
readRecentEntityTranscriptEntries
|
|
194
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-ZTBH2OHD.js";
|
|
195
195
|
import {
|
|
196
196
|
buildEventOrderRecallSection,
|
|
197
197
|
shouldRecallEventOrderEvidence
|
|
@@ -208,14 +208,14 @@ import {
|
|
|
208
208
|
import {
|
|
209
209
|
compareVerifiedEpisodeResults,
|
|
210
210
|
searchVerifiedEpisodes
|
|
211
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-4HYJETVO.js";
|
|
212
212
|
import {
|
|
213
213
|
ThreadingManager
|
|
214
214
|
} from "./chunk-QRDOSYOR.js";
|
|
215
215
|
import {
|
|
216
216
|
compareVerifiedSemanticRuleResults,
|
|
217
217
|
searchVerifiedSemanticRules
|
|
218
|
-
} from "./chunk-
|
|
218
|
+
} from "./chunk-ES3GAMSQ.js";
|
|
219
219
|
import {
|
|
220
220
|
searchWorkProductLedgerEntries
|
|
221
221
|
} from "./chunk-ZRWB5D4H.js";
|
|
@@ -228,14 +228,14 @@ import {
|
|
|
228
228
|
import {
|
|
229
229
|
runNamespaceMaintenanceFanout,
|
|
230
230
|
summarizeNamespaceMaintenanceHealth
|
|
231
|
-
} from "./chunk-
|
|
231
|
+
} from "./chunk-ESDBHQY6.js";
|
|
232
232
|
import {
|
|
233
233
|
NamespaceCatalog,
|
|
234
234
|
planNamespaceMaintenance
|
|
235
|
-
} from "./chunk-
|
|
235
|
+
} from "./chunk-2PGB63VU.js";
|
|
236
236
|
import {
|
|
237
237
|
NamespaceStorageRouter
|
|
238
|
-
} from "./chunk-
|
|
238
|
+
} from "./chunk-PNFN7SIN.js";
|
|
239
239
|
import {
|
|
240
240
|
isAboveImportanceThreshold,
|
|
241
241
|
scoreImportance
|
|
@@ -270,7 +270,7 @@ import {
|
|
|
270
270
|
materializeAfterSemanticConsolidation,
|
|
271
271
|
parseConsolidationResponse,
|
|
272
272
|
parseOperatorAwareConsolidationResponse
|
|
273
|
-
} from "./chunk-
|
|
273
|
+
} from "./chunk-HDFS6RWQ.js";
|
|
274
274
|
import {
|
|
275
275
|
BoxBuilder
|
|
276
276
|
} from "./chunk-7FL4CNPV.js";
|
|
@@ -316,7 +316,7 @@ import {
|
|
|
316
316
|
createCorrectionService,
|
|
317
317
|
detectPassiveCorrections,
|
|
318
318
|
qmdCollectionPathParts
|
|
319
|
-
} from "./chunk-
|
|
319
|
+
} from "./chunk-LAJIXABF.js";
|
|
320
320
|
import {
|
|
321
321
|
importCapsule
|
|
322
322
|
} from "./chunk-M5QKGHCR.js";
|
|
@@ -343,11 +343,11 @@ import {
|
|
|
343
343
|
} from "./chunk-BAVVI5GP.js";
|
|
344
344
|
import {
|
|
345
345
|
NamespaceSearchRouter
|
|
346
|
-
} from "./chunk-
|
|
346
|
+
} from "./chunk-BRYPUVJU.js";
|
|
347
347
|
import {
|
|
348
348
|
createConversationIndexRuntime,
|
|
349
349
|
createSearchBackend
|
|
350
|
-
} from "./chunk-
|
|
350
|
+
} from "./chunk-NKP6II6G.js";
|
|
351
351
|
import {
|
|
352
352
|
NoopSearchBackend
|
|
353
353
|
} from "./chunk-CYEPCZN5.js";
|
|
@@ -383,7 +383,7 @@ import {
|
|
|
383
383
|
} from "./chunk-SQNED75R.js";
|
|
384
384
|
import {
|
|
385
385
|
buildChainFollowupGenerator
|
|
386
|
-
} from "./chunk-
|
|
386
|
+
} from "./chunk-VHYFY3JI.js";
|
|
387
387
|
import {
|
|
388
388
|
ContentHashIndex,
|
|
389
389
|
StorageManager,
|
|
@@ -392,7 +392,7 @@ import {
|
|
|
392
392
|
normalizeAttributePairs,
|
|
393
393
|
parseEntityFile,
|
|
394
394
|
selfDeps
|
|
395
|
-
} from "./chunk-
|
|
395
|
+
} from "./chunk-P7W4CDX6.js";
|
|
396
396
|
import {
|
|
397
397
|
isValidTranscriptDate,
|
|
398
398
|
loadSpeakerRegistry,
|
|
@@ -22723,4 +22723,4 @@ export {
|
|
|
22723
22723
|
blendGraphExpandedRecallScore,
|
|
22724
22724
|
Orchestrator
|
|
22725
22725
|
};
|
|
22726
|
-
//# sourceMappingURL=chunk-
|
|
22726
|
+
//# sourceMappingURL=chunk-EDC7RZCW.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StorageManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P7W4CDX6.js";
|
|
4
4
|
import {
|
|
5
5
|
getCachedRuleMemories,
|
|
6
6
|
setCachedRuleMemories
|
|
@@ -117,4 +117,4 @@ export {
|
|
|
117
117
|
compareVerifiedSemanticRuleResults,
|
|
118
118
|
searchVerifiedSemanticRules
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-ES3GAMSQ.js.map
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
readNamespaceMaintenanceLastRanStatuses,
|
|
4
4
|
readNamespaceMaintenanceStatuses,
|
|
5
5
|
runNamespaceMaintenancePlan
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2PGB63VU.js";
|
|
7
7
|
import {
|
|
8
8
|
listNamespaces
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QPFO54VC.js";
|
|
10
10
|
import {
|
|
11
11
|
analyzeSessionIntegrity,
|
|
12
12
|
applySessionRepair,
|
|
@@ -42,13 +42,13 @@ import {
|
|
|
42
42
|
import {
|
|
43
43
|
listMemoryGovernanceRuns,
|
|
44
44
|
readMemoryGovernanceRunArtifact
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-HDYFNXVO.js";
|
|
46
46
|
import {
|
|
47
47
|
analyzeGraphHealth
|
|
48
48
|
} from "./chunk-EHQ5HO5T.js";
|
|
49
49
|
import {
|
|
50
50
|
StorageManager
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-P7W4CDX6.js";
|
|
52
52
|
import {
|
|
53
53
|
lintWorkspaceFiles
|
|
54
54
|
} from "./chunk-DM2T26WE.js";
|
|
@@ -1599,4 +1599,4 @@ export {
|
|
|
1599
1599
|
runBenchmarkRecall,
|
|
1600
1600
|
runOperatorRepair
|
|
1601
1601
|
};
|
|
1602
|
-
//# sourceMappingURL=chunk-
|
|
1602
|
+
//# sourceMappingURL=chunk-ESDBHQY6.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runPostConsolidationMaterialize
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OQ6F3WBX.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverMemoryExtensions,
|
|
6
6
|
renderExtensionsBlock,
|
|
@@ -220,4 +220,4 @@ export {
|
|
|
220
220
|
buildExtensionsBlockForConsolidation,
|
|
221
221
|
materializeAfterSemanticConsolidation
|
|
222
222
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
223
|
+
//# sourceMappingURL=chunk-HDFS6RWQ.js.map
|