txcode-sdk 1.3.0__tar.gz → 1.5.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 (202) hide show
  1. {txcode_sdk-1.3.0/src/txcode_sdk.egg-info → txcode_sdk-1.5.0}/PKG-INFO +63 -1
  2. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/README.md +283 -221
  3. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/pyproject.toml +44 -44
  4. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/__init__.py +1 -1
  5. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/client.py +44 -3
  6. txcode_sdk-1.5.0/src/txcode_sdk/config/__init__.py +28 -0
  7. txcode_sdk-1.5.0/src/txcode_sdk/config/ai_settings.py +42 -0
  8. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/provider/base.py +16 -1
  9. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/provider/deepseek_provider.py +41 -35
  10. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/provider/openai_provider.py +41 -34
  11. txcode_sdk-1.5.0/src/txcode_sdk/provider/router.py +20 -0
  12. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/__main__.py +49 -0
  13. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/config_store.py +36 -4
  14. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/handler.py +21 -0
  15. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/__init__.py +14 -3
  16. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/http_base.py +50 -11
  17. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/sys_config_routes.py +355 -288
  18. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/provider_config.py +101 -1
  19. txcode_sdk-1.5.0/src/txcode_sdk/server/services/config_import_export.py +148 -0
  20. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/services/provider_service.py +14 -0
  21. txcode_sdk-1.5.0/src/txcode_sdk/server/yaml_lite.py +734 -0
  22. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0/src/txcode_sdk.egg-info}/PKG-INFO +63 -1
  23. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk.egg-info/SOURCES.txt +9 -1
  24. txcode_sdk-1.5.0/tests/test_ai_settings.py +59 -0
  25. txcode_sdk-1.5.0/tests/test_provider_reasoning_effort.py +143 -0
  26. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/tests/test_server_cli_logging.py +116 -1
  27. txcode_sdk-1.5.0/tests/test_sys_config_ai_settings.py +232 -0
  28. txcode_sdk-1.5.0/tests/test_sys_config_import_export.py +393 -0
  29. txcode_sdk-1.5.0/tests/test_yaml_lite.py +267 -0
  30. txcode_sdk-1.3.0/src/txcode_sdk/config/__init__.py +0 -5
  31. txcode_sdk-1.3.0/src/txcode_sdk/provider/router.py +0 -13
  32. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/LICENSE +0 -0
  33. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/setup.cfg +0 -0
  34. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/setup.py +0 -0
  35. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/__init__.py +0 -0
  36. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/code_example.py +0 -0
  37. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/code_session.py +0 -0
  38. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/code_tool.py +0 -0
  39. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/constants.py +0 -0
  40. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/query_session.py +0 -0
  41. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/example/ws_server.py +0 -0
  42. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/_compat/__init__.py +0 -0
  43. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/_compat/dataclasses.py +0 -0
  44. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/_compat/resources.py +0 -0
  45. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/__init__.py +0 -0
  46. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/base_agent.py +0 -0
  47. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/chat/__init__.py +0 -0
  48. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/chat/agent_tool.py +0 -0
  49. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/chat/chat_agent.py +0 -0
  50. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/chat/prompts/__init__.py +0 -0
  51. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/chat/prompts/role.txt +0 -0
  52. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/code/__init__.py +0 -0
  53. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/code/agent_tool.py +0 -0
  54. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/code/code_agent.py +0 -0
  55. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/code/prompts/__init__.py +0 -0
  56. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/code/prompts/role.txt +0 -0
  57. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/common/__init__.py +0 -0
  58. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/common/common_agent.py +0 -0
  59. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/common/prompt/__init__.py +0 -0
  60. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/common/prompt/role.txt +0 -0
  61. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/compact_mixin.py +0 -0
  62. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/design/__init__.py +0 -0
  63. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/design/agent_tool.py +0 -0
  64. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/design/design_agent.py +0 -0
  65. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/design/prompts/__init__.py +0 -0
  66. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/design/prompts/role.txt +0 -0
  67. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/discuss/__init__.py +0 -0
  68. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/discuss/agent_tool.py +0 -0
  69. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/discuss/discuss_agent.py +0 -0
  70. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/discuss/prompts/__init__.py +0 -0
  71. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/discuss/prompts/role.txt +0 -0
  72. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/dream/__init__.py +0 -0
  73. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/dream/agent_tool.py +0 -0
  74. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/dream/dream_agent.py +0 -0
  75. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/dream/prompts/__init__.py +0 -0
  76. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/dream/prompts/role.txt +0 -0
  77. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/factory.py +0 -0
  78. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/hook_mixin.py +0 -0
  79. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/mem/__init__.py +0 -0
  80. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/mem/agent_tool.py +0 -0
  81. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/mem/mem_agent.py +0 -0
  82. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/mem/prompts/__init__.py +0 -0
  83. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/mem/prompts/role.txt +0 -0
  84. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/message_utils.py +0 -0
  85. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/name/__init__.py +0 -0
  86. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/name/name_agent.py +0 -0
  87. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/name/prompts/__init__.py +0 -0
  88. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/name/prompts/role.txt +0 -0
  89. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/plan/__init__.py +0 -0
  90. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/plan/agent_tool.py +0 -0
  91. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/plan/plan_agent.py +0 -0
  92. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/plan/prompts/__init__.py +0 -0
  93. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/plan/prompts/role.txt +0 -0
  94. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/prompt_builder.py +0 -0
  95. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/shell/__init__.py +0 -0
  96. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/shell/agent_tool.py +0 -0
  97. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/shell/prompts/__init__.py +0 -0
  98. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/shell/prompts/role.txt +0 -0
  99. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/shell/shell_agent.py +0 -0
  100. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/skill/__init__.py +0 -0
  101. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/skill/agent_tool.py +0 -0
  102. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/skill/prompts/__init__.py +0 -0
  103. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/skill/prompts/role.txt +0 -0
  104. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/skill/skill_agent.py +0 -0
  105. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/step_utils.py +0 -0
  106. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/summarizer/__init__.py +0 -0
  107. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/summarizer/prompts/__init__.py +0 -0
  108. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/summarizer/prompts/role.txt +0 -0
  109. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/summarizer/summarizer_agent.py +0 -0
  110. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/task/__init__.py +0 -0
  111. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/task/agent_tool.py +0 -0
  112. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/task/prompts/__init__.py +0 -0
  113. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/task/prompts/role.txt +0 -0
  114. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/task/task_agent.py +0 -0
  115. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/test/__init__.py +0 -0
  116. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/test/agent_tool.py +0 -0
  117. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/test/prompts/__init__.py +0 -0
  118. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/test/prompts/role.txt +0 -0
  119. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/test/test_agent.py +0 -0
  120. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/agent/tool_registry.py +0 -0
  121. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/compact/__init__.py +0 -0
  122. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/compact/compressor.py +0 -0
  123. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/config/context_config.py +0 -0
  124. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/__init__.py +0 -0
  125. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/handlers/__init__.py +0 -0
  126. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/handlers/base.py +0 -0
  127. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/handlers/memory.py +0 -0
  128. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/processor.py +0 -0
  129. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/queue.py +0 -0
  130. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/hooks/types.py +0 -0
  131. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/provider/__init__.py +0 -0
  132. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/provider/txcode_ai.py +0 -0
  133. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/__init__.py +0 -0
  134. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/git.py +0 -0
  135. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/chat_routes.py +0 -0
  136. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/file_routes.py +0 -0
  137. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/git_routes.py +0 -0
  138. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/plan_code_routes.py +0 -0
  139. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/project_routes.py +0 -0
  140. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/session_routes.py +0 -0
  141. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/skill_routes.py +0 -0
  142. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/http/spec_routes.py +0 -0
  143. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/hub_client.py +0 -0
  144. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/json_store.py +0 -0
  145. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/plan_code.py +0 -0
  146. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/project_manager.py +0 -0
  147. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/server.py +0 -0
  148. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/services/__init__.py +0 -0
  149. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/services/broadcaster.py +0 -0
  150. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/services/project_service.py +0 -0
  151. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/skill_manager.py +0 -0
  152. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/spec_manager.py +0 -0
  153. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/websocket.py +0 -0
  154. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/server/zip_utils.py +0 -0
  155. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/session/__init__.py +0 -0
  156. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/session/manager.py +0 -0
  157. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/skills/__init__.py +0 -0
  158. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/specs/__init__.py +0 -0
  159. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/__init__.py +0 -0
  160. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/_util.py +0 -0
  161. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/bash.py +0 -0
  162. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/bash.txt +0 -0
  163. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/code_search.py +0 -0
  164. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/code_search.txt +0 -0
  165. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/edit_file.py +0 -0
  166. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/edit_file.txt +0 -0
  167. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/edit_replacers.py +0 -0
  168. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/edit_similarity.py +0 -0
  169. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/email_tool.py +0 -0
  170. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/email_tool.txt +0 -0
  171. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/glob.py +0 -0
  172. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/glob.txt +0 -0
  173. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/grep.py +0 -0
  174. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/grep.txt +0 -0
  175. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/memory.py +0 -0
  176. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/memory.txt +0 -0
  177. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/read_file.py +0 -0
  178. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/read_file.txt +0 -0
  179. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/skill_tool.py +0 -0
  180. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/skill_tool.txt +0 -0
  181. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/todo_read.py +0 -0
  182. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/todo_read.txt +0 -0
  183. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/todo_write.py +0 -0
  184. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/todo_write.txt +0 -0
  185. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/web_fetch.py +0 -0
  186. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/web_fetch.txt +0 -0
  187. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/web_search.py +0 -0
  188. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/web_search.txt +0 -0
  189. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/web_shell_exec.py +0 -0
  190. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/web_shell_exec.txt +0 -0
  191. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/write_file.py +0 -0
  192. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/tools/write_file.txt +0 -0
  193. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/types.py +0 -0
  194. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/utils/__init__.py +0 -0
  195. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/utils/format.py +0 -0
  196. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/utils/log.py +0 -0
  197. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/utils/path_util.py +0 -0
  198. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk/utils/time_util.py +0 -0
  199. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk.egg-info/dependency_links.txt +0 -0
  200. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk.egg-info/entry_points.txt +0 -0
  201. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/src/txcode_sdk.egg-info/top_level.txt +0 -0
  202. {txcode_sdk-1.3.0 → txcode_sdk-1.5.0}/tests/test_txcode_ai.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txcode-sdk
