Revert "refactor: remove legacy history and proxy migrations (#6518)"

This reverts commit cb3ba45317.

Keep JSONL history and legacy proxy migration available throughout 0.4.x. Mark their removal for 0.5.0 in code and release guidance, preserving later context graph, archive and recovery changes.
This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-06 10:58:10 +08:00
1 parent 3918ece17f
commit 812b92d734
47 files changed
+1932 -204

No files matched your search

+25
View File
@@ -40,6 +40,7 @@ from nanobot.session.sqlite_store import SessionConflictError
from nanobot.session.state import SessionOperationQueueFullError
from nanobot.webui.history import (
fact_from_record,
initialize_history,
record_from_fact,
turn_records,
)
@@ -319,6 +320,25 @@ def _compact_completed_stream_deltas(
], len(dropped_indexes)
def _compact_completed_turns(
turns: list[list[dict[str, Any]]],
) -> tuple[list[list[dict[str, Any]]], int]:
compacted: list[list[dict[str, Any]]] = []
dropped = 0
for turn in turns:
next_turn, turn_dropped = _compact_completed_stream_deltas(turn)
compacted.append(next_turn)
dropped += turn_dropped
return compacted, dropped
def compact_legacy_records(records: list[dict[str, Any]]) -> list[dict[str, Any]]:
turns, _ = _compact_completed_turns(_split_transcript_turns(records))
return [record for turn in turns for record in turn]
def _records_with_replay_identity(
records: list[dict[str, Any]],
*,
@@ -513,6 +533,11 @@ class WebUITranscriptRecorder:
self._log = log
self._turn_sequences: dict[tuple[str, str], int] = {}
async def initialize(self) -> None:
sessions = self.sessions
if sessions is not None:
await initialize_history(sessions)
def client_turn_metadata(self, value: Any) -> dict[str, str]:
return {WEBUI_TURN_METADATA_KEY: normalize_webui_turn_id(value)}