Sign inSign up

sbx/copilot-kit:latest

Manifest digest

sha256:6b8f55c4c30a6d3095ec237c94c0b2c3933ece5d0ac24239f3d1d54fb3a0124a

Last pushed

1 day by sbx

Type

Sandbox Kit

Manifest digest

sha256:6b8f55c4c30a6d3095ec237c94c0b2c3933ece5d0ac24239f3d1d54fb3a0124a

yaml
schemaVersion: "2"
kind: sandbox
name: copilot
version: 1.0.0
displayName: GitHub Copilot
description: GitHub Copilot CLI, GitHub's agentic coding CLI.
sandbox:
    image: docker.io/sbx/copilot-image:latest
    entrypoint:
        - copilot
    command:
        default:
            - --yolo
        interactive:
            - --yolo
agentInstructions:
    filename: AGENTS.md
permissions:
    network:
        allow:
            - api.business.githubcopilot.com
            - api.enterprise.githubcopilot.com
            - api.github.com
            - api.githubcopilot.com
            - api.individual.githubcopilot.com
            - copilot.github.com
            - github.com
            - archive.ubuntu.com
            - security.ubuntu.com
            - ports.ubuntu.com
            - download.docker.com
credentials:
    - service: github
      apiKey:
        name: GH_TOKEN
        inject:
            - domain: api.github.com
              header: Authorization
              format: Bearer %s
            - domain: github.com
              header: Authorization
              format: Bearer %s
    - service: copilot
      apiKey:
        name: COPILOT_GITHUB_TOKEN
        inject:
            - domain: api.business.githubcopilot.com
              header: Authorization
              format: Bearer %s
            - domain: api.enterprise.githubcopilot.com
              header: Authorization
              format: Bearer %s
            - domain: api.githubcopilot.com
              header: Authorization
              format: Bearer %s
            - domain: api.individual.githubcopilot.com
              header: Authorization
              format: Bearer %s
            - domain: copilot.github.com
              header: Authorization
              format: Bearer %s
setup:
    install:
        - command: mkdir -p /home/agent/.copilot && chown agent:agent /home/agent/.copilot
          user: "0"
          description: Ensure .copilot is owned by agent before bind mounts and initFiles run
    startup:
        - command:
            - sh
            - -c
            - command -v apt-get > /dev/null 2>&1 && (apt-get update -qq -y > /dev/null 2>&1 || true) &
          user: root
          description: Update apt package cache in background
        - command:
            - sh
            - -c
            - |
              set -e
              [ -n "$MCP_GATEWAY_URL" ] || exit 0
              cfg="$HOME/.copilot/mcp-config.json"
              dir=$(dirname "$cfg")
              mkdir -p "$dir"
              gateway=$(cat <<EOF
              {
                "mcpServers": {
                  "mcp-gateway": {
                    "type": "http",
                    "url": "$MCP_GATEWAY_URL",
                    "headers": {
                      "Authorization": "Bearer $MCP_SENTINEL_TOKEN_NAME"
                    },
                    "tools": ["*"]
                  }
                }
              }
              EOF
              )
              # Two overlapping starts would read-modify-write the same file.
              exec 9>>"$dir/.mcp-config.lock"
              flock 9
              # mv would nest the config inside a directory here and still exit 0.
              if [ -e "$cfg" ] && [ ! -f "$cfg" ]; then
                echo "mcp-config.json is not a regular file; leaving the MCP gateway unregistered" >&2
                exit 0
              fi
              if ! merged=$({ if [ -s "$cfg" ]; then cat "$cfg"; else echo '{}'; fi; printf '%s\n' "$gateway"; } | jq -s '
                  if length != 2 or (.[0] | type) != "object" or ((.[0].mcpServers // {}) | type) != "object" then
                    error("mcp-config.json must hold one JSON object whose mcpServers is an object")
                  else
                    .[0] + {mcpServers: ((.[0].mcpServers // {}) + .[1].mcpServers)}
                  end'); then
                echo "mcp-config.json is not readable as JSON; leaving the MCP gateway unregistered" >&2
                exit 0
              fi
              # The temp name is unpredictable, so a stale or crashed leftover is never installed.
              tmp=$(mktemp "$dir/mcp-config.json.XXXXXX")
              trap 'rm -f "$tmp"' EXIT
              printf '%s\n' "$merged" > "$tmp"
              mv -f "$tmp" "$cfg"
          user: agent
          description: Register the sandbox MCP gateway in ~/.copilot/mcp-config.json
    files:
        - path: /home/agent/.copilot/config.json
          content: '{"trusted_folders": ["${WORKDIR}"]}'
          onlyIfMissing: true
          description: Copilot config with trusted workspace folder