3
- Version: 1.3.0
3
+ Version: 1.5.0
4
4
  Summary: AI Agent SDK with built-in tools for Python projects
5
5
  Author: homecommunity
6
6
  License: MIT
@@ -87,6 +87,28 @@ txcode-sdk serve --work-dir 您的目录
87
87
  - `TXCODE_API_KEY`:**可选**——仅当 `~/.txcode/providers.json` 不存在且希望首次自动注册默认供应商时使用;未设置时服务以**空配置**正常启动(stderr 打印 WARN 提示),供应商由桌面端通过 WS `add_provider` / `switch_provider` 动态添加,无需重启
88
88
  - 兜底启动:`python -m txcode_sdk.server serve --work-dir ...`(无脚本路径时同样可用)
89
89
 
90
+ ### AI 运行参数(上下文大小 / 循环次数 / 思考强度)
91
+
92
+ 三项参数与桌面端「设置 - 系统配置」一致,**默认值与 txcode(TS 版)完全对齐**;修改后无需重启服务,
93
+ **下次 Agent 运行生效**:
94
+
95
+ | 配置 | `~/.txcode/config.json` key | 默认值 | 可选值 | CLI 参数 |
96
+ | --- | --- | --- | --- | --- |
97
+ | 上下文大小 | `ai.context.maxTokens` | `150000` | 128k / 150k / 200k / 320k / 1M | `--context-tokens` |
98
+ | 循环次数 | `ai.maxIterations` | `1000` | 100 / 500 / 1000 / 5000 | `--max-iterations` |
99
+ | 思考强度 | `ai.reasoningEffort` | `max` | none / minimal / low / medium / high / xhigh / max | `--reasoning-effort` |
100
+
101
+ 优先级:**显式 CLI 参数 > `~/.txcode/config.json`(桌面端写入)> 内置默认值**。
102
+
103
+ ```bash
104
+ txcode-sdk serve --work-dir /opt/door-access \
105
+ --context-tokens 320000 --max-iterations 500 --reasoning-effort high
106
+ ```
107
+
108
+ - 桌面端保存后经 `POST /api/sys_config/set_config` 立即热更新运行中的 client(压缩阈值 / ReAct 循环上限 / 请求体 `thinking` + `reasoning_effort`);
109
+ - 手工编辑 `~/.txcode/config.json` 亦可,下次 `chat` 前自动比对并应用;
110
+ - 非法值读取端回退默认值,写入端返回明确错误;`reasoning_effort` 仅在 `chat` 请求发送(`chat_stream` 固定关闭思考)。
111
+
90
112
  ### 启动装配(JSON 为权威源,0.4.1)
