maivn 0.2.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 (269) hide show
  1. maivn/__init__.py +265 -0
  2. maivn/__version__.py +10 -0
  3. maivn/_internal/adapters/__init__.py +1 -0
  4. maivn/_internal/adapters/networking/__init__.py +17 -0
  5. maivn/_internal/adapters/networking/http_client.py +41 -0
  6. maivn/_internal/adapters/networking/sse_client.py +153 -0
  7. maivn/_internal/adapters/repositories/__init__.py +22 -0
  8. maivn/_internal/adapters/repositories/agent_repo.py +73 -0
  9. maivn/_internal/adapters/repositories/dependency_repo.py +91 -0
  10. maivn/_internal/adapters/repositories/tool_repo.py +74 -0
  11. maivn/_internal/api/__init__.py +23 -0
  12. maivn/_internal/api/agent/__init__.py +7 -0
  13. maivn/_internal/api/agent/agent.py +673 -0
  14. maivn/_internal/api/agent/client_cache.py +45 -0
  15. maivn/_internal/api/agent/hooks.py +153 -0
  16. maivn/_internal/api/agent/invocation_helpers.py +199 -0
  17. maivn/_internal/api/agent/invocation_state.py +38 -0
  18. maivn/_internal/api/async_stream.py +44 -0
  19. maivn/_internal/api/base_scope/__init__.py +11 -0
  20. maivn/_internal/api/base_scope/batch.py +89 -0
  21. maivn/_internal/api/base_scope/builders.py +326 -0
  22. maivn/_internal/api/base_scope/mcp.py +92 -0
  23. maivn/_internal/api/base_scope/memory.py +427 -0
  24. maivn/_internal/api/base_scope/normalization.py +35 -0
  25. maivn/_internal/api/base_scope/redaction.py +134 -0
  26. maivn/_internal/api/base_scope/runtime.py +72 -0
  27. maivn/_internal/api/base_scope/scheduling.py +113 -0
  28. maivn/_internal/api/base_scope/scope.py +318 -0
  29. maivn/_internal/api/base_scope/tooling.py +260 -0
  30. maivn/_internal/api/base_scope/validation.py +234 -0
  31. maivn/_internal/api/client/__init__.py +8 -0
  32. maivn/_internal/api/client/client.py +314 -0
  33. maivn/_internal/api/client/http.py +143 -0
  34. maivn/_internal/api/client/memory.py +343 -0
  35. maivn/_internal/api/mcp/__init__.py +11 -0
  36. maivn/_internal/api/mcp/auto.py +72 -0
  37. maivn/_internal/api/mcp/clients.py +390 -0
  38. maivn/_internal/api/mcp/retry.py +104 -0
  39. maivn/_internal/api/mcp/server.py +337 -0
  40. maivn/_internal/api/mcp/tools.py +61 -0
  41. maivn/_internal/api/resource_models.py +151 -0
  42. maivn/_internal/api/scheduling/__init__.py +30 -0
  43. maivn/_internal/api/scheduling/builder.py +289 -0
  44. maivn/_internal/api/scheduling/jitter.py +169 -0
  45. maivn/_internal/api/scheduling/job.py +314 -0
  46. maivn/_internal/api/scheduling/models.py +43 -0
  47. maivn/_internal/api/scheduling/registry.py +38 -0
  48. maivn/_internal/api/scheduling/retry.py +55 -0
  49. maivn/_internal/api/scheduling/schedule.py +145 -0
  50. maivn/_internal/api/swarm/__init__.py +7 -0
  51. maivn/_internal/api/swarm/member.py +199 -0
  52. maivn/_internal/api/swarm/metadata.py +302 -0
  53. maivn/_internal/api/swarm/swarm.py +488 -0
  54. maivn/_internal/api/swarm/validation.py +50 -0
  55. maivn/_internal/core/__init__.py +37 -0
  56. maivn/_internal/core/application_init.py +4 -0
  57. maivn/_internal/core/application_services/__init__.py +43 -0
  58. maivn/_internal/core/application_services/config_helpers.py +18 -0
  59. maivn/_internal/core/application_services/constants.py +18 -0
  60. maivn/_internal/core/application_services/events/__init__.py +13 -0
  61. maivn/_internal/core/application_services/events/event_handlers.py +260 -0
  62. maivn/_internal/core/application_services/events/event_stream_processor.py +330 -0
  63. maivn/_internal/core/application_services/events/interrupt_manager.py +355 -0
  64. maivn/_internal/core/application_services/events/system_tool_handlers.py +237 -0
  65. maivn/_internal/core/application_services/execution/__init__.py +12 -0
  66. maivn/_internal/core/application_services/execution/background_executor.py +228 -0
  67. maivn/_internal/core/application_services/helpers/__init__.py +16 -0
  68. maivn/_internal/core/application_services/helpers/input_validator.py +242 -0
  69. maivn/_internal/core/application_services/helpers/pydantic_deserializer.py +393 -0
  70. maivn/_internal/core/application_services/helpers/resource_utils.py +56 -0
  71. maivn/_internal/core/application_services/http/__init__.py +10 -0
  72. maivn/_internal/core/application_services/http/http_client_service.py +214 -0
  73. maivn/_internal/core/application_services/orchestration/__init__.py +14 -0
  74. maivn/_internal/core/application_services/orchestration/tool_execution_orchestrator.py +396 -0
  75. maivn/_internal/core/application_services/session/__init__.py +10 -0
  76. maivn/_internal/core/application_services/session/session_service.py +74 -0
  77. maivn/_internal/core/application_services/state_compilation/__init__.py +11 -0
  78. maivn/_internal/core/application_services/state_compilation/dependency_updates.py +83 -0
  79. maivn/_internal/core/application_services/state_compilation/dynamic_tool_factory.py +390 -0
  80. maivn/_internal/core/application_services/state_compilation/dynamic_tool_factory_nested.py +173 -0
  81. maivn/_internal/core/application_services/state_compilation/dynamic_tool_factory_response.py +155 -0
  82. maivn/_internal/core/application_services/state_compilation/state_compiler.py +484 -0
  83. maivn/_internal/core/application_services/state_compilation/tool_normalization.py +110 -0
  84. maivn/_internal/core/application_services/tool_execution/__init__.py +41 -0
  85. maivn/_internal/core/application_services/tool_execution/argument_utils.py +116 -0
  86. maivn/_internal/core/application_services/tool_execution/basic_tool_execution_service.py +190 -0
  87. maivn/_internal/core/application_services/tool_execution/execution_strategy.py +386 -0
  88. maivn/_internal/core/application_services/tool_execution/helpers/__init__.py +21 -0
  89. maivn/_internal/core/application_services/tool_execution/helpers/argument_validator.py +44 -0
  90. maivn/_internal/core/application_services/tool_execution/helpers/dependency_resolver.py +307 -0
  91. maivn/_internal/core/application_services/tool_execution/helpers/function_executor.py +121 -0
  92. maivn/_internal/core/application_services/tool_execution/helpers/mcp_executor.py +44 -0
  93. maivn/_internal/core/application_services/tool_execution/helpers/model_executor.py +61 -0
  94. maivn/_internal/core/application_services/tool_execution/tool_event_dispatcher/__init__.py +7 -0
  95. maivn/_internal/core/application_services/tool_execution/tool_event_dispatcher/dispatcher.py +315 -0
  96. maivn/_internal/core/application_services/tool_execution/tool_event_dispatcher/execution.py +75 -0
  97. maivn/_internal/core/application_services/tool_execution/tool_event_dispatcher/logging_helpers.py +64 -0
  98. maivn/_internal/core/application_services/tool_execution/tool_event_dispatcher/reporting.py +156 -0
  99. maivn/_internal/core/application_services/tool_execution/tool_execution_service.py +299 -0
  100. maivn/_internal/core/domain_init.py +35 -0
  101. maivn/_internal/core/entities/__init__.py +52 -0
  102. maivn/_internal/core/entities/execution_context.py +82 -0
  103. maivn/_internal/core/entities/mixins/__init__.py +37 -0
  104. maivn/_internal/core/entities/mixins/configurable_mixin.py +145 -0
  105. maivn/_internal/core/entities/mixins/identifiable_mixin.py +109 -0
  106. maivn/_internal/core/entities/session_endpoints.py +17 -0
  107. maivn/_internal/core/entities/sse_event.py +14 -0
  108. maivn/_internal/core/entities/state_compilation_config.py +26 -0
  109. maivn/_internal/core/entities/tool_events.py +34 -0
  110. maivn/_internal/core/entities/tool_spec_registry.py +45 -0
  111. maivn/_internal/core/entities/tools/__init__.py +22 -0
  112. maivn/_internal/core/entities/tools/agent_tool.py +42 -0
  113. maivn/_internal/core/entities/tools/base_tool.py +111 -0
  114. maivn/_internal/core/entities/tools/function_tool.py +91 -0
  115. maivn/_internal/core/entities/tools/mcp_tool.py +56 -0
  116. maivn/_internal/core/entities/tools/model_tool.py +127 -0
  117. maivn/_internal/core/exceptions.py +340 -0
  118. maivn/_internal/core/interfaces/__init__.py +20 -0
  119. maivn/_internal/core/interfaces/orchestrator_protocol.py +195 -0
  120. maivn/_internal/core/interfaces/repositories/__init__.py +15 -0
  121. maivn/_internal/core/interfaces/repositories/agent.py +87 -0
  122. maivn/_internal/core/interfaces/repositories/dependency.py +77 -0
  123. maivn/_internal/core/interfaces/repositories/tool.py +82 -0
  124. maivn/_internal/core/interfaces/resolvers.py +40 -0
  125. maivn/_internal/core/interfaces/sse_client.py +33 -0
  126. maivn/_internal/core/interfaces/tool_executor.py +26 -0
  127. maivn/_internal/core/interfaces/tool_specs.py +20 -0
  128. maivn/_internal/core/orchestrator/__init__.py +18 -0
  129. maivn/_internal/core/orchestrator/builder.py +169 -0
  130. maivn/_internal/core/orchestrator/core.py +480 -0
  131. maivn/_internal/core/orchestrator/events/__init__.py +8 -0
  132. maivn/_internal/core/orchestrator/events/consumption.py +221 -0
  133. maivn/_internal/core/orchestrator/events/reporter_hooks.py +227 -0
  134. maivn/_internal/core/orchestrator/execution.py +326 -0
  135. maivn/_internal/core/orchestrator/helpers.py +83 -0
  136. maivn/_internal/core/orchestrator/initialization.py +267 -0
  137. maivn/_internal/core/orchestrator/reporter_hooks.py +216 -0
  138. maivn/_internal/core/orchestrator/tooling.py +151 -0
  139. maivn/_internal/core/registrars/__init__.py +16 -0
  140. maivn/_internal/core/registrars/register_agent.py +55 -0
  141. maivn/_internal/core/registrars/register_dependency.py +31 -0
  142. maivn/_internal/core/registrars/register_tools.py +64 -0
  143. maivn/_internal/core/resolvers/__init__.py +11 -0
  144. maivn/_internal/core/resolvers/noop_resolver.py +28 -0
  145. maivn/_internal/core/services/__init__.py +54 -0
  146. maivn/_internal/core/services/agent_execution_service.py +322 -0
  147. maivn/_internal/core/services/dependency_collector.py +174 -0
  148. maivn/_internal/core/services/dependency_execution_service.py +327 -0
  149. maivn/_internal/core/services/interrupt_service.py +384 -0
  150. maivn/_internal/core/services/team_dependencies.py +363 -0
  151. maivn/_internal/core/services/toolify/__init__.py +10 -0
  152. maivn/_internal/core/services/toolify/policies.py +306 -0
  153. maivn/_internal/core/services/toolify/service.py +253 -0
  154. maivn/_internal/core/tool_specs/__init__.py +27 -0
  155. maivn/_internal/core/tool_specs/dependency_detector.py +169 -0
  156. maivn/_internal/core/tool_specs/dependency_extractor.py +150 -0
  157. maivn/_internal/core/tool_specs/factory.py +250 -0
  158. maivn/_internal/core/tool_specs/flattener.py +357 -0
  159. maivn/_internal/core/tool_specs/model_discovery.py +79 -0
  160. maivn/_internal/core/tool_specs/schema_builder.py +353 -0
  161. maivn/_internal/core/tool_specs/schema_processors.py +133 -0
  162. maivn/_internal/core/tool_specs/type_utils.py +188 -0
  163. maivn/_internal/core/utils/__init__.py +13 -0
  164. maivn/_internal/core/utils/dependency_utils.py +154 -0
  165. maivn/_internal/core/utils/logger.py +72 -0
  166. maivn/_internal/utils/__init__.py +26 -0
  167. maivn/_internal/utils/configuration/__init__.py +40 -0
  168. maivn/_internal/utils/configuration/config_builder.py +142 -0
  169. maivn/_internal/utils/configuration/config_store.py +72 -0
  170. maivn/_internal/utils/configuration/environment_config.py +402 -0
  171. maivn/_internal/utils/decorators.py +500 -0
  172. maivn/_internal/utils/env_parsing.py +96 -0
  173. maivn/_internal/utils/infrastructure_init.py +25 -0
  174. maivn/_internal/utils/logging/__init__.py +20 -0
  175. maivn/_internal/utils/logging/sdk_logger.py +216 -0
  176. maivn/_internal/utils/reporting/__init__.py +30 -0
  177. maivn/_internal/utils/reporting/app_event_payloads/__init__.py +39 -0
  178. maivn/_internal/utils/reporting/app_event_payloads/assistant_events.py +165 -0
  179. maivn/_internal/utils/reporting/app_event_payloads/common.py +92 -0
  180. maivn/_internal/utils/reporting/app_event_payloads/lifecycle_events.py +131 -0
  181. maivn/_internal/utils/reporting/app_event_payloads/tool_events.py +149 -0
  182. maivn/_internal/utils/reporting/context.py +89 -0
  183. maivn/_internal/utils/reporting/terminal_reporter/__init__.py +24 -0
  184. maivn/_internal/utils/reporting/terminal_reporter/_components.py +271 -0
  185. maivn/_internal/utils/reporting/terminal_reporter/_formatters.py +247 -0
  186. maivn/_internal/utils/reporting/terminal_reporter/base/__init__.py +7 -0
  187. maivn/_internal/utils/reporting/terminal_reporter/base/defaults.py +126 -0
  188. maivn/_internal/utils/reporting/terminal_reporter/base/interface.py +147 -0
  189. maivn/_internal/utils/reporting/terminal_reporter/base/reporter.py +13 -0
  190. maivn/_internal/utils/reporting/terminal_reporter/config.py +182 -0
  191. maivn/_internal/utils/reporting/terminal_reporter/event_categories.py +204 -0
  192. maivn/_internal/utils/reporting/terminal_reporter/event_router/__init__.py +7 -0
  193. maivn/_internal/utils/reporting/terminal_reporter/event_router/display.py +136 -0
  194. maivn/_internal/utils/reporting/terminal_reporter/event_router/reporter.py +109 -0
  195. maivn/_internal/utils/reporting/terminal_reporter/event_router/session.py +40 -0
  196. maivn/_internal/utils/reporting/terminal_reporter/event_router/system.py +134 -0
  197. maivn/_internal/utils/reporting/terminal_reporter/event_router/tools.py +183 -0
  198. maivn/_internal/utils/reporting/terminal_reporter/factory.py +51 -0
  199. maivn/_internal/utils/reporting/terminal_reporter/reporters/__init__.py +8 -0
  200. maivn/_internal/utils/reporting/terminal_reporter/reporters/reporter_base.py +268 -0
  201. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/__init__.py +9 -0
  202. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/assistant_streaming.py +126 -0
  203. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/display.py +314 -0
  204. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/display_methods.py +83 -0
  205. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/progress.py +141 -0
  206. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/progress_methods.py +82 -0
  207. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/reporter.py +57 -0
  208. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/reporting.py +298 -0
  209. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/session_methods.py +36 -0
  210. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/stream_state.py +80 -0
  211. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/streaming_handler.py +260 -0
  212. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/streaming_panel.py +107 -0
  213. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/streaming_progress.py +92 -0
  214. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/terminal_setup.py +153 -0
  215. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/tool_children.py +185 -0
  216. maivn/_internal/utils/reporting/terminal_reporter/reporters/rich_reporter/tool_methods.py +210 -0
  217. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/__init__.py +9 -0
  218. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/assistant_streaming.py +67 -0
  219. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/display_helpers.py +255 -0
  220. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/display_methods.py +153 -0
  221. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/progress_methods.py +142 -0
  222. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/progress_state.py +55 -0
  223. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/reporter.py +48 -0
  224. maivn/_internal/utils/reporting/terminal_reporter/reporters/simple_reporter/session_methods.py +116 -0
  225. maivn/cli.py +80 -0
  226. maivn/constants.py +39 -0
  227. maivn/events/__init__.py +153 -0
  228. maivn/events/_bridge/__init__.py +38 -0
  229. maivn/events/_bridge/bridge.py +479 -0
  230. maivn/events/_bridge/dedup.py +51 -0
  231. maivn/events/_bridge/emitters.py +229 -0
  232. maivn/events/_bridge/queueing.py +57 -0
  233. maivn/events/_bridge/registry.py +47 -0
  234. maivn/events/_bridge/runtime/__init__.py +7 -0
  235. maivn/events/_bridge/runtime/helpers.py +70 -0
  236. maivn/events/_bridge/runtime/identity.py +271 -0
  237. maivn/events/_bridge/runtime/normalization.py +320 -0
  238. maivn/events/_bridge/schema.py +143 -0
  239. maivn/events/_bridge/security.py +331 -0
  240. maivn/events/_bridge/serialization.py +126 -0
  241. maivn/events/_bridge/streaming.py +194 -0
  242. maivn/events/_bridge/ui_event.py +59 -0
  243. maivn/events/_forward.py +57 -0
  244. maivn/events/_forwarding/__init__.py +13 -0
  245. maivn/events/_forwarding/bridge.py +413 -0
  246. maivn/events/_forwarding/payload.py +145 -0
  247. maivn/events/_forwarding/reporter.py +516 -0
  248. maivn/events/_forwarding/state.py +64 -0
  249. maivn/events/_models.py +179 -0
  250. maivn/events/_normalize/__init__.py +10 -0
  251. maivn/events/_normalize/assistant_events.py +108 -0
  252. maivn/events/_normalize/context.py +27 -0
  253. maivn/events/_normalize/handlers.py +59 -0
  254. maivn/events/_normalize/helpers.py +77 -0
  255. maivn/events/_normalize/lifecycle_events.py +157 -0
  256. maivn/events/_normalize/stream.py +80 -0
  257. maivn/events/_normalize/system_events.py +108 -0
  258. maivn/events/_normalize/tool_events.py +114 -0
  259. maivn/events/_normalize/tooling.py +113 -0
  260. maivn/events/fastapi.py +267 -0
  261. maivn/logging.py +23 -0
  262. maivn/messages/__init__.py +23 -0
  263. maivn/py.typed +0 -0
  264. maivn-0.2.0.dist-info/METADATA +456 -0
  265. maivn-0.2.0.dist-info/RECORD +269 -0
  266. maivn-0.2.0.dist-info/WHEEL +4 -0
  267. maivn-0.2.0.dist-info/entry_points.txt +2 -0
  268. maivn-0.2.0.dist-info/licenses/LICENSE +191 -0
  269. maivn-0.2.0.dist-info/licenses/NOTICE +16 -0
