cliver-core 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. cliver_core-0.3.0/LICENSE +201 -0
  2. cliver_core-0.3.0/PKG-INFO +416 -0
  3. cliver_core-0.3.0/README.md +373 -0
  4. cliver_core-0.3.0/pyproject.toml +78 -0
  5. cliver_core-0.3.0/src/cliver_core/__init__.py +120 -0
  6. cliver_core-0.3.0/src/cliver_core/agent.py +2270 -0
  7. cliver_core-0.3.0/src/cliver_core/bindings.py +790 -0
  8. cliver_core-0.3.0/src/cliver_core/capabilities/__init__.py +54 -0
  9. cliver_core-0.3.0/src/cliver_core/capabilities/_base.py +47 -0
  10. cliver_core-0.3.0/src/cliver_core/capabilities/asr.py +82 -0
  11. cliver_core-0.3.0/src/cliver_core/capabilities/embed.py +62 -0
  12. cliver_core-0.3.0/src/cliver_core/capabilities/image.py +82 -0
  13. cliver_core-0.3.0/src/cliver_core/capabilities/rerank.py +65 -0
  14. cliver_core-0.3.0/src/cliver_core/capabilities/tts.py +74 -0
  15. cliver_core-0.3.0/src/cliver_core/capabilities/video.py +80 -0
  16. cliver_core-0.3.0/src/cliver_core/compaction.py +220 -0
  17. cliver_core-0.3.0/src/cliver_core/compactors.py +84 -0
  18. cliver_core-0.3.0/src/cliver_core/constants.py +3 -0
  19. cliver_core-0.3.0/src/cliver_core/errors.py +61 -0
  20. cliver_core-0.3.0/src/cliver_core/events.py +128 -0
  21. cliver_core-0.3.0/src/cliver_core/local/__init__.py +97 -0
  22. cliver_core-0.3.0/src/cliver_core/local/backends/__init__.py +93 -0
  23. cliver_core-0.3.0/src/cliver_core/local/backends/base.py +148 -0
  24. cliver_core-0.3.0/src/cliver_core/local/backends/common.py +155 -0
  25. cliver_core-0.3.0/src/cliver_core/local/backends/flag_embedding.py +175 -0
  26. cliver_core-0.3.0/src/cliver_core/local/backends/laya.py +175 -0
  27. cliver_core-0.3.0/src/cliver_core/local/backends/sentence_transformers.py +108 -0
  28. cliver_core-0.3.0/src/cliver_core/local/bindings.py +149 -0
  29. cliver_core-0.3.0/src/cliver_core/local/errors.py +64 -0
  30. cliver_core-0.3.0/src/cliver_core/local/info.py +29 -0
  31. cliver_core-0.3.0/src/cliver_core/local/providers.py +671 -0
  32. cliver_core-0.3.0/src/cliver_core/local/resolution.py +208 -0
  33. cliver_core-0.3.0/src/cliver_core/mcp/__init__.py +285 -0
  34. cliver_core-0.3.0/src/cliver_core/mcp/adapters.py +415 -0
  35. cliver_core-0.3.0/src/cliver_core/mcp/discovery.py +448 -0
  36. cliver_core-0.3.0/src/cliver_core/mcp/pool.py +198 -0
  37. cliver_core-0.3.0/src/cliver_core/media.py +348 -0
  38. cliver_core-0.3.0/src/cliver_core/media_jobs.py +64 -0
  39. cliver_core-0.3.0/src/cliver_core/messages.py +328 -0
  40. cliver_core-0.3.0/src/cliver_core/pipeline.py +318 -0
  41. cliver_core-0.3.0/src/cliver_core/policy.py +190 -0
  42. cliver_core-0.3.0/src/cliver_core/presets.py +546 -0
  43. cliver_core-0.3.0/src/cliver_core/provider/__init__.py +1070 -0
  44. cliver_core-0.3.0/src/cliver_core/provider/providers/__init__.py +308 -0
  45. cliver_core-0.3.0/src/cliver_core/provider/providers/anthropic.py +556 -0
  46. cliver_core-0.3.0/src/cliver_core/provider/providers/dashscope.py +452 -0
  47. cliver_core-0.3.0/src/cliver_core/provider/providers/deepseek.py +34 -0
  48. cliver_core-0.3.0/src/cliver_core/provider/providers/glm.py +23 -0
  49. cliver_core-0.3.0/src/cliver_core/provider/providers/minimax.py +163 -0
  50. cliver_core-0.3.0/src/cliver_core/provider/providers/ollama.py +27 -0
  51. cliver_core-0.3.0/src/cliver_core/provider/providers/openai.py +402 -0
  52. cliver_core-0.3.0/src/cliver_core/provider/providers/qwen.py +22 -0
  53. cliver_core-0.3.0/src/cliver_core/provider/providers/qwen_image.py +123 -0
  54. cliver_core-0.3.0/src/cliver_core/provider/providers/seedance.py +173 -0
  55. cliver_core-0.3.0/src/cliver_core/provider/providers/system_one.py +113 -0
  56. cliver_core-0.3.0/src/cliver_core/provider/transport.py +119 -0
  57. cliver_core-0.3.0/src/cliver_core/provider/transports/__init__.py +127 -0
  58. cliver_core-0.3.0/src/cliver_core/provider/transports/anthropic_sdk.py +131 -0
  59. cliver_core-0.3.0/src/cliver_core/provider/transports/openai_sdk.py +150 -0
  60. cliver_core-0.3.0/src/cliver_core/py.typed +0 -0
  61. cliver_core-0.3.0/src/cliver_core/run_ids.py +18 -0
  62. cliver_core-0.3.0/src/cliver_core/run_state.py +50 -0
  63. cliver_core-0.3.0/src/cliver_core/skill.py +482 -0
  64. cliver_core-0.3.0/src/cliver_core/skill_tools.py +327 -0
  65. cliver_core-0.3.0/src/cliver_core/structured.py +181 -0
  66. cliver_core-0.3.0/src/cliver_core/system_one/__init__.py +43 -0
  67. cliver_core-0.3.0/src/cliver_core/system_one/selector.py +316 -0
  68. cliver_core-0.3.0/src/cliver_core/system_one/types.py +135 -0
  69. cliver_core-0.3.0/src/cliver_core/system_one/wire.py +137 -0
  70. cliver_core-0.3.0/src/cliver_core/tests/__init__.py +0 -0
  71. cliver_core-0.3.0/src/cliver_core/tests/conftest.py +1 -0
  72. cliver_core-0.3.0/src/cliver_core/tests/fixtures/skills/test-code-review/SKILL.md +13 -0
  73. cliver_core-0.3.0/src/cliver_core/tests/fixtures/skills/test-greeting/SKILL.md +20 -0
  74. cliver_core-0.3.0/src/cliver_core/tests/fixtures/skills/test-greeting/references/phrases.md +3 -0
  75. cliver_core-0.3.0/src/cliver_core/tests/live/__init__.py +1 -0
  76. cliver_core-0.3.0/src/cliver_core/tests/live/support.py +112 -0
  77. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_agent_sessions.py +190 -0
  78. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_brands.py +107 -0
  79. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_context_compactor.py +198 -0
  80. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_contracts.py +82 -0
  81. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_failover.py +333 -0
  82. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_media.py +39 -0
  83. cliver_core-0.3.0/src/cliver_core/tests/live/test_live_system_one.py +217 -0
  84. cliver_core-0.3.0/src/cliver_core/tests/test_agent_async_tools.py +169 -0
  85. cliver_core-0.3.0/src/cliver_core/tests/test_agent_bindings.py +468 -0
  86. cliver_core-0.3.0/src/cliver_core/tests/test_agent_call_snapshot.py +65 -0
  87. cliver_core-0.3.0/src/cliver_core/tests/test_agent_events.py +127 -0
  88. cliver_core-0.3.0/src/cliver_core/tests/test_agent_execution_scope.py +453 -0
  89. cliver_core-0.3.0/src/cliver_core/tests/test_agent_failover.py +419 -0
  90. cliver_core-0.3.0/src/cliver_core/tests/test_agent_lifecycle.py +192 -0
  91. cliver_core-0.3.0/src/cliver_core/tests/test_agent_mcp_wiring.py +119 -0
  92. cliver_core-0.3.0/src/cliver_core/tests/test_agent_run_id.py +400 -0
  93. cliver_core-0.3.0/src/cliver_core/tests/test_agent_run_timeout.py +398 -0
  94. cliver_core-0.3.0/src/cliver_core/tests/test_agent_skills.py +612 -0
  95. cliver_core-0.3.0/src/cliver_core/tests/test_agent_tool_execution.py +416 -0
  96. cliver_core-0.3.0/src/cliver_core/tests/test_agent_usage.py +226 -0
  97. cliver_core-0.3.0/src/cliver_core/tests/test_binding_refresh.py +360 -0
  98. cliver_core-0.3.0/src/cliver_core/tests/test_binding_secrets.py +29 -0
  99. cliver_core-0.3.0/src/cliver_core/tests/test_bindings_failover.py +139 -0
  100. cliver_core-0.3.0/src/cliver_core/tests/test_bindings_loop_affinity.py +86 -0
  101. cliver_core-0.3.0/src/cliver_core/tests/test_capabilities.py +534 -0
  102. cliver_core-0.3.0/src/cliver_core/tests/test_chat_roundtrip.py +306 -0
  103. cliver_core-0.3.0/src/cliver_core/tests/test_client_options.py +184 -0
  104. cliver_core-0.3.0/src/cliver_core/tests/test_context_compactor.py +664 -0
  105. cliver_core-0.3.0/src/cliver_core/tests/test_core_closure.py +93 -0
  106. cliver_core-0.3.0/src/cliver_core/tests/test_dashscope.py +980 -0
  107. cliver_core-0.3.0/src/cliver_core/tests/test_inference_contracts.py +596 -0
  108. cliver_core-0.3.0/src/cliver_core/tests/test_llm_compactor.py +215 -0
  109. cliver_core-0.3.0/src/cliver_core/tests/test_local_live.py +150 -0
  110. cliver_core-0.3.0/src/cliver_core/tests/test_local_models.py +710 -0
  111. cliver_core-0.3.0/src/cliver_core/tests/test_mcp_adapters.py +461 -0
  112. cliver_core-0.3.0/src/cliver_core/tests/test_mcp_client.py +295 -0
  113. cliver_core-0.3.0/src/cliver_core/tests/test_mcp_discovery.py +340 -0
  114. cliver_core-0.3.0/src/cliver_core/tests/test_mcp_import_guard.py +75 -0
  115. cliver_core-0.3.0/src/cliver_core/tests/test_mcp_pool.py +369 -0
  116. cliver_core-0.3.0/src/cliver_core/tests/test_media_loading.py +72 -0
  117. cliver_core-0.3.0/src/cliver_core/tests/test_media_paths.py +1221 -0
  118. cliver_core-0.3.0/src/cliver_core/tests/test_messages_native.py +203 -0
  119. cliver_core-0.3.0/src/cliver_core/tests/test_pipeline.py +274 -0
  120. cliver_core-0.3.0/src/cliver_core/tests/test_policy.py +621 -0
  121. cliver_core-0.3.0/src/cliver_core/tests/test_presets.py +384 -0
  122. cliver_core-0.3.0/src/cliver_core/tests/test_provider_registry.py +231 -0
  123. cliver_core-0.3.0/src/cliver_core/tests/test_seedance.py +407 -0
  124. cliver_core-0.3.0/src/cliver_core/tests/test_skill_dispatch.py +376 -0
  125. cliver_core-0.3.0/src/cliver_core/tests/test_skill_preload.py +91 -0
  126. cliver_core-0.3.0/src/cliver_core/tests/test_skills.py +608 -0
  127. cliver_core-0.3.0/src/cliver_core/tests/test_structured_output.py +296 -0
  128. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_agent.py +119 -0
  129. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_bindings.py +66 -0
  130. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_local.py +502 -0
  131. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_presets.py +86 -0
  132. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_provider.py +154 -0
  133. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_selector.py +274 -0
  134. cliver_core-0.3.0/src/cliver_core/tests/test_system_one_types.py +178 -0
  135. cliver_core-0.3.0/src/cliver_core/tests/test_tool_registry.py +101 -0
  136. cliver_core-0.3.0/src/cliver_core/tests/test_transports.py +1266 -0
  137. cliver_core-0.3.0/src/cliver_core/tests/test_util_confirm.py +51 -0
  138. cliver_core-0.3.0/src/cliver_core/tests/test_versions_aligned.py +18 -0
  139. cliver_core-0.3.0/src/cliver_core/timeouts.py +57 -0
  140. cliver_core-0.3.0/src/cliver_core/tool.py +284 -0
  141. cliver_core-0.3.0/src/cliver_core/tools/__init__.py +44 -0
  142. cliver_core-0.3.0/src/cliver_core/tools/execute_code.py +123 -0
  143. cliver_core-0.3.0/src/cliver_core/tools/grep_search.py +134 -0
  144. cliver_core-0.3.0/src/cliver_core/tools/list_directory.py +104 -0
  145. cliver_core-0.3.0/src/cliver_core/tools/read_file.py +120 -0
  146. cliver_core-0.3.0/src/cliver_core/tools/run_shell_command.py +109 -0
  147. cliver_core-0.3.0/src/cliver_core/tools/todo_read.py +22 -0
  148. cliver_core-0.3.0/src/cliver_core/tools/todo_write.py +120 -0
  149. cliver_core-0.3.0/src/cliver_core/tools/web_fetch.py +164 -0
  150. cliver_core-0.3.0/src/cliver_core/tools/write_file.py +66 -0
  151. cliver_core-0.3.0/src/cliver_core/util.py +494 -0