91
113
 
92
114
  服务启动时以用户层 JSON 为权威源恢复上次状态,**重启自动恢复上次激活供应商/模型与当前项目**:
@@ -169,6 +191,46 @@ txcode-sdk serve --work-dir 您的目录
169
191
  - **模型解析定序**:激活供应商优先 → 跨供应商按列表顺序第一个命中 → 未限制放行 → 全未命中回
170
192
  `error: Model not allowed: xxx, available: [..]`
171
193
 
194
+ #### 配置导入 / 导出(与桌面版本地后端同一 YAML 契约)
195
+
196
+ `GET /api/sys_config/export_config` 与 `POST /api/sys_config/import_config`(请求体 `{"content": "<配置文件文本>"}`)
197
+ 使用**与桌面版本地后端 `tx_server` 完全相同的格式**:YAML、camelCase、模型在顶层 `models` 数组、**无 `success/data` 信封**。
198
+ 因此桌面端「导出配置」得到的 `config.yml` 可直接导入 SDK 主机,SDK 导出的 `config.yml` 也可直接导入桌面端/其他 SDK 主机。
199
+ 文本解析/生成由纯标准库模块 `yaml_lite` 完成(零第三方依赖,JSON 文本是 YAML 子集,同一入口天然兼容)。
200
+
201
+ 导出响应为文件附件:`Content-Type: application/x-yaml` + `Content-Disposition: attachment; filename=config.yml`:
202
+
203
+ ```yaml
204
+ providers:
205
+ - id: 3f2a1b... # 命中本地已有 id → 更新;未命中但 name 同名 → 更新该条;否则新增并保留文件中的 id
206
+ name: OpenAI
207
+ apiKey: sk-xxx # 明文(导入必需,注意保管);空串或打码值 sk-***xxxx 时不覆盖本地已有 key
208
+ baseUrl: https://api.openai.com/v1
209
+ enabled: true
210
+ isDefault: true
211
+ models:
212
+ - id: m-1 # SDK 无 model id 语义,导出时按 providerId + name 派生
213
+ providerId: 3f2a1b... # 关联同一文件内 providers[].id(导入期建立「文件 id → 本地 id」映射)
214
+ name: gpt-4o
215
+ contextWindow: 128000 # SDK 无此存储,导入时忽略不报错,导出时省略
216
+ maxOutputTokens: 8192
217
+ supportsVision: true
218
+ supportsTools: true
219
+ enabled: true
220
+ projects: # SDK 扩展段:目录存在则打开项目;桌面端后端解析时忽略该段,不报错
221
+ - id: a1b2c3
222
+ name: door-access
223
+ path: /opt/door-access
224
+ ```
225
+
226
+ - **兼容旧格式**:`providers[].models` 内联的模型数组(旧版 SDK 导出)仍可导入;
227
+ - **忽略未知段**:`providerAuth / gateway / wafGateway / email / proxy` 等桌面端专属段只解析不落库,不报错;
228
+ - **幂等**:同一文件重复导入不产生重复供应商/模型(id 命中走更新,未命中同名走更新);
229
+ - **可读报错**:语法不合法(含锚点/别名/多文档等 YAML 子集外特性)返回 400
230
+ `{"success": false, "error": "配置文件格式无效(第 N 行): ..."}`,不再透出 Python 异常串;
231
+ - **统计反馈**:成功返回 `{"success": true, "message": "配置导入成功", "data": {"providers": 6, "models": 12, "projects": 2, "skipped": []}}`,
232
+ `skipped` 列出被跳过的条目及原因(缺 apiKey 的新供应商、`providerId` 不存在或目录不存在的项目等)。
233
+
172
234
  ### 项目管理
173
235
 
174
236
  远程模式下桌面版右上角「打开项目 / 选择项目」由 SDK 侧 WS 协议提供等价能力:项目列表 / 打开(目录校验)/
