delfhos 0.4.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.
- delfhos-0.4.0/LICENSE +201 -0
- delfhos-0.4.0/PKG-INFO +454 -0
- delfhos-0.4.0/README.md +413 -0
- delfhos-0.4.0/cortex/__init__.py +50 -0
- delfhos-0.4.0/cortex/_engine/__init__.py +14 -0
- delfhos-0.4.0/cortex/_engine/agent.py +715 -0
- delfhos-0.4.0/cortex/_engine/config/__init__.py +32 -0
- delfhos-0.4.0/cortex/_engine/config/env_loader.py +90 -0
- delfhos-0.4.0/cortex/_engine/config/llmPricing.json +52 -0
- delfhos-0.4.0/cortex/_engine/connection.py +252 -0
- delfhos-0.4.0/cortex/_engine/core/__init__.py +2 -0
- delfhos-0.4.0/cortex/_engine/core/approval_manager.py +409 -0
- delfhos-0.4.0/cortex/_engine/core/conversation_summarizer.py +189 -0
- delfhos-0.4.0/cortex/_engine/core/orchestrator.py +1626 -0
- delfhos-0.4.0/cortex/_engine/core/python_executor.py +911 -0
- delfhos-0.4.0/cortex/_engine/internal/llm.py +290 -0
- delfhos-0.4.0/cortex/_engine/mcp/__init__.py +12 -0
- delfhos-0.4.0/cortex/_engine/mcp/client.py +270 -0
- delfhos-0.4.0/cortex/_engine/mcp/compiler.py +320 -0
- delfhos-0.4.0/cortex/_engine/mcp/executor.py +173 -0
- delfhos-0.4.0/cortex/_engine/memory/AgentMemory.py +32 -0
- delfhos-0.4.0/cortex/_engine/memory/TaskMemory.py +24 -0
- delfhos-0.4.0/cortex/_engine/memory/__init__.py +4 -0
- delfhos-0.4.0/cortex/_engine/tools/__init__.py +5 -0
- delfhos-0.4.0/cortex/_engine/tools/calendar/__init__.py +1 -0
- delfhos-0.4.0/cortex/_engine/tools/calendar/calendar_client.py +281 -0
- delfhos-0.4.0/cortex/_engine/tools/calendar/calendar_tool.py +474 -0
- delfhos-0.4.0/cortex/_engine/tools/classification.py +129 -0
- delfhos-0.4.0/cortex/_engine/tools/docs/__init__.py +4 -0
- delfhos-0.4.0/cortex/_engine/tools/docs/docs_client.py +336 -0
- delfhos-0.4.0/cortex/_engine/tools/docs/docs_tool.py +554 -0
- delfhos-0.4.0/cortex/_engine/tools/drive/__init__.py +1 -0
- delfhos-0.4.0/cortex/_engine/tools/drive/gdrive_client.py +464 -0
- delfhos-0.4.0/cortex/_engine/tools/drive/gdrive_doc.py +24 -0
- delfhos-0.4.0/cortex/_engine/tools/drive/gdrive_tool.py +288 -0
- delfhos-0.4.0/cortex/_engine/tools/files.py +306 -0
- delfhos-0.4.0/cortex/_engine/tools/gmail/__init__.py +1 -0
- delfhos-0.4.0/cortex/_engine/tools/gmail/gmail_client.py +591 -0
- delfhos-0.4.0/cortex/_engine/tools/gmail/gmail_dsl_parser.py +376 -0
- delfhos-0.4.0/cortex/_engine/tools/gmail/gmail_tool_unified.py +449 -0
- delfhos-0.4.0/cortex/_engine/tools/internal_tools.py +132 -0
- delfhos-0.4.0/cortex/_engine/tools/sheets/__init__.py +1 -0
- delfhos-0.4.0/cortex/_engine/tools/sheets/gsheets_client.py +388 -0
- delfhos-0.4.0/cortex/_engine/tools/sheets/gsheets_doc.py +56 -0
- delfhos-0.4.0/cortex/_engine/tools/sheets/gsheets_tool.py +1236 -0
- delfhos-0.4.0/cortex/_engine/tools/sql/__init__.py +5 -0
- delfhos-0.4.0/cortex/_engine/tools/sql/sql_client.py +358 -0
- delfhos-0.4.0/cortex/_engine/tools/sql/sql_tool.py +213 -0
- delfhos-0.4.0/cortex/_engine/tools/tool.py +144 -0
- delfhos-0.4.0/cortex/_engine/tools/tool_libraries.py +2422 -0
- delfhos-0.4.0/cortex/_engine/tools/tool_registry.py +1041 -0
- delfhos-0.4.0/cortex/_engine/tools/websearch/__init__.py +90 -0
- delfhos-0.4.0/cortex/_engine/trace.py +305 -0
- delfhos-0.4.0/cortex/_engine/types.py +32 -0
- delfhos-0.4.0/cortex/_engine/utils/__init__.py +6 -0
- delfhos-0.4.0/cortex/_engine/utils/console.py +171 -0
- delfhos-0.4.0/cortex/_engine/utils/error_codes.py +272 -0
- delfhos-0.4.0/cortex/_engine/utils/llm_utils.py +32 -0
- delfhos-0.4.0/cortex/_engine/utils/logger.py +174 -0
- delfhos-0.4.0/cortex/_engine/utils/pricing.py +131 -0
- delfhos-0.4.0/cortex/connections/__init__.py +49 -0
- delfhos-0.4.0/cortex/connections/base.py +146 -0
- delfhos-0.4.0/cortex/connections/calendar.py +52 -0
- delfhos-0.4.0/cortex/connections/docs.py +56 -0
- delfhos-0.4.0/cortex/connections/drive.py +51 -0
- delfhos-0.4.0/cortex/connections/gmail.py +63 -0
- delfhos-0.4.0/cortex/connections/mcp.py +180 -0
- delfhos-0.4.0/cortex/connections/sheets.py +56 -0
- delfhos-0.4.0/cortex/connections/sql.py +98 -0
- delfhos-0.4.0/cortex/connections/websearch.py +48 -0
- delfhos-0.4.0/cortex/cortex.py +268 -0
- delfhos-0.4.0/cortex/google_auth.py +335 -0
- delfhos-0.4.0/cortex/tool_docs/__init__.py +47 -0
- delfhos-0.4.0/cortex/tool_docs/calendar.py +43 -0
- delfhos-0.4.0/cortex/tool_docs/drive.py +47 -0
- delfhos-0.4.0/cortex/tool_docs/files.py +43 -0
- delfhos-0.4.0/cortex/tool_docs/gdocs.py +38 -0
- delfhos-0.4.0/cortex/tool_docs/gmail.py +59 -0
- delfhos-0.4.0/cortex/tool_docs/llm.py +49 -0
- delfhos-0.4.0/cortex/tool_docs/sheets.py +44 -0
- delfhos-0.4.0/cortex/tool_docs/sql.py +49 -0
- delfhos-0.4.0/cortex/tool_docs/websearch.py +25 -0
- delfhos-0.4.0/delfhos/__init__.py +66 -0
- delfhos-0.4.0/delfhos/connections/__init__.py +32 -0
- delfhos-0.4.0/delfhos/errors.py +108 -0
- delfhos-0.4.0/delfhos/memory/__init__.py +4 -0
- delfhos-0.4.0/delfhos/memory/chat.py +62 -0
- delfhos-0.4.0/delfhos/memory/persistent.py +239 -0
- delfhos-0.4.0/delfhos/sandbox/__init__.py +4 -0
- delfhos-0.4.0/delfhos/sandbox/gmail.py +121 -0
- delfhos-0.4.0/delfhos/sandbox/sql.py +104 -0
- delfhos-0.4.0/delfhos/tool.py +566 -0
- delfhos-0.4.0/delfhos/tools/__init__.py +45 -0
- delfhos-0.4.0/delfhos/tools/mcp.py +5 -0
- delfhos-0.4.0/delfhos/tools/native.py +33 -0
- delfhos-0.4.0/delfhos.egg-info/PKG-INFO +454 -0
- delfhos-0.4.0/delfhos.egg-info/SOURCES.txt +111 -0
- delfhos-0.4.0/delfhos.egg-info/dependency_links.txt +1 -0
- delfhos-0.4.0/delfhos.egg-info/requires.txt +19 -0
- delfhos-0.4.0/delfhos.egg-info/top_level.txt +2 -0
- delfhos-0.4.0/pyproject.toml +63 -0
- delfhos-0.4.0/setup.cfg +4 -0
- delfhos-0.4.0/setup.py +4 -0
- delfhos-0.4.0/tests/test_approval_manager.py +122 -0
- delfhos-0.4.0/tests/test_confirm_policy.py +47 -0
- delfhos-0.4.0/tests/test_custom_tool_confirm.py +41 -0
- delfhos-0.4.0/tests/test_error_system.py +56 -0
- delfhos-0.4.0/tests/test_file_preview_helpers.py +50 -0
- delfhos-0.4.0/tests/test_google_auth.py +132 -0
- delfhos-0.4.0/tests/test_mcp_compiler.py +185 -0
- delfhos-0.4.0/tests/test_memory_integration.py +194 -0
- delfhos-0.4.0/tests/test_prefilter_compaction.py +33 -0
- delfhos-0.4.0/tests/test_typeddict.py +185 -0
delfhos-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
delfhos-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: delfhos
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Delfhos — AI agent SDK with typed connections and tool orchestration
|
|
5
|
+
Author-email: David Serrano <davidsd.2704@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/DavidFraifer/delfhos
|
|
8
|
+
Project-URL: Source, https://github.com/DavidFraifer/delfhos
|
|
9
|
+
Project-URL: Issues, https://github.com/DavidFraifer/delfhos/issues
|
|
10
|
+
Keywords: ai,agents,sdk,automation,mcp,gemini
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: google-genai>=1.0.0
|
|
24
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
25
|
+
Requires-Dist: requests>=2.28.0
|
|
26
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0.0
|
|
28
|
+
Requires-Dist: tenacity>=8.0.0
|
|
29
|
+
Requires-Dist: google-auth>=2.0.0
|
|
30
|
+
Requires-Dist: google-auth-oauthlib>=1.0.0
|
|
31
|
+
Requires-Dist: google-auth-httplib2>=0.1.0
|
|
32
|
+
Requires-Dist: google-api-python-client>=2.0.0
|
|
33
|
+
Provides-Extra: sql
|
|
34
|
+
Requires-Dist: psycopg2-binary<3.0,>=2.9; extra == "sql"
|
|
35
|
+
Requires-Dist: mysql-connector-python<9.0,>=8.0; extra == "sql"
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: build>=1.2.2; extra == "dev"
|
|
38
|
+
Requires-Dist: twine>=5.1.1; extra == "dev"
|
|
39
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# Delfhos
|
|
43
|
+
|
|
44
|
+
**Delfhos** is an open-source AI agent SDK. Give it connections to your tools and describe what you want in plain English — Delfhos takes care of the rest.
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from delfhos import Agent
|
|
48
|
+
from delfhos.tools import Gmail, SQL
|
|
49
|
+
|
|
50
|
+
gmail = Gmail(oauth_credentials="client_secrets.json")
|
|
51
|
+
db = SQL(url="postgresql://user:pass@host/mydb")
|
|
52
|
+
|
|
53
|
+
with Agent(tools=[gmail, db]) as agent:
|
|
54
|
+
agent.run("How many users signed up this week? Email a summary to the team.")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install delfhos
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Or from source:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git clone https://github.com/DavidFraifer/delfhos
|
|
69
|
+
cd delfhos
|
|
70
|
+
pip install -e .
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Requirements:** Python ≥ 3.9, a Gemini API key.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
export GEMINI_API_KEY="your-key-here"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Quickstart
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
python -m examples.PersistentMemory.memory_demo
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from delfhos import Agent
|
|
89
|
+
from delfhos.tools import WebSearch
|
|
90
|
+
|
|
91
|
+
with Agent(
|
|
92
|
+
tools=[WebSearch()],
|
|
93
|
+
system_prompt="You are a helpful research assistant.",
|
|
94
|
+
) as agent:
|
|
95
|
+
agent.run("What are the top 3 AI trends in 2026? Give a brief summary.")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Error Handling
|
|
101
|
+
|
|
102
|
+
Delfhos uses a unified error system in [delfhos/errors.py](delfhos/errors.py).
|
|
103
|
+
|
|
104
|
+
All SDK errors include:
|
|
105
|
+
1. A stable error code (for logs and support)
|
|
106
|
+
2. A clear message with context
|
|
107
|
+
3. A fix-oriented hint
|
|
108
|
+
|
|
109
|
+
Example output shape:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
❌ [ERR_TOOL_001] Delfhos Error
|
|
113
|
+
----------------------------------------
|
|
114
|
+
Message: Tool 'web_search' failed during execution: network timeout
|
|
115
|
+
----------------------------------------
|
|
116
|
+
💡 Hint: Review the arguments sent to the tool...
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Common error families:
|
|
120
|
+
|
|
121
|
+
| Code | Exception | Typical Cause |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `ERR_TOOL_001` | `ToolExecutionError` | Tool runtime failure |
|
|
124
|
+
| `ERR_TOOL_002` | `ToolDefinitionError` | Invalid custom tool definition |
|
|
125
|
+
| `ERR_CONN_001` | `ConnectionConfigurationError` | Missing/invalid connection config |
|
|
126
|
+
| `ERR_CONN_002` | `ConnectionFileNotFoundError` | Credentials file path not found |
|
|
127
|
+
| `ERR_ENV_001` | `EnvironmentKeyError` | Missing environment variable |
|
|
128
|
+
| `ERR_REQ_001` | `OptionalDependencyError` | Missing optional package |
|
|
129
|
+
| `ERR_MCP_001` | `MCPConnectionError` | MCP server start/connect issues |
|
|
130
|
+
|
|
131
|
+
Catch by base class when you want one handler for all SDK-level failures:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from delfhos.errors import DelfhosConfigError
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
agent.run("Send a summary email to the team")
|
|
138
|
+
except DelfhosConfigError as exc:
|
|
139
|
+
print(str(exc)) # Includes code + message + hint
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Notes:
|
|
143
|
+
1. Some errors keep compatibility with Python built-ins for existing code:
|
|
144
|
+
- `ToolDefinitionError` is also a `TypeError`
|
|
145
|
+
- `ConnectionConfigurationError` is also a `ValueError`
|
|
146
|
+
- `ConnectionFileNotFoundError` is also a `FileNotFoundError`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Authentication
|
|
151
|
+
|
|
152
|
+
All Google connections (Gmail, Sheets, Drive, Calendar, Docs) support three auth methods.
|
|
153
|
+
|
|
154
|
+
### Service Account (recommended for servers)
|
|
155
|
+
|
|
156
|
+
Download a service account JSON key from [Google Cloud Console](https://console.cloud.google.com/iam-admin/serviceaccounts), then:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from delfhos.connections import GmailConnection
|
|
160
|
+
|
|
161
|
+
gmail = GmailConnection(
|
|
162
|
+
service_account="path/to/service-account.json",
|
|
163
|
+
delegated_user="admin@company.com", # impersonate a Workspace user
|
|
164
|
+
actions=["read"], # optional: restrict capabilities
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
> **Note:** Service accounts require Google Workspace and domain-wide delegation enabled by a Workspace admin.
|
|
169
|
+
|
|
170
|
+
### OAuth Client Secrets (for personal accounts)
|
|
171
|
+
|
|
172
|
+
Download a `client_secrets.json` from [Cloud Console → Credentials](https://console.cloud.google.com/apis/credentials):
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
gmail = GmailConnection(
|
|
176
|
+
oauth_credentials="path/to/client_secrets.json",
|
|
177
|
+
actions=["read", "send"],
|
|
178
|
+
)
|
|
179
|
+
# First run: opens browser for consent → token cached to ~/.cortex/tokens/
|
|
180
|
+
# Subsequent runs: token loaded automatically and refreshed if expired.
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Action restrictions & scope mapping
|
|
184
|
+
|
|
185
|
+
The `actions` parameter controls **what the agent can do** and **what OAuth scopes are requested** — minimal privilege by default:
|
|
186
|
+
|
|
187
|
+
| Connection | Action | Scope requested |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| Gmail | `read` | `gmail.readonly` |
|
|
190
|
+
| Gmail | `send` | `gmail.send` |
|
|
191
|
+
| Gmail | *(all)* | `gmail.modify` |
|
|
192
|
+
| Sheets | `read` | `spreadsheets.readonly` |
|
|
193
|
+
| Sheets | `write`, `create` | `spreadsheets` |
|
|
194
|
+
| Drive | `search`, `get` | `drive.readonly` |
|
|
195
|
+
| Drive | `create`, `update`, `delete`, `share` | `drive` |
|
|
196
|
+
| Calendar | `list` | `calendar.readonly` |
|
|
197
|
+
| Calendar | `create`, `update`, `delete` | `calendar` |
|
|
198
|
+
| Docs | `read` | `documents.readonly` |
|
|
199
|
+
| Docs | `create`, `update`, `delete` | `documents` + `drive` |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## SQL Authentication
|
|
204
|
+
|
|
205
|
+
`SQLConnection` supports both full connection URLs and individual parameters.
|
|
206
|
+
|
|
207
|
+
### Connection URL
|
|
208
|
+
```python
|
|
209
|
+
from delfhos.connections import SQLConnection
|
|
210
|
+
db = SQLConnection(url="postgresql://user:pass@host:5432/dbname")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Individual Parameters
|
|
214
|
+
Recommended if your password contains special characters (like `@`) that would otherwise need URL-encoding.
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
db = SQLConnection(
|
|
218
|
+
host="db.example.co",
|
|
219
|
+
port=5432,
|
|
220
|
+
database="postgres",
|
|
221
|
+
user="postgres",
|
|
222
|
+
password="your-password",
|
|
223
|
+
db_type="postgresql" # or "mysql"
|
|
224
|
+
)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Built-in Connections
|
|
230
|
+
|
|
231
|
+
| Connection | Auth | What it does |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| `WebSearchConnection` | None | Search the web |
|
|
234
|
+
| `GmailConnection` | SA / OAuth | Read and send emails |
|
|
235
|
+
| `SQLConnection` | URL | Query PostgreSQL / MySQL databases |
|
|
236
|
+
| `SheetsConnection` | SA / OAuth | Read and write Google Sheets |
|
|
237
|
+
| `DriveConnection` | SA / OAuth | Upload, organize, and share files |
|
|
238
|
+
| `CalendarConnection` | SA / OAuth | Create and manage calendar events |
|
|
239
|
+
| `DocsConnection` | SA / OAuth | Create and edit Google Docs |
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
# Multiple accounts of the same type
|
|
243
|
+
work = GmailConnection(service_account="sa.json", delegated_user="work@co.com", name="work")
|
|
244
|
+
inbox = GmailConnection(oauth_credentials="secrets.json", name="personal")
|
|
245
|
+
|
|
246
|
+
agent = Agent(connections=[work, inbox, db])
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Supported Models
|
|
252
|
+
|
|
253
|
+
Delfhos supports multiple LLM providers:
|
|
254
|
+
|
|
255
|
+
| Provider | Model | Notes |
|
|
256
|
+
|---|---|---|
|
|
257
|
+
| Google | `gemini-2.5-flash` | Default, fast |
|
|
258
|
+
| Google | `gemini-2.5-flash-lite` | Lighter, cheaper |
|
|
259
|
+
| Google | `gemini-3-flash-preview` | Preview |
|
|
260
|
+
| Google | `gemini-3.1-flash-lite-preview` | Latest lite |
|
|
261
|
+
| Inception | `mercury-2` | Diffusion-based, very fast |
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
agent = Agent(
|
|
265
|
+
connections=[...],
|
|
266
|
+
light_llm="mercury-2",
|
|
267
|
+
heavy_llm="mercury-2",
|
|
268
|
+
)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
> **Note:** Mercury-2 requires an `INCEPTION_AI` API key in your `.env` file.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Agent Options
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
agent = Agent(
|
|
279
|
+
connections=[...],
|
|
280
|
+
system_prompt="You are a finance assistant.", # optional role description
|
|
281
|
+
confirm="write", # deployment-time confirm policy
|
|
282
|
+
on_confirm=my_confirm_callback, # auto-enables approval callbacks
|
|
283
|
+
validation_mode=True, # dry-run, no real writes
|
|
284
|
+
light_llm="gemini-3.1-flash-lite-preview", # fast model for filtering
|
|
285
|
+
heavy_llm="gemini-3.1-flash-lite-preview", # powerful model for code gen
|
|
286
|
+
)
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Run modes
|
|
290
|
+
|
|
291
|
+
```python
|
|
292
|
+
agent.run_async("Do something") # async, fire and forget (returns immediately)
|
|
293
|
+
agent.run("Do something", timeout=60) # blocks until done (synchronous)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Context manager (Recommended)
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
with Agent(tools=[...]) as agent:
|
|
300
|
+
agent.run("Generate the monthly report.")
|
|
301
|
+
```
|
|
302
|
+
Using the context manager ensures that memory persists correctly when the session exits.
|
|
303
|
+
|
|
304
|
+
### Default Memory and Chat settings
|
|
305
|
+
If you add `Memory` to your agent, a `Chat(keep=8, summarize=True)` instance is automatically configured:
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
from delfhos import Agent, Memory
|
|
309
|
+
|
|
310
|
+
# Sensible defaults for chat memory are handled automatically
|
|
311
|
+
with Agent(tools=[...], memory=Memory("~/.delfhos/agent_memory.db")) as agent:
|
|
312
|
+
agent.run("Process overdue invoices")
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Human approval
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
with Agent(tools=[...], enable_human_approval=True) as agent:
|
|
319
|
+
agent.run("Delete all files older than 90 days.")
|
|
320
|
+
|
|
321
|
+
pending = agent.get_pending_approvals()
|
|
322
|
+
agent.approve(pending[0]["request_id"]) # or agent.reject(...)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
If you provide `on_confirm=...`, approval is enabled automatically. Use `enable_human_approval=True` when you want manual approve/reject flow without a callback.
|
|
326
|
+
Recommended callback return is `bool` (or `(bool, "reason")` for an explicit message).
|
|
327
|
+
|
|
328
|
+
`confirm` policy is unified across tool types:
|
|
329
|
+
- Agent deployment policy: `confirm=["send", "delete"]`
|
|
330
|
+
- Tool static nature: pass `kind="send"` in `@tool(...)`
|
|
331
|
+
- Hard override: `@tool(confirm=True)` always requires confirmation, regardless of agent policy
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Creating Custom Tools
|
|
336
|
+
|
|
337
|
+
Delfhos makes it very easy to inject your own APIs, scraping scripts, or internal systems as tools. Define functions and decorate them with `@tool`.
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
from delfhos import Agent, tool
|
|
341
|
+
|
|
342
|
+
# Define your logic
|
|
343
|
+
@tool(kind="read")
|
|
344
|
+
async def check_inventory(product_id: str) -> str:
|
|
345
|
+
"""Mock checking a product database."""
|
|
346
|
+
return f"Product {product_id} has 42 units in stock."
|
|
347
|
+
|
|
348
|
+
# Pass it to the agent alongside built-in connections
|
|
349
|
+
with Agent(
|
|
350
|
+
tools=[check_inventory],
|
|
351
|
+
system_prompt="You are a warehouse assistant."
|
|
352
|
+
) as agent:
|
|
353
|
+
agent.run("How many units of product 12345 do we have?")
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
See **[examples/CustomTools/custom_tool_example.py](examples/CustomTools/custom_tool_example.py)** for a full script using `@tool`.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Adding a Custom Connection
|
|
361
|
+
|
|
362
|
+
If your tool requires OAuth or deep integration with the internal Cortex engine, follow the structure below and mirror patterns in `cortex/connections/` and `cortex/_engine/tools/`.
|
|
363
|
+
|
|
364
|
+
In short, you need to create 4 things:
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
cortex/connections/slack.py ← credentials + config
|
|
368
|
+
cortex/tool_docs/slack.py ← what the LLM knows about this tool
|
|
369
|
+
cortex/_engine/tools/slack/ ← execution code (the actual API calls)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Then register it in `cortex/tool_docs/__init__.py`, `cortex/connections/__init__.py`, and `cortex/__init__.py`.
|
|
373
|
+
|
|
374
|
+
For Google services, subclass `GoogleBaseConnection` instead of `BaseConnection` to get service account + OAuth support for free.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Project Structure
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
delfhos/ ← Public API (import from here)
|
|
382
|
+
├── __init__.py # Agent + connections re-exports
|
|
383
|
+
└── connections/
|
|
384
|
+
└── __init__.py # All connection classes
|
|
385
|
+
|
|
386
|
+
cortex/ ← Internal engine
|
|
387
|
+
├── __init__.py
|
|
388
|
+
├── cortex.py # Cortex class (the agent)
|
|
389
|
+
├── google_auth.py # Google auth: scope mapping, SA/OAuth loaders
|
|
390
|
+
│
|
|
391
|
+
├── connections/ # User-facing: one file per service
|
|
392
|
+
│ ├── base.py # BaseConnection + GoogleBaseConnection
|
|
393
|
+
│ ├── gmail.py
|
|
394
|
+
│ ├── sql.py
|
|
395
|
+
│ └── ...
|
|
396
|
+
│
|
|
397
|
+
├── tool_docs/ # LLM prompt documentation for each tool
|
|
398
|
+
│ ├── gmail.py # (ACTIONS, PYTHON_API, EXAMPLES)
|
|
399
|
+
│ └── ...
|
|
400
|
+
│
|
|
401
|
+
└── _engine/ # Internal engine (you don't need to touch this)
|
|
402
|
+
├── agent.py # Orchestration loop
|
|
403
|
+
├── connection.py # Connection base class + manager
|
|
404
|
+
├── internal/llm.py # Multi-provider LLM abstraction
|
|
405
|
+
└── tools/ # Tool executors (actual API call implementations)
|
|
406
|
+
|
|
407
|
+
examples/
|
|
408
|
+
├── Advanced/ # Multi-tool and model comparison demos
|
|
409
|
+
├── ChatMemory/ # Chat memory and summarization demos
|
|
410
|
+
├── CustomTools/ # @tool and confirmation policy demos
|
|
411
|
+
├── MCPTools/ # MCP integration demos
|
|
412
|
+
├── NativeTools/ # Built-in Gmail/SQL/WebSearch flows
|
|
413
|
+
└── PersistentMemory/ # Persistent memory demos
|
|
414
|
+
|
|
415
|
+
tests/ # Unit and integration-style automated tests
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
> **Note:** The `_engine/` directory is the internal implementation. You only need to look in there if you're adding execution code for a new tool.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## Publishing
|
|
423
|
+
|
|
424
|
+
### PyPI package build and validation
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
python -m pip install --upgrade build twine
|
|
428
|
+
python -m build
|
|
429
|
+
python -m twine check dist/*
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Upload to PyPI
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
# TestPyPI first (recommended)
|
|
436
|
+
python -m twine upload --repository testpypi dist/*
|
|
437
|
+
|
|
438
|
+
# Production PyPI
|
|
439
|
+
python -m twine upload dist/*
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### GitHub release checklist
|
|
443
|
+
|
|
444
|
+
1. Ensure `pyproject.toml` version matches release tag (for example `v0.4.0`).
|
|
445
|
+
2. Commit and push all release changes.
|
|
446
|
+
3. Create and push an annotated git tag.
|
|
447
|
+
4. Create a GitHub Release from that tag with highlights and migration notes.
|
|
448
|
+
5. Validate install from a clean environment: `pip install delfhos==<version>`.
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## License
|
|
453
|
+
|
|
454
|
+
[Apache 2.0](LICENSE)
|