Agent Zero AI framework
Add built-in Migrate Agents plugin
Alessandro7129e287c3b9
diff --git a/plugins/AGENTS.md b/plugins/AGENTS.mdindex d6b95d751..3e98f0036 100644--- a/plugins/AGENTS.md+++ b/plugins/AGENTS.md@@ -86,6 +86,7 @@ Direct child DOX files:| [_infection_check/AGENTS.md](_infection_check/AGENTS.md) | Prompt-injection safety analysis before tool execution. || [_kokoro_tts/AGENTS.md](_kokoro_tts/AGENTS.md) | Kokoro text-to-speech integration. || [_memory/AGENTS.md](_memory/AGENTS.md) | Optional persistent recall plugin, knowledge import, tools, and dashboard; do not assume it is enabled outside this plugin. |+| [_migrate_agents/AGENTS.md](_migrate_agents/AGENTS.md) | Built-in migration of chats, projects, memories, instructions, and skills from supported agent harnesses. || [_model_config/AGENTS.md](_model_config/AGENTS.md) | Model selection, presets, API-key checks, and scoped overrides. || [_oauth/AGENTS.md](_oauth/AGENTS.md) | OAuth-backed model-provider connections and local proxy routes. || [_office/AGENTS.md](_office/AGENTS.md) | LibreOffice office artifacts and office canvas sessions. |diff --git a/plugins/_migrate_agents/AGENTS.md b/plugins/_migrate_agents/AGENTS.mdnew file mode 100644index 000000000..18845deca--- /dev/null+++ b/plugins/_migrate_agents/AGENTS.md@@ -0,0 +1,35 @@+# Migrate Agents DOX++## Purpose++- Own the bundled workflow for previewing and importing retained work from OpenClaw, Hermes Agent, OpenCode, Claude Code, and Codex.++## Ownership++- `helpers/migration.py` owns source parsing, redaction, limits, preview data, and native chat conversion.+- `api/migration_preview.py` owns read-only upload inspection; `api/migration_import.py` owns confirmed writes.+- `webui/` and the sidebar extension own source selection, upload, review, consent, and progress UI.+- `tests/` owns parser, privacy, archive-safety, native-chat, project, and import-helper regression coverage.++## Local Contracts++- The bundled folder, manifest name, Python imports, and HTTP routes use `_migrate_agents`.+- Preview must not write Agent Zero state. Import starts only after explicit category selection and review consent.+- Credentials, authentication state, hidden reasoning, schedules, live services, and replayable tool execution stay excluded.+- Imported knowledge and skills remain namespaced below `usr/knowledge/_migrate_agents/` and `usr/skills/_migrate_agents/`.+- Preserve source provenance and do not claim transcript metadata can reconstruct unavailable project files.++## Work Guidance++- Extend the shared parser and redaction path instead of adding source-specific import side channels.+- Keep source commands, supported artifacts, exclusions, and mapping limits accurate in both WebUI copy and README.+- Keep bundled harness assets local and update `webui/assets/ATTRIBUTION.md` when their provenance changes.++## Verification++- Run `conda run -n a0 python -m pytest plugins/_migrate_agents/tests -q`.+- For WebUI changes, verify the mounted modal and upload flow against the named live Agent Zero runtime.++## Child DOX Index++No child DOX files.diff --git a/plugins/_migrate_agents/README.md b/plugins/_migrate_agents/README.mdnew file mode 100644index 000000000..528dfd45e--- /dev/null+++ b/plugins/_migrate_agents/README.md@@ -0,0 +1,78 @@+# Migrate Agents++++Migrate Agents is a bundled Agent Zero plugin for bringing retained work+home from the five most-used open agent harnesses:++- OpenClaw+- Hermes Agent+- OpenCode+- Claude Code+- Codex++The plugin checks an export before importing it. You choose which chats,+projects, memories, instructions, and skills to bring into Agent Zero.+Credentials, authentication files, and hidden reasoning are excluded.++## Enable++Enable **Migrate Agents** in Plugins, then use the inbox button beside Dashboard.++## Prepare an export++| Source | Recommended input |+| --- | --- |+| OpenClaw | `openclaw backup create --verify`, an agent SQLite snapshot, or legacy transcript JSONL |+| Hermes Agent | `hermes sessions export backup.jsonl --redact`, `~/.hermes/state.db`, or a folder/archive containing memories and skills |+| OpenCode | `opencode export <session-id> > session.json`, repeated for each session you want |+| Claude Code | A folder/archive from `~/.claude/projects`, plus any `CLAUDE.md` and skills you want |+| Codex | The `sessions/` and `archived_sessions/` folders beneath `CODEX_HOME` (normally `~/.codex`) |++You can choose individual files, a whole directory, ZIP, TAR, or TAR.GZ. The+preview is read-only. Import does not start until you review the manifest and+confirm it.++## What maps cleanly++| Source material | Agent Zero destination | Notes |+| --- | --- | --- |+| User and assistant messages | Native chats | Source ID, timestamps, and workspace metadata are retained when available. |+| Retained workspace paths | Native projects | Chats from the same retained workspace are attached to the same imported project. Project files are not reconstructed from transcript metadata alone. |+| Tool activity | Historical tool records | Sanitized and inert; never replayed as commands. |+| Memory Markdown | `usr/knowledge/_migrate_agents/<source>/memories/` | Each document receives a provenance header. |+| `SOUL.md`, `USER.md`, `CLAUDE.md`, `AGENTS.md`, and related instructions | `usr/knowledge/_migrate_agents/<source>/instructions/` | Instructions remain separately selectable from memories. |+| Agent Skills containing `SKILL.md` | `usr/skills/_migrate_agents/<source>/` | Complete skill folders are copied under unique names. |+| Attachment references | Chat metadata or text | Binary attachment copying is not automatic. |++## Deliberate privacy boundary++Migrate Agents never imports provider keys, credentials, authentication+state, channel bindings, schedules, hidden reasoning, or live services. It+redacts obvious secret assignments, bearer tokens, private keys, and embedded+data URLs from imported text and tool records. This is defense in depth, not a+guarantee; review migrated material before sharing it.++The Codex adapter follows the preservation and privacy rules of the+`convert-codex-chats` utility skill: public user/commentary/final events are+retained, tool calls and results are paired when available, encrypted or hidden+reasoning is excluded, and historical actions are not presented as replayable.++## Limits++- 5,000 expanded files per migration+- 100 MiB per file+- 256 MiB expanded total+- Preview lists are capped at 200 rows, while import still processes the full accepted bundle+- Modern OpenClaw conversation imports require its per-agent database or transcript artifacts; the global control-plane database does not contain chats++## Development++No third-party Python or JavaScript packages are required.++```bash+python -m pytest plugins/_migrate_agents/tests -q+```++Harness logo SVGs are bundled locally under `webui/assets/`; provenance and+license details are recorded in `webui/assets/ATTRIBUTION.md`.diff --git a/plugins/_migrate_agents/api/migration_import.py b/plugins/_migrate_agents/api/migration_import.pynew file mode 100644index 000000000..e0461b8f6--- /dev/null+++ b/plugins/_migrate_agents/api/migration_import.py@@ -0,0 +1,167 @@+from __future__ import annotations++import json+import os+import re+import time+import uuid+from pathlib import Path, PurePosixPath++from agent import AgentContext+from helpers import files, persist_chat, projects as a0_projects+from helpers.api import ApiHandler, Input, Output, Request, Response+from plugins._migrate_agents.api.migration_preview import uploaded_files+from plugins._migrate_agents.helpers.migration import Asset, Project, build_a0_chat, parse_bundle+++def _slug(value: str, fallback: str) -> str:+ result = re.sub(r"[^a-z0-9_-]+", "_", value.lower()).strip("_")+ return (result or fallback)[:80]+++def _unique_dir(parent: Path, name: str) -> Path:+ candidate = parent / name+ index = 2+ while candidate.exists():+ candidate = parent / f"{name}_{index}"+ index += 1+ return candidate+++def _atomic_write(path: Path, data: bytes) -> None:+ path.parent.mkdir(parents=True, exist_ok=True)+ temporary = path.with_name(f".{path.name}.{uuid.uuid4().hex}.tmp")+ try:+ with temporary.open("wb") as handle:+ handle.write(data)+ handle.flush()+ os.fsync(handle.fileno())+ temporary.replace(path)+ finally:+ temporary.unlink(missing_ok=True)+++def _knowledge_path(run_root: Path, asset: Asset) -> Path:+ source = PurePosixPath(asset.path)+ name = _slug("_".join(source.parts[-3:]), "knowledge")+ if not name.endswith(".md"):+ name += ".md"+ return run_root / name+++def import_knowledge(source: str, category: str, assets: list[Asset]) -> list[str]:+ if not assets:+ return []+ base = Path(files.get_abs_path("usr", "knowledge", "_migrate_agents", source, category))+ run = _unique_dir(base, time.strftime("%Y%m%d_%H%M%S"))+ written: list[str] = []+ for asset in assets:+ destination = _knowledge_path(run, asset)+ header = (+ f"# Imported from {source}\n\n"+ f"> Original path: `{asset.path}` \n"+ "> Imported by Migrate Agents. Review before sharing.\n\n"+ ).encode()+ _atomic_write(destination, header + asset.data)+ written.append(files.deabsolute_path(str(destination)))+ return written+++def import_skills(source: str, skills: dict[str, list[Asset]]) -> list[str]:+ base = Path(files.get_abs_path("usr", "skills", "_migrate_agents", source))+ written: list[str] = []+ for name, assets in skills.items():+ destination = _unique_dir(base, _slug(name, "skill"))+ for asset in assets:+ relative = PurePosixPath(asset.path)+ if relative.is_absolute() or ".." in relative.parts:+ raise ValueError(f"Unsafe skill path: {asset.path}")+ _atomic_write(destination.joinpath(*relative.parts), asset.data)+ written.append(files.deabsolute_path(str(destination)))+ return written+++def import_projects(source: str, items: list[Project]) -> tuple[list[str], dict[str, str]]:+ parent = Path(a0_projects.get_projects_parent_folder())+ written: list[str] = []+ chat_projects: dict[str, str] = {}+ for item in items:+ base = _slug(f"{source}_{item.title}", f"{source}_project")+ name = base+ index = 2+ while (parent / name).exists():+ name = f"{base}_{index}"+ index += 1+ a0_projects.create_project(+ name,+ {+ "title": item.title,+ "description": f"Imported from {source}. Original workspace: {item.path}",+ "instructions": "",+ "include_agents_md": True,+ "color": "#6366f1",+ "git_url": "",+ },+ )+ written.append(name)+ chat_projects.update({chat_id: name for chat_id in item.conversation_ids})+ return written, chat_projects+++def import_chats(source: str, conversations, chat_projects: dict[str, str] | None = None) -> list[str]:+ payloads = [json.dumps(build_a0_chat(item, source), ensure_ascii=False) for item in conversations]+ if not payloads:+ return []+ ctxids = persist_chat.load_json_chats(payloads)+ if len(ctxids) != len(conversations):+ raise RuntimeError("Imported chat count does not match the migration preview")+ chat_projects = chat_projects or {}+ for ctxid, conversation in zip(ctxids, conversations):+ context = AgentContext.get(ctxid)+ if context is None:+ raise RuntimeError(f"Imported chat was not loaded: {ctxid}")+ project_name = chat_projects.get(conversation.source_id)+ if project_name:+ a0_projects.activate_project(ctxid, project_name)+ else:+ persist_chat.save_tmp_chat(context)+ return ctxids+++class MigrationImport(ApiHandler):+ async def process(self, input: Input, request: Request) -> Output:+ try:+ source = str(request.form.get("source") or "").strip().lower()+ include_chats = request.form.get("include_chats", "true").lower() == "true"+ include_projects = request.form.get("include_projects", "true").lower() == "true"+ legacy_knowledge = request.form.get("include_knowledge", "true")+ include_memories = request.form.get("include_memories", legacy_knowledge).lower() == "true"+ include_instructions = request.form.get("include_instructions", legacy_knowledge).lower() == "true"+ include_skills = request.form.get("include_skills", "true").lower() == "true"+ bundle = parse_bundle(source, uploaded_files(request))+ project_names, chat_projects = import_projects(source, bundle.projects) if include_projects else ([], {})+ ctxids = import_chats(source, bundle.conversations, chat_projects) if include_chats else []+ memories = import_knowledge(source, "memories", bundle.memories) if include_memories else []+ instructions = import_knowledge(source, "instructions", bundle.instructions) if include_instructions else []+ skills = import_skills(source, bundle.skills) if include_skills else []+ return {+ "ok": True,+ "ctxids": ctxids,+ "projects": project_names,+ "memories": memories,+ "instructions": instructions,+ "knowledge": [*memories, *instructions],+ "skills": skills,+ "summary": {+ "chats": len(ctxids),+ "projects": len(project_names),+ "memories": len(memories),+ "instructions": len(instructions),+ "knowledge": len(memories) + len(instructions),+ "skills": len(skills),+ "redactions": bundle.redactions,+ },+ "warnings": bundle.warnings,+ }+ except ValueError as exc:+ return Response(str(exc), 400)diff --git a/plugins/_migrate_agents/api/migration_import.py.dox.md b/plugins/_migrate_agents/api/migration_import.py.dox.mdnew file mode 100644index 000000000..e8679130c--- /dev/null+++ b/plugins/_migrate_agents/api/migration_import.py.dox.md@@ -0,0 +1,17 @@+# migration_import.py DOX++## Purpose++Commit a previously reviewed harness export into native Agent Zero storage.++## Contract++- Auth and CSRF use the default `ApiHandler` protections.+- Accepts the same multipart export as the preview endpoint plus category toggles.+- Creates new chat IDs; it never overwrites an existing chat.+- Writes imported knowledge below `usr/knowledge/_migrate_agents/` and skills below `usr/skills/_migrate_agents/` using unique directories and atomic files.+- Does not import credentials, provider keys, authentication state, schedules, channel bindings, or executable runtime services.++## Verification++Run `python -m pytest plugins/_migrate_agents/tests -q`, then exercise preview and import against the live framework runtime.diff --git a/plugins/_migrate_agents/api/migration_preview.py b/plugins/_migrate_agents/api/migration_preview.pynew file mode 100644index 000000000..64db584d7--- /dev/null+++ b/plugins/_migrate_agents/api/migration_preview.py@@ -0,0 +1,27 @@+from __future__ import annotations++from helpers.api import ApiHandler, Input, Output, Request, Response+from plugins._migrate_agents.helpers.migration import MAX_TOTAL_BYTES, Upload, parse_bundle, preview+++def uploaded_files(request: Request) -> list[Upload]:+ result: list[Upload] = []+ total = 0+ for item in request.files.getlist("files[]"):+ data = item.stream.read(MAX_TOTAL_BYTES + 1)+ total += len(data)+ if total > MAX_TOTAL_BYTES:+ raise ValueError("Upload exceeds the 256 MiB limit")+ result.append(Upload(item.filename or "upload", data))+ if not result:+ raise ValueError("Choose at least one export file or folder")+ return result+++class MigrationPreview(ApiHandler):+ async def process(self, input: Input, request: Request) -> Output:+ try:+ source = str(request.form.get("source") or "").strip().lower()+ return preview(parse_bundle(source, uploaded_files(request)))+ except ValueError as exc:+ return Response(str(exc), 400)diff --git a/plugins/_migrate_agents/api/migration_preview.py.dox.md b/plugins/_migrate_agents/api/migration_preview.py.dox.mdnew file mode 100644index 000000000..aea43fc2e--- /dev/null+++ b/plugins/_migrate_agents/api/migration_preview.py.dox.md@@ -0,0 +1,17 @@+# migration_preview.py DOX++## Purpose++Preview a user-selected harness export without changing Agent Zero state.++## Contract++- Auth and CSRF use the default `ApiHandler` protections.+- Accepts multipart `source` plus one or more `files[]` values.+- Rejects unsafe archives and uploads larger than 256 MiB.+- Returns counts, chat titles, knowledge files, skills, exclusions, and warnings.+- Never returns source message bodies or credential values.++## Verification++Run `python -m pytest plugins/_migrate_agents/tests -q` from the Agent Zero root.diff --git a/plugins/_migrate_agents/extensions/webui/sidebar-quick-actions-main-start/migrate-agents.html b/plugins/_migrate_agents/extensions/webui/sidebar-quick-actions-main-start/migrate-agents.htmlnew file mode 100644index 000000000..4f6077225--- /dev/null+++ b/plugins/_migrate_agents/extensions/webui/sidebar-quick-actions-main-start/migrate-agents.html@@ -0,0 +1,10 @@+<div x-data>+ <button x-move-after=".config-button#dashboard"+ class="config-button"+ id="migrate-agents"+ title="Migrate Agents"+ aria-label="Open Migrate Agents"+ @click="openModal('/plugins/_migrate_agents/webui/main.html')">+ <x-icon name="move_to_inbox"></x-icon>+ </button>+</div>diff --git a/plugins/_migrate_agents/helpers/__init__.py b/plugins/_migrate_agents/helpers/__init__.pynew file mode 100644index 000000000..aa5b92da1--- /dev/null+++ b/plugins/_migrate_agents/helpers/__init__.py@@ -0,0 +1 @@+"""Migrate Agents conversion helpers."""diff --git a/plugins/_migrate_agents/helpers/migration.py b/plugins/_migrate_agents/helpers/migration.pynew file mode 100644index 000000000..00452fdba--- /dev/null+++ b/plugins/_migrate_agents/helpers/migration.py@@ -0,0 +1,887 @@+from __future__ import annotations++import hashlib+import io+import json+import re+import sqlite3+import stat+import tarfile+import tempfile+import uuid+import zipfile+from dataclasses import dataclass, field+from datetime import datetime, timezone+from pathlib import Path, PurePosixPath+from typing import Any, Iterable+++MAX_FILES = 5_000+MAX_FILE_BYTES = 100 * 1024 * 1024+MAX_TOTAL_BYTES = 256 * 1024 * 1024+TEXT_SUFFIXES = {+ ".css",+ ".html",+ ".js",+ ".json",+ ".jsonl",+ ".md",+ ".py",+ ".sh",+ ".toml",+ ".ts",+ ".txt",+ ".yaml",+ ".yml",+}+MEMORY_NAMES = {+ "memory.md",+}+INSTRUCTION_NAMES = {+ "agents.md",+ "claude.md",+ "identity.md",+ "soul.md",+ "tools.md",+ "user.md",+}+PROJECT_PATH_KEYS = ("cwd", "directory", "workspace")+SENSITIVE_NAMES = {+ ".credentials.json",+ ".env",+ "auth.json",+ "credentials.json",+ "openclaw.json",+ "settings.json",+}+SECRET_RE = re.compile(+ r"(?i)(\b(?:api[_-]?key|access[_-]?token|refresh[_-]?token|password|passwd|secret)\b[\"']?\s*[:=]\s*[\"']?)([^\s\"']+)"+)+BEARER_RE = re.compile(r"(?i)(Authorization\s*:\s*Bearer\s+)([^\s\"']+)")+PRIVATE_KEY_RE = re.compile(+ r"-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?-----END [^-]*PRIVATE KEY-----"+)+DATA_URL_RE = re.compile(r"data:[^;,\s]+;base64,[A-Za-z0-9+/=_-]+")+++@dataclass(slots=True)+class Upload:+ name: str+ data: bytes+++@dataclass(slots=True)+class Event:+ kind: str+ text: str = ""+ timestamp: float = 0.0+ thoughts: list[str] = field(default_factory=list)+ tool_name: str = ""+ tool_args: dict[str, Any] = field(default_factory=dict)+ tool_result: str = ""+++@dataclass(slots=True)+class Conversation:+ source_id: str+ title: str+ events: list[Event]+ metadata: dict[str, Any] = field(default_factory=dict)+++@dataclass(slots=True)+class Asset:+ path: str+ data: bytes+++@dataclass(slots=True)+class Project:+ source_id: str+ title: str+ path: str+ conversation_ids: list[str] = field(default_factory=list)+++@dataclass(slots=True)+class Bundle:+ source: str+ conversations: list[Conversation] = field(default_factory=list)+ projects: list[Project] = field(default_factory=list)+ memories: list[Asset] = field(default_factory=list)+ instructions: list[Asset] = field(default_factory=list)+ skills: dict[str, list[Asset]] = field(default_factory=dict)+ excluded: list[str] = field(default_factory=list)+ warnings: list[str] = field(default_factory=list)+ redactions: int = 0++ @property+ def knowledge(self) -> list[Asset]:+ return [*self.memories, *self.instructions]++ def summary(self) -> dict[str, int]:+ return {+ "chats": len(self.conversations),+ "projects": len(self.projects),+ "messages": sum(len(item.events) for item in self.conversations),+ "memories": len(self.memories),+ "instructions": len(self.instructions),+ "knowledge": len(self.memories) + len(self.instructions),+ "skills": len(self.skills),+ "excluded": len(self.excluded),+ "redactions": self.redactions,+ }+++def _safe_name(name: str) -> str:+ value = str(PurePosixPath(name.replace("\\", "/")))+ path = PurePosixPath(value)+ if path.is_absolute() or ".." in path.parts:+ raise ValueError(f"Unsafe archive path: {name!r}")+ return value.lstrip("./")+++def expand_uploads(uploads: Iterable[Upload]) -> list[Upload]:+ result: list[Upload] = []+ total = 0++ def add(name: str, data: bytes) -> None:+ nonlocal total+ clean = _safe_name(name)+ if not clean or clean.endswith("/"):+ return+ if len(data) > MAX_FILE_BYTES:+ raise ValueError(f"File exceeds the 100 MiB limit: {clean}")+ total += len(data)+ if total > MAX_TOTAL_BYTES:+ raise ValueError("Expanded upload exceeds the 256 MiB limit")+ result.append(Upload(clean, data))+ if len(result) > MAX_FILES:+ raise ValueError(f"Upload contains more than {MAX_FILES} files")++ for upload in uploads:+ lower = upload.name.lower()+ if lower.endswith(".zip"):+ with zipfile.ZipFile(io.BytesIO(upload.data)) as archive:+ for member in archive.infolist():+ mode = member.external_attr >> 16+ if stat.S_ISLNK(mode):+ raise ValueError(f"Archive symlinks are not accepted: {member.filename}")+ if member.is_dir():+ continue+ add(member.filename, archive.read(member))+ elif lower.endswith((".tar", ".tar.gz", ".tgz")):+ with tarfile.open(fileobj=io.BytesIO(upload.data), mode="r:*") as archive:+ for member in archive.getmembers():+ if member.issym() or member.islnk() or member.isdev():+ raise ValueError(f"Archive links and devices are not accepted: {member.name}")+ if not member.isfile():+ continue+ source = archive.extractfile(member)+ if source is not None:+ add(member.name, source.read(MAX_FILE_BYTES + 1))+ else:+ add(upload.name, upload.data)+ return result+++def _text(asset: Upload | Asset) -> str:+ return asset.data.decode("utf-8-sig", "replace")+++def _redact(value: str) -> tuple[str, int]:+ count = 0++ def secret(match: re.Match[str]) -> str:+ nonlocal count+ if match.group(2).startswith("$"):+ return match.group(0)+ count += 1+ return f"{match.group(1)}[REDACTED]"++ value = SECRET_RE.sub(secret, value)+ value, bearer_count = BEARER_RE.subn(r"\1[REDACTED]", value)+ value, key_count = PRIVATE_KEY_RE.subn("[PRIVATE KEY REDACTED]", value)+ value, data_count = DATA_URL_RE.subn("[EMBEDDED DATA OMITTED]", value)+ return value, count + bearer_count + key_count + data_count+++def _timestamp(value: Any, fallback: float = 0.0) -> float:+ if isinstance(value, (int, float)):+ number = float(value)+ return number / 1000 if number > 10_000_000_000 else number+ if isinstance(value, str) and value:+ try:+ return datetime.fromisoformat(value.replace("Z", "+00:00")).timestamp()+ except ValueError:+ pass+ return fallback or datetime.now(timezone.utc).timestamp()+++def _one_line(value: str, limit: int = 92) -> str:+ text = re.sub(r"\s+", " ", value).strip()+ return text if len(text) <= limit else text[: limit - 1].rstrip() + "…"+++def _content_text(content: Any) -> str:+ if isinstance(content, str):+ return content+ if isinstance(content, dict):+ for key in ("text", "content", "user_message"):+ if isinstance(content.get(key), str):+ return content[key]+ return ""+ if isinstance(content, list):+ parts: list[str] = []+ for item in content:+ if isinstance(item, str):+ parts.append(item)+ elif isinstance(item, dict) and item.get("type") not in {"thinking", "reasoning"}:+ value = item.get("text") or item.get("content")+ if isinstance(value, str):+ parts.append(value)+ return "\n".join(part for part in parts if part)+ return ""+++def _tool_blocks(content: Any) -> list[dict[str, Any]]:+ if not isinstance(content, list):+ return []+ return [+ item+ for item in content+ if isinstance(item, dict) and item.get("type") in {"tool_use", "toolCall", "tool-call"}+ ]+++def _events_from_messages(messages: Iterable[dict[str, Any]]) -> list[Event]:+ events: list[Event] = []+ pending_tools: dict[str, Event] = {}+ for index, message in enumerate(messages):+ role = str(message.get("role") or message.get("type") or "").lower()+ content = message.get("content")+ when = _timestamp(message.get("timestamp") or message.get("created_at"), index + 1)+ if role in {"user", "human"}:+ text = _content_text(content)+ if text:+ events.append(Event("user", text=text, timestamp=when))+ if isinstance(content, list):+ for block in content:+ if not isinstance(block, dict) or block.get("type") != "tool_result":+ continue+ tool_id = str(block.get("tool_use_id") or "")+ result = _content_text(block.get("content"))+ if tool_id in pending_tools:+ pending_tools[tool_id].tool_result = result+ continue+ if role in {"assistant", "agent", "ai"}:+ text = _content_text(content)+ if text:+ events.append(Event("assistant", text=text, timestamp=when))+ for block in _tool_blocks(content):+ tool_id = str(block.get("id") or block.get("tool_call_id") or "")+ event = Event(+ "tool",+ timestamp=when,+ tool_name=str(block.get("name") or "tool"),+ tool_args=block.get("input") if isinstance(block.get("input"), dict) else {},+ )+ events.append(event)+ if tool_id:+ pending_tools[tool_id] = event+ calls = message.get("tool_calls")+ if isinstance(calls, str):+ try:+ calls = json.loads(calls)+ except json.JSONDecodeError:+ calls = []+ for call in calls or []:+ if not isinstance(call, dict):+ continue+ function = call.get("function") if isinstance(call.get("function"), dict) else call+ raw_args = function.get("arguments") or {}+ if isinstance(raw_args, str):+ try:+ raw_args = json.loads(raw_args)+ except json.JSONDecodeError:+ raw_args = {"raw_arguments": raw_args}+ event = Event(+ "tool",+ timestamp=when,+ tool_name=str(function.get("name") or "tool"),+ tool_args=raw_args if isinstance(raw_args, dict) else {"value": raw_args},+ )+ events.append(event)+ tool_id = str(call.get("id") or "")+ if tool_id:+ pending_tools[tool_id] = event+ continue+ if role in {"tool", "tool_result"}:+ tool_id = str(message.get("tool_call_id") or message.get("id") or "")+ result = _content_text(content)+ if tool_id in pending_tools:+ pending_tools[tool_id].tool_result = result+ else:+ events.append(+ Event(+ "tool",+ timestamp=when,+ tool_name=str(message.get("tool_name") or message.get("name") or "tool"),+ tool_result=result,+ )+ )+ return events+++def _conversation(source_id: str, title: str, events: list[Event], **metadata: Any) -> Conversation | None:+ visible = [event for event in events if event.kind == "tool" or event.text.strip()]+ if not visible:+ return None+ first_user = next((event.text for event in visible if event.kind == "user"), source_id)+ return Conversation(source_id, _one_line(title or first_user or source_id), visible, metadata)+++def _json_lines(text: str) -> list[dict[str, Any]]:+ rows: list[dict[str, Any]] = []+ for line_no, line in enumerate(text.splitlines(), 1):+ if not line.strip():+ continue+ try:+ value = json.loads(line)+ except json.JSONDecodeError as exc:+ raise ValueError(f"Invalid JSONL at line {line_no}: {exc.msg}") from exc+ if isinstance(value, dict):+ rows.append(value)+ return rows+++def _parse_codex(asset: Upload) -> list[Conversation]:+ rows = _json_lines(_text(asset))+ metadata: dict[str, Any] = {}+ events: list[Event] = []+ pending: dict[str, Event] = {}+ thoughts: list[str] = []+ for index, row in enumerate(rows):+ payload = row.get("payload") if isinstance(row.get("payload"), dict) else {}+ if row.get("type") == "session_meta" and not metadata:+ metadata = dict(payload)+ continue+ if row.get("type") == "event_msg":+ event_type = payload.get("type")+ when = _timestamp(row.get("timestamp"), index + 1)+ text = payload.get("message")+ if not isinstance(text, str) or not text.strip():+ continue+ if event_type == "user_message":+ events.append(Event("user", text=text, timestamp=when))+ elif event_type == "agent_message" and payload.get("phase") == "commentary":+ thoughts.append(text)+ elif event_type == "agent_message" and payload.get("phase") == "final_answer":+ events.append(Event("assistant", text=text, timestamp=when, thoughts=thoughts.copy()))+ thoughts.clear()+ continue+ if row.get("type") != "response_item":+ continue+ item_type = payload.get("type")+ call_id = str(payload.get("call_id") or payload.get("id") or "")+ when = _timestamp(row.get("timestamp"), index + 1)+ if item_type in {"function_call", "custom_tool_call"}:+ raw = payload.get("arguments") if item_type == "function_call" else payload.get("input")+ if isinstance(raw, str):+ try:+ args = json.loads(raw)+ except json.JSONDecodeError:+ args = {"input": raw}+ else:+ args = raw if isinstance(raw, dict) else {}+ event = Event(+ "tool",+ timestamp=when,+ thoughts=thoughts.copy(),+ tool_name=str(payload.get("name") or "tool"),+ tool_args=args,+ )+ thoughts.clear()+ events.append(event)+ if call_id:+ pending[call_id] = event+ elif item_type in {"function_call_output", "custom_tool_call_output"} and call_id in pending:+ pending[call_id].tool_result = _content_text(payload.get("output")) or str(payload.get("output") or "")+ item = _conversation(+ str(metadata.get("id") or metadata.get("session_id") or Path(asset.name).stem),+ "",+ events,+ cwd=metadata.get("cwd"),+ originator=metadata.get("originator"),+ )+ return [item] if item else []+++def _parse_claude(asset: Upload) -> list[Conversation]:+ rows = _json_lines(_text(asset))+ messages: list[dict[str, Any]] = []+ session_id = Path(asset.name).stem+ cwd = ""+ for row in rows:+ if row.get("isSidechain") is True or row.get("type") not in {"user", "assistant"}:+ continue+ message = row.get("message")+ if not isinstance(message, dict):+ continue+ messages.append({**message, "timestamp": row.get("timestamp")})+ session_id = str(row.get("sessionId") or session_id)+ cwd = str(row.get("cwd") or cwd)+ item = _conversation(session_id, "", _events_from_messages(messages), cwd=cwd)+ return [item] if item else []+++def _parse_opencode(asset: Upload) -> list[Conversation]:+ try:+ data = json.loads(_text(asset))+ except json.JSONDecodeError:+ return []+ if not isinstance(data, dict) or not isinstance(data.get("messages"), list):+ return []+ info = data.get("info") if isinstance(data.get("info"), dict) else {}+ events: list[Event] = []+ for index, wrapper in enumerate(data["messages"]):+ if not isinstance(wrapper, dict):+ continue+ message = wrapper.get("info") if isinstance(wrapper.get("info"), dict) else wrapper+ role = str(message.get("role") or "")+ when = _timestamp((message.get("time") or {}).get("created") if isinstance(message.get("time"), dict) else None, index + 1)+ parts = wrapper.get("parts") if isinstance(wrapper.get("parts"), list) else []+ text = "\n".join(+ str(part.get("text"))+ for part in parts+ if isinstance(part, dict) and part.get("type") == "text" and part.get("text")+ )+ if text and role in {"user", "assistant"}:+ events.append(Event(role, text=text, timestamp=when))+ for part in parts:+ if not isinstance(part, dict) or part.get("type") != "tool":+ continue+ state = part.get("state") if isinstance(part.get("state"), dict) else {}+ args = state.get("input") if isinstance(state.get("input"), dict) else {}+ events.append(+ Event(+ "tool",+ timestamp=when,+ tool_name=str(part.get("tool") or state.get("title") or "tool"),+ tool_args=args,+ tool_result=_content_text(state.get("output")),+ )+ )+ item = _conversation(+ str(info.get("id") or Path(asset.name).stem),+ str(info.get("title") or ""),+ events,+ directory=info.get("directory"),+ project_id=info.get("projectID"),+ )+ return [item] if item else []+++def _parse_hermes_jsonl(asset: Upload) -> list[Conversation]:+ result: list[Conversation] = []+ for row in _json_lines(_text(asset)):+ messages = row.get("messages")+ if not isinstance(messages, list):+ continue+ item = _conversation(+ str(row.get("id") or row.get("session_id") or uuid.uuid4()),+ str(row.get("title") or ""),+ _events_from_messages(message for message in messages if isinstance(message, dict)),+ source=row.get("source"),+ cwd=row.get("cwd"),+ model=row.get("model"),+ )+ if item:+ result.append(item)+ return result+++def _parse_openclaw_jsonl(asset: Upload) -> list[Conversation]:+ rows = _json_lines(_text(asset))+ session_id = Path(asset.name).stem+ title = ""+ workspace = ""+ messages: list[dict[str, Any]] = []+ for row in rows:+ if row.get("type") in {"session", "session_meta"}:+ session_id = str(row.get("id") or row.get("sessionId") or session_id)+ title = str(row.get("title") or title)+ workspace = str(row.get("cwd") or row.get("workspace") or workspace)+ continue+ message = row.get("message") if isinstance(row.get("message"), dict) else None+ if row.get("type") == "message" and message:+ messages.append({**message, "timestamp": row.get("timestamp") or message.get("timestamp")})+ elif row.get("role"):+ messages.append(row)+ item = _conversation(session_id, title, _events_from_messages(messages), workspace=workspace)+ return [item] if item else []+++def _sqlite(asset: Upload) -> tuple[sqlite3.Connection, str]:+ handle = tempfile.NamedTemporaryFile(suffix=".sqlite", delete=False)+ try:+ handle.write(asset.data)+ handle.close()+ connection = sqlite3.connect(f"file:{handle.name}?mode=ro&immutable=1", uri=True)+ connection.row_factory = sqlite3.Row+ return connection, handle.name+ except Exception:+ Path(handle.name).unlink(missing_ok=True)+ raise+++def _close_sqlite(connection: sqlite3.Connection, path: str) -> None:+ connection.close()+ Path(path).unlink(missing_ok=True)+++def _tables(connection: sqlite3.Connection) -> set[str]:+ return {row[0] for row in connection.execute("SELECT name FROM sqlite_master WHERE type='table'")}+++def _parse_hermes_db(asset: Upload) -> list[Conversation]:+ connection, path = _sqlite(asset)+ try:+ if not {"sessions", "messages"}.issubset(_tables(connection)):+ return []+ result: list[Conversation] = []+ for session in connection.execute("SELECT * FROM sessions ORDER BY started_at"):+ rows = connection.execute(+ "SELECT * FROM messages WHERE session_id = ? ORDER BY timestamp, id", (session["id"],)+ ).fetchall()+ messages = [dict(row) for row in rows]+ item = _conversation(+ str(session["id"]),+ str(session["title"] or "") if "title" in session.keys() else "",+ _events_from_messages(messages),+ source=session["source"] if "source" in session.keys() else None,+ cwd=session["cwd"] if "cwd" in session.keys() else None,+ model=session["model"] if "model" in session.keys() else None,+ )+ if item:+ result.append(item)+ return result+ finally:+ _close_sqlite(connection, path)+++def _parse_openclaw_db(asset: Upload) -> list[Conversation]:+ connection, path = _sqlite(asset)+ try:+ if not {"session_windows", "transcript_events"}.issubset(_tables(connection)):+ return []+ result: list[Conversation] = []+ for window in connection.execute("SELECT * FROM session_windows ORDER BY created_at"):+ messages: list[dict[str, Any]] = []+ for row in connection.execute(+ "SELECT event_json, created_at FROM transcript_events WHERE session_id = ? ORDER BY seq",+ (window["session_id"],),+ ):+ try:+ event = json.loads(row["event_json"])+ except (TypeError, json.JSONDecodeError):+ continue+ message = event.get("message") if isinstance(event.get("message"), dict) else None+ if event.get("type") == "message" and message:+ messages.append({**message, "timestamp": event.get("timestamp") or row["created_at"]})+ elif event.get("role"):+ messages.append({**event, "timestamp": event.get("timestamp") or row["created_at"]})+ item = _conversation(+ str(window["session_id"]),+ str(window["display_name"] or "") if "display_name" in window.keys() else "",+ _events_from_messages(messages),+ session_key=window["session_key"],+ channel=window["channel"] if "channel" in window.keys() else None,+ model=window["model"] if "model" in window.keys() else None,+ )+ if item:+ result.append(item)+ return result+ finally:+ _close_sqlite(connection, path)+++def _is_sqlite(asset: Upload) -> bool:+ return asset.data.startswith(b"SQLite format 3\x00")+++def _discover_assets(files: list[Upload], bundle: Bundle) -> None:+ skill_roots: dict[str, str] = {}+ for item in files:+ path = PurePosixPath(item.name)+ if path.name.lower() == "skill.md":+ key = str(path.parent)+ skill_roots[key] = re.sub(r"[^a-z0-9_-]+", "_", path.parent.name.lower()).strip("_") or "skill"+ for item in files:+ path = PurePosixPath(item.name)+ suffix = path.suffix.lower()+ sensitive = path.name.lower() in SENSITIVE_NAMES or suffix in {".key", ".pem"}+ for root, slug in skill_roots.items():+ root_path = PurePosixPath(root)+ try:+ relative = path.relative_to(root_path)+ except ValueError:+ continue+ if sensitive:+ bundle.excluded.append(f"{item.name}: credentials are never imported")+ else:+ bundle.skills.setdefault(slug, []).append(Asset(str(relative), item.data))+ break+ else:+ lower_parts = {part.lower() for part in path.parts}+ if suffix == ".md" and path.name.lower() in INSTRUCTION_NAMES:+ bundle.instructions.append(Asset(item.name, item.data))+ elif suffix == ".md" and (+ path.name.lower() in MEMORY_NAMES or "memory" in lower_parts or "memories" in lower_parts+ ):+ bundle.memories.append(Asset(item.name, item.data))+ elif sensitive:+ bundle.excluded.append(f"{item.name}: settings or credentials are never imported")+++def _discover_projects(bundle: Bundle) -> None:+ by_path: dict[str, Project] = {}+ for conversation in bundle.conversations:+ project_path = next(+ (+ str(conversation.metadata.get(key) or "").strip()+ for key in PROJECT_PATH_KEYS+ if str(conversation.metadata.get(key) or "").strip()+ ),+ "",+ )+ if not project_path or project_path in {".", "/", "\\"}:+ continue+ normalized = project_path.replace("\\", "/").rstrip("/")+ title = PurePosixPath(normalized).name or "Imported project"+ source_id = hashlib.sha256(f"{bundle.source}:{project_path}".encode()).hexdigest()[:12]+ project = by_path.setdefault(source_id, Project(source_id, title, project_path))+ project.conversation_ids.append(conversation.source_id)+ bundle.projects = list(by_path.values())+++def parse_bundle(source: str, uploads: Iterable[Upload]) -> Bundle:+ if source not in {"openclaw", "hermes", "opencode", "claude", "codex"}:+ raise ValueError("Choose one of the five supported source harnesses")+ files = expand_uploads(uploads)+ bundle = Bundle(source)+ _discover_assets(files, bundle)+ seen: set[str] = set()+ for asset in files:+ lower = asset.name.lower()+ conversations: list[Conversation] = []+ try:+ if _is_sqlite(asset):+ conversations = _parse_hermes_db(asset) if source == "hermes" else _parse_openclaw_db(asset) if source == "openclaw" else []+ elif source == "codex" and lower.endswith(".jsonl"):+ conversations = _parse_codex(asset)+ elif source == "claude" and lower.endswith(".jsonl") and "/history.jsonl" not in f"/{lower}":+ conversations = _parse_claude(asset)+ elif source == "opencode" and lower.endswith(".json"):+ conversations = _parse_opencode(asset)+ elif source == "hermes" and lower.endswith(".jsonl"):+ conversations = _parse_hermes_jsonl(asset)+ elif source == "openclaw" and lower.endswith(".jsonl"):+ conversations = _parse_openclaw_jsonl(asset)+ except (ValueError, sqlite3.DatabaseError) as exc:+ bundle.warnings.append(f"{asset.name}: {exc}")+ continue+ for conversation in conversations:+ identity = f"{source}:{conversation.source_id}"+ if identity not in seen:+ seen.add(identity)+ bundle.conversations.append(conversation)++ _discover_projects(bundle)++ for conversation in bundle.conversations:+ for event in conversation.events:+ event.text, count = _redact(event.text)+ bundle.redactions += count+ event.tool_result, count = _redact(event.tool_result)+ bundle.redactions += count+ raw_args, count = _redact(json.dumps(event.tool_args, ensure_ascii=False))+ bundle.redactions += count+ try:+ event.tool_args = json.loads(raw_args)+ except json.JSONDecodeError:+ event.tool_args = {"redacted": raw_args}+ for asset in bundle.knowledge:+ text, count = _redact(_text(asset))+ bundle.redactions += count+ asset.data = text.encode()+ for assets in bundle.skills.values():+ for asset in assets:+ if PurePosixPath(asset.path).suffix.lower() in TEXT_SUFFIXES:+ text, count = _redact(_text(asset))+ bundle.redactions += count+ asset.data = text.encode()+ if not bundle.conversations and not bundle.knowledge and not bundle.skills:+ bundle.warnings.append("No supported chats, memories, instructions, or skills were found in this upload")+ return bundle+++def _iso(timestamp: float) -> str:+ return datetime.fromtimestamp(timestamp, timezone.utc).isoformat().replace("+00:00", "Z")+++def build_a0_chat(conversation: Conversation, source: str) -> dict[str, Any]:+ events = conversation.events+ if not events:+ raise ValueError("Conversation contains no importable events")+ messages: list[dict[str, Any]] = []+ logs: list[dict[str, Any]] = []+ sequence = 0+ last_timestamp = 0.0++ def message(ai: bool, content: Any, when: float, kind: str) -> dict[str, Any]:+ nonlocal sequence+ sequence += 1+ item = {+ "_cls": "Message",+ "id": str(uuid.uuid4()),+ "ai": ai,+ "content": content,+ "metadata": {"imported_from": source, "source_event": kind, "source_timestamp": _iso(when)},+ "sequence": sequence,+ "summary": "",+ "tokens": 0,+ }+ messages.append(item)+ return item++ def log(kind: str, item: dict[str, Any], heading: str, content: str, kvps: dict[str, Any], when: float) -> None:+ nonlocal last_timestamp+ last_timestamp = max(when, last_timestamp + 0.000001)+ logs.append(+ {+ "no": len(logs),+ "id": item["id"],+ "type": kind,+ "heading": heading,+ "content": content,+ "kvps": kvps,+ "timestamp": last_timestamp,+ "agentno": 0,+ }+ )++ for index, event in enumerate(events):+ when = event.timestamp or index + 1.0+ if event.kind == "user":+ item = message(False, {"user_message": event.text}, when, "user")+ log("user", item, "", event.text, {"attachments": []}, when)+ elif event.kind == "assistant":+ envelope = {+ "thoughts": event.thoughts or [f"Imported public response from {source}."],+ "headline": _one_line(event.text),+ "tool_name": "response",+ "tool_args": {"text": event.text},+ }+ raw = json.dumps(envelope, ensure_ascii=False)+ item = message(True, raw, when, "assistant")+ log("agent", item, envelope["headline"], raw, envelope, when)+ log("response", item, "icon://chat Responding", event.text, {"finished": True}, when + 0.000001)+ elif event.kind == "tool":+ name = event.tool_name or "tool"+ envelope = {+ "thoughts": event.thoughts or [f"Imported historical {source} tool activity."],+ "headline": f"Using imported {name} record",+ "tool_name": name,+ "tool_args": event.tool_args,+ }+ raw = json.dumps(envelope, ensure_ascii=False)+ call = message(True, raw, when, "tool_call")+ log("agent", call, envelope["headline"], raw, envelope, when)+ result_text = event.tool_result or "No retained tool result was available."+ result = message(+ False,+ {"tool_name": name, "tool_result": result_text, "file": ""},+ when + 0.000001,+ "tool_result",+ )+ log(+ "tool",+ result,+ f"icon://construction Using tool '{name}'",+ result_text,+ {**event.tool_args, "_tool_name": name},+ when + 0.000001,+ )++ history = {+ "_cls": "History",+ "counter": sequence,+ "bulks": [],+ "topics": [],+ "current": {"_cls": "Topic", "summary": "", "messages": messages},+ }+ first = min((event.timestamp for event in events if event.timestamp), default=1.0)+ last = max((event.timestamp for event in events if event.timestamp), default=first)+ chat_id = hashlib.sha256(f"{source}:{conversation.source_id}".encode()).hexdigest()[:8]+ return {+ "id": chat_id,+ "name": conversation.title,+ "created_at": _iso(first),+ "type": "user",+ "last_message": _iso(last),+ "agents": [+ {+ "number": 0,+ "agent_profile": "default",+ "data": {},+ "history": json.dumps(history, ensure_ascii=False),+ }+ ],+ "streaming_agent": 0,+ "agent_profile": "default",+ "log": {"guid": str(uuid.uuid4()), "logs": logs, "progress": "", "progress_no": 0},+ "data": {+ "_migrate_agents": {+ "format_version": 1,+ "source": source,+ "source_id": conversation.source_id,+ "source_metadata": conversation.metadata,+ "hidden_reasoning_included": False,+ "historical_tools_are_replayable": False,+ }+ },+ "output_data": {},+ }+++def preview(bundle: Bundle) -> dict[str, Any]:+ return {+ "ok": True,+ "source": bundle.source,+ "summary": bundle.summary(),+ "chats": [+ {+ "id": item.source_id,+ "title": item.title,+ "messages": len(item.events),+ "metadata": item.metadata,+ }+ for item in bundle.conversations[:200]+ ],+ "projects": [+ {+ "id": item.source_id,+ "title": item.title,+ "path": item.path,+ "chats": len(item.conversation_ids),+ }+ for item in bundle.projects[:200]+ ],+ "memories": [item.path for item in bundle.memories[:200]],+ "instructions": [item.path for item in bundle.instructions[:200]],+ "knowledge": [item.path for item in bundle.knowledge[:200]],+ "skills": sorted(bundle.skills)[:200],+ "excluded": bundle.excluded[:200],+ "warnings": bundle.warnings[:200],+ }diff --git a/plugins/_migrate_agents/plugin.yaml b/plugins/_migrate_agents/plugin.yamlnew file mode 100644index 000000000..e40396651--- /dev/null+++ b/plugins/_migrate_agents/plugin.yaml@@ -0,0 +1,8 @@+name: _migrate_agents+title: Migrate Agents+description: Review and import chats, projects, memories, instructions, and skills from OpenClaw, Hermes Agent, OpenCode, Claude Code, and Codex.+version: 0.1.0+settings_sections: []+always_enabled: false+per_project_config: false+per_agent_config: falsediff --git a/plugins/_migrate_agents/tests/test_import_helpers.py b/plugins/_migrate_agents/tests/test_import_helpers.pynew file mode 100644index 000000000..3a7071547--- /dev/null+++ b/plugins/_migrate_agents/tests/test_import_helpers.py@@ -0,0 +1,32 @@+from __future__ import annotations++import tempfile+import unittest+from pathlib import Path+from unittest.mock import patch++from plugins._migrate_agents.api import migration_import+from plugins._migrate_agents.helpers.migration import Project+++class ImportHelperTests(unittest.TestCase):+ def test_import_projects_uses_unique_native_names_and_maps_chats(self):+ project = Project("project-1", "Acme App", "/work/acme", ["chat-1", "chat-2"])+ with tempfile.TemporaryDirectory() as root:+ Path(root, "codex_acme_app").mkdir()+ with (+ patch.object(migration_import.a0_projects, "get_projects_parent_folder", return_value=root),+ patch.object(migration_import.a0_projects, "create_project", return_value="codex_acme_app_2") as create,+ ):+ names, mapping = migration_import.import_projects("codex", [project])++ self.assertEqual(names, ["codex_acme_app_2"])+ self.assertEqual(mapping, {"chat-1": "codex_acme_app_2", "chat-2": "codex_acme_app_2"})+ payload = create.call_args.args[1]+ self.assertEqual(payload["title"], "Acme App")+ self.assertIn("/work/acme", payload["description"])+ self.assertNotIn("secret", payload)+++if __name__ == "__main__":+ unittest.main()diff --git a/plugins/_migrate_agents/tests/test_migration.py b/plugins/_migrate_agents/tests/test_migration.pynew file mode 100644index 000000000..523a817d8--- /dev/null+++ b/plugins/_migrate_agents/tests/test_migration.py@@ -0,0 +1,179 @@+from __future__ import annotations++import importlib.util+import io+import json+import sqlite3+import sys+import tempfile+import unittest+import zipfile+from pathlib import Path+++ROOT = Path(__file__).resolve().parents[1]+SPEC = importlib.util.spec_from_file_location("_migrate_agents_core", ROOT / "helpers" / "migration.py")+assert SPEC and SPEC.loader+migration = importlib.util.module_from_spec(SPEC)+sys.modules[SPEC.name] = migration+SPEC.loader.exec_module(migration)+++def jsonl(*rows) -> bytes:+ return ("\n".join(json.dumps(row) for row in rows) + "\n").encode()+++class MigrationTests(unittest.TestCase):+ def test_codex_uses_public_events_tools_and_excludes_reasoning(self):+ upload = migration.Upload(+ "rollout-test.jsonl",+ jsonl(+ {"type": "session_meta", "payload": {"id": "codex-1", "cwd": "/work"}},+ {"type": "event_msg", "timestamp": "2026-01-01T00:00:00Z", "payload": {"type": "user_message", "message": "Fix it"}},+ {"type": "event_msg", "timestamp": "2026-01-01T00:00:01Z", "payload": {"type": "agent_message", "phase": "commentary", "message": "Checking"}},+ {"type": "response_item", "timestamp": "2026-01-01T00:00:02Z", "payload": {"type": "function_call", "call_id": "c1", "name": "shell", "arguments": "{\"api_key\":\"secret-value\"}"}},+ {"type": "response_item", "timestamp": "2026-01-01T00:00:03Z", "payload": {"type": "function_call_output", "call_id": "c1", "output": "done"}},+ {"type": "event_msg", "timestamp": "2026-01-01T00:00:04Z", "payload": {"type": "agent_message", "phase": "final_answer", "message": "Fixed"}},+ {"type": "response_item", "payload": {"type": "reasoning", "text": "hidden"}},+ ),+ )+ bundle = migration.parse_bundle("codex", [upload])+ self.assertEqual(bundle.summary()["chats"], 1)+ self.assertEqual([event.kind for event in bundle.conversations[0].events], ["user", "tool", "assistant"])+ self.assertEqual(bundle.conversations[0].events[1].tool_result, "done")+ self.assertEqual(bundle.conversations[0].events[1].tool_args["api_key"], "[REDACTED]")+ self.assertNotIn('"text": "hidden"', json.dumps(migration.build_a0_chat(bundle.conversations[0], "codex")))++ def test_claude_ignores_thinking_and_sidechains(self):+ upload = migration.Upload(+ "project/session.jsonl",+ jsonl(+ {"type": "user", "sessionId": "claude-1", "timestamp": "2026-01-01T00:00:00Z", "message": {"role": "user", "content": [{"type": "text", "text": "Hello"}]}},+ {"type": "assistant", "sessionId": "claude-1", "timestamp": "2026-01-01T00:00:01Z", "message": {"role": "assistant", "content": [{"type": "thinking", "thinking": "private"}, {"type": "text", "text": "Hi"}]}},+ {"type": "assistant", "isSidechain": True, "sessionId": "claude-1", "message": {"role": "assistant", "content": [{"type": "text", "text": "branch"}]}},+ ),+ )+ bundle = migration.parse_bundle("claude", [upload])+ text = json.dumps(migration.build_a0_chat(bundle.conversations[0], "claude"))+ self.assertIn("Hello", text)+ self.assertIn("Hi", text)+ self.assertNotIn("private", text)+ self.assertNotIn("branch", text)++ def test_opencode_export_keeps_text_and_completed_tool(self):+ data = {+ "info": {"id": "ses_1", "title": "Ship it", "directory": "/repo"},+ "messages": [+ {"info": {"role": "user", "time": {"created": 1000}}, "parts": [{"type": "text", "text": "Build"}]},+ {"info": {"role": "assistant", "time": {"created": 2000}}, "parts": [{"type": "text", "text": "Done"}, {"type": "tool", "tool": "bash", "state": {"status": "completed", "input": {"command": "true"}, "output": "ok"}}]},+ ],+ }+ bundle = migration.parse_bundle("opencode", [migration.Upload("session.json", json.dumps(data).encode())])+ self.assertEqual(bundle.conversations[0].title, "Ship it")+ self.assertEqual([event.kind for event in bundle.conversations[0].events], ["user", "assistant", "tool"])++ def test_hermes_jsonl_and_openclaw_jsonl(self):+ hermes = migration.parse_bundle(+ "hermes",+ [migration.Upload("backup.jsonl", jsonl({"id": "h1", "title": "Hermes", "messages": [{"role": "user", "content": "One"}, {"role": "assistant", "content": "Two"}]}))],+ )+ claw = migration.parse_bundle(+ "openclaw",+ [migration.Upload("trace.jsonl", jsonl({"type": "session", "id": "o1"}, {"type": "message", "message": {"role": "user", "content": "One"}}, {"type": "message", "message": {"role": "assistant", "content": "Two"}}))],+ )+ self.assertEqual(hermes.summary()["chats"], 1)+ self.assertEqual(claw.summary()["chats"], 1)++ def test_hermes_sqlite(self):+ with tempfile.NamedTemporaryFile(suffix=".db") as handle:+ db = sqlite3.connect(handle.name)+ db.executescript(+ "CREATE TABLE sessions (id TEXT, source TEXT, model TEXT, title TEXT, cwd TEXT, started_at REAL);"+ "CREATE TABLE messages (id INTEGER, session_id TEXT, role TEXT, content TEXT, timestamp REAL, tool_calls TEXT, tool_name TEXT, tool_call_id TEXT);"+ "INSERT INTO sessions VALUES ('h1','cli','model','SQLite chat','/repo',1);"+ "INSERT INTO messages VALUES (1,'h1','user','Hello',1,NULL,NULL,NULL);"+ "INSERT INTO messages VALUES (2,'h1','assistant','Hi',2,NULL,NULL,NULL);"+ )+ db.commit()+ data = Path(handle.name).read_bytes()+ db.close()+ bundle = migration.parse_bundle("hermes", [migration.Upload("state.db", data)])+ self.assertEqual(bundle.conversations[0].title, "SQLite chat")++ def test_openclaw_sqlite(self):+ with tempfile.NamedTemporaryFile(suffix=".sqlite") as handle:+ db = sqlite3.connect(handle.name)+ db.executescript(+ "CREATE TABLE session_windows (session_id TEXT, session_key TEXT, created_at INTEGER, display_name TEXT, channel TEXT, model TEXT);"+ "CREATE TABLE transcript_events (session_id TEXT, seq INTEGER, event_json TEXT, created_at INTEGER);"+ "INSERT INTO session_windows VALUES ('o1','agent:main:main',1,'Claw chat','web','model');"+ )+ event = json.dumps({"type": "message", "message": {"role": "user", "content": "Hello"}})+ db.execute("INSERT INTO transcript_events VALUES ('o1',1,?,1)", (event,))+ db.commit()+ data = Path(handle.name).read_bytes()+ db.close()+ bundle = migration.parse_bundle("openclaw", [migration.Upload("openclaw-agent.sqlite", data)])+ self.assertEqual(bundle.conversations[0].title, "Claw chat")++ def test_discovers_knowledge_and_complete_skill_folder(self):+ bundle = migration.parse_bundle(+ "claude",+ [+ migration.Upload("project/memory/MEMORY.md", b"Remember api_key=secret"),+ migration.Upload("project/CLAUDE.md", b"Remember password=secret"),+ migration.Upload("project/skills/release/SKILL.md", b"---\nname: release\n---"),+ migration.Upload("project/skills/release/scripts/run.py", b"API_KEY=secret"),+ migration.Upload("project/skills/release/.env", b"API_KEY=never"),+ ],+ )+ self.assertEqual(bundle.summary()["memories"], 1)+ self.assertEqual(bundle.summary()["instructions"], 1)+ self.assertEqual(bundle.summary()["knowledge"], 2)+ self.assertEqual(bundle.summary()["skills"], 1)+ self.assertIn(b"[REDACTED]", bundle.memories[0].data)+ self.assertIn(b"[REDACTED]", bundle.instructions[0].data)+ self.assertEqual(len(next(iter(bundle.skills.values()))), 2)+ self.assertIn(b"[REDACTED]", bundle.skills["release"][1].data)+ self.assertEqual(bundle.summary()["excluded"], 1)++ def test_discovers_projects_from_retained_workspace_context(self):+ data = {+ "info": {"id": "ses_1", "title": "Ship it", "directory": "/work/acme"},+ "messages": [+ {"info": {"role": "user"}, "parts": [{"type": "text", "text": "Build"}]},+ ],+ }+ bundle = migration.parse_bundle(+ "opencode",+ [migration.Upload("session.json", json.dumps(data).encode())],+ )+ self.assertEqual(bundle.summary()["projects"], 1)+ self.assertEqual(bundle.projects[0].title, "acme")+ self.assertEqual(bundle.projects[0].path, "/work/acme")+ self.assertEqual(bundle.projects[0].conversation_ids, ["ses_1"])++ def test_rejects_archive_traversal(self):+ stream = io.BytesIO()+ with zipfile.ZipFile(stream, "w") as archive:+ archive.writestr("../escape.json", "{}")+ with self.assertRaisesRegex(ValueError, "Unsafe archive path"):+ migration.parse_bundle("opencode", [migration.Upload("bad.zip", stream.getvalue())])++ def test_a0_chat_log_and_history_sequences_are_valid(self):+ conversation = migration.Conversation(+ "id",+ "Title",+ [migration.Event("user", "Hi", 1), migration.Event("assistant", "Hello", 2)],+ )+ chat = migration.build_a0_chat(conversation, "test")+ history = json.loads(chat["agents"][0]["history"])+ messages = history["current"]["messages"]+ self.assertEqual(history["counter"], len(messages))+ self.assertEqual([item["sequence"] for item in messages], list(range(1, len(messages) + 1)))+ self.assertEqual([item["no"] for item in chat["log"]["logs"]], list(range(len(chat["log"]["logs"]))))+ self.assertEqual([item["type"] for item in chat["log"]["logs"]], ["user", "agent", "response"])+++if __name__ == "__main__":+ unittest.main()diff --git a/plugins/_migrate_agents/webui/assets/ATTRIBUTION.md b/plugins/_migrate_agents/webui/assets/ATTRIBUTION.mdnew file mode 100644index 000000000..62e30764f--- /dev/null+++ b/plugins/_migrate_agents/webui/assets/ATTRIBUTION.md@@ -0,0 +1,7 @@+# Harness logo attribution++The SVG marks in this folder are bundled from+[Lobe Icons](https://github.com/lobehub/lobe-icons) at commit+`f07e9be35aef452ce735f95ea8204a14ecc513f7` under its MIT license.+They identify OpenClaw, Hermes Agent, OpenCode, Claude Code, and Codex.+All product names and marks remain the property of their respective owners.diff --git a/plugins/_migrate_agents/webui/assets/claude.svg b/plugins/_migrate_agents/webui/assets/claude.svgnew file mode 100644index 000000000..d55522ced--- /dev/null+++ b/plugins/_migrate_agents/webui/assets/claude.svg@@ -0,0 +1 @@+<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Claude Code</title><path clip-rule="evenodd" d="M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z" fill="#D97757" fill-rule="evenodd"></path></svg>diff --git a/plugins/_migrate_agents/webui/assets/codex.svg b/plugins/_migrate_agents/webui/assets/codex.svgnew file mode 100644index 000000000..9ce439292--- /dev/null+++ b/plugins/_migrate_agents/webui/assets/codex.svg@@ -0,0 +1 @@+<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Codex</title><path d="M19.503 0H4.496A4.496 4.496 0 000 4.496v15.007A4.496 4.496 0 004.496 24h15.007A4.496 4.496 0 0024 19.503V4.496A4.496 4.496 0 0019.503 0z" fill="#fff"></path><path d="M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.74 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388zm3.482 10.565a.637.637 0 000 1.272h3.636a.637.637 0 100-1.272h-3.636zM8.462 9.23a.637.637 0 00-1.106.631l1.272 2.224-1.266 2.136a.636.636 0 101.095.649l1.454-2.455a.636.636 0 00.005-.64L8.462 9.23z" fill="url(#lobe-icons-codex-_R_0_)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-codex-_R_0_" x1="12" x2="12" y1="3" y2="21"><stop stop-color="#B1A7FF"></stop><stop offset=".5" stop-color="#7A9DFF"></stop><stop offset="1" stop-color="#3941FF"></stop></linearGradient></defs></svg>diff --git a/plugins/_migrate_agents/webui/assets/hermes.svg b/plugins/_migrate_agents/webui/assets/hermes.svgnew file mode 100644index 000000000..d77d24d9e--- /dev/null+++ b/plugins/_migrate_agents/webui/assets/hermes.svg@@ -0,0 +1 @@+<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Hermes Agent</title><path d="M5.938 12.835c.127-.039.285.02.373.143.028.038.036.092.046.14.003.014-.02.033-.04.05-.124-.098-.24-.194-.354-.291-.011-.01-.016-.027-.025-.042zM8.396 9.412c.195-.032.39-.06.588-.05a.54.54 0 01.148.026c.202.071.402.147.601.224.028.01.05.036.075.055l-.013.027a9.203 9.203 0 01-.26-.089c-.115-.038-.213-.077-.315-.098-.25-.05-.25-.046-.292-.014l.574.144c.275.139.55.276.823.417.042.022.09.057.107.098.026.06.063.076.117.072.066-.006.132-.017.213-.027l-.04.086c.051.08.142.02.216.064-.074.13-.247.09-.334.199l.061.074-.12.087c0 .106-.038.168-.306.243l.026.085-.196.042.07.124h-.25l-.007.137c-.081-.01-.161-.018-.244-.027l-.053.123c-.027-.008-.052-.011-.073-.023-.067-.038-.128-.056-.195.006-.019.017-.063.014-.093.008-.026-.006-.05-.029-.07-.042-.11.095-.11.095-.208.003-.057.046-.12.074-.186.011-.063.027-.123-.02-.178-.014-.07.007-.097-.035-.133-.07l-.13.033c-.013-.236-.194-.19-.34-.203.005-.072.05-.092.095-.094a.474.474 0 01.159.022c.164.05.32.12.496.138.203.021.405.029.601-.015.265-.059.52-.149.707-.365.049-.056.083-.127.117-.195.019-.038.02-.084-.02-.116a1.397 1.397 0 00-.382-.217c.024.12-.031.182-.115.221 0 .014-.004.025 0 .03.08.115.084.16-.007.267a1.39 1.39 0 01-.218.211.477.477 0 01-.641-.05 1.36 1.36 0 01-.133-.152c-.078-.107-.076-.108-.033-.236-.165-.08-.128-.226-.104-.364.008-.05.028-.096.049-.163-.04.014-.067.017-.087.032a.897.897 0 00-.316.357c-.007.016-.01.034-.02.047-.012.015-.034.038-.045.035-.02-.006-.037-.027-.05-.045-.008-.012-.007-.032-.012-.057h-.126l.053-.172a14.82 14.82 0 00-.039-.049l.11-.284c-.06.026-.091.044-.124.051-.03.007-.064 0-.095 0 0-.031-.01-.07.004-.092.149-.22.305-.428.593-.476z"></path><path d="M8.06 10.788c-.003-.038-.004-.075.037-.062.016.006.034.048.028.067-.01.04-.038.032-.064-.005z"></path><path clip-rule="evenodd" d="M11.981.009c.226-.012.453-.011.679 0 .247.01.495.024.74.062.401.064.798.157 1.19.273.463.138.92.299 1.356.511a7.31 7.31 0 012.948 2.642c.292.469.536.963.739 1.479.219.556.446 1.11.623 1.683.204.654.329 1.326.458 1.997.097.504.182 1.01.29 1.511.156.722.329 1.44.494 2.16.186.812.4 1.615.63 2.415.102.355.193.713.282 1.072.11.436.202.876.254 1.323.031.278.066.557.073.837a7.56 7.56 0 01-.017.88c-.037.413-.1.818-.226 1.212a5.017 5.017 0 01-.915 1.649l-.13.156.018.023c.043-.023.088-.041.127-.068.2-.138.373-.307.531-.49.4-.46.721-.973.975-1.529a3.59 3.59 0 00.325-1.72c-.024-.424-.097-.834-.3-1.213-.013-.027-.015-.06-.03-.121.05.035.082.048.101.072.107.13.22.258.315.398.33.494.46 1.052.486 1.64a3.75 3.75 0 01-.47 1.97c-.36.655-.887 1.14-1.526 1.506-.193.111-.394.21-.595.308-.157.078-.248.211-.318.365a.522.522 0 00-.033.406.359.359 0 01.013.139c-.005.077-.077.155-.14.162-.054.006-.125-.043-.15-.116a1.206 1.206 0 01-.06-.233c-.04-.314-.155-.6-.308-.87a3.906 3.906 0 00-.73-.91 2.129 2.129 0 00-.897-.524 4.093 4.093 0 00-.692-.131c-.075-.008-.15-.04-.22.01.18.06.363.11.538.18.434.173.82.43 1.18.728.308.255.58.543.794.884.098.155.186.315.227.496.027.123.042.25.067.375.013.062-.002.109-.053.144-.047.033-.122.034-.163-.01a.455.455 0 01-.08-.14c-.03-.073-.038-.159-.078-.225a7.314 7.314 0 00-1.423-1.664c-.16-.137-.329-.26-.537-.323-.376-.114-.753-.203-1.15-.154-.213.025-.427.032-.64.053a1.6 1.6 0 00-.736.278 5.14 5.14 0 00-.834.72c-.329.342-.642.699-.955 1.055-.136.155-.264.319-.314.531a5.227 5.227 0 00-.012.051.096.096 0 01-.09.076h-.31c-.046 0-.082-.048-.072-.094.023-.108.045-.216.07-.324.075-.325.19-.635.368-.917.024-.039.04-.088.104-.08l.01.049.027.077c.28-.435.571-.834.996-1.135.283-.204.584-.378.89-.55a.196.196 0 00-.098-.002c-.162.043-.325.084-.485.134-.402.124-.764.33-1.11.566-.147.1-.298.193-.414.333a7.314 7.314 0 00-1.07 1.767.845.845 0 00-.04.12.075.075 0 01-.072.056h-.494c-.04 0-.062-.051-.036-.082.123-.14.246-.282.377-.415.275-.281.58-.532.777-.884.027-.048.063-.09.095-.135.238-.333.54-.607.818-.902.082-.086.175-.16.26-.24.029-.027.053-.057.079-.085l-.018-.025-.135.041c-.034.017-.07.031-.102.05-.248.144-.494.292-.743.433-.408.23-.825.439-1.209.711-.281.2-.591.358-.889.533-.02.012-.044.015-.08.028-.015-.135.143-.201.108-.336-.033.014-.064.02-.085.038-.111.096-.227.19-.328.296-.148.157-.284.325-.425.488-.125.143-.25.286-.373.431A.153.153 0 019.89 24H8.762a.316.316 0 00.016-.042c.028-.09.085-.172.083-.28-.091-.018-.162.001-.212.077a4.45 4.45 0 00-.136.215c-.01.016-.024.03-.042.03h-.093c-.019 0-.029-.022-.017-.037.071-.088.14-.178.209-.268.001-.002-.006-.012-.012-.024-.014.004-.03.006-.045.013-.176.09-.352.181-.527.274a.363.363 0 01-.168.042H5.202c-.026 0-.039-.036-.019-.053.21-.178.402-.374.558-.605.335-.496.538-1.047.667-1.629.004-.02-.003-.043-.006-.091-.037.048-.059.072-.076.1a1.943 1.943 0 01-.334.415c-.28.258-.59.448-.983.464-.297.012-.588 0-.865-.127-.46-.21-.722-.57-.794-1.072-.025-.17-.017-.171-.182-.219A3.513 3.513 0 011.97 20.6a2.286 2.286 0 01-.808-1.13 3.569 3.569 0 01-.16-1.245c.002-.034.016-.067.024-.1.032.023.046.043.05.066.033.153.059.308.096.46.086.355.257.664.516.92.258.256.571.419.91.532.358.118.717.138 1.07-.016a1.89 1.89 0 00.621-.452c.328-.348.533-.76.648-1.223.009-.034.005-.071.007-.11-.015.006-.026.006-.03.011-.031.05-.064.1-.093.152-.284.502-.679.887-1.196 1.135-.351.17-.718.255-1.11.159a1.607 1.607 0 01-.971-.64 2.006 2.006 0 01-.368-.924 2.903 2.903 0 01.02-.886c.05-.439.466-1.17.742-1.271-.02.063-.035.112-.053.16-.043.116-.097.227-.13.345a1.901 1.901 0 00-.05.82c.033.212.09.416.204.6.147.236.346.407.62.465.11.023.225.014.338.018a.576.576 0 00.386-.131c.164-.128.282-.292.366-.481.168-.375.24-.777.309-1.179.05-.296.093-.594.133-.893.039-.281.071-.563.104-.845.026-.232.048-.464.074-.696.024-.228.052-.455.076-.683.024-.227.047-.455.069-.683.013-.14.022-.28.034-.42l.037-.417c.022-.25.041-.5.065-.748.008-.082-.02-.132-.09-.177a2.46 2.46 0 01-.492-.418c-.1-.109-.188-.228-.282-.342-.035-.042-.056-.097-.116-.118a2.084 2.084 0 00.275.597c.06.092.131.176.196.265.063.086.182.115.234.226-.028.003-.046.01-.06.006a4.74 4.74 0 01-.22-.057 2.71 2.71 0 01-1.287-.819c-.435-.487-.656-1.076-.71-1.723a5.206 5.206 0 01.014-1.06c.072-.602.22-1.186.45-1.745.155-.376.338-.741.526-1.102.205-.393.466-.75.765-1.076.512-.559 1.104-1.024 1.726-1.448.717-.49 1.478-.898 2.277-1.233C8.244.828 8.767.632 9.31.494c.655-.166 1.31-.33 1.982-.415.229-.03.458-.058.688-.07zm-1.847 22.82c-.07.06-.147.111-.207.18-.238.27-.464.549-.668.869l-.044.108a.177.177 0 00.093-.057c.174-.19.351-.378.519-.574.104-.122.195-.255.288-.386.024-.034.03-.08.046-.12l-.027-.02zm1.65-3.695a5.51 5.51 0 00-.653.593l-.37.386a.963.963 0 01-.377.25 1.372 1.372 0 01-.467.09c-.044 0-.087.006-.151.012.028.058.043.097.064.131.15.242.301.482.45.724.136.22.276.438.399.666.068.125.105.267.156.404.077.027.14-.018.202-.048.29-.135.579-.274.867-.412.213-.101.437-.186.636-.31.347-.215.68-.455 1.018-.685.015-.01.026-.028.042-.046-.023-.019-.038-.037-.056-.044-.287-.111-.527-.3-.77-.482a5.319 5.319 0 01-.506-.42 1.757 1.757 0 01-.41-.653c-.019-.049-.045-.095-.075-.156zm-5.847.264c-.06.096-.097.194-.132.293a3.38 3.38 0 01-.555 1.01c-.2.25-.455.412-.762.493-.23.06-.464.076-.7.07-.048-.002-.097.002-.158.005.016.04.021.066.035.085.1.145.23.246.4.295.157.046.316.034.498.023.181-.037.343-.115.485-.234.238-.199.402-.454.536-.732.175-.363.264-.751.342-1.144.01-.053.008-.11.011-.164zm14.945-4.586c.008.029.016.057.027.107.024.155.051.31.072.464.03.219.067.437.078.657.017.344.027.689-.014 1.033-.037.315-.063.633-.116.946a6.153 6.153 0 01-.46 1.518c-.008.018-.01.039-.02.082.047-.03.077-.042.098-.064.085-.083.17-.167.248-.255.271-.305.458-.66.596-1.043.18-.498.228-1.011.145-1.531-.103-.65-.33-1.263-.597-1.881a9.055 9.055 0 00-.024-.055l-.033.022zM5.797 8.29a.26.26 0 00.018.153c.124.251.25.501.379.75.025.049.066.09.03.163-.284.06-.578.119-.88.255.059.038.097.06.132.087.042.032.112.058.09.12-.01.033-.075.048-.117.072.017.01.043.021.067.036.166.102.33.207.447.368.138.192.229.404.188.644-.079.469-.306.85-.69 1.132-.054.04-.106.083-.161.122a.243.243 0 00-.103.245.77.77 0 00.055.195c.083.196.22.35.375.492.083.076.159.164.222.257a.37.37 0 01.025.377c-.023.05-.05.099-.076.148-.03.06-.028.111.022.162.041.042.08.089.112.138.038.058.078.079.147.05a.486.486 0 01.333-.006c.16.046.302.126.444.21.13.077.264.149.4.219.067.035.14.05.219.026.071-.022.124.01.145.076.02.064-.003.108-.074.139-.07.03-.137.063-.209.088-.1.035-.201.073-.314.077-.013-.107.11-.088.127-.159-.206-.126-.643-.145-.801-.034.063.112.035.21-.096.313-.13-.1-.025-.202.002-.3a.209.209 0 00-.249.17c-.015.101.067.216.178.224.108.007.218-.005.326-.012.06-.005.12-.027.199 0-.103.123-.248.127-.357.19.002.05.07.086.019.131-.053.048-.095-.001-.132-.03-.08-.063-.16-.126-.231-.197a.474.474 0 01-.157-.311.52.52 0 00-.043-.172c-.032-.074-.032-.137.033-.19-.018-.03-.028-.053-.045-.072a1.222 1.222 0 01-.196-.369c-.053-.137-.046-.264.048-.381.024-.03.05-.06.064-.095a.664.664 0 00.047-.168c.017-.165-.064-.287-.182-.387-.186-.156-.36-.322-.46-.551-.005-.011-.024-.017-.037-.026-.011.017-.024.027-.025.038-.019.185-.045.37-.052.557-.014.377.058.743.162 1.104.118.41.289.798.488 1.173.267.502.537 1.002.812 1.5.055.098.13.189.208.27.198.202.452.272.724.273.202 0 .404-.006.605-.026.295-.03.59-.073.884-.113.183-.025.365-.057.548-.08.21-.026.38.073.522.21.16.156.305.327.447.5.22.265.397.56.554.867.05.098.07.1.147.03.13-.121.26-.242.394-.36.067-.059.088-.12.067-.213a3.535 3.535 0 01-.085-.796c.002-.157.006-.314.018-.471.015-.224.03-.45.06-.672a59.114 59.114 0 01.362-2.298c.087-.493.182-.984.268-1.477.06-.347.118-.694.162-1.043.034-.273.055-.55.063-.825.011-.332.003-.665.002-.998 0-.077.004-.155-.01-.23-.028-.142-.01-.155-.162-.19a5.826 5.826 0 00-.607-.107c-.146-.018-.207-.053-.221-.19-.006-.049-.025-.098-.041-.146-.009-.025-.024-.048-.046-.09l-.025.264c-.009.096-.029.116-.127.115-.055 0-.11-.008-.164-.008-.476 0-.952-.008-1.426.032-.095.008-.173-.015-.226-.103-.04-.066-.088-.126-.134-.186-.063-.084-.086-.093-.182-.06-.195.068-.388.138-.582.21a2.71 2.71 0 00-.675.394.986.986 0 01-.323.168c-.033.01-.07.008-.127.013.02-.066.024-.114.047-.15.064-.105.135-.205.205-.306.023-.033.049-.063.073-.095l-.015-.023-.201.037c-.146.04-.296.07-.437.122-.148.053-.266.023-.386-.072a3.623 3.623 0 01-.733-.786l-.093-.132zm8.592 8.963l-.147.09c-.22.134-.44.266-.659.402-.093.058-.184.12-.27.188-.085.07-.124.161-.072.272.047.1.093.2.147.294.047.08.124.138.213.147.11.01.228.012.336-.012.217-.05.372-.205.528-.357a.291.291 0 00.087-.308c-.046-.18-.079-.365-.118-.547-.011-.052-.027-.103-.045-.169zm-.257-2.409c-.12.291-.205.597-.325.91-.151.433-.294.87-.435 1.323.036-.01.054-.01.067-.018.261-.16.522-.324.785-.484.054-.033.071-.078.065-.138-.012-.13-.024-.262-.034-.393l-.068-.886c-.008-.103-.02-.206-.029-.31-.009 0-.017-.002-.026-.004zm3.081-8.13l.099.285c.08.231.159.463.24.714l.58 1.952c.187.63.372 1.262.558 1.893.114.382.235.762.343 1.146.072.257.126.519.186.799.044.206.087.413.127.64.034.106.023.226.077.325l.025-.006-.068-.362c-.038-.206-.077-.412-.113-.638-.015-.07-.029-.141-.046-.211-.095-.396-.177-.796-.29-1.187-.196-.685-.413-1.364-.618-2.046-.165-.549-.322-1.1-.488-1.648-.069-.227-.15-.45-.226-.695l-.117-.336c-.037-.107-.075-.216-.115-.322-.04-.106-.084-.21-.127-.314a7.558 7.558 0 01-.027.01zM6.225 14.304c-.063-.001-.115.014-.134.083a.35.35 0 00.41.012 4.533 4.533 0 00-.276-.095zM5.23 11.98c-.026-.027-.057-.048-.075.002-.012.032-.007.07-.01.113.082-.037.082-.037.085-.115zm.062-1.189a.135.135 0 00-.088.056.197.197 0 00-.025.11c.005.152.01.306.026.457a.751.751 0 00.066.218c.061.136.157.167.288.101.055-.027.06-.054.025-.11a4.52 4.52 0 01-.129-.211c-.015-.068-.066-.131-.033-.207.04-.09-.076-.116-.074-.19V10.874c-.003-.038-.006-.087-.056-.083zm-.017-.968a.867.867 0 00-.467.127c-.076.045-.084.07-.05.158.034.087.07.173.115.254.064.117.09.125.21.077a.657.657 0 01.336-.053c.202.022.357.136.504.264l.092.077c.007-.006.014-.013.022-.018-.019-.105-.035-.226-.149-.264-.157-.053-.324-.075-.508-.117l-.24-.005c.24-.169.452-.044.687.009-.063-.115-.153-.147-.23-.193-.082-.05-.17-.092-.25-.144-.06-.037-.12-.08-.072-.172zm10.233.325c-.23-.01-.427.08-.608.211-.034.026-.06.065-.105.117.087.026.15.046.232.065.044-.015.088-.03.13-.046.306-.114.61-.115.904.031.126.063.237.04.366-.005-.02-.031-.03-.054-.045-.071a.986.986 0 00-.448-.273c-.14-.044-.284-.024-.426-.03zM7.99 6.483a.308.308 0 00.002.133c.08.321.156.643.242.962.104.387.27.75.456 1.103.02.037.061.08.098.087a.404.404 0 00.253-.051l-.472-.84c-.23-.448-.405-.92-.579-1.394zM10.397.497c-.2-.008-.405.004-.603.034-.236.035-.47.087-.7.152-.287.08-.569.18-.852.273-.04.013-.074.038-.11.058.028.014.05.018.07.014.287-.068.58-.085.873-.09.134-.002.269.009.402.025.19.024.382.048.57.09.456.104.874.3 1.265.556.464.306.888.66 1.257 1.078.205.232.395.475.56.739.17.274.315.561.449.856.273.601.456 1.232.6 1.876.04.173.07.348.1.524.017.104.065.167.17.19.122.028.2.105.22.251-.003.102-.06.174-.129.24a1.065 1.065 0 00-.268.358.164.164 0 00.083-.039c.08-.086.162-.172.235-.265a.56.56 0 00.13-.333c.009-.05.022-.1.024-.15.007-.124-.017-.15-.143-.168-.025-.004-.049-.014-.073-.015-.082-.007-.125-.063-.137-.131-.033-.198-.004-.355.247-.408.086-.018.174-.03.26-.042.158-.023.315-.053.473-.067.14-.012.19.033.226.167.008.029.018.057.021.087.019.179-.008.225-.141.288-.027.013-.055.024-.078.042a.148.148 0 00-.051.067c-.039.144.073.382.206.445l.673.32c.023.011.05.015.075.023l.018-.026c-.015-.008-.032-.013-.044-.024a2.27 2.27 0 00-.544-.32 4.898 4.898 0 00-.173-.075.203.203 0 01-.126-.191c-.003-.085.045-.154.128-.187l.059-.025c.099-.044.118-.076.112-.187a.384.384 0 00-.008-.063c-.067-.294-.123-.59-.205-.88a9.478 9.478 0 00-.826-2.036 7.465 7.465 0 00-1.39-1.805 4.536 4.536 0 00-1.177-.824 3.656 3.656 0 00-1.016-.328 6.155 6.155 0 00-.712-.074zm6.719 5.955c.01.014.018.028.038.034l-.022-.044-.016.01zM4.103 3.917a.062.062 0 01-.03.012.455.455 0 01-.04.039c-.01.01-.02.02-.045.04l-.363.354c-.088.085-.17.178-.266.253-.284.22-.425.53-.544.855a.132.132 0 00-.007.071c.013.055.033.108.052.168l.074.026c-.017.056-.03.105-.047.152-.058.164-.118.327-.175.491-.005.015.008.036.019.077.08-.175.158-.33.225-.489.228-.544.484-1.074.819-1.561.09-.133.182-.266.283-.401.004-.006.007-.013.022-.03.001-.016.003-.032.015-.04l.008-.017zm12.976 2.408a.023.023 0 01.009.019.073.073 0 00-.006.01.188.188 0 00.007.02l.018.022c.002-.007.007-.016.005-.021-.003-.01-.012-.018-.02-.038a1.331 1.331 0 01-.013-.012zM4.199 4.48c-.003.004-.008.008-.027.014-.005.013-.011.025-.031.047a2.085 2.085 0 01-.124.167c-.048.07-.116.055-.181.041-.134-.028-.228.016-.287.143-.089.187-.187.37-.273.56-.049.108-.11.216-.118.36.081.003.154.007.228.008h.228a2.563 2.563 0 01-.079.264c-.01.052-.022.103-.033.155l.02.004c.018-.046.037-.092.067-.153.066-.142.13-.285.2-.426.02-.04.034-.1.116-.092 0 .043.004.084 0 .124-.005.045-.017.09-.028.143.141.043.086.174.115.269.102-.022.104-.195.248-.144v.205l.017.002.439-1.059c-.13 0-.246-.02-.358.033-.024.011-.058-.001-.108-.004.075-.15.139-.278.211-.417a.128.128 0 01.025-.036c0-.015-.001-.03.008-.038l.006-.02c-.005.006-.01.011-.028.017-.004.012-.009.024-.026.045a.085.085 0 01-.032.033c-.123.157-.09.164-.258.106-.079-.027-.078-.028-.047-.144.028-.046.056-.093.098-.15 0-.016-.001-.032.007-.042L4.2 4.48zm2.073-.67c-.003.006-.007.011-.027.016-.094.125-.194.246-.28.377-.155.238-.301.481-.451.723-.14.224-.345.368-.575.481-.017.008-.04.006-.079.011.012-.059.016-.109.033-.153a6.076 6.076 0 01.229-.518l-.007-.02a.138.138 0 01-.035.025c-.028.05-.055.1-.093.164-.26.424-.443.817-.442.95.024.004.048.011.073.013.177.013.188.007.26-.165.03-.07.077-.12.147-.15l.175-.07c.044-.018.085-.057.146-.032.003.05-.01.11.014.145.042.062.044.125.047.193.002.049.017.098.026.147.029-.034.039-.065.05-.097.142-.39.277-.782.428-1.17.1-.256.22-.504.33-.756.013-.03.013-.067.03-.092V3.81zm3.987-.34c0 .045.01.084.021.123.042.16.094.318.124.48.024.133.023.27.028.406 0 .033-.019.067-.032.11-.094-.058-.047-.158-.106-.215h-.125c-.015.072-.01.152-.046.2-.066.085-.155.154-.236.227-.043.038-.078.018-.103-.025l-.046-.087c-.065.035-.117.069-.172.093-.116.051-.235.095-.35.147-.085.038-.09.053-.07.147.014.075.034.148.047.223.013.072.05.109.123.124.233.05.462.115.657.265.058-.102.058-.102.168-.151.03-.014.06-.03.092-.042.08-.03.115-.017.15.06.023.048.041.098.066.158.06-.14-.042-.267.017-.416.157.18.24.39.375.567a.235.235 0 00.022-.098c.002-.124 0-.247.002-.371 0-.034.013-.067.02-.1l.032-.003c.11.155.13.354.226.52a3.036 3.036 0 00-.01-.392c-.004-.045 0-.074.05-.088.08.036.116.14.215.158-.03-.275-.423-1.137-.798-1.635-.114-.127-.2-.28-.34-.386zm-2.667.696c-.019.034-.03.05-.037.067-.061.185-.125.37-.18.556-.031.105-.087.169-.195.19-.09.019-.178.052-.268.073-.038.009-.089.015-.118-.003-.024-.016-.025-.069-.036-.106-.064.076-.082.087-.17.047-.133-.062-.262-.135-.393-.201-.048-.025-.093-.063-.17-.03-.043.12-.091.25-.137.382-.099.28-.087.242.095.453.046.048.102.03.154.023.054-.009.106-.03.16-.036.13-.013.26-.08.367-.015.204-.064.387-.122.571-.178.05-.015.089.005.114.054.022.042.034.093.082.121.038-.056-.013-.128.063-.178l.14.241-.042-1.46zm.278.358c-.096-.01-.107.01-.11.108-.002.038-.003.078.002.115.03.2.099.386.174.57.002.006.012.01.022.015l.078-.05c.052.036.081.088.153.088.205-.002.41.014.616.012.099-.001.158.042.205.12.018.03.024.077.088.066l-.08-.394c-.05-.195-.085-.395-.172-.589-.057.057-.114.068-.18.046a.72.72 0 00-.135-.028c-.22-.028-.44-.059-.66-.08zm10.254-1.727c.089.163.155.316.139.491-.016.168.026.342-.044.516-.047-.033-.088-.082-.112-.075-.117.035-.164-.057-.227-.115a4.772 4.772 0 01-.286-.29l-.104-.113a4.856 4.856 0 01-.023.019c.035.046.07.093.11.156.04.064.084.127.122.193.034.058.065.118.031.205-.082-.01-.164-.019-.246-.032-.06-.01-.101 0-.124.07-.031.098-.037.096-.15.09.02.042.036.08.057.116.041.074.03.138-.03.196-.06.06-.118.122-.178.181a.175.175 0 01-.185.046c-.222-.061-.447-.113-.67-.174-.032-.009-.063-.04-.086-.068-.03-.04-.052-.087-.08-.13-.044-.07-.09-.138-.136-.207a.18.18 0 00-.014.105c.012.127.03.253.035.38.005.1-.024.12-.121.104-.104-.017-.206-.04-.31-.058-.064-.012-.131-.028-.202.03l.081.208c.09 0 .166-.01.237.002a.819.819 0 01.458.251c.078.083.154.168.241.26l.018-.005c-.004-.006-.008-.013-.01-.04.014-.056-.062-.118.018-.178.031.03.064.057.088.09.058.078.111.159.169.257l.089.141.024-.013a2093.819 2093.819 0 01-.427-.934c.055.007.083.007.108.016.193.07.385.142.577.216.074.028.147.06.219.094.062.028.112.018.157-.033.05-.056.102-.112.154-.167.05-.051.095-.046.132.014.016.025.026.053.04.08.071.138.143.277.217.433l.159.308.025-.011c-.044-.106-.07-.218-.138-.334-.057-.182-.168-.346-.206-.545.136.034.362.326.567.732l.057.074.018-.011a1.563 1.563 0 01-.052-.127c-.046-.145-.097-.29-.136-.436-.022-.083-.036-.173.022-.26l.109.058-.026-.207.027-.016c.022.02.05.036.065.06.073.108.143.22.215.33.01.016.029.029.043.043-.036-.217-.2-.38-.229-.626l.155.112c.014-.166.012-.319.042-.465.032-.158-.023-.297-.063-.445.024.004.036.006.055.025.092.124.183.249.277.371.02.027.05.047.069.087l.04.063.019-.015a.293.293 0 01-.053-.082 27.922 27.922 0 01-.332-.49c-.221-.311-.363-.467-.485-.521zm-6.57.327c-.003.161.092.275.069.415l-.368.087c.09.139.032.237-.052.331-.05.057-.092.122-.143.178-.037.04-.046.078-.018.126l.16.275c.029.048.072.066.128.064.076-.003.152 0 .228-.001.116-.003.216.022.275.137.006.014.02.024.044.052.004-.059-.003-.098.01-.13.016-.04.04-.099.072-.108.084-.023.173-.024.26-.03.013-.001.027.018.04.029l.071.065c.019-.11-.082-.198-.024-.31l.126.04c-.026-.123-.07-.245-.071-.366 0-.123.051-.243.115-.36.107.062.16.156.234.253.183.265.36.533.494.834.165-.078.27.068.407.088-.003-.106-.133-.441-.197-.492a.142.142 0 00-.102-.028c-.06.011-.119.039-.191.063-.025-.039-.056-.078-.077-.122a3.936 3.936 0 00-.473-.783c-.076-.094-.16-.182-.228-.26l-.391.285c-.049.035-.094.03-.132-.017l-.169-.207c-.025-.03-.053-.059-.097-.108z"></path></svg>diff --git a/plugins/_migrate_agents/webui/assets/openclaw.svg b/plugins/_migrate_agents/webui/assets/openclaw.svgnew file mode 100644index 000000000..bdc800d01--- /dev/null+++ b/plugins/_migrate_agents/webui/assets/openclaw.svg@@ -0,0 +1 @@+<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenClaw</title><path d="M12 2.568c-6.33 0-9.495 5.275-9.495 9.495 0 4.22 3.165 8.44 6.33 9.494v2.11h2.11v-2.11s1.055.422 2.11 0v2.11h2.11v-2.11c3.165-1.055 6.33-5.274 6.33-9.494S18.33 2.568 12 2.568z" fill="url(#lobe-icons-open-claw-0-_R_0_)"></path><path d="M3.56 9.953C.396 8.898-.66 11.008.396 13.118c1.055 2.11 3.164 1.055 4.22-1.055.632-1.477 0-2.11-1.056-2.11z" fill="url(#lobe-icons-open-claw-1-_R_0_)"></path><path d="M20.44 9.953c3.164-1.055 4.22 1.055 3.164 3.165-1.055 2.11-3.164 1.055-4.22-1.055-.632-1.477 0-2.11 1.056-2.11z" fill="url(#lobe-icons-open-claw-2-_R_0_)"></path><path d="M5.507 1.875c.476-.285 1.036-.233 1.615.037.577.27 1.223.774 1.937 1.488a.316.316 0 01-.447.447c-.693-.693-1.279-1.138-1.757-1.361-.475-.222-.795-.205-1.022-.069a.317.317 0 01-.326-.542zM16.877 1.913c.58-.27 1.14-.323 1.616-.038a.317.317 0 01-.326.542c-.227-.136-.547-.153-1.022.069-.478.223-1.064.668-1.756 1.361a.316.316 0 11-.448-.447c.714-.714 1.36-1.218 1.936-1.487z" fill="#FF4D4D"></path><path d="M8.835 9.109a1.266 1.266 0 100-2.532 1.266 1.266 0 000 2.532zM15.165 9.109a1.266 1.266 0 100-2.532 1.266 1.266 0 000 2.532z" fill="#050810"></path><path d="M9.046 8.16a.527.527 0 100-1.056.527.527 0 000 1.055zM15.376 8.16a.527.527 0 100-1.055.527.527 0 000 1.054z" fill="#00E5CC"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-open-claw-0-_R_0_" x1="-.659" x2="27.023" y1=".458" y2="22.855"><stop stop-color="#FF4D4D"></stop><stop offset="1" stop-color="#991B1B"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-open-claw-1-_R_0_" x1="0" x2="4.311" y1="9.672" y2="14.949"><stop stop-color="#FF4D4D"></stop><stop offset="1" stop-color="#991B1B"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-open-claw-2-_R_0_" x1="19.385" x2="24.399" y1="9.953" y2="14.462"><stop stop-color="#FF4D4D"></stop><stop offset="1" stop-color="#991B1B"></stop></linearGradient></defs></svg>diff --git a/plugins/_migrate_agents/webui/assets/opencode.svg b/plugins/_migrate_agents/webui/assets/opencode.svgnew file mode 100644index 000000000..5c1bb8535--- /dev/null+++ b/plugins/_migrate_agents/webui/assets/opencode.svg@@ -0,0 +1 @@+<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>opencode</title><path d="M16 6H8v12h8V6zm4 16H4V2h16v20z"></path></svg>diff --git a/plugins/_migrate_agents/webui/main.html b/plugins/_migrate_agents/webui/main.htmlnew file mode 100644index 000000000..d26189c6c--- /dev/null+++ b/plugins/_migrate_agents/webui/main.html@@ -0,0 +1,261 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <title>Migrate Agents</title>+ <script type="module" src="/plugins/_migrate_agents/webui/migrate-agents-store.js"></script>+</head>+<body>+ <div x-data>+ <template x-if="$store.migrationParty">+ <main class="mp-shell"+ x-create="$store.migrationParty.onOpen()"+ x-destroy="$store.migrationParty.cleanup()">+ <header class="mp-intro">+ <p class="mp-kicker">Import from another agent</p>+ <h1>Move your work into Agent Zero</h1>+ <p class="mp-lede">Bring over chats, projects, memories, instructions, and skills from OpenClaw, Hermes Agent, OpenCode, Claude Code, or Codex. You will review what was found before anything is copied.</p>+ <div class="mp-safety"><x-icon name="shield_lock"></x-icon><span>Credentials, authentication files, and hidden reasoning are excluded automatically.</span></div>+ </header>++ <section class="mp-section" aria-labelledby="mp-source-title">+ <div class="mp-section-head">+ <div><span class="mp-step">01</span><h2 id="mp-source-title">Choose the app you are importing from</h2></div>+ </div>+ <div class="mp-sources" role="radiogroup" aria-labelledby="mp-source-title">+ <template x-for="source in $store.migrationParty.sources" :key="source.id">+ <button type="button"+ class="mp-source"+ :class="[$store.migrationParty.source === source.id && 'is-selected', `is-${source.accent}`]"+ @click="$store.migrationParty.chooseSource(source.id)"+ role="radio"+ :aria-checked="$store.migrationParty.source === source.id">+ <span class="mp-source-icon"><img :src="source.logo" alt="" aria-hidden="true"></span>+ <span class="mp-source-copy"><strong x-text="source.name"></strong><small x-text="source.hint"></small></span>+ <span class="mp-radio"><span></span></span>+ </button>+ </template>+ </div>+ </section>++ <section class="mp-section" aria-labelledby="mp-prepare-title">+ <div class="mp-section-head">+ <div><span class="mp-step">02</span><h2 id="mp-prepare-title">Prepare your export</h2></div>+ </div>++ <div class="mp-export-guide">+ <div class="mp-guide-head">+ <img :src="$store.migrationParty.selectedSource.logo" alt="" aria-hidden="true">+ <div><strong x-text="$store.migrationParty.selectedSource.guideTitle"></strong><span x-text="$store.migrationParty.selectedSource.guideLabel"></span></div>+ </div>+ <div class="mp-command">+ <code x-text="$store.migrationParty.selectedSource.command"></code>+ <button type="button" class="mp-copy" @click="$store.migrationParty.copyExportValue()" :aria-label="`Copy ${$store.migrationParty.selectedSource.guideLabel.toLowerCase()}`">+ <x-icon :name="$store.migrationParty.copied ? 'check' : 'content_copy'"></x-icon>+ <span x-text="$store.migrationParty.copied ? 'Copied' : 'Copy'"></span>+ </button>+ </div>+ <p x-text="$store.migrationParty.selectedSource.guideNote"></p>+ </div>+ </section>++ <section class="mp-section" aria-labelledby="mp-export-title">+ <div class="mp-section-head">+ <div><span class="mp-step">03</span><h2 id="mp-export-title">Select the export</h2></div>+ <span class="mp-muted">Files stay on this Agent Zero instance</span>+ </div>++ <div class="mp-drop"+ :class="$store.migrationParty.dragActive && 'is-dragging'"+ @dragenter.prevent="$store.migrationParty.dragActive = true"+ @dragover.prevent="$store.migrationParty.dragActive = true"+ @dragleave.prevent="$store.migrationParty.dragActive = false"+ @drop.prevent="$store.migrationParty.onDrop($event)">+ <div class="mp-drop-icon"><x-icon name="move_to_inbox"></x-icon></div>+ <strong>Drag the export here, or choose it from your computer</strong>+ <span>Files, ZIP or TAR archives, and complete folders are supported · 256 MiB expanded limit</span>+ <div class="mp-drop-actions">+ <label class="btn btn-ok mp-file-button">+ <x-icon name="attach_file"></x-icon> Choose files+ <input type="file" multiple accept=".json,.jsonl,.db,.sqlite,.sqlite3,.zip,.tar,.gz,.tgz,.md" @change="$store.migrationParty.handleFiles($event)">+ </label>+ <label class="btn btn-cancel mp-file-button">+ <x-icon name="folder_open"></x-icon> Choose folder+ <input type="file" multiple webkitdirectory @change="$store.migrationParty.handleFiles($event)">+ </label>+ </div>+ </div>++ <template x-if="$store.migrationParty.files.length">+ <div class="mp-files">+ <div class="mp-files-head">+ <span><strong x-text="$store.migrationParty.files.length"></strong> selected · <span x-text="$store.migrationParty.formatBytes($store.migrationParty.totalBytes)"></span></span>+ <button class="text-button" type="button" @click="$store.migrationParty.clearFiles()">Clear</button>+ </div>+ <div class="mp-file-list">+ <template x-for="(file, index) in $store.migrationParty.files.slice(0, 8)" :key="`${file.webkitRelativePath || file.name}:${file.size}`">+ <div class="mp-file-row">+ <x-icon name="draft"></x-icon>+ <span x-text="file.webkitRelativePath || file.name"></span>+ <small x-text="$store.migrationParty.formatBytes(file.size)"></small>+ <button type="button" @click="$store.migrationParty.removeFile(index)" :aria-label="`Remove ${file.name}`"><x-icon name="close"></x-icon></button>+ </div>+ </template>+ <div class="mp-more" x-show="$store.migrationParty.files.length > 8" x-text="`+ ${$store.migrationParty.files.length - 8} more files`"></div>+ </div>+ </div>+ </template>+ </section>++ <template x-if="$store.migrationParty.preview">+ <section class="mp-section mp-review" aria-labelledby="mp-review-title">+ <div class="mp-section-head">+ <div><span class="mp-step">04</span><h2 id="mp-review-title">Review what will be imported</h2></div>+ <span class="mp-ready"><x-icon name="check_circle"></x-icon> Export checked</span>+ </div>++ <div class="mp-stats">+ <div><strong x-text="$store.migrationParty.preview.summary.chats"></strong><span>Chats</span></div>+ <div><strong x-text="$store.migrationParty.preview.summary.projects"></strong><span>Projects</span></div>+ <div><strong x-text="$store.migrationParty.preview.summary.memories"></strong><span>Memories</span></div>+ <div><strong x-text="$store.migrationParty.preview.summary.instructions"></strong><span>Instructions</span></div>+ <div><strong x-text="$store.migrationParty.preview.summary.skills"></strong><span>Skills</span></div>+ </div>++ <div class="mp-review-grid">+ <div class="mp-manifest">+ <h3>Found in this export</h3>+ <template x-if="$store.migrationParty.preview.projects.length">+ <div class="mp-project-list">+ <template x-for="project in $store.migrationParty.preview.projects.slice(0, 8)" :key="project.id">+ <div><x-icon name="folder_open"></x-icon><span><strong x-text="project.title"></strong><small x-text="project.path"></small></span><em x-text="`${project.chats} chats`"></em></div>+ </template>+ </div>+ </template>+ <template x-if="$store.migrationParty.preview.chats.length">+ <div class="mp-chat-list">+ <template x-for="chat in $store.migrationParty.preview.chats.slice(0, 12)" :key="chat.id">+ <div><x-icon name="forum"></x-icon><span x-text="chat.title"></span><small x-text="`${chat.messages} events`"></small></div>+ </template>+ </div>+ </template>+ <p class="mp-empty" x-show="!$store.migrationParty.preview.projects.length && !$store.migrationParty.preview.chats.length">No projects or chats were found. Other selected data can still be imported.</p>+ </div>++ <div class="mp-options">+ <h3>Choose what to import</h3>+ <label :class="!$store.migrationParty.preview.summary.chats && 'is-empty'"><input type="checkbox" x-model="$store.migrationParty.includeChats" :disabled="!$store.migrationParty.preview.summary.chats"><span><strong>Chats</strong><small>Messages and inert historical tool records</small></span><em x-text="$store.migrationParty.preview.summary.chats"></em></label>+ <label :class="!$store.migrationParty.preview.summary.projects && 'is-empty'"><input type="checkbox" x-model="$store.migrationParty.includeProjects" :disabled="!$store.migrationParty.preview.summary.projects"><span><strong>Projects</strong><small>Native projects from retained workspace context</small></span><em x-text="$store.migrationParty.preview.summary.projects"></em></label>+ <label :class="!$store.migrationParty.preview.summary.memories && 'is-empty'"><input type="checkbox" x-model="$store.migrationParty.includeMemories" :disabled="!$store.migrationParty.preview.summary.memories"><span><strong>Memories</strong><small>Markdown memory with source provenance</small></span><em x-text="$store.migrationParty.preview.summary.memories"></em></label>+ <label :class="!$store.migrationParty.preview.summary.instructions && 'is-empty'"><input type="checkbox" x-model="$store.migrationParty.includeInstructions" :disabled="!$store.migrationParty.preview.summary.instructions"><span><strong>Instructions</strong><small>AGENTS.md, CLAUDE.md, and related files</small></span><em x-text="$store.migrationParty.preview.summary.instructions"></em></label>+ <label :class="!$store.migrationParty.preview.summary.skills && 'is-empty'"><input type="checkbox" x-model="$store.migrationParty.includeSkills" :disabled="!$store.migrationParty.preview.summary.skills"><span><strong>Skills</strong><small>Complete skill folders under a source namespace</small></span><em x-text="$store.migrationParty.preview.summary.skills"></em></label>+ </div>+ </div>++ <div class="mp-boundary">+ <x-icon name="shield_lock"></x-icon>+ <div><strong>Always excluded</strong><p>Provider keys, credentials, authentication state, channel connections, schedules, hidden reasoning, and running services are not imported. Historical tool records are saved for reference and never replayed.</p><small x-show="$store.migrationParty.preview.summary.redactions" x-text="`${$store.migrationParty.preview.summary.redactions} sensitive value(s) were removed from imported text.`"></small></div>+ </div>++ <details class="mp-details" x-show="$store.migrationParty.preview.excluded.length || $store.migrationParty.preview.warnings.length">+ <summary>Review exclusions and warnings <span x-text="`(${$store.migrationParty.preview.excluded.length + $store.migrationParty.preview.warnings.length})`"></span></summary>+ <ul>+ <template x-for="item in [...$store.migrationParty.preview.excluded, ...$store.migrationParty.preview.warnings]" :key="item"><li x-text="item"></li></template>+ </ul>+ </details>++ <label class="mp-consent">+ <input type="checkbox" x-model="$store.migrationParty.reviewed">+ <span>I reviewed the preview and want to import the selected items.</span>+ </label>+ </section>+ </template>++ <footer class="modal-footer mp-footer" data-modal-footer>+ <button class="btn btn-ok" type="button" @click="$store.migrationParty.primaryAction()" :disabled="$store.migrationParty.primaryDisabled">+ <x-icon :name="$store.migrationParty.busy ? 'progress_activity' : ($store.migrationParty.preview ? 'move_to_inbox' : 'manage_search')" :class="$store.migrationParty.busy && 'mp-spin'"></x-icon>+ <span x-text="$store.migrationParty.primaryLabel"></span>+ </button>+ <button class="btn btn-cancel" type="button" @click="$store.migrationParty.close()" :disabled="$store.migrationParty.busy">Cancel</button>+ </footer>+ </main>+ </template>+ </div>++ <style>+ .mp-shell { color: var(--color-text); padding: 0 var(--spacing-lg) var(--spacing-lg); }+ .mp-intro { padding: 1.4rem 0 1.2rem; border-bottom: 1px solid var(--color-border); }+ .mp-kicker { margin: 0 0 .35rem; color: var(--color-primary); font-size: .72rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }+ .mp-intro h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2rem); line-height: 1.12; letter-spacing: -.025em; }+ .mp-lede { max-width: 52rem; margin: .65rem 0 0; color: var(--color-text-secondary); font-size: .9rem; line-height: 1.55; }+ .mp-safety { display: flex; align-items: flex-start; gap: .5rem; max-width: 52rem; margin-top: .9rem; color: var(--color-text-secondary); font-size: .76rem; line-height: 1.4; }+ .mp-safety x-icon { flex: 0 0 auto; color: var(--color-success); }+ .mp-section { margin-top: 1.45rem; }+ .mp-section-head, .mp-section-head > div { display: flex; align-items: center; gap: .7rem; }+ .mp-section-head { justify-content: space-between; margin-bottom: .75rem; }+ .mp-section-head h2 { margin: 0; font-size: 1rem; letter-spacing: -.01em; }+ .mp-step { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; flex: 0 0 auto; border: 1px solid var(--color-border); border-radius: .48rem; color: var(--color-text-secondary); font-size: .66rem; font-weight: 750; }+ .mp-muted { color: var(--color-text-secondary); font-size: .72rem; }+ .mp-sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }+ .mp-source { --mp-accent: var(--color-primary); min-width: 0; min-height: 4.4rem; padding: .8rem; border: 1px solid var(--color-border); border-radius: .8rem; display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; color: inherit; background: var(--color-bg); text-align: left; cursor: pointer; transition: border-color var(--transition-speed), background var(--transition-speed); }+ .mp-source:hover { background: var(--color-bg-secondary); }+ .mp-source:focus-visible, .mp-copy:focus-visible, .mp-file-row button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }+ .mp-source.is-selected { border-color: color-mix(in srgb, var(--mp-accent) 72%, var(--color-border)); background: color-mix(in srgb, var(--mp-accent) 7%, var(--color-bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mp-accent) 16%, transparent); }+ .mp-source.is-coral { --mp-accent: #ff5a57; } .mp-source.is-gold { --mp-accent: #d8a62e; } .mp-source.is-mint { --mp-accent: #42b997; } .mp-source.is-violet { --mp-accent: #d97757; } .mp-source.is-sky { --mp-accent: #7a9dff; }+ .mp-source-icon, .mp-guide-head > img { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; box-sizing: border-box; padding: .48rem; border: 1px solid color-mix(in srgb, var(--mp-accent) 20%, var(--color-border)); border-radius: .68rem; background: #fff; object-fit: contain; }+ .mp-source-icon img { width: 100%; height: 100%; object-fit: contain; }+ .mp-source-copy { min-width: 0; display: flex; flex-direction: column; gap: .22rem; }+ .mp-source-copy strong { font-size: .84rem; }+ .mp-source-copy small { color: var(--color-text-secondary); font-size: .69rem; line-height: 1.35; }+ .mp-radio { width: .95rem; height: .95rem; border: 1px solid var(--color-border); border-radius: 50%; display: grid; place-items: center; }+ .is-selected .mp-radio { border-color: var(--mp-accent); } .is-selected .mp-radio span { width: .5rem; height: .5rem; border-radius: 50%; background: var(--mp-accent); }+ .mp-export-guide { padding: .85rem; border: 1px solid var(--color-border); border-radius: .85rem; background: var(--color-bg-secondary); }+ .mp-guide-head { display: flex; align-items: center; gap: .65rem; margin-bottom: .7rem; }+ .mp-guide-head > img { width: 2.2rem; height: 2.2rem; padding: .42rem; }+ .mp-guide-head > div { display: flex; flex-direction: column; gap: .1rem; }+ .mp-guide-head strong { font-size: .82rem; } .mp-guide-head span { color: var(--color-text-secondary); font-size: .69rem; }+ .mp-command { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; align-items: stretch; }+ .mp-command code { min-width: 0; padding: .72rem .8rem; border: 1px solid var(--color-border); border-radius: .58rem; color: var(--color-text); background: var(--color-bg); overflow-wrap: anywhere; white-space: normal; font-size: .75rem; line-height: 1.45; }+ .mp-copy { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-width: 5.4rem; padding: 0 .75rem; border: 1px solid var(--color-border); border-radius: .58rem; color: var(--color-text); background: var(--color-bg); cursor: pointer; font-size: .72rem; font-weight: 650; }+ .mp-copy:hover { border-color: var(--color-primary); }+ .mp-export-guide > p { margin: .6rem .1rem 0; color: var(--color-text-secondary); font-size: .71rem; line-height: 1.45; }+ .mp-drop { padding: 1.35rem; border: 1px dashed color-mix(in srgb, var(--color-text-secondary) 45%, transparent); border-radius: .85rem; display: flex; flex-direction: column; align-items: center; gap: .45rem; background: color-mix(in srgb, var(--color-bg-secondary) 70%, transparent); text-align: center; transition: border-color var(--transition-speed), background var(--transition-speed); }+ .mp-drop.is-dragging { border-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 8%, var(--color-bg)); }+ .mp-drop-icon { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: .8rem; color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 10%, transparent); }+ .mp-drop-icon x-icon { font-size: 1.5rem; } .mp-drop > strong { font-size: .84rem; } .mp-drop > span { max-width: 38rem; color: var(--color-text-secondary); font-size: .71rem; line-height: 1.4; }+ .mp-drop-actions { display: flex; gap: .55rem; margin-top: .45rem; }+ .mp-file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; cursor: pointer; } .mp-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }+ .mp-files { margin-top: .65rem; padding: .7rem; border: 1px solid var(--color-border); border-radius: .75rem; background: var(--color-bg); }+ .mp-files-head { display: flex; justify-content: space-between; align-items: center; padding: 0 .2rem .55rem; color: var(--color-text-secondary); font-size: .72rem; }+ .mp-file-list { display: grid; gap: .25rem; max-height: 12rem; overflow: auto; }+ .mp-file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .5rem; align-items: center; padding: .42rem .5rem; border-radius: .42rem; background: var(--color-bg-secondary); font-size: .72rem; }+ .mp-file-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .mp-file-row small { color: var(--color-text-secondary); } .mp-file-row button { border: 0; padding: 0; color: var(--color-text-secondary); background: none; cursor: pointer; }+ .mp-more { padding: .4rem; color: var(--color-text-secondary); text-align: center; font-size: .7rem; }+ .mp-review { padding: var(--spacing-lg); border: 1px solid var(--color-border); border-radius: .9rem; background: color-mix(in srgb, var(--color-success) 3%, var(--color-bg)); }+ .mp-ready { display: inline-flex; align-items: center; gap: .35rem; color: var(--color-success); font-size: .72rem; font-weight: 650; }+ .mp-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin-bottom: .75rem; }+ .mp-stats > div { padding: .68rem; border: 1px solid var(--color-border); border-radius: .6rem; display: flex; flex-direction: column; background: var(--color-bg); } .mp-stats strong { font-size: 1.2rem; letter-spacing: -.035em; } .mp-stats span { color: var(--color-text-secondary); font-size: .62rem; text-transform: uppercase; letter-spacing: .07em; }+ .mp-review-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: .7rem; }+ .mp-manifest, .mp-options { padding: .8rem; border: 1px solid var(--color-border); border-radius: .68rem; background: var(--color-bg); }+ .mp-manifest h3, .mp-options h3 { margin: 0 0 .6rem; font-size: .76rem; text-transform: uppercase; letter-spacing: .075em; }+ .mp-project-list, .mp-chat-list { max-height: 12rem; overflow: auto; display: grid; gap: .26rem; }+ .mp-project-list { margin-bottom: .35rem; }+ .mp-project-list > div, .mp-chat-list > div { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .48rem; align-items: center; padding: .42rem .46rem; border-radius: .4rem; background: var(--color-bg-secondary); font-size: .71rem; }+ .mp-project-list > div > span { min-width: 0; display: flex; flex-direction: column; } .mp-project-list strong, .mp-project-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .mp-project-list small, .mp-project-list em, .mp-chat-list small { color: var(--color-text-secondary); font-size: .64rem; font-style: normal; }+ .mp-chat-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .mp-options { display: grid; align-content: start; gap: .25rem; }+ .mp-options label { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; padding: .45rem; border-radius: .42rem; cursor: pointer; } .mp-options label:hover { background: var(--color-bg-secondary); } .mp-options label.is-empty { opacity: .48; cursor: default; } .mp-options label span { display: flex; flex-direction: column; } .mp-options label strong { font-size: .73rem; } .mp-options label small { color: var(--color-text-secondary); font-size: .65rem; line-height: 1.35; } .mp-options em { min-width: 1.5rem; padding: .14rem .32rem; border-radius: 99px; color: var(--color-text-secondary); background: var(--color-bg-secondary); text-align: center; font-size: .64rem; font-style: normal; }+ .mp-boundary { display: grid; grid-template-columns: auto 1fr; gap: .65rem; margin-top: .7rem; padding: .7rem; border: 1px solid color-mix(in srgb, var(--color-warning) 25%, var(--color-border)); border-radius: .62rem; background: color-mix(in srgb, var(--color-warning) 4%, var(--color-bg)); } .mp-boundary x-icon { color: var(--color-warning); } .mp-boundary strong { font-size: .73rem; } .mp-boundary p { margin: .12rem 0 0; color: var(--color-text-secondary); font-size: .68rem; line-height: 1.45; } .mp-boundary small { display: block; margin-top: .35rem; color: var(--color-warning); font-size: .66rem; }+ .mp-details { margin-top: .6rem; color: var(--color-text-secondary); font-size: .7rem; } .mp-details summary { cursor: pointer; } .mp-details ul { max-height: 9rem; overflow: auto; padding-left: 1.2rem; }+ .mp-consent { display: flex; gap: .5rem; align-items: center; margin-top: .7rem; font-size: .73rem; cursor: pointer; }+ .mp-footer .btn { display: inline-flex; align-items: center; gap: .4rem; }+ .mp-footer .btn:disabled { opacity: .48; cursor: not-allowed; filter: saturate(.35); }+ .mp-spin { animation: mp-spin .8s linear infinite; } @keyframes mp-spin { to { transform: rotate(360deg); } }+ .mp-empty { margin: .5rem 0; color: var(--color-text-secondary); font-size: .71rem; line-height: 1.4; }+ @media (max-width: 800px) { .mp-stats { grid-template-columns: repeat(3, 1fr); } .mp-review-grid { grid-template-columns: 1fr; } }+ @media (max-width: 560px) { .mp-shell { padding-inline: var(--spacing-sm); } .mp-intro { padding-top: 1rem; } .mp-intro h1 { font-size: 1.45rem; } .mp-lede { font-size: .82rem; } .mp-sources { grid-template-columns: 1fr; } .mp-section-head { align-items: flex-start; } .mp-muted { display: none; } .mp-command { grid-template-columns: 1fr; } .mp-copy { min-height: 2.35rem; } .mp-stats { grid-template-columns: repeat(2, 1fr); } .mp-drop { padding: 1rem; } .mp-drop-actions { flex-direction: column; width: 100%; } .mp-file-button { width: 100%; } .mp-file-row { grid-template-columns: auto minmax(0, 1fr) auto; } .mp-file-row small { display: none; } }+ @media (prefers-reduced-motion: reduce) { .mp-source { transition: none; } .mp-spin { animation: none; } }+ </style>+</body>+</html>diff --git a/plugins/_migrate_agents/webui/migrate-agents-store.js b/plugins/_migrate_agents/webui/migrate-agents-store.jsnew file mode 100644index 000000000..8b8f55496--- /dev/null+++ b/plugins/_migrate_agents/webui/migrate-agents-store.js@@ -0,0 +1,301 @@+import { createStore } from "/js/AlpineStore.js";+import { fetchApi } from "/js/api.js";+import { closeModal } from "/js/modals.js";+import { setContext } from "/index.js";+import {+ toastFrontendError,+ toastFrontendInfo,+ toastFrontendSuccess,+ toastFrontendWarning,+} from "/components/notifications/notification-store.js";++const PREVIEW_API = "/api/plugins/_migrate_agents/migration_preview";+const IMPORT_API = "/api/plugins/_migrate_agents/migration_import";++export const sources = [+ {+ id: "openclaw",+ name: "OpenClaw",+ logo: "/plugins/_migrate_agents/webui/assets/openclaw.svg",+ accent: "coral",+ hint: "Chats, projects, memory, instructions and skills",+ guideTitle: "Create an OpenClaw backup",+ guideLabel: "Run in a terminal",+ command: "openclaw backup create --verify",+ guideNote: "Choose the generated .tar.gz file below. Credentials inside the backup are detected and excluded.",+ },+ {+ id: "hermes",+ name: "Hermes Agent",+ logo: "/plugins/_migrate_agents/webui/assets/hermes.svg",+ accent: "gold",+ hint: "Chats, projects, memory, instructions and skills",+ guideTitle: "Export your Hermes sessions",+ guideLabel: "Run in a terminal",+ command: "hermes sessions export backup.jsonl --redact",+ guideNote: "To include memory and skills, also select the relevant files or folders from your Hermes data directory.",+ },+ {+ id: "opencode",+ name: "OpenCode",+ logo: "/plugins/_migrate_agents/webui/assets/opencode.svg",+ accent: "mint",+ hint: "Chats, projects, AGENTS.md and skills",+ guideTitle: "Export an OpenCode session",+ guideLabel: "Run in a terminal",+ command: "opencode export <session-id> > session.json",+ guideNote: "Repeat for other sessions. You can also add AGENTS.md and skill folders when selecting files.",+ },+ {+ id: "claude",+ name: "Claude Code",+ logo: "/plugins/_migrate_agents/webui/assets/claude.svg",+ accent: "violet",+ hint: "Chats, projects, CLAUDE.md, memory and skills",+ guideTitle: "Find your Claude Code data",+ guideLabel: "Folder to select",+ command: "~/.claude/projects",+ guideNote: "Add any CLAUDE.md, memory files, and skill folders you want to bring over.",+ },+ {+ id: "codex",+ name: "Codex",+ logo: "/plugins/_migrate_agents/webui/assets/codex.svg",+ accent: "sky",+ hint: "Chats, projects, AGENTS.md, memory and skills",+ guideTitle: "Find your Codex data",+ guideLabel: "Folders to select",+ command: "$CODEX_HOME/sessions and $CODEX_HOME/archived_sessions",+ guideNote: "CODEX_HOME is usually ~/.codex. Add AGENTS.md, memory files, and skill folders separately if needed.",+ },+];++async function responseJson(response) {+ const text = await response.text();+ if (!response.ok) throw new Error(text || `Request failed (${response.status})`);+ return text ? JSON.parse(text) : {};+}++export const store = createStore("migrationParty", {+ sources,+ source: "openclaw",+ files: [],+ preview: null,+ busy: false,+ includeChats: true,+ includeProjects: true,+ includeMemories: true,+ includeInstructions: true,+ includeSkills: true,+ reviewed: false,+ dragActive: false,+ copied: false,+ copyTimer: null,++ get selectedSource() {+ return sources.find((item) => item.id === this.source) || sources[0];+ },++ get totalBytes() {+ return this.files.reduce((total, file) => total + (file.size || 0), 0);+ },++ get canImport() {+ return Boolean(+ this.preview &&+ this.reviewed &&+ !this.busy &&+ this.selectedItemCount > 0,+ );+ },++ get selectedItemCount() {+ const summary = this.preview?.summary || {};+ return (+ (this.includeChats ? summary.chats || 0 : 0) ++ (this.includeProjects ? summary.projects || 0 : 0) ++ (this.includeMemories ? summary.memories || 0 : 0) ++ (this.includeInstructions ? summary.instructions || 0 : 0) ++ (this.includeSkills ? summary.skills || 0 : 0)+ );+ },++ get primaryDisabled() {+ return this.busy || (this.preview ? !this.canImport : !this.files.length);+ },++ get primaryLabel() {+ if (this.busy) return this.preview ? "Importing…" : "Checking export…";+ if (this.preview) return "Import selected data";+ return this.files.length ? "Review selected data" : "Select an export to continue";+ },++ onOpen() {+ this.reset();+ },++ cleanup() {+ this.dragActive = false;+ if (this.copyTimer) clearTimeout(this.copyTimer);+ },++ reset() {+ this.files = [];+ this.preview = null;+ this.reviewed = false;+ this.busy = false;+ this.dragActive = false;+ this.copied = false;+ this.includeChats = true;+ this.includeProjects = true;+ this.includeMemories = true;+ this.includeInstructions = true;+ this.includeSkills = true;+ },++ chooseSource(source) {+ if (source === this.source) return;+ this.source = source;+ this.files = [];+ this.preview = null;+ this.reviewed = false;+ this.copied = false;+ },++ acceptFiles(fileList) {+ const incoming = Array.from(fileList || []);+ if (!incoming.length) return;+ const byKey = new Map(this.files.map((file) => [`${file.webkitRelativePath || file.name}:${file.size}`, file]));+ for (const file of incoming) byKey.set(`${file.webkitRelativePath || file.name}:${file.size}`, file);+ this.files = [...byKey.values()];+ this.preview = null;+ this.reviewed = false;+ },++ handleFiles(event) {+ this.acceptFiles(event?.target?.files);+ if (event?.target) event.target.value = "";+ },++ onDrop(event) {+ this.dragActive = false;+ this.acceptFiles(event?.dataTransfer?.files);+ },++ removeFile(index) {+ this.files = this.files.filter((_, position) => position !== index);+ this.preview = null;+ this.reviewed = false;+ },++ clearFiles() {+ this.files = [];+ this.preview = null;+ this.reviewed = false;+ },++ formatBytes(value) {+ if (!value) return "0 B";+ const units = ["B", "KiB", "MiB", "GiB"];+ const power = Math.min(Math.floor(Math.log(value) / Math.log(1024)), units.length - 1);+ return `${(value / 1024 ** power).toFixed(power ? 1 : 0)} ${units[power]}`;+ },++ async copyExportValue() {+ try {+ await navigator.clipboard.writeText(this.selectedSource.command);+ this.copied = true;+ if (this.copyTimer) clearTimeout(this.copyTimer);+ this.copyTimer = setTimeout(() => { this.copied = false; }, 1600);+ void toastFrontendInfo("Copied to the clipboard.", "Migrate Agents");+ } catch {+ void toastFrontendError("Could not copy. Select the text and copy it manually.", "Migrate Agents");+ }+ },++ formData(includeOptions = false) {+ const data = new FormData();+ data.append("source", this.source);+ for (const file of this.files) {+ data.append("files[]", file, file.webkitRelativePath || file.name);+ }+ if (includeOptions) {+ data.append("include_chats", String(this.includeChats));+ data.append("include_projects", String(this.includeProjects));+ data.append("include_memories", String(this.includeMemories));+ data.append("include_instructions", String(this.includeInstructions));+ data.append("include_skills", String(this.includeSkills));+ }+ return data;+ },++ async inspect() {+ if (!this.files.length) {+ void toastFrontendWarning("Choose an export file, archive, or folder first.", "Migrate Agents");+ return;+ }+ this.busy = true;+ this.preview = null;+ this.reviewed = false;+ try {+ const response = await fetchApi(PREVIEW_API, {+ method: "POST",+ credentials: "same-origin",+ body: this.formData(),+ });+ this.preview = await responseJson(response);+ const found = this.preview?.summary || {};+ this.includeChats = Boolean(found.chats);+ this.includeProjects = Boolean(found.projects);+ this.includeMemories = Boolean(found.memories);+ this.includeInstructions = Boolean(found.instructions);+ this.includeSkills = Boolean(found.skills);+ void toastFrontendInfo(+ `Found ${found.chats || 0} chats, ${found.projects || 0} projects, ${found.memories || 0} memories, ${found.instructions || 0} instructions, and ${found.skills || 0} skills.`,+ "Migrate Agents",+ );+ if (this.preview?.warnings?.length) {+ void toastFrontendWarning(`${this.preview.warnings.length} item(s) need review.`, "Migrate Agents");+ }+ } catch (error) {+ void toastFrontendError(error instanceof Error ? error.message : String(error), "Migrate Agents");+ } finally {+ this.busy = false;+ }+ },++ async migrate() {+ if (!this.canImport) return;+ this.busy = true;+ try {+ const response = await fetchApi(IMPORT_API, {+ method: "POST",+ credentials: "same-origin",+ body: this.formData(true),+ });+ const result = await responseJson(response);+ const summary = result.summary || {};+ void toastFrontendSuccess(+ `Imported ${summary.chats || 0} chats, ${summary.projects || 0} projects, ${summary.memories || 0} memories, ${summary.instructions || 0} instructions, and ${summary.skills || 0} skills.`,+ "Migrate Agents",+ );+ if (result.warnings?.length) {+ void toastFrontendWarning(`${result.warnings.length} item(s) were skipped with warnings.`, "Migrate Agents");+ }+ if (result.ctxids?.[0]) setContext(result.ctxids[0]);+ closeModal("/plugins/_migrate_agents/webui/main.html");+ } catch (error) {+ void toastFrontendError(error instanceof Error ? error.message : String(error), "Migrate Agents");+ } finally {+ this.busy = false;+ }+ },++ primaryAction() {+ return this.preview ? this.migrate() : this.inspect();+ },++ close() {+ closeModal("/plugins/_migrate_agents/webui/main.html");+ },+});diff --git a/plugins/_migrate_agents/webui/thumbnail.webp b/plugins/_migrate_agents/webui/thumbnail.webpnew file mode 100644index 000000000..c9cf5a431Binary files /dev/null and b/plugins/_migrate_agents/webui/thumbnail.webp differ