managed-deepagents 0.10.2.dev4__py3-none-win_amd64.whl → 0.10.2.dev6__py3-none-win_amd64.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.
@@ -208,7 +208,7 @@ if TYPE_CHECKING:
208
208
  PromptResponse,
209
209
  SlackPromptResponse,
210
210
  )
211
- from managed_deepagents.sandbox import SandboxDefinition, basic, bearer
211
+ from managed_deepagents.sandbox import SandboxDefinition, basic, bearer, open_sandbox
212
212
  from managed_deepagents.schedules import define_schedule
213
213
 
214
214
  # Each export loads on first use (PEP 562), so a service that only needs the
@@ -371,6 +371,7 @@ _EXPORTS: dict[str, str] = {
371
371
  "define_memory": "managed_deepagents.define_memory",
372
372
  "define_sandbox": "managed_deepagents.namespaces",
373
373
  "define_schedule": "managed_deepagents.schedules",
374
+ "open_sandbox": "managed_deepagents.sandbox",
374
375
  "schedules": "managed_deepagents._runtime_schedules",
375
376
  }
376
377
 
@@ -575,5 +576,6 @@ __all__ = [
575
576
  "define_memory",
576
577
  "define_sandbox",
577
578
  "define_schedule",
579
+ "open_sandbox",
578
580
  "schedules",
579
581
  ]
Binary file
@@ -73,19 +73,24 @@ def _content_as_text(content: object) -> str:
73
73
  #: A reply that means "nothing to tell the channel" (Content Studio's convention).
74
74
  QUIET_REPLY = "[quiet]"
75
75
  #: Message field (``additional_kwargs`` key) deepagents uses for a task notification.
76
+ #: Deprecated: read ``lc_source`` and ``lc_data``.
76
77
  NOTIFICATION_KEY = "deepagents_notification"
77
- #: Message field MDA uses the same way, for a notification of its own such as a
78
- #: browser handoff ending.
79
- MDA_NOTIFICATION_KEY = "mda_notification"
78
+ #: Notification metadata sources of task news: async subagent and browser handoff updates.
79
+ NOTIFICATION_SOURCES = frozenset({"async_subagent", "browser_handoff"})
80
80
 
81
81
 
82
82
  def is_task_notification(message: object) -> bool:
83
- """Whether a message is a deepagents or MDA notification rather than the user's."""
83
+ """Whether a message is a harness-added notification rather than the user's.
84
+
85
+ Recognizes notification metadata with a source in ``NOTIFICATION_SOURCES``
86
+ and the deprecated ``deepagents_notification`` key.
87
+ """
84
88
  extra = _field(message, "additional_kwargs")
