@agentunion/kite 1.4.0 → 1.5.0

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 (235) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/cli.js +44 -5
  3. package/core/dependency_checker.py +250 -0
  4. package/core/env_checker.py +490 -0
  5. package/dependencies_lock.json +128 -0
  6. package/extensions/agents/assistant/server.py +33 -17
  7. package/extensions/channels/acp_channel/server.py +33 -17
  8. package/extensions/services/backup/entry.py +23 -16
  9. package/extensions/services/evol/auth_manager.py +443 -0
  10. package/extensions/services/evol/config.yaml +149 -0
  11. package/extensions/services/evol/config_loader.py +117 -0
  12. package/extensions/services/evol/entry.py +406 -0
  13. package/extensions/services/evol/evol_api.py +173 -0
  14. package/extensions/services/evol/evol_config.json5 +29 -0
  15. package/extensions/services/evol/migrate_tokens.py +122 -0
  16. package/extensions/services/evol/module.md +32 -0
  17. package/extensions/services/evol/pairing.py +250 -0
  18. package/extensions/services/evol/pairing_codes.jsonl +1 -0
  19. package/extensions/services/evol/relay.py +682 -0
  20. package/extensions/services/evol/relay_config.json5 +67 -0
  21. package/extensions/services/evol/routes/__init__.py +1 -0
  22. package/extensions/services/evol/routes/routes_management_ws.py +127 -0
  23. package/extensions/services/evol/routes/routes_rpc.py +89 -0
  24. package/extensions/services/evol/routes/routes_test.py +61 -0
  25. package/extensions/services/evol/server.py +875 -0
  26. package/extensions/services/evol/static/css/style.css +1200 -0
  27. package/extensions/services/evol/static/index.html +781 -0
  28. package/extensions/services/evol/static/index_evol.html +14 -0
  29. package/extensions/services/evol/static/js/app.js +6304 -0
  30. package/extensions/services/evol/static/js/auth.js +326 -0
  31. package/extensions/services/evol/static/js/dialog.js +285 -0
  32. package/extensions/services/evol/static/js/evol-app-fixed.js +50 -0
  33. package/extensions/services/evol/static/js/evol-app.js +1949 -0
  34. package/extensions/services/evol/static/js/evol-app.js.bak +1800 -0
  35. package/extensions/services/evol/static/js/kernel-client-example.js +228 -0
  36. package/extensions/services/evol/static/js/kernel-client.js +396 -0
  37. package/extensions/services/evol/static/js/main.js +141 -0
  38. package/extensions/services/evol/static/js/registry-tests.js +585 -0
  39. package/extensions/services/evol/static/js/stats.js +217 -0
  40. package/extensions/services/evol/static/js/token-manager.js +175 -0
  41. package/extensions/services/evol/static/pairing.html +248 -0
  42. package/extensions/services/evol/static/test_registry.html +262 -0
  43. package/extensions/services/evol/static/test_relay.html +462 -0
  44. package/extensions/services/evol/stats_manager.py +240 -0
  45. package/extensions/services/model_service/entry.py +23 -1
  46. package/extensions/services/proxy/.claude/settings.local.json +13 -0
  47. package/extensions/services/proxy/CHANGELOG_20260308.md +258 -0
  48. package/extensions/services/proxy/_fix_prints.py +133 -0
  49. package/extensions/services/proxy/_fix_prints2.py +87 -0
  50. package/extensions/services/proxy/agentcp/LICENCE +178 -0
  51. package/extensions/services/proxy/agentcp/README copy.md +85 -0
  52. package/extensions/services/proxy/agentcp/README.md +260 -0
  53. package/extensions/services/proxy/agentcp/__init__.py +16 -0
  54. package/extensions/services/proxy/agentcp/agent.py +4 -0
  55. package/extensions/services/proxy/agentcp/agentcp.py +2494 -0
  56. package/extensions/services/proxy/agentcp/agentprofile.json +89 -0
  57. package/extensions/services/proxy/agentcp/ap/__init__.py +16 -0
  58. package/extensions/services/proxy/agentcp/ap/ap_client.py +316 -0
  59. package/extensions/services/proxy/agentcp/assets/images/wechat_qr.png +0 -0
  60. package/extensions/services/proxy/agentcp/backup/metrics.json +31 -0
  61. package/extensions/services/proxy/agentcp/base/__init__.py +20 -0
  62. package/extensions/services/proxy/agentcp/base/auth_client.py +257 -0
  63. package/extensions/services/proxy/agentcp/base/client.py +112 -0
  64. package/extensions/services/proxy/agentcp/base/env.py +34 -0
  65. package/extensions/services/proxy/agentcp/base/html_util.py +336 -0
  66. package/extensions/services/proxy/agentcp/base/log.py +98 -0
  67. package/extensions/services/proxy/agentcp/ca/__init__.py +17 -0
  68. package/extensions/services/proxy/agentcp/ca/ca_client.py +414 -0
  69. package/extensions/services/proxy/agentcp/ca/ca_root.py +74 -0
  70. package/extensions/services/proxy/agentcp/context/__init__.py +20 -0
  71. package/extensions/services/proxy/agentcp/context/context.py +73 -0
  72. package/extensions/services/proxy/agentcp/context/exceptions.py +114 -0
  73. package/extensions/services/proxy/agentcp/create_profile.py +125 -0
  74. package/extensions/services/proxy/agentcp/create_profile_weather.py +125 -0
  75. package/extensions/services/proxy/agentcp/db/__init__.py +15 -0
  76. package/extensions/services/proxy/agentcp/db/db_mananger.py +550 -0
  77. package/extensions/services/proxy/agentcp/docs/UDP_HEARTBEAT_FIX_REPORT.md +265 -0
  78. package/extensions/services/proxy/agentcp/docs/heartbeat_issue_analysis.md +291 -0
  79. package/extensions/services/proxy/agentcp/file/__init__.py +16 -0
  80. package/extensions/services/proxy/agentcp/file/file_client.py +141 -0
  81. package/extensions/services/proxy/agentcp/file/wss_binary_message.py +137 -0
  82. package/extensions/services/proxy/agentcp/hcp.py +299 -0
  83. package/extensions/services/proxy/agentcp/heartbeat/__init__.py +16 -0
  84. package/extensions/services/proxy/agentcp/heartbeat/heartbeat_client.py +360 -0
  85. package/extensions/services/proxy/agentcp/improved_scheduler.py +498 -0
  86. package/extensions/services/proxy/agentcp/llm_agent_utils.py +249 -0
  87. package/extensions/services/proxy/agentcp/llm_server.py +172 -0
  88. package/extensions/services/proxy/agentcp/mermaid.py +210 -0
  89. package/extensions/services/proxy/agentcp/message.py +149 -0
  90. package/extensions/services/proxy/agentcp/metrics.py +256 -0
  91. package/extensions/services/proxy/agentcp/monitoring/__init__.py +20 -0
  92. package/extensions/services/proxy/agentcp/monitoring/global_monitor.py +27 -0
  93. package/extensions/services/proxy/agentcp/monitoring/metrics_store.py +325 -0
  94. package/extensions/services/proxy/agentcp/monitoring/monitoring_service.py +269 -0
  95. package/extensions/services/proxy/agentcp/monitoring/sliding_window.py +222 -0
  96. package/extensions/services/proxy/agentcp/monitoring/standalone_reader.py +224 -0
  97. package/extensions/services/proxy/agentcp/msg/__init__.py +21 -0
  98. package/extensions/services/proxy/agentcp/msg/connection_manager.py +456 -0
  99. package/extensions/services/proxy/agentcp/msg/message_client.py +2058 -0
  100. package/extensions/services/proxy/agentcp/msg/message_serialize.py +263 -0
  101. package/extensions/services/proxy/agentcp/msg/open_ai_message.py +88 -0
  102. package/extensions/services/proxy/agentcp/msg/session_manager.py +1062 -0
  103. package/extensions/services/proxy/agentcp/msg/stream_client.py +267 -0
  104. package/extensions/services/proxy/agentcp/msg/websocket_file_receiver.py +89 -0
  105. package/extensions/services/proxy/agentcp/msg/ws_logger.py +685 -0
  106. package/extensions/services/proxy/agentcp/msg/wss_binary_message.py +137 -0
  107. package/extensions/services/proxy/agentcp/requirements.txt +7 -0
  108. package/extensions/services/proxy/agentcp/samples/agent_graph/README.md +37 -0
  109. package/extensions/services/proxy/agentcp/samples/agent_graph/agentprofile.json +89 -0
  110. package/extensions/services/proxy/agentcp/samples/agent_graph/create_profile.py +138 -0
  111. package/extensions/services/proxy/agentcp/samples/agent_graph/main.py +164 -0
  112. package/extensions/services/proxy/agentcp/samples/agent_use/create_profile.py +123 -0
  113. package/extensions/services/proxy/agentcp/samples/agent_use/llm/create_profile.py +129 -0
  114. package/extensions/services/proxy/agentcp/samples/agent_use/llm/env.json +5 -0
  115. package/extensions/services/proxy/agentcp/samples/agent_use/llm/main.py +146 -0
  116. package/extensions/services/proxy/agentcp/samples/agent_use/main.py +123 -0
  117. package/extensions/services/proxy/agentcp/samples/agent_use/readme.md +379 -0
  118. package/extensions/services/proxy/agentcp/samples/agent_use/search/create_profile.py +129 -0
  119. package/extensions/services/proxy/agentcp/samples/agent_use/search/main.py +28 -0
  120. package/extensions/services/proxy/agentcp/samples/agent_use/tool/create_profile.py +129 -0
  121. package/extensions/services/proxy/agentcp/samples/agent_use/tool/main.py +20 -0
  122. package/extensions/services/proxy/agentcp/samples/ali_amap/README.md +97 -0
  123. package/extensions/services/proxy/agentcp/samples/ali_amap/amap_agent.py +88 -0
  124. package/extensions/services/proxy/agentcp/samples/ali_amap/create_profile.py +125 -0
  125. package/extensions/services/proxy/agentcp/samples/compute_agent/agent/powershell.py +228 -0
  126. package/extensions/services/proxy/agentcp/samples/compute_agent/agent/software.py +63 -0
  127. package/extensions/services/proxy/agentcp/samples/compute_agent/agent/tools.py +36 -0
  128. package/extensions/services/proxy/agentcp/samples/compute_agent/browser_user.py +41 -0
  129. package/extensions/services/proxy/agentcp/samples/deepseek/README.md +79 -0
  130. package/extensions/services/proxy/agentcp/samples/deepseek/create_profile.py +126 -0
  131. package/extensions/services/proxy/agentcp/samples/deepseek/deepseek.py +42 -0
  132. package/extensions/services/proxy/agentcp/samples/dify_chat/README.md +78 -0
  133. package/extensions/services/proxy/agentcp/samples/dify_chat/create_profile.py +126 -0
  134. package/extensions/services/proxy/agentcp/samples/dify_chat/dify_chat.py +47 -0
  135. package/extensions/services/proxy/agentcp/samples/dify_workflow/README.md +78 -0
  136. package/extensions/services/proxy/agentcp/samples/dify_workflow/create_profile.py +126 -0
  137. package/extensions/services/proxy/agentcp/samples/dify_workflow/dify_workflow.py +46 -0
  138. package/extensions/services/proxy/agentcp/samples/executor/README.md +44 -0
  139. package/extensions/services/proxy/agentcp/samples/executor/agentprofile.json +89 -0
  140. package/extensions/services/proxy/agentcp/samples/executor/create_profile.py +139 -0
  141. package/extensions/services/proxy/agentcp/samples/executor/main.py +160 -0
  142. package/extensions/services/proxy/agentcp/samples/filereader/README.md +45 -0
  143. package/extensions/services/proxy/agentcp/samples/filereader/agentprofile.json +90 -0
  144. package/extensions/services/proxy/agentcp/samples/filereader/create_profile.py +137 -0
  145. package/extensions/services/proxy/agentcp/samples/filereader/main.py +253 -0
  146. package/extensions/services/proxy/agentcp/samples/filewriter/README.md +38 -0
  147. package/extensions/services/proxy/agentcp/samples/filewriter/agentprofile.json +91 -0
  148. package/extensions/services/proxy/agentcp/samples/filewriter/create_profile.py +138 -0
  149. package/extensions/services/proxy/agentcp/samples/filewriter/main.py +289 -0
  150. package/extensions/services/proxy/agentcp/samples/hcp/README.md +85 -0
  151. package/extensions/services/proxy/agentcp/samples/hcp/acp_weather_agent.zip +0 -0
  152. package/extensions/services/proxy/agentcp/samples/hcp/create_profile.py +125 -0
  153. package/extensions/services/proxy/agentcp/samples/hcp/hcp.py +237 -0
  154. package/extensions/services/proxy/agentcp/samples/helloworld/README.md +68 -0
  155. package/extensions/services/proxy/agentcp/samples/helloworld/hello_world.py +40 -0
  156. package/extensions/services/proxy/agentcp/samples/llm_agent/MEADME.md +117 -0
  157. package/extensions/services/proxy/agentcp/samples/llm_agent/create_profile.py +125 -0
  158. package/extensions/services/proxy/agentcp/samples/llm_agent/qwen_agent.py +136 -0
  159. package/extensions/services/proxy/agentcp/samples/local_llm_agent/README.md +90 -0
  160. package/extensions/services/proxy/agentcp/samples/local_llm_agent/create_profile.py +125 -0
  161. package/extensions/services/proxy/agentcp/samples/local_llm_agent/main.py +49 -0
  162. package/extensions/services/proxy/agentcp/samples/query_llm_from_agent/README.md +55 -0
  163. package/extensions/services/proxy/agentcp/samples/query_llm_from_agent/create_profile.py +125 -0
  164. package/extensions/services/proxy/agentcp/samples/query_llm_from_agent/main.py +23 -0
  165. package/extensions/services/proxy/agentcp/samples/query_weather_api_agent/README.md +103 -0
  166. package/extensions/services/proxy/agentcp/samples/query_weather_api_agent/create_profile.py +125 -0
  167. package/extensions/services/proxy/agentcp/samples/query_weather_api_agent/main.py +69 -0
  168. package/extensions/services/proxy/agentcp/samples/query_weather_from_agent/README.md +58 -0
  169. package/extensions/services/proxy/agentcp/samples/query_weather_from_agent/create_profile.py +125 -0
  170. package/extensions/services/proxy/agentcp/samples/query_weather_from_agent/main.py +25 -0
  171. package/extensions/services/proxy/agentcp/samples/qwen3/README.md +71 -0
  172. package/extensions/services/proxy/agentcp/samples/qwen3/create_profile.py +126 -0
  173. package/extensions/services/proxy/agentcp/samples/qwen3/qwen3.py +37 -0
  174. package/extensions/services/proxy/agentcp/samples/qwen3_tools/README.md +133 -0
  175. package/extensions/services/proxy/agentcp/samples/qwen3_tools/create_profile.py +126 -0
  176. package/extensions/services/proxy/agentcp/samples/qwen3_tools/qwen3_tools.py +98 -0
  177. package/extensions/services/proxy/agentcp/samples/search/create_profile_qwen.py +125 -0
  178. package/extensions/services/proxy/agentcp/samples/search/create_profile_search.py +125 -0
  179. package/extensions/services/proxy/agentcp/samples/search/qwen_agent.py +136 -0
  180. package/extensions/services/proxy/agentcp/samples/search/search_agent.py +170 -0
  181. package/extensions/services/proxy/agentcp/samples/wrapper_agently_to_agent/README.md +89 -0
  182. package/extensions/services/proxy/agentcp/samples/wrapper_agently_to_agent/create_profile.py +125 -0
  183. package/extensions/services/proxy/agentcp/samples/wrapper_agently_to_agent/main.py +44 -0
  184. package/extensions/services/proxy/agentcp/utils/__init__.py +15 -0
  185. package/extensions/services/proxy/agentcp/utils/file_util.py +117 -0
  186. package/extensions/services/proxy/agentcp/utils/proxy_bypass.py +99 -0
  187. package/extensions/services/proxy/agentcp/workflow.py +203 -0
  188. package/extensions/services/proxy/console_auth.py +109 -0
  189. package/extensions/services/proxy/evol/__init__.py +1 -0
  190. package/extensions/services/proxy/evol/config.py +37 -0
  191. package/extensions/services/proxy/evol/http/__init__.py +1 -0
  192. package/extensions/services/proxy/evol/http/async_http.py +551 -0
  193. package/extensions/services/proxy/evol/log.py +28 -0
  194. package/extensions/services/proxy/evol/presenter/__init__.py +2 -0
  195. package/extensions/services/proxy/evol/presenter/agentIdPresenter.py +1031 -0
  196. package/extensions/services/proxy/evol/presenter/apikeyPresenter.py +106 -0
  197. package/extensions/services/proxy/evol/presenter/configPresenter.py +1281 -0
  198. package/extensions/services/proxy/evol/presenter/userPresenter.py +477 -0
  199. package/extensions/services/proxy/evol/server/__init__.py +1 -0
  200. package/extensions/services/proxy/evol/server/claude_proxy_async.py +3430 -0
  201. package/extensions/services/proxy/evol/server/openclaw_proxy.py +1861 -0
  202. package/extensions/services/proxy/evol/server/proxy_config.py +15 -0
  203. package/extensions/services/proxy/evol/server/proxy_engine.py +501 -0
  204. package/extensions/services/proxy/evol/version.py +24 -0
  205. package/extensions/services/proxy/logs/websocket.log +260 -0
  206. package/extensions/services/proxy/main.py +240 -0
  207. package/extensions/services/proxy/requirements.txt +13 -0
  208. package/extensions/services/proxy/server.py +271 -0
  209. package/extensions/services/watchdog/entry.py +42 -16
  210. package/extensions/services/watchdog/module.md +1 -0
  211. package/extensions/services/watchdog/monitor.py +34 -4
  212. package/extensions/services/web/module.md +1 -1
  213. package/extensions/services/web/server.py +30 -18
  214. package/extensions/services/web/static/js/token-manager.js +10 -10
  215. package/kernel/entry.py +1 -1
  216. package/kernel/module.md +25 -1
  217. package/kernel/registry_store.py +2 -26
  218. package/kernel/rpc_router.py +36 -10
  219. package/kernel/server.py +106 -17
  220. package/kite_cli/commands/deps_install.py +67 -0
  221. package/kite_cli/commands/env_check.py +45 -0
  222. package/kite_cli/commands/prepare.py +49 -0
  223. package/kite_cli/commands/venv_setup.py +56 -0
  224. package/kite_cli/main.py +29 -1
  225. package/launcher/entry.py +306 -21
  226. package/launcher/module.md +9 -0
  227. package/launcher/module_scanner.py +11 -1
  228. package/main.py +4 -1
  229. package/package.json +8 -1
  230. package/python_version.json +4 -0
  231. package/requirements.txt +38 -0
  232. package/scripts/env-manager.js +328 -0
  233. package/scripts/python-env.js +79 -0
  234. package/scripts/scan_dependencies.py +461 -0
  235. package/scripts/setup-python-env.js +191 -0
