deepagents-code 0.2.8__py3-none-any.whl → 0.2.10__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/_build_info.py +1 -1
- deepagents_code/_env_vars.py +11 -0
- deepagents_code/_version.py +1 -1
- deepagents_code/app.py +122 -19
- deepagents_code/config_manifest.py +13 -0
- deepagents_code/extras_info.py +8 -2
- deepagents_code/main.py +46 -4
- deepagents_code/mcp_tools.py +4 -1
- deepagents_code/model_catalog.py +7 -1
- deepagents_code/program_status.py +670 -0
- deepagents_code/tui/widgets/model_selector.py +35 -32
- {deepagents_code-0.2.8.dist-info → deepagents_code-0.2.10.dist-info}/METADATA +19 -19
- {deepagents_code-0.2.8.dist-info → deepagents_code-0.2.10.dist-info}/RECORD +17 -16
- {deepagents_code-0.2.8.data → deepagents_code-0.2.10.data}/data/deepagents_code/default_agent_prompt.md +0 -0
- {deepagents_code-0.2.8.dist-info → deepagents_code-0.2.10.dist-info}/WHEEL +0 -0
- {deepagents_code-0.2.8.dist-info → deepagents_code-0.2.10.dist-info}/entry_points.txt +0 -0
- {deepagents_code-0.2.8.dist-info → deepagents_code-0.2.10.dist-info}/licenses/LICENSE +0 -0
deepagents_code/_build_info.py
CHANGED
deepagents_code/_env_vars.py
CHANGED
|
@@ -715,6 +715,17 @@ overrides `config.toml` instead of falling through. Also settable via
|
|
|
715
715
|
sequence regardless.
|
|
716
716
|
"""
|
|
717
717
|
|
|
718
|
+
TERMINAL_STATUS = "DEEPAGENTS_CODE_TERMINAL_STATUS"
|
|
719
|
+
"""Report agent status to the terminal with `OSC 7501` (Program Status Protocol).
|
|
720
|
+
|
|
721
|
+
Terminals and multiplexers that support the protocol (such as Herdr) show
|
|
722
|
+
whether the agent is working, waiting on you, done, or failed. Enabled by
|
|
723
|
+
default; set to a falsy value (`0`, `false`, `no`, `off`, or blank) to stop
|
|
724
|
+
emitting the sequence. Parsed like `TERMINAL_PROGRESS`. Also settable via
|
|
725
|
+
`[ui].terminal_status` in config.toml. `NO_TERMINAL_ESCAPE` suppresses the
|
|
726
|
+
sequence regardless.
|
|
727
|
+
"""
|
|
728
|
+
|
|
718
729
|
THEME = "DEEPAGENTS_CODE_THEME"
|
|
719
730
|
"""Force the CLI to launch with this theme name when set."""
|
|
720
731
|
|
deepagents_code/_version.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Keep the `x-release-please-version` annotation — release-please uses it to
|
|
4
4
|
# bump `__version__` in sync with `pyproject.toml` on every release PR.
|
|
5
|
-
__version__ = "0.2.
|
|
5
|
+
__version__ = "0.2.10" # x-release-please-version
|
|
6
6
|
|
|
7
7
|
DOCS_URL = "https://docs.langchain.com/oss/python/deepagents/code"
|
|
8
8
|
"""URL for `deepagents-code` documentation."""
|
deepagents_code/app.py
CHANGED
|
@@ -1751,6 +1751,33 @@ def _load_terminal_progress_preference() -> bool:
|
|
|
1751
1751
|
return _load_bool_display_preference("display.terminal_progress", fallback=True)
|
|
1752
1752
|
|
|
1753
1753
|
|
|
1754
|
+
def _approval_status_message(action_requests: Any) -> str: # noqa: ANN401 # ActionRequest uses dynamic typing
|
|
1755
|
+
"""Return a one-line `OSC 7501` message naming the tools awaiting approval.
|
|
1756
|
+
|
|
1757
|
+
Tool arguments are left out: terminals may show the message in desktop
|
|
1758
|
+
notifications.
|
|
1759
|
+
"""
|
|
1760
|
+
names = [
|
|
1761
|
+
name
|
|
1762
|
+
for request in action_requests or []
|
|
1763
|
+
if isinstance(request, dict) and isinstance(name := request.get("name"), str)
|
|
1764
|
+
]
|
|
1765
|
+
return f"Approval needed: {', '.join(dict.fromkeys(names))}" if names else ""
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
def _load_terminal_status_preference() -> bool:
|
|
1769
|
+
"""Resolve whether to emit `OSC 7501` program status reports.
|
|
1770
|
+
|
|
1771
|
+
Turn off with `DEEPAGENTS_CODE_TERMINAL_STATUS=0` or
|
|
1772
|
+
`[ui].terminal_status = false`. `DEEPAGENTS_CODE_NO_TERMINAL_ESCAPE` still
|
|
1773
|
+
disables all terminal escapes regardless of this value.
|
|
1774
|
+
|
|
1775
|
+
Returns:
|
|
1776
|
+
The resolved preference, or `True` when unset, unreadable, or malformed.
|
|
1777
|
+
"""
|
|
1778
|
+
return _load_bool_display_preference("display.terminal_status", fallback=True)
|
|
1779
|
+
|
|
1780
|
+
|
|
1754
1781
|
def _save_terminal_theme_mapping_result(
|
|
1755
1782
|
term_program: str,
|
|
1756
1783
|
name: str,
|
|
@@ -3667,6 +3694,16 @@ class DeepAgentsApp(App):
|
|
|
3667
3694
|
self._terminal_progress_enabled = _load_terminal_progress_preference()
|
|
3668
3695
|
"""Whether to emit `OSC 9;4` taskbar progress (user preference)."""
|
|
3669
3696
|
|
|
3697
|
+
from deepagents_code.program_status import (
|
|
3698
|
+
AgentStatusTracker,
|
|
3699
|
+
ProgramStatusReporter,
|
|
3700
|
+
)
|
|
3701
|
+
|
|
3702
|
+
self._agent_status = AgentStatusTracker(
|
|
3703
|
+
ProgramStatusReporter(enabled=_load_terminal_status_preference())
|
|
3704
|
+
)
|
|
3705
|
+
"""Reports agent status to terminals such as Herdr with `OSC 7501`."""
|
|
3706
|
+
|
|
3670
3707
|
self.sync_terminal_background()
|
|
3671
3708
|
|
|
3672
3709
|
# Injected session config
|
|
@@ -5130,6 +5167,7 @@ class DeepAgentsApp(App):
|
|
|
5130
5167
|
gc.freeze()
|
|
5131
5168
|
self._terminal_title.start()
|
|
5132
5169
|
self._update_terminal_title()
|
|
5170
|
+
self._agent_status.start()
|
|
5133
5171
|
self.screen_change_signal.subscribe(self, self._on_thread_name_screen_change)
|
|
5134
5172
|
self.app_resume_signal.subscribe(self, self._on_terminal_resume)
|
|
5135
5173
|
|
|
@@ -6712,6 +6750,7 @@ class DeepAgentsApp(App):
|
|
|
6712
6750
|
self._connecting = False
|
|
6713
6751
|
self._reconnecting = False
|
|
6714
6752
|
self._connection_ready_event.set()
|
|
6753
|
+
self._agent_status.clear_error()
|
|
6715
6754
|
self._agent = event.agent
|
|
6716
6755
|
self._server_proc = event.server_proc
|
|
6717
6756
|
self._mcp_server_info = event.mcp_server_info
|
|
@@ -6870,6 +6909,9 @@ class DeepAgentsApp(App):
|
|
|
6870
6909
|
)
|
|
6871
6910
|
else:
|
|
6872
6911
|
text = f"Server failed to start: {self._server_startup_error}"
|
|
6912
|
+
from deepagents_code.program_status import TurnOutcome
|
|
6913
|
+
|
|
6914
|
+
self._agent_status.set_outcome(TurnOutcome.ERROR, text)
|
|
6873
6915
|
if had_deferred_actions:
|
|
6874
6916
|
text += (
|
|
6875
6917
|
"\n\nCommands you ran while the server was starting were "
|
|
@@ -9478,6 +9520,9 @@ class DeepAgentsApp(App):
|
|
|
9478
9520
|
|
|
9479
9521
|
def _mark_thread_turn_completed(self) -> None:
|
|
9480
9522
|
"""Record a clean stream end for the thread that owns the active turn."""
|
|
9523
|
+
from deepagents_code.program_status import TurnOutcome
|
|
9524
|
+
|
|
9525
|
+
self._agent_status.set_outcome(TurnOutcome.DONE)
|
|
9481
9526
|
if self._inflight_thread_id == self._lc_thread_id:
|
|
9482
9527
|
self._thread_has_completed_turn = True
|
|
9483
9528
|
|
|
@@ -10074,7 +10119,7 @@ class DeepAgentsApp(App):
|
|
|
10074
10119
|
):
|
|
10075
10120
|
return
|
|
10076
10121
|
self._idle_compaction_seen[thread_id] = expires_at
|
|
10077
|
-
self._set_agent_running(True)
|
|
10122
|
+
self._set_agent_running(True, report_status=False)
|
|
10078
10123
|
try:
|
|
10079
10124
|
self._offload_worker = self.run_worker(
|
|
10080
10125
|
self._run_offload_task(idle_window=(thread_id, expires_at)),
|
|
@@ -11475,6 +11520,13 @@ class DeepAgentsApp(App):
|
|
|
11475
11520
|
# remaining case where a future is abandoned without completing.
|
|
11476
11521
|
self._pause_loading_spinner_for_approval()
|
|
11477
11522
|
result_future.add_done_callback(self._resume_loading_spinner_after_approval)
|
|
11523
|
+
from deepagents_code.program_status import BlockedKind
|
|
11524
|
+
|
|
11525
|
+
self._agent_status.track(
|
|
11526
|
+
result_future,
|
|
11527
|
+
BlockedKind.PERMISSION,
|
|
11528
|
+
_approval_status_message(action_requests),
|
|
11529
|
+
)
|
|
11478
11530
|
|
|
11479
11531
|
# Create menu with unique ID to avoid conflicts
|
|
11480
11532
|
from deepagents_code.tui.widgets.approval import ApprovalMenu
|
|
@@ -11942,6 +11994,13 @@ class DeepAgentsApp(App):
|
|
|
11942
11994
|
unique_id = f"ask-user-menu-{uuid.uuid4().hex[:8]}"
|
|
11943
11995
|
menu = AskUserMenu(questions, id=unique_id)
|
|
11944
11996
|
menu.set_future(result_future)
|
|
11997
|
+
from deepagents_code.program_status import BlockedKind
|
|
11998
|
+
|
|
11999
|
+
self._agent_status.track(
|
|
12000
|
+
result_future,
|
|
12001
|
+
BlockedKind.QUESTION,
|
|
12002
|
+
questions[0]["question"] if questions else "",
|
|
12003
|
+
)
|
|
11945
12004
|
|
|
11946
12005
|
self._pending_ask_user_widget = menu
|
|
11947
12006
|
|
|
@@ -12088,6 +12147,11 @@ class DeepAgentsApp(App):
|
|
|
12088
12147
|
id=unique_id,
|
|
12089
12148
|
)
|
|
12090
12149
|
menu.set_future(result_future)
|
|
12150
|
+
from deepagents_code.program_status import BlockedKind
|
|
12151
|
+
|
|
12152
|
+
self._agent_status.track(
|
|
12153
|
+
result_future, BlockedKind.PERMISSION, "Review the goal's criteria"
|
|
12154
|
+
)
|
|
12091
12155
|
self._pending_goal_review_widget = menu
|
|
12092
12156
|
self._pending_goal_review_future = result_future
|
|
12093
12157
|
|
|
@@ -15198,13 +15262,22 @@ class DeepAgentsApp(App):
|
|
|
15198
15262
|
while self._agent_running or self._agent_reconciling:
|
|
15199
15263
|
await self._agent_quiescent.wait()
|
|
15200
15264
|
|
|
15201
|
-
def _set_agent_running(self, running: bool) -> None:
|
|
15202
|
-
"""Keep the agent-running flag and quiescence event synchronized.
|
|
15265
|
+
def _set_agent_running(self, running: bool, *, report_status: bool = True) -> None:
|
|
15266
|
+
"""Keep the agent-running flag and quiescence event synchronized.
|
|
15267
|
+
|
|
15268
|
+
Args:
|
|
15269
|
+
running: Whether the agent (or exclusive app work) is busy.
|
|
15270
|
+
report_status: Report the change as `OSC 7501` status. Background
|
|
15271
|
+
maintenance passes `False` so it does not replace an unseen
|
|
15272
|
+
`done` with `working` and then `idle`.
|
|
15273
|
+
"""
|
|
15203
15274
|
if running:
|
|
15204
15275
|
self._agent_quiescent.clear()
|
|
15205
15276
|
self._agent_running = running
|
|
15206
15277
|
if not running and not self._agent_reconciling:
|
|
15207
15278
|
self._agent_quiescent.set()
|
|
15279
|
+
if report_status:
|
|
15280
|
+
self._agent_status.set_working(running)
|
|
15208
15281
|
|
|
15209
15282
|
@asynccontextmanager
|
|
15210
15283
|
async def _goal_state_mutation_boundary(self) -> AsyncIterator[None]:
|
|
@@ -18503,10 +18576,15 @@ class DeepAgentsApp(App):
|
|
|
18503
18576
|
)
|
|
18504
18577
|
)
|
|
18505
18578
|
return False
|
|
18579
|
+
from deepagents_code.program_status import BlockedKind
|
|
18580
|
+
|
|
18506
18581
|
try:
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
)
|
|
18582
|
+
with self._agent_status.blocked(
|
|
18583
|
+
BlockedKind.PERMISSION, f"Trust skill {skill_name}?"
|
|
18584
|
+
):
|
|
18585
|
+
allowed = await self._push_screen_wait(
|
|
18586
|
+
SkillTrustScreen(skill_name, directory)
|
|
18587
|
+
)
|
|
18510
18588
|
except Exception:
|
|
18511
18589
|
# Fail closed: a prompt that cannot display is a deny.
|
|
18512
18590
|
logger.warning(
|
|
@@ -19566,11 +19644,13 @@ class DeepAgentsApp(App):
|
|
|
19566
19644
|
cwd=self._cwd,
|
|
19567
19645
|
branch=self._status_bar.branch if self._status_bar else "",
|
|
19568
19646
|
)
|
|
19647
|
+
self._agent_status.set_title(self._thread_name)
|
|
19569
19648
|
|
|
19570
19649
|
def _on_terminal_resume(self, _app: App) -> None:
|
|
19571
|
-
"""Reclaim the tab title from programs that ran
|
|
19650
|
+
"""Reclaim the tab title and status from programs that ran meanwhile."""
|
|
19572
19651
|
self._terminal_title.invalidate()
|
|
19573
19652
|
self._update_terminal_title()
|
|
19653
|
+
self._agent_status.refresh()
|
|
19574
19654
|
|
|
19575
19655
|
async def _load_thread_name(self) -> None:
|
|
19576
19656
|
"""Restore a name without letting an old read replace the active name."""
|
|
@@ -19887,6 +19967,7 @@ class DeepAgentsApp(App):
|
|
|
19887
19967
|
for task in tasks:
|
|
19888
19968
|
task.cancel()
|
|
19889
19969
|
self._terminal_title.restore()
|
|
19970
|
+
self._agent_status.close()
|
|
19890
19971
|
await asyncio.gather(*tasks, return_exceptions=True)
|
|
19891
19972
|
|
|
19892
19973
|
def _effective_model_spec(self) -> str | None:
|
|
@@ -20297,6 +20378,7 @@ class DeepAgentsApp(App):
|
|
|
20297
20378
|
|
|
20298
20379
|
from deepagents_code.config import runtime_state
|
|
20299
20380
|
from deepagents_code.hooks.client_lifecycle import ClientHookStopError
|
|
20381
|
+
from deepagents_code.program_status import TurnOutcome
|
|
20300
20382
|
from deepagents_code.resume_state import RUBRIC_RESULT_VALUES
|
|
20301
20383
|
from deepagents_code.tui.textual_adapter import (
|
|
20302
20384
|
RubricEvaluationEnd,
|
|
@@ -20534,6 +20616,9 @@ class DeepAgentsApp(App):
|
|
|
20534
20616
|
# would blame the model or the backend for a bug in this file —
|
|
20535
20617
|
# and run credential-mismatch detection that cannot apply.
|
|
20536
20618
|
logger.exception("Agent turn setup failed before streaming began")
|
|
20619
|
+
self._agent_status.set_outcome(
|
|
20620
|
+
TurnOutcome.ERROR, "Internal error preparing this turn"
|
|
20621
|
+
)
|
|
20537
20622
|
with suppress(Exception):
|
|
20538
20623
|
await self._mount_message(
|
|
20539
20624
|
ErrorMessage(
|
|
@@ -20552,6 +20637,7 @@ class DeepAgentsApp(App):
|
|
|
20552
20637
|
# The formatter itself must never mask the original error.
|
|
20553
20638
|
logger.exception("format_agent_exception failed")
|
|
20554
20639
|
error_text = f"Agent error: {e!r}"
|
|
20640
|
+
self._agent_status.set_outcome(TurnOutcome.ERROR, error_text)
|
|
20555
20641
|
# Ensure any in-flight tool calls don't remain stuck in "Running..."
|
|
20556
20642
|
# when streaming aborts before tool results arrive.
|
|
20557
20643
|
if self._ui_adapter:
|
|
@@ -20770,7 +20856,10 @@ class DeepAgentsApp(App):
|
|
|
20770
20856
|
"""
|
|
20771
20857
|
self._agent_quiescent.clear()
|
|
20772
20858
|
self._agent_reconciling = True
|
|
20773
|
-
|
|
20859
|
+
# Report the stop in `finally` below, and only if no queued message or
|
|
20860
|
+
# goal continuation started a new turn: reporting it here would flash
|
|
20861
|
+
# `done` between back-to-back turns.
|
|
20862
|
+
self._set_agent_running(False, report_status=False)
|
|
20774
20863
|
self._agent_worker = None
|
|
20775
20864
|
# Tie the flag's lifetime to the worker's: left `True` across turns it
|
|
20776
20865
|
# would disable `_recover_unstarted_agent_worker` for every later turn.
|
|
@@ -20901,6 +20990,8 @@ class DeepAgentsApp(App):
|
|
|
20901
20990
|
# `_goal_state_lock` — would never be woken and would deadlock.
|
|
20902
20991
|
if not self._agent_running and not self._agent_reconciling:
|
|
20903
20992
|
self._agent_quiescent.set()
|
|
20993
|
+
if not self._agent_running:
|
|
20994
|
+
self._agent_status.set_working(False)
|
|
20904
20995
|
# Scheduled after goal reconciliation so the refreshed rows include
|
|
20905
20996
|
# every checkpoint this turn produced.
|
|
20906
20997
|
self._schedule_thread_cache_refresh()
|
|
@@ -22757,6 +22848,7 @@ class DeepAgentsApp(App):
|
|
|
22757
22848
|
async def _clear_messages_unlocked(self) -> None:
|
|
22758
22849
|
"""Clear the messages area and message store."""
|
|
22759
22850
|
self._transcript_generation += 1
|
|
22851
|
+
self._agent_status.start_new_conversation()
|
|
22760
22852
|
# Drop buffered `!` shell output so it never leaks across a thread
|
|
22761
22853
|
# reset, switch, or resume.
|
|
22762
22854
|
self._pending_shell_messages.clear()
|
|
@@ -23749,6 +23841,7 @@ class DeepAgentsApp(App):
|
|
|
23749
23841
|
for task in self._thread_name_tasks.values():
|
|
23750
23842
|
task.cancel()
|
|
23751
23843
|
self._terminal_title.restore()
|
|
23844
|
+
self._agent_status.close()
|
|
23752
23845
|
if self._external_event_source_task is not None:
|
|
23753
23846
|
self._external_event_source_task.cancel()
|
|
23754
23847
|
# Cancellation alone is not enough: the task's `finally` block runs
|
|
@@ -26132,13 +26225,18 @@ class DeepAgentsApp(App):
|
|
|
26132
26225
|
return True
|
|
26133
26226
|
|
|
26134
26227
|
env_var = status.env_var or get_credential_env_var(provider)
|
|
26135
|
-
|
|
26136
|
-
|
|
26137
|
-
|
|
26138
|
-
|
|
26139
|
-
|
|
26228
|
+
from deepagents_code.program_status import BlockedKind
|
|
26229
|
+
|
|
26230
|
+
with self._agent_status.blocked(
|
|
26231
|
+
BlockedKind.AUTH, f"API key required to use {model_spec}"
|
|
26232
|
+
):
|
|
26233
|
+
result = await self._push_screen_wait(
|
|
26234
|
+
AuthPromptScreen(
|
|
26235
|
+
provider,
|
|
26236
|
+
env_var,
|
|
26237
|
+
reason=f"Required to use {model_spec}",
|
|
26238
|
+
)
|
|
26140
26239
|
)
|
|
26141
|
-
)
|
|
26142
26240
|
return result is AuthResult.SAVED
|
|
26143
26241
|
|
|
26144
26242
|
def _register_custom_themes(self) -> None:
|
|
@@ -29446,12 +29544,17 @@ class DeepAgentsApp(App):
|
|
|
29446
29544
|
await asyncio.sleep(0)
|
|
29447
29545
|
|
|
29448
29546
|
login_error: Exception | None = None
|
|
29547
|
+
from deepagents_code.program_status import BlockedKind
|
|
29548
|
+
|
|
29449
29549
|
try:
|
|
29450
|
-
|
|
29451
|
-
server_name
|
|
29452
|
-
|
|
29453
|
-
|
|
29454
|
-
|
|
29550
|
+
with self._agent_status.blocked(
|
|
29551
|
+
BlockedKind.AUTH, f"Sign in to MCP server {server_name}"
|
|
29552
|
+
):
|
|
29553
|
+
await mcp_login(
|
|
29554
|
+
server_name=server_name,
|
|
29555
|
+
server_config=selection.server_config,
|
|
29556
|
+
ui=screen,
|
|
29557
|
+
)
|
|
29455
29558
|
except MCPLoginCancelledError:
|
|
29456
29559
|
screen.finish(success=False, message="Login cancelled.")
|
|
29457
29560
|
await asyncio.wait_for(outcome_future, timeout=5.0)
|
|
@@ -2272,6 +2272,19 @@ _STATIC_OPTIONS: tuple[ConfigOption[object], ...] = (
|
|
|
2272
2272
|
toml_keys=("ui", "terminal_progress"),
|
|
2273
2273
|
empty_env_is_false=True,
|
|
2274
2274
|
),
|
|
2275
|
+
ConfigOption(
|
|
2276
|
+
key="display.terminal_status",
|
|
2277
|
+
group="Display",
|
|
2278
|
+
summary=(
|
|
2279
|
+
"Report agent status (working, waiting on you, done, failed) to terminals "
|
|
2280
|
+
"that support OSC 7501."
|
|
2281
|
+
),
|
|
2282
|
+
kind=OptionKind.BOOL,
|
|
2283
|
+
default=True,
|
|
2284
|
+
env_var=_env_vars.TERMINAL_STATUS,
|
|
2285
|
+
toml_keys=("ui", "terminal_status"),
|
|
2286
|
+
empty_env_is_false=True,
|
|
2287
|
+
),
|
|
2275
2288
|
ConfigOption(
|
|
2276
2289
|
key="terminal.tab_title",
|
|
2277
2290
|
group="Display",
|
deepagents_code/extras_info.py
CHANGED
|
@@ -176,7 +176,7 @@ def _is_under(root: Path, candidate: Path) -> bool:
|
|
|
176
176
|
def _editable_sdk_source_root() -> Path | None:
|
|
177
177
|
"""Return the editable `deepagents` source root from package metadata.
|
|
178
178
|
|
|
179
|
-
Scans
|
|
179
|
+
Scans the installed distributions named `deepagents` for PEP 610
|
|
180
180
|
`direct_url.json` with `dir_info.editable: true`, and credits a record only
|
|
181
181
|
when its source root actually contains the `deepagents` module imported into
|
|
182
182
|
this process.
|
|
@@ -208,7 +208,13 @@ def _editable_sdk_source_root() -> Path | None:
|
|
|
208
208
|
# be attributed to it, so report the plain metadata version.
|
|
209
209
|
return None
|
|
210
210
|
try:
|
|
211
|
-
|
|
211
|
+
# `name=` matches on directory names, so only `deepagents` records have
|
|
212
|
+
# their metadata read; an unfiltered scan parses `METADATA` for every
|
|
213
|
+
# installed package. It still yields *every* matching record across
|
|
214
|
+
# `sys.path`, so the shadowing `*.egg-info` case above is handled.
|
|
215
|
+
for dist in distributions(name="deepagents"):
|
|
216
|
+
# Redundant with the filter for stdlib finders; kept for third-party
|
|
217
|
+
# finders that may ignore `name`.
|
|
212
218
|
if _sdk_distribution_name(dist) != "deepagents":
|
|
213
219
|
continue
|
|
214
220
|
source_root = _sdk_editable_record_root(dist)
|
deepagents_code/main.py
CHANGED
|
@@ -37,6 +37,7 @@ if TYPE_CHECKING:
|
|
|
37
37
|
from deepagents_code.hooks.trust import WorkspaceTrust
|
|
38
38
|
from deepagents_code.mcp_tools import MCPServerInfo, ProjectServerSummary
|
|
39
39
|
from deepagents_code.notifications import PendingNotification
|
|
40
|
+
from deepagents_code.program_status import ProgramStatusReporter
|
|
40
41
|
from deepagents_code.thread_ownership import ThreadLease
|
|
41
42
|
|
|
42
43
|
from deepagents_code._env_vars import LAUNCH_TERM_PROGRAM
|
|
@@ -112,6 +113,28 @@ def _handle_termination_signal(signum: int, _frame: object) -> NoReturn:
|
|
|
112
113
|
raise SystemExit(128 + signum)
|
|
113
114
|
|
|
114
115
|
|
|
116
|
+
def _start_headless_program_status() -> ProgramStatusReporter:
|
|
117
|
+
"""Report a headless run as `working` with `OSC 7501`.
|
|
118
|
+
|
|
119
|
+
The run's final `done` or `error` must outlive the process, so the
|
|
120
|
+
reporter does not clear at exit; terminals drop `working` on their own.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
The reporter for the run's final report.
|
|
124
|
+
"""
|
|
125
|
+
from deepagents_code.config_manifest import load_bool_display_preference
|
|
126
|
+
from deepagents_code.program_status import (
|
|
127
|
+
ProgramState,
|
|
128
|
+
ProgramStatus,
|
|
129
|
+
ProgramStatusReporter,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
enabled = load_bool_display_preference("display.terminal_status", fallback=True)
|
|
133
|
+
reporter = ProgramStatusReporter(enabled=enabled, clear_on_exit=False)
|
|
134
|
+
reporter.report(ProgramStatus(ProgramState.WORKING))
|
|
135
|
+
return reporter
|
|
136
|
+
|
|
137
|
+
|
|
115
138
|
def _install_termination_signal_handlers() -> None:
|
|
116
139
|
"""Install graceful terminating-signal handling on POSIX."""
|
|
117
140
|
if sys.platform != "win32":
|
|
@@ -5864,10 +5887,13 @@ def cli_main() -> None:
|
|
|
5864
5887
|
from acp import run_agent as run_acp_agent
|
|
5865
5888
|
from deepagents_acp.server import AgentServerACP
|
|
5866
5889
|
except ImportError as exc:
|
|
5890
|
+
from deepagents_code.update_check import upgrade_command
|
|
5891
|
+
|
|
5867
5892
|
msg = (
|
|
5868
5893
|
f"ACP dependencies not available: {exc}\n"
|
|
5869
|
-
"
|
|
5870
|
-
"
|
|
5894
|
+
"This usually means an incompatible deepagents-acp or "
|
|
5895
|
+
"agent-client-protocol version is installed. "
|
|
5896
|
+
f"Upgrade with: {upgrade_command()}\n"
|
|
5871
5897
|
)
|
|
5872
5898
|
sys.stderr.write(msg)
|
|
5873
5899
|
sys.stderr.flush()
|
|
@@ -6726,6 +6752,9 @@ def cli_main() -> None:
|
|
|
6726
6752
|
sys.exit(2)
|
|
6727
6753
|
|
|
6728
6754
|
timeout = getattr(args, "timeout", None)
|
|
6755
|
+
program_status = _start_headless_program_status()
|
|
6756
|
+
exit_code: int | None = None
|
|
6757
|
+
failure = ""
|
|
6729
6758
|
try:
|
|
6730
6759
|
exit_code = asyncio.run(
|
|
6731
6760
|
asyncio.wait_for(
|
|
@@ -6781,13 +6810,26 @@ def cli_main() -> None:
|
|
|
6781
6810
|
f"{timeout}s. Retry with a larger --timeout, or use "
|
|
6782
6811
|
"--max-turns for a turn-count limit."
|
|
6783
6812
|
)
|
|
6784
|
-
|
|
6813
|
+
exit_code = 124
|
|
6814
|
+
failure = f"Timed out after {timeout}s"
|
|
6785
6815
|
except KeyboardInterrupt:
|
|
6786
6816
|
# `asyncio.run` re-raises `KeyboardInterrupt` past the inner
|
|
6787
6817
|
# `run_non_interactive` handler when the signal hits during
|
|
6788
6818
|
# `wait_for`; mirror its exit code 130 here so Ctrl-C is a
|
|
6789
6819
|
# quiet exit instead of a traceback.
|
|
6790
|
-
|
|
6820
|
+
exit_code = 130
|
|
6821
|
+
except Exception as exc:
|
|
6822
|
+
# An unexpected crash exits 1 with a traceback; report it as
|
|
6823
|
+
# `error` instead of clearing. A signal's `SystemExit` is not
|
|
6824
|
+
# caught here, so it still clears. Only the type is reported:
|
|
6825
|
+
# the message can hold paths or data meant for the log.
|
|
6826
|
+
exit_code = 1
|
|
6827
|
+
failure = f"Crashed with {type(exc).__name__}"
|
|
6828
|
+
raise
|
|
6829
|
+
finally:
|
|
6830
|
+
from deepagents_code.program_status import exit_status
|
|
6831
|
+
|
|
6832
|
+
program_status.report(exit_status(exit_code, reason=failure))
|
|
6791
6833
|
sys.exit(exit_code)
|
|
6792
6834
|
else:
|
|
6793
6835
|
_print_configured_profile_notice()
|
deepagents_code/mcp_tools.py
CHANGED
|
@@ -2649,7 +2649,10 @@ async def resolve_and_load_mcp_tools(
|
|
|
2649
2649
|
if additional_configs or project_configs:
|
|
2650
2650
|
from deepagents_code.model_config import load_mcp_server_trust_lists
|
|
2651
2651
|
|
|
2652
|
-
|
|
2652
|
+
# Normalizing saved approval roots calls `Path.resolve()`, which calls
|
|
2653
|
+
# `os.readlink` when a root sits under a symlink. That blocks the
|
|
2654
|
+
# server event loop, so read the trust lists in a worker thread.
|
|
2655
|
+
trust_lists = await asyncio.to_thread(load_mcp_server_trust_lists)
|
|
2653
2656
|
config_load_errors.extend(_mcp_trust_list_notices(trust_lists))
|
|
2654
2657
|
|
|
2655
2658
|
# Installing a plugin is the user's trust decision for every bundled
|
deepagents_code/model_catalog.py
CHANGED
|
@@ -185,6 +185,7 @@ def load_model_catalog(
|
|
|
185
185
|
Returns:
|
|
186
186
|
Displayable capabilities, policy, and provider readiness.
|
|
187
187
|
"""
|
|
188
|
+
from deepagents_code.config_manifest import is_provider_package_installed
|
|
188
189
|
from deepagents_code.model_config import MANAGED_CONFIG_SOURCE
|
|
189
190
|
|
|
190
191
|
config = ModelConfig.load()
|
|
@@ -209,7 +210,12 @@ def load_model_catalog(
|
|
|
209
210
|
if provider not in providers:
|
|
210
211
|
providers[provider] = _provider_entry(provider, config)
|
|
211
212
|
info = providers[provider]
|
|
212
|
-
if
|
|
213
|
+
if (
|
|
214
|
+
provider in available
|
|
215
|
+
or info.install_extra
|
|
216
|
+
or is_provider_package_installed(provider)
|
|
217
|
+
or spec == current_spec
|
|
218
|
+
):
|
|
213
219
|
models.append(spec)
|
|
214
220
|
except Exception:
|
|
215
221
|
logger.warning(
|