Skip to content

Investigate Re-implementation of Auto-Migration via OpenClaw Native Secrets System #34

Description

@KHAEntertainment

Background

The original automated migration system (clawvault openclaw migrate --apply) was deprecated and disabled because OpenClaw did not support ${ENV_VAR} placeholders in auth-profiles.json. Running --apply would replace plaintext keys with placeholder strings that OpenClaw treated as literal credential values, causing complete authentication failure.

This issue tracks investigating whether OpenClaw's native secrets management system (added since v0.2.0) now enables a safe, working auto-migration path — potentially via the exec source type that ClawVault already implements.


What Was Previously Attempted

v0.0.x / v0.1.0 migration approach (deprecated)

The clawvault openclaw migrate --apply command:

  1. Scanned all ~/.openclaw/agents/<agentId>/agent/auth-profiles.json files
  2. Extracted plaintext API keys and OAuth tokens
  3. Stored them in the ClawVault keyring
  4. Rewrote auth-profiles.json with ${ENV_VAR} placeholder strings:
    {
      "profiles": {
        "openai:default": {
          "type": "api_key",
          "key": "\${OPENCLAW_OPENAI_OPENAI_DEFAULT_KEY}"
        }
      }
    }
  5. Expected OpenClaw to expand those placeholders at runtime

Why it failed

  • OpenClaw did not expand ${ENV_VAR} in auth-profiles.json — it treated the placeholder string as the literal credential value
  • Authentication failed silently because OpenClaw sent the placeholder string instead of the actual key
  • OAuth tokens were especially brittle — they could be partially validated/parsed before env expansion occurred, causing unpredictable failures
  • Multi-agent setups had multiple auth-profiles.json files — a failed migration could break all of them at once

What's Changed: OpenClaw Native Secrets System

OpenClaw now has a built-in secrets management system that is directly relevant to this investigation:

openclaw secrets configure (interactive)

openclaw secrets configure --agent main

Interactive wizard that scans plaintext secrets, maps them to SecretRefs, and optionally applies with preflight validation.

openclaw secrets apply (plan executor)

openclaw secrets apply --from /tmp/plan.json --dry-run
openclaw secrets apply --from /tmp/plan.json
  • Validates all target paths before writing
  • One-way scrub: replaces plaintext with refs
  • Requires agentId for all auth-profiles.json targets
  • Supports auth-profiles.api_key.key target type

SecretRef source: "exec" (critical for ClawVault)

{
  "source": "exec",
  "provider": "vault",
  "id": "providers/openai/apiKey"
}

keyRef/tokenRef in auth-profiles.json

From secrets-plan-contract.md:

Ref-only auth-profiles.json entries (keyRef/tokenRef) are included in runtime resolution and audit coverage.

secrets.providers exec config in openclaw.json

{
  "secrets": {
    "providers": {
      "clawvault": {
        "source": "exec",
        "command": ["/absolute/path/to/clawvault", "resolve"],
        "jsonOnly": true,
        "passEnv": ["PATH"]
      }
    }
  }
}

This is exactly the integration path ClawVault v0.2.0's exec-provider was built for.


Investigation Tasks

  • Verify auth-profiles.json supports keyRef/tokenRef fields (exact schema)
  • Verify source: "exec" works for auth-profiles.json refs (test with a known key)
  • Identify which OpenClaw version introduced these features
  • Assess OAuth token handling — confirm tokenRef works end-to-end
  • Verify ClawVault's clawvault resolve produces the exact JSON format required

Proposed Re-implementation Plan (conditional on investigation)

Phase 1: Generate OpenClaw-compatible plan files

Replace ${ENV_VAR} rewriting with plan file generation:

  1. Run clawvault openclaw migrate --verbose as dry-run (existing)
  2. Generate a plan.json compatible with openclaw secrets apply
  3. Guide user to run openclaw secrets apply
  4. ClawVault acts as the exec backend; OpenClaw handles the auth-profiles.json writes

Phase 2: clawvault openclaw setup command

Auto-configure secrets.providers.clawvault in openclaw.json so users don't have to edit it manually.

Phase 3: Deprecate old --apply path

Once Phase 1 is validated, mark clawvault openclaw migrate --apply as superseded by openclaw secrets configure + ClawVault exec provider workflow.


Priority

Medium — existing workaround works but is not migration-friendly for new users with existing plaintext auth-profiles.json setups.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions