txcode-sdk 1.5.0__tar.gz → 1.6.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.
- {txcode_sdk-1.5.0/src/txcode_sdk.egg-info → txcode_sdk-1.6.0}/PKG-INFO +16 -1
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/README.md +58 -43
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/pyproject.toml +1 -1
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/__init__.py +1 -1
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/message_utils.py +25 -12
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/handler.py +5 -1
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/__init__.py +2 -0
- txcode_sdk-1.6.0/src/txcode_sdk/server/http/chat_routes.py +164 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/http_base.py +23 -6
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/server.py +1 -0
- txcode_sdk-1.6.0/src/txcode_sdk/utils/multipart.py +104 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0/src/txcode_sdk.egg-info}/PKG-INFO +16 -1
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk.egg-info/SOURCES.txt +2 -0
- txcode_sdk-1.6.0/tests/test_chat_upload.py +275 -0
- txcode_sdk-1.5.0/src/txcode_sdk/server/http/chat_routes.py +0 -64
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/LICENSE +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/setup.cfg +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/setup.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/code_example.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/code_session.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/code_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/constants.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/query_session.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/example/ws_server.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/_compat/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/_compat/dataclasses.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/_compat/resources.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/base_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/chat/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/chat/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/chat/chat_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/chat/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/chat/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/code/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/code/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/code/code_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/code/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/code/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/common/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/common/common_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/common/prompt/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/common/prompt/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/compact_mixin.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/design/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/design/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/design/design_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/design/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/design/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/discuss/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/discuss/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/discuss/discuss_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/discuss/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/discuss/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/dream/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/dream/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/dream/dream_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/dream/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/dream/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/factory.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/hook_mixin.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/mem/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/mem/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/mem/mem_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/mem/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/mem/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/name/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/name/name_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/name/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/name/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/plan/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/plan/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/plan/plan_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/plan/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/plan/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/prompt_builder.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/shell/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/shell/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/shell/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/shell/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/shell/shell_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/skill/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/skill/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/skill/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/skill/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/skill/skill_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/step_utils.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/summarizer/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/summarizer/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/summarizer/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/summarizer/summarizer_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/task/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/task/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/task/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/task/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/task/task_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/test/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/test/agent_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/test/prompts/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/test/prompts/role.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/test/test_agent.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/agent/tool_registry.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/client.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/compact/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/compact/compressor.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/config/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/config/ai_settings.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/config/context_config.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/handlers/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/handlers/base.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/handlers/memory.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/processor.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/queue.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/hooks/types.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/provider/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/provider/base.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/provider/deepseek_provider.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/provider/openai_provider.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/provider/router.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/provider/txcode_ai.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/__main__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/config_store.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/git.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/file_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/git_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/plan_code_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/project_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/session_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/skill_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/spec_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/http/sys_config_routes.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/hub_client.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/json_store.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/plan_code.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/project_manager.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/provider_config.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/services/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/services/broadcaster.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/services/config_import_export.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/services/project_service.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/services/provider_service.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/skill_manager.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/spec_manager.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/websocket.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/yaml_lite.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/server/zip_utils.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/session/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/session/manager.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/skills/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/specs/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/_util.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/bash.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/bash.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/code_search.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/code_search.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/edit_file.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/edit_file.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/edit_replacers.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/edit_similarity.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/email_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/email_tool.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/glob.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/glob.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/grep.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/grep.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/memory.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/memory.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/read_file.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/read_file.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/skill_tool.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/skill_tool.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/todo_read.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/todo_read.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/todo_write.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/todo_write.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/web_fetch.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/web_fetch.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/web_search.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/web_search.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/web_shell_exec.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/web_shell_exec.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/write_file.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/tools/write_file.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/types.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/utils/__init__.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/utils/format.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/utils/log.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/utils/path_util.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk/utils/time_util.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk.egg-info/dependency_links.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk.egg-info/entry_points.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/src/txcode_sdk.egg-info/top_level.txt +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_ai_settings.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_provider_reasoning_effort.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_server_cli_logging.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_sys_config_ai_settings.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_sys_config_import_export.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_txcode_ai.py +0 -0
- {txcode_sdk-1.5.0 → txcode_sdk-1.6.0}/tests/test_yaml_lite.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: txcode-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: AI Agent SDK with built-in tools for Python projects
|
|
5
5
|
Author: homecommunity
|
|
6
6
|
License: MIT
|
|
@@ -157,6 +157,21 @@ txcode-sdk serve --work-dir /opt/door-access \
|
|
|
157
157
|
| S→C | `projects_list` | get_projects 响应(仅发送方) |
|
|
158
158
|
| S→C | `projects_changed` / `project_changed` | 项目列表变更 / 当前项目切换广播(全局) |
|
|
159
159
|
|
|
160
|
+
### 图片上传 / 下载
|
|
161
|
+
|
|
162
|
+
桌面端粘贴/选择图片后先调上传接口,再把 `mediaFiles`(`[{filePath, type, dataUrl?}]`)随 `chat` 一并发送:
|
|
163
|
+
|
|
164
|
+
- `POST /api/chat/upload_image_chat`:`multipart/form-data` 字段名 `file`,落盘当前项目
|
|
165
|
+
`.txcode/uploads/<YYYY-MM-DD>/<uuid>.<ext>`,返回 `{filePath, url, type, size}`;
|
|
166
|
+
单文件上限 10MB,仅支持 `.png/.jpg/.jpeg/.gif/.webp/.bmp/.svg`
|
|
167
|
+
- `GET /api/chat/file_download?filePath=<绝对/相对路径>`:返回图片二进制(按扩展名定 `Content-Type`),
|
|
168
|
+
供 `<img src>` / Electron 直取;文件不存在 404,缺 `filePath` 400
|
|
169
|
+
- `GET /api/chat/history_chat?sessionId=<id>`:用户消息的 `mediaFiles[]` 含 `filePath/url/type`,
|
|
170
|
+
历史会话重开后图片仍可渲染(`url` 为绝对地址,`Host` 缺失回退 `localhost:<端口>`)
|
|
171
|
+
|
|
172
|
+
发送链路对图片按 `work_dir` 解析相对路径并转 `data:` URI(`dataUrl` 存在时优先),
|
|
173
|
+
单张图片读取失败仅告警跳过,不中断整轮对话。
|
|
174
|
+
|
|
160
175
|
### 供应商与模型管理
|
|
161
176
|
|
|
162
177
|
服务端支持**动态添加/编辑/删除多个供应商**(OpenAI / DeepSeek / 自建网关),配置实时持久化到用户层
|
|
@@ -132,6 +132,21 @@ txcode-sdk serve --work-dir /opt/door-access \
|
|
|
132
132
|
| S→C | `projects_list` | get_projects 响应(仅发送方) |
|
|
133
133
|
| S→C | `projects_changed` / `project_changed` | 项目列表变更 / 当前项目切换广播(全局) |
|
|
134
134
|
|
|
135
|
+
### 图片上传 / 下载
|
|
136
|
+
|
|
137
|
+
桌面端粘贴/选择图片后先调上传接口,再把 `mediaFiles`(`[{filePath, type, dataUrl?}]`)随 `chat` 一并发送:
|
|
138
|
+
|
|
139
|
+
- `POST /api/chat/upload_image_chat`:`multipart/form-data` 字段名 `file`,落盘当前项目
|
|
140
|
+
`.txcode/uploads/<YYYY-MM-DD>/<uuid>.<ext>`,返回 `{filePath, url, type, size}`;
|
|
141
|
+
单文件上限 10MB,仅支持 `.png/.jpg/.jpeg/.gif/.webp/.bmp/.svg`
|
|
142
|
+
- `GET /api/chat/file_download?filePath=<绝对/相对路径>`:返回图片二进制(按扩展名定 `Content-Type`),
|
|
143
|
+
供 `<img src>` / Electron 直取;文件不存在 404,缺 `filePath` 400
|
|
144
|
+
- `GET /api/chat/history_chat?sessionId=<id>`:用户消息的 `mediaFiles[]` 含 `filePath/url/type`,
|
|
145
|
+
历史会话重开后图片仍可渲染(`url` 为绝对地址,`Host` 缺失回退 `localhost:<端口>`)
|
|
146
|
+
|
|
147
|
+
发送链路对图片按 `work_dir` 解析相对路径并转 `data:` URI(`dataUrl` 存在时优先),
|
|
148
|
+
单张图片读取失败仅告警跳过,不中断整轮对话。
|
|
149
|
+
|
|
135
150
|
### 供应商与模型管理
|
|
136
151
|
|
|
137
152
|
服务端支持**动态添加/编辑/删除多个供应商**(OpenAI / DeepSeek / 自建网关),配置实时持久化到用户层
|
|
@@ -163,49 +178,49 @@ txcode-sdk serve --work-dir /opt/door-access \
|
|
|
163
178
|
匹配 name 与 display_name 双通道;`add_model` 缺省 display_name = name
|
|
164
179
|
- **api_key 安全**:WS 协议返回打码值(`sk-***` + 后 4 位);`update_provider` 传打码值/空不改原 key;
|
|
165
180
|
明文仅存于用户层本地文件(权限建议 `chmod 600`)
|
|
166
|
-
- **模型解析定序**:激活供应商优先 → 跨供应商按列表顺序第一个命中 → 未限制放行 → 全未命中回
|
|
167
|
-
`error: Model not allowed: xxx, available: [..]`
|
|
168
|
-
|
|
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
|
|
199
|
-
```
|
|
200
|
-
|
|
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
|
-
|
|
181
|
+
- **模型解析定序**:激活供应商优先 → 跨供应商按列表顺序第一个命中 → 未限制放行 → 全未命中回
|
|
182
|
+
`error: Model not allowed: xxx, available: [..]`
|
|
183
|
+
|
|
184
|
+
#### 配置导入 / 导出(与桌面版本地后端同一 YAML 契约)
|
|
185
|
+
|
|
186
|
+
`GET /api/sys_config/export_config` 与 `POST /api/sys_config/import_config`(请求体 `{"content": "<配置文件文本>"}`)
|
|
187
|
+
使用**与桌面版本地后端 `tx_server` 完全相同的格式**:YAML、camelCase、模型在顶层 `models` 数组、**无 `success/data` 信封**。
|
|
188
|
+
因此桌面端「导出配置」得到的 `config.yml` 可直接导入 SDK 主机,SDK 导出的 `config.yml` 也可直接导入桌面端/其他 SDK 主机。
|
|
189
|
+
文本解析/生成由纯标准库模块 `yaml_lite` 完成(零第三方依赖,JSON 文本是 YAML 子集,同一入口天然兼容)。
|
|
190
|
+
|
|
191
|
+
导出响应为文件附件:`Content-Type: application/x-yaml` + `Content-Disposition: attachment; filename=config.yml`:
|
|
192
|
+
|
|
193
|
+
```yaml
|
|
194
|
+
providers:
|
|
195
|
+
- id: 3f2a1b... # 命中本地已有 id → 更新;未命中但 name 同名 → 更新该条;否则新增并保留文件中的 id
|
|
196
|
+
name: OpenAI
|
|
197
|
+
apiKey: sk-xxx # 明文(导入必需,注意保管);空串或打码值 sk-***xxxx 时不覆盖本地已有 key
|
|
198
|
+
baseUrl: https://api.openai.com/v1
|
|
199
|
+
enabled: true
|
|
200
|
+
isDefault: true
|
|
201
|
+
models:
|
|
202
|
+
- id: m-1 # SDK 无 model id 语义,导出时按 providerId + name 派生
|
|
203
|
+
providerId: 3f2a1b... # 关联同一文件内 providers[].id(导入期建立「文件 id → 本地 id」映射)
|
|
204
|
+
name: gpt-4o
|
|
205
|
+
contextWindow: 128000 # SDK 无此存储,导入时忽略不报错,导出时省略
|
|
206
|
+
maxOutputTokens: 8192
|
|
207
|
+
supportsVision: true
|
|
208
|
+
supportsTools: true
|
|
209
|
+
enabled: true
|
|
210
|
+
projects: # SDK 扩展段:目录存在则打开项目;桌面端后端解析时忽略该段,不报错
|
|
211
|
+
- id: a1b2c3
|
|
212
|
+
name: door-access
|
|
213
|
+
path: /opt/door-access
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- **兼容旧格式**:`providers[].models` 内联的模型数组(旧版 SDK 导出)仍可导入;
|
|
217
|
+
- **忽略未知段**:`providerAuth / gateway / wafGateway / email / proxy` 等桌面端专属段只解析不落库,不报错;
|
|
218
|
+
- **幂等**:同一文件重复导入不产生重复供应商/模型(id 命中走更新,未命中同名走更新);
|
|
219
|
+
- **可读报错**:语法不合法(含锚点/别名/多文档等 YAML 子集外特性)返回 400
|
|
220
|
+
`{"success": false, "error": "配置文件格式无效(第 N 行): ..."}`,不再透出 Python 异常串;
|
|
221
|
+
- **统计反馈**:成功返回 `{"success": true, "message": "配置导入成功", "data": {"providers": 6, "models": 12, "projects": 2, "skipped": []}}`,
|
|
222
|
+
`skipped` 列出被跳过的条目及原因(缺 apiKey 的新供应商、`providerId` 不存在或目录不存在的项目等)。
|
|
223
|
+
|
|
209
224
|
### 项目管理
|
|
210
225
|
|
|
211
226
|
远程模式下桌面版右上角「打开项目 / 选择项目」由 SDK 侧 WS 协议提供等价能力:项目列表 / 打开(目录校验)/
|
|
@@ -5,10 +5,16 @@
|
|
|
5
5
|
_history_to_chat_message(历史 dict → ChatMessage)、_build_tool_context。
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import base64
|
|
8
9
|
import json
|
|
10
|
+
import logging
|
|
11
|
+
import mimetypes
|
|
9
12
|
from typing import List, Optional
|
|
10
13
|
|
|
11
14
|
from ..types import ChatMessage, ImageContent, MediaFile, TextContent
|
|
15
|
+
from ..utils.path_util import _resolve_path
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
12
18
|
|
|
13
19
|
|
|
14
20
|
class MessageUtilsMixin:
|
|
@@ -18,21 +24,28 @@ class MessageUtilsMixin:
|
|
|
18
24
|
if media_files:
|
|
19
25
|
content: list = [TextContent(text=text)]
|
|
20
26
|
for mf in media_files:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import base64
|
|
25
|
-
import mimetypes
|
|
26
|
-
from pathlib import Path
|
|
27
|
-
path = Path(mf.file_path)
|
|
28
|
-
mime = mf.type or mimetypes.guess_type(str(path))[0] or "image/png"
|
|
29
|
-
with open(path, "rb") as f:
|
|
30
|
-
b64 = base64.b64encode(f.read()).decode("utf-8")
|
|
31
|
-
url = "data:%s;base64,%s" % (mime, b64)
|
|
32
|
-
content.append(ImageContent(url=url))
|
|
27
|
+
url = self._media_file_to_url(mf)
|
|
28
|
+
if url:
|
|
29
|
+
content.append(ImageContent(url=url))
|
|
33
30
|
return ChatMessage(role="user", content=content)
|
|
34
31
|
return ChatMessage(role="user", content=text)
|
|
35
32
|
|
|
33
|
+
def _media_file_to_url(self, mf: MediaFile) -> Optional[str]:
|
|
34
|
+
"""图片 → `data:` URI;读取失败返回 None(跳过该图,不中断整轮对话)。"""
|
|
35
|
+
if mf.data_url:
|
|
36
|
+
return mf.data_url
|
|
37
|
+
if not mf.file_path:
|
|
38
|
+
return None
|
|
39
|
+
path = _resolve_path(mf.file_path, self._work_dir)
|
|
40
|
+
try:
|
|
41
|
+
mime = mf.type or mimetypes.guess_type(str(path))[0] or "image/png"
|
|
42
|
+
with open(str(path), "rb") as f:
|
|
43
|
+
b64 = base64.b64encode(f.read()).decode("utf-8")
|
|
44
|
+
except Exception as exc:
|
|
45
|
+
logger.warning("image load failed | path=%s error=%s", path, exc)
|
|
46
|
+
return None
|
|
47
|
+
return "data:%s;base64,%s" % (mime, b64)
|
|
48
|
+
|
|
36
49
|
def _build_tool_context(self, session_id: str):
|
|
37
50
|
from ..types import ToolContext
|
|
38
51
|
return ToolContext(session_id=session_id, work_dir=self._work_dir)
|
|
@@ -312,7 +312,11 @@ class CodeWebSocketHandler:
|
|
|
312
312
|
mf_list = None
|
|
313
313
|
if media_files:
|
|
314
314
|
mf_list = [
|
|
315
|
-
MediaFile(
|
|
315
|
+
MediaFile(
|
|
316
|
+
file_path=mf.get("filePath", ""),
|
|
317
|
+
type=mf.get("type") or "image/png",
|
|
318
|
+
data_url=mf.get("dataUrl") or None,
|
|
319
|
+
)
|
|
316
320
|
for mf in media_files
|
|
317
321
|
]
|
|
318
322
|
|
|
@@ -68,6 +68,7 @@ class HttpApiHandler:
|
|
|
68
68
|
hub_client=None,
|
|
69
69
|
config_store=None,
|
|
70
70
|
git_manager=None,
|
|
71
|
+
port: int = 41000,
|
|
71
72
|
):
|
|
72
73
|
self.ctx = HttpContext(
|
|
73
74
|
client=client,
|
|
@@ -80,6 +81,7 @@ class HttpApiHandler:
|
|
|
80
81
|
hub_client=hub_client,
|
|
81
82
|
config_store=config_store,
|
|
82
83
|
git_manager=git_manager,
|
|
84
|
+
port=port,
|
|
83
85
|
)
|
|
84
86
|
self._sub_handlers = []
|
|
85
87
|
for prefix, cls in self._PREFIX_ROUTES:
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""`/api/chat/*` 路由:history_chat(历史消息转桌面端契约结构)、
|
|
2
|
+
upload_image_chat(multipart 图片上传)、file_download(图片二进制下载)。"""
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import uuid
|
|
7
|
+
from urllib.parse import quote
|
|
8
|
+
|
|
9
|
+
from ...utils.format import _to_posix
|
|
10
|
+
from ...utils.multipart import parse_multipart
|
|
11
|
+
from ...utils.time_util import _now_iso
|
|
12
|
+
from .http_base import MAX_UPLOAD_BYTES, HttpRequest, RawResponse
|
|
13
|
+
|
|
14
|
+
UPLOAD_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".svg")
|
|
15
|
+
|
|
16
|
+
IMAGE_MIME_BY_EXT = {
|
|
17
|
+
".png": "image/png",
|
|
18
|
+
".jpg": "image/jpeg",
|
|
19
|
+
".jpeg": "image/jpeg",
|
|
20
|
+
".gif": "image/gif",
|
|
21
|
+
".webp": "image/webp",
|
|
22
|
+
".bmp": "image/bmp",
|
|
23
|
+
".svg": "image/svg+xml",
|
|
24
|
+
".ico": "image/x-icon",
|
|
25
|
+
".tiff": "image/tiff",
|
|
26
|
+
".tif": "image/tiff",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ChatRoutes:
|
|
31
|
+
"""chat 路由(依赖注入 HttpContext)。"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, ctx):
|
|
34
|
+
self.ctx = ctx
|
|
35
|
+
|
|
36
|
+
def route(self, request: HttpRequest):
|
|
37
|
+
path = request.path
|
|
38
|
+
if request.method == "GET":
|
|
39
|
+
if path == "/api/chat/history_chat":
|
|
40
|
+
return self._history_chat(request)
|
|
41
|
+
if path == "/api/chat/file_download":
|
|
42
|
+
return self._file_download(request)
|
|
43
|
+
elif request.method == "POST":
|
|
44
|
+
if path == "/api/chat/upload_image_chat":
|
|
45
|
+
return self._upload_image_chat(request)
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
# ---------- 图片上传 / 下载 ----------
|
|
49
|
+
|
|
50
|
+
def _upload_image_chat(self, request: HttpRequest):
|
|
51
|
+
"""POST /api/chat/upload_image_chat(multipart 字段 `file`)→ {filePath, url, type, size}。
|
|
52
|
+
|
|
53
|
+
落盘到当前项目 `.txcode/uploads/<YYYY-MM-DD>/<uuid>.<ext>`,
|
|
54
|
+
单文件上限 MAX_UPLOAD_BYTES;全部失败路径抛 ValueError(转 400)。
|
|
55
|
+
"""
|
|
56
|
+
parts = parse_multipart(request.body, request.headers.get("content-type", ""))
|
|
57
|
+
part = None
|
|
58
|
+
for item in parts:
|
|
59
|
+
if item.name == "file":
|
|
60
|
+
part = item
|
|
61
|
+
break
|
|
62
|
+
if part is None or not part.filename:
|
|
63
|
+
raise ValueError("未上传文件")
|
|
64
|
+
if len(part.content) > MAX_UPLOAD_BYTES:
|
|
65
|
+
raise ValueError("文件大小超过 10MB")
|
|
66
|
+
ext = os.path.splitext(part.filename)[1].lower() or ".png"
|
|
67
|
+
if ext not in UPLOAD_IMAGE_EXTS:
|
|
68
|
+
raise ValueError("不支持的图片类型: %s" % ext)
|
|
69
|
+
upload_dir = os.path.join(
|
|
70
|
+
self.ctx._current_project_path(), ".txcode", "uploads", _now_iso()[:10]
|
|
71
|
+
)
|
|
72
|
+
os.makedirs(upload_dir, exist_ok=True)
|
|
73
|
+
file_path = os.path.join(upload_dir, uuid.uuid4().hex + ext)
|
|
74
|
+
with open(file_path, "wb") as f:
|
|
75
|
+
f.write(part.content)
|
|
76
|
+
path_text = _to_posix(file_path)
|
|
77
|
+
return 200, {"success": True, "data": {
|
|
78
|
+
"filePath": path_text,
|
|
79
|
+
"url": self._build_file_url(request, path_text),
|
|
80
|
+
"type": IMAGE_MIME_BY_EXT.get(ext, "image/png"),
|
|
81
|
+
"size": len(part.content),
|
|
82
|
+
}}
|
|
83
|
+
|
|
84
|
+
def _file_download(self, request: HttpRequest):
|
|
85
|
+
"""GET /api/chat/file_download?filePath=<路径> → 图片二进制(按扩展名定 Content-Type)。"""
|
|
86
|
+
raw = request.query.get("filePath", "")
|
|
87
|
+
if not raw:
|
|
88
|
+
raise ValueError("filePath 必填")
|
|
89
|
+
file_path = self.ctx._resolve_file_path(raw)
|
|
90
|
+
if not os.path.exists(file_path):
|
|
91
|
+
return 404, {"success": False, "error": "文件不存在"}
|
|
92
|
+
if not os.path.isfile(file_path):
|
|
93
|
+
return 404, {"success": False, "error": "不是文件"}
|
|
94
|
+
try:
|
|
95
|
+
with open(file_path, "rb") as f:
|
|
96
|
+
data = f.read()
|
|
97
|
+
except Exception as exc:
|
|
98
|
+
return 500, {"success": False, "error": str(exc) or "读取文件失败"}
|
|
99
|
+
ext = os.path.splitext(file_path)[1].lower()
|
|
100
|
+
return RawResponse(
|
|
101
|
+
data,
|
|
102
|
+
content_type=IMAGE_MIME_BY_EXT.get(ext, "application/octet-stream"),
|
|
103
|
+
headers={"Cache-Control": "public, max-age=86400"},
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def _build_file_url(self, request: HttpRequest, file_path: str) -> str:
|
|
107
|
+
"""绝对下载地址:优先 Host 头,缺失回退 localhost:<服务端口>。"""
|
|
108
|
+
host = (request.headers.get("host") or "").strip()
|
|
109
|
+
if not host:
|
|
110
|
+
host = "localhost:%d" % self.ctx.port
|
|
111
|
+
return "http://%s/api/chat/file_download?filePath=%s" % (
|
|
112
|
+
host, quote(file_path, safe="")
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# ---------- 历史消息 ----------
|
|
116
|
+
|
|
117
|
+
def _history_chat(self, request: HttpRequest):
|
|
118
|
+
session_id = request.query.get("sessionId", "")
|
|
119
|
+
if not session_id:
|
|
120
|
+
raise ValueError("sessionId 必填")
|
|
121
|
+
session = self.ctx._session_manager().get(session_id)
|
|
122
|
+
if session is None:
|
|
123
|
+
return 200, {"success": True, "data": []}
|
|
124
|
+
result = []
|
|
125
|
+
for msg in session.get("messages", []):
|
|
126
|
+
role = msg.get("role", "")
|
|
127
|
+
content = msg.get("content", "")
|
|
128
|
+
if role == "user" and msg.get("is_original"):
|
|
129
|
+
media_files = []
|
|
130
|
+
for mf in msg.get("media_files") or []:
|
|
131
|
+
file_path = mf.get("file_path", "")
|
|
132
|
+
item = {
|
|
133
|
+
"filePath": file_path,
|
|
134
|
+
"type": mf.get("type", ""),
|
|
135
|
+
}
|
|
136
|
+
if file_path:
|
|
137
|
+
item["url"] = self._build_file_url(request, _to_posix(file_path))
|
|
138
|
+
media_files.append(item)
|
|
139
|
+
result.append({
|
|
140
|
+
"type": "chat",
|
|
141
|
+
"role": "user",
|
|
142
|
+
"content": content,
|
|
143
|
+
"mediaFiles": media_files,
|
|
144
|
+
})
|
|
145
|
+
elif role == "assistant":
|
|
146
|
+
thought = content
|
|
147
|
+
tool_calls = []
|
|
148
|
+
success = True
|
|
149
|
+
try:
|
|
150
|
+
parsed = json.loads(content)
|
|
151
|
+
except (TypeError, ValueError):
|
|
152
|
+
parsed = None
|
|
153
|
+
if isinstance(parsed, dict) and parsed.get("type") == "assistant_with_tools":
|
|
154
|
+
thought = parsed.get("thought") or ""
|
|
155
|
+
tool_calls = parsed.get("toolCalls") or []
|
|
156
|
+
success = parsed.get("success") is not False
|
|
157
|
+
result.append({
|
|
158
|
+
"type": "step",
|
|
159
|
+
"role": "assistant",
|
|
160
|
+
"thought": thought,
|
|
161
|
+
"toolCalls": tool_calls,
|
|
162
|
+
"success": success,
|
|
163
|
+
})
|
|
164
|
+
return 200, {"success": True, "data": result}
|
|
@@ -24,7 +24,8 @@ from ..services.project_service import ProjectService
|
|
|
24
24
|
from ..services.provider_service import ProviderService
|
|
25
25
|
|
|
26
26
|
MAX_HEADER_BYTES = 65536
|
|
27
|
-
MAX_BODY_BYTES =
|
|
27
|
+
MAX_BODY_BYTES = 12 * 1024 * 1024
|
|
28
|
+
MAX_UPLOAD_BYTES = 10 * 1024 * 1024
|
|
28
29
|
|
|
29
30
|
DEFAULT_BASE_URL = "https://api.openai.com/v1"
|
|
30
31
|
|
|
@@ -140,33 +141,43 @@ def build_json_response(status: int, payload: dict) -> bytes:
|
|
|
140
141
|
|
|
141
142
|
|
|
142
143
|
class RawResponse(object):
|
|
143
|
-
"""非 JSON
|
|
144
|
+
"""非 JSON 响应(如导出配置文件 / 图片二进制):自定义 Content-Type + 可选附加头。
|
|
144
145
|
|
|
145
146
|
路由直接返回本对象即可(HttpApiHandler.handle 优先按本类型构造响应),
|
|
146
|
-
用于 `/api/sys_config/export_config` 输出 `application/x-yaml` + `filename=config.yml
|
|
147
|
+
用于 `/api/sys_config/export_config` 输出 `application/x-yaml` + `filename=config.yml`,
|
|
148
|
+
以及 `/api/chat/file_download` 输出图片二进制 + `Cache-Control`。
|
|
147
149
|
"""
|
|
148
150
|
|
|
149
|
-
def __init__(
|
|
151
|
+
def __init__(
|
|
152
|
+
self,
|
|
153
|
+
body,
|
|
154
|
+
content_type="application/octet-stream",
|
|
155
|
+
filename=None,
|
|
156
|
+
status=200,
|
|
157
|
+
headers=None,
|
|
158
|
+
):
|
|
150
159
|
if not isinstance(body, bytes):
|
|
151
160
|
body = str(body).encode("utf-8")
|
|
152
161
|
self.body = body
|
|
153
162
|
self.content_type = content_type
|
|
154
163
|
self.filename = filename
|
|
155
164
|
self.status = status
|
|
165
|
+
self.headers = headers or {}
|
|
156
166
|
|
|
157
167
|
def to_http_bytes(self) -> bytes:
|
|
158
168
|
disposition = ""
|
|
159
169
|
if self.filename:
|
|
160
170
|
disposition = "Content-Disposition: attachment; filename=%s\r\n" % self.filename
|
|
171
|
+
extra = "".join("%s: %s\r\n" % (key, value) for key, value in self.headers.items())
|
|
161
172
|
head = (
|
|
162
173
|
"HTTP/1.1 %d %s\r\n"
|
|
163
174
|
"Content-Type: %s\r\n"
|
|
164
175
|
"Content-Length: %d\r\n"
|
|
165
176
|
"Connection: close\r\n"
|
|
166
|
-
"%s"
|
|
177
|
+
"%s%s"
|
|
167
178
|
"\r\n" % (
|
|
168
179
|
self.status, _reason_phrase(self.status), self.content_type,
|
|
169
|
-
len(self.body), disposition,
|
|
180
|
+
len(self.body), disposition, extra,
|
|
170
181
|
)
|
|
171
182
|
)
|
|
172
183
|
return head.encode("latin-1") + self.body
|
|
@@ -205,6 +216,7 @@ class HttpContext:
|
|
|
205
216
|
hub_client=None,
|
|
206
217
|
config_store=None,
|
|
207
218
|
git_manager=None,
|
|
219
|
+
port: int = 41000,
|
|
208
220
|
):
|
|
209
221
|
self._client = client
|
|
210
222
|
self._provider_config = provider_config or ProviderConfigManager()
|
|
@@ -215,6 +227,7 @@ class HttpContext:
|
|
|
215
227
|
self._spec_mgr = spec_manager
|
|
216
228
|
self._hub = hub_client
|
|
217
229
|
self._config_store = config_store or ConfigStore()
|
|
230
|
+
self._port = port
|
|
218
231
|
self._git_mgr = git_manager or GitManager(
|
|
219
232
|
project_manager=self._project_manager, client=self._client
|
|
220
233
|
)
|
|
@@ -260,6 +273,10 @@ class HttpContext:
|
|
|
260
273
|
def provider_service(self):
|
|
261
274
|
return self._provider_service
|
|
262
275
|
|
|
276
|
+
@property
|
|
277
|
+
def port(self) -> int:
|
|
278
|
+
return self._port
|
|
279
|
+
|
|
263
280
|
@property
|
|
264
281
|
def project_service(self):
|
|
265
282
|
return self._project_service
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""multipart/form-data 解析(纯标准库实现,Python 3.6 兼容)。
|
|
2
|
+
|
|
3
|
+
供 `POST /api/chat/upload_image_chat` 使用:按 boundary 切分 part,
|
|
4
|
+
解析 Content-Disposition(name / filename)与 Content-Type,返回二进制 content。
|
|
5
|
+
不依赖第三方库(对齐 multer 的 `upload.single('file')` 语义)。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import List
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MultipartPart(object):
|
|
12
|
+
"""单个 part:表单字段名 / 文件名 / 内容类型 / 二进制内容。"""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
name: str = "",
|
|
17
|
+
filename: str = "",
|
|
18
|
+
content_type: str = "",
|
|
19
|
+
content: bytes = b"",
|
|
20
|
+
):
|
|
21
|
+
self.name = name
|
|
22
|
+
self.filename = filename
|
|
23
|
+
self.content_type = content_type
|
|
24
|
+
self.content = content
|
|
25
|
+
|
|
26
|
+
def __repr__(self):
|
|
27
|
+
return "MultipartPart(name=%r, filename=%r, size=%d)" % (
|
|
28
|
+
self.name, self.filename, len(self.content)
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _extract_boundary(content_type: str) -> bytes:
|
|
33
|
+
"""从 Content-Type 提取 boundary;非 multipart 或缺 boundary → ValueError。"""
|
|
34
|
+
if not content_type or "multipart/form-data" not in content_type.lower():
|
|
35
|
+
raise ValueError("请求体必须为 multipart/form-data")
|
|
36
|
+
lowered = content_type.lower()
|
|
37
|
+
index = lowered.find("boundary=")
|
|
38
|
+
if index < 0:
|
|
39
|
+
raise ValueError("multipart 缺少 boundary")
|
|
40
|
+
raw = content_type[index + len("boundary="):].strip()
|
|
41
|
+
if raw.startswith('"'):
|
|
42
|
+
end = raw.find('"', 1)
|
|
43
|
+
raw = raw[1:] if end < 0 else raw[1:end]
|
|
44
|
+
else:
|
|
45
|
+
raw = raw.split(";")[0].strip()
|
|
46
|
+
if not raw:
|
|
47
|
+
raise ValueError("multipart 缺少 boundary")
|
|
48
|
+
return raw.encode("latin-1")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _parse_headers(text: str) -> dict:
|
|
52
|
+
headers = {}
|
|
53
|
+
for line in text.split("\r\n"):
|
|
54
|
+
if ":" not in line:
|
|
55
|
+
continue
|
|
56
|
+
key, _, value = line.partition(":")
|
|
57
|
+
headers[key.strip().lower()] = value.strip()
|
|
58
|
+
return headers
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _parse_disposition(value: str) -> dict:
|
|
62
|
+
"""`form-data; name="file"; filename="a.png"` → {name: file, filename: a.png}。"""
|
|
63
|
+
params = {}
|
|
64
|
+
if not value:
|
|
65
|
+
return params
|
|
66
|
+
for item in value.split(";")[1:]:
|
|
67
|
+
if "=" not in item:
|
|
68
|
+
continue
|
|
69
|
+
key, _, raw = item.partition("=")
|
|
70
|
+
raw = raw.strip()
|
|
71
|
+
if len(raw) >= 2 and raw[0] == '"' and raw[-1] == '"':
|
|
72
|
+
raw = raw[1:-1]
|
|
73
|
+
params[key.strip().lower()] = raw
|
|
74
|
+
return params
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def parse_multipart(body: bytes, content_type: str) -> List[MultipartPart]:
|
|
78
|
+
"""解析 multipart body → part 列表(无 part 返回空列表)。"""
|
|
79
|
+
boundary = _extract_boundary(content_type or "")
|
|
80
|
+
if not body:
|
|
81
|
+
return []
|
|
82
|
+
delimiter = b"--" + boundary
|
|
83
|
+
parts = []
|
|
84
|
+
for segment in body.split(delimiter)[1:]:
|
|
85
|
+
if segment.startswith(b"--"):
|
|
86
|
+
break
|
|
87
|
+
if segment.startswith(b"\r\n"):
|
|
88
|
+
segment = segment[2:]
|
|
89
|
+
elif segment.startswith(b"\n"):
|
|
90
|
+
segment = segment[1:]
|
|
91
|
+
head, sep, content = segment.partition(b"\r\n\r\n")
|
|
92
|
+
if not sep:
|
|
93
|
+
continue
|
|
94
|
+
if content.endswith(b"\r\n"):
|
|
95
|
+
content = content[:-2]
|
|
96
|
+
headers = _parse_headers(head.decode("latin-1"))
|
|
97
|
+
params = _parse_disposition(headers.get("content-disposition", ""))
|
|
98
|
+
parts.append(MultipartPart(
|
|
99
|
+
name=params.get("name", ""),
|
|
100
|
+
filename=params.get("filename", ""),
|
|
101
|
+
content_type=headers.get("content-type", ""),
|
|
102
|
+
content=content,
|
|
103
|
+
))
|
|
104
|
+
return parts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: txcode-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: AI Agent SDK with built-in tools for Python projects
|
|
5
5
|
Author: homecommunity
|
|
6
6
|
License: MIT
|
|
@@ -157,6 +157,21 @@ txcode-sdk serve --work-dir /opt/door-access \
|
|
|
157
157
|
| S→C | `projects_list` | get_projects 响应(仅发送方) |
|
|
158
158
|
| S→C | `projects_changed` / `project_changed` | 项目列表变更 / 当前项目切换广播(全局) |
|
|
159
159
|
|
|
160
|
+
### 图片上传 / 下载
|
|
161
|
+
|
|
162
|
+
桌面端粘贴/选择图片后先调上传接口,再把 `mediaFiles`(`[{filePath, type, dataUrl?}]`)随 `chat` 一并发送:
|
|
163
|
+
|
|
164
|
+
- `POST /api/chat/upload_image_chat`:`multipart/form-data` 字段名 `file`,落盘当前项目
|
|
165
|
+
`.txcode/uploads/<YYYY-MM-DD>/<uuid>.<ext>`,返回 `{filePath, url, type, size}`;
|
|
166
|
+
单文件上限 10MB,仅支持 `.png/.jpg/.jpeg/.gif/.webp/.bmp/.svg`
|
|
167
|
+
- `GET /api/chat/file_download?filePath=<绝对/相对路径>`:返回图片二进制(按扩展名定 `Content-Type`),
|
|
168
|
+
供 `<img src>` / Electron 直取;文件不存在 404,缺 `filePath` 400
|
|
169
|
+
- `GET /api/chat/history_chat?sessionId=<id>`:用户消息的 `mediaFiles[]` 含 `filePath/url/type`,
|
|
170
|
+
历史会话重开后图片仍可渲染(`url` 为绝对地址,`Host` 缺失回退 `localhost:<端口>`)
|
|
171
|
+
|
|
172
|
+
发送链路对图片按 `work_dir` 解析相对路径并转 `data:` URI(`dataUrl` 存在时优先),
|
|
173
|
+
单张图片读取失败仅告警跳过,不中断整轮对话。
|
|
174
|
+
|
|
160
175
|
### 供应商与模型管理
|
|
161
176
|
|
|
162
177
|
服务端支持**动态添加/编辑/删除多个供应商**(OpenAI / DeepSeek / 自建网关),配置实时持久化到用户层
|
|
@@ -187,9 +187,11 @@ src/txcode_sdk/tools/write_file.txt
|
|
|
187
187
|
src/txcode_sdk/utils/__init__.py
|
|
188
188
|
src/txcode_sdk/utils/format.py
|
|
189
189
|
src/txcode_sdk/utils/log.py
|
|
190
|
+
src/txcode_sdk/utils/multipart.py
|
|
190
191
|
src/txcode_sdk/utils/path_util.py
|
|
191
192
|
src/txcode_sdk/utils/time_util.py
|
|
192
193
|
tests/test_ai_settings.py
|
|
194
|
+
tests/test_chat_upload.py
|
|
193
195
|
tests/test_provider_reasoning_effort.py
|
|
194
196
|
tests/test_server_cli_logging.py
|
|
195
197
|
tests/test_sys_config_ai_settings.py
|