txcode-sdk 0.8.0__tar.gz → 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.
Files changed (192) hide show
  1. {txcode_sdk-0.8.0/src/txcode_sdk.egg-info → txcode_sdk-1.0.0}/PKG-INFO +1 -1
  2. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/pyproject.toml +1 -1
  3. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/base_agent.py +187 -62
  4. txcode_sdk-1.0.0/src/txcode_sdk/agent/summarizer/summarizer_agent.py +130 -0
  5. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/client.py +390 -359
  6. txcode_sdk-1.0.0/src/txcode_sdk/compact/compressor.py +132 -0
  7. txcode_sdk-1.0.0/src/txcode_sdk/config/__init__.py +5 -0
  8. txcode_sdk-1.0.0/src/txcode_sdk/config/context_config.py +19 -0
  9. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/provider/deepseek_provider.py +127 -121
  10. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/provider/openai_provider.py +99 -94
  11. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/session/manager.py +3 -2
  12. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/bash.py +74 -31
  13. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/grep.py +18 -4
  14. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0/src/txcode_sdk.egg-info}/PKG-INFO +1 -1
  15. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk.egg-info/SOURCES.txt +3 -25
  16. txcode_sdk-0.8.0/src/txcode_sdk/agent/summarizer/summarizer_agent.py +0 -101
  17. txcode_sdk-0.8.0/src/txcode_sdk/compact/compressor.py +0 -75
  18. txcode_sdk-0.8.0/tests/test_cli.py +0 -253
  19. txcode_sdk-0.8.0/tests/test_client.py +0 -245
  20. txcode_sdk-0.8.0/tests/test_compat.py +0 -149
  21. txcode_sdk-0.8.0/tests/test_deepseek_provider.py +0 -161
  22. txcode_sdk-0.8.0/tests/test_design_agent.py +0 -47
  23. txcode_sdk-0.8.0/tests/test_discuss_agent.py +0 -35
  24. txcode_sdk-0.8.0/tests/test_dream_agent.py +0 -35
  25. txcode_sdk-0.8.0/tests/test_http_api.py +0 -682
  26. txcode_sdk-0.8.0/tests/test_http_ext_api.py +0 -612
  27. txcode_sdk-0.8.0/tests/test_json_store.py +0 -99
  28. txcode_sdk-0.8.0/tests/test_name_agent.py +0 -56
  29. txcode_sdk-0.8.0/tests/test_plan_agent.py +0 -87
  30. txcode_sdk-0.8.0/tests/test_project_manager.py +0 -122
  31. txcode_sdk-0.8.0/tests/test_provider_config.py +0 -248
  32. txcode_sdk-0.8.0/tests/test_provider_model.py +0 -75
  33. txcode_sdk-0.8.0/tests/test_session.py +0 -52
  34. txcode_sdk-0.8.0/tests/test_session_query.py +0 -358
  35. txcode_sdk-0.8.0/tests/test_shell_agent.py +0 -62
  36. txcode_sdk-0.8.0/tests/test_skill_agent.py +0 -70
  37. txcode_sdk-0.8.0/tests/test_test_agent.py +0 -126
  38. txcode_sdk-0.8.0/tests/test_tools.py +0 -601
  39. txcode_sdk-0.8.0/tests/test_txcode_ai.py +0 -208
  40. txcode_sdk-0.8.0/tests/test_websocket_protocol.py +0 -218
  41. txcode_sdk-0.8.0/tests/test_ws_server.py +0 -1093
  42. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/LICENSE +0 -0
  43. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/README.md +0 -0
  44. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/setup.cfg +0 -0
  45. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/setup.py +0 -0
  46. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/__init__.py +0 -0
  47. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/code_example.py +0 -0
  48. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/code_session.py +0 -0
  49. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/code_tool.py +0 -0
  50. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/constants.py +0 -0
  51. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/query_session.py +0 -0
  52. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/example/ws_server.py +0 -0
  53. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/__init__.py +0 -0
  54. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/_compat/__init__.py +0 -0
  55. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/_compat/dataclasses.py +0 -0
  56. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/_compat/resources.py +0 -0
  57. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/__init__.py +0 -0
  58. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/chat/__init__.py +0 -0
  59. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/chat/agent_tool.py +0 -0
  60. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/chat/chat_agent.py +0 -0
  61. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/chat/prompts/__init__.py +0 -0
  62. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/chat/prompts/role.txt +0 -0
  63. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/code/__init__.py +0 -0
  64. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/code/agent_tool.py +0 -0
  65. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/code/code_agent.py +0 -0
  66. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/code/prompts/__init__.py +0 -0
  67. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/code/prompts/role.txt +0 -0
  68. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/common/__init__.py +0 -0
  69. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/common/common_agent.py +0 -0
  70. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/common/prompt/__init__.py +0 -0
  71. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/common/prompt/role.txt +0 -0
  72. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/design/__init__.py +0 -0
  73. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/design/agent_tool.py +0 -0
  74. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/design/design_agent.py +0 -0
  75. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/design/prompts/__init__.py +0 -0
  76. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/design/prompts/role.txt +0 -0
  77. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/discuss/__init__.py +0 -0
  78. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/discuss/agent_tool.py +0 -0
  79. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/discuss/discuss_agent.py +0 -0
  80. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/discuss/prompts/__init__.py +0 -0
  81. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/discuss/prompts/role.txt +0 -0
  82. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/dream/__init__.py +0 -0
  83. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/dream/agent_tool.py +0 -0
  84. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/dream/dream_agent.py +0 -0
  85. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/dream/prompts/__init__.py +0 -0
  86. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/dream/prompts/role.txt +0 -0
  87. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/mem/__init__.py +0 -0
  88. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/mem/agent_tool.py +0 -0
  89. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/mem/mem_agent.py +0 -0
  90. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/mem/prompts/__init__.py +0 -0
  91. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/mem/prompts/role.txt +0 -0
  92. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/name/__init__.py +0 -0
  93. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/name/name_agent.py +0 -0
  94. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/name/prompts/__init__.py +0 -0
  95. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/name/prompts/role.txt +0 -0
  96. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/plan/__init__.py +0 -0
  97. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/plan/agent_tool.py +0 -0
  98. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/plan/plan_agent.py +0 -0
  99. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/plan/prompts/__init__.py +0 -0
  100. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/plan/prompts/role.txt +0 -0
  101. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/shell/__init__.py +0 -0
  102. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/shell/agent_tool.py +0 -0
  103. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/shell/prompts/__init__.py +0 -0
  104. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/shell/prompts/role.txt +0 -0
  105. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/shell/shell_agent.py +0 -0
  106. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/skill/__init__.py +0 -0
  107. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/skill/agent_tool.py +0 -0
  108. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/skill/prompts/__init__.py +0 -0
  109. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/skill/prompts/role.txt +0 -0
  110. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/skill/skill_agent.py +0 -0
  111. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/summarizer/__init__.py +0 -0
  112. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/summarizer/prompts/__init__.py +0 -0
  113. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/summarizer/prompts/role.txt +0 -0
  114. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/task/__init__.py +0 -0
  115. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/task/agent_tool.py +0 -0
  116. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/task/prompts/__init__.py +0 -0
  117. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/task/prompts/role.txt +0 -0
  118. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/task/task_agent.py +0 -0
  119. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/test/__init__.py +0 -0
  120. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/test/agent_tool.py +0 -0
  121. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/test/prompts/__init__.py +0 -0
  122. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/test/prompts/role.txt +0 -0
  123. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/test/test_agent.py +0 -0
  124. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/agent/tool_registry.py +0 -0
  125. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/compact/__init__.py +0 -0
  126. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/__init__.py +0 -0
  127. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/handlers/__init__.py +0 -0
  128. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/handlers/base.py +0 -0
  129. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/handlers/memory.py +0 -0
  130. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/processor.py +0 -0
  131. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/queue.py +0 -0
  132. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/hooks/types.py +0 -0
  133. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/provider/__init__.py +0 -0
  134. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/provider/base.py +0 -0
  135. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/provider/router.py +0 -0
  136. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/provider/txcode_ai.py +0 -0
  137. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/__init__.py +0 -0
  138. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/__main__.py +0 -0
  139. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/config_store.py +0 -0
  140. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/handler.py +0 -0
  141. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/http.py +0 -0
  142. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/hub_client.py +0 -0
  143. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/json_store.py +0 -0
  144. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/plan_code.py +0 -0
  145. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/project_manager.py +0 -0
  146. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/provider_config.py +0 -0
  147. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/server.py +0 -0
  148. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/skill_manager.py +0 -0
  149. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/spec_manager.py +0 -0
  150. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/websocket.py +0 -0
  151. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/server/zip_utils.py +0 -0
  152. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/session/__init__.py +0 -0
  153. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/skills/__init__.py +0 -0
  154. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/specs/__init__.py +0 -0
  155. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/__init__.py +0 -0
  156. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/_util.py +0 -0
  157. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/bash.txt +0 -0
  158. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/bash_tool.py +0 -0
  159. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/code_search.py +0 -0
  160. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/code_search.txt +0 -0
  161. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/edit_file.py +0 -0
  162. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/edit_file.txt +0 -0
  163. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/email_tool.py +0 -0
  164. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/email_tool.txt +0 -0
  165. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/glob.py +0 -0
  166. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/glob.txt +0 -0
  167. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/glob_tool.py +0 -0
  168. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/grep.txt +0 -0
  169. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/grep_tool.py +0 -0
  170. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/memory.py +0 -0
  171. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/memory.txt +0 -0
  172. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/memory_tool.py +0 -0
  173. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/read_file.py +0 -0
  174. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/read_file.txt +0 -0
  175. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/skill_tool.py +0 -0
  176. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/skill_tool.txt +0 -0
  177. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/todo_read.py +0 -0
  178. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/todo_read.txt +0 -0
  179. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/todo_write.py +0 -0
  180. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/todo_write.txt +0 -0
  181. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/web_fetch.py +0 -0
  182. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/web_fetch.txt +0 -0
  183. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/web_search.py +0 -0
  184. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/web_search.txt +0 -0
  185. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/web_shell_exec.py +0 -0
  186. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/web_shell_exec.txt +0 -0
  187. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/write_file.py +0 -0
  188. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/tools/write_file.txt +0 -0
  189. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk/types.py +0 -0
  190. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk.egg-info/dependency_links.txt +0 -0
  191. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk.egg-info/entry_points.txt +0 -0
  192. {txcode_sdk-0.8.0 → txcode_sdk-1.0.0}/src/txcode_sdk.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txcode-sdk
