PtcRunner.Upstream.Result (PtcRunner v0.12.0)

Copy Markdown View Source

Transport-neutral upstream call result helpers.

Summary

Functions

Projects raw upstream-call entries to compact result summaries.

Decorates a structured payload with upstream call diagnostics.

Builds the PTC-Lisp-visible tagged recoverable failure shape.

Builds a compact, LLM-facing overview of an upstream result value.

Builds the PTC-Lisp-visible tagged success shape.

Types

json()

@type json() ::
  nil
  | boolean()
  | number()
  | binary()
  | [json()]
  | %{optional(binary()) => json()}

reason()

@type reason() ::
  :upstream_unavailable
  | :upstream_error
  | :tool_error
  | :auth_failed
  | :rate_limited
  | :timeout
  | :response_too_large
  | :cap_exhausted

t()

@type t() :: {:ok, json()} | {:error, reason(), String.t()}

Functions

compact_result_entries(entries)

@spec compact_result_entries([map()]) :: [map()]

Projects raw upstream-call entries to compact result summaries.

decorate_payload(payload, entries)

@spec decorate_payload(map(), [map()]) :: map()

Decorates a structured payload with upstream call diagnostics.

error(reason, message)

@spec error(atom(), String.t()) :: map()

Builds the PTC-Lisp-visible tagged recoverable failure shape.

result_overview(value, value_kind)

@spec result_overview(term(), atom()) :: map()

Builds a compact, LLM-facing overview of an upstream result value.

success(value)

@spec success(term()) :: map()

Builds the PTC-Lisp-visible tagged success shape.

value_kind(value)

@spec value_kind(term()) :: :json | :text | :none