darwin-sdk 0.1.0__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.
Files changed (67) hide show
  1. darwin_sdk/__init__.py +96 -0
  2. darwin_sdk/_default_clients.py +30 -0
  3. darwin_sdk/agent/__init__.py +3 -0
  4. darwin_sdk/agent/client.py +212 -0
  5. darwin_sdk/agent/raw_client.py +379 -0
  6. darwin_sdk/approvals/__init__.py +37 -0
  7. darwin_sdk/approvals/client.py +200 -0
  8. darwin_sdk/approvals/raw_client.py +364 -0
  9. darwin_sdk/approvals/types/__init__.py +38 -0
  10. darwin_sdk/approvals/types/approval_decision_request_decision.py +5 -0
  11. darwin_sdk/approvals/types/list_approvals_response.py +20 -0
  12. darwin_sdk/client.py +309 -0
  13. darwin_sdk/core/__init__.py +127 -0
  14. darwin_sdk/core/api_error.py +23 -0
  15. darwin_sdk/core/client_wrapper.py +144 -0
  16. darwin_sdk/core/datetime_utils.py +70 -0
  17. darwin_sdk/core/file.py +67 -0
  18. darwin_sdk/core/force_multipart.py +18 -0
  19. darwin_sdk/core/http_client.py +885 -0
  20. darwin_sdk/core/http_response.py +59 -0
  21. darwin_sdk/core/http_sse/__init__.py +42 -0
  22. darwin_sdk/core/http_sse/_api.py +455 -0
  23. darwin_sdk/core/http_sse/_decoders.py +74 -0
  24. darwin_sdk/core/http_sse/_exceptions.py +7 -0
  25. darwin_sdk/core/http_sse/_models.py +17 -0
  26. darwin_sdk/core/jsonable_encoder.py +120 -0
  27. darwin_sdk/core/logging.py +107 -0
  28. darwin_sdk/core/parse_error.py +36 -0
  29. darwin_sdk/core/pydantic_utilities.py +508 -0
  30. darwin_sdk/core/query_encoder.py +58 -0
  31. darwin_sdk/core/remove_none_from_dict.py +11 -0
  32. darwin_sdk/core/request_options.py +40 -0
  33. darwin_sdk/core/serialization.py +347 -0
  34. darwin_sdk/environment.py +7 -0
  35. darwin_sdk/errors/__init__.py +42 -0
  36. darwin_sdk/errors/bad_request_error.py +11 -0
  37. darwin_sdk/errors/forbidden_error.py +11 -0
  38. darwin_sdk/errors/not_found_error.py +11 -0
  39. darwin_sdk/errors/unauthorized_error.py +11 -0
  40. darwin_sdk/goals/__init__.py +34 -0
  41. darwin_sdk/goals/client.py +264 -0
  42. darwin_sdk/goals/raw_client.py +531 -0
  43. darwin_sdk/goals/types/__init__.py +38 -0
  44. darwin_sdk/goals/types/create_goal_request_kind.py +5 -0
  45. darwin_sdk/goals/types/list_goals_response.py +20 -0
  46. darwin_sdk/integrations/__init__.py +3 -0
  47. darwin_sdk/integrations/client.py +99 -0
  48. darwin_sdk/integrations/raw_client.py +168 -0
  49. darwin_sdk/py.typed +0 -0
  50. darwin_sdk/tools/__init__.py +34 -0
  51. darwin_sdk/tools/client.py +188 -0
  52. darwin_sdk/tools/raw_client.py +352 -0
  53. darwin_sdk/tools/types/__init__.py +34 -0
  54. darwin_sdk/tools/types/list_tools_response.py +20 -0
  55. darwin_sdk/types/__init__.py +48 -0
  56. darwin_sdk/types/approval.py +5 -0
  57. darwin_sdk/types/error.py +26 -0
  58. darwin_sdk/types/error_message.py +5 -0
  59. darwin_sdk/types/execute_tool_response.py +23 -0
  60. darwin_sdk/types/goal.py +5 -0
  61. darwin_sdk/types/tool.py +29 -0
  62. darwin_sdk/types/tool_risk.py +5 -0
  63. darwin_sdk-0.1.0.dist-info/METADATA +49 -0
  64. darwin_sdk-0.1.0.dist-info/RECORD +67 -0
  65. darwin_sdk-0.1.0.dist-info/WHEEL +5 -0
  66. darwin_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
  67. darwin_sdk-0.1.0.dist-info/top_level.txt +1 -0
