@yahyahammad/venastine 0.2.0 → 0.3.9
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 +9 -4
- package/CONFIG_ARCHITECTURE.md +2030 -0
- package/LICENSE +201 -201
- package/NOTICE +1 -1
- package/README.md +1034 -895
- package/agents/builtin/build.md +73 -0
- package/agents/builtin/compactor.md +75 -75
- package/agents/builtin/explore.md +77 -77
- package/agents/builtin/general.md +80 -0
- package/agents/builtin/pipeline-reviewer.md +100 -100
- package/agents/builtin/plan.md +106 -88
- package/agents/builtin/review.md +74 -74
- package/agents/builtin/test.md +65 -0
- package/agents/builtin/writer.md +67 -0
- package/agents/manager.py +68 -2
- package/agents/subagent_tool.py +472 -238
- package/agents/tui_commands.py +238 -151
- package/bin/venastine.mjs +150 -4
- package/bin/venastine.py +71 -0
- package/cli_commands.py +838 -0
- package/config.py +95 -1198
- package/config.yaml +1103 -0
- package/config_edit.py +1301 -0
- package/config_schema.py +971 -0
- package/config_update.py +749 -0
- package/core/agent_activity.py +256 -118
- package/core/ansi.py +452 -0
- package/core/approval.py +137 -115
- 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 +2715 -1559
- package/core/commands.py +460 -0
- package/core/compaction.py +1735 -971
- package/core/config_loader.py +1982 -1563
- package/core/connect.py +686 -0
- package/core/events.py +123 -61
- package/core/file_mentions.py +280 -0
- package/core/interaction.py +411 -328
- package/core/line_pattern.py +128 -0
- package/core/loop.py +2566 -1490
- package/core/memory.py +482 -370
- package/core/pipeline_models.py +190 -176
- package/core/provider_errors.py +234 -0
- package/core/reasoning/authorization.py +130 -130
- package/core/reasoning/base.py +219 -219
- package/core/reasoning/confidence_scoring.py +484 -468
- package/core/reasoning/events.py +149 -149
- package/core/reasoning/json_retry.py +19 -1
- package/core/reasoning/orchestrator.py +1561 -1382
- package/core/reasoning/output_writer.py +345 -286
- package/core/reasoning/payload_validation.py +524 -398
- package/core/reasoning/pipeline_storage.py +88 -22
- package/core/reasoning/review.py +659 -615
- package/core/reasoning/scholar.py +458 -434
- package/core/reasoning/source_corpus.py +433 -327
- package/core/reasoning/source_scoring.py +855 -855
- package/core/replay.py +315 -183
- 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 +148 -20
- package/database.py +333 -252
- package/{PRIVACY.md → docs/PRIVACY.md} +78 -66
- package/docs/SECURITY.md +108 -0
- package/docs/THIRD_PARTY_NOTICES.md +148 -0
- package/env_secrets.py +50 -9
- package/json_store.py +343 -123
- package/logging_setup.py +295 -185
- package/main.py +3433 -1961
- package/mcp_client/client.py +733 -499
- package/mcp_client/config.py +126 -21
- package/mcp_client/registration.py +343 -182
- package/memories/manager.py +147 -132
- package/memories/tui_commands.py +319 -244
- package/package.json +303 -73
- package/project_init/config_files.py +282 -278
- package/project_init/generator.py +728 -564
- package/project_init/manifest.py +18 -6
- package/project_init/tui_commands.py +147 -144
- package/prompts/critic_pass.md +24 -24
- package/prompts/revalidate.md +25 -25
- package/prompts/revise.md +2 -0
- package/prompts/source_grounding.md +66 -66
- package/prompts/system_prompts.py +316 -262
- package/providers.json.example +4 -2
- package/pyproject.toml +149 -100
- package/requirements.txt +295 -72
- package/safety/policy_enforcement.py +1082 -746
- package/security/askpass.py +419 -0
- package/security/capability.py +207 -177
- package/security/confine.py +484 -0
- package/security/hosted.py +182 -0
- package/security/permissions.py +237 -190
- package/security/posture.py +124 -12
- package/security/protected_paths.py +501 -309
- package/security/sandbox.py +4108 -985
- package/security/secrets.py +855 -0
- 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 -111
- package/storage.py +1338 -1005
- package/tools/base.py +161 -1
- package/tools/builtin/_math_common.py +667 -377
- package/tools/builtin/_net_common.py +225 -19
- package/tools/builtin/arxiv.py +497 -39
- package/tools/builtin/ask_user.py +231 -213
- package/tools/builtin/discrete_math.py +35 -4
- package/tools/builtin/fetch_url.py +371 -153
- package/tools/builtin/file_ops.py +720 -412
- package/tools/builtin/geometry.py +48 -12
- package/tools/builtin/get_time.py +2 -2
- package/tools/builtin/linear_algebra.py +66 -23
- package/tools/builtin/load_skill.py +76 -66
- package/tools/builtin/logic.py +171 -12
- package/tools/builtin/pin.py +227 -193
- package/tools/builtin/probability_stats.py +12 -16
- package/tools/builtin/project_docs.py +464 -405
- package/tools/builtin/remember.py +175 -158
- package/tools/builtin/shell.py +980 -461
- package/tools/builtin/shell_sessions.py +613 -0
- package/tools/builtin/symbolic_math.py +80 -10
- package/tools/builtin/todo.py +149 -147
- package/tools/builtin/web_search.py +191 -13
- package/tools/context.py +159 -136
- package/tools/isolation.py +107 -34
- package/tools/registry.py +1242 -925
- package/tui/app.py +8318 -4100
- package/tui/app.tcss +747 -556
- package/tui/commands.py +26 -170
- package/tui/diffs.py +34 -13
- package/tui/history.py +128 -128
- package/tui/hosted_driver.py +102 -0
- package/tui/markdown.py +1329 -1279
- package/tui/meters.py +364 -268
- package/tui/ravens.py +146 -146
- package/tui/screens.py +1255 -943
- package/tui/themes.py +599 -559
- package/tui/widgets.py +3813 -2332
- package/SECURITY.md +0 -88
- package/THIRD_PARTY_NOTICES.md +0 -100
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""
|
|
2
|
+
core/line_pattern.py
|
|
3
|
+
|
|
4
|
+
The one place a model-supplied pattern is compiled and matched (ROADMAP_v3
|
|
5
|
+
§49, SS8). A monitor session wakes the agent when a line of a program's
|
|
6
|
+
output matches a pattern the MODEL wrote -- two untrusted inputs meeting
|
|
7
|
+
inside the harness's own process, on a thread beside the TUI's.
|
|
8
|
+
|
|
9
|
+
WHY NOT `re`. Measured on CPython 3.13 (batch 93): `re.match(r"(a+)+$",
|
|
10
|
+
"a" * 25 + "b")` took 1.88 s, and a sibling thread's ticker stalled for
|
|
11
|
+
1.98 s of it. `re` holds the GIL for the whole match, so a backtracking
|
|
12
|
+
pattern freezes EVERY thread, and each extra character doubles the time. No
|
|
13
|
+
per-line budget enforced from inside the same process can bound that.
|
|
14
|
+
|
|
15
|
+
re2 matches in time linear in the input, releases the GIL while it runs,
|
|
16
|
+
and refuses the constructs that make backtracking possible: a backreference
|
|
17
|
+
or a lookaround is a compile error, and the error is what the agent is told.
|
|
18
|
+
|
|
19
|
+
THREE GUARDS, each measured against google-re2 1.1.20251105:
|
|
20
|
+
|
|
21
|
+
provenance another package ships a module named `re2` that falls back to
|
|
22
|
+
`re` for what it cannot handle, which would bring the freeze
|
|
23
|
+
back under a name that looks safe. The module must be the one
|
|
24
|
+
the `google-re2` distribution installed, or this module
|
|
25
|
+
refuses to import. Checked by locating that distribution's
|
|
26
|
+
own `re2/__init__.py` (0.6 ms), not by
|
|
27
|
+
`packages_distributions()`, which scans every installed
|
|
28
|
+
package (593 ms, on a path every launch takes).
|
|
29
|
+
log_errors OFF. re2's C++ side reports every compile error on stderr
|
|
30
|
+
through Abseil, and anything written to stderr while Textual
|
|
31
|
+
is up paints over the screen.
|
|
32
|
+
max_mem set explicitly to re2's own 8 MiB default, so the bound on
|
|
33
|
+
what one compiled pattern may cost is a decision rather than
|
|
34
|
+
a library default that can move. A pattern past it is refused
|
|
35
|
+
("pattern too large").
|
|
36
|
+
|
|
37
|
+
Imports nothing first-party, so a session backend or a tool can use it
|
|
38
|
+
without an import cycle.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from __future__ import annotations
|
|
42
|
+
|
|
43
|
+
import importlib.metadata
|
|
44
|
+
import os
|
|
45
|
+
|
|
46
|
+
import re2
|
|
47
|
+
|
|
48
|
+
_DISTRIBUTION = "google-re2"
|
|
49
|
+
_MAX_MEM = 8 << 20
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class PatternError(ValueError):
|
|
53
|
+
"""A pattern re2 will not compile, carrying re2's own reason."""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _assert_provenance() -> None:
|
|
57
|
+
"""Refuse a `re2` module that the `google-re2` distribution did not
|
|
58
|
+
install. Raises ImportError, because a module that cannot vouch for its
|
|
59
|
+
engine should fail where it is imported rather than at the first match."""
|
|
60
|
+
try:
|
|
61
|
+
dist = importlib.metadata.distribution(_DISTRIBUTION)
|
|
62
|
+
expected = os.path.realpath(str(dist.locate_file("re2/__init__.py")))
|
|
63
|
+
except importlib.metadata.PackageNotFoundError:
|
|
64
|
+
expected = None
|
|
65
|
+
actual = os.path.realpath(getattr(re2, "__file__", "") or "")
|
|
66
|
+
if expected is None or expected != actual:
|
|
67
|
+
raise ImportError(
|
|
68
|
+
f"core/line_pattern.py needs the `re2` module from the "
|
|
69
|
+
f"{_DISTRIBUTION} distribution, and the one imported is "
|
|
70
|
+
f"{actual or 'unknown'}. Another package's `re2` can fall back "
|
|
71
|
+
f"to Python's `re`, which freezes every thread on a backtracking "
|
|
72
|
+
f"pattern. Install it with: pip install {_DISTRIBUTION}")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
_assert_provenance()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _options():
|
|
79
|
+
options = re2.Options()
|
|
80
|
+
options.log_errors = False
|
|
81
|
+
options.max_mem = _MAX_MEM
|
|
82
|
+
return options
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _reason(error: Exception) -> str:
|
|
86
|
+
"""re2's message as text. The wrapper raises it as bytes."""
|
|
87
|
+
detail = error.args[0] if error.args else ""
|
|
88
|
+
if isinstance(detail, bytes):
|
|
89
|
+
detail = detail.decode("utf-8", "replace")
|
|
90
|
+
return str(detail) or "the pattern could not be compiled"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class LinePattern:
|
|
94
|
+
"""A compiled monitor pattern. `search` is the only question asked."""
|
|
95
|
+
|
|
96
|
+
__slots__ = ("source", "_compiled")
|
|
97
|
+
|
|
98
|
+
def __init__(self, source: str, compiled) -> None:
|
|
99
|
+
self.source = source
|
|
100
|
+
self._compiled = compiled
|
|
101
|
+
|
|
102
|
+
def search(self, line: str) -> bool:
|
|
103
|
+
"""Whether the pattern occurs anywhere in *line*."""
|
|
104
|
+
return self._compiled.search(line) is not None
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def compile_pattern(pattern) -> LinePattern:
|
|
108
|
+
"""Compile *pattern* for line matching, or raise PatternError.
|
|
109
|
+
|
|
110
|
+
Total over whatever the model sent: the value arrives from a tool call's
|
|
111
|
+
params, so a non-string is refused here rather than raising a TypeError
|
|
112
|
+
out of re2.
|
|
113
|
+
"""
|
|
114
|
+
if not isinstance(pattern, str) or not pattern:
|
|
115
|
+
raise PatternError("a pattern must be a non-empty string")
|
|
116
|
+
try:
|
|
117
|
+
return LinePattern(pattern, re2.compile(pattern, _options()))
|
|
118
|
+
except re2.error as e:
|
|
119
|
+
raise PatternError(_reason(e)) from None
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def validate(pattern) -> str | None:
|
|
123
|
+
"""Why *pattern* cannot be a monitor pattern, or None when it can."""
|
|
124
|
+
try:
|
|
125
|
+
compile_pattern(pattern)
|
|
126
|
+
except PatternError as e:
|
|
127
|
+
return str(e)
|
|
128
|
+
return None
|