3
- Version: 0.8.0
3
+ Version: 1.0.0
4
4
  Summary: AI Agent SDK with built-in tools for Python projects
5
5
  Author: homecommunity
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "txcode-sdk"
7
- version = "0.8.0"
7
+ version = "1.0.0"
8
8
  description = "AI Agent SDK with built-in tools for Python projects"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -1,6 +1,7 @@
1
1
  """BaseAgent 抽象基类(ReAct 主循环),Python 3.6 兼容。"""
2
2
 
3
3
  import json
4
+ import logging
4
5
  import platform as _platform
5
6
  from abc import ABC, abstractmethod
6
7
  from pathlib import Path
@@ -25,6 +26,8 @@ from ..specs import SpecInjector
25
26
  from .._compat.resources import get_resource
26
27
  from .tool_registry import ToolRegistry
27
28
 
29
+ logger = logging.getLogger(__name__)
30
+
28
31
 
29
32
  def _format_tool_args(tool_name: str, args: dict) -> str:
30
33
  key_map = {
@@ -74,6 +77,30 @@ def _build_step_print_msg(step: StepInfo) -> Optional[str]:
74
77
  return "\n".join(lines) if lines else None
75
78
 
76
79
 
80
+ def _format_last_response(resp: ProviderResponse) -> str:
81
+ lines = ["<last-ai-response>"]
82
+ lines.append("finish_reason: %s" % (resp.finish_reason or ""))
83
+ if resp.usage:
84
+ lines.append(
85
+ "usage: prompt=%s completion=%s total=%s"
86
+ % (resp.usage.prompt_tokens, resp.usage.completion_tokens, resp.usage.total_tokens)
87
+ )
88
+ if resp.reasoning:
89
+ lines.append("--- reasoning ---")
90
+ lines.append(resp.reasoning)
91
+ if resp.content:
92
+ lines.append("--- content ---")
93
+ lines.append(resp.content)
94
+ if resp.tool_calls:
95
+ lines.append("--- tool_calls ---")
96
+ for tc in resp.tool_calls:
97
+ name = tc.get("function", {}).get("name", "?")
98
+ args = tc.get("function", {}).get("arguments", "")
99
+ lines.append("- %s(%s)" % (name, args))
100
+ lines.append("</last-ai-response>")
101
+ return "\n".join(lines)
102
+
103
+
77
104
  PROMPT_TEMPLATE = """
78
105
  ## 可用 Skills
79
106
 
@@ -226,6 +253,7 @@ class BaseAgent(ABC):
226
253
  iteration = 0
227
254
  final_answer = ""
228
255
  total_usage = TokenUsage()
256
+ last_response: Optional[ProviderResponse] = None
229
257
 
230
258
  while iteration < self._max_iterations:
231
259
  if abort_signal and getattr(abort_signal, "aborted", False):
@@ -254,10 +282,11 @@ class BaseAgent(ABC):
254
282
  "work_dir": self._work_dir,
255
283
  } if self._log_enabled else None,
256
284
  )
285
+ last_response = response
257
286
 
258
- if response.usage:
259
- total_usage.prompt_tokens = response.usage.prompt_tokens
260
- total_usage.completion_tokens = response.usage.completion_tokens
287
+ if response.usage:
288
+ total_usage.prompt_tokens = response.usage.prompt_tokens
289
+ total_usage.completion_tokens = response.usage.completion_tokens
261
290
  total_usage.total_tokens = response.usage.total_tokens
262
291
 
263
292
  if response.finish_reason == "stop" and response.content:
@@ -287,7 +316,7 @@ class BaseAgent(ABC):
287
316
  results=results,
288
317
  iteration=iteration,
289
318
  usage=response.usage,
290
- )
319
+ )
291
320
  step.printMsg = _build_step_print_msg(step)
292
321
  steps.append(step)
293
322
 
@@ -308,12 +337,12 @@ class BaseAgent(ABC):
308
337
  reasoning_content=response.reasoning,
309
338
  )
310
339
  self._base_messages.append(assistant_msg)
311
- self._save_message(session_id, "assistant", json.dumps({
312
- "type": "assistant_with_tools",
313
- "toolCalls": assistant_msg.tool_calls,
314
- "thought": response.reasoning or "",
315
- "reasoning_content": response.reasoning or "",
316
- }), keep_context=True)
340
+ self._save_message(
341
+ session_id, "assistant", "",
342
+ keep_context=True,
343
+ tool_calls=assistant_msg.tool_calls,
344
+ reasoning=response.reasoning,
345
+ )
317
346
 
318
347
  # tool message
319
348
  tool_msg = ChatMessage(
@@ -322,9 +351,16 @@ class BaseAgent(ABC):
322
351
  tool_call_id=tc.id,
323
352
  )
324
353
  self._base_messages.append(tool_msg)
325
- self._save_message(session_id, "tool", tool_msg.content, keep_context=False, tool_call_id=tc.id)
354
+ self._save_message(
355
+ session_id, "tool", tool_msg.content,
356
+ keep_context=False, tool_call_id=tc.id,
357
+ )
326
358
 
327
- await self._check_and_compact(session_id, on_compact)
359
+ new_messages_start_index = len(self._base_messages) - 2 * len(tool_calls)
360
+ await self._check_and_compact(
361
+ session_id, on_compact, self._base_messages,
362
+ total_usage, new_messages_start_index,
363
+ )
328
364
  continue
329
365
 
330
366
  if response.content:
@@ -334,18 +370,58 @@ class BaseAgent(ABC):
334
370
  break
335
371
 
336
372
  self._check_hooks("end")
337
-
338
- success = final_answer != ""
339
- return ChatResult(
340
- answer=final_answer or "Unable to complete task",
341
- steps=steps,
342
- session_id=session_id or "",
343
- iterations=iteration,
344
- success=success,
345
- error="Max iterations reached" if iteration >= self._max_iterations and not final_answer else None,
346
- usage=total_usage,
373
+
374
+ err: Optional[str] = None
375
+ answer = final_answer
376
+ if final_answer == "":
377
+ if iteration >= self._max_iterations:
378
+ header = "已达到最大循环次数 %d 次,任务未完成" % self._max_iterations
379
+ err = "Max iterations reached (%d)" % self._max_iterations
380
+ elif last_response is not None:
381
+ fr = last_response.finish_reason or ""
382
+ if fr == "length":
383
+ header = "AI 响应被截断(finish_reason=length)"
384
+ err = "Response truncated (length)"
385
+ elif fr and fr not in ("stop", "tool_calls"):
386
+ header = "AI 返回异常 finish_reason=%s" % fr
387
+ err = "Unexpected finish_reason: %s" % fr
388
+ elif not last_response.content and not last_response.tool_calls:
389
+ header = "AI 返回空响应"
390
+ err = "Empty response from provider"
391
+ else:
392
+ header = "Unable to complete task"
393
+ err = "Unknown"
394
+ else:
395
+ header = "Unable to complete task"
396
+ err = "Unknown"
397
+
398
+ if last_response is not None:
399
+ answer = header + "\n" + _format_last_response(last_response)
400
+ else:
401
+ answer = header
402
+
403
+ logger.warning(
404
+ "agent run failed | session=%s iter=%d | %s",
405
+ session_id, iteration, err,
406
+ )
407
+ if last_response is not None:
408
+ logger.warning("last response: %s", _format_last_response(last_response))
409
+
410
+ success = final_answer != ""
411
+ return ChatResult(
412
+ answer=answer,
413
+ steps=steps,
414
+ session_id=session_id or "",
415
+ iterations=iteration,
416
+ success=success,
417
+ error=err,
418
+ usage=total_usage,
347
419
  )
348
420
 
421
+ def set_compressor(self, compressor: Any):
422
+ """注入客户端的 ContextCompressor,确保 _check_and_compact 使用同一实例。"""
423
+ self._compressor = compressor
424
+
349
425
  def _check_hooks(self, trigger: str):
350
426
  try:
351
427
  from ..hooks import create_hooks
@@ -405,14 +481,32 @@ class BaseAgent(ABC):
405
481
  is_original: bool = False,
406
482
  tool_call_id: Optional[str] = None,
407
483
  media_files: Optional[List[MediaFile]] = None,
484
+ tool_calls: Optional[List[dict]] = None,
485
+ reasoning: Optional[str] = None,
408
486
  ):
409
487
  if not session_id or not self._session_manager:
410
488
  return
411
489
  mf_list = None
412
490
  if media_files:
413
491
  mf_list = [{"file_path": mf.file_path, "type": mf.type} for mf in media_files]
492
+
493
+ if role == "tool" and tool_call_id:
494
+ saved_content = json.dumps({
495
+ "type": "tool_result",
496
+ "toolCallId": tool_call_id,
497
+ "output": content,
498
+ }, ensure_ascii=False)
499
+ elif role == "assistant" and tool_calls:
500
+ saved_content = json.dumps({
501
+ "type": "assistant_with_tools",
502
+ "toolCalls": tool_calls,
503
+ "thought": reasoning or "",
504
+ }, ensure_ascii=False)
505
+ else:
506
+ saved_content = content
507
+
414
508
  self._session_manager.add_message(
415
- session_id, role, content,
509
+ session_id, role, saved_content,
416
510
  keep_context=keep_context, is_original=is_original,
417
511
  tool_call_id=tool_call_id, media_files=mf_list,
418
512
  )
@@ -421,58 +515,89 @@ class BaseAgent(ABC):
421
515
  self,
422
516
  session_id: Optional[str],
423
517
  on_compact: Optional[Callable[[dict], None]],
518
+ base_messages: Optional[List[ChatMessage]] = None,
519
+ total_usage: Optional[TokenUsage] = None,
520
+ new_messages_start_index: int = 0,
424
521
  ):
425
522
  if not session_id or not self._session_manager:
426
523
  return
427
- try:
428
- from ..compact.compressor import ContextCompressor
429
- compressor = getattr(self, "_compressor", None)
430
- if compressor is None:
431
- compressor = ContextCompressor(
432
- max_tokens=150_000,
433
- provider=self._provider,
434
- session_manager=self._session_manager,
435
- )
436
- self._compressor = compressor
437
524
 
438
- check = compressor.check_needs_compact(session_id)
439
- if not check.needed:
440
- return
525
+ if base_messages is None:
526
+ base_messages = getattr(self, "_base_messages", [])
441
527
 
442
- user_msg = None
443
- if self._original_user_index is not None and self._original_user_index < len(self._base_messages):
444
- user_msg = self._base_messages[self._original_user_index]
528
+ compressor = getattr(self, "_compressor", None)
529
+ if compressor is None:
530
+ from ..compact.compressor import ContextCompressor
531
+ compressor = ContextCompressor(
532
+ max_tokens=150_000,
533
+ provider=self._provider,
534
+ session_manager=self._session_manager,
535
+ )
536
+ self._compressor = compressor
445
537
 
446
- current_round_start = len(self._base_messages)
447
- if self._original_user_index is not None:
448
- current_round_start = max(self._original_user_index + 1, 1)
538
+ prompt_tokens = total_usage.prompt_tokens if total_usage else 0
539
+ check = compressor.check_needs_compact(prompt_tokens=prompt_tokens)
540
+ if not check.needed:
541
+ return
449
542
 
450
- current_round_msgs = self._base_messages[current_round_start:]
543
+ self._check_hooks("before_compact")
544
+ self._round_count = 0
451
545
 
452
- result = await compressor.compact(session_id)
546
+ current_tool_results: List[ChatMessage] = [
547
+ m for m in base_messages[new_messages_start_index:]
548
+ if m.role == "tool" or (m.role == "assistant" and m.tool_calls)
549
+ ]
453
550
 
454
- if result.success and result.summary:
455
- self._base_messages = []
456
- if hasattr(self, "_injected_user_message") and self._injected_user_message:
457
- self._base_messages.append(ChatMessage(
458
- role="user",
459
- content=self._injected_user_message,
460
- ))
461
- self._original_user_index = 0
551
+ try:
552
+ result = await compressor.compact(session_id)
462
553
 
463
- self._base_messages.append(ChatMessage(
464
- role="assistant",
465
- content=f"[SUMMARY] {result.summary}",
466
- ))
554
+ if result.success:
555
+ injected = getattr(self, "_injected_user_message", "")
556
+ new_base: List[ChatMessage] = []
557
+ if injected:
558
+ new_base.append(ChatMessage(role="user", content=injected))
559
+ self._original_user_index = 0 if new_base else None
560
+
561
+ session = self._session_manager.get(session_id)
562
+ summary_index = (session or {}).get("summary_message_index")
563
+ summary_msgs = self._session_manager.get_messages_for_ai(
564
+ session_id, summary_index=summary_index
565
+ )
566
+ for m in summary_msgs:
567
+ if m.get("role") == "system":
568
+ continue
569
+ new_base.append(self._history_to_chat_message(m))
467
570
 
468
- self._base_messages.extend(current_round_msgs)
571
+ new_base.extend(current_tool_results)
572
+ base_messages.clear()
573
+ base_messages.extend(new_base)
574
+ self._base_messages = base_messages
469
575
 
470
576
  if on_compact:
471
577
  on_compact({
472
- "needed": True,
473
- "current_tokens": check.current_tokens,
474
- "threshold": check.threshold,
578
+ "beforeTokens": check.current_tokens,
579
+ "afterTokens": result.tokens_after,
475
580
  "summary": result.summary,
476
581
  })
477
- except Exception:
478
- pass
582
+ except Exception as e:
583
+ logger.warning("[AutoCompact] Error: %s", e)
584
+
585
+ def _history_to_chat_message(self, msg: dict) -> ChatMessage:
586
+ """历史记录中的 dict → ChatMessage(仅支持 assistant/user/tool)。"""
587
+ role = msg.get("role", "")
588
+ content = msg.get("content", "")
589
+ tool_calls = None
590
+ if role == "assistant":
591
+ try:
592
+ parsed = json.loads(content)
593
+ if isinstance(parsed, dict) and parsed.get("type") == "assistant_with_tools":
594
+ tool_calls = parsed.get("toolCalls")
595
+ content = ""
596
+ except (json.JSONDecodeError, TypeError, ValueError):
597
+ pass
598
+ return ChatMessage(
599
+ role=role,
600
+ content=content,
601
+ tool_call_id=msg.get("tool_call_id") if role == "tool" else None,
602
+ tool_calls=tool_calls,
603
+ )
@@ -0,0 +1,130 @@
1
+ """SummarizerAgent:会话压缩总结(Python 3.6 兼容)。
2
+
3
+ 行为对齐 txcode `summarizer.agent.ts:compact`:
4
+ - /compact user 占位消息(keep_context=True)
5
+ - 过滤 role=='tool' 且 JSON 解析后 type=='tool_result' 的消息
6
+ - assistant_with_tools 反向解包 text/content,tool_result 反向解包 output
7
+ - provider.chat(messages)(max_tokens 由 Provider 内部硬编码,不在此处传参)
8
+ - 摘要写入 assistant(keep_context=True)后 update_summary + reset_tokens
9
+ - tokens_after = round(tokens_before * 0.3)
10
+ """
11
+
12
+ import json
13
+ from typing import Any, Optional
14
+
15
+ from ..._compat.dataclasses import dataclass
16
+ from ..._compat.resources import get_resource
17
+ from ...provider.base import BaseProvider
18
+ from ...types import ChatMessage
19
+
20
+
21
+ @dataclass
22
+ class CompactCheck:
23
+ needed: bool
24
+ current_tokens: int
25
+ threshold: int
26
+ reason: str = ""
27
+
28
+
29
+ @dataclass
30
+ class CompactResult:
31
+ success: bool
32
+ summary: str = ""
33
+ tokens_before: int = 0
34
+ tokens_after: int = 0
35
+ error: Optional[str] = None
36
+
37
+
38
+ class SummarizerAgent:
39
+ def __init__(self, provider: BaseProvider, max_tokens: int = 150_000):
40
+ self._provider = provider
41
+ self._max_tokens = max_tokens
42
+
43
+ def check_needs_compact(self, session_data: Optional[dict], additional_tokens: int = 0) -> CompactCheck:
44
+ if not session_data:
45
+ return CompactCheck(needed=False, current_tokens=0, threshold=self._max_tokens, reason="No session")
46
+
47
+ prompt = session_data.get("prompt_tokens", 0)
48
+ completion = session_data.get("completion_tokens", 0)
49
+ total = prompt + completion + additional_tokens
50
+ threshold = self._max_tokens
51
+ needed = total >= threshold
52
+ return CompactCheck(
53
+ needed=needed,
54
+ current_tokens=total,
55
+ threshold=threshold,
56
+ reason="Above threshold" if needed else "Below threshold",
57
+ )
58
+
59
+ async def compact(self, session_manager: Any, session_id: str) -> CompactResult:
60
+ try:
61
+ session = session_manager.get(session_id)
62
+ if not session:
63
+ return CompactResult(success=False, error="Session not found")
64
+
65
+ summary_index = session.get("summary_message_index")
66
+ msgs = session_manager.get_messages_for_ai(session_id, summary_index=summary_index)
67
+ if not msgs:
68
+ return CompactResult(success=False, error="No messages to compact")
69
+
70
+ tokens_before = (
71
+ session.get("prompt_tokens", 0) + session.get("completion_tokens", 0)
72
+ )
73
+
74
+ session_manager.add_message(
75
+ session_id, "user", "/compact", keep_context=True,
76
+ )
77
+
78
+ chat_messages: list = []
79
+ for m in msgs:
80
+ role = m.get("role")
81
+ content = m.get("content", "")
82
+ if role == "tool":
83
+ continue
84
+ try:
85
+ parsed = json.loads(content)
86
+ if isinstance(parsed, dict):
87
+ ptype = parsed.get("type")
88
+ if ptype == "tool_result":
89
+ continue
90
+ if ptype == "assistant_with_tools":
91
+ content = parsed.get("text") or parsed.get("content") or content
92
+ elif ptype == "tool_result":
93
+ content = parsed.get("output") or content
94
+ except (json.JSONDecodeError, TypeError, ValueError):
95
+ pass
96
+ chat_messages.append(ChatMessage(role=role, content=content))
97
+
98
+ if not chat_messages:
99
+ return CompactResult(
100
+ success=False, error="No messages to compact after filter",
101
+ tokens_before=tokens_before, tokens_after=tokens_before,
102
+ )
103
+
104
+ role_template = get_resource(
105
+ "txcode_sdk.agent.summarizer.prompts", "role.txt"
106
+ )
107
+ chat_messages.append(ChatMessage(role="user", content=role_template))
108
+
109
+ response = await self._provider.chat(chat_messages)
110
+ summary = (getattr(response, "content", "") or "").strip()
111
+ if not summary:
112
+ return CompactResult(
113
+ success=False, error="Empty summary",
114
+ tokens_before=tokens_before, tokens_after=tokens_before,
115
+ )
116
+
117
+ summary_index = session_manager.add_message(
118
+ session_id, "assistant", summary, keep_context=True,
119
+ )
120
+ session_manager.update_summary(session_id, summary_index)
121
+ session_manager.reset_tokens(session_id)
122
+
123
+ return CompactResult(
124
+ success=True,
125
+ summary=summary,
126
+ tokens_before=tokens_before,
127
+ tokens_after=int(round(tokens_before * 0.3)),
128
+ )
129
+ except Exception as e:
130
+ return CompactResult(success=False, error=str(e))