txcode-sdk 0.4.1__tar.gz → 0.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 (171) hide show
  1. {txcode_sdk-0.4.1/src/txcode_sdk.egg-info → txcode_sdk-0.5.0}/PKG-INFO +1 -1
  2. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/pyproject.toml +1 -1
  3. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/client.py +5 -0
  4. txcode_sdk-0.5.0/src/txcode_sdk/server/config_store.py +39 -0
  5. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/handler.py +42 -13
  6. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/http.py +469 -4
  7. txcode_sdk-0.5.0/src/txcode_sdk/server/hub_client.py +139 -0
  8. txcode_sdk-0.5.0/src/txcode_sdk/server/plan_code.py +234 -0
  9. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/server.py +19 -0
  10. txcode_sdk-0.5.0/src/txcode_sdk/server/skill_manager.py +148 -0
  11. txcode_sdk-0.5.0/src/txcode_sdk/server/spec_manager.py +121 -0
  12. txcode_sdk-0.5.0/src/txcode_sdk/server/zip_utils.py +42 -0
  13. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/session/manager.py +50 -1
  14. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0/src/txcode_sdk.egg-info}/PKG-INFO +1 -1
  15. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk.egg-info/SOURCES.txt +7 -0
  16. txcode_sdk-0.5.0/tests/test_http_ext_api.py +612 -0
  17. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/LICENSE +0 -0
  18. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/README.md +0 -0
  19. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/setup.cfg +0 -0
  20. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/setup.py +0 -0
  21. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/__init__.py +0 -0
  22. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/code_example.py +0 -0
  23. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/code_session.py +0 -0
  24. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/code_tool.py +0 -0
  25. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/constants.py +0 -0
  26. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/query_session.py +0 -0
  27. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/example/ws_server.py +0 -0
  28. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/__init__.py +0 -0
  29. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/_compat/__init__.py +0 -0
  30. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/_compat/dataclasses.py +0 -0
  31. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/_compat/resources.py +0 -0
  32. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/__init__.py +0 -0
  33. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/base_agent.py +0 -0
  34. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/chat/__init__.py +0 -0
  35. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/chat/agent_tool.py +0 -0
  36. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/chat/chat_agent.py +0 -0
  37. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/chat/prompts/__init__.py +0 -0
  38. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/chat/prompts/role.txt +0 -0
  39. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/code/__init__.py +0 -0
  40. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/code/agent_tool.py +0 -0
  41. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/code/code_agent.py +0 -0
  42. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/code/prompts/__init__.py +0 -0
  43. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/code/prompts/role.txt +0 -0
  44. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/common/__init__.py +0 -0
  45. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/common/common_agent.py +0 -0
  46. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/common/prompt/__init__.py +0 -0
  47. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/common/prompt/role.txt +0 -0
  48. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/design/__init__.py +0 -0
  49. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/design/agent_tool.py +0 -0
  50. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/design/design_agent.py +0 -0
  51. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/design/prompts/__init__.py +0 -0
  52. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/design/prompts/role.txt +0 -0
  53. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/discuss/__init__.py +0 -0
  54. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/discuss/agent_tool.py +0 -0
  55. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/discuss/discuss_agent.py +0 -0
  56. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/discuss/prompts/__init__.py +0 -0
  57. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/discuss/prompts/role.txt +0 -0
  58. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/dream/__init__.py +0 -0
  59. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/dream/agent_tool.py +0 -0
  60. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/dream/dream_agent.py +0 -0
  61. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/dream/prompts/__init__.py +0 -0
  62. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/dream/prompts/role.txt +0 -0
  63. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/mem/__init__.py +0 -0
  64. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/mem/agent_tool.py +0 -0
  65. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/mem/mem_agent.py +0 -0
  66. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/mem/prompts/__init__.py +0 -0
  67. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/mem/prompts/role.txt +0 -0
  68. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/name/__init__.py +0 -0
  69. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/name/name_agent.py +0 -0
  70. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/name/prompts/__init__.py +0 -0
  71. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/name/prompts/role.txt +0 -0
  72. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/plan/__init__.py +0 -0
  73. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/plan/agent_tool.py +0 -0
  74. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/plan/plan_agent.py +0 -0
  75. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/plan/prompts/__init__.py +0 -0
  76. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/plan/prompts/role.txt +0 -0
  77. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/shell/__init__.py +0 -0
  78. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/shell/agent_tool.py +0 -0
  79. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/shell/prompts/__init__.py +0 -0
  80. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/shell/prompts/role.txt +0 -0
  81. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/shell/shell_agent.py +0 -0
  82. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/skill/__init__.py +0 -0
  83. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/skill/agent_tool.py +0 -0
  84. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/skill/prompts/__init__.py +0 -0
  85. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/skill/prompts/role.txt +0 -0
  86. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/skill/skill_agent.py +0 -0
  87. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/summarizer/__init__.py +0 -0
  88. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/summarizer/prompts/__init__.py +0 -0
  89. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/summarizer/prompts/role.txt +0 -0
  90. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/summarizer/summarizer_agent.py +0 -0
  91. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/task/__init__.py +0 -0
  92. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/task/agent_tool.py +0 -0
  93. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/task/prompts/__init__.py +0 -0
  94. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/task/prompts/role.txt +0 -0
  95. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/task/task_agent.py +0 -0
  96. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/test/__init__.py +0 -0
  97. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/test/agent_tool.py +0 -0
  98. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/test/prompts/__init__.py +0 -0
  99. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/test/prompts/role.txt +0 -0
  100. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/test/test_agent.py +0 -0
  101. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/agent/tool_registry.py +0 -0
  102. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/compact/__init__.py +0 -0
  103. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/compact/compressor.py +0 -0
  104. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/__init__.py +0 -0
  105. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/handlers/__init__.py +0 -0
  106. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/handlers/base.py +0 -0
  107. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/handlers/memory.py +0 -0
  108. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/processor.py +0 -0
  109. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/queue.py +0 -0
  110. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/hooks/types.py +0 -0
  111. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/provider/__init__.py +0 -0
  112. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/provider/base.py +0 -0
  113. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/provider/deepseek_provider.py +0 -0
  114. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/provider/openai_provider.py +0 -0
  115. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/provider/router.py +0 -0
  116. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/provider/txcode_ai.py +0 -0
  117. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/__init__.py +0 -0
  118. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/__main__.py +0 -0
  119. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/json_store.py +0 -0
  120. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/project_manager.py +0 -0
  121. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/provider_config.py +0 -0
  122. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/server/websocket.py +0 -0
  123. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/session/__init__.py +0 -0
  124. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/skills/__init__.py +0 -0
  125. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/specs/__init__.py +0 -0
  126. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/__init__.py +0 -0
  127. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/bash.txt +0 -0
  128. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/bash_tool.py +0 -0
  129. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/edit_file.py +0 -0
  130. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/edit_file.txt +0 -0
  131. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/glob.txt +0 -0
  132. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/glob_tool.py +0 -0
  133. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/grep.txt +0 -0
  134. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/grep_tool.py +0 -0
  135. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/memory_tool.py +0 -0
  136. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/read_file.py +0 -0
  137. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/read_file.txt +0 -0
  138. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/todo_read.py +0 -0
  139. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/todo_read.txt +0 -0
  140. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/todo_write.py +0 -0
  141. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/todo_write.txt +0 -0
  142. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/web_shell_exec.py +0 -0
  143. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/web_shell_exec.txt +0 -0
  144. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/write_file.py +0 -0
  145. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/tools/write_file.txt +0 -0
  146. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk/types.py +0 -0
  147. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk.egg-info/dependency_links.txt +0 -0
  148. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk.egg-info/entry_points.txt +0 -0
  149. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/src/txcode_sdk.egg-info/top_level.txt +0 -0
  150. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_cli.py +0 -0
  151. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_client.py +0 -0
  152. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_compat.py +0 -0
  153. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_design_agent.py +0 -0
  154. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_discuss_agent.py +0 -0
  155. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_dream_agent.py +0 -0
  156. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_http_api.py +0 -0
  157. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_json_store.py +0 -0
  158. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_name_agent.py +0 -0
  159. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_plan_agent.py +0 -0
  160. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_project_manager.py +0 -0
  161. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_provider_config.py +0 -0
  162. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_provider_model.py +0 -0
  163. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_session.py +0 -0
  164. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_session_query.py +0 -0
  165. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_shell_agent.py +0 -0
  166. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_skill_agent.py +0 -0
  167. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_test_agent.py +0 -0
  168. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_tools.py +0 -0
  169. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_txcode_ai.py +0 -0
  170. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_websocket_protocol.py +0 -0
  171. {txcode_sdk-0.4.1 → txcode_sdk-0.5.0}/tests/test_ws_server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txcode-sdk
