@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
package/core/workspace_trust.py
CHANGED
|
@@ -173,7 +173,7 @@ def _load_trust_store() -> dict:
|
|
|
173
173
|
if not os.path.exists(path):
|
|
174
174
|
return {}
|
|
175
175
|
try:
|
|
176
|
-
with open(path,
|
|
176
|
+
with open(path, encoding="utf-8-sig") as f:
|
|
177
177
|
data = json.load(f)
|
|
178
178
|
except (OSError, ValueError):
|
|
179
179
|
return {}
|
package/credentials.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
+
# A root module importing a root module: no new edge, and json_store.py's
|
|
5
|
+
# docstring names `credentials` among the things already imported from
|
|
6
|
+
# everywhere for that reason.
|
|
7
|
+
from json_store import write_json_atomic
|
|
8
|
+
|
|
4
9
|
# #24. Resolved at IMPORT time, exactly like its four siblings --
|
|
5
10
|
# config.DB_PATH / OUTPUT_DIR / WORKSPACE_DIR and logging_setup's log
|
|
6
11
|
# file are all `os.environ.get(NAME, default)` evaluated once -- so a
|
|
@@ -55,13 +60,48 @@ def unknown_provider_message(provider_name: str, providers: dict) -> str:
|
|
|
55
60
|
)
|
|
56
61
|
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
# ROADMAP_v3 §79 (HD5). Providers connected for THIS PROCESS ONLY, never
|
|
64
|
+
# written anywhere. A shared hosted demo runs every visitor in one container
|
|
65
|
+
# as one Unix user, so a key in a file is a key one bug away from the next
|
|
66
|
+
# visitor; a key in this dict lives as long as the session's process does.
|
|
67
|
+
# Entries here win over the file's, and the file is never told about them.
|
|
68
|
+
_SESSION_PROVIDERS: dict = {}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def set_session_provider(provider_name: str, entry: dict) -> None:
|
|
72
|
+
"""Connect a provider for this process without writing it to disk (HD5).
|
|
73
|
+
|
|
74
|
+
A COPY is stored, so the caller's dict cannot change it afterwards.
|
|
75
|
+
"""
|
|
76
|
+
_SESSION_PROVIDERS[provider_name] = dict(entry)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def clear_session_providers() -> None:
|
|
80
|
+
_SESSION_PROVIDERS.clear()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _load_file_data() -> dict:
|
|
59
84
|
if not os.path.exists(LLM_PROVIDERS_FILE):
|
|
60
85
|
return {}
|
|
61
|
-
with open(LLM_PROVIDERS_FILE,
|
|
86
|
+
with open(LLM_PROVIDERS_FILE, encoding="utf-8") as file:
|
|
62
87
|
return json.load(file)
|
|
63
88
|
|
|
64
89
|
|
|
90
|
+
def load_provider_data() -> dict:
|
|
91
|
+
"""Every configured provider: the file's entries, with any connected for
|
|
92
|
+
this session only laid over them (HD5).
|
|
93
|
+
|
|
94
|
+
Callers get fresh dicts each time, so mutating the answer changes
|
|
95
|
+
neither the file nor the session's entries. `save_credentials` reads the
|
|
96
|
+
FILE alone, which is what keeps a session-only key from being written
|
|
97
|
+
back by the next save of some other provider.
|
|
98
|
+
"""
|
|
99
|
+
data = _load_file_data()
|
|
100
|
+
for name, entry in _SESSION_PROVIDERS.items():
|
|
101
|
+
data[name] = dict(entry)
|
|
102
|
+
return data
|
|
103
|
+
|
|
104
|
+
|
|
65
105
|
# 0600 -- owner read/write, nobody else. This file holds every LLM
|
|
66
106
|
# provider's API key in cleartext, and a bare open(path, "w") left its
|
|
67
107
|
# protection to the process umask: 0644 under the common default, i.e.
|
|
@@ -75,23 +115,33 @@ _SECRET_FILE_MODE = 0o600
|
|
|
75
115
|
|
|
76
116
|
|
|
77
117
|
def _write_secret_json(path: str, data: dict) -> None:
|
|
78
|
-
"""Write JSON to a file created 0600, never world-readable even briefly
|
|
118
|
+
"""Write JSON to a file created 0600, never world-readable even briefly,
|
|
119
|
+
and never half-written.
|
|
79
120
|
|
|
80
|
-
|
|
81
|
-
|
|
121
|
+
0600 AT CREATION, NOT open() followed by os.chmod. A post-write chmod
|
|
122
|
+
leaves a window in which the key is on disk with the umask's
|
|
82
123
|
permissions -- short, but it is exactly the window an attacker with
|
|
83
124
|
local read access is waiting for, and closing it costs one line.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
the
|
|
125
|
+
`write_json_atomic` applies the mode to the TEMP file, which is the
|
|
126
|
+
same property: `os.replace` carries it across, and the key is never on
|
|
127
|
+
disk under the umask's permissions at any point.
|
|
128
|
+
|
|
129
|
+
WINDOWS: POSIX mode bits do not apply, and the mode argument only
|
|
130
|
+
controls the read-only flag there. This is a no-op on Windows rather
|
|
131
|
+
than a wrong-op; the file's protection comes from the ACL on the user
|
|
132
|
+
profile directory instead. The tests skip accordingly, and the CI
|
|
133
|
+
container is where the assertion actually runs.
|
|
134
|
+
|
|
135
|
+
ATOMIC SINCE BATCH 108, and this was the older half of the same defect.
|
|
136
|
+
It wrote `O_TRUNC` straight over the live file, so a crash, a full disk
|
|
137
|
+
or a kill between the truncate and the flush destroyed every stored
|
|
138
|
+
provider key at once -- and unlike the secrets store, this file ships
|
|
139
|
+
in use for every user who has ever saved a credential. `json_store.py`
|
|
140
|
+
was extracted to delete exactly this pattern and says so; the two files
|
|
141
|
+
holding credentials were the last two stores in the project still
|
|
142
|
+
carrying a private copy of it.
|
|
90
143
|
"""
|
|
91
|
-
|
|
92
|
-
_SECRET_FILE_MODE)
|
|
93
|
-
with os.fdopen(fd, "w", encoding="utf-8") as file:
|
|
94
|
-
json.dump(data, file, indent=2)
|
|
144
|
+
write_json_atomic(path, data, mode=_SECRET_FILE_MODE, indent=2)
|
|
95
145
|
|
|
96
146
|
|
|
97
147
|
def _write_provider_data(provider_data: dict) -> None:
|
|
@@ -105,7 +155,9 @@ def save_credentials(
|
|
|
105
155
|
is_v1_compatible: bool = True,
|
|
106
156
|
supports_stream_usage: bool = False,
|
|
107
157
|
) -> None:
|
|
108
|
-
|
|
158
|
+
# The FILE, never the merged view: a session-only entry (HD5) read here
|
|
159
|
+
# would be written to disk by this save.
|
|
160
|
+
provider_data = _load_file_data()
|
|
109
161
|
|
|
110
162
|
if provider_name in provider_data:
|
|
111
163
|
provider_data[provider_name]["API_KEY"] = api_key
|
|
@@ -124,6 +176,29 @@ def save_credentials(
|
|
|
124
176
|
_write_provider_data(provider_data)
|
|
125
177
|
|
|
126
178
|
|
|
179
|
+
def forget_key(provider_name: str) -> "str | None":
|
|
180
|
+
"""Remove `provider_name`'s key; say where it was (ROADMAP_v3 §83, CG13).
|
|
181
|
+
|
|
182
|
+
`/disconnect`'s one writer. A session-only entry (HD5) is dropped whole,
|
|
183
|
+
since it exists only to carry the key, and the file is not touched --
|
|
184
|
+
a shared deployment never writes it. Otherwise the file entry's
|
|
185
|
+
`API_KEY` is blanked and EVERY OTHER FIELD STAYS: the URL, the two
|
|
186
|
+
flags, `echoes_reasoning`, `accepts_images` -- exactly what
|
|
187
|
+
`save_credentials` keeps when a key is replaced, so a later `/connect`
|
|
188
|
+
comes back to the same entry. Returns "session", "file", or None when
|
|
189
|
+
there was no key to forget.
|
|
190
|
+
"""
|
|
191
|
+
if _SESSION_PROVIDERS.pop(provider_name, None) is not None:
|
|
192
|
+
return "session"
|
|
193
|
+
provider_data = _load_file_data()
|
|
194
|
+
entry = provider_data.get(provider_name)
|
|
195
|
+
if not entry or not entry.get("API_KEY"):
|
|
196
|
+
return None
|
|
197
|
+
entry["API_KEY"] = ""
|
|
198
|
+
_write_provider_data(provider_data)
|
|
199
|
+
return "file"
|
|
200
|
+
|
|
201
|
+
|
|
127
202
|
def load_credentials(provider_name: str) -> tuple[str, str]:
|
|
128
203
|
provider_data = load_provider_data()
|
|
129
204
|
# #24. The two failure modes say different things now -- "the file is
|
|
@@ -154,12 +229,65 @@ def missing_key_message(provider_name: str) -> str:
|
|
|
154
229
|
f"needs none.")
|
|
155
230
|
|
|
156
231
|
|
|
232
|
+
def empty_key_refusal(provider_name: str) -> str:
|
|
233
|
+
"""What a SEND says when a provider that cannot go keyless has no key.
|
|
234
|
+
|
|
235
|
+
missing_key_message is the launch and /model WARNING, and its "unless it
|
|
236
|
+
is a local endpoint" is true there. This is the refusal at the moment a
|
|
237
|
+
client would be built, for a provider with no local-endpoint case at all
|
|
238
|
+
(batch 234: ANTHROPIC). anthropic 0.116.0 refused an empty key itself
|
|
239
|
+
with a TypeError naming the problem; 2.x builds `Authorization: Bearer `,
|
|
240
|
+
httpx2 refuses that header before anything is sent, and the SDK reports
|
|
241
|
+
it as "Connection error." -- which core/provider_errors.py rightly
|
|
242
|
+
treats as transient, so it was retried as a network blip.
|
|
243
|
+
"""
|
|
244
|
+
return (f"{provider_name} has no API_KEY in {LLM_PROVIDERS_FILE}, and its "
|
|
245
|
+
f"SDK cannot send a request without one. Add the key there, or "
|
|
246
|
+
f"with /connect {provider_name.lower()} in the TUI.")
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def missing_credential_message(provider_name: str,
|
|
250
|
+
entry: dict) -> "str | None":
|
|
251
|
+
"""What to say when `provider_name` has nothing to authenticate with, or
|
|
252
|
+
None when it has something. The ONE test, for launch and for every
|
|
253
|
+
command that switches a provider.
|
|
254
|
+
|
|
255
|
+
A key for every provider but one. The ChatGPT plan's entry holds no key
|
|
256
|
+
BY DESIGN (ROADMAP_v3 §83, CG20) and its credential is the sign-in in
|
|
257
|
+
`chatgpt_auth.json`, so testing the key said "calls will fail" -- in
|
|
258
|
+
red, at launch and after each `/model CHATGPT` -- about a plan that was
|
|
259
|
+
signed in and answering (batch 189, the owner's live check). Three call
|
|
260
|
+
sites each tested the key on their own, which is why one fix here rather
|
|
261
|
+
than three there.
|
|
262
|
+
|
|
263
|
+
On a hosted deployment the plan has no credential at all (CG1): the
|
|
264
|
+
answer there is why, never "/connect chatgpt signs in", which that
|
|
265
|
+
deployment refuses (batch 195). Signed in or not -- a token file
|
|
266
|
+
carried onto one still cannot reach the plan (core/client.py).
|
|
267
|
+
"""
|
|
268
|
+
if provider_name == "CHATGPT":
|
|
269
|
+
# Imported here: core.chatgpt_auth imports this module.
|
|
270
|
+
from core import chatgpt_auth
|
|
271
|
+
from security import hosted
|
|
272
|
+
|
|
273
|
+
if hosted.is_hosted():
|
|
274
|
+
return chatgpt_auth.LOCAL_ONLY
|
|
275
|
+
if chatgpt_auth.status().signed_in:
|
|
276
|
+
return None
|
|
277
|
+
return ("The ChatGPT plan is not signed in, so CHATGPT cannot answer. "
|
|
278
|
+
"/connect chatgpt signs in.")
|
|
279
|
+
if entry.get("API_KEY"):
|
|
280
|
+
return None
|
|
281
|
+
return missing_key_message(provider_name)
|
|
282
|
+
|
|
283
|
+
|
|
157
284
|
def provider_startup_issues(provider_name: str) -> list:
|
|
158
285
|
"""What launch should say about the provider setup, before either
|
|
159
286
|
shell starts (#138).
|
|
160
287
|
|
|
161
288
|
The same three checks /model performs on a switch -- file present,
|
|
162
|
-
provider configured,
|
|
289
|
+
provider configured, a credential present (a key, or for the ChatGPT
|
|
290
|
+
plan its sign-in: `missing_credential_message`) -- applied at the moment the user
|
|
163
291
|
chose the provider, instead of at the first model call, which is a
|
|
164
292
|
dead end away from the mistake that caused it. WARN-ONLY, never a
|
|
165
293
|
refusal: an OpenAI-compatible endpoint running locally legitimately
|
|
@@ -175,6 +303,6 @@ def provider_startup_issues(provider_name: str) -> list:
|
|
|
175
303
|
return [no_providers_message()]
|
|
176
304
|
if provider_name not in providers:
|
|
177
305
|
return [unknown_provider_message(provider_name, providers)]
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return []
|
|
306
|
+
message = missing_credential_message(provider_name,
|
|
307
|
+
providers[provider_name])
|
|
308
|
+
return [message] if message else []
|