darwin_sdk/__init__.py ADDED
@@ -0,0 +1,96 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import Approval, Error, ErrorMessage, ExecuteToolResponse, Goal, Tool, ToolRisk
10
+ from .errors import BadRequestError, ForbiddenError, NotFoundError, UnauthorizedError
11
+ from . import agent, approvals, goals, integrations, tools
12
+ from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
13
+ from .approvals import ApprovalDecisionRequestDecision, ListApprovalsResponse
14
+ from .client import AsyncDarwin, Darwin
15
+ from .environment import DarwinEnvironment
16
+ from .goals import CreateGoalRequestKind, ListGoalsResponse
17
+ from .tools import ListToolsResponse
18
+ _dynamic_imports: typing.Dict[str, str] = {
19
+ "Approval": ".types",
20
+ "ApprovalDecisionRequestDecision": ".approvals",
21
+ "AsyncDarwin": ".client",
22
+ "BadRequestError": ".errors",
23
+ "CreateGoalRequestKind": ".goals",
24
+ "Darwin": ".client",
25
+ "DarwinEnvironment": ".environment",
26
+ "DefaultAioHttpClient": "._default_clients",
27
+ "DefaultAsyncHttpxClient": "._default_clients",
28
+ "Error": ".types",
29
+ "ErrorMessage": ".types",
30
+ "ExecuteToolResponse": ".types",
31
+ "ForbiddenError": ".errors",
32
+ "Goal": ".types",
33
+ "ListApprovalsResponse": ".approvals",
34
+ "ListGoalsResponse": ".goals",
35
+ "ListToolsResponse": ".tools",
36
+ "NotFoundError": ".errors",
37
+ "Tool": ".types",
38
+ "ToolRisk": ".types",
39
+ "UnauthorizedError": ".errors",
40
+ "agent": ".agent",
41
+ "approvals": ".approvals",
42
+ "goals": ".goals",
43
+ "integrations": ".integrations",
44
+ "tools": ".tools",
45
+ }
46
+
47
+
48
+ def __getattr__(attr_name: str) -> typing.Any:
49
+ module_name = _dynamic_imports.get(attr_name)
50
+ if module_name is None:
51
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
52
+ try:
53
+ module = import_module(module_name, __package__)
54
+ if module_name == f".{attr_name}":
55
+ return module
56
+ else:
57
+ return getattr(module, attr_name)
58
+ except ImportError as e:
59
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
60
+ except AttributeError as e:
61
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
62
+
63
+
64
+ def __dir__():
65
+ lazy_attrs = list(_dynamic_imports.keys())
66
+ return sorted(lazy_attrs)
67
+
68
+
69
+ __all__ = [
70
+ "Approval",
71
+ "ApprovalDecisionRequestDecision",
72
+ "AsyncDarwin",
73
+ "BadRequestError",
74
+ "CreateGoalRequestKind",
75
+ "Darwin",
76
+ "DarwinEnvironment",
77
+ "DefaultAioHttpClient",
78
+ "DefaultAsyncHttpxClient",
79
+ "Error",
80
+ "ErrorMessage",
81
+ "ExecuteToolResponse",
82
+ "ForbiddenError",
83
+ "Goal",
84
+ "ListApprovalsResponse",
85
+ "ListGoalsResponse",
86
+ "ListToolsResponse",
87
+ "NotFoundError",
88
+ "Tool",
89
+ "ToolRisk",
90
+ "UnauthorizedError",
91
+ "agent",
92
+ "approvals",
93
+ "goals",
94
+ "integrations",
95
+ "tools",
96
+ ]
@@ -0,0 +1,30 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+ SDK_DEFAULT_TIMEOUT = 60
8
+
9
+ try:
10
+ import httpx_aiohttp # type: ignore[import-not-found]
11
+ except ImportError:
12
+
13
+ class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
14
+ def __init__(self, **kwargs: typing.Any) -> None:
15
+ raise RuntimeError("To use the aiohttp client, install the aiohttp extra: pip install darwin_sdk[aiohttp]")
16
+
17
+ else:
18
+
19
+ class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
20
+ def __init__(self, **kwargs: typing.Any) -> None:
21
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
22
+ kwargs.setdefault("follow_redirects", True)
23
+ super().__init__(**kwargs)
24
+
25
+
26
+ class DefaultAsyncHttpxClient(httpx.AsyncClient):
27
+ def __init__(self, **kwargs: typing.Any) -> None:
28
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
29
+ kwargs.setdefault("follow_redirects", True)
30
+ super().__init__(**kwargs)
@@ -0,0 +1,3 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
@@ -0,0 +1,212 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from .raw_client import AsyncRawAgentClient, RawAgentClient
8
+
9
+ # this is used as the default value for optional parameters
10
+ OMIT = typing.cast(typing.Any, ...)
11
+
12
+
13
+ class AgentClient:
14
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
15
+ self._raw_client = RawAgentClient(client_wrapper=client_wrapper)
16
+
17
+ @property
18
+ def with_raw_response(self) -> RawAgentClient:
19
+ """
20
+ Retrieves a raw implementation of this client that returns raw responses.
21
+
22
+ Returns
23
+ -------
24
+ RawAgentClient
25
+ """
26
+ return self._raw_client
27
+
28
+ def get_conversation(
29
+ self,
30
+ *,
31
+ limit: typing.Optional[int] = None,
32
+ cursor: typing.Optional[str] = None,
33
+ request_options: typing.Optional[RequestOptions] = None,
34
+ ) -> typing.Dict[str, typing.Any]:
35
+ """
36
+ Returns the conversation for the agent currently selected on the developer/MCP channel. Natural-language routing in createMessage updates this selection.
37
+
38
+ Parameters
39
+ ----------
40
+ limit : typing.Optional[int]
41
+
42
+ cursor : typing.Optional[str]
43
+
44
+ request_options : typing.Optional[RequestOptions]
45
+ Request-specific configuration.
46
+
47
+ Returns
48
+ -------
49
+ typing.Dict[str, typing.Any]
50
+ The conversation page.
51
+
52
+ Examples
53
+ --------
54
+ from darwin_sdk import Darwin
55
+
56
+ client = Darwin(
57
+ token="YOUR_TOKEN",
58
+ )
59
+ client.agent.get_conversation()
60
+ """
61
+ _response = self._raw_client.get_conversation(limit=limit, cursor=cursor, request_options=request_options)
62
+ return _response.data
63
+
64
+ def create_message(
65
+ self,
66
+ *,
67
+ content: str,
68
+ request_id: typing.Optional[str] = OMIT,
69
+ request_options: typing.Optional[RequestOptions] = None,
70
+ ) -> typing.Dict[str, typing.Any]:
71
+ """
72
+ Darwin infers the intended accessible personal or business agent from the message and current conversation. Name an agent naturally when changing context; ambiguous requests return a clarification without running tools.
73
+
74
+ Parameters
75
+ ----------
76
+ content : str
77
+
78
+ request_id : typing.Optional[str]
79
+ An optional caller-generated idempotency and correlation identifier.
80
+
81
+ request_options : typing.Optional[RequestOptions]
82
+ Request-specific configuration.
83
+
84
+ Returns
85
+ -------
86
+ typing.Dict[str, typing.Any]
87
+ The completed agent turn.
88
+
89
+ Examples
90
+ --------
91
+ from darwin_sdk import Darwin
92
+
93
+ client = Darwin(
94
+ token="YOUR_TOKEN",
95
+ )
96
+ client.agent.create_message(
97
+ content="content",
98
+ )
99
+ """
100
+ _response = self._raw_client.create_message(
101
+ content=content, request_id=request_id, request_options=request_options
102
+ )
103
+ return _response.data
104
+
105
+
106
+ class AsyncAgentClient:
107
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
108
+ self._raw_client = AsyncRawAgentClient(client_wrapper=client_wrapper)
109
+
110
+ @property
111
+ def with_raw_response(self) -> AsyncRawAgentClient:
112
+ """
113
+ Retrieves a raw implementation of this client that returns raw responses.
114
+
115
+ Returns
116
+ -------
117
+ AsyncRawAgentClient
118
+ """
119
+ return self._raw_client
120
+
121
+ async def get_conversation(
122
+ self,
123
+ *,
124
+ limit: typing.Optional[int] = None,
125
+ cursor: typing.Optional[str] = None,
126
+ request_options: typing.Optional[RequestOptions] = None,
127
+ ) -> typing.Dict[str, typing.Any]:
128
+ """
129
+ Returns the conversation for the agent currently selected on the developer/MCP channel. Natural-language routing in createMessage updates this selection.
130
+
131
+ Parameters
132
+ ----------
133
+ limit : typing.Optional[int]
134
+
135
+ cursor : typing.Optional[str]
136
+
137
+ request_options : typing.Optional[RequestOptions]
138
+ Request-specific configuration.
139
+
140
+ Returns
141
+ -------
142
+ typing.Dict[str, typing.Any]
143
+ The conversation page.
144
+
145
+ Examples
146
+ --------
147
+ import asyncio
148
+
149
+ from darwin_sdk import AsyncDarwin
150
+
151
+ client = AsyncDarwin(
152
+ token="YOUR_TOKEN",
153
+ )
154
+
155
+
156
+ async def main() -> None:
157
+ await client.agent.get_conversation()
158
+
159
+
160
+ asyncio.run(main())
161
+ """
162
+ _response = await self._raw_client.get_conversation(limit=limit, cursor=cursor, request_options=request_options)
163
+ return _response.data
164
+
165
+ async def create_message(
166
+ self,
167
+ *,
168
+ content: str,
169
+ request_id: typing.Optional[str] = OMIT,
170
+ request_options: typing.Optional[RequestOptions] = None,
171
+ ) -> typing.Dict[str, typing.Any]:
172
+ """
173
+ Darwin infers the intended accessible personal or business agent from the message and current conversation. Name an agent naturally when changing context; ambiguous requests return a clarification without running tools.
174
+
175
+ Parameters
176
+ ----------
177
+ content : str
178
+
179
+ request_id : typing.Optional[str]
180
+ An optional caller-generated idempotency and correlation identifier.
181
+
182
+ request_options : typing.Optional[RequestOptions]
183
+ Request-specific configuration.
184
+
185
+ Returns
186
+ -------
187
+ typing.Dict[str, typing.Any]
188
+ The completed agent turn.
189
+
190
+ Examples
191
+ --------
192
+ import asyncio
193
+
194
+ from darwin_sdk import AsyncDarwin
195
+
196
+ client = AsyncDarwin(
197
+ token="YOUR_TOKEN",
198
+ )
199
+
200
+
201
+ async def main() -> None:
202
+ await client.agent.create_message(
203
+ content="content",
204
+ )
205
+
206
+
207
+ asyncio.run(main())
208
+ """
209
+ _response = await self._raw_client.create_message(
210
+ content=content, request_id=request_id, request_options=request_options
211
+ )
212
+ return _response.data