3
- Version: 0.4.1
3
+ Version: 0.5.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.4.1"
7
+ version = "0.5.0"
8
8
  description = "AI Agent SDK with built-in tools for Python projects"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -68,6 +68,11 @@ class TxCodeClient:
68
68
  def work_dir(self) -> str:
69
69
  return self._work_dir
70
70
 
71
+ @property
72
+ def session_manager(self) -> SessionManager:
73
+ """当前 SessionManager(set_work_dir 重建后仍指向最新实例)。"""
74
+ return self._session_manager
75
+
71
76
  def get_model(self) -> str:
72
77
  return self._model
73
78
 
@@ -0,0 +1,39 @@
1
+ """ConfigStore:通用 KV 配置存储(`~/.txcode/config.json`,用户级,跨项目共享)。
2
+
3
+ 与 TS 版 configService 对齐:字符串值原样存取,非字符串 JSON 序列化。
4
+ 复用 JsonStore(asyncio.Lock + 原子写),Python 3.6 兼容,零第三方依赖。
5
+ """
6
+
7
+ import json
8
+ import os
9
+
10
+ from .json_store import JsonStore
11
+
12
+
13
+ class ConfigStore:
14
+ """通用 KV 配置:~/.txcode/config.json(用户级,跨项目共享)。"""
15
+
16
+ def __init__(self, path: str = "~/.txcode/config.json"):
17
+ self._store = JsonStore(os.path.expanduser(path))
18
+
19
+ def get(self, key: str):
20
+ """不存在返回 None;值为字符串原样返回,否则返回 JSON 对象。"""
21
+ data = self._store.load({})
22
+ value = data.get(key)
23
+ if value is None:
24
+ return None
25
+ if isinstance(value, str):
26
+ return value
27
+ try:
28
+ return json.loads(value)
29
+ except (TypeError, ValueError):
30
+ return value
31
+
32
+ async def set(self, key: str, value):
33
+ """value 为字符串原样存,否则 json.dumps;原子写。"""
34
+ data = self._store.load({})
35
+ if isinstance(value, str):
36
+ data[key] = value
37
+ else:
38
+ data[key] = json.dumps(value, ensure_ascii=False)
39
+ await self._store.save(data)
@@ -12,6 +12,7 @@ import os
12
12
  from typing import Any, Dict, Optional, Set