maivn/__init__.py ADDED
@@ -0,0 +1,265 @@
1
+ """Top-level SDK exports for Maivn.
2
+ Re-exports clients, agents, decorators, logging, and configuration.
3
+ Configuration mutation helpers are intentionally not exported to avoid external rewiring.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ # MARK: - Shared Models
9
+ from maivn_shared import (
10
+ HIPAA_SAFE_HARBOR_CATEGORIES,
11
+ MemoryAssetsConfig,
12
+ MemoryConfig,
13
+ MemoryInsightExtractionConfig,
14
+ MemoryLevel,
15
+ MemoryPersistenceMode,
16
+ MemoryResourceConfig,
17
+ MemoryRetrievalConfig,
18
+ MemorySharingScope,
19
+ MemorySkillConfig,
20
+ MemorySkillExtractionConfig,
21
+ PIIWhitelist,
22
+ PIIWhitelistEntry,
23
+ PrivateData,
24
+ RedactedMessage,
25
+ RedactionPreviewRequest,
26
+ RedactionPreviewResponse,
27
+ SessionExecutionConfig,
28
+ SessionOrchestrationConfig,
29
+ StructuredOutputConfig,
30
+ SwarmAgentConfig,
31
+ SwarmConfig,
32
+ SystemToolsConfig,
33
+ )
34
+
35
+ # MARK: - Version
36
+ from .__version__ import __version__
37
+
38
+ # MARK: - Core Classes
39
+ from ._internal.api import (
40
+ Agent,
41
+ BaseScope,
42
+ Client,
43
+ ClientBuilder,
44
+ MCPAutoSetup,
45
+ MCPServer,
46
+ MCPSoftErrorHandling,
47
+ Swarm,
48
+ )
49
+ from ._internal.api.resource_models import (
50
+ MemoryInsight,
51
+ MemoryInsightOrigin,
52
+ MemoryInsightType,
53
+ MemoryPersistenceCeiling,
54
+ MemoryResource,
55
+ MemoryResourceBindingType,
56
+ MemoryResourceDetail,
57
+ MemoryResourceStatus,
58
+ MemorySkill,
59
+ MemorySkillOrigin,
60
+ MemorySkillStatus,
61
+ MemoryUnboundResourceCandidate,
62
+ OrganizationMemoryPolicy,
63
+ OrganizationMemoryPurgeResult,
64
+ ProjectMemoryResources,
65
+ )
66
+
67
+ # MARK: - Scheduling
68
+ from ._internal.api.scheduling import (
69
+ AtSchedule,
70
+ CronInvocationBuilder,
71
+ CronSchedule,
72
+ IntervalSchedule,
73
+ JitterDistribution,
74
+ JitterSpec,
75
+ MisfirePolicy,
76
+ OverlapPolicy,
77
+ Retry,
78
+ RetryBackoff,
79
+ RunRecord,
80
+ RunStatus,
81
+ Schedule,
82
+ ScheduledJob,
83
+ list_jobs,
84
+ stop_all_jobs,
85
+ )
86
+
87
+ # MARK: - Interrupts
88
+ from ._internal.core.services.interrupt_service import (
89
+ default_terminal_interrupt,
90
+ get_interrupt_service,
91
+ set_interrupt_service,
92
+ )
93
+
94
+ # MARK: - Decorators
95
+ from ._internal.utils import (
96
+ compose_artifact_policy,
97
+ depends_on_agent,
98
+ depends_on_await_for,
99
+ depends_on_interrupt,
100
+ depends_on_private_data,
101
+ depends_on_reevaluate,
102
+ depends_on_tool,
103
+ )
104
+
105
+ # MARK: - Configuration
106
+ from ._internal.utils.configuration import (
107
+ ConfigurationBuilder,
108
+ MaivnConfiguration,
109
+ get_configuration,
110
+ )
111
+
112
+ # MARK: - Logging
113
+ # Logging must be importable before other modules to allow early configuration
114
+ from ._internal.utils.logging import (
115
+ configure_logging,
116
+ get_logger,
117
+ )
118
+ from .events import (
119
+ APP_EVENT_CONTRACT_VERSION,
120
+ AppEvent,
121
+ BackpressurePolicy,
122
+ BridgeAudience,
123
+ BridgeRegistry,
124
+ EventBridge,
125
+ EventBridgeSecurityPolicy,
126
+ NormalizedEventForwardingState,
127
+ NormalizedStreamState,
128
+ RawSSEEvent,
129
+ UIEvent,
130
+ build_agent_assignment_payload,
131
+ build_assistant_chunk_payload,
132
+ build_enrichment_payload,
133
+ build_error_payload,
134
+ build_final_payload,
135
+ build_interrupt_required_payload,
136
+ build_session_start_payload,
137
+ build_status_message_payload,
138
+ build_system_tool_chunk_payload,
139
+ build_system_tool_complete_payload,
140
+ build_system_tool_start_payload,
141
+ build_tool_event_payload,
142
+ forward_normalized_event,
143
+ forward_normalized_stream,
144
+ normalize_stream,
145
+ normalize_stream_event,
146
+ )
147
+
148
+ # MARK: - Public API
149
+
150
+ __all__ = [
151
+ # Version
152
+ "__version__",
153
+ # Logging
154
+ "configure_logging",
155
+ "get_logger",
156
+ # Event Contract
157
+ "APP_EVENT_CONTRACT_VERSION",
158
+ "AppEvent",
159
+ "BackpressurePolicy",
160
+ "BridgeAudience",
161
+ "BridgeRegistry",
162
+ "EventBridge",
163
+ "EventBridgeSecurityPolicy",
164
+ "NormalizedEventForwardingState",
165
+ "NormalizedStreamState",
166
+ "RawSSEEvent",
167
+ "UIEvent",
168
+ "build_agent_assignment_payload",
169
+ "build_assistant_chunk_payload",
170
+ "build_enrichment_payload",
171
+ "build_error_payload",
172
+ "build_final_payload",
173
+ "build_interrupt_required_payload",
174
+ "build_session_start_payload",
175
+ "build_status_message_payload",
176
+ "build_system_tool_chunk_payload",
177
+ "build_system_tool_complete_payload",
178
+ "build_system_tool_start_payload",
179
+ "build_tool_event_payload",
180
+ "forward_normalized_event",
181
+ "forward_normalized_stream",
182
+ "normalize_stream",
183
+ "normalize_stream_event",
184
+ # Decorators
185
+ "compose_artifact_policy",
186
+ "depends_on_agent",
187
+ "depends_on_await_for",
188
+ "depends_on_private_data",
189
+ "depends_on_interrupt",
190
+ "depends_on_reevaluate",
191
+ "depends_on_tool",
192
+ # Core Classes
193
+ "Agent",
194
+ "BaseScope",
195
+ "Client",
196
+ "ClientBuilder",
197
+ "MCPAutoSetup",
198
+ "MCPServer",
199
+ "MCPSoftErrorHandling",
200
+ "Swarm",
201
+ "OrganizationMemoryPolicy",
202
+ "OrganizationMemoryPurgeResult",
203
+ "MemoryPersistenceCeiling",
204
+ "MemoryResource",
205
+ "MemoryResourceDetail",
206
+ "MemoryResourceBindingType",
207
+ "MemoryResourceStatus",
208
+ "MemorySkill",
209
+ "MemorySkillOrigin",
210
+ "MemorySkillStatus",
211
+ "MemoryInsight",
212
+ "MemoryInsightType",
213
+ "MemoryInsightOrigin",
214
+ "MemoryUnboundResourceCandidate",
215
+ "ProjectMemoryResources",
216
+ # Shared Models
217
+ "HIPAA_SAFE_HARBOR_CATEGORIES",
218
+ "PIIWhitelist",
219
+ "PIIWhitelistEntry",
220
+ "PrivateData",
221
+ "MemoryConfig",
222
+ "MemoryAssetsConfig",
223
+ "MemoryInsightExtractionConfig",
224
+ "MemoryLevel",
225
+ "MemoryPersistenceMode",
226
+ "MemoryResourceConfig",
227
+ "MemoryRetrievalConfig",
228
+ "MemorySharingScope",
229
+ "MemorySkillConfig",
230
+ "MemorySkillExtractionConfig",
231
+ "SessionExecutionConfig",
232
+ "SessionOrchestrationConfig",
233
+ "StructuredOutputConfig",
234
+ "SwarmAgentConfig",
235
+ "SwarmConfig",
236
+ "SystemToolsConfig",
237
+ "RedactedMessage",
238
+ "RedactionPreviewRequest",
239
+ "RedactionPreviewResponse",
240
+ # Configuration
241
+ "ConfigurationBuilder",
242
+ "MaivnConfiguration",
243
+ "get_configuration",
244
+ # Interrupts
245
+ "default_terminal_interrupt",
246
+ "get_interrupt_service",
247
+ "set_interrupt_service",
248
+ # Scheduling
249
+ "AtSchedule",
250
+ "CronInvocationBuilder",
251
+ "CronSchedule",
252
+ "IntervalSchedule",
253
+ "JitterDistribution",
254
+ "JitterSpec",
255
+ "MisfirePolicy",
256
+ "OverlapPolicy",
257
+ "Retry",
258
+ "RetryBackoff",
259
+ "RunRecord",
260
+ "RunStatus",
261
+ "Schedule",
262
+ "ScheduledJob",
263
+ "list_jobs",
264
+ "stop_all_jobs",
265
+ ]
maivn/__version__.py ADDED
@@ -0,0 +1,10 @@
1
+ """Package version for the maivn SDK.
2
+ Exposed via ``maivn.__version__`` for tooling and client diagnostics.
3
+ """
4
+
5
+ # MARK: Version
6
+ from __future__ import annotations
7
+
8
+ __all__ = ["__version__"]
9
+
10
+ __version__ = "0.2.0"
@@ -0,0 +1 @@
1
+ """Internal Adapters Package Exports."""
@@ -0,0 +1,17 @@
1
+ """Networking infrastructure.
2
+ Provides HTTP and SSE client implementations for orchestrator communication.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ # MARK: - Imports
8
+ from .http_client import HttpClient, HttpError
9
+ from .sse_client import StreamingSSEClient
10
+
11
+ # MARK: - Exports
12
+
13
+ __all__ = [
14
+ "HttpClient",
15
+ "HttpError",
16
+ "StreamingSSEClient",
17
+ ]
@@ -0,0 +1,41 @@
1
+ """HTTP client wrapper using maivn-core shared implementation.
2
+
3
+ This module provides the HTTP client implementation using the shared
4
+ maivn-core HttpClient for consistent behavior across services.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from maivn_shared import HttpClient as CoreHttpClient
10
+ from maivn_shared import HttpError
11
+
12
+ from maivn._internal.utils.configuration import get_configuration
13
+
14
+ # MARK: - HttpClient
15
+
16
+
17
+ class HttpClient(CoreHttpClient):
18
+ """HTTP client implementation using maivn-core shared client.
19
+
20
+ This class extends the core HttpClient with SDK-specific configuration.
21
+ """
22
+
23
+ # MARK: - Initialization
24
+
25
+ def __init__(self, *, timeout: float | None = None) -> None:
26
+ """Initialize the HTTP client with SDK configuration.
27
+
28
+ Args:
29
+ timeout: Default timeout for requests
30
+ """
31
+ config = get_configuration()
32
+ sdk_timeout = timeout if timeout is not None else config.server.timeout_seconds
33
+ super().__init__(timeout=sdk_timeout)
34
+
35
+
36
+ # MARK: - Exports
37
+
38
+ __all__ = [
39
+ "HttpClient",
40
+ "HttpError",
41
+ ]
@@ -0,0 +1,153 @@
1
+ """Server-Sent Events (SSE) client implementation.
2
+
3
+ This module provides a production-ready SSE client using urllib for HTTP streaming.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Iterator
9
+ from typing import IO, cast
10
+
11
+ from maivn_shared import loads
12
+
13
+ from maivn._internal.core import SSEClient, SSEEvent
14
+
15
+ # MARK: - StreamingSSEClient
16
+
17
+
18
+ class StreamingSSEClient(SSEClient):
19
+ """urllib-based SSE client for production use.
20
+
21
+ This client implements the SSE protocol for consuming server-sent event streams
22
+ over HTTP. It handles event parsing and yields structured SSEEvent objects.
23
+ """
24
+
25
+ # MARK: - Initialization
26
+
27
+ def __init__(self, *, timeout: float = 600.0) -> None:
28
+ """Initialize the SSE client.
29
+
30
+ Args:
31
+ timeout: Request timeout in seconds (default: 600.0)
32
+ """
33
+ self._timeout = timeout
34
+
35
+ # MARK: - Public Methods
36
+
37
+ def iter_events(
38
+ self,
39
+ url: str,
40
+ *,
41
+ headers: dict[str, str] | None = None,
42
+ ) -> Iterator[SSEEvent]:
43
+ """Iterate over server-sent events from the given URL.
44
+
45
+ Args:
46
+ url: The SSE endpoint URL to connect to
47
+ headers: Optional HTTP headers to include with the SSE request
48
+
49
+ Yields:
50
+ SSEEvent objects parsed from the event stream
51
+
52
+ Raises:
53
+ URLError: If the connection fails
54
+ TimeoutError: If the request times out
55
+ """
56
+ from urllib.request import Request, urlopen
57
+
58
+ self._validate_stream_url(url)
59
+ merged_headers: dict[str, str] = {}
60
+ if headers:
61
+ merged_headers = {
62
+ key: value for key, value in headers.items() if key.lower() != "accept"
63
+ }
64
+ merged_headers["Accept"] = "text/event-stream"
65
+ req = Request(url, headers=merged_headers)
66
+ try:
67
+ # _validate_stream_url rejects file: and custom schemes before urlopen.
68
+ with cast(
69
+ IO[bytes],
70
+ urlopen(req, timeout=self._timeout), # noqa: S310 # nosec B310
71
+ ) as resp:
72
+ buf = b""
73
+ while True:
74
+ chunk = resp.readline()
75
+ if not chunk:
76
+ raise RuntimeError(
77
+ "SSE stream closed unexpectedly. The server may have stopped, "
78
+ "the connection may have been interrupted, "
79
+ "or the session may have ended."
80
+ )
81
+ buf += chunk
82
+ if self._is_event_complete(buf):
83
+ yield self._parse_event(buf)
84
+ buf = b""
85
+ except Exception as exc: # noqa: BLE001
86
+ raise RuntimeError(
87
+ "Failed to read SSE event stream. The server may be unreachable "
88
+ "or closed the connection."
89
+ ) from exc
90
+
91
+ # MARK: - Private Methods
92
+
93
+ @staticmethod
94
+ def _validate_stream_url(url: str) -> None:
95
+ """Reject local-file and custom-scheme URLs before urllib opens them."""
96
+ from urllib.parse import urlsplit
97
+
98
+ parsed = urlsplit(url)
99
+ if parsed.scheme not in {"http", "https"} or not parsed.netloc:
100
+ raise ValueError("SSE stream URL must be an absolute http:// or https:// URL")
101
+
102
+ def _is_event_complete(self, buf: bytes) -> bool:
103
+ """Check if the buffer contains a complete SSE event.
104
+
105
+ Args:
106
+ buf: The accumulated byte buffer
107
+
108
+ Returns:
109
+ True if the buffer ends with a double newline delimiter
110
+ """
111
+ return buf.endswith(b"\n\n") or buf.endswith(b"\r\n\r\n")
112
+
113
+ def _parse_event(self, buf: bytes) -> SSEEvent:
114
+ """Parse a complete SSE event from the buffer.
115
+
116
+ Args:
117
+ buf: The byte buffer containing a complete event
118
+
119
+ Returns:
120
+ Parsed SSEEvent object
121
+ """
122
+ lines = buf.decode("utf-8", errors="replace").splitlines()
123
+ event_name = "message"
124
+ data_lines: list[str] = []
125
+
126
+ for line in lines:
127
+ if line.startswith("event:"):
128
+ event_name = line.split(":", 1)[1].strip()
129
+ elif line.startswith("data:"):
130
+ data_lines.append(line.split(":", 1)[1].strip())
131
+
132
+ data = "\n".join(data_lines) if data_lines else "{}"
133
+ payload = self._parse_payload(data)
134
+ return SSEEvent(name=event_name, payload=payload)
135
+
136
+ def _parse_payload(self, data: str) -> dict:
137
+ """Parse the event data payload as JSON.
138
+
139
+ Args:
140
+ data: The raw data string from the event
141
+
142
+ Returns:
143
+ Parsed dictionary or fallback with raw data
144
+ """
145
+ if not data:
146
+ return {}
147
+ try:
148
+ return loads(data)
149
+ except Exception:
150
+ return {"raw": data}
151
+
152
+
153
+ __all__ = ["StreamingSSEClient"]
@@ -0,0 +1,22 @@
1
+ """Infrastructure repository implementations.
2
+ Provides in-memory repositories for agents, tools, and dependencies.
3
+ Used as default wiring for scopes and orchestration.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ # MARK: Repository Exports
9
+ # MARK: - Agent Repository
10
+ from .agent_repo import AgentRepo
11
+
12
+ # MARK: - Dependency Repository
13
+ from .dependency_repo import DependencyRepo
14
+
15
+ # MARK: - Tool Repository
16
+ from .tool_repo import ToolRepo
17
+
18
+ __all__ = [
19
+ "AgentRepo",
20
+ "DependencyRepo",
21
+ "ToolRepo",
22
+ ]
@@ -0,0 +1,73 @@
1
+ """In-memory agent repository implementation.
2
+ Stores agents by id and maintains a secondary name index for lookup.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ # MARK: In-Memory Agent Repository
8
+ from typing import TYPE_CHECKING
9
+
10
+ from maivn._internal.core.interfaces.repositories import AgentRepoInterface
11
+
12
+ if TYPE_CHECKING:
13
+ from maivn._internal.api.agent import Agent
14
+
15
+
16
+ class AgentRepo(AgentRepoInterface):
17
+ """In-memory implementation of AgentRepoInterface."""
18
+
19
+ def __init__(self) -> None:
20
+ self.store: dict[str, Agent] = {}
21
+ self._name_index: dict[str, Agent] = {}
22
+
23
+ # MARK: - Private methods
24
+
25
+ def _get_agent_id(self, agent: Agent) -> str | None:
26
+ return getattr(agent, "id", None)
27
+
28
+ def _get_agent_name(self, agent: Agent) -> str | None:
29
+ return getattr(agent, "name", None)
30
+
31
+ def _add_to_name_index(self, agent: Agent) -> None:
32
+ name = self._get_agent_name(agent)
33
+ if name:
34
+ self._name_index[name] = agent
35
+
36
+ def _remove_from_name_index(self, agent: Agent) -> None:
37
+ name = self._get_agent_name(agent)
38
+ if name and name in self._name_index:
39
+ del self._name_index[name]
40
+
41
+ # MARK: - Agent methods
42
+
43
+ def add_agent(self, agent: Agent) -> None:
44
+ if agent is None:
45
+ return
46
+ agent_id = self._get_agent_id(agent)
47
+ if not agent_id or agent_id in self.store:
48
+ return
49
+ self.store[agent_id] = agent
50
+ self._add_to_name_index(agent)
51
+
52
+ def get_agent(self, agent_id: str) -> Agent | None:
53
+ return self.store.get(agent_id)
54
+
55
+ def get_agent_by_name(self, name: str) -> Agent | None:
56
+ return self._name_index.get(name)
57
+
58
+ def list_agents(self) -> list[Agent]:
59
+ return list(self.store.values())
60
+
61
+ def remove_agent(self, agent_id: str) -> None:
62
+ agent = self.store.pop(agent_id, None)
63
+ if agent:
64
+ self._remove_from_name_index(agent)
65
+
66
+ def update_agent(self, agent: Agent) -> None:
67
+ agent_id = self._get_agent_id(agent)
68
+ if not agent_id:
69
+ return
70
+ if agent_id in self.store:
71
+ self._remove_from_name_index(self.store[agent_id])
72
+ self.store[agent_id] = agent
73
+ self._add_to_name_index(agent)
@@ -0,0 +1,91 @@
1
+ """In-memory dependency repository implementation.
2
+ Stores dependency lists keyed by tool id.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ # MARK: In-Memory Dependency Repository
8
+ from maivn_shared import BaseDependency, InterruptDependency, dumps
9
+
10
+ from maivn._internal.core.interfaces.repositories import DependencyRepoInterface
11
+
12
+
13
+ class DependencyRepo(DependencyRepoInterface):
14
+ """In-memory implementation of DependencyRepoInterface."""
15
+
16
+ def __init__(self) -> None:
17
+ self.store: dict[str, list[BaseDependency]] = {}
18
+
19
+ # MARK: - Private Helpers
20
+
21
+ def _get_dependency_id(self, dependency: BaseDependency) -> str | None:
22
+ dep_type = getattr(dependency, "dependency_type", None)
23
+ arg_name = getattr(dependency, "arg_name", None)
24
+
25
+ if isinstance(dependency, InterruptDependency):
26
+ return dumps(
27
+ {
28
+ "dependency_type": dep_type or "user",
29
+ "arg_name": arg_name,
30
+ "prompt": getattr(dependency, "prompt", None),
31
+ }
32
+ )
33
+
34
+ identifier = (
35
+ getattr(dependency, "tool_id", None)
36
+ or getattr(dependency, "agent_id", None)
37
+ or getattr(dependency, "data_key", None)
38
+ or getattr(dependency, "name", None)
39
+ )
40
+ if dep_type or arg_name or identifier:
41
+ return dumps(
42
+ {
43
+ "dependency_type": dep_type,
44
+ "arg_name": arg_name,
45
+ "identifier": str(identifier) if identifier else None,
46
+ }
47
+ )
48
+
49
+ try:
50
+ return dumps(dependency.model_dump(mode="json"))
51
+ except Exception:
52
+ return str(dependency)
53
+
54
+ def _find_dependency_index(self, deps: list[BaseDependency], dependency_id: str) -> int | None:
55
+ for i, dep in enumerate(deps):
56
+ if self._get_dependency_id(dep) == dependency_id:
57
+ return i
58
+ return None
59
+
60
+ # MARK: - Dependency Methods
61
+
62
+ def add_dependency(self, tool_id: str, dependency: BaseDependency) -> None:
63
+ if not tool_id or dependency is None:
64
+ return
65
+ self.store.setdefault(tool_id, []).append(dependency)
66
+
67
+ def get_dependency(self, dependency_id: str) -> BaseDependency | None:
68
+ for deps in self.store.values():
69
+ for dep in deps:
70
+ if self._get_dependency_id(dep) == dependency_id:
71
+ return dep
72
+ return None
73
+
74
+ def list_dependencies(self, tool_id: str) -> list[BaseDependency]:
75
+ return list(self.store.get(tool_id, []))
76
+
77
+ def remove_dependency(self, dependency_id: str) -> None:
78
+ for tool_id, deps in list(self.store.items()):
79
+ idx = self._find_dependency_index(deps, dependency_id)
80
+ if idx is not None:
81
+ deps.pop(idx)
82
+ if not deps:
83
+ del self.store[tool_id]
84
+ return
85
+
86
+ def update_dependency(self, dependency_id: str, dependency: BaseDependency) -> None:
87
+ for deps in self.store.values():
88
+ idx = self._find_dependency_index(deps, dependency_id)
89
+ if idx is not None:
90
+ deps[idx] = dependency
91
+ return