@@ -0,0 +1,178 @@
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
+
@@ -0,0 +1,85 @@
1
+ ```markdown:d:/github_agentcp/samples/hcp/README.md
2
+ # 智能天气助手(HCP)
3
+
4
+ 基于 agentcp 框架开发的智能天气助手,支持自然语言交互和上下文记忆,能够将用户作为外部工具回调获取必要信息。
5
+
6
+ ## 🚀 使用指南
7
+
8
+ 1. **创建agent身份(aid)**
9
+ - 参考文档:创建身份&读写公私有数据
10
+
11
+ 2. **配置Agent参数**
12
+ ```python:hcp.py
13
+ # 修改hcp.py中的agent_id配置项
14
+ agent_id = "your_agent_id" # 替换为实际创建的aid
15
+ ```
16
+
17
+ 3. **配置环境变量**
18
+ ```bash:.env
19
+ OPENAI_API_KEY=your_api_key
20
+ BASE_URL=https://api.openai.com/v1
21
+ MODEL=gpt-3.5-turbo
22
+ ```
23
+
24
+ 4. **安装依赖**
25
+ ```bash
26
+ pip install openai agentcp python-dotenv
27
+ ```
28
+
29
+ 5. **启动服务**
30
+ ```bash
31
+ python hcp.py
32
+ ```
33
+
34
+ ## ✨ 核心功能
35
+
36
+ - 🌦️ 多维度天气查询(当前天气/历史天气/天气预报)
37
+ - 🗣️ 上下文感知的对话管理
38
+ - 🔧 外部工具回调机制(用于获取缺失的位置/时间信息)
39
+ - ⏰ 自动时间推理(支持绝对时间、相对时间和年号纪年)
40
+
41
+ ## 🧩 核心类说明:MCPClient
42
+
43
+ ### 初始化方法
44
+ ```python
45
+ def __init__(self):
46
+ # 初始化 OpenAI 客户端
47
+ self.client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
48
+ # 创建 AgentCP 实例
49
+ self.acp = agentcp.AgentCP(app_path)
50
+ # 消息存储器(按 session_id 隔离)
51
+ self.message_store = dict()
52
+ ```
53
+
54
+ ### 消息管理机制
55
+ ```python
56
+ def record_message(self, session_id: str, role: str, content: str):
57
+ # 记录对话历史(支持 user/assistant/system 三种角色)
58
+
59
+ def get_messages_for_llm(self, session_id: str, max_messages=20, system_message=None):
60
+ # 构造符合 OpenAI 格式的对话历史(自动维护最近20条消息)
61
+ ```
62
+
63
+ ## 🔄 交互流程
64
+
65
+ ```mermaid
66
+ graph TD
67
+ A[用户提问] --> B{是否天气相关?}
68
+ B -->|是| C[检查位置/时间信息]
69
+ B -->|否| D[简短回答并引导]
70
+ C --> E{信息完整?}
71
+ E -->|是| F[生成天气报告]
72
+ E -->|否| G[调用用户工具获取信息]
73
+ ```
74
+
75
+ ## 💬 示例对话
76
+
77
+ > **用户**:明天天气怎么样
78
+ > **Agent**:你想查询哪里的天气呢
79
+ > **用户**:上海
80
+ > **Agent**:上海的天气晴
81
+ > **用户**:上海
82
+ > **Agent**:你是想查询上海什么时候的天气呢
83
+ ```
84
+
85
+
@@ -0,0 +1,260 @@
1
+ # AgentCP - 基于ACP协议的Agent标准通信库
2
+
3
+ ## Agent Communication Protocol(智能体通信协议,简称ACP)
4
+ ACP是一个开放协议,用于解决Agent互相通信协作的问题
5
+ ACP定义了agent的数据规范、agent之间的通信以及agent之间的授权规范
6
+ ACP Python SDK
7
+ ACP Python SDK是一个基于ACP协议的Agent标准通信库,用于解决Agent间的身份认证及通信问题。
8
+ ACP Python SDK提供了一系列API,用于创建AID、连接入网、构建会话,收发消息等。
9
+ ACP Python SDK支持多Agent协作,异步消息处理,支持内网穿透,支持Agent访问的负载均衡
10
+
11
+ ## 功能特性
12
+
13
+ - 🔐 Agent之间采用对等网络通信
14
+ - 🛡️ 基于https安全通信及PKI体系的安全身份认证、连接管理
15
+ - 🔄 异步消息处理,支持全链路流式输入输出
16
+ - 🤖 多 Agent 协作模式支持
17
+ - 📦 简洁易用的 API 设计
18
+ - 📊 支持Agent的高并发场景
19
+ - 📚 支持多种消息类型,包括文本、图片、文件等
20
+ - 🔗 支持内网部署,全网服务
21
+ - 🌐 异构兼容:标准化通信接口支持不同架构的Agent互联
22
+
23
+
24
+ ## 开始使用 AgentCP 吧!
25
+ ## 安装
26
+
27
+ ```bash
28
+ pip install agentcp
29
+ ```
30
+ ## 快速入门
31
+
32
+ ### 初始化ACP实例
33
+
34
+ ```python
35
+ from agentcp import AgentCP
36
+
37
+ # 创建 AgentCP 实例
38
+ # - agent_data_path: agent数据存储路径,必须外部指定,"."为当前目录
39
+ # - seed_password: 加密种子,用于私有证书加密
40
+ # - debug: 是否开启调试模式,默认为False
41
+ # - 注意:日志默认输出在控制台&当前路径下log.txt文件中
42
+ agent_data_path = "."
43
+ acp = AgentCP(agent_data_path,seed_password = "123456",debug=True)
44
+ ```
45
+
46
+ ### 创建新身份
47
+
48
+ ```python
49
+ # 创建新身份
50
+ # - ap: 接入点URL,指定Agent网络的接入点(如:"agentunion.cn")
51
+ # - name: Agent的身份标识,用于在该接入点上唯一标识该Agent
52
+ # - 创建身份成功,返回aid对象,创建身份失败,抛出异常,可获取失败原因
53
+ # - ps:下面两行代码将创建一个临时的aid标识,用于临时演示,实际使用时,需要将name替换为自己的名字,注意不能以guest开头
54
+ # - 正式的aid标识可以在浏览器中像二级域名一样直接访问
55
+ name = "guest"
56
+ aid = acp.create_aid("agentunion.cn", name)
57
+ ```
58
+ ### 获取身份列表
59
+ ```python
60
+ # 获取身份列表
61
+ list = acp.get_aid_list()
62
+ ```
63
+
64
+ ### 加载现有身份
65
+ ```python
66
+ # - load_success: 加载成功返回aid对象,加载失败返回None,详细原因请打开日志查看
67
+ aid = acp.load_aid("yourname.agentunion.cn")
68
+ ```
69
+
70
+ ### 设置消息监听器
71
+ #### 方式1:通过装饰器方式
72
+ ```python
73
+ # - msg: 当有消息
74
+ @aid.message_handler()
75
+ async def sync_message_handler(msg):
76
+ #print(f"收到消息数据: {msg}")
77
+ return True
78
+ ```
79
+
80
+ #### 方式2:通过方法灵活设置
81
+ ```python
82
+ # - msg: 当有消息
83
+ async def sync_message_handler(msg):
84
+ #print(f"收到消息数据: {msg}")
85
+ return True
86
+ aid.add_message_handler(sync_message_handler)
87
+ ```
88
+
89
+ #### 方式3:绑定sesion_id和方法监听器,指定监听某个会话的消息,该消息将不会被其他监听器监听
90
+ ```python
91
+ # - msg: 当有消息
92
+ async def sync_message_handler(msg):
93
+ #print(f"收到消息数据: {msg}")
94
+ return True
95
+ aid.add_message_handler(sync_message_handler,session_id = session_id)
96
+ ```
97
+
98
+ ### 移除消息监听器
99
+
100
+ ```python
101
+ # - msg: 当有消息
102
+ async def sync_message_handler(msg):
103
+ #print(f"收到消息数据: {msg}")
104
+ return True
105
+ aid.remove_message_handler(sync_message_handler,session_id = session_id)
106
+ ```
107
+
108
+ ### 连接到网络
109
+
110
+ ```python
111
+ # aid上线,开始监听消息
112
+ aid.online()
113
+ ```
114
+
115
+
116
+ ### 快速回复消息
117
+
118
+ ```python
119
+ # msg 收到的消息dict
120
+ # message 发送的消息对象或者消息文本
121
+ aid.reply_message(msg,message)
122
+ ```
123
+
124
+ ### 快速发送文本消息
125
+
126
+ ```python
127
+ # to_aid = "" 快速给aid发送消息
128
+ # message_content 消息文本
129
+ # asnyc_message_result 快速消息回调
130
+ aid.quick_send_messsage_content(to_aid,message_content,asnyc_message_result)
131
+ ```
132
+
133
+
134
+ ### 快速发送消息
135
+
136
+ ```python
137
+ # to_aid = "" 快速给aid发送消息
138
+ # message 消息对象
139
+ # asnyc_message_result 快速消息回调
140
+ aid.quick_send_messsage(to_aid,message,asnyc_message_result)
141
+ ```
142
+
143
+
144
+
145
+ ### 创建会话
146
+
147
+ ```python
148
+ # 创建会话
149
+ session_id = aid.create_session(
150
+ name="",
151
+ subject=""
152
+ )
153
+ ```
154
+
155
+
156
+ ### 再会话中发送文本消息
157
+
158
+ ```python
159
+ # to_aid_list = [] 指定多人接收处理
160
+ # session_id 会话id
161
+ # llm_content 大模型处理结果
162
+ aid.send_message_content(to_aid_list, session_id,llm_content)
163
+ ```
164
+
165
+ ### 在会话中发送消息
166
+
167
+ ```python
168
+ # 在会话中发送消息
169
+ aid.send_message(
170
+ session_id=session_id,
171
+ to_aid_list=["member1.agentunion.cn"],
172
+ message={"type": "text", "content": "你好!"}
173
+ )
174
+ ```
175
+
176
+
177
+
178
+ ### 在会话中发送流式消息
179
+
180
+ ```python
181
+ # to_aid_list = [] 指定多人接收处理
182
+ # session_id 会话id
183
+ # llm_content 大模型处理结果
184
+ # 大模型调用流式response
185
+ #type默认为text/event-stream
186
+ await aid.send_stream_message(to_aid_list, session_id,response,type)
187
+ ```
188
+
189
+ ## 核心 API
190
+
191
+ ### `AgentCP` 类
192
+ 主要负责信号处理和程序持续运行的控制。
193
+
194
+ | 方法 | 描述 |
195
+ |------|------|
196
+ | `__init__()` | 初始化信号量和退出钩子函数,可传入app_path |
197
+ | `get_aid_list()` | 获取aid列表,返回aid字符串列表 |
198
+ | `create_aid("ep_point,name")` | 创建aid,返回aid实例|
199
+ | `load_aid(aid_str)` | 加载aid,返回aid实例 |
200
+ | `register_signal_handler(exit_hook_func=None)` | 注册信号处理函数,处理 `SIGTERM` 和 `SIGINT` 信号 |
201
+ | `serve_forever()` | 使程序持续运行,直到关闭标志被设置 |
202
+ | `signal_handle(signum, frame)` | 信号处理函数,设置关闭标志并调用退出钩子函数 |
203
+
204
+ ### `AgentID` 类
205
+ 核心的 Agent 身份管理类,提供身份创建、消息处理、会话管理等功能。
206
+
207
+ #### 连接管理
208
+ | 方法 | 描述 |
209
+ |------|------|
210
+ | `__init__(id, app_path, ca_client, ep_url)` | 初始化 AgentID 实例 |
211
+ | `online()` | 初始化入口点客户端、心跳客户端和会话管理器,并建立连接 |
212
+ | `offline()` | 使 Agent 下线,关闭心跳客户端和入口点客户端 |
213
+ | `get_aid_info()` | 获取 Agent 的基本信息 |
214
+
215
+ #### 会话管理
216
+ | 方法 | 描述 |
217
+ |------|------|
218
+ | `create_session(name, subject, *, type='public')` | 创建会话,返回会话 ID 或 `None` |
219
+ | `invite_member(session_id, to_aid)` | 邀请成员加入指定会话 |
220
+ | `get_online_status(aids)` | 获取指定 Agent 的在线状态 |
221
+ | `get_conversation_list(aid, main_aid, page, page_size)` | 获取会话列表 |
222
+
223
+ #### 消息处理
224
+ | 方法 | 描述 |
225
+ |------|------|
226
+ | `add_message_handler(handler: Callable[[dict], Awaitable[None]], session_id: str = "")` | 添加消息监听器 |
227
+ | `send_message(to_aid_list: list, session_id: str, message: Union[AssistantMessageBlock, list[AssistantMessageBlock], dict], ref_msg_id: str = "", message_id: str = "")` | 发送消息 |
228
+ | `async send_stream_message(to_aid_list: list, session_id: str, response: AsyncGenerator[bytes, None], type: str = "text/event-stream", ref_msg_id: str = "")` | 发送流式消息 |
229
+ | `remove_message_handler(handler: typing.Callable[[dict], typing.Awaitable[None]], session_id:str="")` | 移除消息监听器 |
230
+ | `send_message_content(to_aid_list: list, session_id: str, llm_content: str, ref_msg_id: str="", message_id:str="")` | 发送文本消息 |
231
+ | `send_message(to_aid_list: list, sessionId: str, message: Union[AssistantMessageBlock, list[AssistantMessageBlock], dict], ref_msg_id: str="", message_id:str="")` | 发送消息,可以处理不同类型的消息对象 |
232
+ | `async send_stream_message(to_aid_list: list, session_id: str, response, type="text/event-stream", ref_msg_id:str="")` | 发送流式消息 |
233
+
234
+ #### 其他功能
235
+ | 方法 | 描述 |
236
+ |------|------|
237
+ | `post_public_data(json_path)` | 发送数据到接入点服务器 |
238
+ | `add_friend_agent(aid, name, description, avaUrl)` | 添加好友 Agent |
239
+ | `get_friend_agent_list()` | 获取好友 Agent 列表 |
240
+ | `get_agent_list()` | 获取所有 AgentID 列表 |
241
+ | `get_all_public_data()` | 获取所有 AgentID 的公共数据 |
242
+ | `get_session_member_list(session_id)` | 获取指定会话的成员列表 |
243
+ | `update_aid_info(aid, avaUrl, name, description)` | 更新 Agent 的信息 |
244
+
245
+ ## 微信支持
246
+ 如需技术交流或问题咨询,欢迎添加开发者微信:
247
+
248
+ ![WeChat QR Code](assets/images/wechat_qr.png) <!-- 请将二维码图片放在指定路径 -->
249
+
250
+ 📮 问题反馈: 19169495461@163.com
251
+
252
+ ## 许可证
253
+
254
+ MIT © 2025
255
+
256
+ ---
257
+
258
+ 📮 问题反馈: 19169495461@163.com
259
+
260
+
@@ -0,0 +1,16 @@
1
+ # 移除或注释掉原来的导入
2
+ #: code: utf-8
3
+
4
+ from requests.packages import urllib3
5
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
6
+
7
+ from agentcp.utils.proxy_bypass import ensure_no_proxy_for_local_env
8
+ ensure_no_proxy_for_local_env()
9
+
10
+ from agentcp.agentcp import AgentCP, AgentID
11
+ from agentcp.mermaid import Mermaid
12
+ from agentcp.workflow import Workflow
13
+
14
+ __version__ = "0.1.96"
15
+
16
+ __all__ = ["__version__", "AgentCP", "AgentID","Mermaid","Workflow"]
@@ -0,0 +1,4 @@
1
+ class Agent:
2
+ def __init__(self, name:str, pomp):
3
+ self.name = name
4
+ self.pomp = pomp