13
13
 
14
14
  from ..types import MediaFile, StepInfo
15
+ from .config_store import ConfigStore
15
16
  from .provider_config import ProviderConfigManager
16
17
  from .project_manager import ProjectManager
17
18
  from .websocket import OPCODE_TEXT, build_close_frame, build_frame, read_message
@@ -66,10 +67,11 @@ def _usage_to_desktop(usage) -> Optional[dict]:
66
67
 
67
68
 
68
69
  class CodeWebSocketHandler:
69
- def __init__(self, client, provider_config=None, project_manager=None):
70
+ def __init__(self, client, provider_config=None, project_manager=None, config_store=None):
70
71
  self._client = client
71
72
  self._provider_config = provider_config or ProviderConfigManager()
72
73
  self._project_manager = project_manager or ProjectManager()
74
+ self._config_store = config_store or ConfigStore()
73
75
  self._writers: Set = set()
74
76
  self._abort_signals: Dict[str, AbortSignal] = {}
75
77
  self._running: Set[str] = set()
@@ -194,25 +196,29 @@ class CodeWebSocketHandler:
194
196
  self.broadcast({"type": "error", "error": "sessionId is required"})
195
197
  return
196
198
 
199
+ # ① 携带 modelName → 优先解析激活(_apply_model_name 内部 resolve + switch + client.set_provider)
200
+ model_name = data.get("modelName")
201
+ if model_name:
202
+ ok = await self._apply_model_name(model_name, session_id)
203
+ if not ok:
204
+ return
205
+
206
+ # ② 无 modelName → 从 KV defaultModel 兜底激活
197
207
  active_provider, _ = self._provider_config.get_active()
198
208
  if not active_provider:
199
- self.broadcast({
200
- "type": "error",
201
- "sessionId": session_id,
202
- "error": "No active provider configured, please add provider first",
203
- })
204
- return
209
+ ok = await self._ensure_default_provider()
210
+ if not ok:
211
+ self.broadcast({
212
+ "type": "error",
213
+ "sessionId": session_id,
214
+ "error": "No active provider configured, please add provider first",
215
+ })
216
+ return
205
217
 
206
218
  message = data.get("message", "")
207
219
  agent_type = data.get("agent") or "code"
208
220
  media_files = data.get("mediaFiles") or []
209
221
 
210
- model_name = data.get("modelName")
211
- if model_name:
212
- ok = await self._apply_model_name(model_name, session_id)
213
- if not ok:
214
- return
215
-
216
222
  existing = self._abort_signals.get(session_id)
217
223
  if existing:
218
224
  existing.abort()
@@ -302,6 +308,29 @@ class CodeWebSocketHandler:
302
308
 
303
309
  # ---------- 供应商 / 模型 ----------
304
310
 
311
+ async def _ensure_default_provider(self) -> bool:
312
+ """KV defaultModel → resolve_model → switch 激活 + 同步 client。成功返回 True。"""
313
+ model_name = self._config_store.get("defaultModel")
314
+ if not model_name:
315
+ return False
316
+ resolved = self._provider_config.resolve_model(model_name)
317
+ if resolved is None:
318
+ return False
319
+ provider_id, resolved_model = resolved
320
+ provider = self._provider_config.get_provider(provider_id)
321
+ if not provider:
322
+ return False
323
+ await self._provider_config.switch(provider_id, resolved_model)
324
+ self._client.set_provider(
325
+ provider.get("api_key", ""), provider.get("base_url", ""), resolved_model
326
+ )
327
+ self.broadcast({"type": "model_changed", "data": {
328
+ "providerName": provider.get("name", ""),
329
+ "modelName": model_name,
330
+ "model": resolved_model,
331
+ }})
332
+ return True
333
+
305
334
  async def _apply_model_name(self, model_name: str, session_id: str) -> bool:
306
335
  """chat.modelName 解析:命中 → 切换供应商/模型 + 广播 model_changed;未命中 → error。"""
307
336
  resolved = self._provider_config.resolve_model(model_name)