@@ -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.
@@ -0,0 +1,416 @@
1
+ Metadata-Version: 2.4
2
+ Name: cliver-core
3
+ Version: 0.3.0
4
+ Summary: CLIver — embeddable AgentCore library
5
+ Keywords: ai,agents,llm,mcp,react-loop
6
+ Author: CLIver Project
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: pydantic>=2.0.0
20
+ Requires-Dist: openai>=3.0.0
21
+ Requires-Dist: anthropic>=1.0.0
22
+ Requires-Dist: httpx>=0.28.0
23
+ Requires-Dist: mcp>=2.3.0,<3.0
24
+ Requires-Dist: cliver-core[local-st] ; extra == 'local'
25
+ Requires-Dist: cliver-core[local-flag] ; extra == 'local'
26
+ Requires-Dist: cliver-core[local-laya] ; extra == 'local'
27
+ Requires-Dist: flagembedding>=1.3.0 ; extra == 'local-flag'
28
+ Requires-Dist: huggingface-hub>=0.24.0 ; extra == 'local-flag'
29
+ Requires-Dist: laya>=0.4.0 ; extra == 'local-laya'
30
+ Requires-Dist: sentence-transformers>=3.0 ; extra == 'local-st'
31
+ Requires-Dist: huggingface-hub>=0.24.0 ; extra == 'local-st'
32
+ Requires-Python: >=3.10
33
+ Project-URL: Changelog, https://github.com/cliver-project/CLIver/blob/main/CHANGELOG.md
34
+ Project-URL: Documentation, https://cliver-project.github.io/CLIver/
35
+ Project-URL: Homepage, https://github.com/cliver-project/CLIver
36
+ Project-URL: Issues, https://github.com/cliver-project/CLIver/issues
37
+ Project-URL: Repository, https://github.com/cliver-project/CLIver
38
+ Provides-Extra: local
39
+ Provides-Extra: local-flag
40
+ Provides-Extra: local-laya
41
+ Provides-Extra: local-st
42
+ Description-Content-Type: text/markdown
43
+
44
+ # cliver-core
45
+
46
+ The embeddable agent core behind [CLIver](https://github.com/cliver-project/CLIver): an agent loop
47
+ with tool calling, per-purpose model bindings, media capabilities, and first-class MCP support.
48
+
49
+ No CLI, no database, no config files — you pass Python objects in and get messages back.
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ pip install cliver-core==0.3.0 # core library + MCP client (stdio / streamable HTTP)
55
+ pip install "cliver-core[local]==0.3.0" # + in-process local embed / rerank / System One models
56
+ ```
57
+
58
+ `0.3.0` is the first stable release of the 0.3 API series: the public API is frozen, with bug
59
+ fixes only in `0.3.x` patch releases. Python 3.10–3.13. See
60
+ [Stability & Versioning](https://cliver-project.github.io/CLIver/getting-started/stability/).
61
+
62
+ ## 0.3 highlights
63
+
64
+ - Ordered binding mounts with same-purpose retryable failover
65
+ - `run_id` correlation, `run_timeout` deadlines, and `arefresh_credentials()`
66
+ - `chat_structured()` with pydantic / JSON-Schema validation and retries
67
+ - Caller-supplied `context_compactor` (declarative plans) plus an opt-in `LlmCompactor`
68
+ - System One decision models and `SystemOneSelector`
69
+ - A streamable-HTTP MCP session pool (`session_pool_size`)
70
+ - DashScope, Qwen, and Qwen-Image chat/media brands
71
+ - A committed live verification suite (`make live-verify`)
72
+
73
+ ## Quick start
74
+
75
+ ```python
76
+ import asyncio
77
+
78
+ from cliver_core import AgentCore, ModelBinding, ModelBindings
79
+
80
+
81
+ async def main():
82
+ agent = AgentCore(
83
+ ModelBindings(
84
+ llm=ModelBinding.llm(
85
+ model="deepseek-v4-flash",
86
+ api_key="...",
87
+ base_url="https://api.deepseek.com",
88
+ )
89
+ )
90
+ )
91
+ response = await agent.chat("Summarize the agent loop in one sentence.")
92
+ print(response.message.content)
93
+ await agent.aclose()
94
+
95
+
96
+ asyncio.run(main())
97
+ ```
98
+
99
+ Ready-made bindings for live-verified providers live in `cliver_core.presets`:
100
+
101
+ ```python
102
+ from cliver_core import ModelBindings, presets
103
+
104
+ bindings = ModelBindings(llm=presets.deepseek(api_key="..."))
105
+ agent = AgentCore(bindings)
106
+ ```
107
+
108
+ ## Tools
109
+
110
+ `cliver_core.tools` ships nine file, shell, todo, and web tools. Register them directly:
111
+
112
+ ```python
113
+ from cliver_core.tools import discover_builtin_tools
114
+
115
+ agent = AgentCore(bindings, builtin_tools=discover_builtin_tools())
116
+ ```
117
+
118
+ `ToolRegistry` and the `@tool` decorator build custom tools.
119
+
120
+ ## Capabilities
121
+
122
+ Every purpose works standalone — no AgentCore required:
123
+
124
+ ```python
125
+ from cliver_core import ModelBinding
126
+ from cliver_core.capabilities import embed, generate_image
127
+
128
+ vectors = await embed(
129
+ texts=["hello", "world"],
130
+ binding=ModelBinding.embed(model="text-embedding-3-small", api_key="...", base_url="..."),
131
+ )
132
+
133
+ image = await generate_image(
134
+ prompt="a red panda on a skateboard",
135
+ binding=ModelBinding.image(model="gpt-image-1", api_key="...", base_url="..."),
136
+ )
137
+ ```
138
+
139
+ Purposes: image, video, text-to-speech, speech-to-text, embed, rerank. Long generations can return
140
+ a `MediaJob` future via `AgentCore`'s `submit_*` variants.
141
+
142
+ ## Reliability and structured output
143
+
144
+ `ModelBindings` accepts an ordered list per purpose. Retryable failures — rate limits, timeouts,
145
+ connection failures, and 5xx — move to the next binding; non-retryable failures surface
146
+ immediately. Chat is sticky after a switch, and streams switch only before the first chunk.
147
+
148
+ `run_id` correlates inference, tool, and pipeline events; `run_timeout` bounds a whole run
149
+ (preamble, model calls, tools, and handler awaits); `arefresh_credentials()` rebuilds providers
150
+ after a credential rotation. A caller-supplied `context_compactor` can replace history once per
151
+ loop iteration before the model call: return a `CompactionPlan` and core applies it safely, or
152
+ return a full history as an escape hatch. `LlmCompactor` is an opt-in reference policy that is
153
+ never installed automatically.
154
+
155
+ `chat_structured()` validates a pydantic model or JSON-Schema dict and retries invalid output:
156
+
157
+ ```python
158
+ from pydantic import BaseModel
159
+
160
+
161
+ class Item(BaseModel):
162
+ title: str
163
+ price: float
164
+
165
+
166
+ result = await agent.chat_structured("Extract the product from this page.", schema=Item)
167
+ print(result.value.title)
168
+ ```
169
+
170
+ See [Structured Output](https://cliver-project.github.io/CLIver/core-concepts/structured-output/),
171
+ [Concurrency & Lifecycle](https://cliver-project.github.io/CLIver/core-concepts/concurrency/), and
172
+ [Context Window](https://cliver-project.github.io/CLIver/core-concepts/context-window/).
173
+
174
+ ## System One
175
+
176
+ `ModelBinding.system_one(...)` mounts a Jev-compatible decision model. `AgentCore.system_one()`
177
+ answers typed `Choice` / `Score` / `Noul` questions, and `SystemOneSelector` uses the model to
178
+ narrow tools and skills as a fail-open candidate selector. Hosted Bailian and TypeSafe presets
179
+ and a local `laya` backend are available. See
180
+ [System One](https://cliver-project.github.io/CLIver/core-concepts/system-one/).
181
+
182
+ ## Local models
183
+
184
+ Run embedding, rerank, and System One decision models in-process — no endpoint. The backends
185
+ pull torch, so they are opt-in:
186
+
187
+ ```bash
188
+ pip install "cliver-core[local-st]==0.3.0" # sentence-transformers embeddings
189
+ pip install "cliver-core[local-flag]==0.3.0" # FlagEmbedding embeddings + rerank
190
+ pip install "cliver-core[local]==0.3.0" # all three local backends
191
+ ```
192
+
193
+ ```python
194
+ from cliver_core.capabilities import embed, rerank
195
+ from cliver_core.local import (
196
+ LocalEmbeddingProvider,
197
+ LocalRerankProvider,
198
+ local_embed,
199
+ local_rerank,
200
+ )
201
+
202
+ embedder = LocalEmbeddingProvider(
203
+ model="BAAI/bge-base-zh-v1.5", # Hugging Face id or local directory
204
+ backend="sentence-transformers", # required; never inferred from the model name
205
+ )
206
+ reranker = LocalRerankProvider(
207
+ model="BAAI/bge-reranker-v2-m3",
208
+ backend="flag-embedding",
209
+ )
210
+
211
+ vectors = await embed(
212
+ texts=["hello", "world"],
213
+ binding=local_embed(provider=embedder, normalize=True),
214
+ )
215
+ items = await rerank(
216
+ query="hello",
217
+ documents=["hi", "hey"],
218
+ binding=local_rerank(provider=reranker, top_k=1),
219
+ )
220
+
221
+ await embedder.close()
222
+ await reranker.close()
223
+ ```
224
+
225
+ A provider owns one loaded model and is meant to be long-lived: create it once, share it across
226
+ bindings and calls, and close it at shutdown. There is no process-global model cache.
227
+ `ModelBinding.aclose()` never closes a provider you supplied.
228
+
229
+ The API is deliberately explicit: `model`, `backend`, `device`, and `dtype` are parameters, not
230
+ name-based defaults. Call options are generic — `dim` (optional output-size check), `normalize`
231
+ (off by default; raw vectors/scores), `batch_size`, and `top_k` (rerank). Query/document prefixes
232
+ and instruction templates belong to the application.
233
+
234
+ `provider.info()` reports the resolved model directory, revision, device, dtype, and load time.
235
+ Hugging Face downloads honor `HF_TOKEN`, `cache_dir`, `revision`, and `local_files_only`.
236
+
237
+ ## MCP
238
+
239
+ ```python
240
+ from cliver_core.mcp import MCPClient
241
+
242
+ client = MCPClient.from_discovery() # ~/.cliver/mcp.json, .cliver/mcp.json, drop-ins
243
+ agent = AgentCore(bindings, mcp_client=client)
244
+ ```
245
+
246
+ MCP tools are advertised to the model as `mcp__<server>__<tool>`. Prompts and resources are read on
247
+ demand — `list_prompts`, `get_prompt`, `list_resources`, `read_resource` — never registered as
248
+ tools.
249
+
250
+ ## Skills
251
+
252
+ [Agent Skills](https://agentskills.io/specification): a skill is a directory with a `SKILL.md`
253
+ (frontmatter + instructions) plus optional `scripts/`, `references/`, `assets/`. cliver-core reads
254
+ skills from **explicit sources the application supplies** — a directory of skill directories or a
255
+ single skill directory; nothing is discovered implicitly, and later sources override earlier ones
256
+ by name.
257
+
258
+ ```python
259
+ from cliver_core import AgentCore, SkillManager
260
+
261
+ skills = SkillManager(sources=["./skills"]) # routing metadata: skills.list_skills()
262
+ agent = AgentCore(bindings, builtin_tools=[...], skill_manager=skills)
263
+
264
+ result = await agent.run_skill("Refund", "订单 12345 想退货", conversation=history)
265
+ ```
266
+
267
+ `run_skill` (name or an already-loaded `Skill` object) appends an activation header — skill
268
+ name and location, so bundled `scripts/` are runnable — plus the skill body to the single
269
+ system message and runs the normal agent loop; a declared `allowed-tools` frontmatter narrows
270
+ the advertised tools to that set — a non-empty allowlist matching zero available tools fails
271
+ fast, while an absent or empty list leaves tools unchanged. The other call parameters mirror
272
+ `chat()` (except `tool_filter` and `skill_dispatch`). `run_skill()` adds none of the
273
+ model-driven skill tools (`FindSkills`, `ActivateSkill`, `ReadSkillFile`); an `allowed-tools`
274
+ entry naming one of those is unavailable in this path.
275
+
276
+ Progressive disclosure: `list_skills()` exposes only routing metadata (name + description —
277
+ `format_skill_catalog()` renders the catalogue for prompts); the body enters context only when a
278
+ skill is activated; bundled files are listed (`skill.files`) and readable on demand
279
+ (`skill.read_file("references/policy.md")`, path escapes rejected).
280
+
281
+ With a `SkillManager` configured, `chat()`/`stream()` give the model that catalogue in the system
282
+ prompt (`skill_summary_limit`, default 10), `FindSkills(query, limit)` to search the full
283
+ catalogue, and `ActivateSkill(name)` to load a skill's body as a tool result for the rest of the
284
+ run. Activation is one skill at a time; a declared `allowed-tools` narrows the advertised tools
285
+ for the remaining iterations, and an activated skill that bundles files also gets
286
+ `ReadSkillFile(path)` — confined to that skill's directory (escapes refused, UTF-8 text, 256 KiB
287
+ cap), while workspace files stay on `Read`. Apps may rank the catalogue with
288
+ `skill_selector(skills, user_input)`, replace lexical search with
289
+ `skill_search(query, skills)`, and narrow both candidate pools with
290
+ `candidate_selector(tools, skills, user_input)` / `tool_selector(tools, user_input)`.
291
+ `run_skill()` disables dispatch for its run.
292
+
293
+ The dependency-free frontmatter parser covers the spec's surface plus what cross-agent skills
294
+ (workbuddy, accio, ...) carry — flat scalars, quoted strings, `>` / `|` blocks, and nested maps
295
+ of any depth (unknown keys are kept in `skill.frontmatter` for forward compatibility; no anchors
296
+ or `-` sequences). Validation follows the agentskills.io rules (name
297
+ pattern, 64/1024/500-char limits) as load-time warnings; skills stay loadable unless `name` or
298
+ the frontmatter itself is missing. (Anthropic's product-specific extras — reserved words in
299
+ names — are not enforced.) Script execution sandboxes remain future work.
300
+
301
+ ## Pipelines
302
+
303
+ `SkillPipeline` runs an ordered list of steps sequentially, each in its own fresh context. The
304
+ caller defines the order — no LLM decides it. A step runs a skill (via `run_skill()`) or a raw
305
+ prompt (via `chat()`); its input is composed from the original input and the prior results. A
306
+ synthesis step is an ordinary final step that reads the earlier outputs.
307
+
308
+ ```python
309
+ from cliver_core import PipelineStep, SkillPipeline
310
+
311
+
312
+ async def log(event) -> None:
313
+ print(event.event, getattr(event, "step_name", None))
314
+
315
+
316
+ pipeline = SkillPipeline(
317
+ [
318
+ PipelineStep(name="market", skill="market-analysis"),
319
+ PipelineStep(name="competitors", skill="competitor-scan"),
320
+ PipelineStep(
321
+ name="economics",
322
+ skill="unit-economics",
323
+ input_builder=lambda ctx: f"{ctx.input}\n\nMarket:\n{ctx.result('market').content}",
324
+ ),
325
+ PipelineStep(
326
+ name="report",
327
+ skill="report-writing",
328
+ input_builder=lambda ctx: (
329
+ "\n\n".join(f"## {r.name}\n{r.content}" for r in ctx.results) + f"\n\n## Idea\n{ctx.input}"
330
+ ),
331
+ ),
332
+ ],
333
+ agent=agent,
334
+ on_event=log, # pipeline lifecycle + forwarded tool events
335
+ )
336
+
337
+ result = await pipeline.run("A subscription box for office plants")
338
+ print(result.ok, result.final.content)
339
+ ```
340
+
341
+ - **Results** — `PipelineResult.results` is an ordered tuple of `StepResult`s
342
+ (`name`, `content`, optional `metadata`, `usage`, `error`); `.final` is the last result and
343
+ `.ok` is true only when every step ran and none failed.
344
+ - **Input builders** — `PipelineContext` carries the original `input` and prior `results`
345
+ (`ctx.result(name)`, `ctx.previous`). Builders may be sync or async. The default input is the
346
+ pipeline input.
347
+ - **Step prompts** — `PipelineStep.prompt` is raw step instructions appended to the single
348
+ system message (as extra instructions alongside a skill, or as the whole instruction when no
349
+ skill is given).
350
+ - **Failure policy** — `on_failure=FailurePolicy.STOP` (default) stops at the first failed step
351
+ and sets `PipelineResult.stopped`; `FailurePolicy.CONTINUE` records the error and runs the
352
+ next step. Later steps can inspect `ctx.result(name).error`.
353
+ - **Runners** — a step may inject a `runner(step, step_input, context, emit)` to use a different
354
+ `AgentCore` instance, model, tools, or skill set; pass `on_event=emit` so its tool events are
355
+ forwarded. Custom runners may return `StepOutput` (content + metadata + usage),
356
+ `CLIverResponse`, or a plain string.
357
+ - **Events** — the pipeline emits `PipelineEvent`s (`pipeline.start`, `pipeline.step_start`,
358
+ `pipeline.step_end`, `pipeline.step_error`, `pipeline.end`) and forwards each step's
359
+ `ToolEvent`s. Cancelling the task emits `pipeline.end` with `{"cancelled": true}` and
360
+ re-raises `CancelledError`.
361
+
362
+ ## Permissions & execution policy
363
+
364
+ Two independent axes, both opt-in — with neither set, every tool runs exactly as before.
365
+
366
+ **Permission axis (may this tool run?).** Every tool carries a category: `SAFE` or `ASK`.
367
+ Read-only builtins (`Read`, `LS`, `Grep`, `TodoRead`/`TodoWrite`) are `SAFE`; mutating ones
368
+ (`Write`, `Bash`, `Exec`, `WebFetch`) are `ASK` by default. MCP tools map the spec's
369
+ self-declared `readOnlyHint` annotation to `SAFE` — a hint, never a permission boundary.
370
+ An application-supplied async `permission_callback` is consulted before any `ASK` tool runs:
371
+
372
+ ```python
373
+ from cliver_core import AgentCore, Decision, EnvSpec, ExecutionPolicy, SAFE_ENV_VARS, ToolCategory
374
+
375
+
376
+ async def ask_user(ctx) -> Decision: # ctx: tool_name, args, server, category
377
+ answer = await my_ui.confirm(f"Run {ctx.tool_name}?")
378
+ return Decision.allow() if answer else Decision.deny("user said no")
379
+
380
+
381
+ agent = AgentCore(
382
+ bindings,
383
+ builtin_tools=[...],
384
+ permission_callback=ask_user, # None → ASK tools run unchecked
385
+ execution_policy=ExecutionPolicy( # environment axis, ambient per call
386
+ env=EnvSpec(mode="allowlist", names=set(SAFE_ENV_VARS)),
387
+ cwd=project_root,
388
+ write_paths=[project_root / "src"],
389
+ ),
390
+ safety_overrides={"mcp__github__create_issue": ToolCategory.ASK},
391
+ )
392
+ ```
393
+
394
+ A denial never raises: it returns `{"error": "Permission denied: …", "denied": true}` to the
395
+ model through the normal tool-result path and also emits `ToolEventType.PERMISSION_DENIED`
396
+ through `on_event` before the call's `TOOL_END`. Callback exceptions fail closed. Denials share
397
+ the consecutive cap with errors (5 in a row stops the loop). `safety_overrides` reclassify
398
+ individual tools per AgentCore instance — builtins are shared singletons and never mutated.
399
+
400
+ **Environment axis (where does it run, what does it see?).** Pass `execution_policy=` to the
401
+ constructor or per `chat()`/`stream()` call (call-site wins). While ambient: `Bash` and `Exec`
402
+ run with the policy env (`allowlist`/`denylist`/inherit) and pinned cwd — `Bash` logs an INFO
403
+ line when the pin overrides its `directory` argument; `Read`/`LS`/`Grep`/`Write` enforce
404
+ `read_paths`/`write_paths` (resolved against the policy cwd, symlinks followed). `run_skill`
405
+ applies a call-site policy verbatim; otherwise an agent-level policy is reused with cwd pinned
406
+ to the skill's directory.
407
+
408
+ The two axes are complementary, not a hard sandbox: `read_paths`/`write_paths` bind the file
409
+ tools only — an approved `Bash`/`Exec` call runs as your process user and can touch anything
410
+ that user can, under the filtered env and pinned working directory. Use the permission axis
411
+ (callback, `safety_overrides`) to decide whether shell access is granted at all; the paths are
412
+ a guardrail against accidental access, not an OS-level confinement.
413
+
414
+ ## License
415
+
416
+ Apache-2.0