purple-idiot 0.2.0__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.
Files changed (120) hide show
  1. purple_idiot-0.2.0/LICENSE +17 -0
  2. purple_idiot-0.2.0/PKG-INFO +60 -0
  3. purple_idiot-0.2.0/README.md +32 -0
  4. purple_idiot-0.2.0/pyproject.toml +41 -0
  5. purple_idiot-0.2.0/setup.cfg +4 -0
  6. purple_idiot-0.2.0/src/idiot/__init__.py +130 -0
  7. purple_idiot-0.2.0/src/idiot/ai/__init__.py +102 -0
  8. purple_idiot-0.2.0/src/idiot/ai/agent_memory.py +124 -0
  9. purple_idiot-0.2.0/src/idiot/ai/agents.py +476 -0
  10. purple_idiot-0.2.0/src/idiot/ai/contracts.py +362 -0
  11. purple_idiot-0.2.0/src/idiot/ai/document_catalog.py +80 -0
  12. purple_idiot-0.2.0/src/idiot/ai/embeddings.py +169 -0
  13. purple_idiot-0.2.0/src/idiot/ai/memory.py +307 -0
  14. purple_idiot-0.2.0/src/idiot/ai/memory_extraction.py +228 -0
  15. purple_idiot-0.2.0/src/idiot/ai/memory_intelligence.py +279 -0
  16. purple_idiot-0.2.0/src/idiot/ai/memory_review.py +152 -0
  17. purple_idiot-0.2.0/src/idiot/ai/memory_vector_index.py +323 -0
  18. purple_idiot-0.2.0/src/idiot/ai/module.py +21 -0
  19. purple_idiot-0.2.0/src/idiot/ai/namespaced_vector_store.py +188 -0
  20. purple_idiot-0.2.0/src/idiot/ai/orchestration.py +303 -0
  21. purple_idiot-0.2.0/src/idiot/ai/providers/__init__.py +9 -0
  22. purple_idiot-0.2.0/src/idiot/ai/providers/anthropic.py +468 -0
  23. purple_idiot-0.2.0/src/idiot/ai/providers/openai_compatible.py +472 -0
  24. purple_idiot-0.2.0/src/idiot/ai/providers/openai_embeddings.py +154 -0
  25. purple_idiot-0.2.0/src/idiot/ai/rag.py +317 -0
  26. purple_idiot-0.2.0/src/idiot/ai/routing.py +255 -0
  27. purple_idiot-0.2.0/src/idiot/ai/schema_validation.py +190 -0
  28. purple_idiot-0.2.0/src/idiot/ai/service.py +425 -0
  29. purple_idiot-0.2.0/src/idiot/ai/sqlite_memory_review_store.py +558 -0
  30. purple_idiot-0.2.0/src/idiot/ai/sqlite_memory_store.py +373 -0
  31. purple_idiot-0.2.0/src/idiot/ai/sqlite_vector_store.py +412 -0
  32. purple_idiot-0.2.0/src/idiot/ai/vector_store.py +165 -0
  33. purple_idiot-0.2.0/src/idiot/core/__init__.py +18 -0
  34. purple_idiot-0.2.0/src/idiot/core/config.py +27 -0
  35. purple_idiot-0.2.0/src/idiot/core/contracts.py +37 -0
  36. purple_idiot-0.2.0/src/idiot/core/events.py +54 -0
  37. purple_idiot-0.2.0/src/idiot/core/registry.py +113 -0
  38. purple_idiot-0.2.0/src/idiot/core/runtime.py +90 -0
  39. purple_idiot-0.2.0/src/idiot/creative/__init__.py +143 -0
  40. purple_idiot-0.2.0/src/idiot/creative/assets.py +134 -0
  41. purple_idiot-0.2.0/src/idiot/creative/audio_mix.py +168 -0
  42. purple_idiot-0.2.0/src/idiot/creative/continuity.py +238 -0
  43. purple_idiot-0.2.0/src/idiot/creative/ffmpeg_backend.py +517 -0
  44. purple_idiot-0.2.0/src/idiot/creative/models.py +1135 -0
  45. purple_idiot-0.2.0/src/idiot/creative/module.py +22 -0
  46. purple_idiot-0.2.0/src/idiot/creative/otio_adapter.py +529 -0
  47. purple_idiot-0.2.0/src/idiot/creative/production_package.py +432 -0
  48. purple_idiot-0.2.0/src/idiot/creative/render_coordinator.py +416 -0
  49. purple_idiot-0.2.0/src/idiot/creative/rendering.py +249 -0
  50. purple_idiot-0.2.0/src/idiot/creative/resolve_adapter.py +155 -0
  51. purple_idiot-0.2.0/src/idiot/creative/scene_breakdown.py +241 -0
  52. purple_idiot-0.2.0/src/idiot/creative/serialization.py +518 -0
  53. purple_idiot-0.2.0/src/idiot/creative/service.py +451 -0
  54. purple_idiot-0.2.0/src/idiot/creative/storage.py +220 -0
  55. purple_idiot-0.2.0/src/idiot/creative/timeline_validation.py +317 -0
  56. purple_idiot-0.2.0/src/idiot/exceptions.py +190 -0
  57. purple_idiot-0.2.0/src/purple_idiot.egg-info/PKG-INFO +60 -0
  58. purple_idiot-0.2.0/src/purple_idiot.egg-info/SOURCES.txt +118 -0
  59. purple_idiot-0.2.0/src/purple_idiot.egg-info/dependency_links.txt +1 -0
  60. purple_idiot-0.2.0/src/purple_idiot.egg-info/requires.txt +3 -0
  61. purple_idiot-0.2.0/src/purple_idiot.egg-info/top_level.txt +1 -0
  62. purple_idiot-0.2.0/tests/test_agent_memory.py +243 -0
  63. purple_idiot-0.2.0/tests/test_agent_memory_security.py +128 -0
  64. purple_idiot-0.2.0/tests/test_agent_native_tool_calling.py +346 -0
  65. purple_idiot-0.2.0/tests/test_agents.py +199 -0
  66. purple_idiot-0.2.0/tests/test_ai.py +52 -0
  67. purple_idiot-0.2.0/tests/test_ai_contracts.py +56 -0
  68. purple_idiot-0.2.0/tests/test_anthropic_provider_reliability.py +257 -0
  69. purple_idiot-0.2.0/tests/test_anthropic_structured_generation.py +260 -0
  70. purple_idiot-0.2.0/tests/test_anthropic_text_generation.py +241 -0
  71. purple_idiot-0.2.0/tests/test_anthropic_tool_calling.py +326 -0
  72. purple_idiot-0.2.0/tests/test_core.py +158 -0
  73. purple_idiot-0.2.0/tests/test_creative.py +113 -0
  74. purple_idiot-0.2.0/tests/test_creative_asset_lifecycle.py +221 -0
  75. purple_idiot-0.2.0/tests/test_creative_asset_storage.py +97 -0
  76. purple_idiot-0.2.0/tests/test_creative_assets.py +201 -0
  77. purple_idiot-0.2.0/tests/test_creative_audio_mix.py +153 -0
  78. purple_idiot-0.2.0/tests/test_creative_audio_production_integration.py +144 -0
  79. purple_idiot-0.2.0/tests/test_creative_character_relationships.py +239 -0
  80. purple_idiot-0.2.0/tests/test_creative_continuity_facts.py +249 -0
  81. purple_idiot-0.2.0/tests/test_creative_continuity_validation.py +264 -0
  82. purple_idiot-0.2.0/tests/test_creative_ffmpeg_backend.py +382 -0
  83. purple_idiot-0.2.0/tests/test_creative_otio_adapter.py +175 -0
  84. purple_idiot-0.2.0/tests/test_creative_production_integration.py +126 -0
  85. purple_idiot-0.2.0/tests/test_creative_production_package.py +159 -0
  86. purple_idiot-0.2.0/tests/test_creative_render_coordinator.py +363 -0
  87. purple_idiot-0.2.0/tests/test_creative_rendering_contracts.py +173 -0
  88. purple_idiot-0.2.0/tests/test_creative_resolve_adapter.py +171 -0
  89. purple_idiot-0.2.0/tests/test_creative_scene_breakdown.py +355 -0
  90. purple_idiot-0.2.0/tests/test_creative_scene_breakdown_validation.py +111 -0
  91. purple_idiot-0.2.0/tests/test_creative_screenplay_elements.py +291 -0
  92. purple_idiot-0.2.0/tests/test_creative_timeline.py +224 -0
  93. purple_idiot-0.2.0/tests/test_creative_timeline_operations.py +350 -0
  94. purple_idiot-0.2.0/tests/test_creative_timeline_validation.py +146 -0
  95. purple_idiot-0.2.0/tests/test_document_catalog.py +42 -0
  96. purple_idiot-0.2.0/tests/test_embeddings.py +157 -0
  97. purple_idiot-0.2.0/tests/test_hello.py +24 -0
  98. purple_idiot-0.2.0/tests/test_memory_extraction.py +300 -0
  99. purple_idiot-0.2.0/tests/test_memory_intelligence.py +338 -0
  100. purple_idiot-0.2.0/tests/test_memory_retrieval.py +148 -0
  101. purple_idiot-0.2.0/tests/test_memory_review.py +152 -0
  102. purple_idiot-0.2.0/tests/test_memory_vector_index.py +137 -0
  103. purple_idiot-0.2.0/tests/test_memory_vector_index_reliability.py +191 -0
  104. purple_idiot-0.2.0/tests/test_namespaced_vector_store.py +143 -0
  105. purple_idiot-0.2.0/tests/test_native_tool_calling.py +229 -0
  106. purple_idiot-0.2.0/tests/test_openai_compatible.py +170 -0
  107. purple_idiot-0.2.0/tests/test_openai_compatible_embeddings.py +163 -0
  108. purple_idiot-0.2.0/tests/test_openai_compatible_structured.py +220 -0
  109. purple_idiot-0.2.0/tests/test_openai_compatible_tool_calling.py +262 -0
  110. purple_idiot-0.2.0/tests/test_orchestration.py +350 -0
  111. purple_idiot-0.2.0/tests/test_provider_failures.py +75 -0
  112. purple_idiot-0.2.0/tests/test_provider_routing.py +553 -0
  113. purple_idiot-0.2.0/tests/test_public_api.py +35 -0
  114. purple_idiot-0.2.0/tests/test_rag.py +175 -0
  115. purple_idiot-0.2.0/tests/test_rag_document_catalog.py +154 -0
  116. purple_idiot-0.2.0/tests/test_sqlite_memory_review_store.py +497 -0
  117. purple_idiot-0.2.0/tests/test_sqlite_memory_store.py +313 -0
  118. purple_idiot-0.2.0/tests/test_sqlite_vector_store.py +134 -0
  119. purple_idiot-0.2.0/tests/test_structured_output.py +139 -0
  120. purple_idiot-0.2.0/tests/test_vector_store.py +138 -0
