# `CliSubprocessCore.Session`
[🔗](https://github.com/nshkrdotcom/cli_subprocess_core/blob/v0.1.0/lib/cli_subprocess_core/session.ex#L1)

Common CLI session runtime above the raw transport layer.

# `subscriber_info`

```elixir
@type subscriber_info() :: %{monitor_ref: reference(), tag: :legacy | reference()}
```

# `t`

```elixir
@type t() :: %CliSubprocessCore.Session{
  invocation: CliSubprocessCore.Command.t(),
  options: CliSubprocessCore.Session.Options.t(),
  parser_state: term(),
  profile: module(),
  provider: atom(),
  runtime: CliSubprocessCore.Runtime.t(),
  subscribers: %{optional(pid()) =&gt; subscriber_info()},
  transport_pid: pid(),
  transport_ref: reference()
}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

```elixir
@spec close(pid()) :: :ok
```

Stops the session and closes the transport.

# `delivery_info`

```elixir
@spec delivery_info(pid()) :: CliSubprocessCore.Session.Delivery.t() | nil
```

Returns stable mailbox-delivery metadata for the current session.

# `end_input`

```elixir
@spec end_input(pid()) :: :ok | {:error, term()}
```

Closes stdin for EOF-driven CLIs.

# `extract_event`

```elixir
@spec extract_event(term()) :: {:ok, CliSubprocessCore.Event.t()} | :error
```

Extracts a normalized session event from a legacy mailbox message.

Tagged subscribers should use `extract_event/2` so their code does not
depend on a specific outer event atom.

# `extract_event`

```elixir
@spec extract_event(term(), reference()) ::
  {:ok, CliSubprocessCore.Event.t()} | :error
```

Extracts a normalized session event for a tagged subscriber reference.

This is the stable core-owned way for adapters to consume session delivery
without hard-coding the configured outer event atom.

# `info`

```elixir
@spec info(pid()) :: map()
```

Returns session runtime and transport information.

# `interrupt`

```elixir
@spec interrupt(pid()) :: :ok | {:error, term()}
```

Sends an interrupt request to the underlying transport.

# `send`

```elixir
@spec send(pid(), iodata() | map() | list()) :: :ok | {:error, term()}
```

Sends provider input through the underlying transport.

# `send_input`

```elixir
@spec send_input(pid(), iodata() | map() | list(), keyword()) ::
  :ok | {:error, term()}
```

Alias for `send/2` that preserves the runtime-kit naming.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts a linked session process.

# `start_link_session`

```elixir
@spec start_link_session(keyword()) :: {:ok, pid(), map()} | {:error, term()}
```

Starts a linked session and returns the pid together with its initial info
snapshot.

# `start_session`

```elixir
@spec start_session(keyword()) :: {:ok, pid(), map()} | {:error, term()}
```

Starts a session and returns the pid together with its initial info snapshot.

# `subscribe`

```elixir
@spec subscribe(pid(), pid()) :: :ok | {:error, term()}
```

Subscribes a process in legacy mode.

# `subscribe`

```elixir
@spec subscribe(pid(), pid(), :legacy | reference()) :: :ok | {:error, term()}
```

Subscribes a process with an explicit tag.

# `unsubscribe`

```elixir
@spec unsubscribe(pid(), pid()) :: :ok
```

Removes a subscriber.

---

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