Liking cljdoc? Tell your friends :D

com.blockether.vis.ext.channel-tui.chat

TUI-side projections over the canonical in-process gateway.

On startup the TUI creates a fresh :tui gateway session by default. Pass --session-id ID or --resume to pick up an existing one. Session data is persisted in ~/.vis/vis.mdb so you can come back to it.

TUI-side projections over the canonical in-process gateway.

On startup the TUI creates a fresh `:tui` gateway session by default.
Pass `--session-id ID` or `--resume` to pick up an existing one.
Session data is persisted in `~/.vis/vis.mdb` so you can come back to it.
raw docstring

assistant-messageclj

(assistant-message source)
(assistant-message source timestamp)

Create a structured assistant (vis) message with timestamp.

Accepts either:

  • a Markdown source string -> the canonical input on the Markdown answer pipeline; IR is derived via vis/markdown->ir
  • a canonical [:ir & nodes] vector -> IR is used as-is; raw Markdown is reconstructed via vis/render ir :markdown so the message still carries a :text field
  • nil -> empty placeholder for unfilled answer slots

The message carries both: :text raw Markdown source (used by copy/export, FTS, plain views) :ir derived IR (used by the bubble layout walker)

Create a structured assistant (vis) message with timestamp.

Accepts either:
  - a Markdown source string  -> the canonical input on the Markdown
    answer pipeline; IR is derived via `vis/markdown->ir`
  - a canonical `[:ir & nodes]` vector -> IR is used as-is; raw
    Markdown is reconstructed via `vis/render ir :markdown` so the
    message still carries a `:text` field
  - nil -> empty placeholder for unfilled answer slots

The message carries both:
  :text  raw Markdown source (used by copy/export, FTS, plain views)
  :ir    derived IR (used by the bubble layout walker)
sourceraw docstring

attach!clj

(attach! session tid)
(attach! {:keys [id]} tid {:keys [on-chunk]})

Attach to a gateway turn tid already queued/running for session, blocking until it completes. Same result shape as turn! — drives TUI rendering for a busy-time submission the gateway queued (see gateway/state attach-turn-sync!).

Attach to a gateway turn `tid` already queued/running for `session`, blocking
until it completes. Same result shape as `turn!` — drives TUI rendering for a
busy-time submission the gateway queued (see gateway/state `attach-turn-sync!`).
sourceraw docstring

discard-prewarmed-session!clj

(discard-prewarmed-session!)

Delete every warmed-but-unused TUI session and stop any in-flight warmups.

Delete every warmed-but-unused TUI session and stop any in-flight warmups.
sourceraw docstring

dispose!clj

(dispose! {:keys [id]})

Release the TUI's env handle. Session data stays in ~/.vis/vis.mdb so other consumers of the :tui channel (e.g. vis sessions tui, future inspectors) still see it.

Release the TUI's env handle. Session data stays in
`~/.vis/vis.mdb` so other consumers of the `:tui` channel
(e.g. `vis sessions tui`, future inspectors) still see it.
sourceraw docstring

empty-irclj

Canonical empty IR — used as the placeholder when an answer slot is absent (e.g. resumed turns whose answer column is NULL because the turn never finished). Never feed nil or "" to the TUI render chokepoints; lift to empty-ir instead.

Canonical empty IR — used as the placeholder when an answer slot is
absent (e.g. resumed turns whose answer column is NULL because the
turn never finished). Never feed `nil` or `""` to the TUI render
chokepoints; lift to `empty-ir` instead.
sourceraw docstring

make-sessionclj

(make-session _provider-config)
(make-session provider-config opts)

Create a fresh :tui session. BLOCKING on a pool miss (builds inline).

Prefer make-session-async on the input thread; use this only where the caller genuinely needs the session id synchronously.

Optional opts map (second arity): :workspace-id pre-spawned workspace to pin the new session to. Omit and a trunk workspace is auto-minted by create-environment.

Returns {:id session-id :history []}.

Create a fresh `:tui` session. BLOCKING on a pool miss (builds inline).

Prefer `make-session-async` on the input thread; use this only where the
caller genuinely needs the session id synchronously.

 Optional opts map (second arity):
   :workspace-id  pre-spawned workspace to pin the new session to.
                  Omit and a trunk workspace is auto-minted by
                  `create-environment`.

 Returns `{:id session-id :history []}`.
sourceraw docstring

make-session-asyncclj

(make-session-async provider-config)
(make-session-async provider-config opts)

Non-blocking make-session for the input thread. Never runs the cold env/runtime build on the caller's thread.

Returns one of: {:session {:id … :history []}} a warm session was ready — open it now. {:building fut} nothing warm — fut (a worker Future) resolves to {:id … :history []} once the cold build finishes. The caller opens an optimistic placeholder tab now and binds the real session when fut lands.

:workspace-id opts always build off-thread (never pooled), so they take the :building branch too.

Non-blocking `make-session` for the input thread. Never runs the cold
env/runtime build on the caller's thread.

Returns one of:
  {:session {:id … :history []}}  a warm session was ready — open it now.
  {:building fut}                 nothing warm — `fut` (a worker Future)
                                  resolves to `{:id … :history []}` once the
                                  cold build finishes. The caller opens an
                                  optimistic placeholder tab now and binds the
                                  real session when `fut` lands.