85
- return any(
86
- (isinstance(message, Mapping) and key in message)
87
- or (isinstance(extra, Mapping) and key in extra)
88
- for key in (NOTIFICATION_KEY, MDA_NOTIFICATION_KEY)
89
+ source = extra.get("lc_source") if isinstance(extra, Mapping) else None
90
+ if isinstance(source, str) and source in NOTIFICATION_SOURCES:
91
+ return True
92
+ return (isinstance(message, Mapping) and NOTIFICATION_KEY in message) or (
93
+ isinstance(extra, Mapping) and NOTIFICATION_KEY in extra
89
94
  )
90
95
 
91
96
 
@@ -182,7 +187,6 @@ def _field(message: object, name: str) -> object:
182
187
 
183
188
 
184
189
  __all__ = [
185
- "MDA_NOTIFICATION_KEY",
186
190
  "NOTIFICATION_KEY",
187
191
  "QUIET_REPLY",
188
192
  "extract_assistant_text",
@@ -50,7 +50,14 @@ from deepagents.middleware.async_subagents import (
50
50
  from langchain.agents.middleware import AgentMiddleware
51
51
  from langchain.agents.middleware.types import AgentState, OmitFromInput, PrivateStateAttr
52
52
  from langchain.tools import BaseTool, tool
53
- from langchain_core.messages import BaseMessage, SystemMessage, ToolMessage
53
+ from langchain_core.messages import (
54
+ BaseMessage,
55
+ HumanMessage,
56
+ SystemMessage,
57
+ ToolMessage,
58
+ add_notification_metadata,
59
+ get_notification_metadata,
60
+ )
54
61
  from langchain_core.messages.content import create_text_block
55
62
  from langgraph.config import get_config
56
63
  from langgraph.graph import START, StateGraph
@@ -72,7 +79,6 @@ from stagehand_middleware.facade import (
72
79
  )
73
80
  from stagehand_middleware.facade.tools import sanitize_error_message
74
81
 
75
- from managed_deepagents._channels.assistant_text import MDA_NOTIFICATION_KEY
76
82
  from managed_deepagents._managed_tools import ManagedToolRuntime # noqa: TC001 - tool annotations
77
83
  from managed_deepagents.define_browser import BROWSER_TOOL_PREFIX
78
84
  from managed_deepagents.identity import ManagedServerInfo
@@ -144,6 +150,7 @@ _WAKE_TEXT: dict[BrowserHandoffStatus, str] = {
144
150
  ),
145
151
  "ended": "The browser handoff ended. Take a snapshot to see whether the user finished.",
146
152
  }
153
+ _NOT_FROM_USER = "This is not a message from the user."
147
154
  _RELEASE_AFTER_S = 60.0 # a run that raises or interrupts never reaches aafter_agent
148
155
  #: Without a sandbox a saved file lives in thread state, which every later checkpoint carries.
149
156
  _MAX_SAVED_BYTES = 5_000_000
@@ -724,20 +731,30 @@ async def _handoff_status(pending: PendingBrowserHandoff) -> BrowserHandoffStatu
724
731
  return "ended" if time.time() >= pending["until"] else None
725
732
 
726
733
 
734
+ _HANDOFF_SOURCE = "browser_handoff"
735
+ """``lc_source`` of a handoff notification; its ``lc_data`` is ``{"status": ...}``."""
736
+
737
+
727
738
  def _wake_message(status: BrowserHandoffStatus) -> dict[str, Any]:
728
- """A notification in deepagents' task notification's shape: a user-role message
729
- framed as a system notification. Its ``mda_notification`` tells clients how the
730
- handoff ended, so they can tell it from the user's message."""
739
+ """A notification of how the handoff ended, with source ``"browser_handoff"``."""
740
+ message = add_notification_metadata(
741
+ HumanMessage(
742
+ f'<browser_handoff status="{status}">\n'
743
+ f"{_WAKE_TEXT[status]} {_NOT_FROM_USER}\n</browser_handoff>"
744
+ ),
745
+ source=_HANDOFF_SOURCE,
746
+ data={"status": status},
747
+ )
731
748
  return {
732
749
  "role": "user",
733
- "content": f"[SYSTEM NOTIFICATION - NOT USER INPUT]\n{_WAKE_TEXT[status]}",
734
- MDA_NOTIFICATION_KEY: {"type": "browser_handoff", "status": status},
750
+ "content": message.content,
751
+ "additional_kwargs": message.additional_kwargs,
735
752
  }
736
753
 
737
754
 
738
755
  def _is_handoff_notification(message: BaseMessage) -> bool:
739
- notification = message.additional_kwargs.get(MDA_NOTIFICATION_KEY)
740
- return isinstance(notification, dict) and notification.get("type") == "browser_handoff"
756
+ metadata = get_notification_metadata(message)
757
+ return metadata is not None and metadata["source"] == _HANDOFF_SOURCE
741
758
 
742
759
 
743
760
  async def _end_take(key: str, window: str) -> list[dict[str, str]] | str | None:
@@ -2052,6 +2052,10 @@ class _LazyManagedSandboxBackend(SandboxBackendProtocol):
2052
2052
  except TypeError:
2053
2053
  return await self._acall(lambda backend: backend.aexecute(command), execute=True)
2054
2054
 
2055
+ async def aopen(self) -> str:
2056
+ """Adopt or create this thread's sandbox now, as its first use would; return its name."""
2057
+ return (await self._abackend()).id
2058
+
2055
2059
  def _config(self) -> ManagedRunConfig | None:
2056
2060
  return _effective_sandbox_run_config(
2057
2061
  self._source.run_config, bound_configurable=self._bound_configurable
@@ -7,10 +7,13 @@ resolution, per-thread reuse, deploy-time snapshot bake, and lifecycle.
7
7
  from __future__ import annotations
8
8
 
9
9
  from dataclasses import dataclass
10
- from typing import ClassVar, Literal, TypedDict
10
+ from typing import TYPE_CHECKING, ClassVar, Literal, TypedDict
11
11
 
12
12
  from managed_deepagents._connections import ConnectionReference, is_connection_reference
13
13
 
14
+ if TYPE_CHECKING:
15
+ from managed_deepagents.runtime import _LazyManagedSandboxBackend
16
+
14
17
 
15
18
  @dataclass(frozen=True, repr=False)
16
19
  class ConnectionHeader:
@@ -132,6 +135,28 @@ def normalize_sandbox_options(options: dict[str, object]) -> dict[str, object]:
132
135
  return normalized
133
136
 
134
137
 
138
+ async def open_sandbox(backend: object) -> str:
139
+ """Adopt or create the run's managed sandbox now and return its name.
140
+
141
+ ``backend`` is ``runtime.backend``. Without this call, the sandbox opens on
142
+ its first use.
143
+ """
144
+ return await _managed_sandbox(backend).aopen()
145
+
146
+
147
+ def _managed_sandbox(backend: object) -> _LazyManagedSandboxBackend:
148
+ """The run's managed sandbox behind ``runtime.backend``, which tools may see composited."""
149
+ from deepagents.backends import CompositeBackend # noqa: PLC0415
150
+
151
+ from managed_deepagents.runtime import _LazyManagedSandboxBackend # noqa: PLC0415
152
+
153
+ while isinstance(backend, CompositeBackend):
154
+ backend = backend.default
155
+ if not isinstance(backend, _LazyManagedSandboxBackend):
156
+ raise TypeError("This run has no managed sandbox")
157
+ return backend
158
+
159
+
135
160
  __all__ = [
136
161
  "ConnectionHeader",
137
162
  "ProxyAccessControl",
@@ -142,4 +167,5 @@ __all__ = [
142
167
  "basic",
143
168
  "bearer",
144
169
  "normalize_sandbox_options",
170
+ "open_sandbox",
145
171
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: managed-deepagents
3
- Version: 0.10.2.dev4
3
+ Version: 0.10.2.dev6
4
4
  Summary: Managed Deep Agents — the define_deep_agent authoring interface plus the CLI that compiles and deploys a code-first Deep Agent repository to a managed LangGraph runtime.
5
5
  Author: LangChain
6
6
  License: MIT
@@ -18,7 +18,7 @@ Requires-Dist: httpx<1,>=0.28.1
18
18
  Requires-Dist: typing-extensions<5,>=4.12.2
19
19
  Requires-Dist: deepagents<1,>=0.7.30
20
20
  Requires-Dist: langchain<2,>=1.4.6
21
- Requires-Dist: langchain-core<2,>=1.6.2
21
+ Requires-Dist: langchain-core<2,>=1.7.2
22
22
  Requires-Dist: langgraph<2,>=1.2.15
23
23
  Requires-Dist: langgraph-prebuilt<2,>=1.1.1
24
24
  Requires-Dist: langgraph-sdk<0.5,>=0.4.6
@@ -1746,6 +1746,9 @@ Python also has async methods such as `aread`, `awrite`, and `adelete`.
1746
1746
  All paths refer to the current sandbox. Context Hub routes for skills and
1747
1747
  memory are not part of this backend.
1748
1748
 
1749
+ The sandbox opens on its first use. `open_sandbox(runtime.backend)` opens it
1750
+ now and returns its name.
1751
+
1749
1752
  Private published images can declare registry credentials by environment
1750
1753
  variable name; MDA creates or updates the deployment-owned Host registry:
1751
1754
 
@@ -1,4 +1,4 @@
1
- managed_deepagents/__init__.py,sha256=dFi9H9x6uIjewzw9leHOtwPFpYYgDlFxeEgMnRn-bTo,22566
1
+ managed_deepagents/__init__.py,sha256=TrCm3-A0qXJLpEvOprzB9vqv-WFBovSqFeH9NVw0Hkc,22650
2
2
  managed_deepagents/__main__.py,sha256=GcjmqN0Ea5v8OHKMxYToasm3eCX_doSLOlpEzAi1tAw,67
3
3
  managed_deepagents/_agent_auth.py,sha256=RrPCIXxCZWCJmsmH-qCugCwlBrIIOKD76siJQOp3ZcI,21573
4
4
  managed_deepagents/_agent_auth_http.py,sha256=xJzhauBcgFchDKjKHY-GuVIhNEP9e0WIPqUqEXzOx8A,7306
@@ -40,20 +40,20 @@ managed_deepagents/_static_entry.py,sha256=QgvrnBLue6elOHSWdIFosFEfYMp4V9YDwBlZS
40
40
  managed_deepagents/_thread_record.py,sha256=310sxl15FdvsCGJW0mwyBlocsAhrvr7b-CxOOyhQVk4,8638
41
41
  managed_deepagents/_validated_token.py,sha256=On96IOQTDz1KE_ZZmuTqY8IPw-cJ3J2tXkkmrfyvbB4,18762
42
42
  managed_deepagents/agent_entry.py,sha256=C6UPWGzp57DlmcY6lJBVbI-8U_Rc5FjGzPBmSoD-O-c,553
43
- managed_deepagents/browser.py,sha256=Ajt4QAcmiDdZi72taZQBSJmezK0PAH9f6UIlcBdk9Dk,59808
43
+ managed_deepagents/browser.py,sha256=dcUhoD8i2ZzxpcsgO7Eb-DUbrd2nHfDpg5MF1pxwqgw,60023
44
44
  managed_deepagents/define_browser.py,sha256=FQKYVVRTDqSNGqG4Pzp1H6qngAsL1h0gOhu8bYxJ140,2000
45
45
  managed_deepagents/define_deep_agent.py,sha256=2qAet4dOn9lUYUSGE1QhoU86LCLZV_MMemLTKayMzfc,12253
46
46
  managed_deepagents/define_memory.py,sha256=0DzI9jxr83YJ6mEhqXRbIYzgWpl259-PdAMoAQRQ3pU,6465
47
47
  managed_deepagents/namespaces.py,sha256=qt41OhCK2mNEDuFwyQ0lkeT5bL0guzv9aRyK3Z-GbVg,4531
48
48
  managed_deepagents/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
49
49
  managed_deepagents/run_context.py,sha256=IayZdcpPrKVss70Hro8qI-EWtL94HZt4JKefzec9qds,3562
50
- managed_deepagents/runtime.py,sha256=FWGLsciTeYqHhr8hpLxetR_xlhqo90RNNSOeAd_FdF0,114053
51
- managed_deepagents/sandbox.py,sha256=cS66-vFcARsbHR3fH5jvWd4qF-MAjiGqRe-_Kocsqtg,4693
50
+ managed_deepagents/runtime.py,sha256=ID3jCEgtxtVyZ8ePKbc4FW4hwh3mwEtndCFl_o60tUY,114229
51
+ managed_deepagents/sandbox.py,sha256=OAZ9BsvuJIIgvE51YR2tL7rwFcjE4q1RaR2dVfNkBzY,5647
52
52
  managed_deepagents/schedules.py,sha256=XROsDs-QwCWH0yEwakIN5Rhl5aM06eZX5-JFJ-KG1To,5898
53
- managed_deepagents/_binaries/mda.exe,sha256=IgOFHlkP0X-kgBpBLdfN9P8PKbc3_UCU66GY-S-VF1A,5106688
53
+ managed_deepagents/_binaries/mda.exe,sha256=dfSqL8aFeiXzeEcGlIS49cEM9pKKUVunxN9hkVKJZCs,5123072
54
54
  managed_deepagents/_channels/__init__.py,sha256=mMgqza7EWRjhJM0lXlFd-W6wBYZrFkpLQ4_30Bpij7k,249
55
55
  managed_deepagents/_channels/actor.py,sha256=3d_1-ia6vwVjXkw7PYn5gg6BjnlPwRXW4nW2C5vAO7c,5203
56
- managed_deepagents/_channels/assistant_text.py,sha256=-QMVt-XhFQu8Myy_Sr7H2rtGDpi_2F7nXG7xYew8_zA,8182
56
+ managed_deepagents/_channels/assistant_text.py,sha256=nf00-KJXNev-e_TkAK_8SBI3J9TiOis1GkGV_zT5048,8472
57
57
  managed_deepagents/_channels/binding.py,sha256=hhx872cgBmJcdMq8Tqz5VKO8pcLCnz0eBlAYfj9_-MA,7837
58
58
  managed_deepagents/_channels/context.py,sha256=3upGBFHPVZXjcZAC5pKhFIMmDhEnKN4d8CzAdOEH-5c,2294
59
59
  managed_deepagents/_channels/delivery.py,sha256=fsBDxoPKk2FIMDH-Gx97vvW-wvnw_HwcIkV9QmpVsDQ,23529
@@ -151,9 +151,9 @@ managed_deepagents/identity/__init__.py,sha256=uZUKDHtfBc0n-T2xoJEFMqMplmXwAK7hb
151
151
  managed_deepagents/identity/claims.py,sha256=prby7r_8Lww3MmoBm8PX6PsSGE3GwSHkr8mVIz_08nU,1180
152
152
  managed_deepagents/identity/options.py,sha256=x_yMbXEFR7zXyehEjDHG2qjAlukXjrRBcQLcM6IndLM,2550
153
153
  managed_deepagents/identity/supabase.py,sha256=8uobl3WCrQL_ieSXG8KTLf1th7Qjim9liZT50HeaJE0,6026
154
- managed_deepagents-0.10.2.dev4.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
155
- managed_deepagents-0.10.2.dev4.dist-info/METADATA,sha256=ceqUGJMyKkW1NLpiJ4pBptkKPiW7gswv1TehUPLTtPA,92915
156
- managed_deepagents-0.10.2.dev4.dist-info/WHEEL,sha256=bhMFZwp6VMtrbl2Ck6PlXryKaCggO1NzYn_HcFbBF1I,97
157
- managed_deepagents-0.10.2.dev4.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
158
- managed_deepagents-0.10.2.dev4.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
159
- managed_deepagents-0.10.2.dev4.dist-info/RECORD,,
154
+ managed_deepagents-0.10.2.dev6.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
155
+ managed_deepagents-0.10.2.dev6.dist-info/METADATA,sha256=bvw-eJlzFYHqII5v87QYXmVdBgqtRhd7up_Fvwnf_Lk,93019
156
+ managed_deepagents-0.10.2.dev6.dist-info/WHEEL,sha256=bhMFZwp6VMtrbl2Ck6PlXryKaCggO1NzYn_HcFbBF1I,97
157
+ managed_deepagents-0.10.2.dev6.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
158
+ managed_deepagents-0.10.2.dev6.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
159
+ managed_deepagents-0.10.2.dev6.dist-info/RECORD,,