# `Snodo.Extensions.Tasks.Task`
[🔗](https://github.com/joshrotenberg/snodo/blob/v0.1.0/extensions/tasks/lib/snodo/extensions/tasks/task.ex#L1)

Application-facing task state for the `io.modelcontextprotocol/tasks` extension.

The struct contains a small amount of private bookkeeping (`used_input_keys`)
that never appears on the wire. State changes are explicit and terminal states
are immutable, which lets an atomic store resolve cancellation/completion races.

# `status`

```elixir
@type status() :: :working | :input_required | :completed | :failed | :cancelled
```

# `t`

```elixir
@type t() :: %Snodo.Extensions.Tasks.Task{
  created_at: String.t(),
  error: map() | nil,
  id: String.t(),
  input_requests: map(),
  last_updated_at: String.t(),
  poll_interval_ms: pos_integer() | nil,
  result: map() | nil,
  status: status(),
  status_message: String.t() | nil,
  ttl_ms: pos_integer() | nil,
  used_input_keys: MapSet.t(String.t())
}
```

# `add_input`

```elixir
@spec add_input(t(), String.t(), map(), String.t()) ::
  {:ok, t()}
  | {:error, :duplicate_input_key | :terminal | :invalid_input_request}
```

# `cancel`

```elixir
@spec cancel(t(), String.t(), String.t() | nil) :: {:ok, t()} | {:terminal, t()}
```

# `complete`

```elixir
@spec complete(t(), map(), String.t()) :: {:ok, t()} | {:terminal, t()}
```

# `creation_result`

```elixir
@spec creation_result(t()) :: map()
```

Returns the flat SEP-2663 creation result, without detailed payload fields.

# `detailed_result`

```elixir
@spec detailed_result(t()) :: map()
```

Returns the flat status-specific `tasks/get` result.

# `fail`

```elixir
@spec fail(t(), map(), String.t(), String.t() | nil) :: {:ok, t()} | {:terminal, t()}
```

# `fulfill_inputs`

```elixir
@spec fulfill_inputs(t(), [String.t()], String.t()) :: {:ok, t(), [String.t()]}
```

# `new!`

```elixir
@spec new!(keyword()) :: t()
```

# `notification_params`

```elixir
@spec notification_params(t()) :: map()
```

Returns the complete status-specific payload for `notifications/tasks`.

# `terminal?`

```elixir
@spec terminal?(t()) :: boolean()
```

# `timestamp`

```elixir
@spec timestamp() :: String.t()
```

Returns an RFC 3339/ISO 8601 UTC timestamp at millisecond precision.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
