{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aumos.app/spec/amp/1/manager-package-manifest.schema.json",
  "title": "manager-package-manifest",
  "type": "object",
  "properties": {
    "manifestVersion": {
      "type": "number",
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*(?:\\/[a-z0-9][a-z0-9-]*)?$"
    },
    "publisher": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z-.]+)?(?:\\+[0-9A-Za-z-.]+)?$"
    },
    "description": {
      "type": "string"
    },
    "readme": {
      "type": "string",
      "minLength": 1
    },
    "prompt": {
      "type": "string",
      "minLength": 1
    },
    "schedule": {
      "minItems": 1,
      "maxItems": 8,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "cron": {
            "type": "string",
            "minLength": 1
          },
          "timeZone": {
            "type": "string",
            "minLength": 1
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          }
        },
        "required": ["cron", "timeZone"],
        "additionalProperties": false
      }
    },
    "translations": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "managers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "description": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": ["id", "description"],
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    },
    "runtimes": {
      "default": ["claude", "codex"],
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["claude", "codex"]
      }
    },
    "credentials": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string"
          }
        },
        "required": ["name"],
        "additionalProperties": false
      }
    },
    "license": {
      "type": "string"
    },
    "provenance": {
      "type": "object",
      "properties": {
        "sourceRepo": {
          "type": "string",
          "format": "uri"
        },
        "commit": {
          "type": "string",
          "pattern": "^[0-9a-f]{40}$"
        },
        "license": {
          "type": "string",
          "minLength": 1
        },
        "licenseHolder": {
          "type": "string",
          "minLength": 1
        },
        "notice": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": ["sourceRepo", "commit", "license", "licenseHolder", "notice"],
      "additionalProperties": false
    },
    "homepage": {
      "type": "string",
      "format": "uri"
    },
    "engines": {
      "type": "object",
      "properties": {
        "aumos": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": ["aumos"],
      "additionalProperties": false
    },
    "ampVersion": {
      "type": "number",
      "const": 1
    },
    "contributes": {
      "type": "object",
      "properties": {
        "managers": {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z0-9][a-z0-9-]*(?:\\/[a-z0-9][a-z0-9-]*)?$"
              },
              "name": {
                "type": "string",
                "minLength": 1
              },
              "description": {
                "type": "string"
              },
              "tasks": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": ["PORTFOLIO_REVIEW", "ASSET_REVIEW", "THESIS_REVIEW", "EVENT_REVIEW"]
                }
              },
              "assetClasses": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": ["equity", "etf", "crypto", "cash"]
                }
              },
              "markets": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Z0-9]{1,12}$",
                  "description": "MIC-style market identifier, e.g. XNAS"
                }
              }
            },
            "required": ["id", "name", "tasks", "assetClasses", "markets"],
            "additionalProperties": false
          }
        }
      },
      "required": ["managers"],
      "additionalProperties": false
    },
    "capabilities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "portfolio:read",
              "thesis:read",
              "evidence:read",
              "market:read",
              "skill:invoke",
              "manager-memory:read",
              "manager-memory:write",
              "brief:read",
              "brief:write",
              "source:passthrough",
              "connection:passthrough",
              "source-cache:read",
              "source-cache:write",
              "observation:file",
              "research:prepare",
              "research:read"
            ]
          },
          "reason": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "connectors": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "required": ["kind"],
        "additionalProperties": false
      }
    },
    "requires": {
      "type": "object",
      "properties": {
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "optionalSkills": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "required": ["skills"],
      "additionalProperties": false
    },
    "network": {
      "default": {
        "mode": "deny"
      },
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "deny"
            }
          },
          "required": ["mode"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "allowlist"
            },
            "hosts": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "required": ["mode", "hosts"],
          "additionalProperties": false
        }
      ]
    },
    "config": {
      "type": "object",
      "properties": {
        "schema": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": ["schema"],
      "additionalProperties": false
    },
    "memory": {
      "type": "object",
      "properties": {
        "persistent": {
          "type": "boolean"
        }
      },
      "required": ["persistent"],
      "additionalProperties": false
    },
    "recipes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]*$"
          },
          "version": {
            "type": "string",
            "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z-.]+)?(?:\\+[0-9A-Za-z-.]+)?$"
          },
          "entrypoint": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string"
          }
        },
        "required": ["id", "version", "entrypoint"],
        "additionalProperties": false
      }
    },
    "validates": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "character": {
      "type": "object",
      "properties": {
        "generator": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "seed": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[\\x20-\\x7E]+$"
        }
      },
      "required": ["generator", "seed"],
      "additionalProperties": false
    }
  },
  "required": [
    "manifestVersion",
    "id",
    "publisher",
    "name",
    "version",
    "engines",
    "ampVersion",
    "contributes",
    "capabilities",
    "requires"
  ]
}
