{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-package-manifest-schema.json",
  "title": "PackageManifest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antfly-packages-api-openapi.yml#/components/schemas/PackageManifest",
  "type": "object",
  "properties": {
    "manifest_api_version": {
      "type": "string",
      "enum": [
        "extensions/v1"
      ]
    },
    "name": {
      "$ref": "#/$defs/ExtensionIdentifier"
    },
    "version": {
      "type": "string"
    },
    "kind": {
      "$ref": "#/$defs/PackageKind"
    },
    "description": {
      "type": "string"
    },
    "digest": {
      "type": "string"
    },
    "antfly_min_version": {
      "type": "string"
    },
    "antfly_max_version": {
      "type": "string"
    },
    "trusted": {
      "type": "boolean",
      "default": false
    },
    "relocatable": {
      "type": "boolean",
      "default": false
    },
    "capabilities_requested": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Capability"
      }
    },
    "dependencies": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PackageDependency"
      }
    },
    "artifacts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PackageArtifact"
      }
    },
    "install": {
      "$ref": "#/$defs/InstallManifest"
    },
    "updates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/UpdateManifestRef"
      }
    }
  },
  "required": [
    "manifest_api_version",
    "name",
    "version",
    "kind",
    "digest",
    "install"
  ],
  "$defs": {
    "Capability": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/$defs/CapabilityName"
        },
        "scope": {
          "type": "string"
        }
      },
      "required": [
        "name"
      ]
    },
    "CapabilityName": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.:-]+$",
      "description": "Capability identifier. Capability names may use colon-delimited namespaces such as read:table."
    },
    "DataShapeDecl": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/$defs/ExtensionIdentifier"
        },
        "kind": {
          "$ref": "#/$defs/DataShapeKind"
        },
        "version": {
          "type": "string",
          "default": "1"
        },
        "schema_json": {
          "type": "string",
          "description": "JSON object encoded as a string until the public shape language is finalized.",
          "default": "{}"
        }
      },
      "required": [
        "name",
        "kind"
      ]
    },
    "DataShapeKind": {
      "type": "string",
      "enum": [
        "document",
        "row",
        "generated_artifact",
        "extension_relation",
        "endpoint_schema",
        "tool_schema"
      ]
    },
    "ExtensionIdentifier": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]+$",
      "description": "Path-safe extension or package identifier."
    },
    "ExtensionObjectDecl": {
      "type": "object",
      "properties": {
        "kind": {
          "$ref": "#/$defs/ExtensionObjectKind"
        },
        "name": {
          "$ref": "#/$defs/ExtensionIdentifier"
        },
        "shape": {
          "type": "string"
        },
        "table_name": {
          "type": "string"
        },
        "config_json": {
          "type": "string",
          "default": "{}"
        }
      },
      "required": [
        "kind",
        "name"
      ]
    },
    "ExtensionObjectKind": {
      "type": "string",
      "enum": [
        "data_shape",
        "table_schema",
        "extension_relation",
        "generated_artifact",
        "index",
        "enrichment",
        "resolver",
        "mcp_tool",
        "skill",
        "agent",
        "query_function",
        "api_endpoint",
        "a2a_agent",
        "auth_policy",
        "workflow",
        "maintenance_task",
        "provider_config",
        "text_analyzer",
        "text_tokenizer",
        "provider_adapter",
        "connector",
        "index_backend"
      ]
    },
    "ExtensionScopeKind": {
      "type": "string",
      "enum": [
        "cluster",
        "table",
        "embedded_db"
      ]
    },
    "InstallManifest": {
      "type": "object",
      "properties": {
        "scopes_supported": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ExtensionScopeKind"
          }
        },
        "shapes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DataShapeDecl"
          }
        },
        "objects": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ExtensionObjectDecl"
          }
        },
        "runtimes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RuntimeDecl"
          }
        },
        "config_schema_json": {
          "type": "string",
          "default": "{}"
        }
      },
      "required": [
        "scopes_supported"
      ]
    },
    "PackageArtifact": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "manifest",
            "wasm",
            "native_library",
            "asset"
          ]
        },
        "path": {
          "type": "string"
        },
        "digest": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "path"
      ]
    },
    "PackageDependency": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/$defs/ExtensionIdentifier"
        },
        "version_requirement": {
          "type": "string"
        },
        "optional": {
          "type": "boolean",
          "default": false
        }
      },
      "required": [
        "name"
      ]
    },
    "PackageKind": {
      "type": "string",
      "enum": [
        "extension"
      ]
    },
    "RuntimeDecl": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/$defs/ExtensionIdentifier"
        },
        "mode": {
          "type": "string",
          "enum": [
            "manifest_only",
            "antfly_api_template",
            "workflow",
            "wasm",
            "sidecar",
            "native"
          ],
          "default": "manifest_only"
        },
        "artifact": {
          "type": "string"
        },
        "config_json": {
          "type": "string",
          "default": "{}"
        }
      },
      "required": [
        "name"
      ]
    },
    "UpdateManifestRef": {
      "type": "object",
      "properties": {
        "from_version": {
          "type": "string"
        },
        "to_version": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "digest": {
          "type": "string"
        }
      },
      "required": [
        "from_version",
        "to_version",
        "path"
      ]
    }
  }
}