@yahyahammad/venastine 0.1.0
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 +14 -0
- package/LICENSE +201 -0
- package/NOTICE +14 -0
- package/PRIVACY.md +66 -0
- package/README.md +878 -0
- package/SECURITY.md +88 -0
- package/THIRD_PARTY_NOTICES.md +100 -0
- package/agents/builtin/compactor.md +75 -0
- package/agents/builtin/explore.md +77 -0
- package/agents/builtin/grill-me.md +27 -0
- package/agents/builtin/initializer.md +94 -0
- package/agents/builtin/pipeline-reviewer.md +100 -0
- package/agents/builtin/plan.md +88 -0
- package/agents/builtin/review.md +74 -0
- package/agents/manager.py +195 -0
- package/agents/subagent_tool.py +215 -0
- package/agents/tui_commands.py +136 -0
- package/bin/venastine.mjs +382 -0
- package/config.py +1198 -0
- package/core/__init__.py +0 -0
- package/core/approval.py +115 -0
- package/core/client.py +1548 -0
- package/core/compaction.py +959 -0
- package/core/config_loader.py +1563 -0
- package/core/events.py +61 -0
- package/core/interaction.py +328 -0
- package/core/loop.py +1353 -0
- package/core/memory.py +370 -0
- package/core/model_windows.py +175 -0
- package/core/pipeline_models.py +176 -0
- package/core/reasoning/__init__.py +0 -0
- package/core/reasoning/authorization.py +130 -0
- package/core/reasoning/base.py +219 -0
- package/core/reasoning/confidence_scoring.py +468 -0
- package/core/reasoning/events.py +149 -0
- package/core/reasoning/json_retry.py +219 -0
- package/core/reasoning/orchestrator.py +1382 -0
- package/core/reasoning/output_writer.py +286 -0
- package/core/reasoning/payload_validation.py +398 -0
- package/core/reasoning/pipeline_storage.py +361 -0
- package/core/reasoning/review.py +615 -0
- package/core/reasoning/scholar.py +434 -0
- package/core/reasoning/source_corpus.py +327 -0
- package/core/reasoning/source_scoring.py +855 -0
- package/core/replay.py +167 -0
- package/core/session.py +153 -0
- package/core/workspace_trust.py +207 -0
- package/credentials.py +180 -0
- package/database.py +252 -0
- package/env_secrets.py +77 -0
- package/json_store.py +123 -0
- package/logging_setup.py +185 -0
- package/main.py +1959 -0
- package/mcp_client/__init__.py +15 -0
- package/mcp_client/client.py +499 -0
- package/mcp_client/config.py +379 -0
- package/mcp_client/registration.py +182 -0
- package/memories/manager.py +132 -0
- package/memories/tui_commands.py +232 -0
- package/package.json +73 -0
- package/project_init/config_files.py +278 -0
- package/project_init/doc_sets.py +330 -0
- package/project_init/generator.py +564 -0
- package/project_init/manifest.py +406 -0
- package/project_init/tui_commands.py +144 -0
- package/prompts/__init__.py +0 -0
- package/prompts/annotate.md +14 -0
- package/prompts/assumption_audit.md +27 -0
- package/prompts/claim_extraction.md +34 -0
- package/prompts/completeness.md +18 -0
- package/prompts/confidence_tiers.md +23 -0
- package/prompts/critic_pass.md +24 -0
- package/prompts/final_synthesis.md +13 -0
- package/prompts/initial_generation.md +14 -0
- package/prompts/preliminary_plan.md +23 -0
- package/prompts/revalidate.md +25 -0
- package/prompts/revise.md +15 -0
- package/prompts/source_grounding.md +66 -0
- package/prompts/system_prompts.py +262 -0
- package/prompts/universal_system_prompt +7 -0
- package/prompts/untrusted_content +1 -0
- package/providers.json.example +92 -0
- package/pyproject.toml +100 -0
- package/requirements.txt +72 -0
- package/safety/__init__.py +0 -0
- package/safety/policy_enforcement.py +682 -0
- package/security/__init__.py +0 -0
- package/security/capability.py +177 -0
- package/security/permissions.py +190 -0
- package/security/posture.py +302 -0
- package/security/protected_paths.py +309 -0
- package/security/sandbox.py +985 -0
- package/skills/builtin/crypto/cryptography-verification.md +66 -0
- package/skills/builtin/math/formal-specification.md +67 -0
- package/skills/builtin/math/numerical-methods.md +66 -0
- package/skills/builtin/math/proof-writing.md +61 -0
- package/skills/builtin/research/experiment-design.md +62 -0
- package/skills/builtin/research/literature-review.md +65 -0
- package/skills/builtin/research/reproducibility.md +55 -0
- package/skills/builtin/research/source-evaluation.md +70 -0
- package/skills/builtin/research/statistical-inference.md +63 -0
- package/skills/builtin/research/technical-writing.md +59 -0
- package/skills/builtin/security/cybersecurity-research.md +63 -0
- package/skills/builtin/software/code-review.md +61 -0
- package/skills/builtin/software/debugging.md +61 -0
- package/skills/builtin/software/test-design.md +67 -0
- package/skills/manager.py +138 -0
- package/skills/tui_commands.py +111 -0
- package/storage.py +1005 -0
- package/tools/base.py +305 -0
- package/tools/builtin/__init__.py +0 -0
- package/tools/builtin/_math_common.py +377 -0
- package/tools/builtin/_net_common.py +61 -0
- package/tools/builtin/arxiv.py +223 -0
- package/tools/builtin/ask_user.py +213 -0
- package/tools/builtin/discrete_math.py +134 -0
- package/tools/builtin/fetch_url.py +153 -0
- package/tools/builtin/file_ops.py +412 -0
- package/tools/builtin/geometry.py +148 -0
- package/tools/builtin/get_time.py +20 -0
- package/tools/builtin/linear_algebra.py +155 -0
- package/tools/builtin/load_skill.py +66 -0
- package/tools/builtin/logic.py +96 -0
- package/tools/builtin/pin.py +193 -0
- package/tools/builtin/probability_stats.py +228 -0
- package/tools/builtin/project_docs.py +405 -0
- package/tools/builtin/remember.py +158 -0
- package/tools/builtin/shell.py +461 -0
- package/tools/builtin/symbolic_math.py +119 -0
- package/tools/builtin/todo.py +147 -0
- package/tools/builtin/web_search.py +151 -0
- package/tools/context.py +136 -0
- package/tools/isolation.py +314 -0
- package/tools/registry.py +897 -0
- package/tui/app.py +3423 -0
- package/tui/app.tcss +458 -0
- package/tui/commands.py +61 -0
- package/tui/diffs.py +265 -0
- package/tui/preferences.py +182 -0
- package/tui/ravens.py +146 -0
- package/tui/screens.py +943 -0
- package/tui/themes.py +366 -0
- package/tui/widgets.py +1239 -0
package/logging_setup.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""logging_setup.py
|
|
2
|
+
|
|
3
|
+
Call configure_logging() ONCE, early, from the entry point (main.py once
|
|
4
|
+
ROADMAP.md §1's CLI lands), before any module that might log. Not called
|
|
5
|
+
on import, so tests and library-style usage don't get surprise handlers.
|
|
6
|
+
|
|
7
|
+
Diverges from ROADMAP.md §2's literal "stream=sys.stderr" decision in two
|
|
8
|
+
narrow ways, by explicit product decision:
|
|
9
|
+
1. Also writes to a rotating file (logs/app.log by default) so tool
|
|
10
|
+
retries survive CLI exit and process close.
|
|
11
|
+
2. Level is env-overridable via AGENT_LOG_LEVEL instead of a hardcoded
|
|
12
|
+
logging.INFO default. AGENT_LOG_FILE overrides the file path.
|
|
13
|
+
|
|
14
|
+
Idempotent on repeated calls so test runs that invoke configure_logging
|
|
15
|
+
more than once don't stack duplicate handlers and double-emit lines.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import logging
|
|
19
|
+
import os
|
|
20
|
+
import sys
|
|
21
|
+
from logging.handlers import RotatingFileHandler
|
|
22
|
+
|
|
23
|
+
# Top-level, not inside format(): this runs on every log record, and
|
|
24
|
+
# safety/policy_enforcement.py is a leaf (stdlib imports only, nothing
|
|
25
|
+
# from this project), so there is no cycle to dodge.
|
|
26
|
+
from safety.policy_enforcement import redact_secrets
|
|
27
|
+
|
|
28
|
+
__all__ = ["configure_logging"]
|
|
29
|
+
|
|
30
|
+
_DEFAULT_FORMAT = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
|
31
|
+
_DEFAULT_DATEFMT = "%Y-%m-%d %H:%M:%S"
|
|
32
|
+
|
|
33
|
+
_DEFAULT_LOG_FILE = "logs/app.log"
|
|
34
|
+
_DEFAULT_LEVEL = "INFO"
|
|
35
|
+
|
|
36
|
+
# Rotation defaults live here, not in config.py: this file owns the
|
|
37
|
+
# logging concern end-to-end (mirrors how ROADMAP.md §2 keeps the whole
|
|
38
|
+
# logging subsystem in one file). Bump via the function signature if
|
|
39
|
+
# needed; there is no project-wide reason to surface them as config yet.
|
|
40
|
+
_DEFAULT_MAX_BYTES = 1_000_000
|
|
41
|
+
_DEFAULT_BACKUP_COUNT = 3
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _RedactingFormatter(logging.Formatter):
|
|
45
|
+
"""Secret redaction on the LOG, which was the fourth sink (#132).
|
|
46
|
+
|
|
47
|
+
README enumerates three: "before it reaches the model, the transcript
|
|
48
|
+
or the database". The log is a fourth, and it was never an
|
|
49
|
+
acknowledged exception -- just an unlisted one.
|
|
50
|
+
|
|
51
|
+
`registry.dispatch()` states this exact threat in the comment above
|
|
52
|
+
its redaction call: "an exception message routinely carries the
|
|
53
|
+
request that produced it, and for an HTTP client that means a URL
|
|
54
|
+
with an API key in the query string. Redacting only the success path
|
|
55
|
+
would make a failing tool the way secrets escape." It then calls
|
|
56
|
+
`logger.exception(...)` THIRTEEN LINES EARLIER, so the unredacted
|
|
57
|
+
message and traceback were already on disk by the time
|
|
58
|
+
check_output_policy saw the result. Same string, two sinks, one
|
|
59
|
+
redacted.
|
|
60
|
+
|
|
61
|
+
A FORMATTER, not a logging.Filter, and that is load-bearing.
|
|
62
|
+
`logger.exception` renders the traceback at format time, from
|
|
63
|
+
`record.exc_info` -- and the traceback is precisely what carries the
|
|
64
|
+
upstream URL. A filter rewriting `record.msg` never sees it.
|
|
65
|
+
Formatting the record first and redacting the finished string covers
|
|
66
|
+
the message, the arguments and the traceback in one pass.
|
|
67
|
+
|
|
68
|
+
Fixed here rather than at dispatch's call site because dispatch is
|
|
69
|
+
not the only site: `fetch_url` logs a warning naming the URL it
|
|
70
|
+
failed on, and any future `logger.*` inherits this for free. Fixing
|
|
71
|
+
the one site the issue measured would have left the class open --
|
|
72
|
+
the same producer-vs-consumer argument #47 makes one file over.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
def format(self, record):
|
|
76
|
+
return redact_secrets(super().format(record))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _resolve_level(level):
|
|
80
|
+
"""Accepts a logging level as int, a name string ("INFO"), a numeric
|
|
81
|
+
string ("20"), or None (in which case AGENT_LOG_LEVEL / the default
|
|
82
|
+
is consulted)."""
|
|
83
|
+
if level is None:
|
|
84
|
+
level = os.environ.get("AGENT_LOG_LEVEL", _DEFAULT_LEVEL)
|
|
85
|
+
if isinstance(level, str):
|
|
86
|
+
# First try a named level ("INFO" -> logging.INFO); fall back to
|
|
87
|
+
# parsing as an int ("20"). Anything else raises ValueError, which
|
|
88
|
+
# is the right failure mode for a misconfigured env var.
|
|
89
|
+
named = getattr(logging, level.upper(), None)
|
|
90
|
+
if isinstance(named, int):
|
|
91
|
+
return named
|
|
92
|
+
return int(level)
|
|
93
|
+
return int(level)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def configure_logging(
|
|
97
|
+
level=None,
|
|
98
|
+
*,
|
|
99
|
+
log_file=None,
|
|
100
|
+
max_bytes=_DEFAULT_MAX_BYTES,
|
|
101
|
+
backup_count=_DEFAULT_BACKUP_COUNT,
|
|
102
|
+
stderr=True,
|
|
103
|
+
) -> None:
|
|
104
|
+
"""Configure the root logger with a stderr handler and a rotating
|
|
105
|
+
file handler.
|
|
106
|
+
|
|
107
|
+
Safe to call more than once: each call clears existing root handlers
|
|
108
|
+
before re-attaching, so repeated invocations (e.g. across tests)
|
|
109
|
+
don't stack duplicates and double-emit lines.
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
level:
|
|
114
|
+
Logging level as int, name ("INFO"), numeric string ("20"), or
|
|
115
|
+
None. None falls back to the AGENT_LOG_LEVEL env var, then the
|
|
116
|
+
INFO default.
|
|
117
|
+
log_file:
|
|
118
|
+
Path to the rotating log file. None falls back to the
|
|
119
|
+
AGENT_LOG_FILE env var, then "logs/app.log". Parent directory is
|
|
120
|
+
created if missing.
|
|
121
|
+
max_bytes, backup_count:
|
|
122
|
+
RotatingFileHandler rotation parameters.
|
|
123
|
+
stderr:
|
|
124
|
+
Attach the stderr handler. FALSE FOR THE TUI, and this is not a
|
|
125
|
+
preference. Textual owns the terminal and repaints it; anything
|
|
126
|
+
written to stderr lands on top of the rendered screen, sits over
|
|
127
|
+
the input bar and behind the panels, and disappears at the next
|
|
128
|
+
repaint -- so the message is both corrupting and unreadable. The
|
|
129
|
+
rotating file keeps everything at full detail either way, and
|
|
130
|
+
tui/app.py additionally routes WARNING+ into the transcript so
|
|
131
|
+
nothing that matters is only in a file.
|
|
132
|
+
"""
|
|
133
|
+
resolved_level = _resolve_level(level)
|
|
134
|
+
formatter = _RedactingFormatter(_DEFAULT_FORMAT, datefmt=_DEFAULT_DATEFMT)
|
|
135
|
+
|
|
136
|
+
root = logging.getLogger()
|
|
137
|
+
root.setLevel(resolved_level)
|
|
138
|
+
|
|
139
|
+
# Clear any pre-existing handlers so a repeated call does not attach
|
|
140
|
+
# a second stderr and a second file handler on top of the first.
|
|
141
|
+
for handler in list(root.handlers):
|
|
142
|
+
root.removeHandler(handler)
|
|
143
|
+
try:
|
|
144
|
+
handler.close()
|
|
145
|
+
except (OSError, IOError):
|
|
146
|
+
# Closing should not fail loudly, but if a handler is in a
|
|
147
|
+
# weird state we still want to proceed with fresh handlers.
|
|
148
|
+
pass
|
|
149
|
+
|
|
150
|
+
if stderr:
|
|
151
|
+
stderr_handler = logging.StreamHandler(stream=sys.stderr)
|
|
152
|
+
stderr_handler.setFormatter(formatter)
|
|
153
|
+
root.addHandler(stderr_handler)
|
|
154
|
+
|
|
155
|
+
if log_file is None:
|
|
156
|
+
log_file = os.environ.get("AGENT_LOG_FILE", _DEFAULT_LOG_FILE)
|
|
157
|
+
# Normalize relative paths and embedded ../ so makedirs and
|
|
158
|
+
# RotatingFileHandler see a clean absolute path. Not a containment
|
|
159
|
+
# check -- the user can still point AGENT_LOG_FILE anywhere they
|
|
160
|
+
# want; this just prevents accidental path-traversal via relative
|
|
161
|
+
# segments in env-configured paths.
|
|
162
|
+
log_file = os.path.abspath(log_file)
|
|
163
|
+
log_dir = os.path.dirname(log_file)
|
|
164
|
+
try:
|
|
165
|
+
if log_dir and not os.path.isdir(log_dir):
|
|
166
|
+
os.makedirs(log_dir, exist_ok=True)
|
|
167
|
+
|
|
168
|
+
file_handler = RotatingFileHandler(
|
|
169
|
+
log_file,
|
|
170
|
+
maxBytes=max_bytes,
|
|
171
|
+
backupCount=backup_count,
|
|
172
|
+
encoding="utf-8",
|
|
173
|
+
)
|
|
174
|
+
file_handler.setFormatter(formatter)
|
|
175
|
+
root.addHandler(file_handler)
|
|
176
|
+
except OSError as e:
|
|
177
|
+
# Logging to a file is non-essential. If the directory can't be
|
|
178
|
+
# created or the file can't be opened (read-only filesystem,
|
|
179
|
+
# permission denied, disk full), fall back to stderr-only rather
|
|
180
|
+
# than crashing the program at startup.
|
|
181
|
+
print(
|
|
182
|
+
f"Warning: could not create log file at {log_file} ({e}); "
|
|
183
|
+
f"logging to stderr only.",
|
|
184
|
+
file=sys.stderr,
|
|
185
|
+
)
|