{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://evidence.contact/agent-wallet.schema.json",
  "title": "402Mob agent wallet bootstrap recipe",
  "type": "object",
  "required": [
    "name",
    "version",
    "package",
    "npmPublishedVersion",
    "guide",
    "download",
    "sha256",
    "runtime",
    "bootstrap",
    "statusCommand",
    "statusMeaning",
    "creationPolicy",
    "adapterTemplate",
    "storage",
    "recovery",
    "nextSteps",
    "boundaries",
    "preflight",
    "pythonBootstrap",
    "validation"
  ],
  "properties": {
    "localMcp": {
      "type": "object",
      "properties": {
        "guide": {
          "type": "string",
          "format": "uri"
        },
        "manifest": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "guide",
        "manifest"
      ],
      "additionalProperties": false
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
    },
    "npmPublishedVersion": {
      "type": "string",
      "minLength": 1
    },
    "guide": {
      "type": "string",
      "minLength": 1
    },
    "download": {
      "type": "string",
      "minLength": 1
    },
    "statusCommand": {
      "type": "string",
      "minLength": 1
    },
    "statusMeaning": {
      "type": "string",
      "minLength": 1
    },
    "creationPolicy": {
      "type": "string",
      "minLength": 1
    },
    "adapterTemplate": {
      "type": "string",
      "minLength": 1
    },
    "package": {
      "const": "402mob-agent-wallet"
    },
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "runtime": {
      "type": "object",
      "required": [
        "node",
        "platforms",
        "network",
        "storage"
      ],
      "properties": {
        "node": {
          "type": "string"
        },
        "platforms": {
          "type": "array",
          "minItems": 1,
          "items": {
            "enum": [
              "linux",
              "darwin"
            ]
          }
        },
        "network": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          }
        },
        "storage": {
          "type": "string"
        }
      }
    },
    "bootstrap": {
      "type": "object",
      "required": [
        "command",
        "proof",
        "fundingRequired",
        "browserRequired",
        "operatorTokenRequired",
        "stdout",
        "success",
        "invocation"
      ],
      "properties": {
        "command": {
          "type": "string",
          "minLength": 1
        },
        "proof": {
          "type": "string"
        },
        "fundingRequired": {
          "const": false
        },
        "browserRequired": {
          "const": false
        },
        "operatorTokenRequired": {
          "const": false
        },
        "stdout": {
          "type": "string"
        },
        "success": {
          "type": "array",
          "minItems": 3,
          "items": {
            "type": "string"
          }
        },
        "invocation": {
          "type": "object",
          "required": [
            "executable",
            "args",
            "substitutions"
          ],
          "properties": {
            "executable": {
              "const": "npm"
            },
            "args": {
              "type": "array",
              "minItems": 10,
              "items": {
                "type": "string"
              }
            },
            "substitutions": {
              "type": "object",
              "required": [
                "<absolute-private-directory>",
                "<merchant-name>"
              ],
              "additionalProperties": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "storage": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "string"
      }
    },
    "recovery": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "string"
      }
    },
    "nextSteps": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    },
    "boundaries": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    },
    "preflight": {
      "type": "object",
      "required": [
        "checks",
        "onMissingCapability",
        "existingWalletGuide"
      ],
      "properties": {
        "appliesTo": {
          "type": "string"
        },
        "checks": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "onMissingCapability": {
          "type": "string"
        },
        "existingWalletGuide": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "pythonBootstrap": {
      "type": "object",
      "properties": {
        "package": {
          "const": "402mob-agent-wallet"
        },
        "version": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
        },
        "guide": {
          "type": "string",
          "format": "uri"
        },
        "download": {
          "type": "string",
          "format": "uri"
        },
        "runtime": {
          "type": "string"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "pypiPublished": {
          "type": "boolean"
        },
        "install": {
          "type": "string"
        },
        "command": {
          "type": "string"
        },
        "invocation": {
          "type": "object",
          "properties": {
            "executable": {
              "const": "<python-executable>"
            },
            "args": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 7
            },
            "substitutions": {
              "type": "object",
              "required": [
                "<python-executable>",
                "<absolute-private-python-wallet-directory>",
                "<merchant-name>"
              ],
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          "required": [
            "executable",
            "args",
            "substitutions"
          ],
          "additionalProperties": false
        },
        "preflight": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "validation": {
          "type": "object",
          "properties": {
            "localHttpEnrollmentVerified": {
              "type": "boolean"
            },
            "registryInstallVerified": {
              "type": "boolean"
            },
            "freshProductionEnrollmentVerified": {
              "type": "boolean"
            },
            "livePurchaseVerified": {
              "type": "boolean"
            },
            "scope": {
              "type": "string"
            }
          },
          "required": [
            "localHttpEnrollmentVerified",
            "registryInstallVerified",
            "freshProductionEnrollmentVerified",
            "livePurchaseVerified",
            "scope"
          ],
          "additionalProperties": false
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "package",
        "version",
        "guide",
        "download",
        "runtime",
        "sha256",
        "pypiPublished",
        "install",
        "command",
        "invocation",
        "preflight",
        "validation",
        "note"
      ],
      "additionalProperties": false
    },
    "validation": {
      "type": "object",
      "required": [
        "localHttpEnrollment",
        "registryInstall",
        "freshProductionEnrollmentVerified",
        "scope"
      ],
      "properties": {
        "localHttpEnrollment": {
          "type": "string"
        },
        "registryInstall": {
          "type": "string"
        },
        "freshProductionEnrollmentVerified": {
          "type": "boolean"
        },
        "scope": {
          "type": "string"
        },
        "livePurchaseVerified": {
          "type": "boolean"
        },
        "livePurchaseEvidence": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  }
}
