devtrace-cli 1.0.0__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.
@@ -0,0 +1,110 @@
1
+ """Node.js declared vs installed dependency collector."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from pathlib import Path
7
+
8
+ from devtrace.core.models import LanguageDependencies
9
+
10
+
11
+ def _read_package_json_declared(project_dir: Path) -> tuple[dict[str, str], list[str]]:
12
+ """Read dependencies and devDependencies from package.json."""
13
+ pkg_json = project_dir / "package.json"
14
+ if not pkg_json.is_file():
15
+ return {}, []
16
+
17
+ try:
18
+ data = json.loads(pkg_json.read_text(encoding="utf-8"))
19
+ except (OSError, json.JSONDecodeError) as exc:
20
+ return {}, [f"Failed to parse package.json: {type(exc).__name__}"]
21
+
22
+ if not isinstance(data, dict):
23
+ return {}, ["package.json root is not a JSON object."]
24
+
25
+ declared: dict[str, str] = {}
26
+ for section in ("dependencies", "devDependencies"):
27
+ block = data.get(section, {})
28
+ if isinstance(block, dict):
29
+ for pkg, ver in block.items():
30
+ if isinstance(pkg, str) and isinstance(ver, str):
31
+ declared[pkg] = ver
32
+
33
+ return dict(sorted(declared.items())), []
34
+
35
+
36
+ def _read_node_modules_installed(project_dir: Path) -> dict[str, str]:
37
+ """Read installed versions for direct packages in node_modules."""
38
+ node_modules = project_dir / "node_modules"
39
+ if not node_modules.is_dir():
40
+ return {}
41
+
42
+ installed: dict[str, str] = {}
43
+ try:
44
+ entries = list(node_modules.iterdir())
45
+ except OSError:
46
+ return {}
47
+
48
+ for entry in entries:
49
+ if entry.name.startswith(".") or not entry.is_dir():
50
+ continue
51
+ if entry.name.startswith("@"):
52
+ # Scoped packages like @types/node
53
+ try:
54
+ scoped_entries = list(entry.iterdir())
55
+ except OSError:
56
+ continue
57
+ for sub in scoped_entries:
58
+ pkg_file = sub / "package.json"
59
+ if pkg_file.is_file():
60
+ ver = _extract_pkg_version(pkg_file)
61
+ if ver:
62
+ installed[f"{entry.name}/{sub.name}"] = ver
63
+ else:
64
+ pkg_file = entry / "package.json"
65
+ if pkg_file.is_file():
66
+ ver = _extract_pkg_version(pkg_file)
67
+ if ver:
68
+ installed[entry.name] = ver
69
+
70
+ return dict(sorted(installed.items()))
71
+
72
+
73
+ def _extract_pkg_version(pkg_json_path: Path) -> str | None:
74
+ """Safely extract version string from an installed package's package.json."""
75
+ try:
76
+ data = json.loads(pkg_json_path.read_text(encoding="utf-8"))
77
+ if isinstance(data, dict) and isinstance(data.get("version"), str):
78
+ return data["version"]
79
+ except (OSError, json.JSONDecodeError):
80
+ return None
81
+ return None
82
+
83
+
84
+ def collect_node_dependencies(
85
+ project_dir: Path,
86
+ has_node_manifest: bool,
87
+ ) -> tuple[LanguageDependencies, list[str]]:
88
+ """Collect Node.js declared vs installed dependencies and detect drift."""
89
+ if not has_node_manifest:
90
+ return LanguageDependencies(), []
91
+
92
+ declared, warnings = _read_package_json_declared(project_dir)
93
+ installed = _read_node_modules_installed(project_dir)
94
+
95
+ declared_keys = set(declared.keys())
96
+ installed_keys = set(installed.keys())
97
+
98
+ missing = sorted(declared_keys - installed_keys)
99
+ # Flag undeclared packages only when node_modules exists
100
+ undeclared = sorted(installed_keys - declared_keys) if installed else []
101
+
102
+ return (
103
+ LanguageDependencies(
104
+ declared=declared,
105
+ installed=installed,
106
+ missing_from_env=missing,
107
+ undeclared_in_manifest=undeclared,
108
+ ),
109
+ warnings,
110
+ )
@@ -0,0 +1,37 @@
1
+ """Node.js runtime collector."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import shutil
6
+ import subprocess
7
+
8
+ from devtrace.core.models import RuntimeInfo
9
+
10
+
11
+ def collect_node_runtime(timeout_seconds: float = 3.0) -> tuple[RuntimeInfo, list[str]]:
12
+ """Safely detect Node.js availability and version without failing if absent."""
13
+ node_path = shutil.which("node")
14
+ if node_path is None:
15
+ return RuntimeInfo(available=False, version=None), []
16
+
17
+ try:
18
+ completed = subprocess.run(
19
+ [node_path, "--version"],
20
+ capture_output=True,
21
+ text=True,
22
+ timeout=timeout_seconds,
23
+ check=False,
24
+ )
25
+ except (OSError, subprocess.TimeoutExpired) as exc:
26
+ warning = f"Node.js binary found but version check failed: {type(exc).__name__}"
27
+ return RuntimeInfo(available=True, version=None), [warning]
28
+
29
+ if completed.returncode != 0:
30
+ return (
31
+ RuntimeInfo(available=True, version=None),
32
+ [f"Node.js version check exited with code {completed.returncode}."],
33
+ )
34
+
35
+ raw_version = completed.stdout.strip().lstrip("v")
36
+ version = raw_version if raw_version else None
37
+ return RuntimeInfo(available=True, version=version), []
@@ -0,0 +1,136 @@
1
+ """Python declared vs installed dependency collector."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.metadata
6
+ import re
7
+ from pathlib import Path
8
+
9
+ try:
10
+ import tomllib
11
+ except ModuleNotFoundError: # Python 3.10 fallback
12
+ import tomli as tomllib # type: ignore[no-redef]
13
+
14
+ from devtrace.core.models import LanguageDependencies
15
+
16
+ _REQ_PATTERN = re.compile(r"^([A-Za-z0-9_.-]+)(?:\[[^\]]+\])?\s*(.*)$")
17
+
18
+
19
+ def normalize_pkg_name(name: str) -> str:
20
+ """Normalize Python package names per PEP 503."""
21
+ return re.sub(r"[-_.]+", "-", name).lower().strip()
22
+
23
+
24
+ def _parse_requirement_line(raw_line: str) -> tuple[str, str] | None:
25
+ """Extract (normalized_name, specifier) from a PEP 508 requirement string."""
26
+ line = raw_line.split("#", 1)[0].strip()
27
+ if not line or line.startswith(("-", "git+", "http://", "https://", ".")):
28
+ return None
29
+ line = line.split(";", 1)[0].strip()
30
+ match = _REQ_PATTERN.match(line)
31
+ if not match:
32
+ return None
33
+ name = normalize_pkg_name(match.group(1))
34
+ spec = match.group(2).strip() or "*"
35
+ return name, spec
36
+
37
+
38
+ def _read_pyproject_declared(project_dir: Path) -> tuple[dict[str, str], list[str]]:
39
+ """Read dependencies from pyproject.toml if present."""
40
+ pyproject_path = project_dir / "pyproject.toml"
41
+ if not pyproject_path.is_file():
42
+ return {}, []
43
+
44
+ declared: dict[str, str] = {}
45
+ warnings: list[str] = []
46
+ try:
47
+ data = tomllib.loads(pyproject_path.read_text(encoding="utf-8"))
48
+ except (OSError, tomllib.TOMLDecodeError) as exc:
49
+ return {}, [f"Failed to parse pyproject.toml: {type(exc).__name__}"]
50
+
51
+ project_table = data.get("project", {})
52
+ if isinstance(project_table, dict):
53
+ deps = project_table.get("dependencies", [])
54
+ if isinstance(deps, list):
55
+ for item in deps:
56
+ if isinstance(item, str):
57
+ parsed = _parse_requirement_line(item)
58
+ if parsed:
59
+ declared[parsed[0]] = parsed[1]
60
+
61
+ optional_deps = project_table.get("optional-dependencies", {})
62
+ if isinstance(optional_deps, dict):
63
+ for group_deps in optional_deps.values():
64
+ if isinstance(group_deps, list):
65
+ for item in group_deps:
66
+ if isinstance(item, str):
67
+ parsed = _parse_requirement_line(item)
68
+ if parsed and parsed[0] not in declared:
69
+ declared[parsed[0]] = parsed[1]
70
+
71
+ return declared, warnings
72
+
73
+
74
+ def _read_requirements_txt(project_dir: Path) -> tuple[dict[str, str], list[str]]:
75
+ """Read dependencies from requirements.txt if present."""
76
+ req_path = project_dir / "requirements.txt"
77
+ if not req_path.is_file():
78
+ return {}, []
79
+
80
+ declared: dict[str, str] = {}
81
+ try:
82
+ lines = req_path.read_text(encoding="utf-8").splitlines()
83
+ except OSError as exc:
84
+ return {}, [f"Failed to read requirements.txt: {type(exc).__name__}"]
85
+
86
+ for raw in lines:
87
+ parsed = _parse_requirement_line(raw)
88
+ if parsed and parsed[0] not in declared:
89
+ declared[parsed[0]] = parsed[1]
90
+
91
+ return declared, []
92
+
93
+
94
+ def _get_installed_packages() -> dict[str, str]:
95
+ """Collect installed distributions in the active Python environment."""
96
+ installed: dict[str, str] = {}
97
+ for dist in importlib.metadata.distributions():
98
+ raw_name = dist.metadata.get("Name")
99
+ if raw_name:
100
+ norm = normalize_pkg_name(raw_name)
101
+ installed[norm] = dist.version
102
+ return dict(sorted(installed.items()))
103
+
104
+
105
+ def collect_python_dependencies(
106
+ project_dir: Path,
107
+ has_python_manifest: bool,
108
+ ) -> tuple[LanguageDependencies, list[str]]:
109
+ """Collect Python declared vs installed dependencies and detect drift."""
110
+ if not has_python_manifest:
111
+ return LanguageDependencies(), []
112
+
113
+ declared_pyproject, warn_py = _read_pyproject_declared(project_dir)
114
+ declared_req, warn_req = _read_requirements_txt(project_dir)
115
+
116
+ declared = {**declared_req, **declared_pyproject}
117
+ declared = dict(sorted(declared.items()))
118
+ installed = _get_installed_packages()
119
+
120
+ declared_keys = set(declared.keys())
121
+ installed_keys = set(installed.keys())
122
+
123
+ missing = sorted(declared_keys - installed_keys)
124
+ # Ignore packaging tools like pip/setuptools/wheel when reporting undeclared drift
125
+ ignored_base = {"pip", "setuptools", "wheel"}
126
+ undeclared = sorted(installed_keys - declared_keys - ignored_base)
127
+
128
+ return (
129
+ LanguageDependencies(
130
+ declared=declared,
131
+ installed=installed,
132
+ missing_from_env=missing,
133
+ undeclared_in_manifest=undeclared,
134
+ ),
135
+ [*warn_py, *warn_req],
136
+ )
@@ -0,0 +1,18 @@
1
+ """Python runtime collector."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import platform
6
+
7
+ from devtrace.core.models import RuntimeInfo
8
+
9
+
10
+ def collect_python_runtime() -> tuple[RuntimeInfo, list[str]]:
11
+ """Detect the Python runtime executing DevTrace."""
12
+ version = platform.python_version() or None
13
+ if version is None:
14
+ return (
15
+ RuntimeInfo(available=True, version=None),
16
+ ["Python runtime version could not be determined."],
17
+ )
18
+ return RuntimeInfo(available=True, version=version), []
@@ -0,0 +1,46 @@
1
+ """System and OS environment collector."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import platform
6
+
7
+ from devtrace.core.models import SystemInfo
8
+
9
+
10
+ def _read_linux_pretty_name() -> str | None:
11
+ """Read PRETTY_NAME from /etc/os-release if available on Linux."""
12
+ try:
13
+ with open("/etc/os-release", encoding="utf-8") as f:
14
+ for line in f:
15
+ line = line.strip()
16
+ if line.startswith("PRETTY_NAME="):
17
+ value = line.split("=", 1)[1].strip()
18
+ return value.strip('"').strip("'")
19
+ except OSError:
20
+ return None
21
+ return None
22
+
23
+
24
+ def collect_system_info() -> tuple[SystemInfo, list[str]]:
25
+ """Collect host operating system, release, and CPU architecture."""
26
+ warnings: list[str] = []
27
+
28
+ os_name = platform.system() or "unknown"
29
+ architecture = platform.machine() or "unknown"
30
+
31
+ os_release = platform.release() or "unknown"
32
+ if os_name == "Linux":
33
+ pretty_name = _read_linux_pretty_name()
34
+ if pretty_name:
35
+ os_release = pretty_name
36
+ else:
37
+ warnings.append("Could not read /etc/os-release; using kernel release.")
38
+
39
+ return (
40
+ SystemInfo(
41
+ os=os_name,
42
+ os_release=os_release,
43
+ architecture=architecture,
44
+ ),
45
+ warnings,
46
+ )
File without changes
devtrace/core/agent.py ADDED
@@ -0,0 +1,297 @@
1
+ """Autonomous multi-step tool-calling agent for DevTrace (`devtrace ask`)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import urllib.error
8
+ import urllib.request
9
+ from dataclasses import dataclass, field
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from devtrace.core.collector import capture_environment
14
+ from devtrace.core.comparator import compare_snapshots, load_snapshot_file
15
+ from devtrace.core.diagnostics import load_error_file, run_diagnostics
16
+ from devtrace.storage.history_store import find_baseline_snapshot, list_history
17
+
18
+ DEFAULT_BASE_URL = "http://localhost:11434/v1"
19
+ DEFAULT_MODEL = "llama3.2"
20
+
21
+ AGENT_TOOLS_SCHEMA: list[dict[str, Any]] = [
22
+ {
23
+ "type": "function",
24
+ "function": {
25
+ "name": "inspect_live_environment",
26
+ "description": (
27
+ "Capture the current live OS, Python/Node runtimes, and declared vs "
28
+ "installed dependency drift for the project."
29
+ ),
30
+ "parameters": {"type": "object", "properties": {}},
31
+ },
32
+ },
33
+ {
34
+ "type": "function",
35
+ "function": {
36
+ "name": "run_diagnostic_rules",
37
+ "description": (
38
+ "Run DevTrace deterministic diagnostic rules against the current "
39
+ "environment and the user's optional crash log."
40
+ ),
41
+ "parameters": {"type": "object", "properties": {}},
42
+ },
43
+ },
44
+ {
45
+ "type": "function",
46
+ "function": {
47
+ "name": "get_snapshot_history",
48
+ "description": (
49
+ "List recorded chronological snapshots and tags (such as 'working') "
50
+ "stored in .devtrace/history/."
51
+ ),
52
+ "parameters": {"type": "object", "properties": {}},
53
+ },
54
+ },
55
+ {
56
+ "type": "function",
57
+ "function": {
58
+ "name": "time_travel_diff",
59
+ "description": (
60
+ "Compare the current live environment against the latest saved "
61
+ "snapshot or a specific tagged baseline (e.g. 'working')."
62
+ ),
63
+ "parameters": {
64
+ "type": "object",
65
+ "properties": {
66
+ "against_tag": {
67
+ "type": "string",
68
+ "description": "Optional snapshot tag to compare against.",
69
+ }
70
+ },
71
+ },
72
+ },
73
+ },
74
+ ]
75
+
76
+
77
+ @dataclass
78
+ class AgentTurnTrace:
79
+ """Record of one tool invocation performed by the agent."""
80
+
81
+ tool_name: str
82
+ arguments: dict[str, Any]
83
+ summary: str
84
+
85
+
86
+ @dataclass
87
+ class AgentResult:
88
+ """Final answer and tool-execution audit trail from DevTrace Agent."""
89
+
90
+ question: str
91
+ answer: str
92
+ tool_trace: list[AgentTurnTrace] = field(default_factory=list)
93
+ mode: str = "llm" # "llm" | "offline-fallback"
94
+
95
+
96
+ def execute_agent_tool(
97
+ tool_name: str,
98
+ arguments: dict[str, Any],
99
+ project_dir: Path,
100
+ error_text: str | None = None,
101
+ ) -> tuple[dict[str, Any], str]:
102
+ """Run a deterministic DevTrace tool and return (json_payload, short_summary)."""
103
+ if tool_name == "inspect_live_environment":
104
+ snap = capture_environment(project_dir).to_dict()
105
+ py_d = snap["dependencies"]["python"]
106
+ summary = (
107
+ f"Captured live env: Py {snap['runtimes']['python']['version']}, "
108
+ f"missing={len(py_d['missing_from_env'])}, "
109
+ f"undeclared={len(py_d['undeclared_in_manifest'])}"
110
+ )
111
+ return snap, summary
112
+
113
+ if tool_name == "run_diagnostic_rules":
114
+ snap = capture_environment(project_dir).to_dict()
115
+ report = run_diagnostics(snap, error_text=error_text).to_dict()
116
+ count = len(report["findings"])
117
+ return report, f"Ran diagnostic rules: {count} finding(s) triggered"
118
+
119
+ if tool_name == "get_snapshot_history":
120
+ entries = list_history(project_dir)
121
+ payload = {
122
+ "count": len(entries),
123
+ "snapshots": [
124
+ {
125
+ "snapshot_id": e.snapshot_id,
126
+ "captured_at": e.captured_at,
127
+ "tag": e.tag,
128
+ "python": e.python_version,
129
+ "node": e.node_version,
130
+ "drift_count": e.drift_count,
131
+ }
132
+ for e in entries
133
+ ],
134
+ }
135
+ return payload, f"Loaded {len(entries)} historical snapshot(s)"
136
+
137
+ if tool_name == "time_travel_diff":
138
+ tag = arguments.get("against_tag")
139
+ baseline = find_baseline_snapshot(project_dir, tag=tag)
140
+ base_data = load_snapshot_file(baseline.file_path)
141
+ live_data = capture_environment(project_dir).to_dict()
142
+ comp = compare_snapshots(base_data, live_data).to_dict()
143
+ return comp, f"Compared live env against baseline ({tag or 'latest'})"
144
+
145
+ raise ValueError(f"Unknown agent tool: {tool_name}")
146
+
147
+
148
+ def _call_chat_completions(
149
+ messages: list[dict[str, Any]],
150
+ tools: list[dict[str, Any]],
151
+ model: str,
152
+ base_url: str,
153
+ api_key: str,
154
+ timeout_seconds: float = 30.0,
155
+ ) -> dict[str, Any]:
156
+ """Call an OpenAI-compatible /chat/completions endpoint with tool definitions."""
157
+ endpoint = f"{base_url.rstrip('/')}/chat/completions"
158
+ payload = {
159
+ "model": model,
160
+ "temperature": 0.1,
161
+ "messages": messages,
162
+ "tools": tools,
163
+ "tool_choice": "auto",
164
+ }
165
+ req = urllib.request.Request(
166
+ endpoint,
167
+ data=json.dumps(payload).encode("utf-8"),
168
+ headers={
169
+ "Content-Type": "application/json",
170
+ "Authorization": f"Bearer {api_key}",
171
+ },
172
+ method="POST",
173
+ )
174
+ with urllib.request.urlopen(req, timeout=timeout_seconds) as resp:
175
+ return json.loads(resp.read().decode("utf-8"))
176
+
177
+
178
+ def run_offline_deterministic_agent(
179
+ question: str,
180
+ project_dir: Path,
181
+ error_text: str | None = None,
182
+ ) -> AgentResult:
183
+ """Fallback deterministic investigation when no LLM endpoint is reachable."""
184
+ traces: list[AgentTurnTrace] = []
185
+
186
+ diag_data, diag_sum = execute_agent_tool(
187
+ "run_diagnostic_rules", {}, project_dir, error_text=error_text
188
+ )
189
+ traces.append(AgentTurnTrace("run_diagnostic_rules", {}, diag_sum))
190
+
191
+ hist_data, hist_sum = execute_agent_tool("get_snapshot_history", {}, project_dir)
192
+ traces.append(AgentTurnTrace("get_snapshot_history", {}, hist_sum))
193
+
194
+ lines = [
195
+ f"Question: {question}",
196
+ "Mode: Deterministic Offline Investigation (no LLM endpoint required)",
197
+ "",
198
+ f"- Diagnostic findings triggered: {len(diag_data['findings'])}",
199
+ ]
200
+ for f in diag_data["findings"]:
201
+ lines.append(f" * [{f['severity'].upper()}] {f['rule_id']}: {f['title']}")
202
+ lines.append(f" Next Check: {f['next_check']}")
203
+
204
+ lines.append(f"- Recorded history snapshots: {hist_data['count']}")
205
+ return AgentResult(
206
+ question=question,
207
+ answer="\n".join(lines),
208
+ tool_trace=traces,
209
+ mode="offline-fallback",
210
+ )
211
+
212
+
213
+ def run_devtrace_agent(
214
+ question: str,
215
+ project_dir: Path,
216
+ error_file: Path | None = None,
217
+ model: str | None = None,
218
+ base_url: str | None = None,
219
+ api_key: str | None = None,
220
+ offline_only: bool = False,
221
+ max_steps: int = 5,
222
+ ) -> AgentResult:
223
+ """Execute a multi-step tool-calling investigation to answer a developer query."""
224
+ err_text = load_error_file(error_file) if error_file else None
225
+ if offline_only:
226
+ return run_offline_deterministic_agent(question, project_dir, error_text=err_text)
227
+
228
+ resolved_url = base_url or os.getenv("DEVTRACE_AI_BASE_URL") or DEFAULT_BASE_URL
229
+ resolved_model = model or os.getenv("DEVTRACE_AI_MODEL") or DEFAULT_MODEL
230
+ resolved_key = api_key or os.getenv("DEVTRACE_AI_API_KEY") or "ollama"
231
+
232
+ system_prompt = (
233
+ "You are DevTrace Agent, an autonomous environment diagnostics engineer.\n"
234
+ "Use the provided deterministic tools to inspect the developer's environment, "
235
+ "history, and diagnostic rules before answering.\n"
236
+ "Cite exact tool facts, versions, and rule IDs. Never invent data."
237
+ )
238
+ user_content = question
239
+ if err_text:
240
+ user_content += f"\n\nAttached error log excerpt:\n{err_text[:2500]}"
241
+
242
+ messages: list[dict[str, Any]] = [
243
+ {"role": "system", "content": system_prompt},
244
+ {"role": "user", "content": user_content},
245
+ ]
246
+ traces: list[AgentTurnTrace] = []
247
+
248
+ try:
249
+ for _ in range(max_steps):
250
+ raw = _call_chat_completions(
251
+ messages=messages,
252
+ tools=AGENT_TOOLS_SCHEMA,
253
+ model=resolved_model,
254
+ base_url=resolved_url,
255
+ api_key=resolved_key,
256
+ )
257
+ choice = (raw.get("choices") or [{}])[0]
258
+ msg = choice.get("message") or {}
259
+ tool_calls = msg.get("tool_calls") or []
260
+
261
+ if not tool_calls:
262
+ final_text = str(msg.get("content") or "").strip()
263
+ return AgentResult(
264
+ question=question,
265
+ answer=final_text or "No response generated.",
266
+ tool_trace=traces,
267
+ mode="llm",
268
+ )
269
+
270
+ messages.append(msg)
271
+ for tc in tool_calls:
272
+ tc_id = tc.get("id", "call_0")
273
+ fn = tc.get("function") or {}
274
+ fn_name = str(fn.get("name", ""))
275
+ raw_args = fn.get("arguments") or "{}"
276
+ parsed_args = json.loads(raw_args) if isinstance(raw_args, str) else dict(raw_args)
277
+
278
+ try:
279
+ tool_out, summary = execute_agent_tool(
280
+ fn_name, parsed_args, project_dir, error_text=err_text
281
+ )
282
+ except Exception as exc:
283
+ tool_out = {"error": str(exc)}
284
+ summary = f"Tool error: {exc}"
285
+
286
+ traces.append(AgentTurnTrace(fn_name, parsed_args, summary))
287
+ messages.append(
288
+ {
289
+ "role": "tool",
290
+ "tool_call_id": tc_id,
291
+ "content": json.dumps(tool_out),
292
+ }
293
+ )
294
+ except urllib.error.URLError:
295
+ return run_offline_deterministic_agent(question, project_dir, error_text=err_text)
296
+
297
+ return run_offline_deterministic_agent(question, project_dir, error_text=err_text)