touchdb-ai 2.0.2__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 (292) hide show
  1. touchdb/__init__.py +172 -0
  2. touchdb/agents/__init__.py +7 -0
  3. touchdb/capabilities/__init__.py +17 -0
  4. touchdb/capabilities/agent_memory/__init__.py +21 -0
  5. touchdb/capabilities/agent_memory/base.py +103 -0
  6. touchdb/capabilities/agent_memory/models.py +53 -0
  7. touchdb/capabilities/file_system/__init__.py +14 -0
  8. touchdb/capabilities/file_system/base.py +71 -0
  9. touchdb/capabilities/file_system/models.py +25 -0
  10. touchdb/capabilities/sql_runner/__init__.py +13 -0
  11. touchdb/capabilities/sql_runner/base.py +37 -0
  12. touchdb/capabilities/sql_runner/models.py +13 -0
  13. touchdb/components/__init__.py +92 -0
  14. touchdb/components/base.py +11 -0
  15. touchdb/components/rich/__init__.py +83 -0
  16. touchdb/components/rich/containers/__init__.py +7 -0
  17. touchdb/components/rich/containers/card.py +20 -0
  18. touchdb/components/rich/data/__init__.py +9 -0
  19. touchdb/components/rich/data/chart.py +17 -0
  20. touchdb/components/rich/data/dataframe.py +93 -0
  21. touchdb/components/rich/feedback/__init__.py +21 -0
  22. touchdb/components/rich/feedback/badge.py +16 -0
  23. touchdb/components/rich/feedback/icon_text.py +14 -0
  24. touchdb/components/rich/feedback/log_viewer.py +41 -0
  25. touchdb/components/rich/feedback/notification.py +19 -0
  26. touchdb/components/rich/feedback/progress.py +37 -0
  27. touchdb/components/rich/feedback/status_card.py +28 -0
  28. touchdb/components/rich/feedback/status_indicator.py +14 -0
  29. touchdb/components/rich/interactive/__init__.py +21 -0
  30. touchdb/components/rich/interactive/button.py +95 -0
  31. touchdb/components/rich/interactive/task_list.py +58 -0
  32. touchdb/components/rich/interactive/ui_state.py +93 -0
  33. touchdb/components/rich/specialized/__init__.py +7 -0
  34. touchdb/components/rich/specialized/artifact.py +20 -0
  35. touchdb/components/rich/text.py +16 -0
  36. touchdb/components/simple/__init__.py +15 -0
  37. touchdb/components/simple/image.py +15 -0
  38. touchdb/components/simple/link.py +15 -0
  39. touchdb/components/simple/text.py +11 -0
  40. touchdb/core/__init__.py +193 -0
  41. touchdb/core/_compat.py +19 -0
  42. touchdb/core/agent/__init__.py +10 -0
  43. touchdb/core/agent/agent.py +1419 -0
  44. touchdb/core/agent/config.py +123 -0
  45. touchdb/core/audit/__init__.py +28 -0
  46. touchdb/core/audit/base.py +299 -0
  47. touchdb/core/audit/models.py +131 -0
  48. touchdb/core/component_manager.py +329 -0
  49. touchdb/core/components.py +53 -0
  50. touchdb/core/enhancer/__init__.py +11 -0
  51. touchdb/core/enhancer/base.py +94 -0
  52. touchdb/core/enhancer/default.py +118 -0
  53. touchdb/core/enricher/__init__.py +10 -0
  54. touchdb/core/enricher/base.py +59 -0
  55. touchdb/core/errors.py +47 -0
  56. touchdb/core/evaluation/__init__.py +81 -0
  57. touchdb/core/evaluation/base.py +186 -0
  58. touchdb/core/evaluation/dataset.py +254 -0
  59. touchdb/core/evaluation/evaluators.py +376 -0
  60. touchdb/core/evaluation/report.py +289 -0
  61. touchdb/core/evaluation/runner.py +313 -0
  62. touchdb/core/filter/__init__.py +10 -0
  63. touchdb/core/filter/base.py +67 -0
  64. touchdb/core/interfaces.py +19 -0
  65. touchdb/core/lifecycle/__init__.py +10 -0
  66. touchdb/core/lifecycle/base.py +83 -0
  67. touchdb/core/llm/__init__.py +16 -0
  68. touchdb/core/llm/base.py +40 -0
  69. touchdb/core/llm/models.py +61 -0
  70. touchdb/core/middleware/__init__.py +10 -0
  71. touchdb/core/middleware/base.py +69 -0
  72. touchdb/core/models.py +32 -0
  73. touchdb/core/observability/__init__.py +11 -0
  74. touchdb/core/observability/base.py +88 -0
  75. touchdb/core/observability/models.py +47 -0
  76. touchdb/core/recovery/__init__.py +11 -0
  77. touchdb/core/recovery/base.py +84 -0
  78. touchdb/core/recovery/models.py +32 -0
  79. touchdb/core/registry.py +292 -0
  80. touchdb/core/rich_component.py +156 -0
  81. touchdb/core/rich_components.py +6 -0
  82. touchdb/core/simple_component.py +27 -0
  83. touchdb/core/simple_components.py +6 -0
  84. touchdb/core/storage/__init__.py +14 -0
  85. touchdb/core/storage/base.py +46 -0
  86. touchdb/core/storage/models.py +46 -0
  87. touchdb/core/system_prompt/__init__.py +13 -0
  88. touchdb/core/system_prompt/base.py +36 -0
  89. touchdb/core/system_prompt/default.py +157 -0
  90. touchdb/core/tool/__init__.py +18 -0
  91. touchdb/core/tool/base.py +70 -0
  92. touchdb/core/tool/models.py +84 -0
  93. touchdb/core/user/__init__.py +19 -0
  94. touchdb/core/user/base.py +29 -0
  95. touchdb/core/user/models.py +25 -0
  96. touchdb/core/user/request_context.py +70 -0
  97. touchdb/core/user/resolver.py +61 -0
  98. touchdb/core/validation.py +164 -0
  99. touchdb/core/workflow/__init__.py +12 -0
  100. touchdb/core/workflow/base.py +254 -0
  101. touchdb/core/workflow/default.py +789 -0
  102. touchdb/examples/__init__.py +1 -0
  103. touchdb/examples/__main__.py +44 -0
  104. touchdb/examples/anthropic_quickstart.py +80 -0
  105. touchdb/examples/artifact_example.py +293 -0
  106. touchdb/examples/claude_sqlite_example.py +236 -0
  107. touchdb/examples/coding_agent_example.py +300 -0
  108. touchdb/examples/custom_system_prompt_example.py +174 -0
  109. touchdb/examples/default_workflow_handler_example.py +208 -0
  110. touchdb/examples/email_auth_example.py +340 -0
  111. touchdb/examples/evaluation_example.py +269 -0
  112. touchdb/examples/extensibility_example.py +262 -0
  113. touchdb/examples/minimal_example.py +67 -0
  114. touchdb/examples/mock_auth_example.py +227 -0
  115. touchdb/examples/mock_custom_tool.py +311 -0
  116. touchdb/examples/mock_quickstart.py +79 -0
  117. touchdb/examples/mock_quota_example.py +145 -0
  118. touchdb/examples/mock_rich_components_demo.py +396 -0
  119. touchdb/examples/mock_sqlite_example.py +223 -0
  120. touchdb/examples/openai_quickstart.py +83 -0
  121. touchdb/examples/primitive_components_demo.py +305 -0
  122. touchdb/examples/quota_lifecycle_example.py +139 -0
  123. touchdb/examples/visualization_example.py +251 -0
  124. touchdb/integrations/__init__.py +17 -0
  125. touchdb/integrations/anthropic/__init__.py +9 -0
  126. touchdb/integrations/anthropic/llm.py +270 -0
  127. touchdb/integrations/azureopenai/__init__.py +9 -0
  128. touchdb/integrations/azureopenai/llm.py +329 -0
  129. touchdb/integrations/azuresearch/__init__.py +7 -0
  130. touchdb/integrations/azuresearch/agent_memory.py +413 -0
  131. touchdb/integrations/bigquery/__init__.py +5 -0
  132. touchdb/integrations/bigquery/sql_runner.py +81 -0
  133. touchdb/integrations/chromadb/__init__.py +104 -0
  134. touchdb/integrations/chromadb/agent_memory.py +488 -0
  135. touchdb/integrations/clickhouse/__init__.py +5 -0
  136. touchdb/integrations/clickhouse/sql_runner.py +82 -0
  137. touchdb/integrations/duckdb/__init__.py +5 -0
  138. touchdb/integrations/duckdb/sql_runner.py +65 -0
  139. touchdb/integrations/faiss/__init__.py +7 -0
  140. touchdb/integrations/faiss/agent_memory.py +435 -0
  141. touchdb/integrations/google/__init__.py +9 -0
  142. touchdb/integrations/google/gemini.py +370 -0
  143. touchdb/integrations/hive/__init__.py +5 -0
  144. touchdb/integrations/hive/sql_runner.py +87 -0
  145. touchdb/integrations/local/__init__.py +17 -0
  146. touchdb/integrations/local/agent_memory/__init__.py +7 -0
  147. touchdb/integrations/local/agent_memory/in_memory.py +285 -0
  148. touchdb/integrations/local/audit.py +59 -0
  149. touchdb/integrations/local/file_system.py +242 -0
  150. touchdb/integrations/local/file_system_conversation_store.py +255 -0
  151. touchdb/integrations/local/storage.py +62 -0
  152. touchdb/integrations/marqo/__init__.py +7 -0
  153. touchdb/integrations/marqo/agent_memory.py +354 -0
  154. touchdb/integrations/milvus/__init__.py +7 -0
  155. touchdb/integrations/milvus/agent_memory.py +458 -0
  156. touchdb/integrations/mock/__init__.py +9 -0
  157. touchdb/integrations/mock/llm.py +65 -0
  158. touchdb/integrations/mssql/__init__.py +5 -0
  159. touchdb/integrations/mssql/sql_runner.py +66 -0
  160. touchdb/integrations/mysql/__init__.py +5 -0
  161. touchdb/integrations/mysql/sql_runner.py +92 -0
  162. touchdb/integrations/ollama/__init__.py +7 -0
  163. touchdb/integrations/ollama/llm.py +252 -0
  164. touchdb/integrations/openai/__init__.py +10 -0
  165. touchdb/integrations/openai/llm.py +267 -0
  166. touchdb/integrations/openai/responses.py +163 -0
  167. touchdb/integrations/opensearch/__init__.py +7 -0
  168. touchdb/integrations/opensearch/agent_memory.py +411 -0
  169. touchdb/integrations/oracle/__init__.py +5 -0
  170. touchdb/integrations/oracle/sql_runner.py +75 -0
  171. touchdb/integrations/pinecone/__init__.py +7 -0
  172. touchdb/integrations/pinecone/agent_memory.py +329 -0
  173. touchdb/integrations/plotly/__init__.py +5 -0
  174. touchdb/integrations/plotly/chart_generator.py +313 -0
  175. touchdb/integrations/postgres/__init__.py +9 -0
  176. touchdb/integrations/postgres/sql_runner.py +112 -0
  177. touchdb/integrations/premium/agent_memory/__init__.py +7 -0
  178. touchdb/integrations/premium/agent_memory/premium.py +186 -0
  179. touchdb/integrations/presto/__init__.py +5 -0
  180. touchdb/integrations/presto/sql_runner.py +107 -0
  181. touchdb/integrations/qdrant/__init__.py +7 -0
  182. touchdb/integrations/qdrant/agent_memory.py +466 -0
  183. touchdb/integrations/snowflake/__init__.py +5 -0
  184. touchdb/integrations/snowflake/sql_runner.py +147 -0
  185. touchdb/integrations/sqlite/__init__.py +9 -0
  186. touchdb/integrations/sqlite/sql_runner.py +65 -0
  187. touchdb/integrations/weaviate/__init__.py +7 -0
  188. touchdb/integrations/weaviate/agent_memory.py +428 -0
  189. touchdb/legacy/ZhipuAI/ZhipuAI_Chat.py +233 -0
  190. touchdb/legacy/ZhipuAI/ZhipuAI_embeddings.py +79 -0
  191. touchdb/legacy/ZhipuAI/__init__.py +2 -0
  192. touchdb/legacy/__init__.py +403 -0
  193. touchdb/legacy/adapter.py +463 -0
  194. touchdb/legacy/advanced/__init__.py +28 -0
  195. touchdb/legacy/anthropic/__init__.py +1 -0
  196. touchdb/legacy/anthropic/anthropic_chat.py +80 -0
  197. touchdb/legacy/azuresearch/__init__.py +1 -0
  198. touchdb/legacy/azuresearch/azuresearch_vector.py +274 -0
  199. touchdb/legacy/base/__init__.py +1 -0
  200. touchdb/legacy/base/base.py +2125 -0
  201. touchdb/legacy/bedrock/__init__.py +1 -0
  202. touchdb/legacy/bedrock/bedrock_converse.py +86 -0
  203. touchdb/legacy/chromadb/__init__.py +1 -0
  204. touchdb/legacy/chromadb/chromadb_vector.py +259 -0
  205. touchdb/legacy/cohere/__init__.py +2 -0
  206. touchdb/legacy/cohere/cohere_chat.py +99 -0
  207. touchdb/legacy/cohere/cohere_embeddings.py +77 -0
  208. touchdb/legacy/deepseek/__init__.py +1 -0
  209. touchdb/legacy/deepseek/deepseek_chat.py +59 -0
  210. touchdb/legacy/exceptions/__init__.py +46 -0
  211. touchdb/legacy/faiss/__init__.py +1 -0
  212. touchdb/legacy/faiss/faiss.py +230 -0
  213. touchdb/legacy/flask/__init__.py +1343 -0
  214. touchdb/legacy/flask/assets.py +58 -0
  215. touchdb/legacy/flask/auth.py +56 -0
  216. touchdb/legacy/google/__init__.py +2 -0
  217. touchdb/legacy/google/bigquery_vector.py +282 -0
  218. touchdb/legacy/google/gemini_chat.py +78 -0
  219. touchdb/legacy/hf/__init__.py +1 -0
  220. touchdb/legacy/hf/hf.py +80 -0
  221. touchdb/legacy/local.py +8 -0
  222. touchdb/legacy/marqo/__init__.py +1 -0
  223. touchdb/legacy/marqo/marqo.py +168 -0
  224. touchdb/legacy/milvus/__init__.py +1 -0
  225. touchdb/legacy/milvus/milvus_vector.py +328 -0
  226. touchdb/legacy/mistral/__init__.py +1 -0
  227. touchdb/legacy/mistral/mistral.py +51 -0
  228. touchdb/legacy/mock/__init__.py +3 -0
  229. touchdb/legacy/mock/embedding.py +11 -0
  230. touchdb/legacy/mock/llm.py +18 -0
  231. touchdb/legacy/mock/vectordb.py +67 -0
  232. touchdb/legacy/ollama/__init__.py +1 -0
  233. touchdb/legacy/ollama/ollama.py +110 -0
  234. touchdb/legacy/openai/__init__.py +2 -0
  235. touchdb/legacy/openai/openai_chat.py +124 -0
  236. touchdb/legacy/openai/openai_embeddings.py +46 -0
  237. touchdb/legacy/opensearch/__init__.py +2 -0
  238. touchdb/legacy/opensearch/opensearch_vector.py +369 -0
  239. touchdb/legacy/opensearch/opensearch_vector_semantic.py +200 -0
  240. touchdb/legacy/oracle/__init__.py +1 -0
  241. touchdb/legacy/oracle/oracle_vector.py +584 -0
  242. touchdb/legacy/pgvector/__init__.py +1 -0
  243. touchdb/legacy/pgvector/pgvector.py +282 -0
  244. touchdb/legacy/pinecone/__init__.py +3 -0
  245. touchdb/legacy/pinecone/pinecone_vector.py +275 -0
  246. touchdb/legacy/qdrant/__init__.py +3 -0
  247. touchdb/legacy/qdrant/qdrant.py +329 -0
  248. touchdb/legacy/qianfan/Qianfan_Chat.py +170 -0
  249. touchdb/legacy/qianfan/Qianfan_embeddings.py +36 -0
  250. touchdb/legacy/qianfan/__init__.py +2 -0
  251. touchdb/legacy/qianwen/QianwenAI_chat.py +132 -0
  252. touchdb/legacy/qianwen/QianwenAI_embeddings.py +46 -0
  253. touchdb/legacy/qianwen/__init__.py +2 -0
  254. touchdb/legacy/remote.py +79 -0
  255. touchdb/legacy/touchdbdb/__init__.py +1 -0
  256. touchdb/legacy/touchdbdb/touchdbdb_vector.py +468 -0
  257. touchdb/legacy/types/__init__.py +292 -0
  258. touchdb/legacy/utils.py +72 -0
  259. touchdb/legacy/vllm/__init__.py +1 -0
  260. touchdb/legacy/vllm/vllm.py +97 -0
  261. touchdb/legacy/weaviate/__init__.py +1 -0
  262. touchdb/legacy/weaviate/weaviate_vector.py +194 -0
  263. touchdb/legacy/xinference/__init__.py +1 -0
  264. touchdb/legacy/xinference/xinference.py +53 -0
  265. touchdb/py.typed +0 -0
  266. touchdb/servers/__init__.py +16 -0
  267. touchdb/servers/__main__.py +8 -0
  268. touchdb/servers/base/__init__.py +18 -0
  269. touchdb/servers/base/chat_handler.py +65 -0
  270. touchdb/servers/base/models.py +111 -0
  271. touchdb/servers/base/rich_chat_handler.py +141 -0
  272. touchdb/servers/base/templates.py +331 -0
  273. touchdb/servers/cli/__init__.py +7 -0
  274. touchdb/servers/cli/server_runner.py +204 -0
  275. touchdb/servers/fastapi/__init__.py +7 -0
  276. touchdb/servers/fastapi/app.py +163 -0
  277. touchdb/servers/fastapi/routes.py +183 -0
  278. touchdb/servers/flask/__init__.py +7 -0
  279. touchdb/servers/flask/app.py +132 -0
  280. touchdb/servers/flask/routes.py +137 -0
  281. touchdb/tools/__init__.py +41 -0
  282. touchdb/tools/agent_memory.py +322 -0
  283. touchdb/tools/file_system.py +879 -0
  284. touchdb/tools/python.py +222 -0
  285. touchdb/tools/run_sql.py +165 -0
  286. touchdb/tools/visualize_data.py +195 -0
  287. touchdb/utils/__init__.py +0 -0
  288. touchdb/web_components/__init__.py +44 -0
  289. touchdb_ai-2.0.2.dist-info/METADATA +152 -0
  290. touchdb_ai-2.0.2.dist-info/RECORD +292 -0
  291. touchdb_ai-2.0.2.dist-info/WHEEL +4 -0
  292. touchdb_ai-2.0.2.dist-info/entry_points.txt +3 -0
