raindrop-deep-agents 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ """Raindrop integration for Deep Agents."""
2
+
3
+ # IMPORTANT: install the wrapt 2.x compat shim BEFORE handler.py imports
4
+ # raindrop.analytics (which transitively triggers Traceloop's instrumentor
5
+ # loader). The shim is a no-op on wrapt 1.x and translates the legacy
6
+ # ``module=`` kwarg to ``target=`` on wrapt 2.x so the LangChain
7
+ # instrumentor can activate. See raindrop_deep_agents/_wrapt_compat.py.
8
+ from . import _wrapt_compat as _wrapt_compat # noqa: E402 (must run first)
9
+ _wrapt_compat.install()
10
+
11
+ from .handler import ( # noqa: E402 (after shim install)
12
+ RaindropDeepAgents,
13
+ RaindropDeepAgentsHandler,
14
+ create_raindrop_deep_agents,
15
+ )
16
+
17
+ __version__ = "0.0.1"
18
+
19
+ __all__ = [
20
+ "RaindropDeepAgents",
21
+ "RaindropDeepAgentsHandler",
22
+ "create_raindrop_deep_agents",
23
+ ]
@@ -0,0 +1,112 @@
1
+ """Backwards-compat shim for wrapt 1.x → 2.x.
2
+
3
+ wrapt 2.0 (released 2026) renamed the first parameter of
4
+ ``wrap_function_wrapper`` from ``module`` to ``target``::
5
+
6
+ # wrapt 1.x
7
+ def wrap_function_wrapper(module, name, wrapper): ...
8
+
9
+ # wrapt 2.x
10
+ def wrap_function_wrapper(target, name, wrapper): ...
11
+
12
+ About 16 OpenTelemetry instrumentation packages — including the
13
+ ``opentelemetry-instrumentation-langchain`` package that powers our
14
+ trace nesting — still call this function with ``module=`` as a
15
+ keyword argument. Under wrapt 2.x that raises::
16
+
17
+ TypeError: wrap_function_wrapper() got an unexpected keyword
18
+ argument 'module'
19
+
20
+ Traceloop catches the exception and silently disables the
21
+ instrumentor, so the user's app keeps running while traces never
22
+ reach the dashboard — a hard-to-debug feature loss.
23
+
24
+ This shim wraps ``wrap_function_wrapper`` (in both ``wrapt`` and
25
+ ``wrapt.wrappers``, since some packages import directly from the
26
+ submodule) with a translation layer that accepts ``module=`` and
27
+ forwards it as ``target=``. It is a no-op on wrapt 1.x and is
28
+ applied at import time so any subsequent instrumentor activation
29
+ sees the patched function.
30
+
31
+ Tracked upstream:
32
+ - traceloop/openllmetry#4009 (the package we actually depend on,
33
+ via raindrop-ai → traceloop-sdk → opentelemetry-instrumentation-
34
+ langchain). As of latest release 0.59.2 (uploaded 2026-04-16)
35
+ the call sites still use ``module=`` — fix not shipped yet.
36
+ - Arize-ai/openinference#2996 (a separate but identical instrumentor
37
+ family — same bug, affects 16 packages on their side).
38
+
39
+ When the Traceloop maintainers migrate the call sites to ``target=``
40
+ (or to positional args) and ship a release, this shim becomes
41
+ pointless and can be deleted.
42
+ """
43
+ from __future__ import annotations
44
+
45
+ import logging
46
+ from typing import Any
47
+
48
+ logger = logging.getLogger(__name__)
49
+
50
+
51
+ def install() -> bool:
52
+ """Install the wrapt 2.x ``module=`` → ``target=`` compat shim.
53
+
54
+ Returns ``True`` if the shim was applied, ``False`` if not needed
55
+ (wrapt < 2.0) or installation failed.
56
+ """
57
+ try:
58
+ import wrapt
59
+ except Exception: # wrapt should always be importable as a transitive dep
60
+ logger.debug("wrapt not importable — skipping compat shim", exc_info=True)
61
+ return False
62
+
63
+ # wrapt 1.x already accepts module= so the shim is unnecessary. Only
64
+ # touch wrapt 2.x and later.
65
+ version = getattr(wrapt, "__version__", "0")
66
+ try:
67
+ major = int(version.split(".", 1)[0])
68
+ except Exception:
69
+ major = 0
70
+ if major < 2:
71
+ return False
72
+
73
+ try:
74
+ original = wrapt.wrap_function_wrapper
75
+ except AttributeError:
76
+ logger.debug(
77
+ "wrapt.wrap_function_wrapper missing — cannot install compat shim",
78
+ )
79
+ return False
80
+
81
+ # Idempotent: if we've already shimmed this process, don't double-wrap.
82
+ if getattr(original, "_raindrop_deep_agents_compat_shim", False):
83
+ return True
84
+
85
+ def _compat_wrap_function_wrapper(
86
+ target: Any = None,
87
+ name: Any = None,
88
+ wrapper: Any = None,
89
+ *,
90
+ module: Any = None,
91
+ ) -> Any:
92
+ # Translate the legacy module= kwarg to the renamed target= arg.
93
+ # If both are provided, target wins (matches modern API).
94
+ if target is None and module is not None:
95
+ target = module
96
+ return original(target, name, wrapper)
97
+
98
+ _compat_wrap_function_wrapper._raindrop_deep_agents_compat_shim = True # type: ignore[attr-defined]
99
+ wrapt.wrap_function_wrapper = _compat_wrap_function_wrapper
100
+
101
+ # Some packages import directly from wrapt.wrappers, so patch both.
102
+ try:
103
+ import wrapt.wrappers as _wrappers
104
+ _wrappers.wrap_function_wrapper = _compat_wrap_function_wrapper
105
+ except Exception:
106
+ logger.debug(
107
+ "Could not patch wrapt.wrappers.wrap_function_wrapper",
108
+ exc_info=True,
109
+ )
110
+
111
+ logger.debug("Installed wrapt %s compat shim (module= → target=)", version)
112
+ return True