@@ -1,226 +1,288 @@
1
- # txcode-sdk
2
-
3
- AI Agent SDK with built-in tools for Python projects.
4
-
5
- ## Installation
6
-
7
- - 要求:**Python >= 3.6**(含 3.6/3.7/3.8/3.9/3.10/3.11/3.12)
8
- - **零第三方运行时依赖**(仅标准库,适合门禁设备等离线环境)
9
-
10
- ```bash
11
- pip install txcode-sdk
12
- ```
13
-
14
- ## Quick Start
15
-
16
- ```python
17
- import asyncio
18
- from txcode_sdk import TxCodeClient
19
-
20
- async def main():
21
- client = TxCodeClient(
22
- api_key="sk-xxx",
23
- base_url="https://api.openai.com/v1",
24
- model="gpt-4",
25
- )
26
- result = await client.chat("Hello!")
27
- print(result.answer)
28
-
29
- asyncio.get_event_loop().run_until_complete(main())
30
- ```
31
-
32
- ## Features
33
-
34
- - ReAct Agent loop with tool calling
35
- - Multiple agent types: code, chat, common, task, plan, shell, skill, test, design, discuss, dream, name
36
- - 10 built-in tools: read_file, write_file, edit_file, glob, grep, bash, memory, web_shell_exec, todo_read, todo_write
37
- - Session management with JSON file persistence
38
- - Context compression for long conversations
39
- - Multimodal input support (images)
40
- - Extensible custom tools
41
- - Self-developed HTTP client (urllib, no openai/tiktoken dependency), supports OpenAI / DeepSeek / any OpenAI-compatible API
42
-
43
- ## WebSocket Server
44
-
45
- SDK 内置零第三方依赖的 WebSocket 服务端(RFC 6455 自研协议层,Python 3.6 兼容),
46
- 支持 **txcode 桌面版远程连接**:把 SDK 安装到门禁 ARM 设备(Ubuntu 18 / Python 3.6)后,
47
- Agent 循环与全部内置工具(read_file / write_file / edit_file / glob / grep / bash / todo 等)
48
- 在**设备本地执行**,桌面版仅作为远程操作界面——实现"直接在门禁系统上开发门禁系统代码"。
49
-
50
- ### 一条命令启动(主推)
51
-
52
- ```bash
53
- pip install txcode-sdk
54
-
55
- txcode-sdk serve --work-dir 您的目录
56
- ```
57
-
58
- - `--work-dir`:门禁代码目录(**必填**,仅首次启动无当前项目时注册为当前项目),Agent 与内置工具在此目录下本地执行
59
- - `--host` / `--port`:默认 `0.0.0.0:41000`
60
- - `--agent-type`:默认 `code`
61
- - `--models`:默认供应商初始模型列表 `[显示名=]模型名` 逗号分隔(仅首次注册默认供应商时使用);缺省读 `TXCODE_MODELS`,再缺省 = 不限制
62
- - `TXCODE_API_KEY`:**可选**——仅当 `~/.txcode/providers.json` 不存在且希望首次自动注册默认供应商时使用;未设置时服务以**空配置**正常启动(stderr 打印 WARN 提示),供应商由桌面端通过 WS `add_provider` / `switch_provider` 动态添加,无需重启
63
- - 兜底启动:`python -m txcode_sdk.server serve --work-dir ...`(无脚本路径时同样可用)
64
-
65
- ### 启动装配(JSON 为权威源,0.4.1)
66
-
67
- 服务启动时以用户层 JSON 为权威源恢复上次状态,**重启自动恢复上次激活供应商/模型与当前项目**:
68
-
69
- 1. **供应商**:加载 `~/.txcode/providers.json`——存在则取激活供应商的 `(api_key, base_url, model)` 直接构造
70
- `TxCodeClient`(不读 `TXCODE_BASE_URL` / `TXCODE_MODEL`);不存在(首次启动/全新环境)且设置了
71
- `TXCODE_API_KEY`(可选)时以 `TXCODE_BASE_URL` / `TXCODE_MODEL` 注册默认供应商并激活(`--models` 作为初始模型列表);
72
- **未设置 `TXCODE_API_KEY` 时以空配置正常启动**(占位 client,不发起任何 API 请求),
73
- 供应商由桌面端经 WS `add_provider` / `switch_provider` 动态添加;未配置供应商前 `chat` / `name_session`
74
- 会收到「No active provider configured」提示,其余能力(WS 握手、ping、配置/项目管理消息)全部可用
75
- 2. **项目**:加载 `~/.txcode/projects.json`——有当前项目则其 `path` 作为 work_dir(不读 `TXCODE_WORK_DIR`);
76
- 无当前项目则 `--work-dir` 注册为当前项目后使用
77
-
78
- 配置(供应商/模型/项目列表)存**用户层 `~/.txcode/`**,跨项目共享、切换项目不影响;
79
- 会话仍按项目分别存于各自工作目录 `{work_dir}/.txcode/session/`。
80
-
81
- ### 桌面版连接
82
-
83
- 1. 桌面版「主机管理」添加远程主机:IP = 门禁设备 IP,端口 = 41000
84
- 2. 桌面版自动以 `ws://{ip}:{port}/ws/code` 连接(无需任何桌面版改动)
85
- 3. 发起对话:AI 在门禁系统本地读写文件、执行 `bash` 编译/运行/调试代码
86
- 4. 文件变更实时推送(`file:changed` 事件),前端自动刷新文件树与编辑器
87
-
88
- ### 协议消息
89
-
90
- | 方向 | type | data |
91
- |---|---|---|
92
- | C→S | `chat` | message, sessionId, mediaFiles, agent, modelName(可选:命中即切换供应商/模型) |
93
- | C→S | `stop` | sessionId(中断运行中会话) |
94
- | C→S | `ping` | - |
95
- | C→S | `get_running_sessions` | -(桌面版 5s 轮询) |
96
- | C→S | `name_session` | sessionId, folderName, userInput |
97
- | C→S | `get_providers` / `get_models` | - |
98
- | C→S | `add_provider` | name, base_url, api_key, models |
99
- | C→S | `update_provider` | providerId, name?, base_url?, api_key?, models? |
100
- | C→S | `delete_provider` | providerId |
101
- | C→S | `add_model` / `delete_model` | providerId, name / modelName |
102
- | C→S | `switch_provider` | providerId, modelName? |
103
- | C→S | `get_projects` | - |
104
- | C→S | `open_project` | name, path |
105
- | C→S | `select_project` / `delete_project` | projectId |
106
- | S→C | `connected` / `step` / `compact` / `done` / `stopped` / `error` / `running_sessions` / `pong` / `rename` | 见下 |
107
- | S→C | `providers_list` / `model_list` | get_providers / get_models 响应(仅发送方) |
108
- | S→C | `providers_changed` | 供应商/模型增删改广播(全局) |
109
- | S→C | `model_changed` | 模型/供应商切换成功广播(全局),data: {providerName, modelName, model} |
110
- | S→C | `projects_list` | get_projects 响应(仅发送方) |
111
- | S→C | `projects_changed` / `project_changed` | 项目列表变更 / 当前项目切换广播(全局) |
112
-
113
- ### 供应商与模型管理
114
-
115
- 服务端支持**动态添加/编辑/删除多个供应商**(OpenAI / DeepSeek / 自建网关),配置实时持久化到用户层
116
- `~/.txcode/providers.json`,服务重启自动恢复;聊天消息携带 `modelName` 命中即切换(自动匹配供应商),
117
- 也可用 `switch_provider` 显式切换。
118
-
119
- `~/.txcode/providers.json` 结构(配置在用户层,跨项目共享,**不随 work_dir 变化**):
120
-
121
- ```json
122
- {
123
- "providers": [
124
- {
125
- "id": "3f2a...",
126
- "name": "OpenAI",
127
- "base_url": "https://api.openai.com/v1",
128
- "api_key": "sk-xxx",
129
- "models": [{"name": "gpt-4o", "display_name": "GPT-4o"}],
130
- "created_at": "2026-08-14T...",
131
- "updated_at": "2026-08-14T..."
132
- }
133
- ],
134
- "active_provider_id": "3f2a...",
135
- "active_model": "gpt-4o"
136
- }
137
- ```
138
-
139
- - **模型限制规则**:供应商 `models` 为空列表 = 不限制(向后兼容);非空 = 白名单校验
140
- - **显示名**:`display_name` 对齐桌面版模型选择器语义(如 `DeepSeek V3` = `deepseek-chat`),
141
- 匹配 name 与 display_name 双通道;`add_model` 缺省 display_name = name
142
- - **api_key 安全**:WS 协议返回打码值(`sk-***` + 后 4 位);`update_provider` 传打码值/空不改原 key;
143
- 明文仅存于用户层本地文件(权限建议 `chmod 600`)
1
+ # txcode-sdk
2
+
3
+ AI Agent SDK with built-in tools for Python projects.
4
+
5
+ ## Installation
6
+
7
+ - 要求:**Python >= 3.6**(含 3.6/3.7/3.8/3.9/3.10/3.11/3.12)
8
+ - **零第三方运行时依赖**(仅标准库,适合门禁设备等离线环境)
9
+
10
+ ```bash
11
+ pip install txcode-sdk
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```python
17
+ import asyncio
18
+ from txcode_sdk import TxCodeClient
19
+
20
+ async def main():
21
+ client = TxCodeClient(
22
+ api_key="sk-xxx",
23
+ base_url="https://api.openai.com/v1",
24
+ model="gpt-4",
25
+ )
26
+ result = await client.chat("Hello!")
27
+ print(result.answer)
28
+
29
+ asyncio.get_event_loop().run_until_complete(main())
30
+ ```
31
+
32
+ ## Features
33
+
34
+ - ReAct Agent loop with tool calling
35
+ - Multiple agent types: code, chat, common, task, plan, shell, skill, test, design, discuss, dream, name
36
+ - 10 built-in tools: read_file, write_file, edit_file, glob, grep, bash, memory, web_shell_exec, todo_read, todo_write
37
+ - Session management with JSON file persistence
38
+ - Context compression for long conversations
39
+ - Multimodal input support (images)
40
+ - Extensible custom tools
41
+ - Self-developed HTTP client (urllib, no openai/tiktoken dependency), supports OpenAI / DeepSeek / any OpenAI-compatible API
42
+
43
+ ## WebSocket Server
44
+
45
+ SDK 内置零第三方依赖的 WebSocket 服务端(RFC 6455 自研协议层,Python 3.6 兼容),
46
+ 支持 **txcode 桌面版远程连接**:把 SDK 安装到门禁 ARM 设备(Ubuntu 18 / Python 3.6)后,
47
+ Agent 循环与全部内置工具(read_file / write_file / edit_file / glob / grep / bash / todo 等)
48
+ 在**设备本地执行**,桌面版仅作为远程操作界面——实现"直接在门禁系统上开发门禁系统代码"。
49
+
50
+ ### 一条命令启动(主推)
51
+
52
+ ```bash
53
+ pip install txcode-sdk
54
+
55
+ txcode-sdk serve --work-dir 您的目录
56
+ ```
57
+
58
+ - `--work-dir`:门禁代码目录(**必填**,仅首次启动无当前项目时注册为当前项目),Agent 与内置工具在此目录下本地执行
59
+ - `--host` / `--port`:默认 `0.0.0.0:41000`
60
+ - `--agent-type`:默认 `code`
61
+ - `--models`:默认供应商初始模型列表 `[显示名=]模型名` 逗号分隔(仅首次注册默认供应商时使用);缺省读 `TXCODE_MODELS`,再缺省 = 不限制
62
+ - `TXCODE_API_KEY`:**可选**——仅当 `~/.txcode/providers.json` 不存在且希望首次自动注册默认供应商时使用;未设置时服务以**空配置**正常启动(stderr 打印 WARN 提示),供应商由桌面端通过 WS `add_provider` / `switch_provider` 动态添加,无需重启
63
+ - 兜底启动:`python -m txcode_sdk.server serve --work-dir ...`(无脚本路径时同样可用)
64
+
65
+ ### AI 运行参数(上下文大小 / 循环次数 / 思考强度)
66
+
67
+ 三项参数与桌面端「设置 - 系统配置」一致,**默认值与 txcode(TS 版)完全对齐**;修改后无需重启服务,
68
+ **下次 Agent 运行生效**:
69
+
70
+ | 配置 | `~/.txcode/config.json` key | 默认值 | 可选值 | CLI 参数 |
71
+ | --- | --- | --- | --- | --- |
72
+ | 上下文大小 | `ai.context.maxTokens` | `150000` | 128k / 150k / 200k / 320k / 1M | `--context-tokens` |
73
+ | 循环次数 | `ai.maxIterations` | `1000` | 100 / 500 / 1000 / 5000 | `--max-iterations` |
74
+ | 思考强度 | `ai.reasoningEffort` | `max` | none / minimal / low / medium / high / xhigh / max | `--reasoning-effort` |
75
+
76
+ 优先级:**显式 CLI 参数 > `~/.txcode/config.json`(桌面端写入)> 内置默认值**。
77
+
78
+ ```bash
79
+ txcode-sdk serve --work-dir /opt/door-access \
80
+ --context-tokens 320000 --max-iterations 500 --reasoning-effort high
81
+ ```
82
+
83
+ - 桌面端保存后经 `POST /api/sys_config/set_config` 立即热更新运行中的 client(压缩阈值 / ReAct 循环上限 / 请求体 `thinking` + `reasoning_effort`);
84
+ - 手工编辑 `~/.txcode/config.json` 亦可,下次 `chat` 前自动比对并应用;
85
+ - 非法值读取端回退默认值,写入端返回明确错误;`reasoning_effort` 仅在 `chat` 请求发送(`chat_stream` 固定关闭思考)。
86
+
87
+ ### 启动装配(JSON 为权威源,0.4.1)
88
+
89
+ 服务启动时以用户层 JSON 为权威源恢复上次状态,**重启自动恢复上次激活供应商/模型与当前项目**:
90
+
91
+ 1. **供应商**:加载 `~/.txcode/providers.json`——存在则取激活供应商的 `(api_key, base_url, model)` 直接构造
92
+ `TxCodeClient`(不读 `TXCODE_BASE_URL` / `TXCODE_MODEL`);不存在(首次启动/全新环境)且设置了
93
+ `TXCODE_API_KEY`(可选)时以 `TXCODE_BASE_URL` / `TXCODE_MODEL` 注册默认供应商并激活(`--models` 作为初始模型列表);
94
+ **未设置 `TXCODE_API_KEY` 时以空配置正常启动**(占位 client,不发起任何 API 请求),
95
+ 供应商由桌面端经 WS `add_provider` / `switch_provider` 动态添加;未配置供应商前 `chat` / `name_session`
96
+ 会收到「No active provider configured」提示,其余能力(WS 握手、ping、配置/项目管理消息)全部可用
97
+ 2. **项目**:加载 `~/.txcode/projects.json`——有当前项目则其 `path` 作为 work_dir(不读 `TXCODE_WORK_DIR`);
98
+ 无当前项目则 `--work-dir` 注册为当前项目后使用
99
+
100
+ 配置(供应商/模型/项目列表)存**用户层 `~/.txcode/`**,跨项目共享、切换项目不影响;
101
+ 会话仍按项目分别存于各自工作目录 `{work_dir}/.txcode/session/`。
102
+
103
+ ### 桌面版连接
104
+
105
+ 1. 桌面版「主机管理」添加远程主机:IP = 门禁设备 IP,端口 = 41000
106
+ 2. 桌面版自动以 `ws://{ip}:{port}/ws/code` 连接(无需任何桌面版改动)
107
+ 3. 发起对话:AI 在门禁系统本地读写文件、执行 `bash` 编译/运行/调试代码
108
+ 4. 文件变更实时推送(`file:changed` 事件),前端自动刷新文件树与编辑器
109
+
110
+ ### 协议消息
111
+
112
+ | 方向 | type | data |
113
+ |---|---|---|
114
+ | C→S | `chat` | message, sessionId, mediaFiles, agent, modelName(可选:命中即切换供应商/模型) |
115
+ | C→S | `stop` | sessionId(中断运行中会话) |
116
+ | C→S | `ping` | - |
117
+ | C→S | `get_running_sessions` | -(桌面版 5s 轮询) |
118
+ | C→S | `name_session` | sessionId, folderName, userInput |
119
+ | C→S | `get_providers` / `get_models` | - |
120
+ | C→S | `add_provider` | name, base_url, api_key, models |
121
+ | C→S | `update_provider` | providerId, name?, base_url?, api_key?, models? |
122
+ | C→S | `delete_provider` | providerId |
123
+ | C→S | `add_model` / `delete_model` | providerId, name / modelName |
124
+ | C→S | `switch_provider` | providerId, modelName? |
125
+ | C→S | `get_projects` | - |
126
+ | C→S | `open_project` | name, path |
127
+ | C→S | `select_project` / `delete_project` | projectId |
128
+ | S→C | `connected` / `step` / `compact` / `done` / `stopped` / `error` / `running_sessions` / `pong` / `rename` | 见下 |
129
+ | S→C | `providers_list` / `model_list` | get_providers / get_models 响应(仅发送方) |
130
+ | S→C | `providers_changed` | 供应商/模型增删改广播(全局) |
131
+ | S→C | `model_changed` | 模型/供应商切换成功广播(全局),data: {providerName, modelName, model} |
132
+ | S→C | `projects_list` | get_projects 响应(仅发送方) |
133
+ | S→C | `projects_changed` / `project_changed` | 项目列表变更 / 当前项目切换广播(全局) |
134
+
135
+ ### 供应商与模型管理
136
+
137
+ 服务端支持**动态添加/编辑/删除多个供应商**(OpenAI / DeepSeek / 自建网关),配置实时持久化到用户层
138
+ `~/.txcode/providers.json`,服务重启自动恢复;聊天消息携带 `modelName` 命中即切换(自动匹配供应商),
139
+ 也可用 `switch_provider` 显式切换。
140
+
141
+ `~/.txcode/providers.json` 结构(配置在用户层,跨项目共享,**不随 work_dir 变化**):
142
+
143
+ ```json
144
+ {
145
+ "providers": [
146
+ {
147
+ "id": "3f2a...",
148
+ "name": "OpenAI",
149
+ "base_url": "https://api.openai.com/v1",
150
+ "api_key": "sk-xxx",
151
+ "models": [{"name": "gpt-4o", "display_name": "GPT-4o"}],
152
+ "created_at": "2026-08-14T...",
153
+ "updated_at": "2026-08-14T..."
154
+ }
155
+ ],
156
+ "active_provider_id": "3f2a...",
157
+ "active_model": "gpt-4o"
158
+ }
159
+ ```
160
+
161
+ - **模型限制规则**:供应商 `models` 为空列表 = 不限制(向后兼容);非空 = 白名单校验
162
+ - **显示名**:`display_name` 对齐桌面版模型选择器语义(如 `DeepSeek V3` = `deepseek-chat`),
163
+ 匹配 name 与 display_name 双通道;`add_model` 缺省 display_name = name
164
+ - **api_key 安全**:WS 协议返回打码值(`sk-***` + 后 4 位);`update_provider` 传打码值/空不改原 key;
165
+ 明文仅存于用户层本地文件(权限建议 `chmod 600`)
144
166
  - **模型解析定序**:激活供应商优先 → 跨供应商按列表顺序第一个命中 → 未限制放行 → 全未命中回
