deepagents-code 0.2.9__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.
@@ -1,3 +1,3 @@
1
1
  """Generated at build time. Do not edit or commit."""
2
2
 
3
- BUILD_COMMIT = "7db36f2"
3
+ BUILD_COMMIT = "07f02d3"
@@ -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
 
@@ -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.9" # x-release-please-version
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
- allowed = await self._push_screen_wait(
18508
- SkillTrustScreen(skill_name, directory)
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 while suspended."""
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
- self._set_agent_running(False)
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
- result = await self._push_screen_wait(
26136
- AuthPromptScreen(
26137
- provider,
26138
- env_var,
26139
- reason=f"Required to use {model_spec}",
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
- await mcp_login(
29451
- server_name=server_name,
29452
- server_config=selection.server_config,
29453
- ui=screen,
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/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
- "Install with: uv tool install --reinstall -U deepagents-code "
5870
- "--with deepagents-acp\n"
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
- sys.exit(124)
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
- sys.exit(130)
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()
@@ -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
- trust_lists = load_mcp_server_trust_lists()
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
@@ -0,0 +1,670 @@
1
+ """Report agent status to the terminal with `OSC 7501` (Program Status Protocol).
2
+
3
+ Terminals and multiplexers that implement the protocol (for example Herdr)
4
+ show what each program is doing: working, waiting on the user, finished, or
5
+ failed. See https://www.superlogical.com/rex/docs/build/program-status.
6
+
7
+ The encoding functions are pure. `ProgramStatusReporter` is the only part that
8
+ writes, through `terminal_escape.write_terminal_escape`, so the
9
+ `DEEPAGENTS_CODE_NO_TERMINAL_ESCAPE` opt-out applies.
10
+
11
+ The reporter never sends the support query (`OSC 7501 ; ? ST`). The spec lets
12
+ programs report without asking, and waiting for a reply can silently disable
13
+ reporting on slow startups.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import atexit
19
+ import base64
20
+ import logging
21
+ import re
22
+ import threading
23
+ import unicodedata
24
+ from contextlib import contextmanager
25
+ from dataclasses import dataclass, replace
26
+ from enum import StrEnum
27
+ from typing import TYPE_CHECKING
28
+
29
+ if TYPE_CHECKING:
30
+ import asyncio
31
+ from collections.abc import Callable, Iterator
32
+
33
+ logger = logging.getLogger(__name__)
34
+
35
+ APP_NAME = "deepagents-code"
36
+ """Stable `app` identifier sent with every report."""
37
+
38
+ MAX_SEQUENCE_BYTES = 4096
39
+ """Spec cap for a whole report, from `OSC` through `ST`."""
40
+
41
+ MAX_TITLE_BYTES = 192
42
+ """Spec cap for the decoded `title` (256 bytes once base64-encoded)."""
43
+
44
+ MAX_MSG_BYTES = 2048
45
+ """Spec cap for the decoded `msg` (2732 bytes once base64-encoded)."""
46
+
47
+ _SEGMENT = r"[A-Za-z0-9_.+-]{1,32}"
48
+ _APP_RE = re.compile(_SEGMENT)
49
+ _ID_RE = re.compile(rf"{_SEGMENT}(?:/{_SEGMENT}){{0,7}}")
50
+ _MAX_ID_BYTES = 128
51
+ _ST = "\x1b\\"
52
+
53
+
54
+ class ProgramState(StrEnum):
55
+ """Values of the protocol's required `state` key."""
56
+
57
+ IDLE = "idle"
58
+ """At rest, waiting for the user's next instruction."""
59
+
60
+ WORKING = "working"
61
+ """Running. Terminals drop this record when the process exits."""
62
+
63
+ DONE = "done"
64
+ """Finished, result not yet seen. Survives process exit."""
65
+
66
+ BLOCKED = "blocked"
67
+ """Cannot continue until the user acts. `kind` says what kind of input."""
68
+
69
+ ERROR = "error"
70
+ """Failed and stopped. Survives process exit."""
71
+
72
+ CLEAR = "clear"
73
+ """Not a state: removes the addressed record and every record below it."""
74
+
75
+
76
+ class BlockedKind(StrEnum):
77
+ """Values of the `kind` key, which terminals read only with `blocked`."""
78
+
79
+ PERMISSION = "permission"
80
+ """Waiting for the user to approve an action."""
81
+
82
+ QUESTION = "question"
83
+ """Waiting for the user to answer a question."""
84
+
85
+ AUTH = "auth"
86
+ """Waiting for the user to sign in or provide credentials."""
87
+
88
+
89
+ _PROGRESS_STATES = frozenset({ProgramState.WORKING, ProgramState.BLOCKED})
90
+
91
+
92
+ @dataclass(frozen=True, slots=True)
93
+ class ProgramStatus:
94
+ """One report for one record.
95
+
96
+ Each report replaces its record entirely on the terminal, so every field
97
+ that should stay visible must be set on every report.
98
+
99
+ Attributes:
100
+ state: The record's state, or `CLEAR` to remove it.
101
+ kind: What the user must do. Only valid with `BLOCKED`.
102
+ progress: Percent complete, `0`-`100`. Only valid with `WORKING` or
103
+ `BLOCKED`; `None` means indeterminate.
104
+ record_id: Sub-record path such as `task/1`; `None` addresses the
105
+ program's own (root) record.
106
+ title: Short label. Control characters are replaced and the text is
107
+ truncated to fit the spec when encoded.
108
+ msg: One human-readable line, sanitized and truncated like `title`.
109
+ """
110
+
111
+ state: ProgramState
112
+ kind: BlockedKind | None = None
113
+ progress: int | None = None
114
+ record_id: str | None = None
115
+ title: str = ""
116
+ msg: str = ""
117
+
118
+ def __post_init__(self) -> None:
119
+ """Reject combinations the protocol would silently ignore.
120
+
121
+ Raises:
122
+ ValueError: If `kind`, `progress`, `title`, `msg`, or `record_id`
123
+ is invalid for this report.
124
+ """
125
+ if self.kind is not None and self.state is not ProgramState.BLOCKED:
126
+ msg = f"kind is only valid with state=blocked, not {self.state}"
127
+ raise ValueError(msg)
128
+ if self.state is ProgramState.CLEAR and (self.title or self.msg):
129
+ msg = "title and msg are not valid with state=clear"
130
+ raise ValueError(msg)
131
+ if self.progress is not None:
132
+ _check_progress(self.state, self.progress)
133
+ if self.record_id is not None and not is_valid_record_id(self.record_id):
134
+ msg = f"invalid OSC 7501 record id: {self.record_id!r}"
135
+ raise ValueError(msg)
136
+
137
+
138
+ def _check_progress(state: ProgramState, progress: int) -> None:
139
+ """Raise unless `progress` is a percentage allowed for `state`.
140
+
141
+ Raises:
142
+ ValueError: If `state` takes no progress or `progress` is out of range.
143
+ """
144
+ if state not in _PROGRESS_STATES:
145
+ msg = f"progress is only valid with working or blocked, not {state}"
146
+ raise ValueError(msg)
147
+ if not 0 <= progress <= 100: # noqa: PLR2004 # the spec's percentage bounds
148
+ msg = f"progress must be within 0-100, got {progress}"
149
+ raise ValueError(msg)
150
+
151
+
152
+ def is_valid_record_id(record_id: str) -> bool:
153
+ """Return whether `record_id` matches the spec's id grammar and limits.
154
+
155
+ Args:
156
+ record_id: Candidate path of `/`-separated segments.
157
+ """
158
+ return (
159
+ len(record_id.encode()) <= _MAX_ID_BYTES
160
+ and _ID_RE.fullmatch(record_id) is not None
161
+ )
162
+
163
+
164
+ def is_valid_app(app: str) -> bool:
165
+ """Return whether `app` matches the spec's `app` grammar.
166
+
167
+ Args:
168
+ app: Candidate program identifier.
169
+ """
170
+ return _APP_RE.fullmatch(app) is not None
171
+
172
+
173
+ def sanitize_text(text: str, max_bytes: int) -> str:
174
+ """Return `text` as one line of at most `max_bytes` UTF-8 bytes.
175
+
176
+ Terminals refuse a whole report whose decoded text contains a control
177
+ character, so newlines, tabs, and other controls become spaces and runs of
178
+ whitespace collapse. Truncation never splits a multi-byte character.
179
+
180
+ Args:
181
+ text: Arbitrary text, such as a thread name or an error message.
182
+ max_bytes: Byte budget for the decoded text.
183
+ """
184
+ spaced = "".join(" " if unicodedata.category(ch) == "Cc" else ch for ch in text)
185
+ line = " ".join(spaced.split())
186
+ data = line.encode("utf-8", errors="replace")[:max_bytes]
187
+ return data.decode("utf-8", errors="ignore").rstrip()
188
+
189
+
190
+ def _b64(text: str) -> str:
191
+ """Return standard, padded base64 of `text` as UTF-8."""
192
+ return base64.b64encode(text.encode("utf-8", errors="replace")).decode("ascii")
193
+
194
+
195
+ def _pairs(status: ProgramStatus, app: str) -> list[str]:
196
+ """Return the `key=value` pairs for `status`, `state` first."""
197
+ pairs = [f"state={status.state}"]
198
+ if status.record_id is not None:
199
+ pairs.append(f"id={status.record_id}")
200
+ if status.kind is not None:
201
+ pairs.append(f"kind={status.kind}")
202
+ if status.progress is not None:
203
+ pairs.append(f"progress={status.progress}")
204
+ pairs.append(f"app={app}")
205
+ title = sanitize_text(status.title, MAX_TITLE_BYTES)
206
+ if title:
207
+ pairs.append(f"title={_b64(title)}")
208
+ msg = sanitize_text(status.msg, MAX_MSG_BYTES)
209
+ if msg:
210
+ pairs.append(f"msg={_b64(msg)}")
211
+ return pairs
212
+
213
+
214
+ def encode_program_status(status: ProgramStatus, *, app: str = APP_NAME) -> str:
215
+ r"""Return the full `OSC 7501` sequence for `status`, terminated with `ESC \`.
216
+
217
+ Args:
218
+ status: The report to encode.
219
+ app: Program identifier; must match `[A-Za-z0-9_.+-]{1,32}`.
220
+
221
+ Returns:
222
+ The escape sequence, always within the spec's 4096-byte cap.
223
+
224
+ Raises:
225
+ ValueError: If `app` is invalid, or the sequence exceeds the
226
+ 4096-byte cap.
227
+ """
228
+ if not is_valid_app(app):
229
+ msg = f"invalid OSC 7501 app: {app!r}"
230
+ raise ValueError(msg)
231
+ sequence = f"\x1b]7501;{':'.join(_pairs(status, app))}{_ST}"
232
+ # Field caps keep the largest legal report near 3.3 KB; this guards edits.
233
+ if len(sequence.encode("ascii")) > MAX_SEQUENCE_BYTES:
234
+ msg = "OSC 7501 report exceeds the 4096-byte limit"
235
+ raise ValueError(msg)
236
+ return sequence
237
+
238
+
239
+ def _is_under(record_id: str, parent: str) -> bool:
240
+ """Return whether `record_id` is `parent` or one of its descendants."""
241
+ return record_id == parent or record_id.startswith(f"{parent}/")
242
+
243
+
244
+ class ProgramStatusReporter:
245
+ """Send `OSC 7501` reports and clear them when the program exits.
246
+
247
+ Skips a report identical to the last one sent for the same record, so
248
+ callers can report on every UI update. Unless `clear_on_exit` is `False`,
249
+ the first successful non-`clear` report registers an `atexit` hook that
250
+ clears all records, so an unhandled exception or `sys.exit` does not leave
251
+ a stale status behind. A hard kill skips the hook.
252
+
253
+ Thread-safe: reports may come from the event loop and the `atexit` hook.
254
+ """
255
+
256
+ def __init__(
257
+ self,
258
+ *,
259
+ write: Callable[[str], bool] | None = None,
260
+ app: str = APP_NAME,
261
+ enabled: bool = True,
262
+ clear_on_exit: bool = True,
263
+ ) -> None:
264
+ """Create a reporter.
265
+
266
+ Args:
267
+ write: Writes one escape sequence and returns whether it was sent.
268
+ Defaults to `terminal_escape.write_terminal_escape`.
269
+ app: Program identifier sent with every report.
270
+ enabled: When `False`, every method is a no-op.
271
+ clear_on_exit: Clear every record at interpreter exit. Turn off for
272
+ a one-shot run whose final `done` or `error` should outlive it.
273
+
274
+ Raises:
275
+ ValueError: If `app` is invalid.
276
+ """
277
+ if not is_valid_app(app):
278
+ msg = f"invalid OSC 7501 app: {app!r}"
279
+ raise ValueError(msg)
280
+ self._write = write
281
+ self._app = app
282
+ self._enabled = enabled
283
+ self._sent: dict[str | None, str] = {}
284
+ self._lock = threading.Lock()
285
+ self._atexit_registered = not clear_on_exit
286
+ self._warned = False
287
+
288
+ @property
289
+ def enabled(self) -> bool:
290
+ """Whether this reporter writes anything."""
291
+ return self._enabled
292
+
293
+ def report(self, status: ProgramStatus, *, force: bool = False) -> bool:
294
+ """Send `status` unless it repeats the record's last report.
295
+
296
+ Never raises: status output is cosmetic.
297
+
298
+ Args:
299
+ status: The report to send.
300
+ force: Send even if it repeats the last report, for when another
301
+ program may have replaced or dropped the record meanwhile.
302
+
303
+ Returns:
304
+ `True` if a sequence was written.
305
+ """
306
+ if not self._enabled:
307
+ return False
308
+ try:
309
+ sequence = encode_program_status(status, app=self._app)
310
+ except ValueError:
311
+ logger.debug("Dropping invalid OSC 7501 report", exc_info=True)
312
+ return False
313
+ with self._lock:
314
+ if not force and self._sent.get(status.record_id) == sequence:
315
+ return False
316
+ if not self._send(sequence):
317
+ return False
318
+ self._remember(status, sequence)
319
+ return True
320
+
321
+ def clear(self, record_id: str | None = None) -> bool:
322
+ """Remove a record and everything below it; `None` removes all records.
323
+
324
+ Does nothing when nothing in that subtree was reported.
325
+
326
+ Args:
327
+ record_id: The record to remove, or `None` for every record.
328
+
329
+ Returns:
330
+ `True` if a `clear` report was written.
331
+ """
332
+ with self._lock:
333
+ if not any(
334
+ record_id is None or (rid is not None and _is_under(rid, record_id))
335
+ for rid in self._sent
336
+ ):
337
+ return False
338
+ return self.report(ProgramStatus(ProgramState.CLEAR, record_id=record_id))
339
+
340
+ def _send(self, sequence: str) -> bool:
341
+ """Return whether `sequence` was written; never raises.
342
+
343
+ The default writer handles its own I/O errors, so an exception here is
344
+ a bug. Warn on the first one so it is visible, then log at debug to
345
+ avoid one warning per UI update.
346
+ """
347
+ try:
348
+ write = self._write or _default_write()
349
+ return write(sequence)
350
+ except Exception: # noqa: BLE001 # status output must never break the app
351
+ log = logger.debug if self._warned else logger.warning
352
+ self._warned = True
353
+ log("OSC 7501 write failed", exc_info=True)
354
+ return False
355
+
356
+ def _remember(self, status: ProgramStatus, sequence: str) -> None:
357
+ """Record what the terminal now holds after `status` was sent."""
358
+ if status.state is ProgramState.CLEAR:
359
+ parent = status.record_id
360
+ self._sent = {
361
+ rid: seq
362
+ for rid, seq in self._sent.items()
363
+ if parent is not None and (rid is None or not _is_under(rid, parent))
364
+ }
365
+ return
366
+ self._sent[status.record_id] = sequence
367
+ if not self._atexit_registered:
368
+ atexit.register(self._clear_at_exit)
369
+ self._atexit_registered = True
370
+
371
+ def _clear_at_exit(self) -> None:
372
+ """Clear every record when the interpreter exits."""
373
+ try:
374
+ self.clear()
375
+ except Exception:
376
+ logger.debug("Failed to clear OSC 7501 status at exit", exc_info=True)
377
+
378
+
379
+ def _default_write() -> Callable[[str], bool]:
380
+ """Return the shared best-effort terminal writer, imported lazily."""
381
+ from deepagents_code.terminal_escape import write_terminal_escape
382
+
383
+ return write_terminal_escape
384
+
385
+
386
+ class TurnOutcome(StrEnum):
387
+ """How the most recent unit of work ended, shown while nothing is running."""
388
+
389
+ IDLE = "idle"
390
+ """Nothing to report: never ran, interrupted, rejected, or already seen."""
391
+
392
+ DONE = "done"
393
+ """The agent finished a turn the user has not acted on yet."""
394
+
395
+ ERROR = "error"
396
+ """The last turn, or startup, failed."""
397
+
398
+
399
+ _OUTCOME_STATES: dict[TurnOutcome, ProgramState] = {
400
+ TurnOutcome.IDLE: ProgramState.IDLE,
401
+ TurnOutcome.DONE: ProgramState.DONE,
402
+ TurnOutcome.ERROR: ProgramState.ERROR,
403
+ }
404
+ """The root-record state shown for each outcome while nothing is running."""
405
+
406
+
407
+ @dataclass(frozen=True, slots=True)
408
+ class Blocker:
409
+ """One outstanding request for user input.
410
+
411
+ Attributes:
412
+ kind: What the user must do.
413
+ msg: One line saying what is being asked.
414
+ in_transcript: The prompt is a widget in the transcript, so clearing
415
+ the transcript removes it.
416
+ """
417
+
418
+ kind: BlockedKind
419
+ msg: str = ""
420
+ in_transcript: bool = False
421
+
422
+
423
+ @dataclass(frozen=True, slots=True)
424
+ class AgentActivity:
425
+ """Snapshot of everything that decides the program's root record.
426
+
427
+ Attributes:
428
+ working: Whether the agent or a long-running app task is busy.
429
+ outcome: How the last unit of work ended.
430
+ detail: Message for `outcome`, such as the error text.
431
+ blockers: Outstanding user prompts as `(token, blocker)`, oldest first.
432
+ title: Label for the record, such as the thread name.
433
+ """
434
+
435
+ working: bool = False
436
+ outcome: TurnOutcome = TurnOutcome.IDLE
437
+ detail: str = ""
438
+ blockers: tuple[tuple[int, Blocker], ...] = ()
439
+ title: str = ""
440
+
441
+
442
+ def activity_status(activity: AgentActivity) -> ProgramStatus:
443
+ """Return the root record for `activity`.
444
+
445
+ A pending prompt wins over everything because the user must act; the
446
+ newest prompt is the one on screen. Work in progress wins over the last
447
+ outcome.
448
+
449
+ Args:
450
+ activity: Current app state.
451
+ """
452
+ if activity.blockers:
453
+ blocker = activity.blockers[-1][1]
454
+ return ProgramStatus(
455
+ ProgramState.BLOCKED,
456
+ kind=blocker.kind,
457
+ title=activity.title,
458
+ msg=blocker.msg,
459
+ )
460
+ if activity.working:
461
+ return ProgramStatus(ProgramState.WORKING, title=activity.title)
462
+ return ProgramStatus(
463
+ _OUTCOME_STATES[activity.outcome],
464
+ title=activity.title,
465
+ msg=activity.detail,
466
+ )
467
+
468
+
469
+ def exit_status(exit_code: int | None, *, reason: str = "") -> ProgramStatus:
470
+ """Return the final report for a one-shot (headless) run.
471
+
472
+ The spec asks a program that exits when it finishes to report `done` or
473
+ `error` just before exiting. An interrupt or an unknown exit clears instead.
474
+
475
+ Args:
476
+ exit_code: The process exit code, or `None` when it is unknown.
477
+ reason: Why the run failed, for the `error` message. Without it, a
478
+ known exit code gets a fixed reason and others get the code.
479
+ """
480
+ if exit_code == 0:
481
+ return ProgramStatus(ProgramState.DONE)
482
+ if exit_code is None or exit_code == _INTERRUPTED_EXIT_CODE:
483
+ return ProgramStatus(ProgramState.CLEAR)
484
+ msg = reason or _EXIT_REASONS.get(exit_code, f"Exited with code {exit_code}")
485
+ return ProgramStatus(ProgramState.ERROR, msg=msg)
486
+
487
+
488
+ _INTERRUPTED_EXIT_CODE = 130
489
+ """Exit code of an interrupted (Ctrl+C) headless run."""
490
+
491
+ _EXIT_REASONS: dict[int, str] = {124: "Reached the --max-turns limit"}
492
+ """Default `error` message for headless exit codes with one known cause.
493
+
494
+ `main.cli_main` passes its own reason for a `--timeout` hit, which also
495
+ exits 124.
496
+ """
497
+
498
+
499
+ class AgentStatusTracker:
500
+ """Keep `AgentActivity` current and report each change.
501
+
502
+ The app calls the mutators from its event loop; `activity_status` decides
503
+ what to send and the reporter drops repeats.
504
+ """
505
+
506
+ def __init__(self, reporter: ProgramStatusReporter) -> None:
507
+ """Create a tracker that reports through `reporter`.
508
+
509
+ Args:
510
+ reporter: Destination for root-record reports.
511
+ """
512
+ self._reporter = reporter
513
+ self._activity = AgentActivity()
514
+ self._next_token = 0
515
+ self._closed = False
516
+
517
+ @property
518
+ def activity(self) -> AgentActivity:
519
+ """The current snapshot."""
520
+ return self._activity
521
+
522
+ def start(self) -> None:
523
+ """Send the first report so the terminal knows the program is here."""
524
+ self._sync()
525
+
526
+ def set_working(self, working: bool) -> None:
527
+ """Mark work as started or stopped.
528
+
529
+ Starting new work forgets the previous outcome, since the user has
530
+ moved on. This also applies when the new work starts before the last
531
+ work was reported as stopped, such as a queued message.
532
+
533
+ Args:
534
+ working: Whether work is in progress.
535
+ """
536
+ if working:
537
+ self._apply(
538
+ replace(
539
+ self._activity, working=True, outcome=TurnOutcome.IDLE, detail=""
540
+ )
541
+ )
542
+ else:
543
+ self._apply(replace(self._activity, working=working))
544
+
545
+ def set_outcome(self, outcome: TurnOutcome, detail: str = "") -> None:
546
+ """Record how the current or last unit of work ended.
547
+
548
+ Args:
549
+ outcome: The result to show once nothing is running.
550
+ detail: Message to show with it, such as an error summary.
551
+ """
552
+ self._apply(replace(self._activity, outcome=outcome, detail=detail))
553
+
554
+ def clear_error(self) -> None:
555
+ """Return to `idle` if the last outcome was an error."""
556
+ if self._activity.outcome is TurnOutcome.ERROR:
557
+ self.set_outcome(TurnOutcome.IDLE)
558
+
559
+ def set_title(self, title: str) -> None:
560
+ """Set the label sent with every report.
561
+
562
+ Args:
563
+ title: Short label, or empty for none.
564
+ """
565
+ self._apply(replace(self._activity, title=title))
566
+
567
+ def start_new_conversation(self) -> None:
568
+ """Forget the last outcome and every prompt shown in the transcript.
569
+
570
+ Call when the transcript is cleared for a new or different thread: its
571
+ prompts are gone and the old thread's result no longer applies.
572
+ """
573
+ remaining = tuple(
574
+ entry for entry in self._activity.blockers if not entry[1].in_transcript
575
+ )
576
+ self._apply(
577
+ replace(
578
+ self._activity,
579
+ blockers=remaining,
580
+ outcome=TurnOutcome.IDLE,
581
+ detail="",
582
+ )
583
+ )
584
+
585
+ def _block(self, blocker: Blocker) -> int:
586
+ """Return a token for a newly recorded prompt waiting for the user."""
587
+ self._next_token += 1
588
+ token = self._next_token
589
+ entry = (token, blocker)
590
+ self._apply(replace(self._activity, blockers=(*self._activity.blockers, entry)))
591
+ return token
592
+
593
+ def _unblock(self, token: int) -> None:
594
+ """Forget the prompt registered under `token`; unknown tokens are ignored.
595
+
596
+ A user who closed a prompt has seen a `done` outcome, so it reverts to
597
+ `idle`. An error stays: closing a prompt, such as cancelling a sign-in,
598
+ does not fix it. `clear_error` or new work removes it.
599
+ """
600
+ blockers = self._activity.blockers
601
+ remaining = tuple(entry for entry in blockers if entry[0] != token)
602
+ if remaining == blockers:
603
+ return
604
+ activity = replace(self._activity, blockers=remaining)
605
+ if activity.outcome is not TurnOutcome.ERROR:
606
+ activity = replace(activity, outcome=TurnOutcome.IDLE, detail="")
607
+ self._apply(activity)
608
+
609
+ def track[T](
610
+ self, future: asyncio.Future[T], kind: BlockedKind, msg: str = ""
611
+ ) -> None:
612
+ """Report blocked until `future` completes, fails, or is cancelled.
613
+
614
+ For prompts mounted in the transcript; `start_new_conversation` drops
615
+ them even if their future never completes.
616
+
617
+ Args:
618
+ future: Resolves when the user answers the prompt.
619
+ kind: What the user must do.
620
+ msg: One line saying what is being asked.
621
+ """
622
+ if future.done():
623
+ return
624
+ token = self._block(Blocker(kind, msg, in_transcript=True))
625
+ future.add_done_callback(lambda _future: self._unblock(token))
626
+
627
+ @contextmanager
628
+ def blocked(self, kind: BlockedKind, msg: str = "") -> Iterator[None]:
629
+ """Report blocked for the duration of the `with` block.
630
+
631
+ Args:
632
+ kind: What the user must do.
633
+ msg: One line saying what is being asked.
634
+
635
+ Yields:
636
+ Nothing.
637
+ """
638
+ token = self._block(Blocker(kind, msg))
639
+ try:
640
+ yield
641
+ finally:
642
+ self._unblock(token)
643
+
644
+ def refresh(self) -> None:
645
+ """Resend the current report even if it was already sent.
646
+
647
+ Use after the app resumes from suspension: the shell prompt shown
648
+ meanwhile makes terminals drop `working` and `blocked` records.
649
+ """
650
+ if not self._closed:
651
+ self._reporter.report(activity_status(self._activity), force=True)
652
+
653
+ def close(self) -> None:
654
+ """Clear every record and stop reporting; later calls do nothing."""
655
+ if self._closed:
656
+ return
657
+ self._closed = True
658
+ self._reporter.clear()
659
+
660
+ def _apply(self, activity: AgentActivity) -> None:
661
+ """Adopt `activity` and report it if anything changed."""
662
+ if activity == self._activity:
663
+ return
664
+ self._activity = activity
665
+ self._sync()
666
+
667
+ def _sync(self) -> None:
668
+ """Report the root record for the current snapshot."""
669
+ if not self._closed:
670
+ self._reporter.report(activity_status(self._activity))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: deepagents-code
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: Terminal coding agent built on the Deep Agents SDK - works with any model, with persistent memory, customizable skills, subagents, and approval controls.
5
5
  Project-URL: Homepage, https://www.langchain.com/dcode
6
6
  Project-URL: Documentation, https://docs.langchain.com/oss/deepagents/code/overview
@@ -36,14 +36,14 @@ Requires-Dist: httpx>=0.28.1
36
36
  Requires-Dist: langchain-anthropic<2.0.0,>=1.7.10
37
37
  Requires-Dist: langchain-core<2.0.0,>=1.8.1
38
38
  Requires-Dist: langchain-google-genai<5.0.0,>=4.4.3
39
- Requires-Dist: langchain-openai<2.0.0,>=1.8.0
40
- Requires-Dist: langchain-quickjs<0.4.0,>=0.3.12
39
+ Requires-Dist: langchain-openai<2.0.0,>=1.8.1
40
+ Requires-Dist: langchain-quickjs<0.5.0,>=0.3.12
41
41
  Requires-Dist: langchain<2.0.0,>=1.5.0
42
42
  Requires-Dist: langgraph-checkpoint-sqlite<4.0.0,>=3.1.3
43
43
  Requires-Dist: langgraph-cli[inmem]<1.0.0,>=0.4.43
44
- Requires-Dist: langgraph-runtime-inmem<1.0.0,>=0.38.1
44
+ Requires-Dist: langgraph-runtime-inmem<1.0.0,>=0.38.2
45
45
  Requires-Dist: langgraph-sdk<1.0.0,>=0.4.14
46
- Requires-Dist: langsmith[sandbox]>=0.14.17
46
+ Requires-Dist: langsmith[sandbox]>=0.15.0
47
47
  Requires-Dist: markdownify>=1.2.3
48
48
  Requires-Dist: mcp>=2.0.0
49
49
  Requires-Dist: packaging>=26.2
@@ -81,7 +81,7 @@ Requires-Dist: langchain-meta<2.0.0,>=0.5.0; extra == 'all-providers'
81
81
  Requires-Dist: langchain-mistralai<2.0.0,>=1.2.0; extra == 'all-providers'
82
82
  Requires-Dist: langchain-nvidia-ai-endpoints<2.0.0,>=1.5.0; extra == 'all-providers'
83
83
  Requires-Dist: langchain-ollama<2.0.0,>=1.1.0; extra == 'all-providers'
84
- Requires-Dist: langchain-openai<2.0.0,>=1.8.0; extra == 'all-providers'
84
+ Requires-Dist: langchain-openai<2.0.0,>=1.8.1; extra == 'all-providers'
85
85
  Requires-Dist: langchain-openrouter<2.0.0,>=0.2.9; extra == 'all-providers'
86
86
  Requires-Dist: langchain-perplexity<2.0.0,>=1.4.2; extra == 'all-providers'
87
87
  Requires-Dist: langchain-together<2.0.0,>=0.4.0; extra == 'all-providers'
@@ -132,7 +132,7 @@ Requires-Dist: langchain-nvidia-ai-endpoints<2.0.0,>=1.5.0; extra == 'nvidia'
132
132
  Provides-Extra: ollama
133
133
  Requires-Dist: langchain-ollama<2.0.0,>=1.1.0; extra == 'ollama'
134
134
  Provides-Extra: openai
135
- Requires-Dist: langchain-openai<2.0.0,>=1.8.0; extra == 'openai'
135
+ Requires-Dist: langchain-openai<2.0.0,>=1.8.1; extra == 'openai'
136
136
  Provides-Extra: openrouter
137
137
  Requires-Dist: langchain-openrouter<2.0.0,>=0.2.9; extra == 'openrouter'
138
138
  Provides-Extra: openshell
@@ -2,7 +2,7 @@ deepagents_code/__init__.py,sha256=73a8obvgWKoHOkvV-npfpuJwVQTq4fy56ITb8ZkuTVo,2
2
2
  deepagents_code/__main__.py,sha256=5ew3bdnHNft6Pbx9Svfs8jkvPwVOmRBsY5hubL2OicY,142
3
3
  deepagents_code/_ask_user_types.py,sha256=YqyBfBlW1J7LpHqsN3seOnMX0MqdM11lGoFRXkxwHuw,30794
4
4
  deepagents_code/_async.py,sha256=oONFzkt5GsIAYIyU2-OHRBOuxifWcZKuBqO4INxP1uE,711
5
- deepagents_code/_build_info.py,sha256=KxG7G_EdH24OObwvB8kn9g0h9v7KI_7HmVTp89H5dNs,80
5
+ deepagents_code/_build_info.py,sha256=f_8oBeMV6sW11s7q1_1MWX2B05M12EwO7W6-prkEipg,80
6
6
  deepagents_code/_checkpointer_adapter.py,sha256=0jEqLDDdGFPXLGiFsZiQb93uZzioA8PxpLBoU510Bnc,3558
7
7
  deepagents_code/_cli_context.py,sha256=BsjGF9ytVLsVexLLKnHeLXDsSUgK2clpAUlW4eNJMC8,10345
8
8
  deepagents_code/_constants.py,sha256=rvXyA-PNVZG49-fh1zWEHXrzvZlC7bAXq41rblRC7yk,5230
@@ -10,7 +10,7 @@ deepagents_code/_content_blocks.py,sha256=RhKMm25MId1bvPrhGV8bKGPLIhVcuG0DRX4gh_
10
10
  deepagents_code/_debug.py,sha256=gpurAPq157cLGf5dhzPMTScTGkt_67x9o4CVC-113-U,16434
11
11
  deepagents_code/_debug_buffer.py,sha256=1B8mhHoyrxKxvd8dtR8gjXxO7VDkwBHrgLl_tzmJqpc,9936
12
12
  deepagents_code/_dep_floor_check.py,sha256=PG4coS1qlArBGwm94z_xmjUDhuFDInlSgP0HjlKhcn0,29585
13
- deepagents_code/_env_vars.py,sha256=ChZD4Ywjiu6K3Sr7PCpTdcaTtYXH5x0RZcvwiiDAP0k,36220
13
+ deepagents_code/_env_vars.py,sha256=V8TYX1kqgsmPBy-9WywHCxBmadI9slKDEaAaTbctZlg,36754
14
14
  deepagents_code/_fake_models.py,sha256=sXkanY_9Y8CFxraicX2fnoC7Bu1KASmMYZlLnJ6VESQ,2776
15
15
  deepagents_code/_git.py,sha256=HTCjfeNWDs18Gm4I2Mwh0ROy1X4utUlgY-mZyfXn3VA,24339
16
16
  deepagents_code/_glm_5p2_profile.py,sha256=YpgVKkq-kPN-i4r2eN1YEhpF-jFN91-ZrFEmVWg0kH0,14189
@@ -34,10 +34,10 @@ deepagents_code/_tool_free.py,sha256=i2-Ycq3gp7zT3UyagDSd4-5O9kigprR137ptO70hpfE
34
34
  deepagents_code/_tool_stream.py,sha256=lXVM-0gObwmkik8ElEoPwaZI3PPq_ATar1fvPraW5Vk,39111
35
35
  deepagents_code/_trace_redaction.py,sha256=ZEjAYg1BlH9hJu7K64jhjhnKVofw5pS0JnIYTOW37FU,5215
36
36
  deepagents_code/_tracing.py,sha256=-Zucmritu9TreUHFcpwjiwPxkqmeJleL4dTDxKqPzLk,2530
37
- deepagents_code/_version.py,sha256=fYe6k6Ik0EWbmPrulhVjTwgEBw9qKOUvkIg1vCHCzK0,975
37
+ deepagents_code/_version.py,sha256=-3yhXaKjZBBQxVCNOaJZLWuW8zOMBbgAoBfXr0MB_wk,976
38
38
  deepagents_code/acp.py,sha256=WCJcpmvUU_lX8yutv3CESV6TG5xPY6AflK0hFwSbuy8,4525
39
39
  deepagents_code/agent.py,sha256=Q6JxwyPkDq2q1KhzKED0Rv5f1czDsE0kJcmekldldug,156779
40
- deepagents_code/app.py,sha256=yO0NiU86vsHOjx20vHjU0OGdg-uIIYg3hHMdPQYOUbk,1439956
40
+ deepagents_code/app.py,sha256=ZcyM_jS8mZoPXKTEar8F-rp0bOYVdsYEQLULg3aScu4,1444200
41
41
  deepagents_code/app.tcss,sha256=q8SmGF7t2xM7OGnKFr6jxGSqLPcwQ1mT-WQOEX_iX5Q,10728
42
42
  deepagents_code/approval_mode.py,sha256=CTBUNNuXalzj5NxYeT0m3xH2d675JE5uT9fxZ0YhJZ4,19336
43
43
  deepagents_code/ask_user.py,sha256=ice3x1SsOyXGoxpzM60MfuVxlVJGapOa782mxw7GVVo,24499
@@ -54,7 +54,7 @@ deepagents_code/cold_cache.py,sha256=KK1GAvjW7YtrJzB8K-nQTqu0Pr5uA5llZMD59IqGvYc
54
54
  deepagents_code/command_registry.py,sha256=I8VWy3QTKUHL5aSyj5RQ52VIZHvFmUHDPTtABZFpEw8,21101
55
55
  deepagents_code/completion.py,sha256=YR4SduNYZ70U3-ol1iKnlH-IRrcZNAmxfR_YBTxP3Ss,30106
56
56
  deepagents_code/config.py,sha256=XmrZVfe7sCOSd84LqhisiWbbdGo-ENyzC7EEtHtQ0NA,299833
57
- deepagents_code/config_manifest.py,sha256=D-GCSkP5tCMkyCtDZxK0-dSNYpFXM03AZdOMhQiqpr0,134518
57
+ deepagents_code/config_manifest.py,sha256=NUNPMFbHZxbw7xQW7cqDM0Y8SpKec6_2CW8-uhvhJoo,134934
58
58
  deepagents_code/configurable_model.py,sha256=ulrM0mQWB8RVLQVPt-_LLndGHnaIIKKNdfSYcRQr8ss,44643
59
59
  deepagents_code/context_doctor.py,sha256=Rp0Am6Gdfnievs5NslNxtzRM9ClfL-FMkYPA4ivsu44,9584
60
60
  deepagents_code/cost_tracking.py,sha256=9EgqS4st5N6UgtvDewY2RIFzIsjko5GvR_a6EFmWd9c,140529
@@ -76,7 +76,7 @@ deepagents_code/input.py,sha256=WwrD0UMJ3x-Y6bgfVVJYBsj7e9noHyu9b6BE-i42hnM,3859
76
76
  deepagents_code/iterm_cursor_guide.py,sha256=l2lcBb9N84ucTEsdI-SHBQ2h6grddNaXNMdLCLWewY8,5989
77
77
  deepagents_code/json_types.py,sha256=lwkG1m0-flVumX4an4zaK4nLpkbAAl3tqJqUaOBy7SY,616
78
78
  deepagents_code/local_context.py,sha256=Y8r87ORYYIxsEDCDhJ_33vAmOI2vbaVkwuBPQGfumMg,39406
79
- deepagents_code/main.py,sha256=--sQYs5SaBkBmjfjxj6iLYF3m9A7qJYBCS2oTzPUjhc,286867
79
+ deepagents_code/main.py,sha256=ZR3vufVMKVmIKlkPyzg-IpOScGfWJrwQu3Tg1r3LsJs,288687
80
80
  deepagents_code/managed_tools.py,sha256=_UdVnot-sf7hbDzgPirHZXgp3l3G5DFuhuVL43vJfIQ,32993
81
81
  deepagents_code/mcp_auth.py,sha256=9kwj3hmF4jOYAPuFchGdrfrbdoHZSKHLPPIAcLltI-M,97480
82
82
  deepagents_code/mcp_config.py,sha256=3gcdbs13V3O5GizojB3rlgUbcbUDrFv9t2t_52yAkFU,7951
@@ -85,7 +85,7 @@ deepagents_code/mcp_login_service.py,sha256=wJWX_b8uxE_iXiHdkvEjcnWKxjwxmVZswaii
85
85
  deepagents_code/mcp_middleware.py,sha256=Oy6QvDpuKUOPqO-TEa3KoFsl3gT8RNLws_QlKWkySDY,6992
86
86
  deepagents_code/mcp_oauth_ui.py,sha256=ylP11W8Aod219Xir_CYMBibnPH1rSC7s0hzyksjJo8A,8552
87
87
  deepagents_code/mcp_proxy.py,sha256=qyMJmDvDjO8wD7GsPCuoKv_txdjYT7xdZ9WQ5cHnYkA,5675
88
- deepagents_code/mcp_tools.py,sha256=8Uzckp_RDNR292GW0sE5f7M0GDwY8qiaKO4_FpKH564,112649
88
+ deepagents_code/mcp_tools.py,sha256=FD1DuSAQSSnk_OGzPq-rlFL7d9dCUqYQxmuIbHZCVEY,112898
89
89
  deepagents_code/media_utils.py,sha256=xLecgZ5eczNa9QdSYfGYqBEKXVb4El8HN8ir8Rj99_Q,21682
90
90
  deepagents_code/memory_guard.py,sha256=fSutntUH3bgWzcyZChsPkTy4nWhwDp0vedfdj88iAgM,19976
91
91
  deepagents_code/model_api.py,sha256=nXA1YU0S-jrJQBNh9frY9TqOskgPC-Du3vb-F0KH9qs,8484
@@ -101,6 +101,7 @@ deepagents_code/onboarding.py,sha256=OAQV4hhVwULcJDB1S46B-CoFnf_uCjRQaEMK5xtLJmY
101
101
  deepagents_code/output.py,sha256=W8j1BleVaQ7M07nDRV9pgW4xSaRwlA5KfWyLtOeUrP0,2044
102
102
  deepagents_code/output_truncation.py,sha256=jQpKecRRsbGEAKlF3FnBB_sibQ1yP8Lj_oUxSyhCyUs,15947
103
103
  deepagents_code/paste_collapse.py,sha256=nukxFCmvMERwaf0ERVH5XuH7Y_TfoiKz7b5Y0ays8qc,3153
104
+ deepagents_code/program_status.py,sha256=FC0a5jMfl8J-rCJIJIuRhqywMvYWrBO4DXM5gb0u7H8,23376
104
105
  deepagents_code/project_utils.py,sha256=yGqY4qILS1hMLnVGd1AqU4KIGVRUXBbLhjTaj3iNXNc,8245
105
106
  deepagents_code/provider_tool_search.py,sha256=tEClWbmMwMAJ39CvDBTyz3Xe4mxJ_EI7pgXXOhsVVtA,7370
106
107
  deepagents_code/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -319,9 +320,9 @@ deepagents_code/tui/widgets/final_markdown/_parse.py,sha256=NeclNxZwNmGkJZXefCVr
319
320
  deepagents_code/tui/widgets/final_markdown/_rows.py,sha256=nsmk7N-2Lrueb4LvC0Y1zdZ__ywcqaKI1vaGaO5chDU,3947
320
321
  deepagents_code/tui/widgets/final_markdown/_table.py,sha256=qZDsE0tpwMBI4ZZEg03L4Wc0FOXf10XUKwMHjn9V1iQ,4823
321
322
  deepagents_code/tui/widgets/final_markdown/_widget.py,sha256=1BU2OAGaapEc4l4xKQOe-VgGDmQqrBs5zr4LKPd8cAg,11265
322
- deepagents_code-0.2.9.data/data/deepagents_code/default_agent_prompt.md,sha256=4I23oEsscs0X-VqXJ6JiC_Tl3FV0f-Na4iIbs5tqVbQ,336
323
- deepagents_code-0.2.9.dist-info/METADATA,sha256=Eli8aO9FtKXX9pVwTwO4N5DuMcAEOYRx9LmkJ3Bctn0,11616
324
- deepagents_code-0.2.9.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
325
- deepagents_code-0.2.9.dist-info/entry_points.txt,sha256=_6mmNRQU3vBqMDX-REOesqVwwqijvs-WASYDEvasGzQ,94
326
- deepagents_code-0.2.9.dist-info/licenses/LICENSE,sha256=TsZ-TKbmch26hJssqCJhWXyGph7iFLvyFBYAa3stBHg,1067
327
- deepagents_code-0.2.9.dist-info/RECORD,,
323
+ deepagents_code-0.2.10.data/data/deepagents_code/default_agent_prompt.md,sha256=4I23oEsscs0X-VqXJ6JiC_Tl3FV0f-Na4iIbs5tqVbQ,336
324
+ deepagents_code-0.2.10.dist-info/METADATA,sha256=b54nSm70mxjptRtT6Pqnj5PyreVqzhSF1lXFwtDsZ1g,11616
325
+ deepagents_code-0.2.10.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
326
+ deepagents_code-0.2.10.dist-info/entry_points.txt,sha256=_6mmNRQU3vBqMDX-REOesqVwwqijvs-WASYDEvasGzQ,94
327
+ deepagents_code-0.2.10.dist-info/licenses/LICENSE,sha256=TsZ-TKbmch26hJssqCJhWXyGph7iFLvyFBYAa3stBHg,1067
328
+ deepagents_code-0.2.10.dist-info/RECORD,,