@yahyahammad/venastine 0.3.8 → 0.3.10
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 -19
- package/CONFIG_ARCHITECTURE.md +2139 -2002
- package/LICENSE +201 -201
- package/README.md +1043 -1034
- package/agents/builtin/compactor.md +75 -75
- package/agents/builtin/explore.md +77 -77
- package/agents/builtin/pipeline-reviewer.md +100 -100
- package/agents/builtin/plan.md +106 -106
- package/agents/builtin/review.md +74 -74
- package/agents/manager.py +261 -261
- package/agents/subagent_tool.py +472 -472
- package/agents/tui_commands.py +238 -146
- package/bin/venastine.mjs +584 -528
- package/bin/venastine.py +73 -71
- package/cli_commands.py +848 -835
- package/config.yaml +64 -0
- package/config_edit.py +1301 -1301
- package/config_schema.py +987 -966
- package/config_update.py +749 -749
- package/core/agent_activity.py +256 -256
- package/core/ansi.py +452 -452
- package/core/approval.py +137 -137
- package/core/call_view.py +364 -364
- package/core/cancel.py +121 -121
- package/core/chatgpt_auth.py +747 -747
- package/core/claims_view.py +107 -107
- package/core/client.py +2756 -2715
- package/core/commands.py +464 -454
- package/core/compaction.py +1735 -1735
- package/core/config_loader.py +1982 -1982
- package/core/connect.py +686 -686
- package/core/events.py +123 -123
- package/core/file_mentions.py +280 -280
- package/core/interaction.py +411 -411
- package/core/loop.py +2566 -2566
- package/core/memory.py +482 -482
- package/core/pipeline_models.py +190 -190
- package/core/provider_errors.py +274 -234
- package/core/reasoning/authorization.py +130 -130
- package/core/reasoning/base.py +219 -219
- package/core/reasoning/confidence_scoring.py +484 -484
- package/core/reasoning/events.py +149 -149
- package/core/reasoning/orchestrator.py +1561 -1561
- package/core/reasoning/output_writer.py +345 -345
- package/core/reasoning/payload_validation.py +524 -524
- package/core/reasoning/pipeline_storage.py +427 -427
- package/core/reasoning/scholar.py +467 -458
- package/core/reasoning/source_corpus.py +433 -433
- package/core/reasoning/source_scoring.py +855 -855
- package/core/replay.py +315 -315
- package/core/shell_sessions.py +1553 -1553
- package/credentials.py +307 -307
- package/database.py +333 -333
- package/docs/PRIVACY.md +78 -78
- package/docs/SECURITY.md +114 -108
- package/docs/THIRD_PARTY_NOTICES.md +148 -148
- package/env_secrets.py +118 -118
- package/json_store.py +343 -343
- package/logging_setup.py +295 -295
- package/main.py +3433 -3433
- package/mcp_client/client.py +780 -733
- package/mcp_client/config.py +484 -484
- package/mcp_client/registration.py +343 -343
- package/memories/manager.py +147 -147
- package/memories/tui_commands.py +319 -239
- package/package.json +303 -303
- package/project_init/config_files.py +282 -282
- package/project_init/generator.py +728 -728
- package/project_init/manifest.py +418 -418
- package/project_init/tui_commands.py +147 -147
- package/prompts/critic_pass.md +24 -24
- package/prompts/revalidate.md +25 -25
- package/prompts/revise.md +17 -17
- package/prompts/source_grounding.md +66 -66
- package/prompts/system_prompts.py +316 -316
- package/providers.json.example +94 -94
- package/pyproject.toml +149 -149
- package/requirements.txt +314 -295
- package/safety/policy_enforcement.py +1082 -1082
- package/security/askpass.py +419 -419
- package/security/capability.py +207 -207
- package/security/confine.py +484 -484
- package/security/hosted.py +182 -182
- package/security/permissions.py +237 -237
- package/security/protected_paths.py +501 -501
- package/security/sandbox.py +4108 -4108
- package/skills/builtin/math/formal-specification.md +67 -67
- package/skills/builtin/math/numerical-methods.md +66 -66
- package/skills/builtin/research/experiment-design.md +62 -62
- package/skills/builtin/research/reproducibility.md +55 -55
- package/skills/builtin/research/source-evaluation.md +70 -70
- package/skills/builtin/research/statistical-inference.md +63 -63
- package/skills/builtin/research/technical-writing.md +59 -59
- package/skills/builtin/software/code-review.md +61 -61
- package/skills/builtin/software/debugging.md +61 -61
- package/skills/builtin/software/test-design.md +67 -67
- package/skills/tui_commands.py +110 -110
- package/storage.py +1338 -1338
- package/tools/base.py +465 -465
- package/tools/builtin/_math_common.py +667 -667
- package/tools/builtin/_net_common.py +1145 -267
- package/tools/builtin/_page_text.py +490 -0
- package/tools/builtin/_pdf_text.py +113 -0
- package/tools/builtin/arxiv.py +685 -681
- package/tools/builtin/fetch_url.py +639 -371
- package/tools/builtin/file_ops.py +720 -720
- package/tools/builtin/geometry.py +184 -184
- package/tools/builtin/load_skill.py +76 -76
- package/tools/builtin/pin.py +227 -227
- package/tools/builtin/probability_stats.py +224 -224
- package/tools/builtin/project_docs.py +464 -464
- package/tools/builtin/remember.py +175 -175
- package/tools/builtin/shell.py +980 -980
- package/tools/builtin/todo.py +149 -149
- package/tools/builtin/web_search.py +402 -328
- package/tools/context.py +159 -159
- package/tools/isolation.py +387 -387
- package/tools/registry.py +1252 -1242
- package/tui/app.py +8372 -8307
- package/tui/app.tcss +754 -739
- package/tui/commands.py +26 -26
- package/tui/diffs.py +286 -286
- package/tui/history.py +128 -128
- package/tui/hosted_driver.py +102 -102
- package/tui/markdown.py +1329 -1329
- package/tui/meters.py +364 -364
- package/tui/ravens.py +146 -146
- package/tui/screens.py +1255 -1197
- package/tui/themes.py +599 -599
- package/tui/widgets.py +3861 -3796
package/agents/tui_commands.py
CHANGED
|
@@ -1,146 +1,238 @@
|
|
|
1
|
-
"""
|
|
2
|
-
agents/tui_commands.py
|
|
3
|
-
|
|
4
|
-
ROADMAP_v2 §18, D6 user-initiated half: /agent, /goal and /grill-me
|
|
5
|
-
register into §16's slash registry. The shell hosts the commands; this
|
|
6
|
-
section owns them -- the same mechanism-vs-policy split tools/registry.py
|
|
7
|
-
uses for tools. TUI-only for now (CLI stays unchanged per the §18 scope
|
|
8
|
-
decision); the model-initiated half lives in subagent_tool.py and works
|
|
9
|
-
in every shell.
|
|
10
|
-
|
|
11
|
-
Handlers receive the app object from tui.commands.dispatch(); this module
|
|
12
|
-
deliberately does NOT import tui.app, so app.py can import it without a
|
|
13
|
-
cycle.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
from agents.manager import GRILL_ME_TASK, manager
|
|
17
|
-
from tui.commands import bind
|
|
18
|
-
from tui.commands import registry as commands
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def _cmd_agent(app, args: str) -> None:
|
|
22
|
-
"""Session-scoped active agent: subsequent turns run under the
|
|
23
|
-
agent's body, model/provider/max_steps overrides, and ToolContext,
|
|
24
|
-
until /agent default or another switch."""
|
|
25
|
-
if not args:
|
|
26
|
-
current = app.active_agent.name if app.active_agent else "default"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
f"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
app
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
"""
|
|
2
|
+
agents/tui_commands.py
|
|
3
|
+
|
|
4
|
+
ROADMAP_v2 §18, D6 user-initiated half: /agent, /goal and /grill-me
|
|
5
|
+
register into §16's slash registry. The shell hosts the commands; this
|
|
6
|
+
section owns them -- the same mechanism-vs-policy split tools/registry.py
|
|
7
|
+
uses for tools. TUI-only for now (CLI stays unchanged per the §18 scope
|
|
8
|
+
decision); the model-initiated half lives in subagent_tool.py and works
|
|
9
|
+
in every shell.
|
|
10
|
+
|
|
11
|
+
Handlers receive the app object from tui.commands.dispatch(); this module
|
|
12
|
+
deliberately does NOT import tui.app, so app.py can import it without a
|
|
13
|
+
cycle.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from agents.manager import GRILL_ME_TASK, manager
|
|
17
|
+
from tui.commands import bind
|
|
18
|
+
from tui.commands import registry as commands
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _cmd_agent(app, args: str) -> None:
|
|
22
|
+
"""Session-scoped active agent: subsequent turns run under the
|
|
23
|
+
agent's body, model/provider/max_steps overrides, and ToolContext,
|
|
24
|
+
until /agent default or another switch."""
|
|
25
|
+
if not args:
|
|
26
|
+
current = app.active_agent.name if app.active_agent else "default"
|
|
27
|
+
stops, _ = cycle_stops()
|
|
28
|
+
cycle = (" shift+tab in the prompt steps through "
|
|
29
|
+
f"{' → '.join(_stop_name(stop) for stop in stops)}."
|
|
30
|
+
if len(stops) > 1 else "")
|
|
31
|
+
app._transcript.write_system(
|
|
32
|
+
f"Active agent: {current}. "
|
|
33
|
+
f"Available: {', '.join(manager.names()) or 'none'}. "
|
|
34
|
+
f"/agent <name> to switch, /agent default to clear.{cycle}"
|
|
35
|
+
)
|
|
36
|
+
return
|
|
37
|
+
if args == "default":
|
|
38
|
+
_switch_to(app, None)
|
|
39
|
+
return
|
|
40
|
+
agent = manager.get(args)
|
|
41
|
+
if agent is None:
|
|
42
|
+
app._transcript.write_error(
|
|
43
|
+
f"Unknown agent {args!r}. "
|
|
44
|
+
f"Available: {', '.join(manager.names()) or 'none'}."
|
|
45
|
+
)
|
|
46
|
+
return
|
|
47
|
+
_switch_to(app, agent)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _switch_to(app, agent) -> None:
|
|
51
|
+
"""Make `agent` the active one, or clear it with None.
|
|
52
|
+
|
|
53
|
+
ONE path for /agent and for shift+tab (ROADMAP_v3 §59), so the two
|
|
54
|
+
cannot differ in what a switch says, re-checks or repaints. A turn
|
|
55
|
+
already running keeps the agent it started with: `agent_turn` reads
|
|
56
|
+
`app.active_agent` once, when the turn begins.
|
|
57
|
+
"""
|
|
58
|
+
app.active_agent = agent
|
|
59
|
+
if agent is None:
|
|
60
|
+
app._transcript.write_system("Active agent cleared — default harness.")
|
|
61
|
+
else:
|
|
62
|
+
app._transcript.write_system(
|
|
63
|
+
f"Active agent: {agent.name} — {agent.description}")
|
|
64
|
+
_note_skills_under_new_context(app)
|
|
65
|
+
_refresh_agent_panel(app)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# ---------------------------------------------------------------------------
|
|
69
|
+
# ---- shift+tab: the agent cycle (ROADMAP_v3 §59, UI2 / UI3) ----------------
|
|
70
|
+
# ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
DEFAULT_STOP = "default"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _stop_name(stop) -> str:
|
|
76
|
+
return DEFAULT_STOP if stop is None else stop.name
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def cycle_stops() -> tuple[list, list]:
|
|
80
|
+
"""The stops shift+tab walks, and the configured names it had to skip.
|
|
81
|
+
|
|
82
|
+
The first stop is ALWAYS None, the plain harness (UI6), and the rest
|
|
83
|
+
are `config.AGENT_CYCLE` in its own order. A "default" entry and a
|
|
84
|
+
repeated name add nothing. A name no tier provides is skipped, because
|
|
85
|
+
the user and project tiers are only known at runtime; the caller says
|
|
86
|
+
so. Read at call time, so a test or a /config edit is seen at once.
|
|
87
|
+
"""
|
|
88
|
+
import config
|
|
89
|
+
|
|
90
|
+
stops, missing, seen = [None], [], {DEFAULT_STOP}
|
|
91
|
+
for name in config.AGENT_CYCLE:
|
|
92
|
+
if name in seen:
|
|
93
|
+
continue
|
|
94
|
+
seen.add(name)
|
|
95
|
+
agent = manager.get(name)
|
|
96
|
+
if agent is None:
|
|
97
|
+
missing.append(name)
|
|
98
|
+
else:
|
|
99
|
+
stops.append(agent)
|
|
100
|
+
return stops, missing
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def can_cycle() -> bool:
|
|
104
|
+
"""Whether shift+tab means "next agent" right now: at least one agent
|
|
105
|
+
beside the default. When it does not, the prompt declines the key and
|
|
106
|
+
Textual's reverse focus gets it, as before §59."""
|
|
107
|
+
stops, _ = cycle_stops()
|
|
108
|
+
return len(stops) > 1
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def cycle_agent(app) -> None:
|
|
112
|
+
"""shift+tab in the prompt: switch to the next stop.
|
|
113
|
+
|
|
114
|
+
From an agent the roster does not list (one picked with /agent), the
|
|
115
|
+
next stop is the first one, the default. A cycle has one start, and
|
|
116
|
+
that is the stop a user can always find again.
|
|
117
|
+
"""
|
|
118
|
+
stops, missing = cycle_stops()
|
|
119
|
+
_note_missing(app, missing)
|
|
120
|
+
if len(stops) < 2:
|
|
121
|
+
return
|
|
122
|
+
names = [_stop_name(stop) for stop in stops]
|
|
123
|
+
current = _stop_name(app.active_agent)
|
|
124
|
+
following = (names.index(current) + 1) % len(stops) \
|
|
125
|
+
if current in names else 0
|
|
126
|
+
_switch_to(app, stops[following])
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _note_missing(app, missing: list) -> None:
|
|
130
|
+
"""Name each skipped roster entry once per session, not once per press.
|
|
131
|
+
Kept on the app, so a new session starts with a clean slate."""
|
|
132
|
+
noted = getattr(app, "_agent_cycle_noted", None)
|
|
133
|
+
if noted is None:
|
|
134
|
+
noted = set()
|
|
135
|
+
app._agent_cycle_noted = noted
|
|
136
|
+
for name in missing:
|
|
137
|
+
if name in noted:
|
|
138
|
+
continue
|
|
139
|
+
noted.add(name)
|
|
140
|
+
app._transcript.write_system(
|
|
141
|
+
f"agent_cycle in config.yaml names {name!r}, which no agent tier "
|
|
142
|
+
"provides here, so shift+tab skips it.")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _refresh_agent_panel(app) -> None:
|
|
146
|
+
"""Batch 59: the panel's root row IS the active agent, so a
|
|
147
|
+
switch has to repaint it.
|
|
148
|
+
|
|
149
|
+
getattr rather than a direct call because this module is driven
|
|
150
|
+
against stub apps in tests/test_agents.py that carry a transcript
|
|
151
|
+
and nothing else -- and /agent must not start depending on a
|
|
152
|
+
sidebar widget to do its actual job."""
|
|
153
|
+
refresh = getattr(app, "refresh_agent_panel", None)
|
|
154
|
+
if refresh is not None:
|
|
155
|
+
refresh()
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _note_skills_under_new_context(app) -> None:
|
|
159
|
+
"""K2's activation note is computed against the context active at
|
|
160
|
+
activation time; an /agent switch changes the context for every
|
|
161
|
+
subsequent turn, so re-check active skills and say what is now
|
|
162
|
+
denied (review §19-20 f21). Advisory only -- enforcement still
|
|
163
|
+
happens per call via is_tool_allowed."""
|
|
164
|
+
from skills.manager import manager as skill_manager
|
|
165
|
+
|
|
166
|
+
context = (manager.active_context(app.active_agent)
|
|
167
|
+
if app.active_agent is not None else None)
|
|
168
|
+
label = app.active_agent.name if app.active_agent is not None else "default"
|
|
169
|
+
for name in app.active_skills:
|
|
170
|
+
skill = skill_manager.get(name)
|
|
171
|
+
if skill is None:
|
|
172
|
+
continue
|
|
173
|
+
missing = skill_manager.missing_tools(skill, context)
|
|
174
|
+
if missing:
|
|
175
|
+
app._transcript.write_system(
|
|
176
|
+
f"Note: {name} expects {', '.join(missing)}, which are "
|
|
177
|
+
f"not available under agent {label}.")
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _cmd_goal(app, args: str) -> None:
|
|
181
|
+
"""Persistent per-thread objective (extra_data). Injected into every
|
|
182
|
+
turn's system prompt in ANY shell; the banner mirrors it here.
|
|
183
|
+
|
|
184
|
+
#113: the read and clear paths go through `app._memory`, NOT
|
|
185
|
+
`app.memory` -- same rule refresh_goal_banner's comment states.
|
|
186
|
+
Constructing a ConversationMemory persists a thread row, so answering
|
|
187
|
+
"there is no goal" (or clearing one on a session that has none) must
|
|
188
|
+
not be what creates the thread. Only SETTING a goal touches
|
|
189
|
+
app.memory: the user is putting state on a thread, so a thread is
|
|
190
|
+
warranted."""
|
|
191
|
+
if args == "clear":
|
|
192
|
+
if app._memory is None:
|
|
193
|
+
app._transcript.write_system("No goal set.")
|
|
194
|
+
else:
|
|
195
|
+
app.memory.set_extra("goal", None)
|
|
196
|
+
app._transcript.write_system("Goal cleared.")
|
|
197
|
+
elif args:
|
|
198
|
+
app.memory.set_extra("goal", args)
|
|
199
|
+
app._transcript.write_system(f"Goal set: {args}")
|
|
200
|
+
else:
|
|
201
|
+
goal = app._memory.extra.get("goal") if app._memory else None
|
|
202
|
+
if goal:
|
|
203
|
+
app._transcript.write_system(f"Current goal: {goal}")
|
|
204
|
+
else:
|
|
205
|
+
app._transcript.write_system(
|
|
206
|
+
"No goal set. /goal <text> to set one, /goal clear to remove.")
|
|
207
|
+
app.refresh_goal_banner()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _cmd_grill(app, args: str) -> None:
|
|
211
|
+
"""One turn in the CURRENT thread under the grill-me agent's system
|
|
212
|
+
prompt -- it reads the live history directly (no digest loss)."""
|
|
213
|
+
if app._busy:
|
|
214
|
+
app._transcript.write_error(
|
|
215
|
+
"Still working — wait for this turn to finish.")
|
|
216
|
+
return
|
|
217
|
+
agent = manager.get("grill-me")
|
|
218
|
+
if agent is None:
|
|
219
|
+
app._transcript.write_error("grill-me agent not found.")
|
|
220
|
+
return
|
|
221
|
+
app._transcript.write_user("/grill-me")
|
|
222
|
+
# run_one_shot owns the WHOLE assembly (#170): the channel, the
|
|
223
|
+
# catalog facts and the run must come from one answer, so nothing is
|
|
224
|
+
# decided here. (Review f19's "no context, deliberately" answered a
|
|
225
|
+
# question §25 R15 replaced -- what matters now is not which policy
|
|
226
|
+
# governs but whether anything can answer, and only the run knows.)
|
|
227
|
+
app.run_one_shot(agent, GRILL_ME_TASK)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def register_agent_commands() -> None:
|
|
231
|
+
"""Idempotent — registering by name overwrites, matching §16's
|
|
232
|
+
register_builtin_commands()."""
|
|
233
|
+
for command in (
|
|
234
|
+
bind("agent", _cmd_agent),
|
|
235
|
+
bind("goal", _cmd_goal),
|
|
236
|
+
bind("grill-me", _cmd_grill),
|
|
237
|
+
):
|
|
238
|
+
commands.register(command)
|