145
167
  `error: Model not allowed: xxx, available: [..]`
146
168
 
147
- ### 项目管理
148
-
149
- 远程模式下桌面版右上角「打开项目 / 选择项目」由 SDK 侧 WS 协议提供等价能力:项目列表 / 打开(目录校验)/
150
- 选择(切换当前项目)/ 删除(不删实际文件),数据持久化到用户层 `~/.txcode/projects.json`(跨项目记忆);
151
- 选择/打开项目后 SDK 实时切换 `work_dir`(Agent 与内置工具基准目录立即生效,切换前中断全部运行中会话)。
152
-
153
- `~/.txcode/projects.json` 结构:
154
-
155
- ```json
156
- {
157
- "projects": [
158
- {"id": "a1b2...", "name": "door-access", "path": "/opt/door-access",
159
- "created_at": "2026-08-14T...", "updated_at": "2026-08-14T..."}
160
- ],
161
- "current_project_id": "a1b2..."
162
- }
163
- ```
164
-
165
- > 安全边界:供应商 `api_key` 明文存于用户层 `~/.txcode/providers.json`(本地文件,与 TS 版 sys_config
166
- > 数据库同等级别),仅限内网/受信网络部署,建议 `chmod 600`;WS 协议无鉴权,建议防火墙限制端口来源。
167
-
168
- `step` 事件数据形状(对齐桌面版):
169
-
170
- ```json
171
- {
172
- "type": "step",
173
- "data": {
174
- "reasoning": "...",
175
- "toolCalls": [{"id": "call-1", "type": "function", "function": {"name": "bash", "arguments": "{\"command\": \"python3 main.py\"}"}, "status": "completed"}],
176
- "success": true,
177
- "iteration": 1,
178
- "sessionId": "xxx",
179
- "usage": {"promptTokens": 10, "completionTokens": 5, "totalTokens": 15}
180
- }
181
- }
182
- ```
183
-
184
- ### 自定义工具(进阶,需写代码)
185
-
186
- `txcode-sdk serve` CLI **只支持内置工具**(远程开发场景完全够用)。
187
- 需要对接门禁硬件控制(`open_door` / `get_door_status` 等)时,走进阶示例
188
- [`src/example/ws_server.py`](src/example/ws_server.py):注册自定义工具 + 启动 `TxCodeServer`。
189
-
190
- ```python
191
- import asyncio
192
- from txcode_sdk import Tool, ToolResult, TxCodeClient
193
- from txcode_sdk.server import TxCodeServer
194
-
195
- def open_door(args, ctx):
196
- return ToolResult(success=True, output="door opened")
197
-
198
- client = TxCodeClient(
199
- api_key="sk-xxx", work_dir="/opt/door-access",
200
- tools=[Tool(name="open_door", description="打开门禁",
201
- parameters={"type": "object", "properties": {}}, execute=open_door)],
202
- )
203
- server = TxCodeServer(client, host="0.0.0.0", port=41000)
204
- asyncio.get_event_loop().run_until_complete(server.start())
205
- asyncio.get_event_loop().run_forever()
206
- ```
207
-
208
- ### 门禁系统部署(Ubuntu 18 / ARM)
209
-
210
- ```bash
211
- # 1. 安装(离线可先下载 wheel 拷贝)
212
- pip install txcode-sdk
213
- python3 -c "import txcode_sdk; print(txcode_sdk.__version__)"
214
-
215
- # 2. 验证端口监听
216
- txcode-sdk serve --work-dir /opt/door-access &
217
- ss -ltn | grep 41000
218
-
219
- # 3. systemd 常驻(/etc/systemd/system/txcode-sdk.service)
220
- # [Service] Environment=TXCODE_API_KEY=sk-xxx
221
- # ExecStart=/usr/local/bin/txcode-sdk serve --work-dir /opt/door-access
222
- # Restart=always
169
+ #### 配置导入 / 导出(与桌面版本地后端同一 YAML 契约)
170
+
171
+ `GET /api/sys_config/export_config` 与 `POST /api/sys_config/import_config`(请求体 `{"content": "<配置文件文本>"}`)
172
+ 使用**与桌面版本地后端 `tx_server` 完全相同的格式**:YAML、camelCase、模型在顶层 `models` 数组、**无 `success/data` 信封**。
173
+ 因此桌面端「导出配置」得到的 `config.yml` 可直接导入 SDK 主机,SDK 导出的 `config.yml` 也可直接导入桌面端/其他 SDK 主机。
174
+ 文本解析/生成由纯标准库模块 `yaml_lite` 完成(零第三方依赖,JSON 文本是 YAML 子集,同一入口天然兼容)。
175
+
176
+ 导出响应为文件附件:`Content-Type: application/x-yaml` + `Content-Disposition: attachment; filename=config.yml`:
177
+
178
+ ```yaml
179
+ providers:
180
+ - id: 3f2a1b... # 命中本地已有 id → 更新;未命中但 name 同名 → 更新该条;否则新增并保留文件中的 id
181
+ name: OpenAI
182
+ apiKey: sk-xxx # 明文(导入必需,注意保管);空串或打码值 sk-***xxxx 时不覆盖本地已有 key
183
+ baseUrl: https://api.openai.com/v1
184
+ enabled: true
185
+ isDefault: true
186
+ models:
187
+ - id: m-1 # SDK 无 model id 语义,导出时按 providerId + name 派生
188
+ providerId: 3f2a1b... # 关联同一文件内 providers[].id(导入期建立「文件 id → 本地 id」映射)
189
+ name: gpt-4o
190
+ contextWindow: 128000 # SDK 无此存储,导入时忽略不报错,导出时省略
191
+ maxOutputTokens: 8192
192
+ supportsVision: true
193
+ supportsTools: true
194
+ enabled: true
195
+ projects: # SDK 扩展段:目录存在则打开项目;桌面端后端解析时忽略该段,不报错
196
+ - id: a1b2c3
197
+ name: door-access
198
+ path: /opt/door-access
223
199
  ```
224
200
 
225
- > 安全边界:协议无鉴权(与桌面版/TS 版一致),仅限内网/受信网络部署,
226
- > 建议防火墙限制 41000 端口来源;鉴权(token 校验)列为二期增强。
201
+ - **兼容旧格式**:`providers[].models` 内联的模型数组(旧版 SDK 导出)仍可导入;
202
+ - **忽略未知段**:`providerAuth / gateway / wafGateway / email / proxy` 等桌面端专属段只解析不落库,不报错;
203
+ - **幂等**:同一文件重复导入不产生重复供应商/模型(id 命中走更新,未命中同名走更新);
204
+ - **可读报错**:语法不合法(含锚点/别名/多文档等 YAML 子集外特性)返回 400
205
+ `{"success": false, "error": "配置文件格式无效(第 N 行): ..."}`,不再透出 Python 异常串;
206
+ - **统计反馈**:成功返回 `{"success": true, "message": "配置导入成功", "data": {"providers": 6, "models": 12, "projects": 2, "skipped": []}}`,
207
+ `skipped` 列出被跳过的条目及原因(缺 apiKey 的新供应商、`providerId` 不存在或目录不存在的项目等)。
208
+
209
+ ### 项目管理
210
+
211
+ 远程模式下桌面版右上角「打开项目 / 选择项目」由 SDK 侧 WS 协议提供等价能力:项目列表 / 打开(目录校验)/
212
+ 选择(切换当前项目)/ 删除(不删实际文件),数据持久化到用户层 `~/.txcode/projects.json`(跨项目记忆);
213
+ 选择/打开项目后 SDK 实时切换 `work_dir`(Agent 与内置工具基准目录立即生效,切换前中断全部运行中会话)。
214
+
215
+ `~/.txcode/projects.json` 结构:
216
+
217
+ ```json
218
+ {
219
+ "projects": [
220
+ {"id": "a1b2...", "name": "door-access", "path": "/opt/door-access",
221
+ "created_at": "2026-08-14T...", "updated_at": "2026-08-14T..."}
222
+ ],
223
+ "current_project_id": "a1b2..."
224
+ }
225
+ ```
226
+
227
+ > 安全边界:供应商 `api_key` 明文存于用户层 `~/.txcode/providers.json`(本地文件,与 TS 版 sys_config
228
+ > 数据库同等级别),仅限内网/受信网络部署,建议 `chmod 600`;WS 协议无鉴权,建议防火墙限制端口来源。
229
+
230
+ `step` 事件数据形状(对齐桌面版):
231
+
232
+ ```json
233
+ {
234
+ "type": "step",
235
+ "data": {
236
+ "reasoning": "...",
237
+ "toolCalls": [{"id": "call-1", "type": "function", "function": {"name": "bash", "arguments": "{\"command\": \"python3 main.py\"}"}, "status": "completed"}],
238
+ "success": true,
239
+ "iteration": 1,
240
+ "sessionId": "xxx",
241
+ "usage": {"promptTokens": 10, "completionTokens": 5, "totalTokens": 15}
242
+ }
243
+ }
244
+ ```
245
+
246
+ ### 自定义工具(进阶,需写代码)
247
+
248
+ `txcode-sdk serve` CLI **只支持内置工具**(远程开发场景完全够用)。
249
+ 需要对接门禁硬件控制(`open_door` / `get_door_status` 等)时,走进阶示例
250
+ [`src/example/ws_server.py`](src/example/ws_server.py):注册自定义工具 + 启动 `TxCodeServer`。
251
+
252
+ ```python
253
+ import asyncio
254
+ from txcode_sdk import Tool, ToolResult, TxCodeClient
255
+ from txcode_sdk.server import TxCodeServer
256
+
257
+ def open_door(args, ctx):
258
+ return ToolResult(success=True, output="door opened")
259
+
260
+ client = TxCodeClient(
261
+ api_key="sk-xxx", work_dir="/opt/door-access",
262
+ tools=[Tool(name="open_door", description="打开门禁",
263
+ parameters={"type": "object", "properties": {}}, execute=open_door)],
264
+ )
265
+ server = TxCodeServer(client, host="0.0.0.0", port=41000)
266
+ asyncio.get_event_loop().run_until_complete(server.start())
267
+ asyncio.get_event_loop().run_forever()
268
+ ```
269
+
270
+ ### 门禁系统部署(Ubuntu 18 / ARM)
271
+
272
+ ```bash
273
+ # 1. 安装(离线可先下载 wheel 拷贝)
274
+ pip install txcode-sdk
275
+ python3 -c "import txcode_sdk; print(txcode_sdk.__version__)"
276
+
277
+ # 2. 验证端口监听
278
+ txcode-sdk serve --work-dir /opt/door-access &
279
+ ss -ltn | grep 41000
280
+
281
+ # 3. systemd 常驻(/etc/systemd/system/txcode-sdk.service)
282
+ # [Service] Environment=TXCODE_API_KEY=sk-xxx
283
+ # ExecStart=/usr/local/bin/txcode-sdk serve --work-dir /opt/door-access
284
+ # Restart=always
285
+ ```
286
+
287
+ > 安全边界:协议无鉴权(与桌面版/TS 版一致),仅限内网/受信网络部署,
288
+ > 建议防火墙限制 41000 端口来源;鉴权(token 校验)列为二期增强。