LemonAgent.Tools.AbortHelpers (lemon_agent v0.1.0)

View Source

Shared abort-signal helpers used across tool implementations.

Provides two styles of abort checking:

  • aborted?/1 – boolean check, useful in if guards
  • check_abort/1 – returns :ok | {:error, "Operation aborted"}, useful in with chains

  • check_aborted/1 – returns :ok | {:error, :aborted}, used by tools that pattern-match on the atom

Summary

Functions

Returns true when the signal has been aborted, false otherwise. Safely handles nil (no signal).

Returns :ok when the signal has not been aborted, or {:error, "Operation aborted"} when it has. Safely handles nil and non-reference values.

Returns :ok when the signal has not been aborted, or {:error, :aborted} when it has. Safely handles nil and non-reference values.

Functions

aborted?(signal)

@spec aborted?(reference() | nil) :: boolean()

Returns true when the signal has been aborted, false otherwise. Safely handles nil (no signal).

check_abort(signal)

@spec check_abort(reference() | nil) :: :ok | {:error, String.t()}

Returns :ok when the signal has not been aborted, or {:error, "Operation aborted"} when it has. Safely handles nil and non-reference values.

check_aborted(signal)

@spec check_aborted(reference() | nil) :: :ok | {:error, :aborted}

Returns :ok when the signal has not been aborted, or {:error, :aborted} when it has. Safely handles nil and non-reference values.