{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Identity Agent Template Schema",
  "description": "Configuration schema for the ERC-8004 identity-enabled agent template",
  "type": "object",
  "properties": {
    "AGENT_NAME": {
      "type": "string",
      "description": "Agent name (set automatically from project directory name)",
      "examples": ["my-identity-agent", "verified-agent"]
    },
    "AGENT_DESCRIPTION": {
      "type": "string",
      "description": "Human-readable description of the agent",
      "default": "Verifiable agent with on-chain identity"
    },
    "AGENT_VERSION": {
      "type": "string",
      "description": "Semantic version number for the agent",
      "default": "0.1.0",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "AGENT_DOMAIN": {
      "type": "string",
      "description": "Domain that will host the agent (used for ERC-8004 registration)",
      "default": "agent.example.com",
      "examples": ["agent.example.com", "ai.mydomain.com"]
    },
    "IDENTITY_INCLUDE_A2A": {
      "type": "boolean",
      "description": "Include an A2A-labeled service entry in registration services[]. This metadata label does not make the generated project A2A v1 conformant.",
      "default": false
    },
    "IDENTITY_A2A_ENDPOINT": {
      "type": "string",
      "description": "Endpoint advertised by the A2A-labeled identity service entry",
      "default": "https://agent.example.com/.well-known/agent-card.json"
    },
    "IDENTITY_A2A_VERSION": {
      "type": "string",
      "description": "Version metadata advertised by the A2A-labeled service entry; verify it against the behavior you actually expose",
      "default": "0.3.0"
    },
    "IDENTITY_INCLUDE_WEB": {
      "type": "boolean",
      "description": "Include web service in registration services[]",
      "default": true
    },
    "IDENTITY_WEBSITE": {
      "type": "string",
      "description": "Website service endpoint",
      "default": "https://agent.example.com/",
      "format": "uri"
    },
    "IDENTITY_INCLUDE_OASF": {
      "type": "boolean",
      "description": "Include OASF service in registration services[]",
      "default": false
    },
    "IDENTITY_OASF_ENDPOINT": {
      "type": "string",
      "description": "OASF service endpoint",
      "default": "https://agent.example.com/.well-known/oasf-record.json"
    },
    "IDENTITY_OASF_VERSION": {
      "type": "string",
      "description": "OASF schema/version",
      "default": "0.8.0"
    },
    "IDENTITY_OASF_AUTHORS_JSON": {
      "type": "string",
      "description": "JSON array string for OASF authors",
      "default": "[\"ops@agent.example.com\"]",
      "examples": ["[\"ops@agent.example.com\"]", "[]"]
    },
    "IDENTITY_OASF_SKILLS_JSON": {
      "type": "string",
      "description": "JSON array string for OASF skills",
      "default": "[\"reasoning\"]",
      "examples": ["[\"reasoning\",\"planning\"]", "[]"]
    },
    "IDENTITY_OASF_DOMAINS_JSON": {
      "type": "string",
      "description": "JSON array string for OASF domains",
      "default": "[\"assistant\"]",
      "examples": ["[\"finance\",\"support\"]", "[]"]
    },
    "IDENTITY_OASF_MODULES_JSON": {
      "type": "string",
      "description": "JSON array string for OASF module URIs",
      "default": "[\"https://agent.example.com/modules/core\"]",
      "examples": ["[\"https://agent.example.com/modules/core\"]", "[]"]
    },
    "IDENTITY_OASF_LOCATORS_JSON": {
      "type": "string",
      "description": "JSON array string for OASF locator URIs",
      "default": "[\"https://agent.example.com/.well-known/oasf-record.json\"]",
      "examples": [
        "[\"https://agent.example.com/.well-known/oasf-record.json\"]",
        "[]"
      ]
    },
    "IDENTITY_INCLUDE_TWITTER": {
      "type": "boolean",
      "description": "Include Twitter service in registration services[]",
      "default": false
    },
    "IDENTITY_TWITTER": {
      "type": "string",
      "description": "Twitter handle or URL for service endpoint",
      "default": ""
    },
    "IDENTITY_INCLUDE_EMAIL": {
      "type": "boolean",
      "description": "Include email service in registration services[]",
      "default": false
    },
    "IDENTITY_EMAIL": {
      "type": "string",
      "description": "Support email for service endpoint",
      "default": ""
    },
    "PAYMENTS_ENABLED": {
      "type": "boolean",
      "description": "Whether to configure x402 payment receiving. Disabled by default so free identity projects do not advertise an incomplete payment method.",
      "default": false
    },
    "PAYMENTS_FACILITATOR_URL": {
      "type": "string",
      "description": "x402 facilitator endpoint. The template default is for development; choose and validate a production facilitator before launch.",
      "default": "https://facilitator.daydreams.systems",
      "format": "uri"
    },
    "PAYMENTS_FACILITATOR_AUTH": {
      "type": "string",
      "description": "Optional bearer token for facilitator requests. PAYMENTS_FACILITATOR_AUTH is canonical; DREAMS_AUTH_TOKEN remains a legacy fallback.",
      "default": ""
    },
    "PAYMENTS_NETWORK": {
      "type": "string",
      "description": "Wizard network alias. The generated runtime normalizes supported aliases; use the canonical CAIP-2 identifier when editing production configuration.",
      "default": "base-sepolia",
      "enum": [
        "ethereum",
        "base",
        "base-sepolia",
        "sepolia",
        "solana",
        "solana-devnet"
      ]
    },
    "PAYMENTS_DESTINATION": {
      "type": "string",
      "description": "Payment destination mode",
      "default": "static",
      "enum": ["static", "stripe"]
    },
    "PAYMENTS_RECEIVABLE_ADDRESS": {
      "type": "string",
      "description": "Payment address for static destination mode: an EVM 0x address or Solana Base58 address, depending on the network. It is independent of AGENT_WALLET_PRIVATE_KEY.",
      "default": "",
      "examples": [
        "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0",
        "9yPGxVrYi7C5JLMGjEZhK8qQ4tn7SzMWwQHvz3vGJCKz",
        ""
      ]
    },
    "STRIPE_SECRET_KEY": {
      "type": "string",
      "description": "Stripe secret key used for dynamic destination mode (Base mainnet only)",
      "default": "",
      "examples": ["sk_live_...", "sk_test_...", ""]
    },
    "RPC_URL": {
      "type": "string",
      "description": "Blockchain RPC endpoint URL for on-chain operations",
      "default": "https://sepolia.base.org",
      "format": "uri",
      "examples": [
        "https://eth.llamarpc.com",
        "https://mainnet.base.org",
        "https://sepolia.base.org"
      ]
    },
    "CHAIN_ID": {
      "type": "string",
      "description": "ERC-8004 registry chain ID supported by this release",
      "default": "84532",
      "pattern": "^[1-9][0-9]*$",
      "enum": ["1", "11155111", "84532"],
      "examples": ["1", "11155111", "84532"]
    },
    "IDENTITY_AGENT_ID": {
      "type": "string",
      "description": "Existing ERC-8004 token ID to resolve directly during read-only startup. Leave empty to discover an ID through AGENT_DOMAIN/.well-known/agent-registration.json.",
      "default": "",
      "pattern": "^$|^[0-9]+$",
      "examples": ["42", ""]
    },
    "IDENTITY_AUTO_REGISTER": {
      "type": "boolean",
      "description": "Auto-register the agent on the ERC-8004 identity registry at startup. This submits an on-chain transaction and is disabled by default.",
      "default": false
    },
    "IDENTITY_ALLOW_MAINNET_REGISTRATION": {
      "type": "boolean",
      "description": "Required additional acknowledgement before auto-registration can submit a transaction on Ethereum mainnet (CHAIN_ID=1).",
      "default": false
    },
    "AGENT_WALLET_TYPE": {
      "type": "string",
      "description": "Signer type emitted when identity auto-registration is enabled by the scaffold wizard.",
      "default": "local",
      "enum": ["local"]
    },
    "AGENT_WALLET_PRIVATE_KEY": {
      "type": "string",
      "description": "Server-only local agent-wallet key used to sign ERC-8004 registration transactions when auto-registration is enabled.",
      "default": "",
      "pattern": "^$|^0x[0-9a-fA-F]{64}$",
      "examples": ["0x...", ""]
    },
    "DEVELOPER_WALLET_PRIVATE_KEY": {
      "type": "string",
      "description": "Optional server-only developer-wallet key for application-owned contract interactions. It is separate from the agent identity signer.",
      "default": "",
      "pattern": "^$|^0x[0-9a-fA-F]{64}$",
      "examples": ["0x...", ""]
    }
  },
  "required": [
    "AGENT_NAME",
    "AGENT_DESCRIPTION",
    "AGENT_VERSION",
    "AGENT_DOMAIN",
    "RPC_URL",
    "CHAIN_ID"
  ],
  "allOf": [
    {
      "if": {
        "required": ["PAYMENTS_ENABLED"],
        "properties": {
          "PAYMENTS_ENABLED": { "const": true }
        }
      },
      "then": {
        "required": [
          "PAYMENTS_FACILITATOR_URL",
          "PAYMENTS_NETWORK",
          "PAYMENTS_DESTINATION"
        ]
      }
    },
    {
      "if": {
        "required": ["PAYMENTS_ENABLED", "PAYMENTS_DESTINATION"],
        "properties": {
          "PAYMENTS_ENABLED": { "const": true },
          "PAYMENTS_DESTINATION": { "const": "static" }
        }
      },
      "then": {
        "required": ["PAYMENTS_RECEIVABLE_ADDRESS"],
        "properties": {
          "PAYMENTS_RECEIVABLE_ADDRESS": { "minLength": 1 }
        }
      }
    },
    {
      "if": {
        "required": ["PAYMENTS_ENABLED", "PAYMENTS_DESTINATION"],
        "properties": {
          "PAYMENTS_ENABLED": { "const": true },
          "PAYMENTS_DESTINATION": { "const": "stripe" }
        }
      },
      "then": {
        "required": ["STRIPE_SECRET_KEY"],
        "properties": {
          "STRIPE_SECRET_KEY": { "minLength": 1 }
        }
      }
    },
    {
      "if": {
        "required": ["IDENTITY_AUTO_REGISTER"],
        "properties": {
          "IDENTITY_AUTO_REGISTER": { "const": true }
        }
      },
      "then": {
        "required": ["AGENT_WALLET_TYPE"],
        "properties": {
          "AGENT_WALLET_TYPE": { "const": "local" }
        },
        "anyOf": [
          {
            "required": ["AGENT_WALLET_PRIVATE_KEY"],
            "properties": {
              "AGENT_WALLET_PRIVATE_KEY": {
                "pattern": "^0x[0-9a-fA-F]{64}$"
              }
            }
          },
          {
            "required": ["DEVELOPER_WALLET_PRIVATE_KEY"],
            "properties": {
              "DEVELOPER_WALLET_PRIVATE_KEY": {
                "pattern": "^0x[0-9a-fA-F]{64}$"
              }
            }
          }
        ]
      }
    },
    {
      "if": {
        "required": ["IDENTITY_AUTO_REGISTER", "CHAIN_ID"],
        "properties": {
          "IDENTITY_AUTO_REGISTER": { "const": true },
          "CHAIN_ID": { "const": "1" }
        }
      },
      "then": {
        "required": ["IDENTITY_ALLOW_MAINNET_REGISTRATION"],
        "properties": {
          "IDENTITY_ALLOW_MAINNET_REGISTRATION": { "const": true }
        }
      }
    }
  ],
  "notes": "The default project uses Base Sepolia (CHAIN_ID=84532), leaves IDENTITY_AGENT_ID empty for bounded domain-document discovery, keeps IDENTITY_AUTO_REGISTER=false, and sets PAYMENTS_ENABLED=false. The wizard therefore emits neither signer secrets nor an incomplete payment configuration, and startup cannot perform an on-chain write. Set IDENTITY_AGENT_ID to resolve a known ERC-8004 token directly. Enabling registration emits AGENT_WALLET_TYPE=local and prompts for AGENT_WALLET_PRIVATE_KEY; a separate DEVELOPER_WALLET_PRIVATE_KEY remains an advanced manual configuration. Local signers are bound to the same RPC_URL and CHAIN_ID used for identity registry reads. Ethereum mainnet (CHAIN_ID=1) additionally requires IDENTITY_ALLOW_MAINNET_REGISTRATION=true and a successful signer-address/native-gas-balance preflight after the chain, registry, domain, agent URI, and transaction policy have been reviewed. Supported registry chains are Ethereum, Ethereum Sepolia, and Base Sepolia. Payment receiving is a separate opt-in concern."
}
