# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: CoPaw Personal Assistant
spec:
    description: |
        CoPaw is a self-hosted personal assistant powered by AgentScope.
        This template is optimized for quick and stable deployment on Zeabur.
    coverImage: https://img.alicdn.com/imgextra/i1/O1CN01nTg6w21NqT5qFKH1u_!!6000000001621-55-tps-550-550.svg
    icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/python.svg
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: Public domain used to access your CoPaw instance
    tags:
        - AI Assistant
        - Agent
        - Self-hosted
        - Automation
    readme: |
        # CoPaw Personal Assistant

        CoPaw is a personal assistant product powered by AgentScope.
        This template focuses on fast self-hosted deployment with persistent data storage.

        ## What this template does

        - Deploys one CoPaw service on Zeabur
        - Exposes a web console on port 8088
        - Persists CoPaw data in `/data`
        - Initializes CoPaw automatically on first startup

        ## Required variable

        | Variable | Description |
        |----------|-------------|
        | `PUBLIC_DOMAIN` | Domain used to access your CoPaw web console |

        ## First-time setup after deployment

        1. Open your CoPaw URL (Web Console)
        2. Go to **Models** in the Console
        3. Configure provider, API key, and model
        4. Start chatting and configure channels as needed

        ## Documentation

        - Quickstart: http://copaw.agentscope.io/docs/quickstart
    services:
        - name: copaw
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/python.svg
          template: PREBUILT_V2
          spec:
            id: copaw
            source:
                image: python:3.12-slim-bookworm
                command:
                    - /bin/sh
                    - -c
                    - |
                      set -eu

                      export COPAW_WORKING_DIR="${COPAW_WORKING_DIR:-/data}"

                      echo "Installing CoPaw..."
                      pip install --no-cache-dir copaw

                      if [ ! -f "${COPAW_WORKING_DIR}/config.json" ]; then
                        echo "No existing config found. Running first-time initialization..."
                        copaw init --defaults
                      else
                        echo "Existing config found. Skipping initialization."
                      fi

                      echo "Starting CoPaw on 0.0.0.0:8088..."
                      exec copaw app --host 0.0.0.0 --port 8088
            ports:
                - id: web
                  port: 8088
                  type: HTTP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: Web Console
                  content: ${ZEABUR_WEB_URL}
                - title: Quickstart Docs
                  content: http://copaw.agentscope.io/docs/quickstart
                - title: First-Time Setup
                  content: Open Console -> Models, then configure provider, API key, and model.
            env:
                COPAW_WORKING_DIR:
                    default: /data
                    expose: false
                PYTHONUNBUFFERED:
                    default: "1"
                    expose: false
                TZ:
                    default: Asia/Shanghai
                    expose: false
          domainKey: PUBLIC_DOMAIN
