Check enumerate counter for custom labels

#enumeratecounters

I want to create a custom enumerate environment specifically for algorithms:
The First \item should have the label Input:
The second \item should have the label Output:
From then on, have the standard (\arabic*) counter.
This is, what it should look like:

enter image description here

I got the counter offset to work, but I can't figure out how to check the counter for the two first items.
How can I do that?
I already tried all kinds of combinations of algo, algoi, thealgo, \thealgo and \value{...} etc., all if which result in the following:

enter image description here

MWE:

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath}
\usepackage{ifthen}
\usepackage[shortlabels]{enumitem}

\newcommand{\step}{
    \ifthenelse{ \equal{\value{algoi}}{-2} }
        { \item[Input: ]}
        { \ifthenelse { \equal{\value{algoi}}{-1} }
            {\item[Output: ]}
            {\item }
        }
    }

\newenvironment{algo}{\begin{enumerate}[label=(\arabic*), start = -1]}{\end{enumerate}}

\begin{document}
    \begin{algo}
        \step This is the input.
        \step This is the output.
        \step This is step 1.
        \step This is step 2.
    \end{algo}
\end{document}

This code will throw the error message You can't use `\relax' after \the. \step twice for each \step.

Best Answer

I'd avoid \ifthenelse. Here's a way that also allows to have automatic good alignment to the left margin.

\documentclass[a4paper,12pt]{article}
\usepackage{showframe}

\usepackage{amsmath}
\usepackage{enumitem}

\ExplSyntaxOn
\NewExpandableDocumentCommand{\steplabel}{m}
 {
  \xoriun_steplabel_std:n { #1 }
 }
\NewExpandableDocumentCommand{\steplabelref}{m}
 {
  \xoriun_steplabel_ref:n { #1 }
 }

\cs_new:Nn \xoriun_steplabel_std:n
 {
  \__xoriun_steplabel:nnn { ( } { ) } { #1 }
 }
\cs_new:Nn \xoriun_steplabel_ref:n
 {
  \__xoriun_steplabel:nnn { } { } { #1 }
 }
\cs_new:Nn \__xoriun_steplabel:nnn
 {
  \int_case:nnF { \value{#3} }
   {
    {-1}{Input:}
    {0}{Output:}
   }
   {#1\arabic{#3}#2}
 }
\AddEnumerateCounter{\steplabel}{\xoriun_steplabel_std:n}{Output:}
\AddEnumerateCounter{\steplabelref}{\xoriun_steplabel_ref:n}{Output:}
\ExplSyntaxOff

\let\step\item

\newenvironment{algo}
 {\begin{enumerate}[label=\steplabel*,ref=\steplabelref*,start=-1,leftmargin=*]}
 {\end{enumerate}}

\begin{document}
    \begin{algo}
        \step This is the input.
        \step This is the output.
        \step This is step 1.\label{test}
        \step This is step 2.
    \end{algo}

\ref{test}
\end{document}

I define two new counter representations, namely \steplabel and \steplabelref, the latter to avoid parentheses around the step number. Next the two representations are registered with enumitem.

enter image description here

If you want parentheses around the step numbers in cross-references, just remove the ref= key.