mantis-agent-sdk 1.0.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 (79) hide show
  1. mantis_agent/__init__.py +290 -0
  2. mantis_agent/agent.py +1149 -0
  3. mantis_agent/bench.py +299 -0
  4. mantis_agent/budget.py +344 -0
  5. mantis_agent/builtin_tools/__init__.py +21 -0
  6. mantis_agent/builtin_tools/web.py +447 -0
  7. mantis_agent/capabilities.py +736 -0
  8. mantis_agent/claude_compat.py +753 -0
  9. mantis_agent/cli.py +672 -0
  10. mantis_agent/compact.py +327 -0
  11. mantis_agent/compat_query.py +469 -0
  12. mantis_agent/errors.py +100 -0
  13. mantis_agent/events.py +131 -0
  14. mantis_agent/examples/__init__.py +0 -0
  15. mantis_agent/examples/fireworks_hosted.py +235 -0
  16. mantis_agent/examples/max_budget_usd.py +95 -0
  17. mantis_agent/examples/mcp_calculator.py +193 -0
  18. mantis_agent/examples/mcp_filesystem.py +64 -0
  19. mantis_agent/examples/multi_agent_research.py +314 -0
  20. mantis_agent/examples/ollama_local.py +57 -0
  21. mantis_agent/examples/quick_start.py +76 -0
  22. mantis_agent/examples/quickstart.py +79 -0
  23. mantis_agent/examples/research_agent.py +129 -0
  24. mantis_agent/examples/stderr_callback_example.py +43 -0
  25. mantis_agent/examples/streaming_mode_ipython.py +229 -0
  26. mantis_agent/examples/streaming_render.py +48 -0
  27. mantis_agent/examples/system_prompt.py +87 -0
  28. mantis_agent/examples/tools_option.py +111 -0
  29. mantis_agent/examples/vllm_self_hosted.py +279 -0
  30. mantis_agent/examples/with_thinking.py +77 -0
  31. mantis_agent/examples/with_tracing.py +172 -0
  32. mantis_agent/hooks.py +266 -0
  33. mantis_agent/http.py +206 -0
  34. mantis_agent/mcp/__init__.py +78 -0
  35. mantis_agent/mcp/client.py +686 -0
  36. mantis_agent/mcp/server.py +695 -0
  37. mantis_agent/mcp/transports/__init__.py +16 -0
  38. mantis_agent/mcp/transports/base.py +49 -0
  39. mantis_agent/mcp/transports/http.py +191 -0
  40. mantis_agent/mcp/transports/in_process.py +110 -0
  41. mantis_agent/mcp/transports/sse.py +169 -0
  42. mantis_agent/mcp/transports/stdio.py +154 -0
  43. mantis_agent/mcp/types.py +355 -0
  44. mantis_agent/memory.py +251 -0
  45. mantis_agent/paths.py +166 -0
  46. mantis_agent/permissions.py +284 -0
  47. mantis_agent/providers/__init__.py +18 -0
  48. mantis_agent/providers/anthropic_passthrough.py +625 -0
  49. mantis_agent/providers/base.py +156 -0
  50. mantis_agent/providers/llamacpp.py +106 -0
  51. mantis_agent/providers/mock.py +203 -0
  52. mantis_agent/providers/modal_provider.py +392 -0
  53. mantis_agent/providers/ollama.py +696 -0
  54. mantis_agent/providers/openai_compat.py +939 -0
  55. mantis_agent/providers/tgi.py +106 -0
  56. mantis_agent/query.py +741 -0
  57. mantis_agent/response_format.py +250 -0
  58. mantis_agent/retry.py +192 -0
  59. mantis_agent/routing.py +124 -0
  60. mantis_agent/session.py +847 -0
  61. mantis_agent/settings.py +388 -0
  62. mantis_agent/setup_local.py +695 -0
  63. mantis_agent/setup_local_llamacpp.py +735 -0
  64. mantis_agent/skills.py +221 -0
  65. mantis_agent/streaming/__init__.py +26 -0
  66. mantis_agent/streaming/executor.py +776 -0
  67. mantis_agent/streaming/text_tool_parser.py +289 -0
  68. mantis_agent/streaming/thinking_parser.py +255 -0
  69. mantis_agent/subagent.py +342 -0
  70. mantis_agent/system_reminder.py +225 -0
  71. mantis_agent/tools.py +409 -0
  72. mantis_agent/tracing.py +536 -0
  73. mantis_agent/transcripts.py +187 -0
  74. mantis_agent/types.py +268 -0
  75. mantis_agent_sdk-1.0.0.dist-info/METADATA +441 -0
  76. mantis_agent_sdk-1.0.0.dist-info/RECORD +79 -0
  77. mantis_agent_sdk-1.0.0.dist-info/WHEEL +4 -0
  78. mantis_agent_sdk-1.0.0.dist-info/entry_points.txt +2 -0
  79. mantis_agent_sdk-1.0.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,290 @@
