@scemoon/cdh 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-dlc-skill/SKILL.md +75 -0
- package/ai-dlc-skill/agents/deliver-agent.md +24 -0
- package/ai-dlc-skill/agents/master.md +44 -0
- package/ai-dlc-skill/agents/plan-agent.md +23 -0
- package/ai-dlc-skill/agents/understand-agent.md +23 -0
- package/ai-dlc-skill/agents/verify-agent.md +27 -0
- package/ai-dlc-skill/architecture/project-structure.md +78 -0
- package/ai-dlc-skill/brownfield/README.md +30 -0
- package/ai-dlc-skill/brownfield/generate-context.sh +64 -0
- package/ai-dlc-skill/brownfield/scripts/deps.sh +27 -0
- package/ai-dlc-skill/brownfield/scripts/discover.sh +34 -0
- package/ai-dlc-skill/brownfield/scripts/extract-api.sh +45 -0
- package/ai-dlc-skill/components/backend.md +34 -0
- package/ai-dlc-skill/components/desktop.md +30 -0
- package/ai-dlc-skill/components/mya.md +29 -0
- package/ai-dlc-skill/components/native.md +30 -0
- package/ai-dlc-skill/components/tta.md +29 -0
- package/ai-dlc-skill/components/web.md +31 -0
- package/ai-dlc-skill/components/wxa.md +29 -0
- package/ai-dlc-skill/contracts/README.md +25 -0
- package/ai-dlc-skill/core/adaptive-flow.md +36 -0
- package/ai-dlc-skill/core/security.md +29 -0
- package/ai-dlc-skill/cross-tool/cline/export.sh +31 -0
- package/ai-dlc-skill/cross-tool/copilot/export.sh +47 -0
- package/ai-dlc-skill/cross-tool/cursor/export.sh +32 -0
- package/ai-dlc-skill/cross-tool/export.sh +22 -0
- package/ai-dlc-skill/cross-tool/onecode/config.yaml.tpl +17 -0
- package/ai-dlc-skill/cross-tool/onecode/export-skills.sh +31 -0
- package/ai-dlc-skill/cross-tool/onecode/export.sh +48 -0
- package/ai-dlc-skill/phases/deliver/entry.md +26 -0
- package/ai-dlc-skill/phases/deliver/lifecycle.md +185 -0
- package/ai-dlc-skill/phases/deliver/prompt.md +40 -0
- package/ai-dlc-skill/phases/deliver/rules.md +61 -0
- package/ai-dlc-skill/phases/plan/entry.md +25 -0
- package/ai-dlc-skill/phases/plan/lifecycle.md +204 -0
- package/ai-dlc-skill/phases/plan/prompt.md +38 -0
- package/ai-dlc-skill/phases/plan/rules.md +25 -0
- package/ai-dlc-skill/phases/understand/entry.md +26 -0
- package/ai-dlc-skill/phases/understand/lifecycle.md +184 -0
- package/ai-dlc-skill/phases/understand/prompt.md +41 -0
- package/ai-dlc-skill/phases/understand/rules.md +37 -0
- package/ai-dlc-skill/phases/verify/entry.md +26 -0
- package/ai-dlc-skill/phases/verify/lifecycle.md +192 -0
- package/ai-dlc-skill/phases/verify/prompt.md +43 -0
- package/ai-dlc-skill/phases/verify/rules.md +73 -0
- package/ai-dlc-skill/practices/bdd.md +91 -0
- package/ai-dlc-skill/practices/sdd.md +84 -0
- package/ai-dlc-skill/practices/tdd.md +95 -0
- package/ai-dlc-skill/providers/README.md +114 -0
- package/ai-dlc-skill/providers/aliyun/deployment.yaml +66 -0
- package/ai-dlc-skill/providers/aliyun/preview.yaml +84 -0
- package/ai-dlc-skill/providers/aliyun/provider.yaml +160 -0
- package/ai-dlc-skill/providers/tcb/deployment.yaml +69 -0
- package/ai-dlc-skill/providers/tcb/preview.yaml +83 -0
- package/ai-dlc-skill/providers/tcb/provider.yaml +172 -0
- package/ai-dlc-skill/requirements.md +140 -0
- package/ai-dlc-skill/skill.yaml +147 -0
- package/ai-dlc-skill/templates/integration/CHANGELOG.md +41 -0
- package/ai-dlc-skill/templates/integration/asyncapi.yaml +43 -0
- package/ai-dlc-skill/templates/integration/contract-diff.md +63 -0
- package/ai-dlc-skill/templates/integration/contract-spec.md +49 -0
- package/ai-dlc-skill/templates/integration/openapi.yaml +18 -0
- package/ai-dlc-skill/templates/integration/runtime-contract.yaml +36 -0
- package/ai-dlc-skill/templates/plan/design.md +49 -0
- package/ai-dlc-skill/templates/plan/task-list.md +32 -0
- package/ai-dlc-skill/templates/project/README.md +127 -0
- package/ai-dlc-skill/templates/project/template.md +119 -0
- package/ai-dlc-skill/templates/understand/feature.feature +23 -0
- package/ai-dlc-skill/templates/understand/intent.md +29 -0
- package/ai-dlc-skill/templates/understand/spec-delta.md +47 -0
- package/ai-dlc-skill/templates/verify/test-unit.py +27 -0
- package/ai-dlc-skill/walkthrough/collect.sh +50 -0
- package/ai-dlc-skill/walkthrough/template.md +54 -0
- package/ai-dlc-skill/workflows/ai-dlc.yaml +110 -0
- package/ai-dlc-skill/workflows/deployment.yaml +199 -0
- package/cdh/__init__.py +0 -0
- package/cdh/__main__.py +4 -0
- package/cdh/__pycache__/__init__.cpython-313.pyc +0 -0
- package/cdh/__pycache__/__init__.cpython-314.pyc +0 -0
- package/cdh/__pycache__/cli.cpython-314.pyc +0 -0
- package/cdh/__pycache__/scaffold.cpython-313.pyc +0 -0
- package/cdh/__pycache__/scaffold.cpython-314.pyc +0 -0
- package/cdh/cli.py +361 -0
- package/cdh/scaffold.py +312 -0
- package/cli.js +2 -0
- package/onecode/__init__.py +1 -0
- package/onecode/__main__.py +4 -0
- package/onecode/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/__pycache__/cli.cpython-314.pyc +0 -0
- package/onecode/__pycache__/commands.cpython-314.pyc +0 -0
- package/onecode/__pycache__/config.cpython-314.pyc +0 -0
- package/onecode/__pycache__/config_screen.cpython-314.pyc +0 -0
- package/onecode/__pycache__/mock_data.cpython-314.pyc +0 -0
- package/onecode/agent/__init__.py +0 -0
- package/onecode/agent/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/cdh_agent_acp.cpython-313.pyc +0 -0
- package/onecode/agent/__pycache__/cdh_agent_acp.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/cdh_loader.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/context.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/engine.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/harness_skill.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/hooks.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/onecode_agent_acp.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/permissions.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/permissions_store.cpython-314.pyc +0 -0
- package/onecode/agent/__pycache__/session.cpython-314.pyc +0 -0
- package/onecode/agent/agents/__init__.py +29 -0
- package/onecode/agent/agents/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/agent/agents/__pycache__/types.cpython-314.pyc +0 -0
- package/onecode/agent/agents/types.py +662 -0
- package/onecode/agent/attachments.py +113 -0
- package/onecode/agent/cdh_loader.py +262 -0
- package/onecode/agent/context.py +338 -0
- package/onecode/agent/engine.py +1894 -0
- package/onecode/agent/hooks.py +86 -0
- package/onecode/agent/onecode_agent_acp.py +2203 -0
- package/onecode/agent/permissions.py +151 -0
- package/onecode/agent/permissions_store.py +62 -0
- package/onecode/agent/session.py +186 -0
- package/onecode/agent/snapshot.py +145 -0
- package/onecode/agent/tools/__init__.py +17 -0
- package/onecode/agent/tools/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/agent_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/apply_patch_tool.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/bash_tool.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/communication_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/config_tool.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/cron_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/errors.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/file_ops.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/file_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/git_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/lsp_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/mcp_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/permission_handler.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/permissions.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/protocol.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/registry.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/sandbox.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/schema_validation.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/skill_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/task_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/__pycache__/web_tools.cpython-314.pyc +0 -0
- package/onecode/agent/tools/agent_tools.py +134 -0
- package/onecode/agent/tools/apply_patch_tool.py +144 -0
- package/onecode/agent/tools/bash_tool.py +91 -0
- package/onecode/agent/tools/communication_tools.py +149 -0
- package/onecode/agent/tools/config_tool.py +130 -0
- package/onecode/agent/tools/cron_tools.py +179 -0
- package/onecode/agent/tools/errors.py +17 -0
- package/onecode/agent/tools/file_ops.py +187 -0
- package/onecode/agent/tools/file_tools.py +226 -0
- package/onecode/agent/tools/git_tools.py +88 -0
- package/onecode/agent/tools/lsp_tools.py +404 -0
- package/onecode/agent/tools/mcp_tools.py +129 -0
- package/onecode/agent/tools/permission_handler.py +46 -0
- package/onecode/agent/tools/permissions.py +77 -0
- package/onecode/agent/tools/protocol.py +20 -0
- package/onecode/agent/tools/registry.py +134 -0
- package/onecode/agent/tools/sandbox.py +264 -0
- package/onecode/agent/tools/schema_validation.py +100 -0
- package/onecode/agent/tools/skill_tools.py +52 -0
- package/onecode/agent/tools/task_tools.py +249 -0
- package/onecode/agent/tools/web_tools.py +170 -0
- package/onecode/builtin_skills/git/SKILL.md +64 -0
- package/onecode/builtin_skills/git/skill.yaml +7 -0
- package/onecode/builtin_skills/shell/SKILL.md +58 -0
- package/onecode/builtin_skills/shell/skill.yaml +8 -0
- package/onecode/cli.py +755 -0
- package/onecode/cloud/__init__.py +0 -0
- package/onecode/cloud/base.py +20 -0
- package/onecode/codebase/__init__.py +69 -0
- package/onecode/codebase/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/chunker.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/config.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/indexer.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/retriever.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/storage.cpython-314.pyc +0 -0
- package/onecode/codebase/__pycache__/tools.cpython-314.pyc +0 -0
- package/onecode/codebase/chunker.py +130 -0
- package/onecode/codebase/indexer.py +136 -0
- package/onecode/codebase/retriever.py +192 -0
- package/onecode/codebase/storage.py +130 -0
- package/onecode/codebase/tools.py +59 -0
- package/onecode/commands.py +276 -0
- package/onecode/config.py +285 -0
- package/onecode/config_screen.py +594 -0
- package/onecode/cron/__init__.py +3 -0
- package/onecode/lsp/__init__.py +3 -0
- package/onecode/mcp/__init__.py +4 -0
- package/onecode/mcp/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/client.cpython-314.pyc +0 -0
- package/onecode/mcp/__pycache__/manager.cpython-314.pyc +0 -0
- package/onecode/mcp/client.py +193 -0
- package/onecode/mcp/manager.py +191 -0
- package/onecode/memory/__init__.py +95 -0
- package/onecode/memory/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/backend.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/offload.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/pyramid.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/recall.cpython-314.pyc +0 -0
- package/onecode/memory/__pycache__/symbolic.cpython-314.pyc +0 -0
- package/onecode/memory/backend.py +185 -0
- package/onecode/memory/offload.py +114 -0
- package/onecode/memory/pyramid.py +202 -0
- package/onecode/memory/recall.py +168 -0
- package/onecode/memory/symbolic.py +164 -0
- package/onecode/models/__init__.py +4 -0
- package/onecode/models/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/errors.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/messages.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/provider.cpython-314.pyc +0 -0
- package/onecode/models/__pycache__/registry.cpython-314.pyc +0 -0
- package/onecode/models/errors.py +94 -0
- package/onecode/models/messages.py +662 -0
- package/onecode/models/provider.py +450 -0
- package/onecode/models/providers/__init__.py +17 -0
- package/onecode/models/providers/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/anthropic_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/deepseek_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/glm_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/minimax_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/minimaxi_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/mock_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/ollama_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/__pycache__/openai_provider.cpython-314.pyc +0 -0
- package/onecode/models/providers/anthropic_provider.py +224 -0
- package/onecode/models/providers/deepseek_provider.py +210 -0
- package/onecode/models/providers/glm_provider.py +154 -0
- package/onecode/models/providers/minimax_provider.py +154 -0
- package/onecode/models/providers/minimaxi_provider.py +363 -0
- package/onecode/models/providers/ollama_provider.py +96 -0
- package/onecode/models/providers/openai_provider.py +233 -0
- package/onecode/models/registry.py +212 -0
- package/onecode/server/__init__.py +3 -0
- package/onecode/server/app.py +224 -0
- package/onecode/skills/__init__.py +11 -0
- package/onecode/skills/__pycache__/__init__.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/argument_substitution.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/create.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/frontmatter.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/loader.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/manager.cpython-314.pyc +0 -0
- package/onecode/skills/__pycache__/model.cpython-314.pyc +0 -0
- package/onecode/skills/argument_substitution.py +39 -0
- package/onecode/skills/create.py +56 -0
- package/onecode/skills/frontmatter.py +33 -0
- package/onecode/skills/loader.py +157 -0
- package/onecode/skills/manager.py +75 -0
- package/onecode/skills/model.py +43 -0
- package/onecode/storage/__init__.py +0 -0
- package/onecode/storage/activity.py +64 -0
- package/onecode/storage/project.py +54 -0
- package/onecode/storage/session.py +113 -0
- package/onecode/tasks/__init__.py +26 -0
- package/onecode/tasks/manager.py +219 -0
- package/onecode/tasks/models.py +240 -0
- package/onecode/trace/__init__.py +0 -0
- package/onecode/trace/tracer.py +174 -0
- package/onecode/utils/__init__.py +0 -0
- package/onecode/utils/helpers.py +20 -0
- package/onecode-cli.js +2 -0
- package/package.json +32 -0
- package/pyproject.toml +60 -0
- package/run.js +86 -0
- package/tui/__init__.py +46 -0
- package/tui/__main__.py +4 -0
- package/tui/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/__pycache__/_loop.cpython-314.pyc +0 -0
- package/tui/__pycache__/_path_fuzzy_search.cpython-314.pyc +0 -0
- package/tui/__pycache__/_path_match.cpython-314.pyc +0 -0
- package/tui/__pycache__/agent.cpython-314.pyc +0 -0
- package/tui/__pycache__/agent_schema.cpython-314.pyc +0 -0
- package/tui/__pycache__/agents.cpython-314.pyc +0 -0
- package/tui/__pycache__/answer.cpython-314.pyc +0 -0
- package/tui/__pycache__/app.cpython-314.pyc +0 -0
- package/tui/__pycache__/atomic.cpython-314.pyc +0 -0
- package/tui/__pycache__/complete.cpython-314.pyc +0 -0
- package/tui/__pycache__/constants.cpython-314.pyc +0 -0
- package/tui/__pycache__/conversation_markdown.cpython-314.pyc +0 -0
- package/tui/__pycache__/danger.cpython-314.pyc +0 -0
- package/tui/__pycache__/db.cpython-314.pyc +0 -0
- package/tui/__pycache__/dec.cpython-314.pyc +0 -0
- package/tui/__pycache__/directory.cpython-314.pyc +0 -0
- package/tui/__pycache__/directory_suggester.cpython-314.pyc +0 -0
- package/tui/__pycache__/directory_watcher.cpython-314.pyc +0 -0
- package/tui/__pycache__/format_path.cpython-314.pyc +0 -0
- package/tui/__pycache__/fuzzy.cpython-314.pyc +0 -0
- package/tui/__pycache__/fuzzy_index.cpython-314.pyc +0 -0
- package/tui/__pycache__/history.cpython-314.pyc +0 -0
- package/tui/__pycache__/jsonrpc.cpython-314.pyc +0 -0
- package/tui/__pycache__/menus.cpython-314.pyc +0 -0
- package/tui/__pycache__/message_log.cpython-314.pyc +0 -0
- package/tui/__pycache__/messages.cpython-314.pyc +0 -0
- package/tui/__pycache__/path_complete.cpython-314.pyc +0 -0
- package/tui/__pycache__/path_filter.cpython-314.pyc +0 -0
- package/tui/__pycache__/paths.cpython-314.pyc +0 -0
- package/tui/__pycache__/pill.cpython-314.pyc +0 -0
- package/tui/__pycache__/platform_commands.cpython-314.pyc +0 -0
- package/tui/__pycache__/protocol.cpython-314.pyc +0 -0
- package/tui/__pycache__/session_tracker.cpython-314.pyc +0 -0
- package/tui/__pycache__/settings.cpython-314.pyc +0 -0
- package/tui/__pycache__/settings_schema.cpython-314.pyc +0 -0
- package/tui/__pycache__/shell.cpython-314.pyc +0 -0
- package/tui/__pycache__/shell_read.cpython-314.pyc +0 -0
- package/tui/__pycache__/slash_command.cpython-314.pyc +0 -0
- package/tui/__pycache__/version.cpython-314.pyc +0 -0
- package/tui/_loop.py +86 -0
- package/tui/_path_fuzzy_search.py +48 -0
- package/tui/_path_match.py +141 -0
- package/tui/about.py +95 -0
- package/tui/acp/__pycache__/agent.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/api.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/encode_tool_call_id.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/messages.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/prompt.cpython-314.pyc +0 -0
- package/tui/acp/__pycache__/protocol.cpython-314.pyc +0 -0
- package/tui/acp/agent.py +886 -0
- package/tui/acp/api.py +55 -0
- package/tui/acp/encode_tool_call_id.py +12 -0
- package/tui/acp/messages.py +190 -0
- package/tui/acp/prompt.py +110 -0
- package/tui/acp/protocol.py +462 -0
- package/tui/agent.py +70 -0
- package/tui/agent_schema.py +76 -0
- package/tui/agents.py +45 -0
- package/tui/ansi/__init__.py +1 -0
- package/tui/ansi/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_ansi.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_ansi_colors.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_control_codes.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_keys.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_sgr_styles.cpython-314.pyc +0 -0
- package/tui/ansi/__pycache__/_stream_parser.cpython-314.pyc +0 -0
- package/tui/ansi/_ansi.py +1689 -0
- package/tui/ansi/_ansi_colors.py +264 -0
- package/tui/ansi/_control_codes.py +37 -0
- package/tui/ansi/_keys.py +251 -0
- package/tui/ansi/_sgr_styles.py +64 -0
- package/tui/ansi/_stream_parser.py +418 -0
- package/tui/answer.py +12 -0
- package/tui/app.py +1236 -0
- package/tui/atomic.py +37 -0
- package/tui/cli.py +313 -0
- package/tui/code_analyze.py +27 -0
- package/tui/complete.py +38 -0
- package/tui/constants.py +61 -0
- package/tui/conversation_markdown.py +30 -0
- package/tui/danger.py +372 -0
- package/tui/data/agents/ampcode.com.toml +51 -0
- package/tui/data/agents/augmentcode.com.toml +40 -0
- package/tui/data/agents/cdh.cloud-dev-harness.toml +22 -0
- package/tui/data/agents/claude.com.toml +41 -0
- package/tui/data/agents/copilot.github.com.toml +29 -0
- package/tui/data/agents/crowai.dev.toml +35 -0
- package/tui/data/agents/cursor.com.toml +38 -0
- package/tui/data/agents/deepagents.langchain.com +33 -0
- package/tui/data/agents/docker.com.toml +59 -0
- package/tui/data/agents/geminicli.com.toml +28 -0
- package/tui/data/agents/goose.ai.toml +51 -0
- package/tui/data/agents/inference.huggingface.co.toml +41 -0
- package/tui/data/agents/kimi.com.toml +35 -0
- package/tui/data/agents/kiro.dev.toml +42 -0
- package/tui/data/agents/openai.com.toml +53 -0
- package/tui/data/agents/openclaw.ai.toml +37 -0
- package/tui/data/agents/opencode.ai.toml +39 -0
- package/tui/data/agents/openhands.dev.toml +45 -0
- package/tui/data/agents/stakpak.dev.toml +61 -0
- package/tui/data/agents/vibe.mistral.ai.toml +30 -0
- package/tui/data/agents/vtcode.dev.toml +62 -0
- package/tui/data/images/frog.png +0 -0
- package/tui/data/sounds/question.wav +0 -0
- package/tui/data/sounds/turn-over.wav +0 -0
- package/tui/db.py +190 -0
- package/tui/dec.py +332 -0
- package/tui/directory.py +234 -0
- package/tui/directory_suggester.py +93 -0
- package/tui/directory_watcher.py +197 -0
- package/tui/format_path.py +25 -0
- package/tui/fuzzy.py +140 -0
- package/tui/fuzzy_index.py +275 -0
- package/tui/gist.py +33 -0
- package/tui/history.py +138 -0
- package/tui/jsonrpc.py +578 -0
- package/tui/menus.py +14 -0
- package/tui/message_log.py +69 -0
- package/tui/messages.py +139 -0
- package/tui/option_content.py +51 -0
- package/tui/os.py +0 -0
- package/tui/path_complete.py +217 -0
- package/tui/path_filter.py +124 -0
- package/tui/paths.py +71 -0
- package/tui/pill.py +23 -0
- package/tui/platform_commands.py +52 -0
- package/tui/prompt/__pycache__/extract.cpython-314.pyc +0 -0
- package/tui/prompt/__pycache__/resource.cpython-314.pyc +0 -0
- package/tui/prompt/extract.py +19 -0
- package/tui/prompt/resource.py +68 -0
- package/tui/protocol.py +28 -0
- package/tui/screens/__init__.py +0 -0
- package/tui/screens/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/log.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/main.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/projects_screen.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/sessions.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/settings.cpython-314.pyc +0 -0
- package/tui/screens/__pycache__/store.cpython-314.pyc +0 -0
- package/tui/screens/action_modal.py +94 -0
- package/tui/screens/agent_modal.py +175 -0
- package/tui/screens/command_edit_modal.py +74 -0
- package/tui/screens/log.py +553 -0
- package/tui/screens/main.py +411 -0
- package/tui/screens/main.tcss +655 -0
- package/tui/screens/permissions.py +404 -0
- package/tui/screens/permissions.tcss +72 -0
- package/tui/screens/projects.tcss +66 -0
- package/tui/screens/projects_app.py +319 -0
- package/tui/screens/projects_screen.py +142 -0
- package/tui/screens/session_resume_modal.py +172 -0
- package/tui/screens/session_resume_modal.tcss +35 -0
- package/tui/screens/sessions.py +166 -0
- package/tui/screens/sessions.tcss +119 -0
- package/tui/screens/settings.py +254 -0
- package/tui/screens/settings.tcss +101 -0
- package/tui/screens/store.py +500 -0
- package/tui/screens/store.tcss +274 -0
- package/tui/screens/tool_content_screen.py +59 -0
- package/tui/session_tracker.py +120 -0
- package/tui/settings.py +353 -0
- package/tui/settings_schema.py +431 -0
- package/tui/shell.py +304 -0
- package/tui/shell_read.py +42 -0
- package/tui/slash_command.py +34 -0
- package/tui/tui.tcss +246 -0
- package/tui/twitter.py +38 -0
- package/tui/version.py +80 -0
- package/tui/visuals/__init__.py +0 -0
- package/tui/visuals/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/visuals/__pycache__/columns.cpython-314.pyc +0 -0
- package/tui/visuals/columns.py +273 -0
- package/tui/widgets/__init__.py +0 -0
- package/tui/widgets/__pycache__/__init__.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/acp_content.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/agent_response.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/agent_thought.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/ask_user.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/condensed_path.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/context_stats.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/conversation.cpython-313.pyc +0 -0
- package/tui/widgets/__pycache__/conversation.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/diff_view.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/directory_input.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/flash.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/future_text.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/grid_select.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/highlighted_textarea.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/mandelbrot.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/markdown_note.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/menu.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/modified_files.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/non_selectable_label.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/note.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/path_search.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/plan.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/project_directory_tree.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/project_grid_select.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/project_summary.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/prompt.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/question.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/session_grid_select.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/session_summary.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/session_tabs.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/shell_result.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/shell_terminal.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/side_bar.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/slash_complete.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/strike_text.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/subagent.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/terminal.cpython-313.pyc +0 -0
- package/tui/widgets/__pycache__/terminal.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/throbber.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/tool_call.cpython-313.pyc +0 -0
- package/tui/widgets/__pycache__/tool_call.cpython-314.pyc +0 -0
- package/tui/widgets/__pycache__/user_input.cpython-314.pyc +0 -0
- package/tui/widgets/acp_content.py +70 -0
- package/tui/widgets/agent_response.py +77 -0
- package/tui/widgets/agent_thought.py +168 -0
- package/tui/widgets/ask_user.py +264 -0
- package/tui/widgets/command_pane.py +223 -0
- package/tui/widgets/condensed_path.py +115 -0
- package/tui/widgets/context_stats.py +66 -0
- package/tui/widgets/conversation.py +2441 -0
- package/tui/widgets/danger_warning.py +65 -0
- package/tui/widgets/diff_view.py +59 -0
- package/tui/widgets/directory_input.py +8 -0
- package/tui/widgets/flash.py +81 -0
- package/tui/widgets/future_text.py +126 -0
- package/tui/widgets/grid_select.py +234 -0
- package/tui/widgets/highlighted_textarea.py +180 -0
- package/tui/widgets/mandelbrot.py +294 -0
- package/tui/widgets/markdown_note.py +13 -0
- package/tui/widgets/menu.py +147 -0
- package/tui/widgets/modified_files.py +106 -0
- package/tui/widgets/non_selectable_label.py +5 -0
- package/tui/widgets/note.py +18 -0
- package/tui/widgets/path_search.py +492 -0
- package/tui/widgets/plan.py +263 -0
- package/tui/widgets/project_directory_tree.py +90 -0
- package/tui/widgets/project_grid_select.py +35 -0
- package/tui/widgets/project_summary.py +33 -0
- package/tui/widgets/prompt.py +795 -0
- package/tui/widgets/question.py +360 -0
- package/tui/widgets/session_grid_select.py +224 -0
- package/tui/widgets/session_summary.py +115 -0
- package/tui/widgets/session_tabs.py +188 -0
- package/tui/widgets/shell_result.py +35 -0
- package/tui/widgets/shell_terminal.py +40 -0
- package/tui/widgets/side_bar.py +114 -0
- package/tui/widgets/slash_complete.py +235 -0
- package/tui/widgets/strike_text.py +70 -0
- package/tui/widgets/subagent.py +87 -0
- package/tui/widgets/terminal.py +577 -0
- package/tui/widgets/terminal_tool.py +351 -0
- package/tui/widgets/throbber.py +100 -0
- package/tui/widgets/tool_call.py +368 -0
- package/tui/widgets/user_input.py +23 -0
- package/tui/widgets/version.py +5 -0
- package/tui/widgets/welcome.py +31 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
"""Typed message model for agent interactions.
|
|
2
|
+
|
|
3
|
+
Inspired by DeepSeek-TUI's structured message hierarchy:
|
|
4
|
+
- AgentMessage: base with id, role, type, timestamp
|
|
5
|
+
- ThinkBlock: collapsible thinking/reasoning
|
|
6
|
+
- ToolCall: with name, args, lifecycle status
|
|
7
|
+
- ToolResult: typed by tool category
|
|
8
|
+
- SubAgentBlock: independent lifecycle tracking
|
|
9
|
+
- HistoryCell: unified renderable cell (mirrors DeepSeek-TUI's core rendering model)
|
|
10
|
+
- ErrorSeverity: severity taxonomy for error cells
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import time
|
|
17
|
+
import uuid
|
|
18
|
+
from dataclasses import dataclass, field
|
|
19
|
+
from enum import Enum
|
|
20
|
+
from typing import Any, Optional
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _now() -> float:
|
|
24
|
+
return time.time()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _uid() -> str:
|
|
28
|
+
return uuid.uuid4().hex[:12]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# ── Status enums ──
|
|
32
|
+
|
|
33
|
+
class MessageRole(str, Enum):
|
|
34
|
+
USER = "user"
|
|
35
|
+
ASSISTANT = "assistant"
|
|
36
|
+
SYSTEM = "system"
|
|
37
|
+
ERROR = "error"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class BlockType(str, Enum):
|
|
41
|
+
TEXT = "text"
|
|
42
|
+
THINKING = "thinking"
|
|
43
|
+
TOOL_CALL = "tool_call"
|
|
44
|
+
TOOL_RESULT = "tool_result"
|
|
45
|
+
SUBAGENT = "subagent"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class LifecycleStatus(str, Enum):
|
|
49
|
+
PENDING = "pending"
|
|
50
|
+
RUNNING = "running"
|
|
51
|
+
COMPLETE = "complete"
|
|
52
|
+
FAILED = "failed"
|
|
53
|
+
CANCELLED = "cancelled"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ErrorSeverity(str, Enum):
|
|
57
|
+
"""Categorized engine/tool error severity, mirroring DeepSeek-TUI."""
|
|
58
|
+
ERROR = "error"
|
|
59
|
+
WARNING = "warning"
|
|
60
|
+
INFO = "info"
|
|
61
|
+
CRITICAL = "critical"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class RenderMode(str, Enum):
|
|
65
|
+
"""Controls whether tool/thinking cells render compact 'Live' or full 'Transcript' form."""
|
|
66
|
+
LIVE = "live"
|
|
67
|
+
TRANSCRIPT = "transcript"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ToolCategory(str, Enum):
|
|
71
|
+
FILE_READ = "file_read"
|
|
72
|
+
FILE_WRITE = "file_write"
|
|
73
|
+
FILE_EDIT = "file_edit"
|
|
74
|
+
FILE_LIST = "file_list"
|
|
75
|
+
FILE_GLOB = "file_glob"
|
|
76
|
+
FILE_GREP = "file_grep"
|
|
77
|
+
BASH = "bash"
|
|
78
|
+
WEB_FETCH = "web_fetch"
|
|
79
|
+
WEB_SEARCH = "web_search"
|
|
80
|
+
TASK = "task" # sub-agent
|
|
81
|
+
TASK_MGMT = "task_mgmt" # task/todo CRUD
|
|
82
|
+
INTERACTION = "interaction" # user approval / AskUser
|
|
83
|
+
UNKNOWN = "unknown"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
TOOL_CATEGORY_MAP: dict[str, ToolCategory] = {
|
|
87
|
+
"Read": ToolCategory.FILE_READ,
|
|
88
|
+
"Write": ToolCategory.FILE_WRITE,
|
|
89
|
+
"Edit": ToolCategory.FILE_EDIT,
|
|
90
|
+
"Insert": ToolCategory.FILE_EDIT,
|
|
91
|
+
"UndoEdit": ToolCategory.FILE_EDIT,
|
|
92
|
+
"List": ToolCategory.FILE_LIST,
|
|
93
|
+
"Glob": ToolCategory.FILE_GLOB,
|
|
94
|
+
"Grep": ToolCategory.FILE_GREP,
|
|
95
|
+
"Bash": ToolCategory.BASH,
|
|
96
|
+
"WebFetch": ToolCategory.WEB_FETCH,
|
|
97
|
+
"WebSearch": ToolCategory.WEB_SEARCH,
|
|
98
|
+
"Task": ToolCategory.TASK,
|
|
99
|
+
"SendMessage": ToolCategory.INTERACTION,
|
|
100
|
+
"Agent": ToolCategory.TASK,
|
|
101
|
+
"ToolSearch": ToolCategory.TASK_MGMT,
|
|
102
|
+
"TaskCreate": ToolCategory.TASK_MGMT,
|
|
103
|
+
"TaskGet": ToolCategory.TASK_MGMT,
|
|
104
|
+
"TaskList": ToolCategory.TASK_MGMT,
|
|
105
|
+
"TaskUpdate": ToolCategory.TASK_MGMT,
|
|
106
|
+
"TaskOutput": ToolCategory.TASK_MGMT,
|
|
107
|
+
"TaskStop": ToolCategory.TASK_MGMT,
|
|
108
|
+
"TodoCreate": ToolCategory.TASK_MGMT,
|
|
109
|
+
"TodoList": ToolCategory.TASK_MGMT,
|
|
110
|
+
"TodoComplete": ToolCategory.TASK_MGMT,
|
|
111
|
+
"AskUser": ToolCategory.INTERACTION,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_tool_category(name: str) -> ToolCategory:
|
|
116
|
+
return TOOL_CATEGORY_MAP.get(name, ToolCategory.UNKNOWN)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# ── Core data types ──
|
|
120
|
+
|
|
121
|
+
@dataclass
|
|
122
|
+
class ThinkBlock:
|
|
123
|
+
"""A thinking/reasoning block — collapsible in UI."""
|
|
124
|
+
id: str = field(default_factory=_uid)
|
|
125
|
+
content: str = ""
|
|
126
|
+
timestamp: float = field(default_factory=_now)
|
|
127
|
+
|
|
128
|
+
def to_dict(self) -> dict:
|
|
129
|
+
return {
|
|
130
|
+
"type": BlockType.THINKING.value,
|
|
131
|
+
"thinking": self.content,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@classmethod
|
|
135
|
+
def from_dict(cls, d: dict) -> "ThinkBlock":
|
|
136
|
+
return cls(content=d.get("thinking", ""))
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass
|
|
140
|
+
class ToolCall:
|
|
141
|
+
"""A tool invocation with lifecycle status."""
|
|
142
|
+
id: str = field(default_factory=_uid)
|
|
143
|
+
name: str = ""
|
|
144
|
+
arguments: dict[str, Any] = field(default_factory=dict)
|
|
145
|
+
status: LifecycleStatus = LifecycleStatus.RUNNING
|
|
146
|
+
timestamp: float = field(default_factory=_now)
|
|
147
|
+
category: ToolCategory = ToolCategory.UNKNOWN
|
|
148
|
+
caller: str = "agent"
|
|
149
|
+
|
|
150
|
+
def __post_init__(self):
|
|
151
|
+
if self.category == ToolCategory.UNKNOWN:
|
|
152
|
+
self.category = get_tool_category(self.name)
|
|
153
|
+
|
|
154
|
+
def to_dict(self) -> dict:
|
|
155
|
+
return {
|
|
156
|
+
"type": BlockType.TOOL_CALL.value,
|
|
157
|
+
"tool_use": {
|
|
158
|
+
"id": self.id,
|
|
159
|
+
"name": self.name,
|
|
160
|
+
"input": self.arguments,
|
|
161
|
+
"caller": self.caller,
|
|
162
|
+
"status": self.status.value,
|
|
163
|
+
"category": self.category.value,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@classmethod
|
|
168
|
+
def from_dict(cls, d: dict) -> "ToolCall":
|
|
169
|
+
tu = d.get("tool_use", {})
|
|
170
|
+
return cls(
|
|
171
|
+
id=tu.get("id", ""),
|
|
172
|
+
name=tu.get("name", ""),
|
|
173
|
+
arguments=tu.get("input", {}),
|
|
174
|
+
status=LifecycleStatus(tu.get("status", "running")),
|
|
175
|
+
category=ToolCategory(tu.get("category", "unknown")),
|
|
176
|
+
caller=tu.get("caller", "agent"),
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@dataclass
|
|
181
|
+
class ToolResult:
|
|
182
|
+
"""Result of a tool execution — typed by tool category."""
|
|
183
|
+
tool_use_id: str = ""
|
|
184
|
+
content: str = ""
|
|
185
|
+
is_error: bool = False
|
|
186
|
+
category: ToolCategory = ToolCategory.UNKNOWN
|
|
187
|
+
truncated: bool = False
|
|
188
|
+
full_size: int = 0
|
|
189
|
+
timestamp: float = field(default_factory=_now)
|
|
190
|
+
|
|
191
|
+
def to_dict(self) -> dict:
|
|
192
|
+
return {
|
|
193
|
+
"type": BlockType.TOOL_RESULT.value,
|
|
194
|
+
"tool_result": {
|
|
195
|
+
"tool_use_id": self.tool_use_id,
|
|
196
|
+
"content": self.content,
|
|
197
|
+
"is_error": self.is_error,
|
|
198
|
+
"category": self.category.value,
|
|
199
|
+
"truncated": self.truncated,
|
|
200
|
+
"full_size": self.full_size,
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@classmethod
|
|
205
|
+
def from_dict(cls, d: dict) -> "ToolResult":
|
|
206
|
+
tr = d.get("tool_result", {})
|
|
207
|
+
return cls(
|
|
208
|
+
tool_use_id=tr.get("tool_use_id", ""),
|
|
209
|
+
content=tr.get("content", ""),
|
|
210
|
+
is_error=tr.get("is_error", False),
|
|
211
|
+
category=ToolCategory(tr.get("category", "unknown")),
|
|
212
|
+
truncated=tr.get("truncated", False),
|
|
213
|
+
full_size=tr.get("full_size", 0),
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@dataclass
|
|
218
|
+
class SubAgentBlock:
|
|
219
|
+
"""A sub-agent execution with independent lifecycle."""
|
|
220
|
+
id: str = field(default_factory=_uid)
|
|
221
|
+
agent_type: str = "general"
|
|
222
|
+
prompt: str = ""
|
|
223
|
+
status: LifecycleStatus = LifecycleStatus.PENDING
|
|
224
|
+
result: str = ""
|
|
225
|
+
error: str = ""
|
|
226
|
+
timestamp: float = field(default_factory=_now)
|
|
227
|
+
blocks: list[dict] = field(default_factory=list) # nested blocks streamed from sub-agent
|
|
228
|
+
|
|
229
|
+
def to_dict(self) -> dict:
|
|
230
|
+
return {
|
|
231
|
+
"type": BlockType.SUBAGENT.value,
|
|
232
|
+
"subagent": {
|
|
233
|
+
"id": self.id,
|
|
234
|
+
"agent_type": self.agent_type,
|
|
235
|
+
"prompt": self.prompt,
|
|
236
|
+
"status": self.status.value,
|
|
237
|
+
"result": self.result,
|
|
238
|
+
"error": self.error,
|
|
239
|
+
"blocks": self.blocks,
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@classmethod
|
|
244
|
+
def from_dict(cls, d: dict) -> "SubAgentBlock":
|
|
245
|
+
sa = d.get("subagent", {})
|
|
246
|
+
return cls(
|
|
247
|
+
id=sa.get("id", ""),
|
|
248
|
+
agent_type=sa.get("agent_type", "general"),
|
|
249
|
+
prompt=sa.get("prompt", ""),
|
|
250
|
+
status=LifecycleStatus(sa.get("status", "pending")),
|
|
251
|
+
result=sa.get("result", ""),
|
|
252
|
+
error=sa.get("error", ""),
|
|
253
|
+
blocks=sa.get("blocks", []),
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@dataclass
|
|
258
|
+
class TextBlock:
|
|
259
|
+
"""A plain text block."""
|
|
260
|
+
id: str = field(default_factory=_uid)
|
|
261
|
+
content: str = ""
|
|
262
|
+
|
|
263
|
+
def to_dict(self) -> dict:
|
|
264
|
+
return {
|
|
265
|
+
"type": BlockType.TEXT.value,
|
|
266
|
+
"text": self.content,
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
# ── Stream events (ai-sdk-python style typed protocol) ──
|
|
271
|
+
|
|
272
|
+
class StreamEventType(str, Enum):
|
|
273
|
+
TEXT_DELTA = "text_delta"
|
|
274
|
+
THINKING = "thinking"
|
|
275
|
+
TOOL_CALL_START = "tool_call_start"
|
|
276
|
+
TOOL_CALL_ARGS = "tool_call_args"
|
|
277
|
+
TOOL_CALL_COMPLETE = "tool_call_complete"
|
|
278
|
+
TOOL_RESULT = "tool_result"
|
|
279
|
+
ASK_USER = "ask_user"
|
|
280
|
+
ERROR = "error"
|
|
281
|
+
PLAN = "plan"
|
|
282
|
+
SUBAGENT_START = "subagent_start"
|
|
283
|
+
SUBAGENT_CHUNK = "subagent_chunk"
|
|
284
|
+
SUBAGENT_END = "subagent_end"
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
@dataclass
|
|
288
|
+
class StreamEvent:
|
|
289
|
+
"""Typed streaming event — replaces raw XML string protocol between Engine and TUI.
|
|
290
|
+
|
|
291
|
+
ai-sdk-python reference:
|
|
292
|
+
- textStream equivalent: TEXT_DELTA events
|
|
293
|
+
- fullStream equivalent: TOOL_CALL_START → TOOL_CALL_ARGS → TOOL_RESULT + TEXT_DELTA
|
|
294
|
+
"""
|
|
295
|
+
type: StreamEventType
|
|
296
|
+
# TEXT_DELTA fields
|
|
297
|
+
text: str = ""
|
|
298
|
+
# THINKING fields
|
|
299
|
+
thinking: str = ""
|
|
300
|
+
# TOOL_CALL_START fields
|
|
301
|
+
tool_name: str = ""
|
|
302
|
+
tool_id: str = ""
|
|
303
|
+
tool_category: ToolCategory = ToolCategory.UNKNOWN
|
|
304
|
+
# TOOL_CALL_ARGS / TOOL_CALL_COMPLETE fields
|
|
305
|
+
tool_args: dict[str, Any] = field(default_factory=dict)
|
|
306
|
+
tool_args_delta: str = ""
|
|
307
|
+
# TOOL_RESULT fields
|
|
308
|
+
result_content: str = ""
|
|
309
|
+
result_is_error: bool = False
|
|
310
|
+
result_category: ToolCategory = ToolCategory.UNKNOWN
|
|
311
|
+
# ASK_USER fields
|
|
312
|
+
ask_action: str = ""
|
|
313
|
+
ask_question: str = ""
|
|
314
|
+
ask_context: str = ""
|
|
315
|
+
ask_options: list[dict] = field(default_factory=list)
|
|
316
|
+
ask_questions: list[dict] = field(default_factory=list)
|
|
317
|
+
ask_action_type: str = ""
|
|
318
|
+
ask_path: str = ""
|
|
319
|
+
ask_command: str = ""
|
|
320
|
+
# ERROR fields
|
|
321
|
+
error_message: str = ""
|
|
322
|
+
# PLAN fields
|
|
323
|
+
plan_entries: list[dict] = field(default_factory=list)
|
|
324
|
+
# SUBAGENT fields
|
|
325
|
+
subagent_id: str = ""
|
|
326
|
+
subagent_type: str = ""
|
|
327
|
+
subagent_text: str = ""
|
|
328
|
+
|
|
329
|
+
@classmethod
|
|
330
|
+
def text_delta(cls, text: str) -> "StreamEvent":
|
|
331
|
+
return cls(type=StreamEventType.TEXT_DELTA, text=text)
|
|
332
|
+
|
|
333
|
+
@classmethod
|
|
334
|
+
def thinking(cls, thought: str) -> "StreamEvent":
|
|
335
|
+
return cls(type=StreamEventType.THINKING, thinking=thought)
|
|
336
|
+
|
|
337
|
+
@classmethod
|
|
338
|
+
def tool_call_start(cls, name: str, call_id: str) -> "StreamEvent":
|
|
339
|
+
return cls(
|
|
340
|
+
type=StreamEventType.TOOL_CALL_START,
|
|
341
|
+
tool_name=name,
|
|
342
|
+
tool_id=call_id,
|
|
343
|
+
tool_category=get_tool_category(name),
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
@classmethod
|
|
347
|
+
def tool_call_args_delta(cls, call_id: str, name: str, args_delta: str) -> "StreamEvent":
|
|
348
|
+
return cls(
|
|
349
|
+
type=StreamEventType.TOOL_CALL_ARGS,
|
|
350
|
+
tool_id=call_id,
|
|
351
|
+
tool_name=name,
|
|
352
|
+
tool_category=get_tool_category(name),
|
|
353
|
+
tool_args_delta=args_delta,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
@classmethod
|
|
357
|
+
def tool_call_complete(cls, call_id: str, name: str, arguments: dict[str, Any]) -> "StreamEvent":
|
|
358
|
+
return cls(
|
|
359
|
+
type=StreamEventType.TOOL_CALL_COMPLETE,
|
|
360
|
+
tool_id=call_id,
|
|
361
|
+
tool_name=name,
|
|
362
|
+
tool_category=get_tool_category(name),
|
|
363
|
+
tool_args=arguments,
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
@classmethod
|
|
367
|
+
def tool_result(cls, call_id: str, content: str, is_error: bool = False,
|
|
368
|
+
category: ToolCategory = ToolCategory.UNKNOWN) -> "StreamEvent":
|
|
369
|
+
return cls(
|
|
370
|
+
type=StreamEventType.TOOL_RESULT,
|
|
371
|
+
tool_id=call_id,
|
|
372
|
+
result_content=content,
|
|
373
|
+
result_is_error=is_error,
|
|
374
|
+
result_category=category,
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
@classmethod
|
|
378
|
+
def ask_user(cls, call_id: str, action: str, question: str,
|
|
379
|
+
context: str = "", action_type: str = "",
|
|
380
|
+
path: str = "", command: str = "",
|
|
381
|
+
options: list[dict] | None = None,
|
|
382
|
+
questions: list[dict] | None = None) -> "StreamEvent":
|
|
383
|
+
return cls(
|
|
384
|
+
type=StreamEventType.ASK_USER,
|
|
385
|
+
tool_id=call_id,
|
|
386
|
+
ask_action=action,
|
|
387
|
+
ask_question=question,
|
|
388
|
+
ask_context=context,
|
|
389
|
+
ask_options=options or [],
|
|
390
|
+
ask_questions=questions or [],
|
|
391
|
+
ask_action_type=action_type,
|
|
392
|
+
ask_path=path,
|
|
393
|
+
ask_command=command,
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
@classmethod
|
|
397
|
+
def error(cls, message: str) -> "StreamEvent":
|
|
398
|
+
return cls(type=StreamEventType.ERROR, error_message=message)
|
|
399
|
+
|
|
400
|
+
@classmethod
|
|
401
|
+
def plan(cls, entries: list[dict]) -> "StreamEvent":
|
|
402
|
+
"""Create a plan update event.
|
|
403
|
+
|
|
404
|
+
Args:
|
|
405
|
+
entries: List of plan entries, each with:
|
|
406
|
+
- content: str - The task description
|
|
407
|
+
- status: str - "pending" | "in_progress" | "completed"
|
|
408
|
+
- priority: str - "high" | "medium" | "low"
|
|
409
|
+
"""
|
|
410
|
+
return cls(type=StreamEventType.PLAN, plan_entries=entries)
|
|
411
|
+
|
|
412
|
+
@classmethod
|
|
413
|
+
def subagent_start(cls, agent_type: str, call_id: str) -> "StreamEvent":
|
|
414
|
+
return cls(
|
|
415
|
+
type=StreamEventType.SUBAGENT_START,
|
|
416
|
+
subagent_id=call_id,
|
|
417
|
+
subagent_type=agent_type,
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
@classmethod
|
|
421
|
+
def subagent_chunk(cls, call_id: str, text: str) -> "StreamEvent":
|
|
422
|
+
return cls(
|
|
423
|
+
type=StreamEventType.SUBAGENT_CHUNK,
|
|
424
|
+
subagent_id=call_id,
|
|
425
|
+
subagent_text=text,
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
@classmethod
|
|
429
|
+
def subagent_end(cls, call_id: str) -> "StreamEvent":
|
|
430
|
+
return cls(type=StreamEventType.SUBAGENT_END, subagent_id=call_id)
|
|
431
|
+
|
|
432
|
+
@staticmethod
|
|
433
|
+
def is_text(event: "StreamEvent") -> bool:
|
|
434
|
+
return event.type in (StreamEventType.TEXT_DELTA, StreamEventType.THINKING)
|
|
435
|
+
|
|
436
|
+
def to_block_dict(self) -> dict:
|
|
437
|
+
"""Convert this stream event to a block dict for TUI rendering."""
|
|
438
|
+
if self.type == StreamEventType.TEXT_DELTA:
|
|
439
|
+
return TextBlock(content=self.text).to_dict()
|
|
440
|
+
elif self.type == StreamEventType.THINKING:
|
|
441
|
+
return ThinkBlock(content=self.thinking).to_dict()
|
|
442
|
+
elif self.type == StreamEventType.TOOL_CALL_START:
|
|
443
|
+
return {
|
|
444
|
+
"type": "tool_use_start",
|
|
445
|
+
"tool_use": {
|
|
446
|
+
"name": self.tool_name,
|
|
447
|
+
"id": self.tool_id,
|
|
448
|
+
"category": self.tool_category.value,
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
elif self.type == StreamEventType.TOOL_CALL_COMPLETE:
|
|
452
|
+
return ToolCall(
|
|
453
|
+
id=self.tool_id,
|
|
454
|
+
name=self.tool_name,
|
|
455
|
+
arguments=self.tool_args,
|
|
456
|
+
status=LifecycleStatus.COMPLETE,
|
|
457
|
+
category=self.tool_category,
|
|
458
|
+
).to_dict()
|
|
459
|
+
elif self.type == StreamEventType.TOOL_RESULT:
|
|
460
|
+
return ToolResult(
|
|
461
|
+
tool_use_id=self.tool_id,
|
|
462
|
+
content=self.result_content,
|
|
463
|
+
is_error=self.result_is_error,
|
|
464
|
+
category=self.result_category,
|
|
465
|
+
).to_dict()
|
|
466
|
+
elif self.type == StreamEventType.ASK_USER:
|
|
467
|
+
result = {
|
|
468
|
+
"type": "ask_user",
|
|
469
|
+
"ask_user": {
|
|
470
|
+
"tool_use_id": self.tool_id,
|
|
471
|
+
"action": self.ask_action,
|
|
472
|
+
"category": self.tool_category.value,
|
|
473
|
+
"question": self.ask_question,
|
|
474
|
+
"context": self.ask_context,
|
|
475
|
+
"options": self.ask_options,
|
|
476
|
+
"questions": self.ask_questions,
|
|
477
|
+
"action_type": self.ask_action_type,
|
|
478
|
+
"path": self.ask_path,
|
|
479
|
+
"command": self.ask_command,
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return result
|
|
483
|
+
elif self.type == StreamEventType.ERROR:
|
|
484
|
+
return TextBlock(content=f"[Error: {self.error_message}]").to_dict()
|
|
485
|
+
elif self.type == StreamEventType.SUBAGENT_START:
|
|
486
|
+
return {
|
|
487
|
+
"type": "subagent_start",
|
|
488
|
+
"subagent": {
|
|
489
|
+
"id": self.subagent_id,
|
|
490
|
+
"agent_type": self.subagent_type,
|
|
491
|
+
"status": "running",
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
elif self.type == StreamEventType.SUBAGENT_CHUNK:
|
|
495
|
+
return {
|
|
496
|
+
"type": "subagent_chunk",
|
|
497
|
+
"subagent": {
|
|
498
|
+
"id": self.subagent_id,
|
|
499
|
+
"text": self.subagent_text,
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
elif self.type == StreamEventType.SUBAGENT_END:
|
|
503
|
+
return {
|
|
504
|
+
"type": "subagent_end",
|
|
505
|
+
"subagent": {
|
|
506
|
+
"id": self.subagent_id,
|
|
507
|
+
"status": "completed",
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return TextBlock(content="").to_dict()
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
# ── Unified block type ──
|
|
514
|
+
|
|
515
|
+
if sys.version_info >= (3, 10):
|
|
516
|
+
AgentBlock = ThinkBlock | ToolCall | ToolResult | SubAgentBlock | TextBlock
|
|
517
|
+
else:
|
|
518
|
+
from typing import Union
|
|
519
|
+
AgentBlock = Union[ThinkBlock, ToolCall, ToolResult, SubAgentBlock, TextBlock]
|
|
520
|
+
StreamEventOrStr = "StreamEvent | str" # Marker type for documentation
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
def block_from_dict(d: dict) -> AgentBlock:
|
|
524
|
+
"""Parse a raw dict into a typed AgentBlock."""
|
|
525
|
+
btype = d.get("type", "")
|
|
526
|
+
if btype == "thinking":
|
|
527
|
+
return ThinkBlock.from_dict(d)
|
|
528
|
+
elif btype == "tool_use" or btype == "tool_call":
|
|
529
|
+
if "tool_use" not in d:
|
|
530
|
+
d = {"type": "tool_call", "tool_use": d.get("tool_use", {})}
|
|
531
|
+
return ToolCall.from_dict(d)
|
|
532
|
+
elif btype == "tool_result":
|
|
533
|
+
return ToolResult.from_dict(d)
|
|
534
|
+
elif btype == "subagent":
|
|
535
|
+
return SubAgentBlock.from_dict(d)
|
|
536
|
+
elif btype == "text":
|
|
537
|
+
return TextBlock(content=d.get("text", ""))
|
|
538
|
+
elif btype == "tool_use_start":
|
|
539
|
+
tu = d.get("tool_use", {})
|
|
540
|
+
return ToolCall(
|
|
541
|
+
id=tu.get("id", ""),
|
|
542
|
+
name=tu.get("name", ""),
|
|
543
|
+
status=LifecycleStatus.RUNNING,
|
|
544
|
+
category=get_tool_category(tu.get("name", "")),
|
|
545
|
+
)
|
|
546
|
+
return TextBlock(content=str(d))
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
# ── AgentMessage ──
|
|
550
|
+
|
|
551
|
+
@dataclass
|
|
552
|
+
class AgentMessage:
|
|
553
|
+
"""A turn-level message with typed content blocks."""
|
|
554
|
+
id: str = field(default_factory=_uid)
|
|
555
|
+
role: MessageRole = MessageRole.ASSISTANT
|
|
556
|
+
blocks: list[AgentBlock] = field(default_factory=list)
|
|
557
|
+
timestamp: float = field(default_factory=_now)
|
|
558
|
+
|
|
559
|
+
def add_text(self, text: str) -> None:
|
|
560
|
+
self.blocks.append(TextBlock(content=text))
|
|
561
|
+
|
|
562
|
+
def add_thinking(self, content: str) -> None:
|
|
563
|
+
self.blocks.append(ThinkBlock(content=content))
|
|
564
|
+
|
|
565
|
+
def add_tool_call(self, tc: ToolCall) -> None:
|
|
566
|
+
self.blocks.append(tc)
|
|
567
|
+
|
|
568
|
+
def add_tool_result(self, tr: ToolResult) -> None:
|
|
569
|
+
self.blocks.append(tr)
|
|
570
|
+
|
|
571
|
+
def add_subagent(self, sa: SubAgentBlock) -> None:
|
|
572
|
+
self.blocks.append(sa)
|
|
573
|
+
|
|
574
|
+
@property
|
|
575
|
+
def text_blocks(self) -> list[TextBlock]:
|
|
576
|
+
return [b for b in self.blocks if isinstance(b, TextBlock)]
|
|
577
|
+
|
|
578
|
+
@property
|
|
579
|
+
def think_blocks(self) -> list[ThinkBlock]:
|
|
580
|
+
return [b for b in self.blocks if isinstance(b, ThinkBlock)]
|
|
581
|
+
|
|
582
|
+
@property
|
|
583
|
+
def tool_calls(self) -> list[ToolCall]:
|
|
584
|
+
return [b for b in self.blocks if isinstance(b, ToolCall)]
|
|
585
|
+
|
|
586
|
+
@property
|
|
587
|
+
def tool_results(self) -> list[ToolResult]:
|
|
588
|
+
return [b for b in self.blocks if isinstance(b, ToolResult)]
|
|
589
|
+
|
|
590
|
+
@property
|
|
591
|
+
def subagents(self) -> list[SubAgentBlock]:
|
|
592
|
+
return [b for b in self.blocks if isinstance(b, SubAgentBlock)]
|
|
593
|
+
|
|
594
|
+
@property
|
|
595
|
+
def text(self) -> str:
|
|
596
|
+
return "\n".join(b.content for b in self.text_blocks)
|
|
597
|
+
|
|
598
|
+
@property
|
|
599
|
+
def thinking(self) -> str:
|
|
600
|
+
return "\n\n".join(b.content for b in self.think_blocks)
|
|
601
|
+
|
|
602
|
+
def get_tool_result(self, tool_use_id: str) -> Optional[ToolResult]:
|
|
603
|
+
for tr in self.tool_results:
|
|
604
|
+
if tr.tool_use_id == tool_use_id:
|
|
605
|
+
return tr
|
|
606
|
+
return None
|
|
607
|
+
|
|
608
|
+
def to_dict(self) -> dict:
|
|
609
|
+
return {
|
|
610
|
+
"id": self.id,
|
|
611
|
+
"role": self.role.value,
|
|
612
|
+
"blocks": [b.to_dict() for b in self.blocks],
|
|
613
|
+
"timestamp": self.timestamp,
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
@classmethod
|
|
617
|
+
def from_dict(cls, d: dict) -> "AgentMessage":
|
|
618
|
+
return cls(
|
|
619
|
+
id=d.get("id", ""),
|
|
620
|
+
role=MessageRole(d.get("role", "assistant")),
|
|
621
|
+
blocks=[block_from_dict(b) for b in d.get("blocks", [])],
|
|
622
|
+
timestamp=d.get("timestamp", 0),
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
# ── Conversation ──
|
|
627
|
+
|
|
628
|
+
@dataclass
|
|
629
|
+
class Conversation:
|
|
630
|
+
"""Full conversation history with typed messages."""
|
|
631
|
+
id: str = field(default_factory=lambda: uuid.uuid4().hex[:16])
|
|
632
|
+
messages: list[AgentMessage] = field(default_factory=list)
|
|
633
|
+
created_at: float = field(default_factory=_now)
|
|
634
|
+
|
|
635
|
+
def add_message(self, msg: AgentMessage) -> None:
|
|
636
|
+
self.messages.append(msg)
|
|
637
|
+
|
|
638
|
+
def new_message(self, role: MessageRole = MessageRole.ASSISTANT) -> AgentMessage:
|
|
639
|
+
msg = AgentMessage(role=role)
|
|
640
|
+
self.messages.append(msg)
|
|
641
|
+
return msg
|
|
642
|
+
|
|
643
|
+
def get_last_assistant(self) -> Optional[AgentMessage]:
|
|
644
|
+
for m in reversed(self.messages):
|
|
645
|
+
if m.role == MessageRole.ASSISTANT:
|
|
646
|
+
return m
|
|
647
|
+
return None
|
|
648
|
+
|
|
649
|
+
def to_dict(self) -> dict:
|
|
650
|
+
return {
|
|
651
|
+
"id": self.id,
|
|
652
|
+
"messages": [m.to_dict() for m in self.messages],
|
|
653
|
+
"created_at": self.created_at,
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
@classmethod
|
|
657
|
+
def from_dict(cls, d: dict) -> "Conversation":
|
|
658
|
+
return cls(
|
|
659
|
+
id=d.get("id", ""),
|
|
660
|
+
messages=[AgentMessage.from_dict(m) for m in d.get("messages", [])],
|
|
661
|
+
created_at=d.get("created_at", 0),
|
|
662
|
+
)
|