Extension-facing helpers for router limits, parse diagnostics, and provider-state provenance handoff. These functions keep extension/TUI code out of svar internals while preserving the full forensic state needed to resume provider-specific conversations.
Extension-facing helpers for router limits, parse diagnostics, and provider-state provenance handoff. These functions keep extension/TUI code out of svar internals while preserving the full forensic state needed to resume provider-specific conversations.
(parse-diagnose text)(parse-diagnose text spec-def)Diagnoses how svar would parse text, optionally against spec-def.
With no spec, returns SAP parser value + warnings. With a spec, runs the
full spec-aware path (str->data-with-spec) and validation. Exceptions are
captured into :error; this function is meant for extension/TUI diagnosis,
so it returns data instead of throwing on parse/schema failures.
Diagnoses how svar would parse `text`, optionally against `spec-def`. With no spec, returns SAP parser value + warnings. With a spec, runs the full spec-aware path (`str->data-with-spec`) and validation. Exceptions are captured into `:error`; this function is meant for extension/TUI diagnosis, so it returns data instead of throwing on parse/schema failures.
(provenance-lifecycle)(provenance-lifecycle x)Returns provenance lifecycle data for extension hosts.
Zero-arity returns the contract. One-arity inspects a result/provider-state
and returns capture/resume data. Resume by merging :resume-opts into the
next svar call opts. Clear by omitting :provider-state.
Returns provenance lifecycle data for extension hosts. Zero-arity returns the contract. One-arity inspects a result/provider-state and returns capture/resume data. Resume by merging `:resume-opts` into the next svar call opts. Clear by omitting `:provider-state`.
(provenance-ref x)(provenance-ref x {:keys [id created-at-ms]})Builds a stable provenance reference from an ask!/ask-code! result or
a raw :provider-state map.
The returned map intentionally carries the full :provider-state. Extension
code can persist it under :id, then resume a later call with:
{:provider-state (:provider-state ref)}. Returns nil when no provider
continuation state is present.
Builds a stable provenance reference from an `ask!`/`ask-code!` result or
a raw `:provider-state` map.
The returned map intentionally carries the full `:provider-state`. Extension
code can persist it under `:id`, then resume a later call with:
`{:provider-state (:provider-state ref)}`. Returns nil when no provider
continuation state is present.(provider-limits router)Returns extension-friendly provider limit state for a svar router.
Shape: {:window-ms N :providers {provider-id {:rpm {:limit N :used N :remaining N :reset-ms N} :tpm {:limit N :used N :remaining N :reset-ms N} :circuit-breaker :closed|:open|:half-open :models [...]}} :budget {:limit ... :spent ... :remaining ...}}
This is read-only. It does not claim a request slot or mutate router state.
Returns extension-friendly provider limit state for a svar router.
Shape:
{:window-ms N
:providers {provider-id {:rpm {:limit N :used N :remaining N :reset-ms N}
:tpm {:limit N :used N :remaining N :reset-ms N}
:circuit-breaker :closed|:open|:half-open
:models [...]}}
:budget {:limit ... :spent ... :remaining ...}}
This is read-only. It does not claim a request slot or mutate router state.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |