A MANAGED Python REPL: a persistent interpreter subprocess running a tiny
line-framed eval server — one JSON request per line in, one JSON response per
line out. Globals persist across evals (real REPL state). One process per
session and canonical directory; the cached Process handle owns teardown.
A MANAGED Python REPL: a persistent interpreter subprocess running a tiny line-framed eval server — one JSON request per line in, one JSON response per line out. Globals persist across evals (real REPL state). One process per session and canonical directory; the cached `Process` handle owns teardown.
(eval! session-id dir code timeout-ms)Evaluate code in this session's REPL for canonical dir. Returns
{"ok" "out" "err" "value" "data" "type" "exc"} — value is the
last expression's repr, data its JSON-safe STRUCTURED view (dicts/lists/
dataclasses/numpy/pandas/objects, so the model can read real fields), type
the class name.
Evaluate `code` in this session's REPL for canonical `dir`. Returns
{"ok" "out" "err" "value" "data" "type" "exc"} — `value` is the
last expression's repr, `data` its JSON-safe STRUCTURED view (dicts/lists/
dataclasses/numpy/pandas/objects, so the model can read real fields), `type`
the class name.(start! session-id dir opts)Start the managed Python REPL for this session and canonical dir, or reuse
its live process. Other sessions at the same directory have separate REPLs.
A live REPL is NEVER silently replaced: its globals ARE the session's work, so a second start answers "already-running", exactly as every other Vis language answers it. A start succeeds only after the child answers its protocol ping; failed children never masquerade as usable REPLs.
opts carries THIS start's own env delta over the project environment (the
env key, string-keyed like every other model-facing option), and that env
BELONGS to the REPL: a start naming a different one is refused by the keys
that differ, because there is no restart — stop it, then start it.
Returns a STRING-keyed lifecycle map.
Start the managed Python REPL for this session and canonical `dir`, or reuse its live process. Other sessions at the same directory have separate REPLs. A live REPL is NEVER silently replaced: its globals ARE the session's work, so a second start answers "already-running", exactly as every other Vis language answers it. A start succeeds only after the child answers its protocol ping; failed children never masquerade as usable REPLs. `opts` carries THIS start's own `env` delta over the project environment (the `env` key, string-keyed like every other model-facing option), and that env BELONGS to the REPL: a start naming a different one is refused by the keys that differ, because there is no restart — stop it, then start it. Returns a STRING-keyed lifecycle map.
(status session-id dir)STRING-keyed lifecycle view (crosses as a tool :result): result, cwd,
status, plus running / pid / cmd / env while the interpreter is up.
A key appears only where it MEANS something — a down REPL has no pid and no
command — which is the shape every language answers. env is the delta this
REPL was STARTED with, by NAME and digest only, and never a value. Lookup is
scoped to session-id and canonical dir.
STRING-keyed lifecycle view (crosses as a tool `:result`): `result`, `cwd`, `status`, plus `running` / `pid` / `cmd` / `env` while the interpreter is up. A key appears only where it MEANS something — a down REPL has no pid and no command — which is the shape every language answers. `env` is the delta this REPL was STARTED with, by NAME and digest only, and never a value. Lookup is scoped to `session-id` and canonical `dir`.
(stop! session-id dir)Stop this session's interpreter for canonical dir. No-op-safe: with nothing
managed the result says not-managed, not a stop that never happened.
Stop this session's interpreter for canonical `dir`. No-op-safe: with nothing managed the result says `not-managed`, not a stop that never happened.
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 |