@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/core/cancel.py
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
"""
|
|
2
|
-
core/cancel.py
|
|
3
|
-
|
|
4
|
-
ROADMAP_v3 §61 (CN1). How a shell stops a turn that is already running.
|
|
5
|
-
|
|
6
|
-
A turn runs on a worker thread and the key that stops it is pressed on
|
|
7
|
-
another one, so the two cannot touch the same generator: calling close()
|
|
8
|
-
on a generator a second thread is stepping raises "generator already
|
|
9
|
-
executing". What DOES cross a thread boundary safely is a flag, which is
|
|
10
|
-
why this is cooperative rather than pre-emptive -- the loop asks, at the
|
|
11
|
-
four sites CN2 names, and stops itself.
|
|
12
|
-
|
|
13
|
-
A LEAF MODULE with no project imports, deliberately, and for
|
|
14
|
-
core/approval.py's reason: core/loop.py, main.py, tui/app.py and
|
|
15
|
-
agents/subagent_tool.py all depend on it and it depends on none of them.
|
|
16
|
-
It is also why this is an object passed down rather than a ContextVar --
|
|
17
|
-
threads do not inherit their parent's context, which core/loop.py's
|
|
18
|
-
_dispatch_parallel and tui/app.py's _consume both already pay for, and a
|
|
19
|
-
token the tool pool could not see would be a stop switch that silently
|
|
20
|
-
missed the longest part of a turn.
|
|
21
|
-
|
|
22
|
-
CANCELLED IS NOT FAILED, and that distinction is why this object carries
|
|
23
|
-
a reason at all rather than being a bare Event. A failed run is recorded
|
|
24
|
-
with memory.mark_turn_failed and reads as something broken; a cancelled
|
|
25
|
-
one is a person changing their mind. §60's UH6 records the same rule
|
|
26
|
-
arriving from the other direction: UHP requires a cancelled task to end
|
|
27
|
-
`cancelled`, never `failed`, with partial output kept.
|
|
28
|
-
|
|
29
|
-
WHAT THIS CANNOT DO, stated here rather than discovered. A cooperative
|
|
30
|
-
token is read between operations, so it cannot interrupt one already
|
|
31
|
-
blocked inside the SDK -- most visibly the socket read before a model
|
|
32
|
-
call's first token, which on a thinking model is tens of seconds. It
|
|
33
|
-
also does not kill a tool call that is already running (CN6). Both are
|
|
34
|
-
limits of the mechanism and both are things a shell has to SAY while it
|
|
35
|
-
waits, which is the difference between a slow stop and a broken one.
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
import threading
|
|
39
|
-
|
|
40
|
-
#: What a cancellation says when nobody gave a reason. It reaches the
|
|
41
|
-
#: transcript and the thread, so it is phrased for a reader rather than
|
|
42
|
-
#: for a log.
|
|
43
|
-
DEFAULT_REASON = "stopped by the user"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class CancelToken:
|
|
47
|
-
"""One run's stop switch: set by a shell, read by the loop.
|
|
48
|
-
|
|
49
|
-
ONE instance per turn, handed down beside the response channel and
|
|
50
|
-
the grant budget -- the shape this project already uses for "an
|
|
51
|
-
out-of-band object a run needs where a LoopEvent cannot reach" -- and
|
|
52
|
-
shared BY REFERENCE with any subagent that turn spawns (CN7), so
|
|
53
|
-
stopping a turn stops the children it started.
|
|
54
|
-
|
|
55
|
-
SET-ONCE. A second caller does not overwrite the first's reason: the
|
|
56
|
-
reason worth keeping is the one that actually stopped the run, and a
|
|
57
|
-
later generic "stopped by the user" landing on top of a specific
|
|
58
|
-
first reason would make the record less true the more often the key
|
|
59
|
-
was pressed.
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
def __init__(self) -> None:
|
|
63
|
-
self._event = threading.Event()
|
|
64
|
-
self._reason = DEFAULT_REASON
|
|
65
|
-
# Not an RLock: nothing under `cancel` re-enters this object, and
|
|
66
|
-
# a plain Lock is what makes that claim checkable. GrantBudget in
|
|
67
|
-
# core/approval.py takes the same line for the same reason.
|
|
68
|
-
self._lock = threading.Lock()
|
|
69
|
-
|
|
70
|
-
def cancel(self, reason: str = DEFAULT_REASON) -> bool:
|
|
71
|
-
"""Ask the run to stop. True if THIS call is the one that set it.
|
|
72
|
-
|
|
73
|
-
The return value is what lets a shell tell a first press from a
|
|
74
|
-
second: the first announces that it is stopping, and a second
|
|
75
|
-
must not announce it again over a run that is already winding
|
|
76
|
-
down -- nor read as having done nothing, which is the other wrong
|
|
77
|
-
answer.
|
|
78
|
-
|
|
79
|
-
The test AND the write are inside the lock, for GrantBudget.take's
|
|
80
|
-
reason: the decision to record a reason IS the read, and a
|
|
81
|
-
decision made on a stale read is the defect.
|
|
82
|
-
"""
|
|
83
|
-
with self._lock:
|
|
84
|
-
if self._event.is_set():
|
|
85
|
-
return False
|
|
86
|
-
self._reason = reason or DEFAULT_REASON
|
|
87
|
-
self._event.set()
|
|
88
|
-
return True
|
|
89
|
-
|
|
90
|
-
@property
|
|
91
|
-
def cancelled(self) -> bool:
|
|
92
|
-
"""Whether the run has been asked to stop.
|
|
93
|
-
|
|
94
|
-
No lock. `threading.Event` is already safe to read from any
|
|
95
|
-
thread, and every caller is asking for a snapshot at a point the
|
|
96
|
-
loop chose. Nothing acts on a stale False except by asking again
|
|
97
|
-
at the next of CN2's four sites, so the only cost of losing a
|
|
98
|
-
race here is one more step, never a missed stop.
|
|
99
|
-
"""
|
|
100
|
-
return self._event.is_set()
|
|
101
|
-
|
|
102
|
-
@property
|
|
103
|
-
def reason(self) -> str:
|
|
104
|
-
"""Why, in words -- for the transcript, and for the rows a
|
|
105
|
-
cancelled turn leaves in its thread."""
|
|
106
|
-
with self._lock:
|
|
107
|
-
return self._reason
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def is_cancelled(token) -> bool:
|
|
111
|
-
"""True when `token` is a CancelToken that has been set.
|
|
112
|
-
|
|
113
|
-
A free function because the parameter is optional at every layer it
|
|
114
|
-
passes through -- None means "nothing can stop this run", which is
|
|
115
|
-
every caller that has not opted in, including every test that
|
|
116
|
-
predates §61. Writing `token is not None and token.cancelled` out at
|
|
117
|
-
each of CN2's sites would be four chances to get the None half wrong,
|
|
118
|
-
and the one that got it wrong would be a stop switch that raised
|
|
119
|
-
AttributeError instead of stopping.
|
|
120
|
-
"""
|
|
121
|
-
return token is not None and token.cancelled
|
|
1
|
+
"""
|
|
2
|
+
core/cancel.py
|
|
3
|
+
|
|
4
|
+
ROADMAP_v3 §61 (CN1). How a shell stops a turn that is already running.
|
|
5
|
+
|
|
6
|
+
A turn runs on a worker thread and the key that stops it is pressed on
|
|
7
|
+
another one, so the two cannot touch the same generator: calling close()
|
|
8
|
+
on a generator a second thread is stepping raises "generator already
|
|
9
|
+
executing". What DOES cross a thread boundary safely is a flag, which is
|
|
10
|
+
why this is cooperative rather than pre-emptive -- the loop asks, at the
|
|
11
|
+
four sites CN2 names, and stops itself.
|
|
12
|
+
|
|
13
|
+
A LEAF MODULE with no project imports, deliberately, and for
|
|
14
|
+
core/approval.py's reason: core/loop.py, main.py, tui/app.py and
|
|
15
|
+
agents/subagent_tool.py all depend on it and it depends on none of them.
|
|
16
|
+
It is also why this is an object passed down rather than a ContextVar --
|
|
17
|
+
threads do not inherit their parent's context, which core/loop.py's
|
|
18
|
+
_dispatch_parallel and tui/app.py's _consume both already pay for, and a
|
|
19
|
+
token the tool pool could not see would be a stop switch that silently
|
|
20
|
+
missed the longest part of a turn.
|
|
21
|
+
|
|
22
|
+
CANCELLED IS NOT FAILED, and that distinction is why this object carries
|
|
23
|
+
a reason at all rather than being a bare Event. A failed run is recorded
|
|
24
|
+
with memory.mark_turn_failed and reads as something broken; a cancelled
|
|
25
|
+
one is a person changing their mind. §60's UH6 records the same rule
|
|
26
|
+
arriving from the other direction: UHP requires a cancelled task to end
|
|
27
|
+
`cancelled`, never `failed`, with partial output kept.
|
|
28
|
+
|
|
29
|
+
WHAT THIS CANNOT DO, stated here rather than discovered. A cooperative
|
|
30
|
+
token is read between operations, so it cannot interrupt one already
|
|
31
|
+
blocked inside the SDK -- most visibly the socket read before a model
|
|
32
|
+
call's first token, which on a thinking model is tens of seconds. It
|
|
33
|
+
also does not kill a tool call that is already running (CN6). Both are
|
|
34
|
+
limits of the mechanism and both are things a shell has to SAY while it
|
|
35
|
+
waits, which is the difference between a slow stop and a broken one.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
import threading
|
|
39
|
+
|
|
40
|
+
#: What a cancellation says when nobody gave a reason. It reaches the
|
|
41
|
+
#: transcript and the thread, so it is phrased for a reader rather than
|
|
42
|
+
#: for a log.
|
|
43
|
+
DEFAULT_REASON = "stopped by the user"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CancelToken:
|
|
47
|
+
"""One run's stop switch: set by a shell, read by the loop.
|
|
48
|
+
|
|
49
|
+
ONE instance per turn, handed down beside the response channel and
|
|
50
|
+
the grant budget -- the shape this project already uses for "an
|
|
51
|
+
out-of-band object a run needs where a LoopEvent cannot reach" -- and
|
|
52
|
+
shared BY REFERENCE with any subagent that turn spawns (CN7), so
|
|
53
|
+
stopping a turn stops the children it started.
|
|
54
|
+
|
|
55
|
+
SET-ONCE. A second caller does not overwrite the first's reason: the
|
|
56
|
+
reason worth keeping is the one that actually stopped the run, and a
|
|
57
|
+
later generic "stopped by the user" landing on top of a specific
|
|
58
|
+
first reason would make the record less true the more often the key
|
|
59
|
+
was pressed.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
def __init__(self) -> None:
|
|
63
|
+
self._event = threading.Event()
|
|
64
|
+
self._reason = DEFAULT_REASON
|
|
65
|
+
# Not an RLock: nothing under `cancel` re-enters this object, and
|
|
66
|
+
# a plain Lock is what makes that claim checkable. GrantBudget in
|
|
67
|
+
# core/approval.py takes the same line for the same reason.
|
|
68
|
+
self._lock = threading.Lock()
|
|
69
|
+
|
|
70
|
+
def cancel(self, reason: str = DEFAULT_REASON) -> bool:
|
|
71
|
+
"""Ask the run to stop. True if THIS call is the one that set it.
|
|
72
|
+
|
|
73
|
+
The return value is what lets a shell tell a first press from a
|
|
74
|
+
second: the first announces that it is stopping, and a second
|
|
75
|
+
must not announce it again over a run that is already winding
|
|
76
|
+
down -- nor read as having done nothing, which is the other wrong
|
|
77
|
+
answer.
|
|
78
|
+
|
|
79
|
+
The test AND the write are inside the lock, for GrantBudget.take's
|
|
80
|
+
reason: the decision to record a reason IS the read, and a
|
|
81
|
+
decision made on a stale read is the defect.
|
|
82
|
+
"""
|
|
83
|
+
with self._lock:
|
|
84
|
+
if self._event.is_set():
|
|
85
|
+
return False
|
|
86
|
+
self._reason = reason or DEFAULT_REASON
|
|
87
|
+
self._event.set()
|
|
88
|
+
return True
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def cancelled(self) -> bool:
|
|
92
|
+
"""Whether the run has been asked to stop.
|
|
93
|
+
|
|
94
|
+
No lock. `threading.Event` is already safe to read from any
|
|
95
|
+
thread, and every caller is asking for a snapshot at a point the
|
|
96
|
+
loop chose. Nothing acts on a stale False except by asking again
|
|
97
|
+
at the next of CN2's four sites, so the only cost of losing a
|
|
98
|
+
race here is one more step, never a missed stop.
|
|
99
|
+
"""
|
|
100
|
+
return self._event.is_set()
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def reason(self) -> str:
|
|
104
|
+
"""Why, in words -- for the transcript, and for the rows a
|
|
105
|
+
cancelled turn leaves in its thread."""
|
|
106
|
+
with self._lock:
|
|
107
|
+
return self._reason
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def is_cancelled(token) -> bool:
|
|
111
|
+
"""True when `token` is a CancelToken that has been set.
|
|
112
|
+
|
|
113
|
+
A free function because the parameter is optional at every layer it
|
|
114
|
+
passes through -- None means "nothing can stop this run", which is
|
|
115
|
+
every caller that has not opted in, including every test that
|
|
116
|
+
predates §61. Writing `token is not None and token.cancelled` out at
|
|
117
|
+
each of CN2's sites would be four chances to get the None half wrong,
|
|
118
|
+
and the one that got it wrong would be a stop switch that raised
|
|
119
|
+
AttributeError instead of stopping.
|
|
120
|
+
"""
|
|
121
|
+
return token is not None and token.cancelled
|