sinapsis_core 1.0.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.
- sinapsis_core-1.0.0/.gitignore +49 -0
- sinapsis_core-1.0.0/LICENSE-APACHE +202 -0
- sinapsis_core-1.0.0/LICENSE-MIT +21 -0
- sinapsis_core-1.0.0/PKG-INFO +239 -0
- sinapsis_core-1.0.0/README.md +219 -0
- sinapsis_core-1.0.0/pyproject.toml +76 -0
- sinapsis_core-1.0.0/src/sinapsis_core/__init__.py +0 -0
- sinapsis_core-1.0.0/src/sinapsis_core/agent/__init__.py +5 -0
- sinapsis_core-1.0.0/src/sinapsis_core/agent/agent.py +362 -0
- sinapsis_core-1.0.0/src/sinapsis_core/agent/agent_helpers.py +112 -0
- sinapsis_core-1.0.0/src/sinapsis_core/agent/base_models.py +361 -0
- sinapsis_core-1.0.0/src/sinapsis_core/agent/builder.py +112 -0
- sinapsis_core-1.0.0/src/sinapsis_core/agent/profiler_agent.py +117 -0
- sinapsis_core-1.0.0/src/sinapsis_core/cli/__init__.py +0 -0
- sinapsis_core-1.0.0/src/sinapsis_core/cli/arg_parser.py +29 -0
- sinapsis_core-1.0.0/src/sinapsis_core/cli/display_template_info.py +202 -0
- sinapsis_core-1.0.0/src/sinapsis_core/cli/run_agent_from_config.py +40 -0
- sinapsis_core-1.0.0/src/sinapsis_core/context_managers/__init__.py +0 -0
- sinapsis_core-1.0.0/src/sinapsis_core/context_managers/env_var_override_context_manager.py +39 -0
- sinapsis_core-1.0.0/src/sinapsis_core/context_managers/working_dir_context_manager.py +57 -0
- sinapsis_core-1.0.0/src/sinapsis_core/data_containers/__init__.py +0 -0
- sinapsis_core-1.0.0/src/sinapsis_core/data_containers/annotations.py +152 -0
- sinapsis_core-1.0.0/src/sinapsis_core/data_containers/data_packet.py +364 -0
- sinapsis_core-1.0.0/src/sinapsis_core/data_containers/model_types/__init__.py +38 -0
- sinapsis_core-1.0.0/src/sinapsis_core/data_containers/model_types/_asr_base_models.py +39 -0
- sinapsis_core-1.0.0/src/sinapsis_core/data_containers/model_types/llm_types.py +189 -0
- sinapsis_core-1.0.0/src/sinapsis_core/exceptions/agent_exceptions.py +2 -0
- sinapsis_core-1.0.0/src/sinapsis_core/hooks/__init__.py +15 -0
- sinapsis_core-1.0.0/src/sinapsis_core/hooks/pre_init_hook_registry.py +225 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/__init__.py +10 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/base_models.py +59 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/copy_data_container.py +46 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/dynamic_template.py +169 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/dynamic_template_factory.py +454 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/dynamic_template_helpers/__init__.py +0 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/dynamic_template_helpers/builder_methods.py +92 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/dynamic_template_helpers/signature_parser.py +625 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/empty_data_container.py +23 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/input_template.py +8 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/merge_data_flow.py +33 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/multi_execute_template.py +65 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/output_template.py +8 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/split_data_flow.py +50 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/template.py +292 -0
- sinapsis_core-1.0.0/src/sinapsis_core/template_base/transfer_data_container.py +13 -0
- sinapsis_core-1.0.0/src/sinapsis_core/utils/__init__.py +0 -0
- sinapsis_core-1.0.0/src/sinapsis_core/utils/base_model_updater.py +148 -0
- sinapsis_core-1.0.0/src/sinapsis_core/utils/doc_string_generator.py +20 -0
- sinapsis_core-1.0.0/src/sinapsis_core/utils/env_var_keys.py +249 -0
- sinapsis_core-1.0.0/src/sinapsis_core/utils/env_var_utils.py +6 -0
- sinapsis_core-1.0.0/src/sinapsis_core/utils/logging_utils.py +53 -0
- sinapsis_core-1.0.0/uv.lock +377 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
.Python
|
|
8
|
+
build/
|
|
9
|
+
develop-eggs/
|
|
10
|
+
dist/
|
|
11
|
+
downloads/
|
|
12
|
+
eggs/
|
|
13
|
+
.eggs/
|
|
14
|
+
lib/
|
|
15
|
+
lib64/
|
|
16
|
+
parts/
|
|
17
|
+
sdist/
|
|
18
|
+
var/
|
|
19
|
+
wheels/
|
|
20
|
+
share/python-wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
MANIFEST
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
.pdm.toml
|
|
28
|
+
.pdm-python
|
|
29
|
+
.pdm-build/
|
|
30
|
+
|
|
31
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
32
|
+
__pypackages__/
|
|
33
|
+
|
|
34
|
+
# Environments
|
|
35
|
+
.env
|
|
36
|
+
.venv
|
|
37
|
+
env/
|
|
38
|
+
venv/
|
|
39
|
+
ENV/
|
|
40
|
+
env.bak/
|
|
41
|
+
venv.bak/
|
|
42
|
+
|
|
43
|
+
# mypy
|
|
44
|
+
.mypy_cache/
|
|
45
|
+
.dmypy.json
|
|
46
|
+
dmypy.json
|
|
47
|
+
|
|
48
|
+
artifacts/*
|
|
49
|
+
.vscode/*
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sinapsis Group Limited
|
|
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. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sinapsis_core
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: sinapsis core agent and template implementation
|
|
5
|
+
Project-URL: Homepage, https://sinapsis.tech
|
|
6
|
+
Project-URL: Documentation, https://docs.sinapsis.tech/docs
|
|
7
|
+
Project-URL: Tutorials, https://docs.sinapsis.tech/docs/latest/tutorials
|
|
8
|
+
Project-URL: Repository, https://github.com/SinapsisHub/sinapsis-hub.git
|
|
9
|
+
Author-email: Ariel Ruiz-Garcia <ariel@sinapsis.tech>
|
|
10
|
+
Maintainer-email: sinapsis <dev@sinapsis.tech>, Nimesh Patel <nimesh@sinapsis.tech>
|
|
11
|
+
License-Expression: MIT OR Apache-2.0
|
|
12
|
+
License-File: LICENSE-APACHE
|
|
13
|
+
License-File: LICENSE-MIT
|
|
14
|
+
Requires-Python: >=3.13
|
|
15
|
+
Requires-Dist: docstring-parser>=0.16
|
|
16
|
+
Requires-Dist: loguru>=0.7.3
|
|
17
|
+
Requires-Dist: pydantic>=2.8.2
|
|
18
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
<h1 align="center">
|
|
22
|
+
<br>
|
|
23
|
+
<a href="https://sinapsis.tech/">
|
|
24
|
+
<img
|
|
25
|
+
src="https://github.com/SinapsisHub/brand-resources/blob/main/public/logo/sinapsis-logo-horizontal-dark-brand.png?raw=true"
|
|
26
|
+
alt="Sinapsis"
|
|
27
|
+
width="300">
|
|
28
|
+
</a>
|
|
29
|
+
<br>
|
|
30
|
+
sinapsis-core
|
|
31
|
+
<br>
|
|
32
|
+
</h1>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<strong>Agent graphs · Template execution · Shared data semantics</strong>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
`sinapsis-core` implements the Agent and Template runtime and owns the `DataContainer` and typed Packet models behind Sinapsis. This document describes the computational model and the contracts that other framework components depend on. It is not an installation guide or a catalogue of integrations.
|
|
39
|
+
|
|
40
|
+
## 1. Runtime model
|
|
41
|
+
|
|
42
|
+
Sinapsis separates **the description of a computation** from **the objects that execute it** and **the data exchanged during execution**.
|
|
43
|
+
|
|
44
|
+
```mermaid
|
|
45
|
+
flowchart TD
|
|
46
|
+
D["Agent definition<br/>declarative configuration"] --> V["AgentSchema<br/>Pydantic validation and graph resolution"]
|
|
47
|
+
V --> R["Agent runtime<br/>template instantiation and orchestration"]
|
|
48
|
+
R --> T1["Template instance A"]
|
|
49
|
+
R --> T2["Template instance B"]
|
|
50
|
+
T1 -->|"DataContainer"| T2
|
|
51
|
+
T2 --> O["Results / completion"]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Concept | Meaning | Responsibility |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| **Agent definition** | User-supplied description of a computational graph. | Names template nodes, selects implementations, configures attributes, and declares dependencies. |
|
|
57
|
+
| **`AgentSchema`** | Validated, normalized representation of that definition. | Enforces the canonical graph and configuration rules and records information derived during validation. |
|
|
58
|
+
| **Agent runtime** | Live orchestration object created from a valid definition. | Instantiates and coordinates Templates, manages execution and completion, and produces results. |
|
|
59
|
+
| **Template instance** | Configured instance of a reusable Python computation. | Performs one unit of work under the runtime's input/output and lifecycle conventions. |
|
|
60
|
+
| **`DataContainer` / Packet** | Shared computation-level data model. | Moves multimodal content and associated metadata between Templates. |
|
|
61
|
+
|
|
62
|
+
These concepts must remain distinct: **validating an Agent does not instantiate or execute it**, and a runtime instance is not a substitute for its serializable definition.
|
|
63
|
+
|
|
64
|
+
## 2. Agent definitions and graph semantics
|
|
65
|
+
|
|
66
|
+
An Agent is a directed graph whose nodes are **Template instances** and whose edges express declared input dependencies. The graph describes *what depends on what*, rather than prescribing which Python method must call which other method.
|
|
67
|
+
|
|
68
|
+
A node declaration has several separate identities:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
- template_name: DetectObjects
|
|
72
|
+
class_name: ObjectDetector
|
|
73
|
+
template_input: DecodeImage
|
|
74
|
+
attributes:
|
|
75
|
+
confidence: 0.5
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Field | Semantics |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `template_name` | Identifies this **instance** within the Agent graph. Multiple nodes may use the same Template class but must remain distinguishable as instances. |
|
|
81
|
+
| `class_name` | Identifies the Template **implementation** to resolve in the installed environment. |
|
|
82
|
+
| `template_input` | Refers to the upstream node supplying input; it is a graph edge, not a direct Python invocation. |
|
|
83
|
+
| `attributes` | Supplies configuration for this node, validated according to its Template's typed attribute model. |
|
|
84
|
+
|
|
85
|
+
The fragment illustrates the relationship; the referenced class and its attributes are examples, not built-in core implementations.
|
|
86
|
+
|
|
87
|
+
### Dependency resolution
|
|
88
|
+
|
|
89
|
+
The runtime uses graph dependencies to determine valid execution order, including **topological sorting**. An upstream node must supply the data needed by its dependent node. Independent portions of a graph can be candidates for parallel execution; the actual scheduling strategy is a runtime concern, not a guarantee implied by configuration order.
|
|
90
|
+
|
|
91
|
+
```mermaid
|
|
92
|
+
flowchart LR
|
|
93
|
+
A[Input] --> B[Preprocess]
|
|
94
|
+
B --> C[Vision model]
|
|
95
|
+
B --> D[Metadata extraction]
|
|
96
|
+
C --> E[Postprocess]
|
|
97
|
+
D --> E
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The graph's textual order is not the authoritative execution order. When changing graph validation or scheduling, preserve the distinction between **dependency ordering**, **runtime readiness**, and **completion**: a node can exist in the graph without being ready to run, and repeated execution is possible under non-single modes.
|
|
101
|
+
|
|
102
|
+
### Canonical validation
|
|
103
|
+
|
|
104
|
+
The framework has **one** authoritative Agent-graph builder, exposed by the stable `sinapsis` interface:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from sinapsis.agent import AgentSchema, generic_agent_schema_builder
|
|
108
|
+
|
|
109
|
+
agent_schema: AgentSchema = generic_agent_schema_builder(agent_definition)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
> **Import convention:** Although `AgentSchema` and `generic_agent_schema_builder` are implemented in `sinapsis-core`, they are exposed through the `sinapsis` package, which provides the stable public API.
|
|
113
|
+
>
|
|
114
|
+
> Consumers should import from `sinapsis` to avoid coupling their code to internal implementation details. Internal modules within `sinapsis-core` may use direct imports where appropriate.
|
|
115
|
+
|
|
116
|
+
The builder returns the canonical `AgentSchema`. Its output may contain derived graph structures such as `sorted_templates`, `template_mapping_dict`, or `sorted_templates_as_dict`. These are part of the validated representation: consumers must not discard them, invent a competing schema, or coerce typed values (for example, numeric `template_type` values) into different representations.
|
|
117
|
+
|
|
118
|
+
**Pydantic is the schema boundary**, not a replacement for runtime coordination. It validates models and configuration; the Agent runtime still owns execution state, scheduling, and lifecycle transitions.
|
|
119
|
+
|
|
120
|
+
## 3. Template semantics
|
|
121
|
+
|
|
122
|
+
A Template wraps an individual Python computation behind the framework's configuration, lifecycle, and input/output conventions. Its implementation may use any suitable library, model, API, or ordinary Python code; the Agent interacts with it through the common Template contract.
|
|
123
|
+
|
|
124
|
+
### Configuration versus instance state
|
|
125
|
+
|
|
126
|
+
Template **attributes** describe how a node should behave (for example, model selection or thresholds). A running Template may also hold **state** (for example, initialized resources, iterators, cached models, or progress across inputs). These are different concerns:
|
|
127
|
+
|
|
128
|
+
- Attribute validation establishes the configured shape and types before or during instantiation.
|
|
129
|
+
- Initialization may be eager or lazy, depending on the Template and runtime configuration.
|
|
130
|
+
- Execution consumes framework data and produces framework data under the shared contract.
|
|
131
|
+
- Reset, attribute updates, completion, and stopping are lifecycle operations; they should not be confused with reconstructing the Agent definition.
|
|
132
|
+
|
|
133
|
+
The framework's conventional processing boundary is **one `DataContainer` input and one `DataContainer` output** for a Template invocation. A container may itself hold many packets across modalities. A streaming or iterative Agent can process many such invocations over its lifetime.
|
|
134
|
+
|
|
135
|
+
### Composition
|
|
136
|
+
|
|
137
|
+
A **composite Template** or **SubAgent** encapsulates a more complex computation behind a Template-level interface. This allows a parent Agent to treat a nested workflow as a reusable unit while the nested structure retains its own internal execution semantics.
|
|
138
|
+
|
|
139
|
+
Composition does not imply that every nested operation shares one process, one set of dependencies, or one scheduling policy; those are execution-environment concerns.
|
|
140
|
+
|
|
141
|
+
## 4. Agent execution and lifecycle
|
|
142
|
+
|
|
143
|
+
The orchestration layer resolves graph dependencies, manages Template instances, advances their execution, and tracks whether further work is available or the Agent should terminate.
|
|
144
|
+
|
|
145
|
+
A useful conceptual lifecycle is:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
Agent definition
|
|
149
|
+
│
|
|
150
|
+
▼
|
|
151
|
+
Validate / normalize graph
|
|
152
|
+
│
|
|
153
|
+
▼
|
|
154
|
+
Resolve and create Template instances
|
|
155
|
+
│ (possibly with lazy resource initialization)
|
|
156
|
+
▼
|
|
157
|
+
Determine ready Templates from graph and runtime state
|
|
158
|
+
│
|
|
159
|
+
▼
|
|
160
|
+
Execute Templates / propagate DataContainers
|
|
161
|
+
│
|
|
162
|
+
├── more work available ──► continue
|
|
163
|
+
│
|
|
164
|
+
├── blocked / waiting ────► coordinate readiness
|
|
165
|
+
│
|
|
166
|
+
└── completed / stopped ──► finish execution
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The runtime also supports blocking and completion signalling where needed. Those signals are **control state**, not extra modality data to insert into a `DataContainer`.
|
|
170
|
+
|
|
171
|
+
### Execution modes
|
|
172
|
+
|
|
173
|
+
| Mode | Termination semantics | Typical data behavior |
|
|
174
|
+
| --- | --- | --- |
|
|
175
|
+
| **Single** | Execute a workflow once. | Produces a result for that execution. |
|
|
176
|
+
| **Generator** | Advance through successive inputs/results until the participating Templates finish. | Suitable for finite streams, datasets, or iterators. |
|
|
177
|
+
| **Continuous** | Continue processing until explicitly stopped. | Suitable for live sources; outputs are often consumed or persisted as they are produced. |
|
|
178
|
+
|
|
179
|
+
The mode governs **how execution progresses and ends**; it does not change the Template or `DataContainer` contracts. The precise Python entry point and result-consumption mechanism are determined by the caller/runner.
|
|
180
|
+
|
|
181
|
+
## 5. DataContainer and Packet semantics
|
|
182
|
+
|
|
183
|
+
`DataContainer` and the typed Packet models are **defined in `sinapsis-core`**. Together they form Sinapsis's **universal data transport (UDT) contract** at Template boundaries. A container is a structured collection of content, not a requirement that every Template understand every modality.
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
DataContainer
|
|
187
|
+
├── container_id
|
|
188
|
+
├── llm_conversations[] → LLmconversationPacket
|
|
189
|
+
├── images[] → ImagePacket
|
|
190
|
+
├── audios[] → AudioPacket
|
|
191
|
+
├── texts[] → TextPacket
|
|
192
|
+
├── time_series[] → TimeSeriesPacket
|
|
193
|
+
├── binary_data[] → BinaryPacket
|
|
194
|
+
└── generic_data{} → additional structured values
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The collections above illustrate the core data model; exact field types and optional metadata are defined by the `sinapsis-core` Pydantic models.
|
|
198
|
+
|
|
199
|
+
### Container versus Packet
|
|
200
|
+
|
|
201
|
+
- A **container** is the unit exchanged between Template invocations. One container can carry zero, one, or many packets, including multiple modalities at once.
|
|
202
|
+
- A **Packet** represents an individual content item plus metadata relevant to that item. Packet schemas preserve modality-specific structure instead of flattening everything into untyped dictionaries.
|
|
203
|
+
- **`generic_data`** accommodates structured values without a suitable native packet type. Use typed packets when one exists, so downstream Templates retain a predictable contract.
|
|
204
|
+
|
|
205
|
+
| Packet | Represents | Examples of modality-specific context |
|
|
206
|
+
| --- | --- | --- |
|
|
207
|
+
| `ImagePacket` | Image content, including individual video frames where appropriate. | Colour space, boxes, keypoints, segmentation annotations. |
|
|
208
|
+
| `AudioPacket` | Audio content. | Sample rate, duration. |
|
|
209
|
+
| `TextPacket` | Text content. | Language or token-related information. |
|
|
210
|
+
| `TimeSeriesPacket` | Temporal observations or forecasts. | Time indexes, past/future covariates. |
|
|
211
|
+
| `BinaryPacket` | Binary payloads. | Content carried without requiring a modality-specific interpretation. |
|
|
212
|
+
|
|
213
|
+
Some packet models also record **provenance** (for example, `source` or `modified_by_templates`) and annotations. These fields describe the individual item's history or interpretation, not the Agent's scheduling state. Preserve them when transforming a packet unless the operation explicitly changes their meaning.
|
|
214
|
+
|
|
215
|
+
### Data flow is not wire serialization
|
|
216
|
+
|
|
217
|
+
`DataContainer` defines the **logical in-memory contract**. Encoding its content for network transport, streams, databases, or object storage is a separate responsibility. A serialization layer must preserve typed content and metadata; a plain JSON conversion is not automatically suitable for arbitrary binary or numerical payloads.
|
|
218
|
+
|
|
219
|
+
Likewise, the contract does not guarantee automatic cloning or merging of containers at every graph edge. Copying, mutation, fan-out, and fan-in behavior must follow the actual Template/runtime implementation rather than assumptions made by an integration.
|
|
220
|
+
|
|
221
|
+
## 6. Architectural boundaries and invariants
|
|
222
|
+
|
|
223
|
+
`sinapsis-core` owns the **Agent runtime, Template contracts, and universal data transport models** (`DataContainer` and typed Packets). The separate `sinapsis` distribution supplies the **stable public import surface** over those implementations. Serialization and remote-transport integrations may live in other packages, but the in-memory data model itself is part of `sinapsis-core`.
|
|
224
|
+
|
|
225
|
+
Core must remain independent of particular hosted services. Authentication, package publication, persistence, billing, remote scheduling, result streaming, and infrastructure scaling belong to surrounding components, not to the Agent graph model.
|
|
226
|
+
|
|
227
|
+
When working on the runtime, the important invariants are:
|
|
228
|
+
|
|
229
|
+
1. **One graph authority.** `generic_agent_schema_builder()` and `AgentSchema` define the canonical validated Agent representation. No parallel graph validator in the API, CLI, SDK, or Management layer.
|
|
230
|
+
2. **Distinct graph identities.** Preserve the difference between a Template's implementation class, its named graph instance, and an instantiated runtime object.
|
|
231
|
+
3. **Declarative edges.** `template_input` expresses dependencies; execution order is derived from graph and runtime state, not YAML position.
|
|
232
|
+
4. **Typed configuration.** Retain Pydantic validation and serialisation semantics, including derived fields in `model_dump(mode="json")`.
|
|
233
|
+
5. **Consistent data transport.** Maintain `DataContainer` and Packet contracts across Template boundaries; do not replace them with integration-specific interchange types.
|
|
234
|
+
6. **Explicit lifecycle semantics.** Keep initialization, execution, blocking, completion, reset, and stopping distinct, particularly across generator and continuous modes.
|
|
235
|
+
7. **Stable facade.** Internal refactors may change `sinapsis-core`, but must preserve the supported interfaces exported by `sinapsis`.
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
Unless otherwise noted, `sinapsis-core` is dual-licensed under **MIT OR Apache-2.0**. See `LICENSE-MIT` and `LICENSE-APACHE` in the Sinapsis Hub repository.
|