@yahyahammad/venastine 0.1.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 +249 -93
- 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 +280 -23
- package/agents/tui_commands.py +31 -21
- 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 +256 -0
- 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 +1249 -82
- package/core/commands.py +454 -0
- package/core/compaction.py +1735 -959
- 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 +2566 -1353
- package/core/memory.py +482 -370
- 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 +315 -167
- 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 +1672 -198
- 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 +21 -14
- package/package.json +303 -73
- 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 +149 -100
- package/requirements.txt +252 -29
- package/safety/policy_enforcement.py +1082 -682
- 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 +1338 -1005
- 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 +374 -29
- package/tui/app.py +5281 -397
- package/tui/app.tcss +290 -9
- package/tui/commands.py +26 -61
- package/tui/diffs.py +286 -265
- package/tui/history.py +128 -0
- package/tui/hosted_driver.py +102 -0
- package/tui/markdown.py +1329 -0
- package/tui/meters.py +364 -0
- package/tui/screens.py +346 -92
- package/tui/themes.py +599 -366
- package/tui/widgets.py +2673 -116
- package/SECURITY.md +0 -88
- package/THIRD_PARTY_NOTICES.md +0 -100
package/tui/history.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""
|
|
2
|
+
tui/history.py
|
|
3
|
+
|
|
4
|
+
Batch 63. What you already sent, so a misfire does not cost the typing.
|
|
5
|
+
|
|
6
|
+
PURE, like `tui/markdown.py`, `tui/diffs.py` and `tui/meters.py` beside it:
|
|
7
|
+
no I/O, no `core/` import, no widget, no clock. `tui/app.py` owns the keys
|
|
8
|
+
and the box; this owns the arithmetic, so every test here is a function
|
|
9
|
+
call rather than a pilot pressing keys at a live TextArea.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# A hundred prompts is more than a sitting produces and costs nothing to
|
|
13
|
+
# hold; the cap exists so a very long session cannot grow this without
|
|
14
|
+
# bound, not because anyone will reach it.
|
|
15
|
+
HISTORY_LIMIT = 100
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class PromptHistory:
|
|
19
|
+
"""The prompts submitted this session, and where a browse has got to.
|
|
20
|
+
|
|
21
|
+
Session-scoped and in memory: it survives `/new` and `/resume` because
|
|
22
|
+
it records what the PERSON typed, not what a thread holds, and a
|
|
23
|
+
misfire bad enough to start a new thread is exactly when the text is
|
|
24
|
+
wanted back. Nothing here is persisted.
|
|
25
|
+
|
|
26
|
+
**Both movers take the box's current text, and that one parameter is
|
|
27
|
+
the whole design.** The history remembers what it last handed out, so
|
|
28
|
+
a `current` that differs from it means the user has typed since --
|
|
29
|
+
which ends the browse and starts a new one with `current` saved as the
|
|
30
|
+
draft. Recall a prompt, edit it, press previous again: the edit is not
|
|
31
|
+
discarded, it becomes the thing `following()` hands back.
|
|
32
|
+
|
|
33
|
+
The alternative was to hook `PromptInput.on_text_area_changed`, where
|
|
34
|
+
batch 55's `_api_edit` flag already separates assignment from typing.
|
|
35
|
+
It is the wrong seam: that message is POSTED, so the app would be
|
|
36
|
+
holding a flag across an async hop, and the panel's own
|
|
37
|
+
`SuggestionsChanged` fires on both halves of the split anyway. Asking
|
|
38
|
+
the box what it holds, at the only two moments it matters, needs
|
|
39
|
+
neither.
|
|
40
|
+
|
|
41
|
+
`previous()` STOPS at the oldest entry rather than wrapping. A
|
|
42
|
+
suggestion panel wraps because its list is a menu; this is a walk
|
|
43
|
+
backwards through time, and arriving at the start of it by pressing a
|
|
44
|
+
key twelve times should not deposit you at the end.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(self) -> None:
|
|
48
|
+
self._entries: list[str] = [] # oldest first
|
|
49
|
+
# The index being shown, or None when the box holds a live draft.
|
|
50
|
+
self._cursor = None
|
|
51
|
+
self._draft = ""
|
|
52
|
+
# The exact string last handed out. `None` while not browsing.
|
|
53
|
+
self._served = None
|
|
54
|
+
|
|
55
|
+
def __len__(self) -> int:
|
|
56
|
+
"""How many prompts are recallable. `check_action` reads this."""
|
|
57
|
+
return len(self._entries)
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def browsing(self) -> bool:
|
|
61
|
+
"""True while a recalled entry is being shown. For tests."""
|
|
62
|
+
return self._cursor is not None
|
|
63
|
+
|
|
64
|
+
def remember(self, text: str) -> None:
|
|
65
|
+
"""Record a submitted prompt and end any browse in progress.
|
|
66
|
+
|
|
67
|
+
Slash commands included: a mistyped `/research --attended --grant`
|
|
68
|
+
is the worst retyping in the shell, and `on_prompt_input_submitted`
|
|
69
|
+
is one funnel for both kinds.
|
|
70
|
+
|
|
71
|
+
A CONSECUTIVE repeat is not appended twice -- sending the same
|
|
72
|
+
thing twice is one thing to walk back past, not two. A repeat with
|
|
73
|
+
something else between them is kept, because the order is the
|
|
74
|
+
record of what happened.
|
|
75
|
+
"""
|
|
76
|
+
if not text:
|
|
77
|
+
return
|
|
78
|
+
if not self._entries or self._entries[-1] != text:
|
|
79
|
+
self._entries.append(text)
|
|
80
|
+
del self._entries[:-HISTORY_LIMIT]
|
|
81
|
+
self._forget_browse()
|
|
82
|
+
|
|
83
|
+
def previous(self, current: str):
|
|
84
|
+
"""The next older prompt, or None when there is nowhere to go.
|
|
85
|
+
|
|
86
|
+
None means the caller writes nothing -- an empty history, or a
|
|
87
|
+
browse already at the oldest entry. The browse state is left
|
|
88
|
+
alone in both cases, so a press at the oldest is inert rather
|
|
89
|
+
than a reset.
|
|
90
|
+
"""
|
|
91
|
+
if not self._entries:
|
|
92
|
+
return None
|
|
93
|
+
if not self._is_browsing(current):
|
|
94
|
+
self._draft = current
|
|
95
|
+
self._cursor = len(self._entries)
|
|
96
|
+
if self._cursor == 0:
|
|
97
|
+
return None
|
|
98
|
+
self._cursor -= 1
|
|
99
|
+
self._served = self._entries[self._cursor]
|
|
100
|
+
return self._served
|
|
101
|
+
|
|
102
|
+
def following(self, current: str):
|
|
103
|
+
"""The next newer prompt, or the draft once past the newest.
|
|
104
|
+
|
|
105
|
+
None when no browse is in progress, which is what makes the key
|
|
106
|
+
inert on a box the user is typing into fresh: there is nothing
|
|
107
|
+
newer than what they are already looking at.
|
|
108
|
+
"""
|
|
109
|
+
if not self._is_browsing(current):
|
|
110
|
+
return None
|
|
111
|
+
self._cursor += 1
|
|
112
|
+
if self._cursor < len(self._entries):
|
|
113
|
+
self._served = self._entries[self._cursor]
|
|
114
|
+
return self._served
|
|
115
|
+
draft = self._draft
|
|
116
|
+
self._forget_browse()
|
|
117
|
+
return draft
|
|
118
|
+
|
|
119
|
+
# -- internals ----------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
def _is_browsing(self, current: str) -> bool:
|
|
122
|
+
"""Whether `current` is still the string this last handed out."""
|
|
123
|
+
return self._cursor is not None and current == self._served
|
|
124
|
+
|
|
125
|
+
def _forget_browse(self) -> None:
|
|
126
|
+
self._cursor = None
|
|
127
|
+
self._draft = ""
|
|
128
|
+
self._served = None
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""
|
|
2
|
+
tui/hosted_driver.py
|
|
3
|
+
|
|
4
|
+
ROADMAP_v3 §79 (HD13). Textual's web driver, plus the three packets a hosted
|
|
5
|
+
bridge sends back about a ModelScope sign-in -- on either site -- it is
|
|
6
|
+
completing for this session.
|
|
7
|
+
|
|
8
|
+
The bridge -- `deploy/hosted/supervisor.py` -- runs every hosted session under
|
|
9
|
+
this driver. It is the only writer of the session's stdin, and everything a
|
|
10
|
+
browser sends reaches it there as screen input (a `D` packet), never as a
|
|
11
|
+
meta packet: so a `venastine_*` packet arriving here was written by the
|
|
12
|
+
bridge, and a page cannot forge one. The app still accepts a credential only
|
|
13
|
+
for the sign-in it is waiting for (tui/app.py), because "only the bridge can
|
|
14
|
+
send this" is a property of the deployment, and the app should not depend on
|
|
15
|
+
it alone.
|
|
16
|
+
|
|
17
|
+
Outside a hosted session nothing selects this driver, and nothing sends it
|
|
18
|
+
these packets.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from textual.drivers.web_driver import WebDriver
|
|
24
|
+
from textual.message import Message
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BridgeSignInUrl(Message):
|
|
28
|
+
"""The bridge started a sign-in: the consent page to open."""
|
|
29
|
+
|
|
30
|
+
def __init__(self, request: str, url: str) -> None:
|
|
31
|
+
super().__init__()
|
|
32
|
+
self.request = request
|
|
33
|
+
self.url = url
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class BridgeCredential(Message):
|
|
37
|
+
"""The bridge traded the pasted code for a token. Never logged: the
|
|
38
|
+
debug breadcrumbs name message types, not their fields (batch 78)."""
|
|
39
|
+
|
|
40
|
+
def __init__(self, request: str, token: str) -> None:
|
|
41
|
+
super().__init__()
|
|
42
|
+
self.request = request
|
|
43
|
+
self.token = token
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class BridgeSignInFailed(Message):
|
|
47
|
+
"""The sign-in did not finish; `retry` when the paste may be tried
|
|
48
|
+
again in the same flow."""
|
|
49
|
+
|
|
50
|
+
def __init__(self, request: str, reason: str, retry: bool) -> None:
|
|
51
|
+
super().__init__()
|
|
52
|
+
self.request = request
|
|
53
|
+
self.reason = reason
|
|
54
|
+
self.retry = retry
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def bridge_message(packet_type: str, payload: dict) -> Message | None:
|
|
58
|
+
"""The app message for one of the bridge's sign-in packets, or None for
|
|
59
|
+
any other packet -- including one of these with a field missing."""
|
|
60
|
+
request = payload.get("id")
|
|
61
|
+
if not isinstance(request, str):
|
|
62
|
+
return None
|
|
63
|
+
if packet_type == "venastine_sign_in_url":
|
|
64
|
+
url = payload.get("url")
|
|
65
|
+
if isinstance(url, str) and url.startswith("https://"):
|
|
66
|
+
return BridgeSignInUrl(request, url)
|
|
67
|
+
elif packet_type == "venastine_credential":
|
|
68
|
+
token = payload.get("token")
|
|
69
|
+
if isinstance(token, str) and token:
|
|
70
|
+
return BridgeCredential(request, token)
|
|
71
|
+
elif packet_type == "venastine_sign_in_failed":
|
|
72
|
+
return BridgeSignInFailed(request, str(payload.get("reason") or
|
|
73
|
+
"The sign-in failed."),
|
|
74
|
+
payload.get("retry") is True)
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class HostedWebDriver(WebDriver):
|
|
79
|
+
"""The web driver a hosted bridge starts its sessions with."""
|
|
80
|
+
|
|
81
|
+
def on_meta(self, packet_type: str, payload: dict[str, object]) -> None:
|
|
82
|
+
message = bridge_message(packet_type, payload)
|
|
83
|
+
if message is not None:
|
|
84
|
+
self._app.post_message(message)
|
|
85
|
+
return
|
|
86
|
+
super().on_meta(packet_type, payload)
|
|
87
|
+
|
|
88
|
+
def send_to_bridge(self, meta: dict) -> None:
|
|
89
|
+
"""One meta packet to the bridge. Call it on the UI thread, which
|
|
90
|
+
is the thread that writes the screen: two threads writing one pipe
|
|
91
|
+
could interleave a packet."""
|
|
92
|
+
self.write_meta(meta)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def send_to_bridge(app, meta: dict) -> bool:
|
|
96
|
+
"""Send `meta` through the app's driver when it is this one; False when
|
|
97
|
+
the session is not running under a bridge that can hear it."""
|
|
98
|
+
driver = getattr(app, "_driver", None)
|
|
99
|
+
if not isinstance(driver, HostedWebDriver):
|
|
100
|
+
return False
|
|
101
|
+
driver.send_to_bridge(meta)
|
|
102
|
+
return True
|