dominusnode-langchain 1.2.0__tar.gz → 1.2.2__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dominusnode-langchain
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: LangChain tools for Dominus Node rotating proxy service
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -1,8 +1,8 @@
1
1
  """Dominus Node LangChain Toolkit -- bundles all 53 Dominus Node tools for agent use.
2
2
 
3
- The :class:`DominusNodeToolkit` creates a :class:`DominusNodeClient` internally
4
- and injects it into each tool so that a single authenticated session is shared
5
- across all tools in a LangChain agent.
3
+ The :class:`DominusNodeToolkit` injects API credentials into each tool so that
4
+ a single authenticated configuration is shared across all tools in a LangChain
5
+ agent. All tools use direct REST calls (no SDK dependency).
6
6
 
7
7
  Example::
8
8
 
@@ -22,8 +22,6 @@ from typing import List, Optional
22
22
 
23
23
  from langchain_core.tools import BaseTool, BaseToolkit
24
24
 
25
- from dominusnode import AsyncDominusNodeClient, DominusNodeClient
26
-
27
25
  from .tools import (
28
26
  # Proxy (3)
29
27
  DominusNodeProxiedFetchTool,
@@ -93,8 +91,7 @@ from .tools import (
93
91
  class DominusNodeToolkit(BaseToolkit):
94
92
  """LangChain toolkit that provides all 53 Dominus Node proxy service tools.
95
93
 
96
- Creates and manages a :class:`DominusNodeClient` (sync) and optionally
97
- an :class:`AsyncDominusNodeClient` (async) for use by LangChain agents.
94
+ Injects API key and base URL into each tool for direct REST API calls.
98
95
 
99
96
  Args:
100
97
  api_key: Dominus Node API key (``dn_live_...``). Falls back to the
@@ -110,9 +107,6 @@ class DominusNodeToolkit(BaseToolkit):
110
107
  ValueError: If no API key is provided or found in environment.
111
108
  """
112
109
 
113
- # Stored so tools can reference them; not exposed to LLM
114
- _sync_client: Optional[DominusNodeClient] = None
115
- _async_client: Optional[AsyncDominusNodeClient] = None
116
110
  _tools: Optional[List[BaseTool]] = None
117
111
 
118
112
  model_config = {"arbitrary_types_allowed": True}
@@ -143,72 +137,56 @@ class DominusNodeToolkit(BaseToolkit):
143
137
  "DOMINUSNODE_PROXY_HOST", "proxy.dominusnode.com"
144
138
  )
145
139
 
146
- # Store credentials for direct REST API tools
147
140
  self._api_key = resolved_key
148
141
  self._base_url = resolved_base
149
142
  self._agent_secret = agent_secret or os.environ.get("DOMINUSNODE_AGENT_SECRET")
150
143
 
151
- # Create sync client
152
- self._sync_client = DominusNodeClient(
153
- base_url=resolved_base,
154
- api_key=resolved_key,
155
- proxy_host=resolved_proxy_host,
156
- http_proxy_port=http_proxy_port,
157
- socks5_proxy_port=socks5_proxy_port,
158
- agent_secret=self._agent_secret,
159
- )
160
-
161
- # Create async client (deferred connect -- will connect in __aenter__)
162
- self._async_client = AsyncDominusNodeClient(
163
- base_url=resolved_base,
164
- api_key=resolved_key,
165
- proxy_host=resolved_proxy_host,
166
- http_proxy_port=http_proxy_port,
167
- socks5_proxy_port=socks5_proxy_port,
168
- agent_secret=self._agent_secret,
169
- )
144
+ # Store proxy host/port for env-based tools
145
+ os.environ.setdefault("DOMINUSNODE_PROXY_HOST", resolved_proxy_host)
146
+ os.environ.setdefault("DOMINUSNODE_PROXY_PORT", str(http_proxy_port))
170
147
 
171
148
  # Build tools once
172
149
  self._tools = self._build_tools()
173
150
 
174
151
  def _build_tools(self) -> List[BaseTool]:
175
- """Construct all 53 tool instances with injected clients."""
176
- sc = self._sync_client
177
- ac = self._async_client
152
+ """Construct all 53 tool instances with injected credentials."""
178
153
  _ak = self._api_key
179
154
  _bu = self._base_url
180
155
  _as = self._agent_secret
181
-
182
- # Helper for SDK-client-based tools
183
- def _sdk(cls: type) -> BaseTool:
184
- return cls(sync_client=sc, async_client=ac)
156
+ _ph = os.environ.get("DOMINUSNODE_PROXY_HOST", "localhost")
157
+ _pp = int(os.environ.get("DOMINUSNODE_PROXY_PORT", "8080"))
185
158
 
186
159
  # Helper for REST-API-based tools (authenticated)
187
160
  def _rest(cls: type) -> BaseTool:
188
161
  return cls(api_key=_ak, base_url=_bu, agent_secret=_as)
189
162
 
163
+ # Helper for proxy tools that need proxy host/port
164
+ def _proxy(cls: type) -> BaseTool:
165
+ return cls(api_key=_ak, base_url=_bu, agent_secret=_as,
166
+ proxy_host=_ph, proxy_port=_pp)
167
+
190
168
  # Helper for unauthenticated tools
191
169
  def _unauth(cls: type) -> BaseTool:
192
170
  return cls(base_url=_bu, agent_secret=_as)
193
171
 
194
172
  return [
195
173
  # Proxy (3)
196
- _sdk(DominusNodeProxiedFetchTool),
197
- _sdk(DominusNodeProxyConfigTool),
198
- _sdk(DominusNodeProxyStatusTool),
174
+ _proxy(DominusNodeProxiedFetchTool),
175
+ _rest(DominusNodeProxyConfigTool),
176
+ _rest(DominusNodeProxyStatusTool),
199
177
  # Sessions (1)
200
- _sdk(DominusNodeListSessionsTool),
178
+ _rest(DominusNodeListSessionsTool),
201
179
  # Wallet (8)
202
- _sdk(DominusNodeBalanceTool),
180
+ _rest(DominusNodeBalanceTool),
203
181
  _rest(DominusNodeGetTransactionsTool),
204
182
  _rest(DominusNodeGetForecastTool),
205
- _sdk(DominusNodeTopupPaypalTool),
206
- _sdk(DominusNodeTopupStripeTool),
207
- _sdk(DominusNodeTopupCryptoTool),
183
+ _rest(DominusNodeTopupPaypalTool),
184
+ _rest(DominusNodeTopupStripeTool),
185
+ _rest(DominusNodeTopupCryptoTool),
208
186
  _rest(DominusNodeCheckPaymentTool),
209
- _sdk(DominusNodeX402InfoTool),
187
+ _rest(DominusNodeX402InfoTool),
210
188
  # Usage (3)
211
- _sdk(DominusNodeUsageTool),
189
+ _rest(DominusNodeUsageTool),
212
190
  _rest(DominusNodeDailyUsageTool),
213
191
  _rest(DominusNodeTopHostsTool),
214
192
  # Account (6) -- register, login, verify_email are unauthenticated
@@ -263,11 +241,5 @@ class DominusNodeToolkit(BaseToolkit):
263
241
  return list(self._tools)
264
242
 
265
243
  def close(self) -> None:
266
- """Close the underlying SDK clients and release resources."""
267
- if self._sync_client is not None:
268
- self._sync_client.close()
269
- self._sync_client = None
270
- if self._async_client is not None:
271
- self._async_client.close()
272
- self._async_client = None
244
+ """Release resources."""
273
245
  self._tools = None