@yahyahammad/venastine 0.2.0 → 0.3.8
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/.env.example +19 -14
- package/CONFIG_ARCHITECTURE.md +2002 -0
- package/NOTICE +1 -1
- package/README.md +233 -94
- package/agents/builtin/build.md +73 -0
- package/agents/builtin/general.md +80 -0
- package/agents/builtin/plan.md +23 -5
- package/agents/builtin/test.md +65 -0
- package/agents/builtin/writer.md +67 -0
- package/agents/manager.py +261 -195
- package/agents/subagent_tool.py +277 -43
- package/agents/tui_commands.py +7 -12
- package/bin/venastine.mjs +528 -382
- package/bin/venastine.py +71 -0
- package/cli_commands.py +835 -0
- package/config.py +95 -1198
- package/config.yaml +1090 -0
- package/config_edit.py +1301 -0
- package/config_schema.py +966 -0
- package/config_update.py +749 -0
- package/core/agent_activity.py +158 -20
- package/core/ansi.py +452 -0
- package/core/approval.py +27 -5
- package/core/call_view.py +364 -0
- package/core/cancel.py +121 -0
- package/core/chatgpt_auth.py +747 -0
- package/core/claims_view.py +107 -0
- package/core/client.py +1238 -82
- package/core/commands.py +454 -0
- package/core/compaction.py +830 -66
- package/core/config_loader.py +516 -97
- package/core/connect.py +686 -0
- package/core/events.py +68 -6
- package/core/file_mentions.py +280 -0
- package/core/interaction.py +87 -4
- package/core/line_pattern.py +128 -0
- package/core/loop.py +1516 -440
- package/core/memory.py +120 -8
- package/core/pipeline_models.py +23 -9
- package/core/provider_errors.py +234 -0
- package/core/reasoning/confidence_scoring.py +70 -54
- package/core/reasoning/json_retry.py +19 -1
- package/core/reasoning/orchestrator.py +232 -53
- package/core/reasoning/output_writer.py +90 -31
- package/core/reasoning/payload_validation.py +133 -7
- package/core/reasoning/pipeline_storage.py +427 -361
- package/core/reasoning/review.py +659 -615
- package/core/reasoning/scholar.py +38 -14
- package/core/reasoning/source_corpus.py +110 -4
- package/core/replay.py +158 -26
- package/core/session.py +36 -12
- package/core/session_view.py +259 -0
- package/core/session_wake.py +259 -0
- package/core/shell_sessions.py +1553 -0
- package/core/workspace_trust.py +1 -1
- package/credentials.py +308 -180
- package/database.py +82 -1
- package/{PRIVACY.md → docs/PRIVACY.md} +19 -7
- package/docs/SECURITY.md +108 -0
- package/docs/THIRD_PARTY_NOTICES.md +148 -0
- package/env_secrets.py +118 -77
- package/json_store.py +236 -16
- package/logging_setup.py +121 -11
- package/main.py +1671 -199
- package/mcp_client/client.py +257 -23
- package/mcp_client/config.py +484 -379
- package/mcp_client/registration.py +163 -2
- package/memories/manager.py +15 -0
- package/memories/tui_commands.py +7 -12
- package/package.json +234 -4
- package/project_init/config_files.py +4 -0
- package/project_init/generator.py +201 -37
- package/project_init/manifest.py +418 -406
- package/project_init/tui_commands.py +7 -4
- package/prompts/revalidate.md +1 -1
- package/prompts/revise.md +17 -15
- package/prompts/system_prompts.py +64 -10
- package/providers.json.example +94 -92
- package/pyproject.toml +51 -2
- package/requirements.txt +252 -29
- package/safety/policy_enforcement.py +353 -17
- package/security/askpass.py +419 -0
- package/security/capability.py +37 -7
- package/security/confine.py +484 -0
- package/security/hosted.py +182 -0
- package/security/permissions.py +54 -7
- package/security/posture.py +124 -12
- package/security/protected_paths.py +198 -6
- package/security/sandbox.py +3262 -139
- package/security/secrets.py +855 -0
- package/skills/tui_commands.py +3 -4
- package/storage.py +368 -35
- package/tools/base.py +465 -305
- package/tools/builtin/_math_common.py +306 -16
- package/tools/builtin/_net_common.py +267 -61
- package/tools/builtin/arxiv.py +681 -223
- package/tools/builtin/ask_user.py +231 -213
- package/tools/builtin/discrete_math.py +35 -4
- package/tools/builtin/fetch_url.py +239 -21
- package/tools/builtin/file_ops.py +341 -33
- package/tools/builtin/geometry.py +184 -148
- package/tools/builtin/get_time.py +2 -2
- package/tools/builtin/linear_algebra.py +66 -23
- package/tools/builtin/load_skill.py +10 -0
- package/tools/builtin/logic.py +171 -12
- package/tools/builtin/pin.py +46 -12
- package/tools/builtin/probability_stats.py +224 -228
- package/tools/builtin/project_docs.py +80 -21
- package/tools/builtin/remember.py +21 -4
- package/tools/builtin/shell.py +586 -67
- package/tools/builtin/shell_sessions.py +613 -0
- package/tools/builtin/symbolic_math.py +80 -10
- package/tools/builtin/todo.py +5 -3
- package/tools/builtin/web_search.py +329 -151
- package/tools/context.py +23 -0
- package/tools/isolation.py +387 -314
- package/tools/registry.py +347 -30
- package/tui/app.py +4645 -438
- package/tui/app.tcss +185 -2
- package/tui/commands.py +10 -154
- package/tui/diffs.py +286 -265
- package/tui/hosted_driver.py +102 -0
- package/tui/markdown.py +60 -10
- package/tui/meters.py +103 -7
- package/tui/screens.py +346 -92
- package/tui/themes.py +59 -19
- package/tui/widgets.py +1575 -111
- package/SECURITY.md +0 -88
- package/THIRD_PARTY_NOTICES.md +0 -100
package/tui/screens.py
CHANGED
|
@@ -11,10 +11,13 @@ modal, and the user's answer unblocks it. Nothing here is async-aware --
|
|
|
11
11
|
the blocking side is a thread, not a coroutine.
|
|
12
12
|
|
|
13
13
|
EVERY RENDERABLE BUILT FROM A NON-LITERAL IS WRAPPED IN `Text(...)`
|
|
14
|
-
(batch 42, RA1). Textual
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
(batch 42, RA1). Textual parses a `str` as MARKUP, so a square bracket
|
|
15
|
+
in a tool argument, a claim, a thread preview or an `ask_user` option
|
|
16
|
+
is a tag here -- and these screens exist to show a person exactly what
|
|
17
|
+
a model asked for. It was Rich's console markup until the textual pin
|
|
18
|
+
moved and is Textual's own grammar now; nothing below changed with it,
|
|
19
|
+
which is the point of re-measuring rather than assuming. Two live
|
|
20
|
+
failures:
|
|
18
21
|
|
|
19
22
|
* `sed -i "s/[/]//" f.txt` in a permission payload
|
|
20
23
|
raised MarkupError inside compose(). The screen was pushed and
|
|
@@ -28,14 +31,25 @@ show a person exactly what a model asked for. Two live failures:
|
|
|
28
31
|
The severity was silently absent from every review modal since
|
|
29
32
|
§20 -- an unconditional defect, needing no adversary at all.
|
|
30
33
|
|
|
31
|
-
`markup=False` IS NOT THE FIX,
|
|
32
|
-
textual 1.0.0
|
|
33
|
-
`
|
|
34
|
-
`
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
`markup=False` WORKS NOW AND IS STILL NOT THE FIX, which is a
|
|
35
|
+
different sentence from the one that stood here. On textual 1.0.0 the
|
|
36
|
+
flag was stored by `__init__` and never read by the `visual`
|
|
37
|
+
property, so `Static(x, markup=False)` raised anyway -- measured then.
|
|
38
|
+
Since the pin moved it is honoured: `visualize(self, content,
|
|
39
|
+
markup=self._render_markup)`, and all four payloads below render
|
|
40
|
+
literally -- measured again.
|
|
41
|
+
|
|
42
|
+
The wrap stays, for two reasons that outlived the version fact. It
|
|
43
|
+
covers `Selection` and `Button`, which take no such flag and both
|
|
44
|
+
parse what they are given. And it is one rule for one file, where the
|
|
45
|
+
flag would be a per-constructor argument somebody adding the next
|
|
46
|
+
screen has to remember -- which is exactly the failure RA1 is.
|
|
47
|
+
|
|
48
|
+
What a bare `str` still does on 8.2.8, measured:
|
|
49
|
+
`sed -i "s/[/]//" f.txt` raises, `[bold]x` renders as `x`,
|
|
50
|
+
`[HIGH] rated` renders as ` rated`, and `[1, 2]` survives intact.
|
|
51
|
+
That last one is why the rule cannot be a scan for brackets: the
|
|
52
|
+
shapes that fail are not the ones a reader expects to be dangerous.
|
|
39
53
|
|
|
40
54
|
A literal written in THIS file is left alone: it is ours and it is
|
|
41
55
|
reviewed. The rule is mechanical, so it holds for the next screen
|
|
@@ -49,10 +63,19 @@ from textual.app import ComposeResult
|
|
|
49
63
|
from textual.containers import Horizontal, Vertical, VerticalScroll
|
|
50
64
|
from textual.screen import ModalScreen
|
|
51
65
|
from textual.widgets import (
|
|
52
|
-
Button,
|
|
66
|
+
Button,
|
|
67
|
+
Input,
|
|
68
|
+
Label,
|
|
69
|
+
ListItem,
|
|
70
|
+
ListView,
|
|
71
|
+
SelectionList,
|
|
72
|
+
Static,
|
|
53
73
|
)
|
|
54
74
|
from textual.widgets.selection_list import Selection
|
|
55
75
|
|
|
76
|
+
from core.claims_view import claims_header, render_claims
|
|
77
|
+
from core.replay import thread_row
|
|
78
|
+
|
|
56
79
|
|
|
57
80
|
class ScrollBox(VerticalScroll):
|
|
58
81
|
"""A bounded block of text whose overflow can actually be reached
|
|
@@ -99,6 +122,33 @@ class ScrollBox(VerticalScroll):
|
|
|
99
122
|
"""
|
|
100
123
|
|
|
101
124
|
|
|
125
|
+
def asker_label(asked_by, depth) -> list:
|
|
126
|
+
"""`[Label]` naming the run that raised a question, or `[]` (§47).
|
|
127
|
+
|
|
128
|
+
ONE SENTENCE FOR THE THREE MODALS THAT CAN BE ASKED FROM INSIDE A RUN.
|
|
129
|
+
§47 gave it to the permission modal alone; batch 75's review found the
|
|
130
|
+
sign-off and the model's own question without it, which is where it
|
|
131
|
+
matters most now that three children of one turn can each be asking:
|
|
132
|
+
three sign-off screens naming the grandchild and nothing about who
|
|
133
|
+
asked are three identical screens.
|
|
134
|
+
|
|
135
|
+
Empty at depth 0, and that is the right SCOPE rather than a gap: the
|
|
136
|
+
asking run is then the conversation you are looking at, which needs no
|
|
137
|
+
label.
|
|
138
|
+
|
|
139
|
+
Returned as a LIST so a caller splices it into its widget list without
|
|
140
|
+
a branch, which is what keeps the placement rule (directly under the
|
|
141
|
+
title, above anything the agent wrote) in one shape across the three.
|
|
142
|
+
|
|
143
|
+
`Text(...)` for RA1's reason -- an agent name comes from a file whose
|
|
144
|
+
author is not necessarily this project.
|
|
145
|
+
"""
|
|
146
|
+
if not asked_by:
|
|
147
|
+
return []
|
|
148
|
+
return [Label(Text(f"asked by {asked_by} (depth {depth})"),
|
|
149
|
+
id="permission-asker")]
|
|
150
|
+
|
|
151
|
+
|
|
102
152
|
class PermissionScreen(ModalScreen[bool]):
|
|
103
153
|
"""Approve or deny one tool call. Dismisses with the decision.
|
|
104
154
|
|
|
@@ -147,9 +197,9 @@ class PermissionScreen(ModalScreen[bool]):
|
|
|
147
197
|
command was merely the part somebody noticed was missing.
|
|
148
198
|
|
|
149
199
|
Nothing caught it because every assertion about this screen reads
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
200
|
+
the widget's own VISUAL -- the string it was built from, which a
|
|
201
|
+
widget of zero height still reports in full. §46's tests assert on
|
|
202
|
+
the rendered REGION for that reason.
|
|
153
203
|
|
|
154
204
|
The headline is DISPLAY ONLY and is also inside `params`, which is
|
|
155
205
|
still rendered whole below it. That duplication is deliberate for
|
|
@@ -161,10 +211,26 @@ class PermissionScreen(ModalScreen[bool]):
|
|
|
161
211
|
BINDINGS = [("escape", "deny", "Deny")]
|
|
162
212
|
|
|
163
213
|
def __init__(self, tool_name: str, params: dict, notice: str = None,
|
|
164
|
-
rationale: str = None, headline: str = None
|
|
214
|
+
rationale: str = None, headline: str = None,
|
|
215
|
+
asked_by: str = None, depth: int = 0):
|
|
165
216
|
super().__init__()
|
|
166
217
|
self._tool_name = tool_name
|
|
167
218
|
self._params = params
|
|
219
|
+
# ROADMAP_v2 §47. WHICH run raised this question, when it was
|
|
220
|
+
# not the conversation itself. A subagent's approvals have
|
|
221
|
+
# always surfaced here -- the channel is inherited -- and the
|
|
222
|
+
# modal said only which TOOL was asked for, so "Allow shell?"
|
|
223
|
+
# over a chat turn and over a nested agent two levels down
|
|
224
|
+
# were the same screen.
|
|
225
|
+
#
|
|
226
|
+
# None for a top-level turn, and that is the right scope
|
|
227
|
+
# rather than a gap: the asking run is then the conversation
|
|
228
|
+
# you are looking at, which needs no label. It becomes
|
|
229
|
+
# load-bearing when two questions can be pending at once,
|
|
230
|
+
# which is why it is a prerequisite for §47's last slice
|
|
231
|
+
# rather than a nicety.
|
|
232
|
+
self._asked_by = asked_by
|
|
233
|
+
self._depth = depth
|
|
168
234
|
# §46 (EP2). What this call is asking to DO -- for `shell`, the
|
|
169
235
|
# command. Resolved by the registry from whichever param the
|
|
170
236
|
# tool declared and passed in already a string, for the reason
|
|
@@ -205,6 +271,11 @@ class PermissionScreen(ModalScreen[bool]):
|
|
|
205
271
|
rendered = f"{self._notice}\n\n{rendered}"
|
|
206
272
|
widgets = [Label(Text(f"Allow {self._tool_name}?"),
|
|
207
273
|
id="permission-title")]
|
|
274
|
+
# DIRECTLY under the title, above the headline and everything the
|
|
275
|
+
# agent wrote: RA6's ordering says a harness fact is read before an
|
|
276
|
+
# agent's claim, and which run is asking is the most harness-y fact
|
|
277
|
+
# on the screen. See `asker_label` for the rest.
|
|
278
|
+
widgets.extend(asker_label(self._asked_by, self._depth))
|
|
208
279
|
if self._headline:
|
|
209
280
|
# `Text(...)` is not optional here (batch 42, RA1). This is
|
|
210
281
|
# the most attacker-influenced string on the screen -- a
|
|
@@ -351,16 +422,26 @@ class SubagentSignoffScreen(ModalScreen[object]):
|
|
|
351
422
|
|
|
352
423
|
BINDINGS = [("escape", "refuse", "Refuse")]
|
|
353
424
|
|
|
354
|
-
def __init__(self, agent: str, candidates: list
|
|
425
|
+
def __init__(self, agent: str, candidates: list, asked_by: str = None,
|
|
426
|
+
depth: int = 0):
|
|
355
427
|
super().__init__()
|
|
356
428
|
self._agent = agent
|
|
357
429
|
self._candidates = list(candidates)
|
|
430
|
+
# §47, extended by batch 75's review. WHICH run wants to spawn
|
|
431
|
+
# this one -- a different agent from `self._agent`, which is the
|
|
432
|
+
# one about to be spawned. It matters more here than on the
|
|
433
|
+
# permission modal: three children of one turn each spawning a
|
|
434
|
+
# grandchild produce three of these screens, and without this they
|
|
435
|
+
# name the grandchild and nothing else, so they are identical.
|
|
436
|
+
self._asked_by = asked_by
|
|
437
|
+
self._depth = depth
|
|
358
438
|
|
|
359
439
|
def compose(self) -> ComposeResult:
|
|
360
440
|
if not self._candidates:
|
|
361
441
|
yield Vertical(
|
|
362
442
|
Label(Text(f"Run {self._agent}?"),
|
|
363
443
|
id="permission-title"),
|
|
444
|
+
*asker_label(self._asked_by, self._depth),
|
|
364
445
|
Static(Text(f"{self._agent} needs no approval-gated "
|
|
365
446
|
f"tools."),
|
|
366
447
|
id="permission-params"),
|
|
@@ -376,6 +457,10 @@ class SubagentSignoffScreen(ModalScreen[object]):
|
|
|
376
457
|
yield Vertical(
|
|
377
458
|
Label(Text(f"What may {self._agent} use without asking again?"),
|
|
378
459
|
id="grant-title"),
|
|
460
|
+
# BOTH branches, because either can be reached from inside a
|
|
461
|
+
# run -- the no-candidates one is what a nested spawn of an
|
|
462
|
+
# agent with no gated tools shows.
|
|
463
|
+
*asker_label(self._asked_by, self._depth),
|
|
379
464
|
Static(
|
|
380
465
|
"Space toggles, then choose. Anything left unticked still "
|
|
381
466
|
"prompts you if the subagent tries it.\nRunning with none "
|
|
@@ -444,18 +529,26 @@ class QuestionScreen(ModalScreen[object]):
|
|
|
444
529
|
BINDINGS = [("escape", "dismiss_unanswered", "No answer")]
|
|
445
530
|
|
|
446
531
|
def __init__(self, question: str, options=(), multi_select: bool = False,
|
|
447
|
-
allow_text: bool = True
|
|
532
|
+
allow_text: bool = True, asked_by: str = None,
|
|
533
|
+
depth: int = 0):
|
|
448
534
|
super().__init__()
|
|
449
535
|
self._question = question
|
|
450
536
|
self._options = list(options)
|
|
451
537
|
self._multi = bool(multi_select)
|
|
452
538
|
self._allow_text = bool(allow_text)
|
|
539
|
+
# §47, added by batch 75's review. "The assistant has a question"
|
|
540
|
+
# is the right title for a chat turn and an understatement for a
|
|
541
|
+
# subagent two levels down, whose question surfaces on the parent's
|
|
542
|
+
# screen exactly as its approvals do.
|
|
543
|
+
self._asked_by = asked_by
|
|
544
|
+
self._depth = depth
|
|
453
545
|
|
|
454
546
|
def compose(self) -> ComposeResult:
|
|
455
547
|
# The question is the MODEL's, so its length is the one thing
|
|
456
548
|
# this screen does not choose -- bounded and scrollable for the
|
|
457
549
|
# same reason the payload block is.
|
|
458
550
|
widgets = [Label("The assistant has a question", id="question-title"),
|
|
551
|
+
*asker_label(self._asked_by, self._depth),
|
|
459
552
|
ScrollBox(Static(Text(self._question), id="question-body"),
|
|
460
553
|
id="question-body-box")]
|
|
461
554
|
|
|
@@ -476,8 +569,17 @@ class QuestionScreen(ModalScreen[object]):
|
|
|
476
569
|
# at `width: auto` an option wider than the dialog was
|
|
477
570
|
# CLIPPED, and the same label at `width: 100%` wraps to two
|
|
478
571
|
# centred lines instead.
|
|
572
|
+
#
|
|
573
|
+
# `Text(option)` for batch 42's reason (RA1), which had
|
|
574
|
+
# not reached a Button: these are the MODEL's words, and
|
|
575
|
+
# measured on both the old pin and the new one, a
|
|
576
|
+
# `Button` given a `str` sends it through markup parsing
|
|
577
|
+
# and raises on an unbalanced tag -- inside compose(), so
|
|
578
|
+
# the screen is pushed and never drawn. The multi-select
|
|
579
|
+
# branch above already wraps its `Selection`; this branch
|
|
580
|
+
# simply had not.
|
|
479
581
|
widgets.append(ScrollBox(
|
|
480
|
-
*[Button(option, variant="primary",
|
|
582
|
+
*[Button(Text(option), variant="primary",
|
|
481
583
|
id=f"question-opt-{index}")
|
|
482
584
|
for index, option in enumerate(self._options)],
|
|
483
585
|
id="question-options"))
|
|
@@ -695,12 +797,10 @@ class ClaimsScreen(ModalScreen[None]):
|
|
|
695
797
|
self._partial = partial
|
|
696
798
|
|
|
697
799
|
def compose(self) -> ComposeResult:
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
# text and tier have been broadcast as events.
|
|
703
|
-
header += " — run in progress, metadata incomplete"
|
|
800
|
+
# core/claims_view.py says what the view shows (§89), so the
|
|
801
|
+
# CLI's /claims and this screen cannot disagree about a run.
|
|
802
|
+
header = claims_header(self._title, len(self._claims),
|
|
803
|
+
self._partial)
|
|
704
804
|
yield Vertical(
|
|
705
805
|
Label(Text(header), id="claims-title"),
|
|
706
806
|
# A ScrollBox, not a `max-height` Static (batch 49). EP3's
|
|
@@ -709,7 +809,7 @@ class ClaimsScreen(ModalScreen[None]):
|
|
|
709
809
|
# claims than fit had the remainder GONE rather than below
|
|
710
810
|
# the fold, on the one screen whose entire purpose is showing
|
|
711
811
|
# all of them.
|
|
712
|
-
ScrollBox(Static(Text(
|
|
812
|
+
ScrollBox(Static(Text(render_claims(self._claims)),
|
|
713
813
|
id="claims-body"),
|
|
714
814
|
id="claims-body-box"),
|
|
715
815
|
id="claims-dialog",
|
|
@@ -719,69 +819,6 @@ class ClaimsScreen(ModalScreen[None]):
|
|
|
719
819
|
self.dismiss(None)
|
|
720
820
|
|
|
721
821
|
|
|
722
|
-
# Tier order for the claims view: worst first. A reader opening this is
|
|
723
|
-
# looking for what NOT to trust, and burying the unverified claims under
|
|
724
|
-
# the confident ones makes them the hardest thing to find.
|
|
725
|
-
_TIER_ORDER = ("UNVERIFIED", "UNVERIFIED_COVERAGE", "LOW", "MEDIUM", "HIGH")
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
def _render_claims(claims: list) -> str:
|
|
729
|
-
if not claims:
|
|
730
|
-
return "No claims recorded for this run."
|
|
731
|
-
|
|
732
|
-
def _rank(claim):
|
|
733
|
-
tier = claim.get("confidence_tier")
|
|
734
|
-
return _TIER_ORDER.index(tier) if tier in _TIER_ORDER else len(_TIER_ORDER)
|
|
735
|
-
|
|
736
|
-
out = []
|
|
737
|
-
for claim in sorted(claims, key=_rank):
|
|
738
|
-
tier = claim.get("confidence_tier") or "—"
|
|
739
|
-
head = f"{tier:<20} {claim.get('id', '?')} {claim.get('type') or ''}"
|
|
740
|
-
if claim.get("retry_count"):
|
|
741
|
-
head += f" revised x{claim['retry_count']}"
|
|
742
|
-
out.append(head.rstrip())
|
|
743
|
-
# final_text is what the claim carries into the report; text is
|
|
744
|
-
# what Pass 2 extracted. Showing final_text when they differ means
|
|
745
|
-
# the view matches the report rather than the draft behind it.
|
|
746
|
-
out.append(f" {claim.get('final_text') or claim.get('text') or ''}")
|
|
747
|
-
if claim.get("entities"):
|
|
748
|
-
out.append(f" entities: {', '.join(map(str, claim['entities']))}")
|
|
749
|
-
if claim.get("grounding_status") or claim.get("grounding_sources"):
|
|
750
|
-
sources = len(claim.get("grounding_sources") or ())
|
|
751
|
-
out.append(f" grounding: {claim.get('grounding_status') or 'none'}"
|
|
752
|
-
f" ({sources} source{'s' if sources != 1 else ''})")
|
|
753
|
-
for field, label in (("fallacies", "fallacies"),
|
|
754
|
-
("contradictions", "contradictions"),
|
|
755
|
-
("assumption_flags", "assumptions")):
|
|
756
|
-
if claim.get(field):
|
|
757
|
-
out.append(f" {label}: {'; '.join(map(str, claim[field]))}")
|
|
758
|
-
if claim.get("score_breakdown"):
|
|
759
|
-
out.append(" score: " + ", ".join(
|
|
760
|
-
f"{k}={v}" for k, v in claim["score_breakdown"].items()))
|
|
761
|
-
if claim.get("annotation"):
|
|
762
|
-
out.append(f" {claim['annotation']}")
|
|
763
|
-
out.append("")
|
|
764
|
-
return "\n".join(out).rstrip()
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
def _thread_row(thread: dict) -> str:
|
|
768
|
-
"""One picker row: timestamp, first message, id (§27).
|
|
769
|
-
|
|
770
|
-
`created_at` and `id` are INDEXED deliberately, not .get: a row
|
|
771
|
-
without either has nothing honest to render -- storage.list_threads()
|
|
772
|
-
always supplies both, and the id is the row's whole payload on
|
|
773
|
-
selection. Only `preview` is optional (.get): §27 added it, so
|
|
774
|
-
hand-built test rows predate it, and a missing preview degrades to an
|
|
775
|
-
id-only row rather than a KeyError in a test-only construction.
|
|
776
|
-
"""
|
|
777
|
-
created = thread["created_at"]
|
|
778
|
-
stamp = (f"{created:%Y-%m-%d %H:%M}"
|
|
779
|
-
if hasattr(created, "strftime") else str(created))
|
|
780
|
-
preview = (thread.get("preview") or "").strip()
|
|
781
|
-
return f"{stamp} {preview} ({thread['id']})" if preview \
|
|
782
|
-
else f"{stamp} {thread['id']}"
|
|
783
|
-
|
|
784
|
-
|
|
785
822
|
class ConfirmScreen(ModalScreen[bool]):
|
|
786
823
|
"""A titled yes/no over a block of text (ROADMAP_v2 §24).
|
|
787
824
|
|
|
@@ -815,7 +852,8 @@ class ConfirmScreen(ModalScreen[bool]):
|
|
|
815
852
|
ScrollBox(Static(Text(self._body), id="permission-params"),
|
|
816
853
|
id="permission-params-box"),
|
|
817
854
|
Horizontal(
|
|
818
|
-
Button(self._confirm_label, variant="success",
|
|
855
|
+
Button(Text(self._confirm_label), variant="success",
|
|
856
|
+
id="allow"),
|
|
819
857
|
Button("No", variant="error", id="deny"),
|
|
820
858
|
id="permission-buttons"),
|
|
821
859
|
id="permission-dialog",
|
|
@@ -834,6 +872,48 @@ class ConfirmScreen(ModalScreen[bool]):
|
|
|
834
872
|
self.dismiss(False)
|
|
835
873
|
|
|
836
874
|
|
|
875
|
+
class NoticeScreen(ModalScreen[None]):
|
|
876
|
+
"""Something to read and acknowledge, with one button (ROADMAP_v3 §83,
|
|
877
|
+
CG8).
|
|
878
|
+
|
|
879
|
+
OpenAI's guidelines for Sign in with ChatGPT ask for a notice the first
|
|
880
|
+
time someone signs in with plan usage on: that eligible requests use
|
|
881
|
+
their ChatGPT plan and that usage is managed in ChatGPT's settings,
|
|
882
|
+
titled "You're using your ChatGPT plan", with "Got it". There is no
|
|
883
|
+
decision in it, so it is not a ConfirmScreen with the No hidden: Enter,
|
|
884
|
+
Escape and the button all mean the one thing it can mean.
|
|
885
|
+
"""
|
|
886
|
+
|
|
887
|
+
BINDINGS = [("escape", "acknowledge", "Got it")]
|
|
888
|
+
|
|
889
|
+
def __init__(self, title: str, body: str, button_label: str = "Got it"):
|
|
890
|
+
super().__init__()
|
|
891
|
+
self._title = title
|
|
892
|
+
self._body = body
|
|
893
|
+
self._button_label = button_label
|
|
894
|
+
|
|
895
|
+
def compose(self) -> ComposeResult:
|
|
896
|
+
yield Vertical(
|
|
897
|
+
Label(Text(self._title), id="permission-title"),
|
|
898
|
+
ScrollBox(Static(Text(self._body), id="permission-params"),
|
|
899
|
+
id="permission-params-box"),
|
|
900
|
+
Horizontal(
|
|
901
|
+
Button(Text(self._button_label), variant="primary",
|
|
902
|
+
id="notice-ok"),
|
|
903
|
+
id="permission-buttons"),
|
|
904
|
+
id="permission-dialog",
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
def on_mount(self) -> None:
|
|
908
|
+
self.query_one("#notice-ok", Button).focus()
|
|
909
|
+
|
|
910
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
911
|
+
self.dismiss(None)
|
|
912
|
+
|
|
913
|
+
def action_acknowledge(self) -> None:
|
|
914
|
+
self.dismiss(None)
|
|
915
|
+
|
|
916
|
+
|
|
837
917
|
class ProjectKindScreen(ModalScreen[object]):
|
|
838
918
|
"""Which document set /init scaffolds (§24, I13).
|
|
839
919
|
|
|
@@ -893,6 +973,114 @@ class ProjectKindScreen(ModalScreen[object]):
|
|
|
893
973
|
self.dismiss(None)
|
|
894
974
|
|
|
895
975
|
|
|
976
|
+
class AgentPickerScreen(ModalScreen[object]):
|
|
977
|
+
"""Pick a run to read. Dismisses with a thread id, or None (§47).
|
|
978
|
+
|
|
979
|
+
THE KEYBOARD ROUTE to what the sidebar offers on a click. The
|
|
980
|
+
sidebar is deliberately not focusable -- batch 59 refused a tab
|
|
981
|
+
stop and refused to take the arrow keys the suggestion panel
|
|
982
|
+
uses -- so making its rows clickable made navigation reachable by
|
|
983
|
+
mouse only. A key-bound picker keeps the panel as it is and
|
|
984
|
+
mirrors ctrl+t, which is already this project's answer to
|
|
985
|
+
"choose a thread".
|
|
986
|
+
|
|
987
|
+
Only runs that HAVE a thread are listed. A row for one that
|
|
988
|
+
cannot be opened would be a control that does nothing, which is
|
|
989
|
+
the rule the sidebar's unbound rows already follow.
|
|
990
|
+
"""
|
|
991
|
+
|
|
992
|
+
BINDINGS = [("escape", "cancel", "Cancel")]
|
|
993
|
+
|
|
994
|
+
def __init__(self, runs: list[dict]):
|
|
995
|
+
super().__init__()
|
|
996
|
+
self._runs = runs
|
|
997
|
+
|
|
998
|
+
def compose(self) -> ComposeResult:
|
|
999
|
+
items = [
|
|
1000
|
+
# Indented by the LINEAGE LEVEL the app read off
|
|
1001
|
+
# `widgets.lineage_rows`, which is the walk the sidebar
|
|
1002
|
+
# indents by -- not `AgentRow.depth`, which is the spawn
|
|
1003
|
+
# bound and parts company with the column wherever a span
|
|
1004
|
+
# adds a display level without adding a spawn level.
|
|
1005
|
+
# `Text(...)` for RA1's reason: an agent name comes from a
|
|
1006
|
+
# file this project did not necessarily write. Finished
|
|
1007
|
+
# runs read muted: they open like any other row, so the
|
|
1008
|
+
# mark is de-emphasis rather than a warning, and `live`
|
|
1009
|
+
# defaults True so a hand-built row renders as running.
|
|
1010
|
+
ListItem(
|
|
1011
|
+
Label(Text(
|
|
1012
|
+
f"{' ' * run.get('level', 0)}{run['label']}")),
|
|
1013
|
+
classes="" if run.get("live", True) else "finished")
|
|
1014
|
+
for run in self._runs
|
|
1015
|
+
]
|
|
1016
|
+
children = [Label("Read which run?", id="agent-picker-title")]
|
|
1017
|
+
if items:
|
|
1018
|
+
children.append(ListView(*items, id="agent-picker-list"))
|
|
1019
|
+
else:
|
|
1020
|
+
children.append(Static(
|
|
1021
|
+
"Nothing is running, and this conversation has not "
|
|
1022
|
+
"started yet.", id="agent-picker-empty"))
|
|
1023
|
+
yield Vertical(*children, id="agent-picker-dialog")
|
|
1024
|
+
|
|
1025
|
+
def on_list_view_selected(self, event: ListView.Selected) -> None:
|
|
1026
|
+
index = event.list_view.index
|
|
1027
|
+
if index is not None and 0 <= index < len(self._runs):
|
|
1028
|
+
self.dismiss(self._runs[index]["thread_id"])
|
|
1029
|
+
else:
|
|
1030
|
+
self.dismiss(None)
|
|
1031
|
+
|
|
1032
|
+
def action_cancel(self) -> None:
|
|
1033
|
+
self.dismiss(None)
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
class SessionKillScreen(ModalScreen[object]):
|
|
1037
|
+
"""Pick a background session to stop. Dismisses with a session id, or
|
|
1038
|
+
None to cancel (ROADMAP_v3 §49, SS2).
|
|
1039
|
+
|
|
1040
|
+
ALWAYS A PICKER, including for a single session, and that is a
|
|
1041
|
+
decision rather than a simplification. §49's adopted default killed
|
|
1042
|
+
outright when exactly one was live and showed this list only for
|
|
1043
|
+
several, which made one key mean two things -- and the destructive
|
|
1044
|
+
one was the case that needed no confirmation. A one-row list costs a
|
|
1045
|
+
keypress and removes the mistyped-ctrl+b case entirely.
|
|
1046
|
+
|
|
1047
|
+
It is also the only thing on screen that says what is running until
|
|
1048
|
+
the sidebar panel lands, which is why the rows carry the command and
|
|
1049
|
+
not just an id.
|
|
1050
|
+
|
|
1051
|
+
The rows arrive already rendered and already REDACTED: the command
|
|
1052
|
+
goes through the same output policy the model's own view of it does,
|
|
1053
|
+
because a modal is a display surface like any other and a secret does
|
|
1054
|
+
not become safe by being shown to the person who typed it.
|
|
1055
|
+
"""
|
|
1056
|
+
|
|
1057
|
+
BINDINGS = [("escape", "cancel", "Cancel")]
|
|
1058
|
+
|
|
1059
|
+
def __init__(self, rows: list[dict]):
|
|
1060
|
+
super().__init__()
|
|
1061
|
+
self._rows = rows
|
|
1062
|
+
|
|
1063
|
+
def compose(self) -> ComposeResult:
|
|
1064
|
+
items = [ListItem(Label(Text(row["label"]))) for row in self._rows]
|
|
1065
|
+
children = [Label("Stop which session?", id="session-kill-title")]
|
|
1066
|
+
if items:
|
|
1067
|
+
children.append(ListView(*items, id="session-kill-list"))
|
|
1068
|
+
else:
|
|
1069
|
+
children.append(Static("Nothing is running.",
|
|
1070
|
+
id="session-kill-empty"))
|
|
1071
|
+
yield Vertical(*children, id="session-kill-dialog")
|
|
1072
|
+
|
|
1073
|
+
def on_list_view_selected(self, event: ListView.Selected) -> None:
|
|
1074
|
+
index = event.list_view.index
|
|
1075
|
+
if index is not None and 0 <= index < len(self._rows):
|
|
1076
|
+
self.dismiss(self._rows[index]["id"])
|
|
1077
|
+
else:
|
|
1078
|
+
self.dismiss(None)
|
|
1079
|
+
|
|
1080
|
+
def action_cancel(self) -> None:
|
|
1081
|
+
self.dismiss(None)
|
|
1082
|
+
|
|
1083
|
+
|
|
896
1084
|
class ThreadPickerScreen(ModalScreen[object]):
|
|
897
1085
|
"""Pick a thread to resume. Dismisses with a UUID, or None to cancel.
|
|
898
1086
|
|
|
@@ -920,7 +1108,7 @@ class ThreadPickerScreen(ModalScreen[object]):
|
|
|
920
1108
|
self._note = note
|
|
921
1109
|
|
|
922
1110
|
def compose(self) -> ComposeResult:
|
|
923
|
-
items = [ListItem(Label(Text(
|
|
1111
|
+
items = [ListItem(Label(Text(thread_row(t))))
|
|
924
1112
|
for t in self._threads]
|
|
925
1113
|
children = [Label("Resume which thread?", id="thread-title")]
|
|
926
1114
|
if self._note:
|
|
@@ -941,3 +1129,69 @@ class ThreadPickerScreen(ModalScreen[object]):
|
|
|
941
1129
|
|
|
942
1130
|
def action_cancel(self) -> None:
|
|
943
1131
|
self.dismiss(None)
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
class SecretScreen(ModalScreen[object]):
|
|
1135
|
+
"""Ask for one secret, masked (ROADMAP_v3 §49 slice 5a, SS59).
|
|
1136
|
+
|
|
1137
|
+
THE FIRST MASKED INPUT IN THIS PROJECT, which is why it is its own
|
|
1138
|
+
screen rather than a flag on QuestionScreen. The KIND is what tells a
|
|
1139
|
+
shell how to render (§23 AC1), and here the rendering IS the substance: a
|
|
1140
|
+
flag that a screen forgot to read would show the passphrase in clear
|
|
1141
|
+
while every test about the plumbing still passed.
|
|
1142
|
+
|
|
1143
|
+
Four properties this screen owes, none of which QuestionScreen has:
|
|
1144
|
+
|
|
1145
|
+
* `password=True`, so the characters are never drawn;
|
|
1146
|
+
* the value is dismissed and NOTHING ELSE. It is not put in a
|
|
1147
|
+
reactive, not logged, not echoed into the transcript, and not kept
|
|
1148
|
+
on the screen object past `dismiss` -- `on_button_pressed` reads
|
|
1149
|
+
the widget and hands the string straight out;
|
|
1150
|
+
* Escape and the Cancel button dismiss with None, which
|
|
1151
|
+
`interaction.decode` turns into the declining default. A dismissed
|
|
1152
|
+
passphrase prompt must not become an empty passphrase, because an
|
|
1153
|
+
empty passphrase is an authentication ATTEMPT (SS59);
|
|
1154
|
+
* Enter submits, because a password field that needs a mouse is a
|
|
1155
|
+
password field people paste into something else first.
|
|
1156
|
+
"""
|
|
1157
|
+
|
|
1158
|
+
BINDINGS = [("escape", "cancel", "Cancel")]
|
|
1159
|
+
|
|
1160
|
+
def __init__(self, title: str, body: str = "",
|
|
1161
|
+
confirm_label: str = "Unlock"):
|
|
1162
|
+
super().__init__()
|
|
1163
|
+
self._title = title
|
|
1164
|
+
self._body = body
|
|
1165
|
+
self._confirm_label = confirm_label
|
|
1166
|
+
|
|
1167
|
+
def compose(self) -> ComposeResult:
|
|
1168
|
+
widgets = [Label(Text(self._title), id="permission-title")]
|
|
1169
|
+
if self._body:
|
|
1170
|
+
widgets.append(
|
|
1171
|
+
ScrollBox(Static(Text(self._body), id="permission-params"),
|
|
1172
|
+
id="permission-params-box"))
|
|
1173
|
+
widgets.append(Input(password=True, id="secret-value"))
|
|
1174
|
+
widgets.append(Horizontal(
|
|
1175
|
+
Button(Text(self._confirm_label), variant="success",
|
|
1176
|
+
id="secret-ok"),
|
|
1177
|
+
Button("Cancel", variant="error", id="secret-cancel"),
|
|
1178
|
+
id="permission-buttons"))
|
|
1179
|
+
yield Vertical(*widgets, id="permission-dialog")
|
|
1180
|
+
|
|
1181
|
+
def on_mount(self) -> None:
|
|
1182
|
+
self.query_one("#secret-value", Input).focus()
|
|
1183
|
+
|
|
1184
|
+
def _submit(self) -> None:
|
|
1185
|
+
self.dismiss(self.query_one("#secret-value", Input).value)
|
|
1186
|
+
|
|
1187
|
+
def on_input_submitted(self, event: Input.Submitted) -> None:
|
|
1188
|
+
self._submit()
|
|
1189
|
+
|
|
1190
|
+
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
1191
|
+
if event.button.id == "secret-ok":
|
|
1192
|
+
self._submit()
|
|
1193
|
+
else:
|
|
1194
|
+
self.dismiss(None)
|
|
1195
|
+
|
|
1196
|
+
def action_cancel(self) -> None:
|
|
1197
|
+
self.dismiss(None)
|