Skip to content

feat: import OpenClaw data (memory, history, settings, credentials)#388

Closed
jaswinder6991 wants to merge 1 commit intonearai:stagingfrom
jaswinder6991:feat/import-openclaw
Closed

feat: import OpenClaw data (memory, history, settings, credentials)#388
jaswinder6991 wants to merge 1 commit intonearai:stagingfrom
jaswinder6991:feat/import-openclaw

Conversation

@jaswinder6991
Copy link
Copy Markdown
Contributor

Summary

Implements ironclaw import openclaw CLI command and onboarding wizard integration for migrating data from OpenClaw installations into IronClaw. Addresses #58.

What it does

Five-phase import pipeline:

  1. Settings — maps OpenClaw JSON5 config keys → IronClaw settings (llm_backend, model, embeddings provider/model)
  2. Identity files — AGENTS.md, SOUL.md, USER.md, IDENTITY.md, HEARTBEAT.md, MEMORY.md
  3. Memory documentsworkspace/memory/*.md → IronClaw workspace
  4. Conversations — JSONL session transcripts → IronClaw conversation history (idempotent via deterministic UUIDs)
  5. Credentials — API keys from auth.profiles + OAuth tokens from credentials/oauth.json → encrypted secrets store

Key features

  • Auto-discovers ~/.openclaw and legacy dirs (~/.clawdbot, ~/.moldbot, ~/.moltbot)
  • Parses JSON5 config (OpenClaw's format)
  • --dry-run mode to preview without writing
  • Fully idempotent — safe to run multiple times (skips existing data)
  • Wizard integration — prompts during onboarding if OpenClaw installation detected
  • 18 unit tests across discovery, config parsing, and JSONL parsing

Usage

ironclaw import openclaw                          # auto-detect ~/.openclaw
ironclaw import openclaw --path /custom/path      # explicit path
ironclaw import openclaw --dry-run                # preview only

Files changed (13 files, +1855 lines)

  • src/import/ — new module: mod.rs, discovery.rs, config_parser.rs, openclaw.rs, progress.rs
  • src/cli/import.rs — CLI subcommand handler
  • src/cli/mod.rs, src/lib.rs, src/main.rs — wiring
  • src/db/postgres.rs — added PgBackend::from_pool() for wizard reuse
  • src/setup/wizard.rs — OpenClaw detection step in onboarding
  • Cargo.toml — added json5 = "0.4"

Questions for code owners

  1. General direction — Does this approach look right? Any architectural concerns with the import module structure or the 5-phase pipeline? Would you prefer a different abstraction (e.g., a generic Importer trait for future sources)?

  2. Tools/skills import — This PR covers memory, history, settings, and credentials. Should we also import OpenClaw's installed tools and skills (WASM extensions, MCP server configs, SKILL.md files)? OpenClaw has similar concepts — would be straightforward to add as Phase 6/7 if desired.

  3. Wizard placement — The OpenClaw detection runs after the database setup step in the onboarding wizard. Is this the right spot, or should it be a separate post-wizard flow?

Looking for a general direction before polishing further.

Test plan

  • cargo fmt — clean
  • cargo clippy --all --all-features — zero warnings
  • cargo test --lib -- import — 18/18 passing
  • cargo check --no-default-features --features libsql — compiles
  • cargo check --no-default-features --features postgres — compiles
  • Manual test with real OpenClaw installation
  • Integration test with in-memory DB

🤖 Generated with Claude Code

@github-actions github-actions bot added scope: agent Agent core (agent loop, router, scheduler) scope: channel Channel infrastructure scope: channel/cli TUI / CLI channel scope: channel/web Web gateway channel scope: channel/wasm WASM channel runtime scope: tool Tool infrastructure scope: tool/builtin Built-in tools scope: tool/wasm WASM tool sandbox scope: tool/mcp MCP client scope: tool/builder Dynamic tool builder scope: db Database trait / abstraction scope: db/postgres PostgreSQL backend scope: db/libsql libSQL / Turso backend scope: safety Prompt injection defense scope: llm LLM integration scope: workspace Persistent memory / workspace scope: orchestrator Container orchestrator scope: worker Container worker scope: secrets Secrets management scope: config Configuration scope: extensions Extension management scope: setup Onboarding / setup scope: evaluation Success evaluation scope: estimation Cost/time estimation scope: sandbox Docker sandbox scope: hooks Git/event hooks scope: pairing Pairing mode scope: ci CI/CD workflows scope: docs Documentation scope: dependencies Dependency updates labels Feb 26, 2026
@github-actions github-actions bot added size: XL 500+ changed lines risk: high Safety, secrets, auth, or critical infrastructure contributor: regular 2-5 merged PRs labels Feb 26, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @jaswinder6991, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances IronClaw's capabilities by introducing a robust data migration path from OpenClaw, broadening its compatibility with various LLM providers, and modularizing its core agent architecture. It also expands the ecosystem with new WASM channels and tools, while bolstering security and observability features. These changes aim to make IronClaw more extensible, easier to deploy, and more resilient against runaway costs.

Highlights

  • OpenClaw Data Import: Introduced a new ironclaw import openclaw CLI command and integrated it into the onboarding wizard, enabling migration of settings, identity files, memory documents, conversation history, and credentials from OpenClaw installations.
  • Enhanced LLM Provider Support: Expanded LLM provider configuration in .env.example and CLAUDE.md to include Ollama, OpenAI-compatible endpoints (OpenRouter, Together AI, Fireworks AI, vLLM, LiteLLM, LM Studio), and Tinfoil private inference, alongside existing NEAR AI, OpenAI, and Anthropic options.
  • Modular Agent Architecture: Refactored the core agent loop by extracting command handling into src/agent/commands.rs, agentic loop and tool dispatch into src/agent/dispatcher.rs, and thread-specific operations into src/agent/thread_ops.rs, improving maintainability and separation of concerns.
  • New WASM Channels and Tools: Added new WASM-based channels for Discord, Slack, and WhatsApp, along with new WASM tools for GitHub, Gmail, Google Calendar, Docs, Drive, Sheets, Slides, Okta, and Telegram, enhancing the agent's extensibility and capabilities.
  • Advanced Security and Observability: Introduced a comprehensive NETWORK_SECURITY.md document detailing network-facing surfaces, authentication, and security controls. Implemented LLM cost tracking (src/agent/cost_guard.rs) and a background job monitor (src/agent/job_monitor.rs) for Claude Code output.
  • Improved Build and Deployment: Updated Cargo.toml with feature-gated database backends (PostgreSQL and libSQL/Turso) and new build scripts (build.rs, scripts/build-all.sh, scripts/dev-setup.sh) for reproducible channel compilation and streamlined development setup. Added Dockerfiles and systemd services for cloud deployment.
Changelog
  • .claude/commands/add-tool.md
    • Updated requires_approval function signature to accept _params and return ApprovalRequirement.
  • .claude/commands/fix-issue.md
    • Added new Claude command to fix GitHub issues.
  • .claude/commands/respond-pr.md
    • Added new Claude command to respond to PR review comments.
  • .claude/commands/review-crate.md
    • Added new Claude command to audit Rust crates.
  • .claude/commands/review-pr.md
    • Added new Claude command to perform paranoid architectural reviews of pull requests.
  • .claude/commands/triage-issues.md
    • Added new Claude command to triage GitHub issues.
  • .claude/commands/triage-prs.md
    • Added new Claude command to triage pull requests.
  • .env.example
    • Updated LLM provider examples to include Ollama, OpenAI-compatible, OpenRouter, Together AI, and Fireworks AI.
    • Added configuration options for memory hygiene settings.
  • .gitattributes
    • Added linguist-generated=true attribute for HTML files in tests/test-pages.
  • .github/labeler.yml
    • Added new GitHub labeler configuration for various code scopes (agent, channel, tool, db, safety, llm, workspace, orchestrator, worker, secrets, config, extensions, setup, evaluation, estimation, sandbox, hooks, pairing, ci, docs, dependencies).
  • .github/scripts/create-labels.sh
    • Added a new script to idempotently create GitHub labels for size, risk, scope, and contributor tiers.
  • .github/scripts/pr-labeler.sh
    • Added a new script to classify pull requests by size, risk, and contributor tier, applying appropriate GitHub labels.
  • .gitignore
    • Added .env.* and !.env.example to ignore environment files.
    • Added .claude/worktrees/, .sidecar/, and .todos/ to ignore Claude Code and sidecar data.
    • Added bench-results/ to ignore benchmark output.
  • CHANGELOG.md
    • Added changelog entries for version 0.11.1, including ignoring out-of-date generated CI.
  • CLAUDE.md
    • Updated features list to include network proxy and credential injection for sandbox, skills system, shell env scrubbing, multi-provider LLM, and setup wizard.
    • Revised linting instructions to fix all warnings before committing.
    • Updated module structure to reflect new dispatcher.rs in agent/ and new mod.rs, nearai_chat.rs, circuit_breaker.rs, retry.rs, failover.rs, response_cache.rs, costs.rs, rig_adapter.rs in llm/.
    • Added skill_tools.rs to tools/builtin/ and expanded db/ module structure.
    • Included sandbox/, setup/, and skills/ module descriptions.
    • Updated error handling guidelines to explicitly ban .expect() in production code and added mechanical verification steps.
    • Expanded Traits for Extensibility to include Database and NetworkPolicyDecider.
    • Added Code Style and Review & Fix Discipline sections.
    • Updated Configuration section with DATABASE_BACKEND, LIBSQL_PATH, LIBSQL_URL, LIBSQL_AUTH_TOKEN, NEARAI_API_KEY, SKILLS_ENABLED, SKILLS_MAX_TOKENS, SKILLS_CATALOG_URL, SKILLS_AUTO_DISCOVER, TINFOIL_API_KEY, TINFOIL_MODEL, and sandbox network proxy settings.
    • Detailed LLM Providers section with NEAR AI, OpenAI-compatible, and Tinfoil information.
    • Expanded Database section to cover PostgreSQL and libSQL/Turso backends, feature flags, the Database trait, and schema differences.
    • Added Current Limitations (libSQL backend) section.
    • Updated Safety Layer to include Leak Detector and Shell Environment Scrubbing.
    • Added comprehensive Skills System documentation, including trust model, SKILL.md format, selection pipeline, skill tools, skill directories, and testing skills.
    • Added detailed Docker Sandbox documentation, including policies, network proxy, and zero-exposure credential model.
    • Removed Completed features section and updated Tool Architecture principles.
  • Cargo.toml
    • Updated package version to 0.11.1 and Rust version to 1.92.
    • Added workspace definition with excludes for various channel and tool source directories.
    • Added authors, homepage, repository, and package.metadata.wix fields.
    • Updated reqwest features to rustls-tls-native-roots.
    • Made deadpool-postgres, tokio-postgres, postgres-types, refinery, pgvector optional and feature-gated under postgres.
    • Added libsql as an optional dependency and feature-gated under libsql.
    • Added toml, json5, fs4, subtle, rig-core, flate2, tar, clap_complete dependencies.
    • Removed rust_decimal/db-tokio-postgres feature.
    • Updated rustyline features to include custom-bindings.
    • Updated tower-http features to include set-header.
    • Added serde_yml for YAML parsing.
    • Added url dependency.
    • Added html-to-markdown-rs and readabilityrs as optional dependencies and feature-gated under html-to-markdown.
    • Defined default features to include postgres, libsql, and html-to-markdown.
    • Added html_to_markdown test target with required-features.
    • Added profile.dist and workspace.metadata.dist configurations for cargo-dist.
  • Dockerfile
    • Added a new multi-stage Dockerfile for IronClaw agent cloud deployment, including build and runtime stages.
  • Dockerfile.worker
    • Updated base Rust image to rust:1.92-bookworm.
    • Modified Dockerfile to install gh CLI and updated Rust toolchain version for the sandbox user.
  • FEATURE_PARITY.md
    • Updated OpenAI-compatible HTTP API to reflect per-request model override.
    • Added Agent event broadcast, Channel health monitor, Presence system, Trusted-proxy auth mode, APNs push pipeline, Oversized payload guard, and Pre-prompt context diagnostics to Core Features.
    • Updated WhatsApp and Telegram channel notes, added Linq and Feishu/Lark to Channels.
    • Added Telegram-Specific Features, Discord-Specific Features, and Slack-Specific Features tables.
    • Updated DM pairing codes and Mention-based activation to implemented.
    • Updated Per-channel media limits and Typing indicators to 🚧.
    • Updated status CLI command note to include enriched session details.
    • Updated skills CLI command to implemented with web API endpoints.
    • Updated pairing CLI command to implemented with list/approve and account selector.
    • Added /subagents spawn and /export-session CLI commands.
    • Updated Multi-provider failover to implemented with FailoverProvider.
    • Updated Skills (modular capabilities) to implemented with trust gating, attenuation, activation criteria, catalog, and selector.
    • Updated Hooks system to implemented with core lifecycle hooks and bundled/plugin/workspace hooks.
    • Added Post-compaction read audit, Post-compaction context injection, Skill routing blocks, Skill path compaction, Per-model thinkingDefault override, Z.AI tool_stream, Multiple images per tool call, URL allowlist (web_search/fetch), suppressToolErrors config, Intent-first tool display, Transcript file size in status to Agent Features.
    • Added NVIDIA API and Tinfoil to LLM Providers.
    • Updated OpenRouter and Ollama (local) to implemented.
    • Added Per-model thinkingDefault and 1M context beta header to LLM Provider Features.
    • Added Configurable image resize dims and Multiple images per tool call to Vision Features.
    • Added Incremental TTS playback to Audio Features.
    • Updated Hook plugins, Bundled hooks, Plugin hooks, Workspace hooks, Outbound webhooks to implemented.
    • Added before_agent_start hook, before_message_write hook, llm_input/llm_output hooks to Hooks.
    • Added Full model compat fields in schema to Configuration.
    • Added Temporal decay (hybrid search), MMR re-ranking, LLM-based query expansion to Memory Features.
    • Updated Embeddings batching and Memory CLI commands to implemented.
    • Added Apple Watch companion, APNs push notifications, Share to OpenClaw (iOS), Background listening toggle to Mobile Features.
    • Added Animated menubar icon, Agent-controlled panel with placement/resizing, Overlay, mic picker, language selection, live meter, Partial transcripts, adaptive delays, dismiss animations, System-wide hotkey, Instances tab, Agent events debug window, Sparkle auto-updates to Desktop Features.
    • Added Control UI i18n, WebChat theme sync, Partial output on abort to Web UI Features.
    • Added Cron stagger controls, Cron finished-run webhook, Channel health monitor, before_agent_start hook, before_message_write hook, llm_input/llm_output hooks to Routines & Hooks.
    • Added Trusted-proxy auth, SSRF IPv6 transition bypass block, Cron webhook SSRF guard, Podman support, Sandbox env sanitization, Safe bins allowlist, Credential theft via env injection, Skill download path restriction, Dangerous tool re-enable warning to Security Features.
    • Added Docker: Chromium + Xvfb, Docker: init scripts, Browser: extraArgs config to DevOps & Infra.
    • Updated P0 - Core to include DM pairing and embeddings batching.
    • Updated P1 - High Priority to include Telegram channel, Multi-provider failover, and Hooks system.
    • Updated P2 - Medium Priority to include Ollama/local model support.
    • Updated P3 - Lower Priority to reflect changes in skills, streaming, memory, and UI.
    • Added Tinfoil private inference, GitHub WASM tool, Prompt-based skills to IronClaw Differentiators.
  • build.rs
    • Added a new build script to compile the Telegram channel WASM from source and embed registry manifests into the binary.
  • channels-src/discord/Cargo.lock
    • Added new Cargo.lock file for the Discord channel.
  • channels-src/discord/Cargo.toml
    • Added new Cargo.toml for the Discord channel, defining its package metadata and dependencies.
  • channels-src/discord/README.md
    • Added a README file for the Discord channel, detailing features, setup, configuration, usage examples, error handling, advanced usage, troubleshooting, and building instructions.
  • channels-src/discord/discord.capabilities.json
    • Added a new capabilities JSON file for the Discord channel, specifying its type, name, description, setup requirements, HTTP capabilities (allowlist, credentials, rate limit), secrets access, channel capabilities, and configuration options.
  • channels-src/discord/src/lib.rs
    • Added the Rust source code for the Discord channel, implementing on_start, on_http_request, on_respond, on_status, and on_shutdown functions for Discord interaction handling, message parsing, and response posting.
  • channels-src/slack/Cargo.toml
    • Added [workspace] declaration to the Cargo.toml file.
  • channels-src/slack/slack.capabilities.json
    • Updated Slack channel capabilities to include setup requirements for slack_bot_token and slack_signing_secret.
    • Added owner_id, dm_policy, and allow_from to the channel configuration.
  • channels-src/slack/src/lib.rs
    • Implemented permission and pairing logic (check_sender_permission, send_pairing_reply) for Slack messages.
    • Persisted owner_id, dm_policy, and allow_from to workspace for cross-callback access.
    • Added message truncation for json_response to prevent serialization errors.
  • channels-src/telegram/Cargo.toml
    • Added [workspace] declaration to the Cargo.toml file.
  • channels-src/telegram/src/lib.rs
    • Updated TelegramMessage to include a caption field for media messages.
    • Added workspace paths for DM_POLICY_PATH, ALLOW_FROM_PATH, CHANNEL_NAME, BOT_USERNAME_PATH, and RESPOND_TO_ALL_GROUP_PATH.
    • Updated on_start to persist dm_policy, allow_from, bot_username, and respond_to_all_group_messages to the workspace.
    • Refactored on_poll to include retry logic for getUpdates on transient HTTP failures.
    • Updated on_respond to use Option<i64> for reply_to_message_id in send_message.
    • Enhanced on_status to classify status updates into TelegramStatusAction (Typing or Notify) and send appropriate Telegram actions or messages.
    • Implemented send_pairing_reply for DM pairing.
    • Modified handle_message to use content (text or caption) and incorporate dm_policy, allow_from, bot_username, and respond_to_all_group_messages for permission checks and group mention handling.
    • Refined clean_message_text to handle specific bot mentions and content_to_emit_for_agent for intelligent message emission.
  • channels-src/telegram/telegram.capabilities.json
    • Updated Telegram channel capabilities to include setup requirements for telegram_bot_token.
    • Removed callback_timeout_secs from channel capabilities.
    • Added dm_policy and allow_from to the channel configuration.
  • channels-src/whatsapp/Cargo.toml
    • Added [workspace] declaration to the Cargo.toml file.
  • channels-src/whatsapp/src/lib.rs
    • Added workspace paths for OWNER_ID_PATH, DM_POLICY_PATH, ALLOW_FROM_PATH, and CHANNEL_NAME.
    • Updated WhatsAppConfig to include owner_id, dm_policy, and allow_from.
    • Modified on_start to persist api_version, owner_id, dm_policy, and allow_from to the workspace.
    • Updated on_respond to dynamically use api_version from the workspace for API calls.
    • Implemented check_sender_permission and send_pairing_reply for WhatsApp DM pairing and permission handling.
  • channels-src/whatsapp/whatsapp.capabilities.json
    • Added owner_id, dm_policy, and allow_from to the channel configuration.
  • deploy/cloud-sql-proxy.service
    • Added a new systemd service file for the Cloud SQL Auth Proxy.
  • deploy/env.example
    • Added an example environment file for cloud deployment, including database, NEAR AI, agent, web gateway, and disabled sandbox/heartbeat/embedding settings.
  • deploy/ironclaw.service
    • Added a new systemd service file for the IronClaw AI Assistant, configured to pull and run a Docker image.
  • deploy/setup.sh
    • Added a new VM bootstrap script for GCP Compute Engine, automating Docker, Cloud SQL Auth Proxy, and IronClaw service installation and configuration.
  • docker-compose.yml
    • Added a new Docker Compose file for local PostgreSQL setup with pgvector, including environment variables and a healthcheck.
  • docs/BUILDING_CHANNELS.md
    • Added a section on supply chain security, emphasizing not to commit compiled WASM binaries and detailing reproducible build steps.
    • Updated Telegram channel manual build instructions.
    • Revised general channel building instructions to use channels-src and wasm32-wasip2 target.
  • docs/LLM_PROVIDERS.md
    • Added a new documentation file detailing LLM provider configuration, including NEAR AI, Anthropic, OpenAI, Ollama, and various OpenAI-compatible endpoints (OpenRouter, Together AI, Fireworks AI, vLLM, LiteLLM, LM Studio).
  • docs/TELEGRAM_SETUP.md
    • Added a new documentation file for Telegram channel setup, covering prerequisites, quick start, DM pairing, manual installation, secrets, webhook secret, and troubleshooting.
  • ironclaw.fish
    • Added a new Fish shell completion script for the ironclaw CLI, including global options and subcommands.
  • ironclaw.zsh
    • Added a new Zsh shell completion script for the ironclaw CLI, including global options and subcommands.
  • migrations/V9__flexible_embedding_dimension.sql
    • Added a new SQL migration to allow flexible embedding vector dimensions in memory_chunks by dropping and recreating related views and altering the column type.
  • registry/_bundles.json
    • Added new bundle definitions for 'google', 'messaging', and 'default' extension sets.
  • registry/channels/discord.json
    • Added a new registry entry for the Discord channel, including its source, artifacts, authentication summary, and tags.
  • registry/channels/slack.json
    • Added a new registry entry for the Slack channel, including its source, artifacts, authentication summary, and tags.
  • registry/channels/telegram.json
    • Added a new registry entry for the Telegram channel, including its source, artifacts, authentication summary, and tags.
  • registry/channels/whatsapp.json
    • Added a new registry entry for the WhatsApp channel, including its source, artifacts, authentication summary, and tags.
  • registry/tools/github.json
    • Added a new registry entry for the GitHub tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/gmail.json
    • Added a new registry entry for the Gmail tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/google-calendar.json
    • Added a new registry entry for the Google Calendar tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/google-docs.json
    • Added a new registry entry for the Google Docs tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/google-drive.json
    • Added a new registry entry for the Google Drive tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/google-sheets.json
    • Added a new registry entry for the Google Sheets tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/google-slides.json
    • Added a new registry entry for the Google Slides tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/okta.json
    • Added a new registry entry for the Okta tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/slack.json
    • Added a new registry entry for the Slack tool, including its source, artifacts, authentication summary, and tags.
  • registry/tools/telegram.json
    • Added a new registry entry for the Telegram tool, including its source, artifacts, authentication summary, and tags.
  • release-plz.toml
    • Added a new release-plz.toml configuration file, disabling git release enablement.
  • scripts/build-all.sh
    • Added a new script to build IronClaw and all bundled channels.
  • scripts/dev-setup.sh
    • Added a new developer setup script to prepare a fresh checkout for development, including rustup, wasm target, wasm-tools, and initial checks.
  • skills/web-ui-test/SKILL.md
    • Added a new skill definition for testing the IronClaw web UI using the Claude for Chrome browser extension, including prerequisites, server startup, test checklist, cleanup, and known issues.
  • src/NETWORK_SECURITY.md
    • Added a new comprehensive network security reference document, detailing threat model, network surface inventory, web gateway, HTTP webhook server, orchestrator internal API, OAuth callback listener, sandbox HTTP proxy, egress controls, authentication mechanisms summary, known security findings, and a review checklist for network changes.
  • src/agent/agent_loop.rs
    • Refactored agent loop to move command handling to commands.rs and thread operations to thread_ops.rs.
    • Updated AgentDeps to include cheap_llm, skill_registry, skill_catalog, skills_config, hooks, and cost_guard.
    • Updated Agent::new signature to accept Arc<ChannelManager> and hygiene_config.
    • Added cheap_llm, hooks, cost_guard, skill_registry, skill_catalog accessors.
    • Implemented select_active_skills for dynamic skill selection.
    • Modified heartbeat spawning to include hygiene_config and safety.
    • Updated routine engine spawning to pass scheduler.
    • Enhanced message handling to include BeforeInbound hook execution and suppress silent LLM replies.
    • Improved error response handling to channels.
  • src/agent/commands.rs
    • Created a new module commands.rs to encapsulate system command and job handling logic previously in agent_loop.rs.
    • Implemented handle_job_or_command, handle_create_job, handle_check_status, handle_cancel_job, handle_list_jobs, handle_help_job, process_heartbeat, process_summarize, process_suggest, and handle_system_command.
    • Added handle_skills_list and handle_skills_search for skill management CLI commands.
    • Updated /model command to list available models and provide switching functionality.
  • src/agent/compaction.rs
    • Updated ContextCompactor::new to accept Arc<SafetyLayer>.
    • Improved error handling for workspace writes during summary and context compaction.
    • Modified summarize_messages to use Reasoning and SafetyLayer for LLM calls.
  • src/agent/cost_guard.rs
    • Created a new module cost_guard.rs to implement LLM cost tracking and enforcement.
    • Defined CostGuardConfig for daily budget and hourly action limits.
    • Implemented CostGuard with methods new, check_allowed, record_llm_call, daily_spend, actions_this_hour, and model_usage.
  • src/agent/dispatcher.rs
    • Created a new module dispatcher.rs to encapsulate the agentic loop and tool dispatch logic.
    • Implemented run_agentic_loop with skill selection, tool attenuation, cost guard checks, context compaction retry on ContextLengthExceeded, parallel tool execution via JoinSet, and deferred auth handling.
    • Implemented execute_chat_tool_standalone for tool execution outside the agent context.
    • Defined ParsedAuthData and check_auth_required for handling authentication intercepts.
  • src/agent/heartbeat.rs
    • Updated HeartbeatRunner to include hygiene_config and safety.
    • Modified HeartbeatRunner::new to accept hygiene_config and safety.
    • Integrated memory hygiene (run_if_due) into the heartbeat loop.
    • Updated check_heartbeat to use Reasoning and SafetyLayer for LLM calls and improved error handling for empty/truncated responses.
  • src/agent/job_monitor.rs
    • Created a new module job_monitor.rs to spawn a background task that monitors Claude Code job events and injects assistant messages into the agent loop.
  • src/agent/mod.rs
    • Added commands, cost_guard, dispatcher, job_monitor, and thread_ops modules.
    • Exported truncate_for_preview from agent_loop.rs.
  • src/agent/routine.rs
    • Updated Trigger::from_db to return RoutineError and provide more specific error types.
    • Updated RoutineAction::from_db to return RoutineError and provide more specific error types.
    • Updated RunStatus::from_str to return RoutineError.
    • Updated next_cron_fire to return RoutineError.
  • src/agent/routine_engine.rs
    • Updated RoutineEngine to use Arc<dyn Database> for store and Arc<AtomicUsize> for running_count.
    • Added scheduler to RoutineEngine for dispatching full-job routines.
    • Modified new function to accept scheduler.
    • Updated handle_event and handle_cron_tick to use atomic operations for running_count and handle global capacity checks.
    • Updated fire_manual to return RoutineError and handle disabled/max concurrent routines.
    • Modified execute_routine to use atomic increment/decrement for running_count.
    • Implemented execute_full_job to dispatch jobs via the scheduler and link routine runs to jobs.
    • Updated execute_lightweight to sanitize routine names for workspace paths and return RoutineError for LLM failures and empty/truncated responses.
    • Improved truncate function to handle UTF-8 character boundaries correctly.
  • src/agent/scheduler.rs
    • Updated Scheduler to use Arc<dyn Database> for store and include hooks: Arc<HookRegistry>.
    • Added dispatch_job method to create, persist, and schedule jobs in one step.
    • Modified schedule method to use a write lock for the entire check-insert sequence to prevent race conditions.
    • Updated stop method to handle job state transitions more robustly.
    • Updated execute_tool to use tool.requires_approval(&params).is_required().
  • src/agent/self_repair.rs
    • Updated DefaultSelfRepair to use Arc<dyn Database> for store.
    • Modified with_store and with_builder to be pub(crate) and added TODO comments for wiring.
    • Updated check_stuck_jobs to use && for conditional checks.
  • src/agent/session.rs
    • Updated Session::create_thread and get_or_create_thread to use HashMap::entry().or_insert() for more robust thread creation and retrieval.
    • Updated PendingApproval to include deferred_tool_calls for multi-tool approval flows.
    • Removed last_response_id from Thread struct.
    • Modified Thread::start_turn to return a mutable reference to the newly created turn using direct indexing.
  • src/agent/session_manager.rs
    • Added SESSION_COUNT_WARNING_THRESHOLD constant.
    • Updated SessionManager to include hooks: Option<Arc<HookRegistry>>.
    • Added with_hooks method to attach a hook registry.
    • Modified get_or_create_session to log warnings for high session counts and fire OnSessionStart hooks.
    • Updated prune_stale_sessions to fire OnSessionEnd hooks for removed sessions.
  • src/agent/submission.rs
    • Updated SubmissionParser::parse to include /skills and /skills search commands.
    • Expanded approval response aliases to include /approve, /always, /deny, /yes, /no, /y, /n, /a.
    • Added #[cfg(test)] to Submission::approval, always_approve, interrupt, compact, undo, redo, starts_turn and SubmissionResult::ok methods.
  • src/agent/task.rs
    • Added #[cfg(test)] to TaskOutput::text, empty and Task::job_with_id, background, background_with_id, parent_id methods.
    • Added #[cfg(test)] to TaskStatus enum.
  • src/agent/thread_ops.rs
    • Created a new module thread_ops.rs to encapsulate thread-specific operations previously in agent_loop.rs.
    • Implemented maybe_hydrate_thread, process_user_input, persist_user_message, persist_assistant_response, process_undo, process_redo, process_interrupt, process_compact, process_clear, process_approval, handle_auth_intercept, process_auth_token, process_new_thread, and process_switch_thread.
Ignored Files
  • Ignored by pattern: .github/workflows/** (6)
    • .github/workflows/code_style.yml
    • .github/workflows/pr-label-classify.yml
    • .github/workflows/pr-label-scope.yml
    • .github/workflows/release-plz.yml
    • .github/workflows/release.yml
    • .github/workflows/test.yml
Activity
  • The pull request author, jaswinder6991, has implemented a new CLI command ironclaw import openclaw to migrate data from OpenClaw installations.
  • The PR includes 18 unit tests covering discovery, config parsing, and JSONL parsing, all of which are passing.
  • The author has performed cargo fmt and cargo clippy --all --all-features checks, with zero warnings.
  • The PR compiles successfully with both libsql and postgres features enabled.
  • Manual testing with a real OpenClaw installation and integration testing with an in-memory database are planned but not yet completed.
  • The author has posed several questions to code owners regarding the general architectural direction, the inclusion of tools/skills import, and the placement of the OpenClaw detection in the onboarding wizard.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

…ion (nearai#58)

Implements a CLI command and onboarding wizard step to import data from
existing OpenClaw installations into IronClaw.

Five-phase import pipeline:
1. Settings — maps OpenClaw config keys (llm_backend, model, embeddings)
2. Identity files — AGENTS.md, SOUL.md, USER.md, etc.
3. Memory documents — workspace/memory/*.md files
4. Conversations — JSONL session transcripts with idempotent dedup
5. Credentials — API keys and OAuth tokens (encrypted at rest)

Features:
- Auto-discovers ~/.openclaw (and legacy ~/.clawdbot, ~/.moldbot, ~/.moltbot)
- Parses JSON5 config files (OpenClaw's format)
- Dry-run mode (--dry-run) to preview without writing
- Idempotent: safe to run multiple times (skips existing data)
- Wizard integration: prompts during onboarding if OpenClaw detected
- 18 unit tests covering discovery, config parsing, JSONL parsing

Usage:
  ironclaw import openclaw [--path ~/.openclaw] [--dry-run]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a massive and impressive pull request that introduces significant refactorings and new features across the entire codebase, greatly improving maintainability, robustness, and functionality. The agent loop has been skillfully broken down into more manageable modules, and new features like the skills system, cost guardrails, and parallel tool execution are excellent additions. The code quality is high, with notable improvements in error handling, concurrency, and API design. While some functions in dispatcher.rs and thread_ops.rs are quite large, suggestions for further structural refactoring are being deferred to follow-up tasks, aligning with the primary goal of this PR (as indicated by its title/description) to achieve correctness and feature parity. Please note that the PR title and description seem to be for a different change (importing OpenClaw data), which was a bit confusing during the review.

I am having trouble creating individual review comments. Click here to see my feedback.

src/agent/dispatcher.rs (37-671)

medium

This function is indeed very long and complex, spanning over 600 lines. While the logic for handling the agentic loop with tool calls, approvals, and hooks is quite sophisticated, its size makes it difficult to follow and maintain. However, given that the primary goal of this pull request appears to be focused on achieving correctness and feature parity (as indicated by the PR title/description), large structural refactorings like breaking down this function should be deferred to a follow-up task to keep the current PR focused.

References
  1. Defer large structural refactorings, like breaking down a large file, when the primary goal of a pull request is to achieve correctness and feature parity with an existing implementation. The refactoring should be tracked as a follow-up task.

src/agent/thread_ops.rs (692-1091)

medium

Similar to run_agentic_loop, this process_approval function is quite large (around 400 lines) and contains a lot of complex logic. While breaking this down would improve maintainability, given that the primary goal of this pull request appears to be focused on achieving correctness and feature parity (as indicated by the PR title/description), large structural refactorings should be deferred to a follow-up task to keep the current PR focused.

References
  1. Defer large structural refactorings, like breaking down a large file, when the primary goal of a pull request is to achieve correctness and feature parity with an existing implementation. The refactoring should be tracked as a follow-up task.

Comment thread .github/workflows/pr-label-scope.yml Outdated
with:
configuration-path: .github/labeler.yml
sync-labels: false # additive only — never remove scope labels
sync-labels: true # remove stale scope labels on force-push / new commits
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prob should be in a separate PR - this labels everything on your PR

Copy link
Copy Markdown
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Import OpenClaw Data (Memory, History, Settings, Credentials)

Well-structured PR with a clean 5-phase import pipeline (settings, identity files, memory documents, conversations, credentials). Discovery is separated from parsing, the importer is stateless, progress reporting is abstracted via a trait, and idempotency is well-handled (checks for existing items before writing, safe to run multiple times). Good unit test coverage for parsing and discovery. However, there are security issues that need fixing.

Blocker: CredentialEntry Derives Debug with Plaintext Values

CredentialEntry has #[derive(Debug)] with a pub value: String field that holds raw API keys and OAuth tokens. Any tracing::debug!("{:?}", config) or accidental dbg!() will dump plaintext secrets to logs. OpenClawConfig also derives Debug and holds Vec<CredentialEntry>, so logging the config leaks all credentials.

The rest of the codebase uses secrecy::SecretString for this purpose. Either:

  • Use SecretString instead of String for the value field
  • Or implement Debug manually to redact the value

Blocker: build_secrets_store Uses NoTls for PostgreSQL

The build_secrets_store function in main.rs creates a NoTls pool, bypassing the TLS support added in commit 1f2e8c3. Users with sslmode=require will silently get an unencrypted connection for the secrets store during import.

Fix: Use connect_from_config or replicate the TLS logic from Store::new().

High: json5 Adds 5 Transitive Dependencies (pest Ecosystem)

The json5 crate pulls in pest, pest_derive, pest_generator, pest_meta, and ucd-trie -- a full parser generator framework. This is a heavy dependency chain. Questions:

  • Does OpenClaw actually use JSON5 features (comments, trailing commas) in config files? If most users have standard JSON, serde_json suffices.
  • If JSON5 is needed, consider serde_jsonrc (lighter, no pest) or document the justification.

Medium

  1. Credentials held as String instead of SecretString during parsing: The OpenClawConfig struct holds all credentials as plaintext for the entire import duration. Read them into SecretString at parse time.

  2. Wizard get_db_handle unexpanded tilde path: The fallback path "~/.ironclaw/ironclaw.db" contains a tilde which std::path::Path does NOT expand. Use default_libsql_path() instead.

  3. No integration test for full pipeline: Per-phase logic is only tested via unit tests. Consider adding at least one integration test with an in-memory database.

What's Good

  • Idempotent: Settings check get_setting before write, identity files check ws.exists(), conversations use deterministic UUIDs via blake3 hash, credentials check store.exists()
  • Partial failure handling: Each phase continues on per-item errors, collecting them in report.errors
  • Safe discovery: Only looks in $HOME for well-known paths, no path traversal risk
  • 10K message safety limit per conversation session -- prevents absurdly large imports
  • Both backends: Uses Arc<dyn Database> + trait abstractions, handles both postgres and libsql feature flags
  • Good test coverage: JSON5 parsing, OAuth parsing, provider mapping, discovery with mock dirs, JSONL parsing, deterministic UUID stability

Low Priority

  • Deterministic UUID manually constructs v4 bits on blake3 -- could use Uuid::new_v5(NAMESPACE_OID, key) since the v5 feature is already enabled
  • Memory file discovery is only one level deep -- recursive scanning might be needed if OpenClaw stores nested files
  • OAuth import has no token format validation

Summary

Fix the CredentialEntry debug leak and the NoTls TLS regression before merge. Justify or replace the json5 dependency. Core import architecture is solid.

jaswinder6991 pushed a commit to jaswinder6991/ironclaw that referenced this pull request Mar 2, 2026
Comprehensive analysis of review feedback on the OpenClaw data import PR,
covering zmanian's security review (2 blockers, 1 high, 3 medium),
ilblackdragon's scope feedback, and Gemini's automated review.

https://claude.ai/code/session_01631kLAGRENE8zjw2Fi5Bfq
@henrypark133 henrypark133 changed the base branch from main to staging March 10, 2026 02:24
@zmanian
Copy link
Copy Markdown
Collaborator

zmanian commented Mar 12, 2026

Closing as superseded by merged #903. The OpenClaw import path is already in staging/mainline, so this older draft is no longer the active merge path.

@zmanian zmanian closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: regular 2-5 merged PRs risk: high Safety, secrets, auth, or critical infrastructure scope: agent Agent core (agent loop, router, scheduler) scope: channel/cli TUI / CLI channel scope: channel/wasm WASM channel runtime scope: channel/web Web gateway channel scope: channel Channel infrastructure scope: ci CI/CD workflows scope: config Configuration scope: db/libsql libSQL / Turso backend scope: db/postgres PostgreSQL backend scope: db Database trait / abstraction scope: dependencies Dependency updates scope: docs Documentation scope: estimation Cost/time estimation scope: evaluation Success evaluation scope: extensions Extension management scope: hooks Git/event hooks scope: llm LLM integration scope: orchestrator Container orchestrator scope: pairing Pairing mode scope: safety Prompt injection defense scope: sandbox Docker sandbox scope: secrets Secrets management scope: setup Onboarding / setup scope: tool/builder Dynamic tool builder scope: tool/builtin Built-in tools scope: tool/mcp MCP client scope: tool/wasm WASM tool sandbox scope: tool Tool infrastructure scope: worker Container worker scope: workspace Persistent memory / workspace size: XL 500+ changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants