@yahyahammad/venastine 0.3.15 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONFIG_ARCHITECTURE.md +14 -8
- package/README.md +9 -9
- package/cli_commands.py +82 -1
- package/core/client.py +232 -22
- package/core/commands.py +7 -3
- package/core/loop.py +21 -1
- package/core/memory.py +13 -0
- package/core/provider_errors.py +102 -0
- package/core/reasoning/json_retry.py +148 -31
- package/core/reasoning/orchestrator.py +49 -3
- package/core/shell_sessions.py +76 -7
- package/core/usage_view.py +119 -0
- package/docs/THIRD_PARTY_NOTICES.md +1 -1
- package/logging_setup.py +35 -2
- package/main.py +184 -21
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/safety/policy_enforcement.py +29 -0
- package/security/sandbox.py +11 -2
- package/tools/builtin/arxiv.py +8 -2
- package/tools/builtin/fetch_url.py +8 -1
- package/tools/builtin/file_ops.py +74 -8
- package/tools/builtin/project_docs.py +10 -4
- package/tools/builtin/shell.py +2 -1
- package/tools/builtin/shell_sessions.py +6 -3
- package/tools/builtin/web_search.py +5 -1
- package/tools/isolation.py +9 -6
- package/tui/app.py +301 -27
- package/tui/meters.py +124 -40
- package/tui/widgets.py +50 -23
package/CONFIG_ARCHITECTURE.md
CHANGED
|
@@ -322,6 +322,10 @@ max corrective follow-up attempts when a pass returns malformed JSON
|
|
|
322
322
|
|
|
323
323
|
(total attempts per pass = MAX_JSON_RETRIES + 1). See ROADMAP §3.
|
|
324
324
|
|
|
325
|
+
Since batch 267 the same budget covers Pass 1 and Final synthesis coming back with no
|
|
326
|
+
text at all: each is asked again that many times, then the pass fails (ROADMAP_v3 §95,
|
|
327
|
+
RO6 amended).
|
|
328
|
+
|
|
325
329
|
## Spend cap (batch 27, #4)
|
|
326
330
|
|
|
327
331
|
There is NO default spend ceiling any more. The loop's cumulative
|
|
@@ -1361,11 +1365,13 @@ start at a time nobody chose.
|
|
|
1361
1365
|
### `shell_session_max_consecutive_wakes`
|
|
1362
1366
|
|
|
1363
1367
|
ROADMAP_v3 §49 (SS2). How many wake turns may run in a row with no message
|
|
1364
|
-
from the user. Every wake is a model call nobody typed,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1368
|
+
from the user. Every wake is a model call nobody typed, so an agent that
|
|
1369
|
+
starts a new session on every wake would otherwise spend tokens
|
|
1370
|
+
indefinitely. Past the limit, waking stops, the commands the wait holds
|
|
1371
|
+
are released, and the results are delivered with the user's next message;
|
|
1372
|
+
a user message resets the count. (Since batch 265 a plain message is never
|
|
1373
|
+
held by live sessions: the user can type while they run, and each message
|
|
1374
|
+
gets a turn of its own -- ROADMAP_v3 §49, SS2 as amended.)
|
|
1369
1375
|
|
|
1370
1376
|
10 is a ceiling on an unattended loop, not an estimate of a normal one. A
|
|
1371
1377
|
subagent has no user to reset it, so it gets one final wake and returns
|
|
@@ -1985,9 +1991,9 @@ for `shell`'s reason and not a weaker one: a session IS a shell command, and
|
|
|
1985
1991
|
one that keeps running after the call that started it has been answered.
|
|
1986
1992
|
Enabling them without `shell` is allowed and coherent -- a session is
|
|
1987
1993
|
classified, approved and routed by exactly the same rules -- but a session
|
|
1988
|
-
also holds a container for as long as its timeout,
|
|
1989
|
-
while it runs, and can wake the agent,
|
|
1990
|
-
less.
|
|
1994
|
+
also holds a container for as long as its timeout, holds the user's
|
|
1995
|
+
thread- and model-changing commands while it runs, and can wake the agent,
|
|
1996
|
+
so it is more authority rather than less.
|
|
1991
1997
|
|
|
1992
1998
|
The two that START one are approval-gated by `shell_approval_mode` alone
|
|
1993
1999
|
(SS16) and have no `tool_approvals` key, exactly like `shell`; the three
|
package/README.md
CHANGED
|
@@ -774,7 +774,7 @@ paths are cached and 200 matches offered; narrow the query when a limit is shown
|
|
|
774
774
|
| `/threads` | Conversations-only picker — research runs' internal threads excluded — most recently active first, capped at 200 with a notice (**ctrl+t**) |
|
|
775
775
|
| `/resume <thread-id>` | Open any thread by id, however old |
|
|
776
776
|
| `/new` | Start a fresh thread; created lazily on your next message, so `/new` twice leaves nothing behind |
|
|
777
|
-
| `/kill [session-id]` | Stop a background session. Bare, it opens the picker **ctrl+b** opens; with an id it stops that one. Deliberately usable *while* sessions are
|
|
777
|
+
| `/kill [session-id]` | Stop a background session. Bare, it opens the picker **ctrl+b** opens; with an id it stops that one. Deliberately usable *while* sessions are running and holding the other commands — it is the way out of that, so it is the one command that never refuses for being busy. A plain message is not held: it gets a turn of its own while they run |
|
|
778
778
|
| `/agent [name\|default]` | Make an agent active for subsequent turns; `default` clears. Active skills are re-checked against the new agent's tool policy |
|
|
779
779
|
| `/goal [text\|clear]` | Persistent objective for this thread — injected into every turn in either shell, mirrored in a banner |
|
|
780
780
|
| `/grill-me` | One turn under the grill-me agent inside the current thread, reading the live history rather than a digest of it |
|
|
@@ -787,7 +787,7 @@ paths are cached and 200 matches offered; narrow the query when a limit is shown
|
|
|
787
787
|
| `/mentions [ignored on\|off]` | Show file mention status or include ignored paths for this session |
|
|
788
788
|
| `/quit` | Leave the harness, on one invocation — a typed command is already deliberate. `/exit` and `/bye` are the same command under other names; type toward either and the suggestion list says so |
|
|
789
789
|
|
|
790
|
-
Keys: **ctrl+c** twice quits — the first press arms it and the footer changes to say so, and it goes back to `Quit` after a couple of seconds; a **ctrl+c** over selected text copies instead and arms nothing, so nothing you copy can end the session. **ctrl+q** quits on a single press, from anywhere, including under a dialog · **ctrl+t** thread picker · **ctrl+l** claims view · **ctrl+j** (or **shift+enter**) newline in the prompt · **shift+tab** in the prompt switches to the next agent in `config.yaml`'s `agent_cycle` (default → plan → build as shipped) · **up/down** and **enter**/**tab** to pick a slash command, **escape** to dismiss the list · **ctrl+click** a URL in an answer — or in a tool line — to open it, or the name on a `spawn_subagent` line to read what that agent did, or the name on a `shell_background`, `shell_monitor` or `shell_interactive` line to read that session -- its command, why it was started, what it printed, and what became of it. A session the harness no longer holds (it aged out, or you restarted) opens the same way and shows what the agent was given, saying so; a live one refreshes as it writes.
|
|
790
|
+
Keys: **ctrl+c** twice quits — the first press arms it and the footer changes to say so, and it goes back to `Quit` after a couple of seconds; a **ctrl+c** over selected text copies instead and arms nothing, so nothing you copy can end the session. **ctrl+q** quits on a single press, from anywhere, including under a dialog · **ctrl+t** thread picker · **ctrl+l** claims view · **ctrl+j** (or **shift+enter**) newline in the prompt · **shift+tab** in the prompt switches to the next agent in `config.yaml`'s `agent_cycle` (default → plan → build as shipped) · **up/down** and **enter**/**tab** to pick a slash command, **escape** to dismiss the list · **ctrl+click** a URL in an answer — or in a tool line — to open it, or the name on a `spawn_subagent` line to read what that agent did, or the name on a `shell_background`, `shell_monitor` or `shell_interactive` line to read that session -- its command, why it was started, what it printed, and what became of it. A session the harness no longer holds (it aged out, or you restarted) opens the same way and shows what the agent was given, saying so; a live one refreshes as it writes. The sidebar lists the running sessions, then the five that finished most recently, each marked with how it ended (`☑` exit 0, `☒` with its exit code, `killed`, `timed out` or `failed`), and clicking a row opens it; **ctrl+g** lists the runs going on right now and opens one from the keyboard · **ctrl+b** stops a background session, and always asks which one rather than killing on a single press. While background sessions are running the prompt and most commands are refused — `ctrl+b`, `/kill`, answering a dialog and quitting stay usable, because they are the ways out.
|
|
791
791
|
|
|
792
792
|
Answers are rendered rather than printed as their source: tables become grids, headings and `**bold**` take weight, `*emphasis*` and `~~strike~~` take their own marks, code fences are highlighted, and a list item that runs past the edge wraps **under its own text** instead of back to the margin. A line indented four spaces or more is left exactly as written, so a code sample keeps its operators and its `#` comments. What is deliberately not rendered: block quotes, horizontal rules, heading *levels* (a `#` and a `######` look the same), and anything at all inside a reasoning block. `/copy` always hands back the markdown the model wrote — the rendering is what the screen does, never what is stored.
|
|
793
793
|
|
|
@@ -901,7 +901,7 @@ A level is validated against the model that will **receive** it, not the one it
|
|
|
901
901
|
| Provider | Levels | Where the set comes from |
|
|
902
902
|
|---|---|---|
|
|
903
903
|
| Anthropic | `low`, `medium`, `high`, `xhigh`, `max` — whichever the model reports supported | Queried live from the Models API, so newly released Anthropic models need no entry anywhere |
|
|
904
|
-
| OpenAI-compatible | `
|
|
904
|
+
| OpenAI-compatible | `default_effort_levels` assumed for unknown models (shipped: `low` through `ultra`) | Static table (`model_effort_levels` in `config.yaml`). Known non-reasoning models — gpt-4o family, gpt-3.5 — ship with *empty* lists, meaning "takes no effort parameter": a requested level is dropped cleanly instead of 400ing every call. An unlisted model gets the assumption plus a WARNING naming it. If it then refuses the level with a 400 that mentions reasoning or thinking — a local model that cannot reason does — the same request is sent once more without it; if that succeeds, the model gets no effort for the rest of the session, and a WARNING says which `model_effort_levels` entry makes that permanent |
|
|
905
905
|
| Google | Levels map to integer thinking budgets, `low`→2,048 through `max`→dynamic | Mapped at the boundary and sent as `thinking_budget`. On since batch 172, when the `google-genai` pin moved to 2.29.0; an unlisted Gemini model gets the default level set plus a WARNING, like any other unlisted model |
|
|
906
906
|
|
|
907
907
|
**Seeing the thinking is separate from doing it.** Effort is what makes the model reason; whether the API hands those thoughts back to the client is a different question, and the answer varies by provider. Reasoning streams into the transcript on **Anthropic** and on OpenAI-compatible providers that send it — DeepSeek, Qwen, Z.AI, OpenRouter. It is absent on **OpenAI**, whose Chat Completions endpoint returns no reasoning text at all, and on **Google**, whose request deliberately does not ask for thought summaries: those would be billed as extra output for something the model produces either way. On those two the turn still thinks; you just do not see it. `tui.show_thinking` and `/thinking` control the display, never the reasoning.
|
|
@@ -930,7 +930,7 @@ Subagents spawned in one model response run **concurrently**, up to `subagent_ma
|
|
|
930
930
|
|
|
931
931
|
### Logging
|
|
932
932
|
|
|
933
|
-
Two sinks from startup: stderr, and a rotating file — `logs/app.log` in the working directory, 1 MB per file, three backups kept. `AGENT_LOG_LEVEL` sets verbosity (a name like `INFO` or a number like `20`; anything else prints a warning naming the value and runs at `INFO`, as an unwritable `AGENT_LOG_FILE` does) and `AGENT_LOG_FILE` moves the file, creating the parent directory if needed. The file formatter redacts secret-shaped strings on the way out — the same patterns tool outputs get — because a failing tool's traceback routinely carries the request that produced it, and for an HTTP client that is a URL with the key in it.
|
|
933
|
+
Two sinks from startup: stderr, and a rotating file — `logs/app.log` in the working directory, 1 MB per file, three backups kept. `AGENT_LOG_LEVEL` sets verbosity (a name like `INFO` or a number like `20`; anything else prints a warning naming the value and runs at `INFO`, as an unwritable `AGENT_LOG_FILE` does) and `AGENT_LOG_FILE` moves the file, creating the parent directory if needed. The terminal shows WARNING and above, as the TUI's transcript does, and the file keeps INFO too; setting `AGENT_LOG_LEVEL` puts that level on the terminal as well. A tool failure the shell already prints as the call's result is logged at INFO, so it is said once. The file formatter redacts secret-shaped strings on the way out — the same patterns tool outputs get — because a failing tool's traceback routinely carries the request that produced it, and for an HTTP client that is a URL with the key in it.
|
|
934
934
|
|
|
935
935
|
In the TUI stderr is detached before the screen is taken (anything written there would paint over the rendered UI and vanish on the next repaint); the rotating file keeps everything, and WARNING-and-above is routed into the transcript so warnings stay visible where you are looking.
|
|
936
936
|
|
|
@@ -1009,7 +1009,7 @@ Deliberately not settings.json keys: editing these means editing the harness's o
|
|
|
1009
1009
|
| `attended_approval_timeout_s` | 600 | Attended prompt deadline; expiry denies that call while the run continues |
|
|
1010
1010
|
| `subagent_review` | `false` | Shipped default for the post-pipeline review |
|
|
1011
1011
|
| `max_review_findings` / `max_review_refinements` | 25 / 3 | Consent-fatigue caps on the review stage |
|
|
1012
|
-
| `max_pipeline_retries` / `max_json_retries` | 2 / 2 | Revise/re-validate rounds per claim; corrective attempts per malformed pass payload |
|
|
1012
|
+
| `max_pipeline_retries` / `max_json_retries` | 2 / 2 | Revise/re-validate rounds per claim; corrective attempts per malformed pass payload, or per empty Pass 1 or Final synthesis |
|
|
1013
1013
|
| `max_iterations` | 50 | Step ceiling for a turn or pass absent an agent's own `max_steps` |
|
|
1014
1014
|
| `subagent_max_depth` | 2 | `spawn_subagent` nesting limit |
|
|
1015
1015
|
| `subagent_max_parallel` | 3 | How many subagents of one model response run at once; 1 makes them sequential again |
|
|
@@ -1043,8 +1043,8 @@ Deliberately not settings.json keys: editing these means editing the harness's o
|
|
|
1043
1043
|
|
|
1044
1044
|
| Field | Meaning |
|
|
1045
1045
|
|---|---|
|
|
1046
|
-
| `API_URL` | Endpoint base URL; empty for ANTHROPIC and GOOGLE, which use their SDKs' defaults |
|
|
1047
|
-
| `API_KEY` | The credential, stored directly |
|
|
1046
|
+
| `API_URL` | Endpoint base URL; empty for ANTHROPIC and GOOGLE, which use their SDKs' defaults. For an OpenAI-compatible server it is the address the harness adds `/chat/completions` and `/models` to, so it usually ends in `/v1`: a local Ollama is `http://localhost:11434/v1`. Without the `/v1` the server answers `404 page not found`, and the harness's error says it is the address, not the model |
|
|
1047
|
+
| `API_KEY` | The credential, stored directly. A local OpenAI-compatible server that needs none can leave it empty: the harness sends a placeholder, because the openai SDK will not build a client with an empty key |
|
|
1048
1048
|
| `is_v1_compatible` | `true` routes the provider through the OpenAI-compatible translation |
|
|
1049
1049
|
| `supports_stream_usage` | Promises streamed responses carry token usage. If a stream then ends with none, the harness **raises** rather than accounting zero tokens — a silent zero would disable the budget stop condition while looking healthy. Endpoints that don't return streaming usage ship with `false` |
|
|
1050
1050
|
| `echoes_reasoning` | Opt in to sending this provider's own reasoning back on the next request (§44). Off everywhere by default: there is no standard for it the way there is for receiving reasoning — DeepSeek documents that `reasoning_content` must not be supplied on input and returns a 400, while OpenRouter accepts it for some models and ignores it for others. Anthropic needs no flag; its thinking blocks are signed and are echoed to the model that produced them automatically |
|
|
@@ -1058,7 +1058,7 @@ Deliberately not settings.json keys: editing these means editing the harness's o
|
|
|
1058
1058
|
|
|
1059
1059
|
**Built:** ROADMAP.md §1–§12 (§10's ensemble mode rebuilt by its revisit — diversity now comes from a roster of different models) and ROADMAP_v2.md §13 (streaming loop), §14 (config loader + workspace trust), §15 (permissions), §16 (TUI), §17 (MCP), §18 (agents), §19 (skills), §20 (post-pipeline review), §21a (compaction + `pin`), §21b (durable memory), §22 (live pipeline progress), §25 (authorised tool use in the pipeline), §26 (research legibility: per-pass tool calls, code-stage announcements, the claims view, role colour, `/copy`), §27 (thread legibility: transcript replay on resume, a conversations-only thread picker), §21c (session summaries and cross-thread referencing — §21 is now complete), §24 (`/init`), §23 (interactive tools: the response channel, per-tool subagent sign-off, `ask_user`, and the todo list), §28 (the shell capability classifier).
|
|
1060
1060
|
|
|
1061
|
-
**Remaining:** nothing in `ROADMAP.md` or `ROADMAP_v2.md`, and §10's revisit is now closed. `ROADMAP_v3.md` §49–§59, §61–§93 and §
|
|
1061
|
+
**Remaining:** nothing in `ROADMAP.md` or `ROADMAP_v2.md`, and §10's revisit is now closed. `ROADMAP_v3.md` §49–§59, §61–§93, §95, §96 and §97 are built. The section still to build is §60 (Unified Harness Protocol compliance), specified and awaiting detailed design. §56 lets a decision model approve a single contained shell command under the opt-in `classified` mode; §54 completes project file/folder mentions without loading contents; §58 supplies a short harness identity that follows the current model; §83's final live checks are confirmed, and the ChatGPT header distinguishes a selected provider from an active sign-in. `TECHNICAL_DEBT.md` items 14, 17, 18, 21, 102, 116, 117, 118 and 119 are open, and so is the secrets half of item 97. The two checks recorded against §10 are answered from the providers' documentation in `ROADMAP_v3.md` §87: the default `temperature` on OpenAI and Google is 1.0, and OpenAI's reasoning models refuse one whenever reasoning effort is not `none`, which the guard now follows.
|
|
1062
1062
|
|
|
1063
1063
|
**And both audits are closed.** Both roadmaps being built is not the same as the code
|
|
1064
1064
|
being clean, and saying only the first would be the "built and runs are different claims"
|
|
@@ -1077,7 +1077,7 @@ note that shell approval is governed solely by `shell_approval_mode` -- `tool_ap
|
|
|
1077
1077
|
deliberately has no `shell` key, so an old file carrying one is refused at startup
|
|
1078
1078
|
naming the key — see `tests/BREAKING_CHANGES.md` §24.
|
|
1079
1079
|
|
|
1080
|
-
Run the test suite with `pytest` —
|
|
1080
|
+
Run the test suite with `pytest` — 9770 tests, fully offline, no API keys needed. Since batch 243 the suite holds itself to that: a test that asks DNS for a name, or writes into your home folder, fails by name, and every test process runs with HOME pointing at a throwaway folder of its own. The suite's own packages are `requirements-test.txt`, separate from `requirements.txt` since batch 136: they used to be in the shipped dependency list, so installing the harness also installed a test runner. It runs in parallel by default (`pytest-xdist`, 70% of your cores): **1:26 on a 16-core machine, against 9:06 single-process.** `pytest -n0` forces the old serial run, which is what you want under a debugger or when something is parsing the output. Eight further tests are marked `integration` and excluded by default: three spawn a real stdio MCP server, one runs an external program through the host fallback shell, one builds the hosted bundle's Docker image, and three run the installers' uv path against a real uv (`pytest -m integration`).
|
|
1081
1081
|
|
|
1082
1082
|
## Documentation
|
|
1083
1083
|
|
package/cli_commands.py
CHANGED
|
@@ -41,6 +41,7 @@ from uuid import UUID
|
|
|
41
41
|
|
|
42
42
|
from core import ansi
|
|
43
43
|
from core.commands import CATALOG, CLI, CommandRegistry, absent_reason, bind
|
|
44
|
+
from core.usage_view import UsageTally, report_lines
|
|
44
45
|
|
|
45
46
|
logger = logging.getLogger(__name__)
|
|
46
47
|
|
|
@@ -84,6 +85,12 @@ class ChatSession:
|
|
|
84
85
|
# Left for run_chat by /quit and /grill-me.
|
|
85
86
|
quit_requested: bool = False
|
|
86
87
|
one_shot: object = None
|
|
88
|
+
# ROADMAP_v3 §97 (UF4). `/usage`'s tally: the calls this shell made on
|
|
89
|
+
# `usage_thread` since it was opened here. The TUI's memory keeps one
|
|
90
|
+
# across turns; this shell builds a memory per turn, so the turns'
|
|
91
|
+
# tallies (`ModelResponse.turn_usage`) are added up here instead.
|
|
92
|
+
usage: object = field(default_factory=UsageTally)
|
|
93
|
+
usage_thread: Optional[UUID] = None
|
|
87
94
|
|
|
88
95
|
def memory(self):
|
|
89
96
|
"""The current thread, created if there is none yet.
|
|
@@ -99,6 +106,19 @@ class ChatSession:
|
|
|
99
106
|
self.thread_id = memory.thread_id
|
|
100
107
|
return memory
|
|
101
108
|
|
|
109
|
+
def count_usage(self, response) -> None:
|
|
110
|
+
"""Add a finished turn's calls to `/usage`'s tally (§97, UF4).
|
|
111
|
+
|
|
112
|
+
The tally starts again when the turn ran on another thread than
|
|
113
|
+
the one it was counting -- the first turn after /new, /resume or
|
|
114
|
+
/threads -- which is the TUI's span: a thread since it was opened.
|
|
115
|
+
"""
|
|
116
|
+
thread = getattr(response, "thread_id", None) or self.thread_id
|
|
117
|
+
if thread != self.usage_thread:
|
|
118
|
+
self.usage = UsageTally()
|
|
119
|
+
self.usage_thread = thread
|
|
120
|
+
self.usage.merge(getattr(response, "turn_usage", None))
|
|
121
|
+
|
|
102
122
|
|
|
103
123
|
def _out(text: str = "") -> None:
|
|
104
124
|
"""One line of a command's answer.
|
|
@@ -112,9 +132,57 @@ def _out(text: str = "") -> None:
|
|
|
112
132
|
|
|
113
133
|
# ---- the loop's entry point ---------------------------------------------------
|
|
114
134
|
|
|
115
|
-
|
|
135
|
+
#: The commands refused when they are sent while the chat waits on a turn's
|
|
136
|
+
#: background sessions, and what each would have done (ROADMAP_v3 §49, SS2
|
|
137
|
+
#: as amended in batch 265, the owner's choice). The CLI's half of the
|
|
138
|
+
#: TUI's `refuse_if_occupied`: the TUI refuses these while its wait runs,
|
|
139
|
+
#: because each changes what the wait is waiting FOR -- the thread, the
|
|
140
|
+
#: model, the history -- underneath it. `/grill-me` is one of them because
|
|
141
|
+
#: the TUI's refuses for its running turn, and its wait is one.
|
|
142
|
+
#: `/submodel` only when it would change something, as in the TUI.
|
|
143
|
+
REFUSED_WHILE_WAITING = {
|
|
144
|
+
"compact": "compact this thread",
|
|
145
|
+
"grill-me": "run /grill-me",
|
|
146
|
+
"model": "change the model",
|
|
147
|
+
"new": "start a new thread",
|
|
148
|
+
"resume": "switch threads",
|
|
149
|
+
"submodel": "change the submodel",
|
|
150
|
+
"threads": "switch threads",
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _refused_while_waiting(session: ChatSession, line: str) -> bool:
|
|
155
|
+
"""Whether `line`, sent during the session wait, is refused, saying why.
|
|
156
|
+
|
|
157
|
+
Asked only of a line the wait handed back: at the prompt, with nothing
|
|
158
|
+
waiting, there is no wait for a command to pull the ground from under,
|
|
159
|
+
and a refusal there would leave the user no way round it.
|
|
160
|
+
"""
|
|
161
|
+
from core import shell_sessions
|
|
162
|
+
|
|
163
|
+
name, _, args = line[1:].partition(" ")
|
|
164
|
+
action = REFUSED_WHILE_WAITING.get(name)
|
|
165
|
+
if action is None or (name == "submodel" and not args.strip()):
|
|
166
|
+
return False
|
|
167
|
+
thread_id = session.thread_id
|
|
168
|
+
sessions = shell_sessions.sessions
|
|
169
|
+
if thread_id is None or not sessions.blocks(thread_id):
|
|
170
|
+
return False
|
|
171
|
+
live = sessions.waited_on(thread_id)
|
|
172
|
+
plural = "" if live == 1 else "s"
|
|
173
|
+
_out(f"[{live} background session{plural} still running — {action} "
|
|
174
|
+
f"once they finish, or press Ctrl+C to stop them]")
|
|
175
|
+
return True
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def run_command(session: ChatSession, line: str, *,
|
|
179
|
+
waiting: bool = False) -> None:
|
|
116
180
|
"""Run one `/` line, and contain whatever the command does.
|
|
117
181
|
|
|
182
|
+
`waiting` (batch 265): the line was sent while the chat waited on
|
|
183
|
+
background sessions, and the commands in `REFUSED_WHILE_WAITING` are
|
|
184
|
+
refused rather than run.
|
|
185
|
+
|
|
118
186
|
CONTAINED HERE, as the TUI contains its own dispatch (batch 135): a
|
|
119
187
|
handler that raises must not end the conversation, and the traceback
|
|
120
188
|
goes to logs/app.log where a real bug stays findable. Ctrl+C during a
|
|
@@ -123,6 +191,8 @@ def run_command(session: ChatSession, line: str) -> None:
|
|
|
123
191
|
turn.
|
|
124
192
|
"""
|
|
125
193
|
name = line[1:].split(" ")[0]
|
|
194
|
+
if waiting and _refused_while_waiting(session, line):
|
|
195
|
+
return
|
|
126
196
|
try:
|
|
127
197
|
handled = registry.dispatch(session, line)
|
|
128
198
|
except KeyboardInterrupt:
|
|
@@ -689,6 +759,16 @@ def _cmd_network(session: ChatSession, args: str) -> None:
|
|
|
689
759
|
_out(line)
|
|
690
760
|
|
|
691
761
|
|
|
762
|
+
def _cmd_usage(session: ChatSession, args: str) -> None:
|
|
763
|
+
"""ROADMAP_v3 §97 (UF4). The TUI's /usage, line for line: both print
|
|
764
|
+
`core.usage_view.report_lines`. Empty until a turn has run on this
|
|
765
|
+
thread here, which is the span the TUI's memory covers."""
|
|
766
|
+
same = (session.thread_id is not None
|
|
767
|
+
and session.usage_thread == session.thread_id)
|
|
768
|
+
for line in report_lines(session.usage if same else None):
|
|
769
|
+
_out(line)
|
|
770
|
+
|
|
771
|
+
|
|
692
772
|
def _cmd_forget(session: ChatSession, args: str) -> None:
|
|
693
773
|
raw = args.strip()
|
|
694
774
|
if not raw:
|
|
@@ -852,6 +932,7 @@ def register_cli_commands() -> None:
|
|
|
852
932
|
bind("model", _cmd_model),
|
|
853
933
|
bind("network", _cmd_network),
|
|
854
934
|
bind("new", _cmd_new),
|
|
935
|
+
bind("usage", _cmd_usage),
|
|
855
936
|
bind("quit", _cmd_quit),
|
|
856
937
|
bind("ref", _cmd_ref),
|
|
857
938
|
bind("resume", _cmd_resume),
|