@@ -0,0 +1,17 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Purple Idiot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: purple-idiot
3
+ Version: 0.2.0
4
+ Summary: Purple Idiot modular development framework
5
+ Author: Purple Idiot
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/purple-idiot/purpleidiot
8
+ Project-URL: Repository, https://github.com/purple-idiot/purpleidiot
9
+ Project-URL: Documentation, https://github.com/purple-idiot/purpleidiot/tree/main/docs
10
+ Project-URL: Issues, https://github.com/purple-idiot/purpleidiot/issues
11
+ Project-URL: Changelog, https://github.com/purple-idiot/purpleidiot/blob/main/CHANGELOG.md
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: otio
26
+ Requires-Dist: OpenTimelineIO<0.19,>=0.18.1; extra == "otio"
27
+ Dynamic: license-file
28
+
29
+ # Purple Idiot
30
+
31
+ Purple Idiot is a modular development ecosystem designed to make complex technology accessible through simple, consistent interfaces.
32
+
33
+ ## Architecture
34
+
35
+ The framework is Python-first and multi-language by design. Its core provides runtime lifecycle management, module registration and discovery, dependency ordering, shared provider interfaces, configuration, and event delivery.
36
+
37
+ ## Built-in modules
38
+
39
+ - **AI** provides provider-neutral text-generation and embedding contracts, OpenAI-compatible chat and embeddings connectivity, bounded agentic tool orchestration, vector storage contracts with in-memory and persistent SQLite backends, a composable RAG ingestion/retrieval service with persistent document lifecycle tracking when used with SQLite, and owner/workspace-scoped episodic, semantic, and working memory with SQLite persistence.
40
+ - **Creative** provides screenplay structure, character relationships and continuity, scene breakdowns, shot/storyboard planning, a project-scoped media asset catalogue, explicit provider-neutral media storage workflows, and a non-destructive editing timeline with audio gain, pan, fades, mute, and layered clips. Its optional local FFmpeg backend supports synchronized audiovisual export with dialogue, music, ambience, and sound effects. AI-assisted scene drafting remains optional.
41
+
42
+ The AI module supports hosted and local OpenAI-compatible inference endpoints. Agent tools must be explicitly registered by the application. No external model SDK or vector database is required by the core package. SQLite persistence uses Python's standard library; its exact-search backend is designed for local workloads.
43
+
44
+ ## Package
45
+
46
+ The distribution package is `purple-idiot`. The Python import namespace is `idiot`.
47
+
48
+ ## Project status
49
+
50
+ The core runtime, AI foundations, and Creative production workflow are implemented through M34. Creative includes screenplay structure, character continuity, scene/shot/storyboard planning, media asset management, non-destructive video/audio editing, deterministic audio mixing, optional local FFmpeg audiovisual export, OpenTimelineIO interchange, portable production packages, and a manual DaVinci Resolve handoff. Resolve scripting is deliberately deferred; the supported adapter does not launch or control the editor.
51
+
52
+ ## Documentation
53
+
54
+ - [Architecture](docs/architecture.md)
55
+ - [Public API](docs/api.md)
56
+ - [Roadmap](docs/roadmap.md)
57
+
58
+ ## License
59
+
60
+ MIT
@@ -0,0 +1,32 @@
1
+ # Purple Idiot
2
+
3
+ Purple Idiot is a modular development ecosystem designed to make complex technology accessible through simple, consistent interfaces.
4
+
5
+ ## Architecture
6
+
7
+ The framework is Python-first and multi-language by design. Its core provides runtime lifecycle management, module registration and discovery, dependency ordering, shared provider interfaces, configuration, and event delivery.
8
+
9
+ ## Built-in modules
10
+
11
+ - **AI** provides provider-neutral text-generation and embedding contracts, OpenAI-compatible chat and embeddings connectivity, bounded agentic tool orchestration, vector storage contracts with in-memory and persistent SQLite backends, a composable RAG ingestion/retrieval service with persistent document lifecycle tracking when used with SQLite, and owner/workspace-scoped episodic, semantic, and working memory with SQLite persistence.
12
+ - **Creative** provides screenplay structure, character relationships and continuity, scene breakdowns, shot/storyboard planning, a project-scoped media asset catalogue, explicit provider-neutral media storage workflows, and a non-destructive editing timeline with audio gain, pan, fades, mute, and layered clips. Its optional local FFmpeg backend supports synchronized audiovisual export with dialogue, music, ambience, and sound effects. AI-assisted scene drafting remains optional.
13
+
14
+ The AI module supports hosted and local OpenAI-compatible inference endpoints. Agent tools must be explicitly registered by the application. No external model SDK or vector database is required by the core package. SQLite persistence uses Python's standard library; its exact-search backend is designed for local workloads.
15
+
16
+ ## Package
17
+
18
+ The distribution package is `purple-idiot`. The Python import namespace is `idiot`.
19
+
20
+ ## Project status
21
+
22
+ The core runtime, AI foundations, and Creative production workflow are implemented through M34. Creative includes screenplay structure, character continuity, scene/shot/storyboard planning, media asset management, non-destructive video/audio editing, deterministic audio mixing, optional local FFmpeg audiovisual export, OpenTimelineIO interchange, portable production packages, and a manual DaVinci Resolve handoff. Resolve scripting is deliberately deferred; the supported adapter does not launch or control the editor.
23
+
24
+ ## Documentation
25
+
26
+ - [Architecture](docs/architecture.md)
27
+ - [Public API](docs/api.md)
28
+ - [Roadmap](docs/roadmap.md)
29
+
30
+ ## License
31
+
32
+ MIT
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "purple-idiot"
7
+ version = "0.2.0"
8
+ description = "Purple Idiot modular development framework"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "Purple Idiot" }
15
+ ]
16
+ dependencies = []
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Topic :: Software Development :: Libraries",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/purple-idiot/purpleidiot"
32
+ Repository = "https://github.com/purple-idiot/purpleidiot"
33
+ Documentation = "https://github.com/purple-idiot/purpleidiot/tree/main/docs"
34
+ Issues = "https://github.com/purple-idiot/purpleidiot/issues"
35
+ Changelog = "https://github.com/purple-idiot/purpleidiot/blob/main/CHANGELOG.md"
36
+
37
+ [project.optional-dependencies]
38
+ otio = ["OpenTimelineIO>=0.18.1,<0.19"]
39
+
40
+ [tool.setuptools.packages.find]
41
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,130 @@
1
+ """Purple Idiot public package interface."""
2
+
3
+ __version__ = "0.2.0"
4
+
5
+ from .core import (
6
+ Event,
7
+ EventBus,
8
+ Module,
9
+ ModuleMetadata,
10
+ ModuleRegistry,
11
+ Provider,
12
+ ProviderRegistry,
13
+ Runtime,
14
+ RuntimeConfig,
15
+ )
16
+ from .core.runtime import RuntimeState
17
+ from .exceptions import (
18
+ AgentError,
19
+ AssetStorageAlreadyExistsError,
20
+ AssetStorageError,
21
+ AssetStorageKeyError,
22
+ AssetStorageNotFoundError,
23
+ AgentProtocolError,
24
+ AgentStepLimitError,
25
+ AgentToolError,
26
+ CircularModuleDependencyError,
27
+ DuplicateModuleError,
28
+ DuplicateProviderError,
29
+ MissingModuleDependencyError,
30
+ ModuleNotFoundError,
31
+ ProviderCapabilityError,
32
+ ProviderCircuitOpenError,
33
+ ProviderNotConfiguredError,
34
+ ProviderNotFoundError,
35
+ ProviderRequestError,
36
+ ProviderFailureError,
37
+ ProviderAuthenticationError,
38
+ ProviderInvalidRequestError,
39
+ ProviderRateLimitError,
40
+ ProviderTimeoutError,
41
+ ProviderTransportError,
42
+ ProviderUnavailableError,
43
+ ProviderMalformedResponseError,
44
+ ProviderRouteError,
45
+ StructuredOutputError,
46
+ StructuredOutputValidationError,
47
+ ToolCallingProtocolError,
48
+ PurpleIdiotError,
49
+ RuntimeErrorBase,
50
+ RuntimeShutdownError,
51
+ RuntimeStartError,
52
+ RuntimeStateError,
53
+ RenderError,
54
+ RenderSubmissionError,
55
+ RenderLifecycleError,
56
+ RenderJobNotFoundError,
57
+ )
58
+
59
+
60
+ def create(name="purple-idiot", *, config=None, include_builtins=True):
61
+ runtime = Runtime(name=name, config=config)
62
+ if include_builtins:
63
+ from .ai import AIModule
64
+ from .creative import CreativeModule
65
+
66
+ runtime.register_module(AIModule())
67
+ runtime.register_module(CreativeModule())
68
+ return runtime
69
+
70
+
71
+ def hello():
72
+ message = "Hello World!\nWelcome to Purple Idiot."
73
+ print(message)
74
+ return message
75
+
76
+
77
+ __all__ = [
78
+ "AgentError",
79
+ "AssetStorageAlreadyExistsError",
80
+ "AssetStorageError",
81
+ "AssetStorageKeyError",
82
+ "AssetStorageNotFoundError",
83
+ "AgentProtocolError",
84
+ "AgentStepLimitError",
85
+ "AgentToolError",
86
+ "CircularModuleDependencyError",
87
+ "DuplicateModuleError",
88
+ "DuplicateProviderError",
89
+ "Event",
90
+ "EventBus",
91
+ "MissingModuleDependencyError",
92
+ "Module",
93
+ "ModuleMetadata",
94
+ "ModuleNotFoundError",
95
+ "ModuleRegistry",
96
+ "Provider",
97
+ "ProviderCapabilityError",
98
+ "ProviderCircuitOpenError",
99
+ "ProviderNotConfiguredError",
100
+ "ProviderNotFoundError",
101
+ "ProviderRegistry",
102
+ "ProviderRequestError",
103
+ "ProviderFailureError",
104
+ "ProviderAuthenticationError",
105
+ "ProviderInvalidRequestError",
106
+ "ProviderRateLimitError",
107
+ "ProviderTimeoutError",
108
+ "ProviderTransportError",
109
+ "ProviderUnavailableError",
110
+ "ProviderMalformedResponseError",
111
+ "ProviderRouteError",
112
+ "StructuredOutputError",
113
+ "StructuredOutputValidationError",
114
+ "ToolCallingProtocolError",
115
+ "PurpleIdiotError",
116
+ "Runtime",
117
+ "RuntimeConfig",
118
+ "RuntimeErrorBase",
119
+ "RuntimeShutdownError",
120
+ "RuntimeStartError",
121
+ "RuntimeState",
122
+ "RuntimeStateError",
123
+ "RenderError",
124
+ "RenderSubmissionError",
125
+ "RenderLifecycleError",
126
+ "RenderJobNotFoundError",
127
+ "__version__",
128
+ "create",
129
+ "hello",
130
+ ]
@@ -0,0 +1,102 @@
1
+ from ..exceptions import (
2
+ AgentProtocolError, AgentStepLimitError, AgentToolError, ToolCallingProtocolError,
3
+ ProviderRouteError, ProviderFailureError, ProviderCircuitOpenError, ProviderAuthenticationError,
4
+ ProviderInvalidRequestError, ProviderRateLimitError, ProviderTimeoutError,
5
+ ProviderTransportError, ProviderUnavailableError, ProviderMalformedResponseError,
6
+ )
7
+ from .agents import Agent, AgentResult, AgentStep, Tool, ToolRegistry
8
+ from .orchestration import (
9
+ AgentOrchestrator,
10
+ AgentRegistry,
11
+ OrchestrationExecutionError,
12
+ OrchestrationPlan,
13
+ OrchestrationPlanError,
14
+ OrchestrationResult,
15
+ OrchestrationTask,
16
+ OrchestrationTaskResult,
17
+ validate_plan,
18
+ )
19
+ from .agent_memory import AgentMemory
20
+ from .contracts import (
21
+ StructuredGenerationRequest,
22
+ StructuredGenerationResponse,
23
+ StructuredOutputProvider,
24
+ StructuredOutputValidator,
25
+ ToolCall,
26
+ ToolCallingMessage,
27
+ ToolCallingProvider,
28
+ ToolCallingRequest,
29
+ ToolCallingResponse,
30
+ ToolDefinition,
31
+ TextGenerationProvider,
32
+ TextGenerationRequest,
33
+ TextGenerationResponse,
34
+ )
35
+ from .document_catalog import DocumentCatalog, DocumentCatalogEntry
36
+ from .embeddings import EmbeddingProvider, EmbeddingRequest, EmbeddingResponse, EmbeddingService
37
+ from .module import AIModule
38
+ from .memory_vector_index import MemoryRetrievalResult, MemoryVectorIndex
39
+ from .memory import (
40
+ MEMORY_KINDS,
41
+ MemoryEntry,
42
+ MemoryService,
43
+ MemorySnapshotChangedError,
44
+ MemoryStore,
45
+ )
46
+ from .memory_intelligence import (
47
+ DECISION_ACTIONS,
48
+ MEMORY_SENSITIVITIES,
49
+ MemoryAssessment,
50
+ MemoryCandidate,
51
+ MemoryCandidateExtractor,
52
+ MemoryDecision,
53
+ MemoryIntelligence,
54
+ )
55
+ from .memory_extraction import (
56
+ MemoryExtractionResult,
57
+ MemoryExtractionService,
58
+ ModelBackedMemoryCandidateExtractor,
59
+ )
60
+ from .memory_review import MemoryReviewItem, MemoryReviewService
61
+ from .sqlite_memory_review_store import (
62
+ MemoryReviewEvent,
63
+ MemoryReviewRecord,
64
+ SQLiteMemoryReviewStore,
65
+ )
66
+ from .sqlite_memory_store import SQLiteMemoryStore
67
+ from .providers import AnthropicProvider, OpenAICompatibleEmbeddingProvider, OpenAICompatibleProvider
68
+ from .rag import Document, DocumentChunk, GroundedAnswer, IngestionResult, RAGService, TextChunker
69
+ from .schema_validation import BuiltinJSONSchemaValidator
70
+ from .routing import CircuitBreakerPolicy, ProviderFailureKind, ProviderLifecycleEvent, ProviderOperation, ProviderRoute, ProviderRouter, RetryPolicy, classify_provider_failure
71
+ from .service import AIService
72
+ from .vector_store import InMemoryVectorStore, VectorRecord, VectorSearchResult, VectorStore
73
+ from .sqlite_vector_store import SQLiteVectorStore
74
+ from .namespaced_vector_store import NamespacedVectorStore
75
+
76
+ __all__ = [
77
+ "AIModule", "AgentOrchestrator", "AgentRegistry", "OrchestrationExecutionError",
78
+ "OrchestrationPlan", "OrchestrationPlanError",
79
+ "OrchestrationResult", "OrchestrationTask", "OrchestrationTaskResult", "validate_plan",
80
+ "MEMORY_KINDS", "MemoryEntry", "MemoryService", "MemoryVectorIndex",
81
+ "MemoryRetrievalResult", "MemorySnapshotChangedError", "MemoryStore", "SQLiteMemoryStore",
82
+ "DECISION_ACTIONS", "MEMORY_SENSITIVITIES", "MemoryAssessment", "MemoryCandidate",
83
+ "MemoryCandidateExtractor", "MemoryDecision", "MemoryIntelligence", "MemoryExtractionResult",
84
+ "MemoryExtractionService", "ModelBackedMemoryCandidateExtractor", "MemoryReviewItem",
85
+ "MemoryReviewService", "MemoryReviewEvent", "MemoryReviewRecord", "SQLiteMemoryReviewStore",
86
+ "AIService", "Agent", "AgentMemory", "AgentProtocolError", "AgentResult", "AgentStep",
87
+ "AgentStepLimitError", "AgentToolError", "AnthropicProvider", "OpenAICompatibleProvider",
88
+ "OpenAICompatibleEmbeddingProvider", "EmbeddingProvider", "EmbeddingRequest",
89
+ "EmbeddingResponse", "EmbeddingService", "InMemoryVectorStore", "SQLiteVectorStore",
90
+ "NamespacedVectorStore", "VectorRecord", "VectorSearchResult", "VectorStore",
91
+ "DocumentCatalog", "DocumentCatalogEntry", "Document", "DocumentChunk", "TextChunker",
92
+ "IngestionResult", "GroundedAnswer", "RAGService", "TextGenerationProvider",
93
+ "TextGenerationRequest", "TextGenerationResponse", "StructuredGenerationRequest",
94
+ "StructuredGenerationResponse", "StructuredOutputProvider", "StructuredOutputValidator",
95
+ "BuiltinJSONSchemaValidator", "Tool", "ToolRegistry", "ToolCallingProtocolError",
96
+ "ProviderRouteError", "ProviderCircuitOpenError", "ProviderOperation", "ProviderFailureKind", "ProviderRoute", "ProviderRouter", "RetryPolicy", "CircuitBreakerPolicy", "ProviderLifecycleEvent",
97
+ "ProviderFailureError", "ProviderAuthenticationError", "ProviderInvalidRequestError",
98
+ "ProviderRateLimitError", "ProviderTimeoutError", "ProviderTransportError",
99
+ "ProviderUnavailableError", "ProviderMalformedResponseError", "classify_provider_failure",
100
+ "ToolDefinition", "ToolCall", "ToolCallingMessage", "ToolCallingRequest",
101
+ "ToolCallingResponse", "ToolCallingProvider",
102
+ ]
@@ -0,0 +1,124 @@
1
+ """Explicit proposal, review, and commit workflow for agent memory.
2
+
3
+ This adapter composes existing memory retrieval, extraction, review, and durable
4
+ review-queue APIs. It never extracts or writes memory as a side effect of
5
+ Agent.run(); host applications must call propose(), decide(), and commit()
6
+ explicitly.
7
+ """
8
+
9
+ from .memory_review import MemoryReviewService
10
+ from .memory_vector_index import MemoryVectorIndex
11
+
12
+
13
+ class AgentMemory:
14
+ """Scoped agent-memory facade with explicit, review-gated writes.
15
+
16
+ The supplied MemoryVectorIndex and review store must be bound to the same
17
+ trusted owner/workspace. The host application remains responsible for
18
+ authentication, authorization, source selection, reviewer identity, and
19
+ sensitivity policy.
20
+ """
21
+
22
+ def __init__(
23
+ self,
24
+ memory_index,
25
+ extraction_service,
26
+ review_store,
27
+ *,
28
+ review_service=None,
29
+ ):
30
+ if not isinstance(memory_index, MemoryVectorIndex):
31
+ raise TypeError("memory_index must be a MemoryVectorIndex")
32
+ if not callable(getattr(extraction_service, "extract", None)):
33
+ raise TypeError("extraction_service must implement extract()")
34
+ if review_service is None:
35
+ review_service = MemoryReviewService(
36
+ intelligence=getattr(extraction_service, "intelligence", None)
37
+ )
38
+ if not isinstance(review_service, MemoryReviewService):
39
+ raise TypeError("review_service must be a MemoryReviewService")
40
+ for method in ("enqueue", "get", "decide", "commit"):
41
+ if not callable(getattr(review_store, method, None)):
42
+ raise TypeError("review_store must implement {}".format(method))
43
+
44
+ memory = memory_index.memory_service
45
+ if (
46
+ getattr(review_store, "owner_id", None) != memory.owner_id
47
+ or getattr(review_store, "namespace", None) != memory.namespace
48
+ ):
49
+ raise ValueError(
50
+ "review store scope must match the memory index owner and namespace"
51
+ )
52
+
53
+ self.memory_index = memory_index
54
+ self.memory_service = memory
55
+ self.extraction_service = extraction_service
56
+ self.review_service = review_service
57
+ self.review_store = review_store
58
+
59
+ def hybrid_search(self, query, *, kind=None, limit=10, rrf_k=60):
60
+ """Delegate agent retrieval to the bound memory index."""
61
+ return self.memory_index.hybrid_search(
62
+ query, kind=kind, limit=limit, rrf_k=rrf_k
63
+ )
64
+
65
+ def propose(self, source_text, *, source_ref):
66
+ """Extract and enqueue review proposals from explicitly supplied text.
67
+
68
+ No conversation history is read implicitly. The caller chooses the
69
+ exact source text and provenance reference. Candidates remain pending
70
+ and are not written to the authoritative memory store.
71
+ """
72
+ if not isinstance(source_text, str) or not source_text.strip():
73
+ raise ValueError("source_text must be a non-empty string")
74
+ if not isinstance(source_ref, str) or not source_ref.strip():
75
+ raise ValueError("source_ref must be a non-empty string")
76
+
77
+ existing = self.memory_service.list(limit=1000000)
78
+ extraction = self.extraction_service.extract(
79
+ source_text, source_ref=source_ref, existing=existing
80
+ )
81
+ items = self.review_service.prepare(extraction)
82
+ return tuple(self.review_store.enqueue(item) for item in items)
83
+
84
+ def get_review(self, review_id):
85
+ """Return a review record from this adapter's bound scope."""
86
+ return self.review_store.get(review_id)
87
+
88
+ def decide(
89
+ self,
90
+ review_id,
91
+ *,
92
+ action,
93
+ reviewer,
94
+ reason=None,
95
+ override_review=False,
96
+ ):
97
+ """Record one explicit host-authorized review decision."""
98
+ record = self.review_store.get(review_id)
99
+ if record is None:
100
+ raise KeyError("review item was not found in this scope")
101
+ decision = self.review_service.decide(
102
+ record.item,
103
+ action=action,
104
+ reviewer=reviewer,
105
+ reason=reason,
106
+ override_review=override_review,
107
+ )
108
+ return self.review_store.decide(review_id, decision)
109
+
110
+ def commit(self, review_id, *, allow_personal=False, allow_sensitive=False):
111
+ """Commit an approved review and synchronize its auxiliary vector.
112
+
113
+ If vector synchronization fails, the authoritative memory and review
114
+ remain committed. Retrying this method safely retries index.sync().
115
+ """
116
+ saved = self.review_store.commit(
117
+ review_id,
118
+ self.review_service,
119
+ self.memory_service,
120
+ allow_personal=allow_personal,
121
+ allow_sensitive=allow_sensitive,
122
+ )
123
+ self.memory_index.sync(saved.id)
124
+ return saved