zjcode 0.0.1__py3-none-any.whl
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.
- deepagents_code/__init__.py +42 -0
- deepagents_code/__main__.py +6 -0
- deepagents_code/_ask_user_types.py +90 -0
- deepagents_code/_cli_context.py +96 -0
- deepagents_code/_constants.py +41 -0
- deepagents_code/_debug.py +148 -0
- deepagents_code/_debug_buffer.py +204 -0
- deepagents_code/_env_vars.py +411 -0
- deepagents_code/_fake_models.py +66 -0
- deepagents_code/_git.py +521 -0
- deepagents_code/_paths.py +69 -0
- deepagents_code/_server_config.py +576 -0
- deepagents_code/_session_stats.py +235 -0
- deepagents_code/_startup_error.py +45 -0
- deepagents_code/_testing_models.py +305 -0
- deepagents_code/_textual_patches.py +420 -0
- deepagents_code/_tool_stream.py +694 -0
- deepagents_code/_version.py +46 -0
- deepagents_code/agent.py +1976 -0
- deepagents_code/app.py +19239 -0
- deepagents_code/app.tcss +438 -0
- deepagents_code/approval_mode.py +131 -0
- deepagents_code/ask_user.py +306 -0
- deepagents_code/auth_display.py +185 -0
- deepagents_code/auth_store.py +545 -0
- deepagents_code/built_in_skills/__init__.py +5 -0
- deepagents_code/built_in_skills/remember/SKILL.md +118 -0
- deepagents_code/built_in_skills/skill-creator/SKILL.md +383 -0
- deepagents_code/built_in_skills/skill-creator/scripts/init_skill.py +366 -0
- deepagents_code/built_in_skills/skill-creator/scripts/quick_validate.py +158 -0
- deepagents_code/client/__init__.py +1 -0
- deepagents_code/client/commands/__init__.py +1 -0
- deepagents_code/client/commands/auth.py +541 -0
- deepagents_code/client/commands/config.py +714 -0
- deepagents_code/client/commands/mcp.py +250 -0
- deepagents_code/client/commands/tools.py +416 -0
- deepagents_code/client/launch/__init__.py +1 -0
- deepagents_code/client/launch/server.py +978 -0
- deepagents_code/client/launch/server_manager.py +540 -0
- deepagents_code/client/non_interactive.py +1758 -0
- deepagents_code/client/remote_client.py +794 -0
- deepagents_code/clipboard.py +217 -0
- deepagents_code/command_registry.py +450 -0
- deepagents_code/config.py +4829 -0
- deepagents_code/config_manifest.py +1451 -0
- deepagents_code/configurable_model.py +577 -0
- deepagents_code/default_agent_prompt.md +12 -0
- deepagents_code/doctor.py +559 -0
- deepagents_code/editor.py +142 -0
- deepagents_code/event_bus.py +411 -0
- deepagents_code/extras_info.py +661 -0
- deepagents_code/file_ops.py +576 -0
- deepagents_code/formatting.py +135 -0
- deepagents_code/goal_rubric.py +497 -0
- deepagents_code/goal_tools.py +459 -0
- deepagents_code/hooks.py +348 -0
- deepagents_code/input.py +1041 -0
- deepagents_code/integrations/__init__.py +1 -0
- deepagents_code/integrations/openai_codex.py +551 -0
- deepagents_code/integrations/sandbox_config.py +198 -0
- deepagents_code/integrations/sandbox_factory.py +1124 -0
- deepagents_code/integrations/sandbox_provider.py +137 -0
- deepagents_code/integrations/sandbox_registry.py +350 -0
- deepagents_code/iterm_cursor_guide.py +176 -0
- deepagents_code/local_context.py +926 -0
- deepagents_code/main.py +3985 -0
- deepagents_code/managed_tools.py +642 -0
- deepagents_code/mcp_auth.py +1950 -0
- deepagents_code/mcp_config.py +176 -0
- deepagents_code/mcp_disabled.py +212 -0
- deepagents_code/mcp_login_service.py +281 -0
- deepagents_code/mcp_oauth_ui.py +199 -0
- deepagents_code/mcp_providers/__init__.py +23 -0
- deepagents_code/mcp_providers/_registry.py +39 -0
- deepagents_code/mcp_providers/base.py +133 -0
- deepagents_code/mcp_providers/github.py +102 -0
- deepagents_code/mcp_providers/slack.py +175 -0
- deepagents_code/mcp_tools.py +2427 -0
- deepagents_code/mcp_trust.py +207 -0
- deepagents_code/media_utils.py +826 -0
- deepagents_code/memory_guard.py +474 -0
- deepagents_code/model_config.py +4156 -0
- deepagents_code/notifications.py +247 -0
- deepagents_code/offload.py +402 -0
- deepagents_code/onboarding.py +223 -0
- deepagents_code/output.py +69 -0
- deepagents_code/paste_collapse.py +103 -0
- deepagents_code/project_utils.py +231 -0
- deepagents_code/py.typed +0 -0
- deepagents_code/reasoning_effort.py +641 -0
- deepagents_code/reliable_rubric.py +97 -0
- deepagents_code/resume_state.py +237 -0
- deepagents_code/server_graph.py +310 -0
- deepagents_code/session_end_summary.py +329 -0
- deepagents_code/sessions.py +1716 -0
- deepagents_code/skills/__init__.py +18 -0
- deepagents_code/skills/commands.py +1252 -0
- deepagents_code/skills/invocation.py +112 -0
- deepagents_code/skills/load.py +196 -0
- deepagents_code/skills/trust.py +547 -0
- deepagents_code/state_migration.py +136 -0
- deepagents_code/subagents.py +278 -0
- deepagents_code/system_prompt.md +204 -0
- deepagents_code/terminal_capabilities.py +115 -0
- deepagents_code/terminal_escape.py +287 -0
- deepagents_code/theme.py +891 -0
- deepagents_code/todo_list_prompt.md +12 -0
- deepagents_code/tool_catalog.py +509 -0
- deepagents_code/tool_display.py +367 -0
- deepagents_code/tools.py +516 -0
- deepagents_code/tui/__init__.py +1 -0
- deepagents_code/tui/textual_adapter.py +2553 -0
- deepagents_code/tui/widgets/__init__.py +9 -0
- deepagents_code/tui/widgets/_js_eval_display.py +139 -0
- deepagents_code/tui/widgets/_links.py +261 -0
- deepagents_code/tui/widgets/agent_selector.py +420 -0
- deepagents_code/tui/widgets/approval.py +602 -0
- deepagents_code/tui/widgets/ask_user.py +515 -0
- deepagents_code/tui/widgets/auth.py +1997 -0
- deepagents_code/tui/widgets/autocomplete.py +890 -0
- deepagents_code/tui/widgets/chat_input.py +3181 -0
- deepagents_code/tui/widgets/codex_auth.py +452 -0
- deepagents_code/tui/widgets/cwd_switch.py +242 -0
- deepagents_code/tui/widgets/debug_console.py +868 -0
- deepagents_code/tui/widgets/diff.py +252 -0
- deepagents_code/tui/widgets/effort_selector.py +189 -0
- deepagents_code/tui/widgets/goal_review.py +390 -0
- deepagents_code/tui/widgets/goal_status.py +50 -0
- deepagents_code/tui/widgets/history.py +194 -0
- deepagents_code/tui/widgets/install_confirm.py +248 -0
- deepagents_code/tui/widgets/launch_init.py +482 -0
- deepagents_code/tui/widgets/loading.py +227 -0
- deepagents_code/tui/widgets/mcp_login.py +539 -0
- deepagents_code/tui/widgets/mcp_reconnect.py +212 -0
- deepagents_code/tui/widgets/mcp_viewer.py +1634 -0
- deepagents_code/tui/widgets/message_store.py +999 -0
- deepagents_code/tui/widgets/messages.py +3846 -0
- deepagents_code/tui/widgets/model_selector.py +2343 -0
- deepagents_code/tui/widgets/notification_center.py +456 -0
- deepagents_code/tui/widgets/notification_detail.py +257 -0
- deepagents_code/tui/widgets/notification_settings.py +170 -0
- deepagents_code/tui/widgets/restart_prompt.py +158 -0
- deepagents_code/tui/widgets/skill_trust.py +131 -0
- deepagents_code/tui/widgets/startup_tip.py +91 -0
- deepagents_code/tui/widgets/status.py +781 -0
- deepagents_code/tui/widgets/subagent_panel.py +969 -0
- deepagents_code/tui/widgets/theme_selector.py +401 -0
- deepagents_code/tui/widgets/thread_selector.py +2564 -0
- deepagents_code/tui/widgets/tool_renderers.py +190 -0
- deepagents_code/tui/widgets/tool_widgets.py +304 -0
- deepagents_code/tui/widgets/update_available.py +311 -0
- deepagents_code/tui/widgets/update_confirm.py +184 -0
- deepagents_code/tui/widgets/update_progress.py +327 -0
- deepagents_code/tui/widgets/welcome.py +508 -0
- deepagents_code/turn_end_summary.py +522 -0
- deepagents_code/ui.py +858 -0
- deepagents_code/unicode_security.py +563 -0
- deepagents_code/update_check.py +3124 -0
- zjcode-0.0.1.data/data/deepagents_code/default_agent_prompt.md +12 -0
- zjcode-0.0.1.dist-info/METADATA +220 -0
- zjcode-0.0.1.dist-info/RECORD +163 -0
- zjcode-0.0.1.dist-info/WHEEL +4 -0
- zjcode-0.0.1.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""Trust store for project-level MCP server configurations.
|
|
2
|
+
|
|
3
|
+
Manages persistent approval of project-level MCP configs that contain stdio
|
|
4
|
+
servers (which execute local commands). Trust is fingerprint-based: if the
|
|
5
|
+
config content changes, the user must re-approve.
|
|
6
|
+
|
|
7
|
+
Trust entries are app-managed bookkeeping (a map of project root to config
|
|
8
|
+
fingerprint), not user-facing configuration, so they live alongside the
|
|
9
|
+
other state files under `~/.deepagents/.state/mcp_trust.json` rather than in
|
|
10
|
+
the hand-editable `config.toml`.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import contextlib
|
|
16
|
+
import hashlib
|
|
17
|
+
import json
|
|
18
|
+
import logging
|
|
19
|
+
import os
|
|
20
|
+
import tempfile
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
_STORAGE_VERSION = 1
|
|
27
|
+
"""Schema version stamped into `mcp_trust.json`; bump on incompatible changes."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _default_store_path() -> Path:
|
|
31
|
+
"""Return `~/.deepagents/.state/mcp_trust.json`.
|
|
32
|
+
|
|
33
|
+
Resolved at call time (not import time) so tests can redirect storage by
|
|
34
|
+
monkeypatching `deepagents_code.model_config.DEFAULT_STATE_DIR` — the same
|
|
35
|
+
pattern `auth_store.auth_path` and `mcp_auth._tokens_dir` use.
|
|
36
|
+
"""
|
|
37
|
+
from deepagents_code.model_config import DEFAULT_STATE_DIR
|
|
38
|
+
|
|
39
|
+
return DEFAULT_STATE_DIR / "mcp_trust.json"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def compute_config_fingerprint(config_paths: list[Path]) -> str:
|
|
43
|
+
"""Compute a SHA-256 fingerprint over sorted, concatenated config contents.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
config_paths: Paths to config files to fingerprint.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
Fingerprint string in the form `sha256:<hex>`.
|
|
50
|
+
"""
|
|
51
|
+
hasher = hashlib.sha256()
|
|
52
|
+
for path in sorted(config_paths):
|
|
53
|
+
try:
|
|
54
|
+
hasher.update(path.read_bytes())
|
|
55
|
+
except OSError:
|
|
56
|
+
logger.warning("Could not read %s for fingerprinting", path, exc_info=True)
|
|
57
|
+
return f"sha256:{hasher.hexdigest()}"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _load_store(store_path: Path) -> dict[str, Any]:
|
|
61
|
+
"""Read the JSON trust store file.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Parsed JSON data, or an empty dict when the file is missing,
|
|
65
|
+
unreadable, or corrupt. A corrupt store degrades to "nothing
|
|
66
|
+
trusted" so a bad file can't crash startup — the next write
|
|
67
|
+
rewrites it cleanly.
|
|
68
|
+
"""
|
|
69
|
+
try:
|
|
70
|
+
if not store_path.exists():
|
|
71
|
+
return {}
|
|
72
|
+
data = json.loads(store_path.read_text(encoding="utf-8"))
|
|
73
|
+
except json.JSONDecodeError as exc:
|
|
74
|
+
# A corrupt store silently drops every prior approval and forces a
|
|
75
|
+
# re-prompt, so log at WARNING (not DEBUG) to leave a breadcrumb for
|
|
76
|
+
# the otherwise-unexplained re-prompt — consistent with the WARNING in
|
|
77
|
+
# compute_config_fingerprint and the exception log in _save_store.
|
|
78
|
+
logger.warning(
|
|
79
|
+
"MCP trust store %s is corrupt; treating as empty: %s", store_path, exc
|
|
80
|
+
)
|
|
81
|
+
return {}
|
|
82
|
+
except OSError as exc:
|
|
83
|
+
logger.warning(
|
|
84
|
+
"Could not read MCP trust store %s; treating as empty: %s",
|
|
85
|
+
store_path,
|
|
86
|
+
exc,
|
|
87
|
+
)
|
|
88
|
+
return {}
|
|
89
|
+
if not isinstance(data, dict):
|
|
90
|
+
logger.warning("MCP trust store %s is not a JSON object; ignoring", store_path)
|
|
91
|
+
return {}
|
|
92
|
+
return data
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _save_store(data: dict[str, Any], store_path: Path) -> bool:
|
|
96
|
+
"""Atomic write of JSON trust data to `store_path`.
|
|
97
|
+
|
|
98
|
+
Uses `tempfile.mkstemp` + `Path.replace` for crash safety.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
data: Full store dict to write.
|
|
102
|
+
store_path: Destination path.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
`True` on success, `False` on I/O failure.
|
|
106
|
+
"""
|
|
107
|
+
try:
|
|
108
|
+
store_path.parent.mkdir(parents=True, exist_ok=True)
|
|
109
|
+
fd, tmp_path = tempfile.mkstemp(dir=store_path.parent, suffix=".tmp")
|
|
110
|
+
try:
|
|
111
|
+
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
|
112
|
+
json.dump(data, f, indent=2)
|
|
113
|
+
Path(tmp_path).replace(store_path)
|
|
114
|
+
except BaseException:
|
|
115
|
+
with contextlib.suppress(OSError):
|
|
116
|
+
Path(tmp_path).unlink()
|
|
117
|
+
raise
|
|
118
|
+
except (OSError, ValueError):
|
|
119
|
+
logger.exception("Failed to save MCP trust store to %s", store_path)
|
|
120
|
+
return False
|
|
121
|
+
return True
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _read_projects(store_path: Path) -> dict[str, Any]:
|
|
125
|
+
"""Return the `projects` mapping from the store, or an empty dict."""
|
|
126
|
+
projects = _load_store(store_path).get("projects", {})
|
|
127
|
+
return projects if isinstance(projects, dict) else {}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def is_project_mcp_trusted(
|
|
131
|
+
project_root: str,
|
|
132
|
+
fingerprint: str,
|
|
133
|
+
*,
|
|
134
|
+
store_path: Path | None = None,
|
|
135
|
+
) -> bool:
|
|
136
|
+
"""Check whether a project's MCP config is trusted with the given fingerprint.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
project_root: Absolute path to the project root.
|
|
140
|
+
fingerprint: Expected fingerprint string (`sha256:<hex>`).
|
|
141
|
+
store_path: Path to the trust store file. Defaults to
|
|
142
|
+
`~/.deepagents/.state/mcp_trust.json`.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
`True` if the stored fingerprint matches.
|
|
146
|
+
"""
|
|
147
|
+
if store_path is None:
|
|
148
|
+
store_path = _default_store_path()
|
|
149
|
+
return _read_projects(store_path).get(project_root) == fingerprint
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def trust_project_mcp(
|
|
153
|
+
project_root: str,
|
|
154
|
+
fingerprint: str,
|
|
155
|
+
*,
|
|
156
|
+
store_path: Path | None = None,
|
|
157
|
+
) -> bool:
|
|
158
|
+
"""Persist trust for a project's MCP config.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
project_root: Absolute path to the project root.
|
|
162
|
+
fingerprint: Fingerprint to store (`sha256:<hex>`).
|
|
163
|
+
store_path: Path to the trust store file. Defaults to
|
|
164
|
+
`~/.deepagents/.state/mcp_trust.json`.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
`True` if the entry was saved successfully.
|
|
168
|
+
"""
|
|
169
|
+
if store_path is None:
|
|
170
|
+
store_path = _default_store_path()
|
|
171
|
+
|
|
172
|
+
data = _load_store(store_path)
|
|
173
|
+
projects = data.get("projects")
|
|
174
|
+
if not isinstance(projects, dict):
|
|
175
|
+
projects = {}
|
|
176
|
+
projects[project_root] = fingerprint
|
|
177
|
+
data["version"] = _STORAGE_VERSION
|
|
178
|
+
data["projects"] = projects
|
|
179
|
+
return _save_store(data, store_path)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def revoke_project_mcp_trust(
|
|
183
|
+
project_root: str,
|
|
184
|
+
*,
|
|
185
|
+
store_path: Path | None = None,
|
|
186
|
+
) -> bool:
|
|
187
|
+
"""Remove trust for a project's MCP config.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
project_root: Absolute path to the project root.
|
|
191
|
+
store_path: Path to the trust store file. Defaults to
|
|
192
|
+
`~/.deepagents/.state/mcp_trust.json`.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
`True` if the entry was removed (or didn't exist).
|
|
196
|
+
"""
|
|
197
|
+
if store_path is None:
|
|
198
|
+
store_path = _default_store_path()
|
|
199
|
+
|
|
200
|
+
data = _load_store(store_path)
|
|
201
|
+
projects = data.get("projects")
|
|
202
|
+
if not isinstance(projects, dict) or project_root not in projects:
|
|
203
|
+
return True
|
|
204
|
+
del projects[project_root]
|
|
205
|
+
data["version"] = _STORAGE_VERSION
|
|
206
|
+
data["projects"] = projects
|
|
207
|
+
return _save_store(data, store_path)
|