`:workspace-id` opts always build off-thread (never pooled), so they take the
`:building` branch too.
sourceraw docstring

prewarm-session!clj

(prewarm-session! provider-config)

Keep a small pool of empty :tui sessions warm on background workers.

The gateway facade intentionally couples the cheap session row with the expensive environment/runtime construction, so the practical prewarm unit is a real empty :tui session. make-session / make-session-async consume them atomically; shutdown deletes any left over.

Idempotent and safe to call from any thread: tops the pool up toward prewarm-pool-depth, counting both already-warm sessions and in-flight warmups, so racing callers never over-build.

Keep a small pool of empty `:tui` sessions warm on background workers.

The gateway facade intentionally couples the cheap session row with the
expensive environment/runtime construction, so the practical prewarm unit is
a real empty `:tui` session. `make-session` / `make-session-async` consume
them atomically; shutdown deletes any left over.

Idempotent and safe to call from any thread: tops the pool up toward
`prewarm-pool-depth`, counting both already-warm sessions and in-flight
warmups, so racing callers never over-build.
sourceraw docstring

render-answerclj

(render-answer ir)

Render canonical answer-IR ([:ir & nodes]) to the markdown string the TUI bubble renderer expects.

STRICT input contract: IR only. nil is accepted as a convenience for unfilled answer slots and renders as the empty string. Strings, Hiccup vectors, EDN values, etc. are programmer bugs — the IR boundary lives upstream (loop emits IR, persistence stores Nippy IR, resumed turns thaw to IR). Anything else throws with the offending type so the bug surfaces at the wrong call site, not silently in the bubble.

Dispatches via the TUI channel's :channel/messages-renderer-fn (core/render-for-tui) when registered; otherwise falls back to vis/render :markdown directly so unit tests that load this ns in isolation still work. Both paths share the same strict IR contract.

Render canonical answer-IR (`[:ir & nodes]`) to the markdown string
the TUI bubble renderer expects.

STRICT input contract: IR only. `nil` is accepted as a convenience
for unfilled answer slots and renders as the empty string. Strings,
Hiccup vectors, EDN values, etc. are programmer bugs — the IR
boundary lives upstream (loop emits IR, persistence stores Nippy IR,
resumed turns thaw to IR). Anything else throws with the offending
type so the bug surfaces at the wrong call site, not silently in the
bubble.

Dispatches via the TUI channel's `:channel/messages-renderer-fn`
(`core/render-for-tui`) when registered; otherwise falls back to
`vis/render :markdown` directly so unit tests that load this ns in
isolation still work. Both paths share the same strict IR contract.
sourceraw docstring

resume-sessionclj

(resume-session session-id)

Resume an existing gateway-managed session by id — ANY channel, so a conversation started in the web (or CLI) resumes here too. Accepts full UUID or unambiguous short UUID prefix. Returns {:id UUID :history [...]} with persisted messages.

Resume an existing gateway-managed session by id — ANY channel, so a
conversation started in the web (or CLI) resumes here too.
Accepts full UUID or unambiguous short UUID prefix.
Returns `{:id UUID :history [...]}` with persisted messages.
sourceraw docstring

turn!clj

(turn! session text)
(turn! {:keys [id]}
       text
       {:keys [on-chunk cancel-token reasoning-default extra-body turn-features
               workspace]})

Submit a user request through the canonical in-process gateway. Blocking. Returns {:answer [:ir ...]} or {:error str}.

Submit a user request through the canonical in-process gateway. Blocking.
Returns `{:answer [:ir ...]}` or `{:error str}`.
sourceraw docstring

user-messageclj

(user-message text)
(user-message text timestamp)

Create a structured user message with timestamp. The user types raw markdown into the input box; we lift it to canonical IR via vis/markdown->ir immediately so the bubble layer (and every downstream consumer) sees the same shape it sees for assistant answers.

Unlike model answers, user input is line-oriented: every literal newline the user typed or pasted is intent (code, line-numbered dumps, stack traces). We lift with {:soft-break :hard} so bare newlines become [:br] and the bubble preserves the exact line structure instead of collapsing pasted lines into one wrapped wall of text (CommonMark prose soft-break semantics).

The message carries ONLY :ir — every consumer that needs a string projection computes it on demand (and caches the result client-side, e.g. via virtual.clj projection) instead of us eagerly rendering at construction.

Create a structured user message with timestamp.
The user types raw markdown into the input box; we lift it to
canonical IR via `vis/markdown->ir` immediately so the bubble layer
(and every downstream consumer) sees the same shape it sees for
assistant answers.

Unlike model answers, user input is line-oriented: every literal
newline the user typed or pasted is intent (code, line-numbered
dumps, stack traces). We lift with `{:soft-break :hard}` so bare
newlines become `[:br]` and the bubble preserves the exact line
structure instead of collapsing pasted lines into one wrapped wall
of text (CommonMark prose soft-break semantics).

The message carries ONLY `:ir` — every consumer that needs a
string projection computes it on demand (and caches the result
client-side, e.g. via `virtual.clj` projection) instead of us
eagerly rendering at construction.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close