1
+ """mantis-agent-sdk — Claude Code for open-source models.
2
+
3
+ The semver-stable public API is the set of names exported in ``__all__``.
4
+ Anything else (including names imported at the top of this module but not
5
+ listed in ``__all__``) is implementation detail and may change between
6
+ minor releases. See ``SEMVER.md`` for the full policy.
7
+ """
8
+
9
+ from .agent import Agent
10
+ from .builtin_tools import WebFetch, WebSearch, web_fetch, web_search
11
+ from .capabilities import (
12
+ BackendCapability,
13
+ ModelCapability,
14
+ ToolUsePath,
15
+ lookup_model,
16
+ resolve_tool_use_path,
17
+ )
18
+ from .errors import (
19
+ AgentError,
20
+ AuthError,
21
+ BudgetExceededError,
22
+ PermissionDeniedError,
23
+ ProviderError,
24
+ RateLimitError,
25
+ StreamProtocolError,
26
+ ToolExecutionError,
27
+ )
28
+ from .events import (
29
+ ContentBlockDelta,
30
+ ContentBlockStart,
31
+ ContentBlockStop,
32
+ InputJsonDelta,
33
+ MessageDelta,
34
+ MessageStart,
35
+ MessageStop,
36
+ StreamEvent,
37
+ TextDelta,
38
+ ThinkingDelta,
39
+ )
40
+ from .claude_compat import (
41
+ AgentDefinition,
42
+ CLIConnectionError,
43
+ ClaudeAgentOptions,
44
+ ClaudeSDKClient,
45
+ ClaudeSDKError,
46
+ HookContext as ClaudeHookContext,
47
+ HookInput,
48
+ HookJSONOutput,
49
+ HookMatcher,
50
+ PermissionResult as ClaudePermissionResult,
51
+ PermissionResultAllow,
52
+ PermissionResultDeny,
53
+ Plugin,
54
+ ResultMessage,
55
+ ToolPermissionContext,
56
+ create_sdk_mcp_server,
57
+ )
58
+ # Pull SystemMessage from claude_compat as the canonical top-level name —
59
+ # this is the flat-shape version with .subtype + .data that Claude SDK
60
+ # examples use. Our internal SystemMessage (no subtype) is still
61
+ # available via `from mantis_agent.types import SystemMessage as
62
+ # InternalSystemMessage` if needed.
63
+ from .claude_compat import SystemMessage # type: ignore[assignment] # overrides earlier import
64
+ from .memory import (
65
+ MemoryEntry,
66
+ list_memory_entries,
67
+ load_memory_entry,
68
+ load_memory_index,
69
+ save_memory_entry,
70
+ update_memory_index,
71
+ )
72
+ from .paths import (
73
+ get_mantis_agent_dir,
74
+ get_memory_dir,
75
+ get_memory_index,
76
+ get_sessions_dir,
77
+ get_session_path,
78
+ )
79
+ from .settings import (
80
+ KNOWN_SETTING_KEYS,
81
+ SETTING_SOURCES,
82
+ apply_settings_to_options,
83
+ load_setting_source,
84
+ load_settings,
85
+ merge_settings,
86
+ resolve_setting_path,
87
+ save_setting_source,
88
+ update_setting_source,
89
+ )
90
+ from .query import (
91
+ APIAssistantMessage,
92
+ APIUserMessage,
93
+ SDKAssistantMessage,
94
+ SDKCompactBoundaryMessage,
95
+ SDKMessage,
96
+ SDKPermissionDenial,
97
+ SDKResultMessage,
98
+ SDKStatusMessage,
99
+ SDKSystemMessage,
100
+ SDKUserMessage,
101
+ query,
102
+ )
103
+ from .system_reminder import (
104
+ build_live_context_block,
105
+ is_system_reminder,
106
+ prepend_user_context,
107
+ render_user_context,
108
+ strip_system_reminders,
109
+ wrap_system_reminder,
110
+ )
111
+ from .session import (
112
+ Checkpoint,
113
+ InMemorySessionStore,
114
+ Session,
115
+ SessionInfo,
116
+ SessionNotFoundError,
117
+ SessionStore,
118
+ SqliteSessionStore,
119
+ fork_session,
120
+ make_checkpoints,
121
+ resume_session,
122
+ )
123
+ from .transcripts import (
124
+ JsonlTranscript,
125
+ iter_transcripts,
126
+ read_transcript,
127
+ )
128
+ from .subagent import (
129
+ IsolationMode,
130
+ SubAgentSpec,
131
+ SubAgentTool,
132
+ WrappedAgentTool,
133
+ as_subagent_tool,
134
+ )
135
+ from .response_format import (
136
+ ResponseFormatError,
137
+ normalize_response_format,
138
+ translate_response_format,
139
+ )
140
+ from .tools import Tool, ToolRegistry, tool
141
+ from .tracing import (
142
+ InMemoryTracer,
143
+ OTelTracer,
144
+ Span,
145
+ Tracer,
146
+ )
147
+ from .types import (
148
+ AssistantMessage,
149
+ ContentBlock,
150
+ Message,
151
+ ModelUsage,
152
+ SystemMessage as InternalSystemMessage, # keep accessible for advanced use
153
+ TextBlock,
154
+ ThinkingBlock,
155
+ ToolResultBlock,
156
+ ToolUseBlock,
157
+ Usage,
158
+ UserMessage,
159
+ )
160
+
161
+ # --- public, semver-stable API surface (1.0.0+) -----------------------------
162
+ # Everything below is covered by the SemVer guarantee in SEMVER.md.
163
+ # Symbols imported above but NOT listed here are implementation detail.
164
+ __all__ = [
165
+ # Core
166
+ "Agent",
167
+ "query",
168
+ "tool",
169
+ # Tools
170
+ "Tool",
171
+ "ToolRegistry",
172
+ "WebFetch",
173
+ "WebSearch",
174
+ "web_fetch",
175
+ "web_search",
176
+ # Sub-agents
177
+ "AgentDefinition",
178
+ "IsolationMode",
179
+ "SubAgentSpec",
180
+ "SubAgentTool",
181
+ "WrappedAgentTool",
182
+ "as_subagent_tool",
183
+ # Capabilities / routing
184
+ "BackendCapability",
185
+ "ModelCapability",
186
+ "ToolUsePath",
187
+ "lookup_model",
188
+ "resolve_tool_use_path",
189
+ # Plugins
190
+ "Plugin",
191
+ # Messages — internal flat shapes
192
+ "AssistantMessage",
193
+ "ContentBlock",
194
+ "Message",
195
+ "ModelUsage",
196
+ "TextBlock",
197
+ "ThinkingBlock",
198
+ "ToolResultBlock",
199
+ "ToolUseBlock",
200
+ "Usage",
201
+ "UserMessage",
202
+ "SystemMessage",
203
+ # Messages — Claude SDK parity shapes
204
+ "APIAssistantMessage",
205
+ "APIUserMessage",
206
+ "SDKAssistantMessage",
207
+ "SDKCompactBoundaryMessage",
208
+ "SDKMessage",
209
+ "SDKPermissionDenial",
210
+ "SDKResultMessage",
211
+ "SDKStatusMessage",
212
+ "SDKSystemMessage",
213
+ "SDKUserMessage",
214
+ "ResultMessage",
215
+ # Streaming events
216
+ "ContentBlockDelta",
217
+ "ContentBlockStart",
218
+ "ContentBlockStop",
219
+ "InputJsonDelta",
220
+ "MessageDelta",
221
+ "MessageStart",
222
+ "MessageStop",
223
+ "StreamEvent",
224
+ "TextDelta",
225
+ "ThinkingDelta",
226
+ # Claude SDK parity entry points
227
+ "ClaudeAgentOptions",
228
+ "ClaudeSDKClient",
229
+ "ClaudeSDKError",
230
+ "CLIConnectionError",
231
+ "HookMatcher",
232
+ "HookInput",
233
+ "HookJSONOutput",
234
+ "ClaudeHookContext",
235
+ "ClaudePermissionResult",
236
+ "PermissionResultAllow",
237
+ "PermissionResultDeny",
238
+ "ToolPermissionContext",
239
+ "create_sdk_mcp_server",
240
+ # Sessions
241
+ "Checkpoint",
242
+ "InMemorySessionStore",
243
+ "Session",
244
+ "SessionInfo",
245
+ "SessionNotFoundError",
246
+ "SessionStore",
247
+ "SqliteSessionStore",
248
+ "fork_session",
249
+ "make_checkpoints",
250
+ "resume_session",
251
+ # Structured output
252
+ "ResponseFormatError",
253
+ "normalize_response_format",
254
+ "translate_response_format",
255
+ # Tracing
256
+ "Tracer",
257
+ "Span",
258
+ "InMemoryTracer",
259
+ "OTelTracer",
260
+ # Errors
261
+ "AgentError",
262
+ "AuthError",
263
+ "BudgetExceededError",
264
+ "PermissionDeniedError",
265
+ "ProviderError",
266
+ "RateLimitError",
267
+ "StreamProtocolError",
268
+ "ToolExecutionError",
269
+ # Version
270
+ "__version__",
271
+ ]
272
+
273
+
274
+ def _detect_version() -> str:
275
+ """Single-source the version from installed package metadata.
276
+
277
+ Falls back to a literal so import still works in editable / unbuilt
278
+ checkouts where metadata may be stale. The release workflow always
279
+ builds from pyproject.toml so the published wheel reports the
280
+ correct version through importlib.metadata.
281
+ """
282
+ try:
283
+ from importlib.metadata import PackageNotFoundError, version # type: ignore[attr-defined]
284
+
285
+ return version("mantis-agent-sdk")
286
+ except Exception: # pragma: no cover - extremely defensive
287
+ return "1.0.0"
288
+
289
+
290
+ __version__ = _detect_version()