touchdb/__init__.py ADDED
@@ -0,0 +1,172 @@
1
+ """
2
+ TouchDB Agents - A modular framework for building LLM agents.
3
+
4
+ This package provides a flexible framework for creating conversational AI agents
5
+ with tool execution, conversation management, and user scoping.
6
+ """
7
+
8
+ # Version information
9
+ __version__ = "2.0.2"
10
+
11
+ # Import core framework components
12
+ from .core import (
13
+ # Interfaces
14
+ Agent,
15
+ ConversationStore,
16
+ LlmService,
17
+ SystemPromptBuilder,
18
+ Tool,
19
+ UserService,
20
+ T,
21
+ # Models
22
+ Conversation,
23
+ LlmMessage,
24
+ LlmRequest,
25
+ LlmResponse,
26
+ LlmStreamChunk,
27
+ Message,
28
+ ToolCall,
29
+ ToolContext,
30
+ ToolResult,
31
+ ToolSchema,
32
+ User,
33
+ # UI Components
34
+ UiComponent,
35
+ SimpleComponent,
36
+ SimpleComponentType,
37
+ SimpleTextComponent,
38
+ SimpleImageComponent,
39
+ SimpleLinkComponent,
40
+ # Rich Components
41
+ ArtifactComponent,
42
+ BadgeComponent,
43
+ CardComponent,
44
+ DataFrameComponent,
45
+ IconTextComponent,
46
+ LogViewerComponent,
47
+ NotificationComponent,
48
+ ProgressBarComponent,
49
+ ProgressDisplayComponent,
50
+ RichTextComponent,
51
+ StatusCardComponent,
52
+ TaskListComponent,
53
+ # Core implementations
54
+ Agent,
55
+ AgentConfig,
56
+ DefaultSystemPromptBuilder,
57
+ DefaultWorkflowHandler,
58
+ ToolRegistry,
59
+ # Evaluation
60
+ Evaluator,
61
+ TestCase,
62
+ ExpectedOutcome,
63
+ AgentResult,
64
+ EvaluationResult,
65
+ TestCaseResult,
66
+ AgentVariant,
67
+ EvaluationRunner,
68
+ TrajectoryEvaluator,
69
+ OutputEvaluator,
70
+ LLMAsJudgeEvaluator,
71
+ EfficiencyEvaluator,
72
+ EvaluationReport,
73
+ ComparisonReport,
74
+ EvaluationDataset,
75
+ # Exceptions
76
+ AgentError,
77
+ ConversationNotFoundError,
78
+ LlmServiceError,
79
+ PermissionError,
80
+ ToolExecutionError,
81
+ ToolNotFoundError,
82
+ ValidationError,
83
+ )
84
+
85
+ # Import basic implementations
86
+ from .integrations import MemoryConversationStore, MockLlmService
87
+
88
+ # Main exports
89
+ __all__ = [
90
+ # Version
91
+ "__version__",
92
+ # Core interfaces
93
+ "Agent",
94
+ "Tool",
95
+ "LlmService",
96
+ "ConversationStore",
97
+ "UserService",
98
+ "SystemPromptBuilder",
99
+ "T",
100
+ # Models
101
+ "User",
102
+ "Message",
103
+ "Conversation",
104
+ "ToolCall",
105
+ "ToolResult",
106
+ "ToolContext",
107
+ "ToolSchema",
108
+ "LlmMessage",
109
+ "LlmRequest",
110
+ "LlmResponse",
111
+ "LlmStreamChunk",
112
+ # UI Components
113
+ "UiComponent",
114
+ "SimpleComponent",
115
+ "SimpleComponentType",
116
+ "SimpleTextComponent",
117
+ "SimpleImageComponent",
118
+ "SimpleLinkComponent",
119
+ # Rich Components
120
+ "ArtifactComponent",
121
+ "BadgeComponent",
122
+ "CardComponent",
123
+ "DataFrameComponent",
124
+ "IconTextComponent",
125
+ "LogViewerComponent",
126
+ "NotificationComponent",
127
+ "ProgressBarComponent",
128
+ "ProgressDisplayComponent",
129
+ "RichTextComponent",
130
+ "StatusCardComponent",
131
+ "TaskListComponent",
132
+ # Core implementations
133
+ "Agent",
134
+ "AgentConfig",
135
+ "ToolRegistry",
136
+ "DefaultSystemPromptBuilder",
137
+ "DefaultWorkflowHandler",
138
+ # Evaluation
139
+ "Evaluator",
140
+ "TestCase",
141
+ "ExpectedOutcome",
142
+ "AgentResult",
143
+ "EvaluationResult",
144
+ "TestCaseResult",
145
+ "AgentVariant",
146
+ "EvaluationRunner",
147
+ "TrajectoryEvaluator",
148
+ "OutputEvaluator",
149
+ "LLMAsJudgeEvaluator",
150
+ "EfficiencyEvaluator",
151
+ "EvaluationReport",
152
+ "ComparisonReport",
153
+ "EvaluationDataset",
154
+ # Basic implementations
155
+ "MemoryConversationStore",
156
+ "MockLlmService",
157
+ # Server components
158
+ "TouchDBFlaskServer",
159
+ "TouchDBFastAPIServer",
160
+ "ChatHandler",
161
+ "ChatRequest",
162
+ "ChatStreamChunk",
163
+ "ExampleAgentLoader",
164
+ # Exceptions
165
+ "AgentError",
166
+ "ToolExecutionError",
167
+ "ToolNotFoundError",
168
+ "PermissionError",
169
+ "ConversationNotFoundError",
170
+ "LlmServiceError",
171
+ "ValidationError",
172
+ ]
@@ -0,0 +1,7 @@
1
+ """
2
+ Agent implementations.
3
+
4
+ This package contains agent implementations and utilities.
5
+ """
6
+
7
+ __all__: list[str] = []
@@ -0,0 +1,17 @@
1
+ """
2
+ Capabilities module.
3
+
4
+ This package contains abstractions for tool capabilities - reusable utilities
5
+ that tools can compose via dependency injection.
6
+ """
7
+
8
+ from .file_system import CommandResult, FileSearchMatch, FileSystem
9
+ from .sql_runner import RunSqlToolArgs, SqlRunner
10
+
11
+ __all__ = [
12
+ "FileSystem",
13
+ "FileSearchMatch",
14
+ "CommandResult",
15
+ "SqlRunner",
16
+ "RunSqlToolArgs",
17
+ ]
@@ -0,0 +1,21 @@
1
+ """
2
+ Agent memory capability package.
3
+ """
4
+
5
+ from .base import AgentMemory
6
+ from .models import (
7
+ MemoryStats,
8
+ TextMemory,
9
+ TextMemorySearchResult,
10
+ ToolMemory,
11
+ ToolMemorySearchResult,
12
+ )
13
+
14
+ __all__ = [
15
+ "AgentMemory",
16
+ "TextMemory",
17
+ "TextMemorySearchResult",
18
+ "ToolMemory",
19
+ "ToolMemorySearchResult",
20
+ "MemoryStats",
21
+ ]
@@ -0,0 +1,103 @@
1
+ """
2
+ Agent memory capability interface for tool usage learning.
3
+
4
+ This module contains the abstract base class for agent memory operations,
5
+ following the same pattern as the FileSystem interface.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from abc import ABC, abstractmethod
11
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional
12
+
13
+ if TYPE_CHECKING:
14
+ from touchdb.core.tool import ToolContext
15
+ from .models import (
16
+ ToolMemorySearchResult,
17
+ TextMemory,
18
+ TextMemorySearchResult,
19
+ ToolMemory,
20
+ )
21
+
22
+
23
+ class AgentMemory(ABC):
24
+ """Abstract base class for agent memory operations."""
25
+
26
+ @abstractmethod
27
+ async def save_tool_usage(
28
+ self,
29
+ question: str,
30
+ tool_name: str,
31
+ args: Dict[str, Any],
32
+ context: "ToolContext",
33
+ success: bool = True,
34
+ metadata: Optional[Dict[str, Any]] = None,
35
+ ) -> None:
36
+ """Save a tool usage pattern for future reference."""
37
+ pass
38
+
39
+ @abstractmethod
40
+ async def save_text_memory(
41
+ self, content: str, context: "ToolContext"
42
+ ) -> "TextMemory":
43
+ """Save a free-form text memory."""
44
+ pass
45
+
46
+ @abstractmethod
47
+ async def search_similar_usage(
48
+ self,
49
+ question: str,
50
+ context: "ToolContext",
51
+ *,
52
+ limit: int = 10,
53
+ similarity_threshold: float = 0.7,
54
+ tool_name_filter: Optional[str] = None,
55
+ ) -> List[ToolMemorySearchResult]:
56
+ """Search for similar tool usage patterns based on a question."""
57
+ pass
58
+
59
+ @abstractmethod
60
+ async def search_text_memories(
61
+ self,
62
+ query: str,
63
+ context: "ToolContext",
64
+ *,
65
+ limit: int = 10,
66
+ similarity_threshold: float = 0.7,
67
+ ) -> List["TextMemorySearchResult"]:
68
+ """Search stored text memories based on a query."""
69
+ pass
70
+
71
+ @abstractmethod
72
+ async def get_recent_memories(
73
+ self, context: "ToolContext", limit: int = 10
74
+ ) -> List[ToolMemory]:
75
+ """Get recently added memories. Returns most recent memories first."""
76
+ pass
77
+
78
+ @abstractmethod
79
+ async def get_recent_text_memories(
80
+ self, context: "ToolContext", limit: int = 10
81
+ ) -> List["TextMemory"]:
82
+ """Fetch recently stored text memories."""
83
+ pass
84
+
85
+ @abstractmethod
86
+ async def delete_by_id(self, context: "ToolContext", memory_id: str) -> bool:
87
+ """Delete a memory by its ID. Returns True if deleted, False if not found."""
88
+ pass
89
+
90
+ @abstractmethod
91
+ async def delete_text_memory(self, context: "ToolContext", memory_id: str) -> bool:
92
+ """Delete a text memory by its ID. Returns True if deleted, False if not found."""
93
+ pass
94
+
95
+ @abstractmethod
96
+ async def clear_memories(
97
+ self,
98
+ context: "ToolContext",
99
+ tool_name: Optional[str] = None,
100
+ before_date: Optional[str] = None,
101
+ ) -> int:
102
+ """Clear stored memories (tool or text). Returns number of memories deleted."""
103
+ pass
@@ -0,0 +1,53 @@
1
+ """
2
+ Memory storage models and types.
3
+ """
4
+
5
+ from typing import Any, Dict, List, Optional
6
+
7
+ from pydantic import BaseModel
8
+
9
+
10
+ class ToolMemory(BaseModel):
11
+ """Represents a stored tool usage memory."""
12
+
13
+ memory_id: Optional[str] = None
14
+ question: str
15
+ tool_name: str
16
+ args: Dict[str, Any]
17
+ timestamp: Optional[str] = None
18
+ success: bool = True
19
+ metadata: Optional[Dict[str, Any]] = None
20
+
21
+
22
+ class TextMemory(BaseModel):
23
+ """Represents a stored free-form text memory."""
24
+
25
+ memory_id: Optional[str] = None
26
+ content: str
27
+ timestamp: Optional[str] = None
28
+
29
+
30
+ class ToolMemorySearchResult(BaseModel):
31
+ """Represents a search result from tool memory storage."""
32
+
33
+ memory: ToolMemory
34
+ similarity_score: float
35
+ rank: int
36
+
37
+
38
+ class TextMemorySearchResult(BaseModel):
39
+ """Represents a search result from text memory storage."""
40
+
41
+ memory: TextMemory
42
+ similarity_score: float
43
+ rank: int
44
+
45
+
46
+ class MemoryStats(BaseModel):
47
+ """Memory storage statistics."""
48
+
49
+ total_memories: int
50
+ unique_tools: int
51
+ unique_questions: int
52
+ success_rate: float
53
+ most_used_tools: Dict[str, int]
@@ -0,0 +1,14 @@
1
+ """
2
+ File system capability.
3
+
4
+ This module provides abstractions for file system operations used by tools.
5
+ """
6
+
7
+ from .base import FileSystem
8
+ from .models import CommandResult, FileSearchMatch
9
+
10
+ __all__ = [
11
+ "FileSystem",
12
+ "FileSearchMatch",
13
+ "CommandResult",
14
+ ]
@@ -0,0 +1,71 @@
1
+ """
2
+ File system capability interface.
3
+
4
+ This module contains the abstract base class for file system operations.
5
+ """
6
+
7
+ from abc import ABC, abstractmethod
8
+ from typing import TYPE_CHECKING, List, Optional
9
+
10
+ from .models import CommandResult, FileSearchMatch
11
+
12
+ if TYPE_CHECKING:
13
+ from touchdb.core.tool import ToolContext
14
+
15
+
16
+ class FileSystem(ABC):
17
+ """Abstract base class for file system operations."""
18
+
19
+ @abstractmethod
20
+ async def list_files(self, directory: str, context: "ToolContext") -> List[str]:
21
+ """List files in a directory."""
22
+ pass
23
+
24
+ @abstractmethod
25
+ async def read_file(self, filename: str, context: "ToolContext") -> str:
26
+ """Read the contents of a file."""
27
+ pass
28
+
29
+ @abstractmethod
30
+ async def write_file(
31
+ self,
32
+ filename: str,
33
+ content: str,
34
+ context: "ToolContext",
35
+ overwrite: bool = False,
36
+ ) -> None:
37
+ """Write content to a file."""
38
+ pass
39
+
40
+ @abstractmethod
41
+ async def exists(self, path: str, context: "ToolContext") -> bool:
42
+ """Check if a file or directory exists."""
43
+ pass
44
+
45
+ @abstractmethod
46
+ async def is_directory(self, path: str, context: "ToolContext") -> bool:
47
+ """Check if a path is a directory."""
48
+ pass
49
+
50
+ @abstractmethod
51
+ async def search_files(
52
+ self,
53
+ query: str,
54
+ context: "ToolContext",
55
+ *,
56
+ max_results: int = 20,
57
+ include_content: bool = False,
58
+ ) -> List[FileSearchMatch]:
59
+ """Search for files matching a query within the accessible namespace."""
60
+ pass
61
+
62
+ @abstractmethod
63
+ async def run_bash(
64
+ self,
65
+ command: str,
66
+ context: "ToolContext",
67
+ *,
68
+ timeout: Optional[float] = None,
69
+ ) -> CommandResult:
70
+ """Execute a bash command within the accessible namespace."""
71
+ pass
@@ -0,0 +1,25 @@
1
+ """
2
+ File system capability models.
3
+
4
+ This module contains data models for file system operations.
5
+ """
6
+
7
+ from dataclasses import dataclass
8
+ from typing import Optional
9
+
10
+
11
+ @dataclass
12
+ class FileSearchMatch:
13
+ """Represents a single search result within a file system."""
14
+
15
+ path: str
16
+ snippet: Optional[str] = None
17
+
18
+
19
+ @dataclass
20
+ class CommandResult:
21
+ """Represents the result of executing a shell command."""
22
+
23
+ stdout: str
24
+ stderr: str
25
+ returncode: int
@@ -0,0 +1,13 @@
1
+ """
2
+ SQL runner capability.
3
+
4
+ This module provides abstractions for SQL execution used by tools.
5
+ """
6
+
7
+ from .base import SqlRunner
8
+ from .models import RunSqlToolArgs
9
+
10
+ __all__ = [
11
+ "SqlRunner",
12
+ "RunSqlToolArgs",
13
+ ]
@@ -0,0 +1,37 @@
1
+ """
2
+ SQL runner capability interface.
3
+
4
+ This module contains the abstract base class for SQL execution.
5
+ """
6
+
7
+ from abc import ABC, abstractmethod
8
+ from typing import TYPE_CHECKING
9
+
10
+ import pandas as pd
11
+
12
+ from .models import RunSqlToolArgs
13
+
14
+ if TYPE_CHECKING:
15
+ from touchdb.core.tool import ToolContext
16
+
17
+
18
+ class SqlRunner(ABC):
19
+ """Interface for SQL execution with different implementations."""
20
+
21
+ @abstractmethod
22
+ async def run_sql(
23
+ self, args: RunSqlToolArgs, context: "ToolContext"
24
+ ) -> pd.DataFrame:
25
+ """Execute SQL query and return results as a DataFrame.
26
+
27
+ Args:
28
+ args: SQL query arguments
29
+ context: Tool execution context
30
+
31
+ Returns:
32
+ DataFrame with query results
33
+
34
+ Raises:
35
+ Exception: If query execution fails
36
+ """
37
+ pass
@@ -0,0 +1,13 @@
1
+ """
2
+ SQL runner capability models.
3
+
4
+ This module contains data models for SQL execution.
5
+ """
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ class RunSqlToolArgs(BaseModel):
11
+ """Arguments for run_sql tool."""
12
+
13
+ sql: str = Field(description="SQL query to execute")
@@ -0,0 +1,92 @@
1
+ """UI Component system for TouchDB Agents."""
2
+
3
+ # Base component
4
+ from .base import UiComponent
5
+
6
+ # Simple components
7
+ from .simple import (
8
+ SimpleComponent,
9
+ SimpleComponentType,
10
+ SimpleTextComponent,
11
+ SimpleImageComponent,
12
+ SimpleLinkComponent,
13
+ )
14
+
15
+ # Rich components - re-export all
16
+ from .rich import (
17
+ # Base
18
+ RichComponent,
19
+ ComponentType,
20
+ ComponentLifecycle,
21
+ # Text
22
+ RichTextComponent,
23
+ # Data
24
+ DataFrameComponent,
25
+ ChartComponent,
26
+ # Feedback
27
+ NotificationComponent,
28
+ StatusCardComponent,
29
+ ProgressBarComponent,
30
+ ProgressDisplayComponent,
31
+ StatusIndicatorComponent,
32
+ LogViewerComponent,
33
+ LogEntry,
34
+ BadgeComponent,
35
+ IconTextComponent,
36
+ # Interactive
37
+ TaskListComponent,
38
+ Task,
39
+ StatusBarUpdateComponent,
40
+ TaskTrackerUpdateComponent,
41
+ ChatInputUpdateComponent,
42
+ TaskOperation,
43
+ ButtonComponent,
44
+ ButtonGroupComponent,
45
+ # Containers
46
+ CardComponent,
47
+ # Specialized
48
+ ArtifactComponent,
49
+ )
50
+
51
+ __all__ = [
52
+ # Base
53
+ "UiComponent",
54
+ # Simple components
55
+ "SimpleComponent",
56
+ "SimpleComponentType",
57
+ "SimpleTextComponent",
58
+ "SimpleImageComponent",
59
+ "SimpleLinkComponent",
60
+ # Rich components - Base
61
+ "RichComponent",
62
+ "ComponentType",
63
+ "ComponentLifecycle",
64
+ # Rich components - Text
65
+ "RichTextComponent",
66
+ # Rich components - Data
67
+ "DataFrameComponent",
68
+ "ChartComponent",
69
+ # Rich components - Feedback
70
+ "NotificationComponent",
71
+ "StatusCardComponent",
72
+ "ProgressBarComponent",
73
+ "ProgressDisplayComponent",
74
+ "StatusIndicatorComponent",
75
+ "LogViewerComponent",
76
+ "LogEntry",
77
+ "BadgeComponent",
78
+ "IconTextComponent",
79
+ # Rich components - Interactive
80
+ "TaskListComponent",
81
+ "Task",
82
+ "StatusBarUpdateComponent",
83
+ "TaskTrackerUpdateComponent",
84
+ "ChatInputUpdateComponent",
85
+ "TaskOperation",
86
+ "ButtonComponent",
87
+ "ButtonGroupComponent",
88
+ # Rich components - Containers
89
+ "CardComponent",
90
+ # Rich components - Specialized
91
+ "ArtifactComponent",
92
+ ]
@@ -0,0 +1,11 @@
1
+ """
2
+ UI components base - re-exports UiComponent from core.
3
+
4
+ UiComponent lives in core/ because it's a fundamental return type for tools.
5
+ This module provides backward compatibility by re-exporting it here.
6
+ """
7
+
8
+ # Re-export UiComponent from core for backward compatibility
9
+ from ..core.components import UiComponent
10
+
11
+ __all__ = ["UiComponent"]