@yahyahammad/venastine 0.3.8 → 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.
Files changed (128) hide show
  1. package/.env.example +19 -19
  2. package/CONFIG_ARCHITECTURE.md +2030 -2002
  3. package/LICENSE +201 -201
  4. package/README.md +1034 -1034
  5. package/agents/builtin/compactor.md +75 -75
  6. package/agents/builtin/explore.md +77 -77
  7. package/agents/builtin/pipeline-reviewer.md +100 -100
  8. package/agents/builtin/plan.md +106 -106
  9. package/agents/builtin/review.md +74 -74
  10. package/agents/manager.py +261 -261
  11. package/agents/subagent_tool.py +472 -472
  12. package/agents/tui_commands.py +238 -146
  13. package/bin/venastine.mjs +528 -528
  14. package/bin/venastine.py +71 -71
  15. package/cli_commands.py +838 -835
  16. package/config.yaml +13 -0
  17. package/config_edit.py +1301 -1301
  18. package/config_schema.py +971 -966
  19. package/config_update.py +749 -749
  20. package/core/agent_activity.py +256 -256
  21. package/core/ansi.py +452 -452
  22. package/core/approval.py +137 -137
  23. package/core/call_view.py +364 -364
  24. package/core/cancel.py +121 -121
  25. package/core/chatgpt_auth.py +747 -747
  26. package/core/claims_view.py +107 -107
  27. package/core/client.py +2715 -2715
  28. package/core/commands.py +460 -454
  29. package/core/compaction.py +1735 -1735
  30. package/core/config_loader.py +1982 -1982
  31. package/core/connect.py +686 -686
  32. package/core/events.py +123 -123
  33. package/core/file_mentions.py +280 -280
  34. package/core/interaction.py +411 -411
  35. package/core/loop.py +2566 -2566
  36. package/core/memory.py +482 -482
  37. package/core/pipeline_models.py +190 -190
  38. package/core/provider_errors.py +234 -234
  39. package/core/reasoning/authorization.py +130 -130
  40. package/core/reasoning/base.py +219 -219
  41. package/core/reasoning/confidence_scoring.py +484 -484
  42. package/core/reasoning/events.py +149 -149
  43. package/core/reasoning/orchestrator.py +1561 -1561
  44. package/core/reasoning/output_writer.py +345 -345
  45. package/core/reasoning/payload_validation.py +524 -524
  46. package/core/reasoning/pipeline_storage.py +427 -427
  47. package/core/reasoning/scholar.py +458 -458
  48. package/core/reasoning/source_corpus.py +433 -433
  49. package/core/reasoning/source_scoring.py +855 -855
  50. package/core/replay.py +315 -315
  51. package/core/shell_sessions.py +1553 -1553
  52. package/credentials.py +307 -307
  53. package/database.py +333 -333
  54. package/docs/PRIVACY.md +78 -78
  55. package/docs/SECURITY.md +108 -108
  56. package/docs/THIRD_PARTY_NOTICES.md +148 -148
  57. package/env_secrets.py +118 -118
  58. package/json_store.py +343 -343
  59. package/logging_setup.py +295 -295
  60. package/main.py +3433 -3433
  61. package/mcp_client/client.py +733 -733
  62. package/mcp_client/config.py +484 -484
  63. package/mcp_client/registration.py +343 -343
  64. package/memories/manager.py +147 -147
  65. package/memories/tui_commands.py +319 -239
  66. package/package.json +303 -303
  67. package/project_init/config_files.py +282 -282
  68. package/project_init/generator.py +728 -728
  69. package/project_init/manifest.py +418 -418
  70. package/project_init/tui_commands.py +147 -147
  71. package/prompts/critic_pass.md +24 -24
  72. package/prompts/revalidate.md +25 -25
  73. package/prompts/revise.md +17 -17
  74. package/prompts/source_grounding.md +66 -66
  75. package/prompts/system_prompts.py +316 -316
  76. package/providers.json.example +94 -94
  77. package/pyproject.toml +149 -149
  78. package/requirements.txt +295 -295
  79. package/safety/policy_enforcement.py +1082 -1082
  80. package/security/askpass.py +419 -419
  81. package/security/capability.py +207 -207
  82. package/security/confine.py +484 -484
  83. package/security/hosted.py +182 -182
  84. package/security/permissions.py +237 -237
  85. package/security/protected_paths.py +501 -501
  86. package/security/sandbox.py +4108 -4108
  87. package/skills/builtin/math/formal-specification.md +67 -67
  88. package/skills/builtin/math/numerical-methods.md +66 -66
  89. package/skills/builtin/research/experiment-design.md +62 -62
  90. package/skills/builtin/research/reproducibility.md +55 -55
  91. package/skills/builtin/research/source-evaluation.md +70 -70
  92. package/skills/builtin/research/statistical-inference.md +63 -63
  93. package/skills/builtin/research/technical-writing.md +59 -59
  94. package/skills/builtin/software/code-review.md +61 -61
  95. package/skills/builtin/software/debugging.md +61 -61
  96. package/skills/builtin/software/test-design.md +67 -67
  97. package/skills/tui_commands.py +110 -110
  98. package/storage.py +1338 -1338
  99. package/tools/base.py +465 -465
  100. package/tools/builtin/_math_common.py +667 -667
  101. package/tools/builtin/_net_common.py +267 -267
  102. package/tools/builtin/arxiv.py +681 -681
  103. package/tools/builtin/fetch_url.py +371 -371
  104. package/tools/builtin/file_ops.py +720 -720
  105. package/tools/builtin/geometry.py +184 -184
  106. package/tools/builtin/load_skill.py +76 -76
  107. package/tools/builtin/pin.py +227 -227
  108. package/tools/builtin/probability_stats.py +224 -224
  109. package/tools/builtin/project_docs.py +464 -464
  110. package/tools/builtin/remember.py +175 -175
  111. package/tools/builtin/shell.py +980 -980
  112. package/tools/builtin/todo.py +149 -149
  113. package/tools/builtin/web_search.py +328 -328
  114. package/tools/context.py +159 -159
  115. package/tools/isolation.py +387 -387
  116. package/tools/registry.py +1242 -1242
  117. package/tui/app.py +8318 -8307
  118. package/tui/app.tcss +747 -739
  119. package/tui/commands.py +26 -26
  120. package/tui/diffs.py +286 -286
  121. package/tui/history.py +128 -128
  122. package/tui/hosted_driver.py +102 -102
  123. package/tui/markdown.py +1329 -1329
  124. package/tui/meters.py +364 -364
  125. package/tui/ravens.py +146 -146
  126. package/tui/screens.py +1255 -1197
  127. package/tui/themes.py +599 -599
  128. package/tui/widgets.py +3813 -3796
package/tui/history.py CHANGED
@@ -1,128 +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
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
@@ -1,102 +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
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