"""Reference manifest for new platform app scaffolds."""

from bridge_platform.apps.contracts import (
    ActionContract,
    AgentCapabilityContract,
    AppManifest,
    CredentialField,
    EventContract,
)


REFERENCE_MANIFEST = AppManifest(
    app_id="example_app",
    display_name="Example App",
    app_version="1.0.0",
    description="Reference only; copy and adapt when creating a new app.",
    credentials=(
        CredentialField("api_token", "API token", help_text="Issued by the external provider."),
    ),
    actions={
        "health_v1": ActionContract(
            capability="platform.health",
            description="Report app runtime health without calling external services.",
            output_schema={"type": "object", "required": ["healthy"]},
        ),
        "test_connection_v1": ActionContract(
            capability="platform.credentials.test",
            description="Validate configured credentials against the provider.",
            required_credentials=("api_token",),
            output_schema={"type": "object", "required": ["connected", "provider"]},
            errors=("credential_not_configured", "provider_connection_failed"),
        ),
        "lookup_v1": ActionContract(
            capability="example.records.lookup",
            description="Return one normalized record.",
            input_schema={"type": "object", "required": ["record_id"]},
            output_schema={"type": "object", "required": ["record"]},
            data_classification="business",
            errors=("invalid_input", "record_not_found", "provider_unavailable"),
            agent=AgentCapabilityContract(
                exposed=True,
                title="Look up an example record",
                summary="Retrieve one normalized example record by its identifier.",
                domains=("example_records",),
                use_when=("The user provides an exact example record identifier.",),
                do_not_use_when=("The user asks to modify or delete a record.",),
                risk_category="read",
                risk_level="low",
                confirmation="never",
                required_permissions=("example.records.read",),
            ),
        ),
    },
    outbound_capabilities=("another_app:another.records.lookup",),
    publishes=(
        EventContract("example.record.updated", {"type": "object", "required": ["record_id"]}),
    ),
)
