@tencent-ai/agent-sdk 0.3.98 → 0.3.100
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/cli/CHANGELOG.md +50 -0
- package/cli/dist/codebuddy-headless.js +137 -108
- package/cli/dist/web-ui/assets/index-BoMlEqUE.js +439 -0
- package/cli/dist/web-ui/assets/index-Dt1puyHn.css +32 -0
- package/cli/dist/web-ui/docs/cn/cli/acp.md +152 -0
- package/cli/dist/web-ui/docs/cn/cli/agent-teams.md +327 -0
- package/cli/dist/web-ui/docs/cn/cli/bash-sandboxing.md +290 -0
- package/cli/dist/web-ui/docs/cn/cli/best-practices.md +554 -0
- package/cli/dist/web-ui/docs/cn/cli/channels-reference.md +293 -0
- package/cli/dist/web-ui/docs/cn/cli/channels.md +215 -0
- package/cli/dist/web-ui/docs/cn/cli/checkpointing.md +51 -0
- package/cli/dist/web-ui/docs/cn/cli/cli-reference.md +187 -0
- package/cli/dist/web-ui/docs/cn/cli/common-workflows.md +1013 -0
- package/cli/dist/web-ui/docs/cn/cli/costs.md +174 -0
- package/cli/dist/web-ui/docs/cn/cli/devcontainer.md +553 -0
- package/cli/dist/web-ui/docs/cn/cli/env-vars.md +326 -0
- package/cli/dist/web-ui/docs/cn/cli/gitlab-ci-cd.md +357 -0
- package/cli/dist/web-ui/docs/cn/cli/headless.md +258 -0
- package/cli/dist/web-ui/docs/cn/cli/hooks-guide.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/hooks.md +805 -0
- package/cli/dist/web-ui/docs/cn/cli/iam.md +530 -0
- package/cli/dist/web-ui/docs/cn/cli/ide-integrations.md +92 -0
- package/cli/dist/web-ui/docs/cn/cli/installation.md +291 -0
- package/cli/dist/web-ui/docs/cn/cli/interactive-mode.md +233 -0
- package/cli/dist/web-ui/docs/cn/cli/mcp.md +739 -0
- package/cli/dist/web-ui/docs/cn/cli/memory.md +436 -0
- package/cli/dist/web-ui/docs/cn/cli/models.md +356 -0
- package/cli/dist/web-ui/docs/cn/cli/overview.md +100 -0
- package/cli/dist/web-ui/docs/cn/cli/plugin-marketplaces.md +533 -0
- package/cli/dist/web-ui/docs/cn/cli/plugins-reference.md +774 -0
- package/cli/dist/web-ui/docs/cn/cli/plugins.md +689 -0
- package/cli/dist/web-ui/docs/cn/cli/quickstart.md +249 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/README.md +199 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.0.md +23 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.11.0.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.12.0.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.13.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.0.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.1.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.16.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.17.0.md +29 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.18.0.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.0.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.1.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.2.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.0.md +23 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.1.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.21.0.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.22.0.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.3.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.4.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.5.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.24.0.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.1.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.26.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.0.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.1.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.2.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.3.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.0.md +26 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.29.0.md +35 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.3.1.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.0.md +51 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.2.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.32.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.0.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.1.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.36.3.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.0.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.1.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.10.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.11.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.12.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.13.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.14.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.15.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.16.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.17.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.18.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.19.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.2.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.20.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.3.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.4.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.5.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.6.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.7.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.8.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.9.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.0.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.2.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.39.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.4.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.0.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.3.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.4.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.5.md +10 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.6.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.7.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.8.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.0.md +39 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.1.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.3.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.0.md +27 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.1.md +27 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.0.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.1.md +22 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.0.md +34 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.1.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.46.0.md +12 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.47.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.0.md +32 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.0.md +26 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.1.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.2.md +39 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.3.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.5.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.6.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.7.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.5.0.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.0.md +25 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.1.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.2.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.3.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.4.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.5.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.6.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.7.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.0.md +24 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.1.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.0.md +30 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.1.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.2.md +12 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.3.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.4.md +27 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.5.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.6.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.53.0.md +29 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.54.0.md +26 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.0.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.1.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.0.md +32 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.1.md +10 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.58.0.md +34 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.59.0.md +28 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.0.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.1.md +10 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.60.0.md +20 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.0.md +29 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.2.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.3.md +13 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.0.md +21 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.1.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.2.md +7 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.3.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.4.md +8 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.5.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.0.md +37 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.1.md +6 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.2.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.0.md +19 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.1.md +11 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.0.md +15 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.1.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.67.0.md +33 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.7.0.md +16 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.0.md +18 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.1.md +17 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.2.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.3.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.4.md +9 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.5.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.6.md +14 -0
- package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.9.0.md +5 -0
- package/cli/dist/web-ui/docs/cn/cli/remote-control.md +247 -0
- package/cli/dist/web-ui/docs/cn/cli/sandboxing.md +316 -0
- package/cli/dist/web-ui/docs/cn/cli/scheduled-tasks.md +161 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-custom-tools.md +1195 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-demos.md +347 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-hooks.md +803 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-mcp.md +643 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-permissions.md +501 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-python.md +783 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-sessions.md +332 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk-typescript.md +759 -0
- package/cli/dist/web-ui/docs/cn/cli/sdk.md +1105 -0
- package/cli/dist/web-ui/docs/cn/cli/security.md +387 -0
- package/cli/dist/web-ui/docs/cn/cli/settings.md +602 -0
- package/cli/dist/web-ui/docs/cn/cli/skills.md +448 -0
- package/cli/dist/web-ui/docs/cn/cli/slash-commands.md +397 -0
- package/cli/dist/web-ui/docs/cn/cli/statusline.md +525 -0
- package/cli/dist/web-ui/docs/cn/cli/sub-agents.md +634 -0
- package/cli/dist/web-ui/docs/cn/cli/terminal-config.md +77 -0
- package/cli/dist/web-ui/docs/cn/cli/tools-reference.md +99 -0
- package/cli/dist/web-ui/docs/cn/cli/troubleshooting.md +190 -0
- package/cli/dist/web-ui/docs/cn/cli/web-ui.md +164 -0
- package/cli/dist/web-ui/docs/cn/cli/wecom-bot-setup.md +274 -0
- package/cli/dist/web-ui/docs/cn/cli/worktree.md +660 -0
- package/cli/dist/web-ui/docs/en/cli/acp.md +126 -0
- package/cli/dist/web-ui/docs/en/cli/agent-teams.md +327 -0
- package/cli/dist/web-ui/docs/en/cli/bash-sandboxing.md +357 -0
- package/cli/dist/web-ui/docs/en/cli/best-practices.md +554 -0
- package/cli/dist/web-ui/docs/en/cli/channels-reference.md +293 -0
- package/cli/dist/web-ui/docs/en/cli/channels.md +215 -0
- package/cli/dist/web-ui/docs/en/cli/checkpointing.md +53 -0
- package/cli/dist/web-ui/docs/en/cli/cli-reference.md +187 -0
- package/cli/dist/web-ui/docs/en/cli/common-workflows.md +1011 -0
- package/cli/dist/web-ui/docs/en/cli/costs.md +174 -0
- package/cli/dist/web-ui/docs/en/cli/devcontainer.md +553 -0
- package/cli/dist/web-ui/docs/en/cli/env-vars.md +326 -0
- package/cli/dist/web-ui/docs/en/cli/gitlab-ci-cd.md +357 -0
- package/cli/dist/web-ui/docs/en/cli/headless.md +258 -0
- package/cli/dist/web-ui/docs/en/cli/hooks-guide.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/hooks.md +801 -0
- package/cli/dist/web-ui/docs/en/cli/iam.md +526 -0
- package/cli/dist/web-ui/docs/en/cli/ide-integrations.md +92 -0
- package/cli/dist/web-ui/docs/en/cli/installation.md +266 -0
- package/cli/dist/web-ui/docs/en/cli/interactive-mode.md +233 -0
- package/cli/dist/web-ui/docs/en/cli/mcp.md +739 -0
- package/cli/dist/web-ui/docs/en/cli/memory.md +436 -0
- package/cli/dist/web-ui/docs/en/cli/models.md +355 -0
- package/cli/dist/web-ui/docs/en/cli/overview.md +100 -0
- package/cli/dist/web-ui/docs/en/cli/plugin-marketplaces.md +534 -0
- package/cli/dist/web-ui/docs/en/cli/plugins-reference.md +774 -0
- package/cli/dist/web-ui/docs/en/cli/plugins.md +688 -0
- package/cli/dist/web-ui/docs/en/cli/quickstart.md +249 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/README.md +193 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.0.md +23 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.11.0.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.12.0.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.13.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.0.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.1.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.16.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.17.0.md +29 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.18.0.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.0.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.1.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.2.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.0.md +23 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.1.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.21.0.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.22.0.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.0.md +41 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.3.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.4.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.5.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.24.0.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.1.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.26.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.0.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.1.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.2.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.3.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.0.md +26 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.29.0.md +35 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.3.1.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.0.md +51 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.2.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.32.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.0.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.1.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.0.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.1.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.35.0.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.0.md +23 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.2.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.3.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.0.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.1.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.10.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.11.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.12.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.13.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.14.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.15.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.16.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.17.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.18.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.19.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.2.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.20.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.3.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.4.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.5.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.6.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.7.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.8.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.9.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.0.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.2.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.39.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.4.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.0.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.3.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.4.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.5.md +10 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.6.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.7.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.8.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.0.md +39 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.1.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.3.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.0.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.1.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.0.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.1.md +22 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.0.md +34 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.1.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.46.0.md +12 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.47.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.0.md +32 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.0.md +26 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.1.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.2.md +39 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.3.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.5.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.6.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.7.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.5.0.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.0.md +25 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.1.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.2.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.3.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.4.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.5.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.6.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.7.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.0.md +24 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.1.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.0.md +30 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.1.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.2.md +12 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.3.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.4.md +27 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.5.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.6.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.53.0.md +29 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.54.0.md +26 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.0.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.1.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.0.md +32 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.1.md +10 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.58.0.md +34 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.59.0.md +28 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.0.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.1.md +10 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.60.0.md +20 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.0.md +29 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.2.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.3.md +13 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.0.md +21 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.1.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.2.md +7 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.3.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.4.md +8 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.5.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.0.md +37 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.1.md +6 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.2.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.0.md +19 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.1.md +11 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.0.md +15 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.1.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.67.0.md +33 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.7.0.md +16 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.0.md +18 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.1.md +17 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.2.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.3.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.4.md +9 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.5.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.6.md +14 -0
- package/cli/dist/web-ui/docs/en/cli/release-notes/v2.9.0.md +5 -0
- package/cli/dist/web-ui/docs/en/cli/remote-control.md +247 -0
- package/cli/dist/web-ui/docs/en/cli/sandboxing.md +316 -0
- package/cli/dist/web-ui/docs/en/cli/scheduled-tasks.md +160 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-custom-tools.md +1131 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-demos.md +347 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-hooks.md +813 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-mcp.md +645 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-permissions.md +461 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-python.md +797 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-sessions.md +340 -0
- package/cli/dist/web-ui/docs/en/cli/sdk-typescript.md +770 -0
- package/cli/dist/web-ui/docs/en/cli/sdk.md +1103 -0
- package/cli/dist/web-ui/docs/en/cli/security.md +388 -0
- package/cli/dist/web-ui/docs/en/cli/settings.md +602 -0
- package/cli/dist/web-ui/docs/en/cli/skills.md +448 -0
- package/cli/dist/web-ui/docs/en/cli/slash-commands.md +397 -0
- package/cli/dist/web-ui/docs/en/cli/statusline.md +525 -0
- package/cli/dist/web-ui/docs/en/cli/sub-agents.md +621 -0
- package/cli/dist/web-ui/docs/en/cli/terminal-config.md +77 -0
- package/cli/dist/web-ui/docs/en/cli/tools-reference.md +99 -0
- package/cli/dist/web-ui/docs/en/cli/troubleshooting.md +190 -0
- package/cli/dist/web-ui/docs/en/cli/web-ui.md +164 -0
- package/cli/dist/web-ui/docs/en/cli/wecom-bot-setup.md +274 -0
- package/cli/dist/web-ui/docs/en/cli/worktree.md +660 -0
- package/cli/dist/web-ui/docs/search-index-en.json +1 -0
- package/cli/dist/web-ui/docs/search-index-zh.json +1 -0
- package/cli/dist/web-ui/docs/sidebar-en.json +1 -0
- package/cli/dist/web-ui/docs/sidebar-zh.json +1 -0
- package/cli/dist/web-ui/index.html +2 -2
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +4 -3
- package/cli/product.internal.json +4 -3
- package/cli/product.ioa.json +4 -3
- package/cli/product.json +13 -6
- package/cli/product.selfhosted.json +4 -3
- package/package.json +1 -1
- package/cli/dist/web-ui/assets/index-4SCgPWnj.css +0 -32
- package/cli/dist/web-ui/assets/index-BijmmKDe.js +0 -391
|
@@ -0,0 +1,1105 @@
|
|
|
1
|
+
# CodeBuddy Agent SDK
|
|
2
|
+
|
|
3
|
+
> **版本要求**:本文档针对 CodeBuddy Agent SDK v0.1.0 及以上版本。
|
|
4
|
+
> **功能状态**:SDK 当前处于 **Preview** 阶段,接口和行为可能在未来版本中调整。
|
|
5
|
+
|
|
6
|
+
::: warning 重要:环境隔离
|
|
7
|
+
SDK 默认**不加载任何文件系统配置**,包括 `settings.json`、`CODEBUDDY.md`、MCP 服务器、子代理、斜杠命令、Rules 和 Skills。这是与 CLI 直接使用的关键区别,确保 SDK 应用的行为完全由代码控制,具有可预测性和一致性。
|
|
8
|
+
|
|
9
|
+
如需加载这些配置,请使用 `settingSources` 选项显式指定。详见 [环境隔离](#环境隔离settingsources) 章节。
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
CodeBuddy Agent SDK 允许你在应用程序中以编程方式控制 CodeBuddy Agent。支持 TypeScript/JavaScript 和 Python,可实现自动化任务执行、自定义权限控制、构建 AI 驱动的开发工具等场景。
|
|
13
|
+
|
|
14
|
+
## 为什么使用 SDK
|
|
15
|
+
|
|
16
|
+
CodeBuddy Agent SDK 让你能够以编程方式访问 CodeBuddy 的全部能力,而不仅仅是通过命令行交互。
|
|
17
|
+
|
|
18
|
+
### 超越命令行的能力
|
|
19
|
+
|
|
20
|
+
- **程序化控制**:在你的应用程序中嵌入 AI 编程助手,实现自动化工作流
|
|
21
|
+
- **自定义交互**:构建符合你需求的用户界面和交互方式
|
|
22
|
+
- **批量处理**:对多个文件或项目执行批量 AI 操作
|
|
23
|
+
- **集成现有系统**:将 AI 能力无缝集成到 CI/CD、IDE 插件或其他开发工具中
|
|
24
|
+
|
|
25
|
+
### 精细化控制
|
|
26
|
+
|
|
27
|
+
- **权限管控**:通过 `canUseTool` 回调实现企业级权限策略
|
|
28
|
+
- **行为定制**:使用 Hook 系统拦截和修改 Agent 行为
|
|
29
|
+
- **资源限制**:控制 token 消耗、执行时间和费用预算
|
|
30
|
+
- **会话管理**:持久化和恢复对话上下文
|
|
31
|
+
|
|
32
|
+
### 扩展能力
|
|
33
|
+
|
|
34
|
+
- **自定义 Agent**:创建专门化的子 Agent 处理特定领域任务
|
|
35
|
+
- **MCP 集成**:接入自定义工具和服务
|
|
36
|
+
- **多模型支持**:灵活切换和配置不同的 AI 模型
|
|
37
|
+
|
|
38
|
+
## 你可以构建什么
|
|
39
|
+
|
|
40
|
+
### 开发工具增强
|
|
41
|
+
|
|
42
|
+
- **IDE 插件**:为 VS Code、JetBrains 等 IDE 构建智能编程助手
|
|
43
|
+
- **代码审查工具**:自动化代码质量检查和安全扫描
|
|
44
|
+
- **文档生成器**:自动生成 API 文档、README 和代码注释
|
|
45
|
+
|
|
46
|
+
### 自动化工作流
|
|
47
|
+
|
|
48
|
+
- **CI/CD 集成**:在流水线中执行智能代码分析和修复
|
|
49
|
+
- **测试生成**:自动生成单元测试和集成测试
|
|
50
|
+
- **重构助手**:批量执行代码重构和迁移任务
|
|
51
|
+
|
|
52
|
+
### 企业应用
|
|
53
|
+
|
|
54
|
+
- **内部开发平台**:构建企业级 AI 编程平台
|
|
55
|
+
- **知识库问答**:基于代码库的智能问答系统
|
|
56
|
+
- **培训工具**:交互式编程学习和代码评审系统
|
|
57
|
+
|
|
58
|
+
## 功能概览
|
|
59
|
+
|
|
60
|
+
- **消息流式传输**:实时接收系统消息、助手响应和工具调用结果
|
|
61
|
+
- **多轮对话**:支持跨多次推理调用的对话上下文保持
|
|
62
|
+
- **会话管理**:通过会话 ID 继续或恢复现有对话
|
|
63
|
+
- **权限控制**:细粒度的工具访问权限管理
|
|
64
|
+
- **Hook 系统**:在工具执行前后插入自定义逻辑
|
|
65
|
+
- **自定义 Agent**:定义专门化的子 Agent 处理特定任务
|
|
66
|
+
- **MCP 集成**:支持配置自定义 MCP 服务器扩展功能
|
|
67
|
+
|
|
68
|
+
## 安装
|
|
69
|
+
|
|
70
|
+
::: code-group
|
|
71
|
+
|
|
72
|
+
```bash [TypeScript]
|
|
73
|
+
npm install @tencent-ai/agent-sdk
|
|
74
|
+
# 或
|
|
75
|
+
yarn add @tencent-ai/agent-sdk
|
|
76
|
+
# 或
|
|
77
|
+
pnpm add @tencent-ai/agent-sdk
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```bash [Python]
|
|
81
|
+
uv add codebuddy-agent-sdk
|
|
82
|
+
# 或
|
|
83
|
+
pip install codebuddy-agent-sdk
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
:::
|
|
87
|
+
|
|
88
|
+
### 环境要求
|
|
89
|
+
|
|
90
|
+
| 语言 | 版本要求 |
|
|
91
|
+
|------|---------|
|
|
92
|
+
| TypeScript/JavaScript | Node.js >= 18.20 |
|
|
93
|
+
| Python | Python >= 3.10 |
|
|
94
|
+
|
|
95
|
+
### 认证配置
|
|
96
|
+
|
|
97
|
+
#### 使用已有登录凭据
|
|
98
|
+
|
|
99
|
+
如果你已经在终端中通过 `codebuddy` 命令完成了交互式登录,SDK 会自动使用该认证信息,无需额外配置。
|
|
100
|
+
|
|
101
|
+
#### 使用 API Key
|
|
102
|
+
|
|
103
|
+
如果未登录或需要使用不同的凭据,可以通过 API Key 认证:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
export CODEBUDDY_API_KEY="your-api-key"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**获取 API Key:**
|
|
110
|
+
|
|
111
|
+
| 版本 | 获取地址 |
|
|
112
|
+
|:----|:--------|
|
|
113
|
+
| 海外版 | <https://www.codebuddy.ai/profile/keys> |
|
|
114
|
+
| 中国版 | <https://copilot.tencent.com/profile/> |
|
|
115
|
+
| iOA 版 | <https://tencent.sso.copilot.tencent.com/profile/keys> |
|
|
116
|
+
|
|
117
|
+
> **注意**:使用 `CODEBUDDY_API_KEY` 时,必须根据版本正确配置 `CODEBUDDY_INTERNET_ENVIRONMENT` 环境变量:
|
|
118
|
+
> - 海外版:不设置(默认)
|
|
119
|
+
> - 中国版:`export CODEBUDDY_INTERNET_ENVIRONMENT=internal`
|
|
120
|
+
> - iOA 版:`export CODEBUDDY_INTERNET_ENVIRONMENT=ioa`
|
|
121
|
+
>
|
|
122
|
+
> 详见 [身份和访问管理文档](iam.md#个人用户获取-api-key)。
|
|
123
|
+
|
|
124
|
+
也可以在代码中通过 `env` 选项传递:
|
|
125
|
+
|
|
126
|
+
::: code-group
|
|
127
|
+
|
|
128
|
+
```typescript [TypeScript]
|
|
129
|
+
const q = query({
|
|
130
|
+
prompt: '...',
|
|
131
|
+
options: {
|
|
132
|
+
env: {
|
|
133
|
+
CODEBUDDY_API_KEY: process.env.MY_API_KEY,
|
|
134
|
+
// 中国版用户需要设置:
|
|
135
|
+
// CODEBUDDY_INTERNET_ENVIRONMENT: 'internal'
|
|
136
|
+
// iOA 版用户需要设置:
|
|
137
|
+
// CODEBUDDY_INTERNET_ENVIRONMENT: 'ioa'
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```python [Python]
|
|
144
|
+
options = CodeBuddyAgentOptions(
|
|
145
|
+
env={
|
|
146
|
+
"CODEBUDDY_API_KEY": os.environ.get("MY_API_KEY"),
|
|
147
|
+
# 中国版用户需要设置:
|
|
148
|
+
# "CODEBUDDY_INTERNET_ENVIRONMENT": "internal"
|
|
149
|
+
# iOA 版用户需要设置:
|
|
150
|
+
# "CODEBUDDY_INTERNET_ENVIRONMENT": "ioa"
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
:::
|
|
156
|
+
|
|
157
|
+
#### 企业用户:OAuth Client Credentials
|
|
158
|
+
|
|
159
|
+
> 目前仅介绍 Client Credentials 授权方式,适用于服务端应用和 CI/CD 场景。
|
|
160
|
+
|
|
161
|
+
> **前提条件**:企业用户需要先购买 CodeBuddy 旗舰版才能使用 OAuth 认证。详见 [CodeBuddy 旗舰版购买指南](https://cloud.tencent.com/document/product/1749/110012)。
|
|
162
|
+
|
|
163
|
+
企业用户需要先通过 OAuth 2.0 Client Credentials 流程获取 access token,然后传入 SDK。
|
|
164
|
+
|
|
165
|
+
**第 1 步:创建应用获取凭据**
|
|
166
|
+
|
|
167
|
+
参考 [企业开发者快速入门](https://copilot.tencent.com/apiDocs/open-platform.html) 创建应用并获取 Client ID 和 Client Secret。
|
|
168
|
+
|
|
169
|
+
**第 2 步:获取 token 并调用 SDK**
|
|
170
|
+
|
|
171
|
+
::: code-group
|
|
172
|
+
|
|
173
|
+
```typescript [TypeScript]
|
|
174
|
+
async function getOAuthToken(clientId: string, clientSecret: string): Promise<string> {
|
|
175
|
+
const response = await fetch('https://copilot.tencent.com/oauth2/token', {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
178
|
+
body: new URLSearchParams({
|
|
179
|
+
grant_type: 'client_credentials',
|
|
180
|
+
client_id: clientId,
|
|
181
|
+
client_secret: clientSecret,
|
|
182
|
+
}),
|
|
183
|
+
});
|
|
184
|
+
const data = await response.json();
|
|
185
|
+
return data.access_token;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 获取 token 并调用 SDK
|
|
189
|
+
const token = await getOAuthToken('your-client-id', 'your-client-secret');
|
|
190
|
+
|
|
191
|
+
for await (const msg of query({
|
|
192
|
+
prompt: 'Hello',
|
|
193
|
+
options: {
|
|
194
|
+
env: { CODEBUDDY_AUTH_TOKEN: token },
|
|
195
|
+
},
|
|
196
|
+
})) {
|
|
197
|
+
console.log(msg);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```python [Python]
|
|
202
|
+
import httpx
|
|
203
|
+
from codebuddy_agent_sdk import query, CodeBuddyAgentOptions
|
|
204
|
+
|
|
205
|
+
async def get_oauth_token(client_id: str, client_secret: str) -> str:
|
|
206
|
+
async with httpx.AsyncClient() as client:
|
|
207
|
+
response = await client.post(
|
|
208
|
+
"https://copilot.tencent.com/oauth2/token",
|
|
209
|
+
data={
|
|
210
|
+
"grant_type": "client_credentials",
|
|
211
|
+
"client_id": client_id,
|
|
212
|
+
"client_secret": client_secret,
|
|
213
|
+
},
|
|
214
|
+
)
|
|
215
|
+
return response.json()["access_token"]
|
|
216
|
+
|
|
217
|
+
# 获取 token 并调用 SDK
|
|
218
|
+
token = await get_oauth_token("your-client-id", "your-client-secret")
|
|
219
|
+
|
|
220
|
+
options = CodeBuddyAgentOptions(
|
|
221
|
+
env={"CODEBUDDY_AUTH_TOKEN": token}
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
async for msg in query(prompt="Hello", options=options):
|
|
225
|
+
print(msg)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
:::
|
|
229
|
+
|
|
230
|
+
详细的认证配置说明请参阅 [身份认证](iam.md#认证方法)。
|
|
231
|
+
|
|
232
|
+
### 其他环境变量
|
|
233
|
+
|
|
234
|
+
| 变量名 | 说明 | 必需 |
|
|
235
|
+
|--------|------|------|
|
|
236
|
+
| `CODEBUDDY_CODE_PATH` | CodeBuddy CLI 可执行文件路径 | 可选 |
|
|
237
|
+
|
|
238
|
+
如果未设置,SDK 会自动尝试查找 CLI。
|
|
239
|
+
|
|
240
|
+
## 基础用法
|
|
241
|
+
|
|
242
|
+
### 简单查询
|
|
243
|
+
|
|
244
|
+
最基础的用法是发送一个提示词并处理响应:
|
|
245
|
+
|
|
246
|
+
::: code-group
|
|
247
|
+
|
|
248
|
+
```typescript [TypeScript]
|
|
249
|
+
import { query } from '@tencent-ai/agent-sdk';
|
|
250
|
+
|
|
251
|
+
async function main() {
|
|
252
|
+
const q = query({
|
|
253
|
+
prompt: '请解释什么是递归函数',
|
|
254
|
+
options: {
|
|
255
|
+
permissionMode: 'bypassPermissions'
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
for await (const message of q) {
|
|
260
|
+
if (message.type === 'assistant') {
|
|
261
|
+
for (const block of message.message.content) {
|
|
262
|
+
if (block.type === 'text') {
|
|
263
|
+
console.log(block.text);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
main();
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
```python [Python]
|
|
274
|
+
import asyncio
|
|
275
|
+
from codebuddy_agent_sdk import query, CodeBuddyAgentOptions
|
|
276
|
+
from codebuddy_agent_sdk import AssistantMessage, TextBlock
|
|
277
|
+
|
|
278
|
+
async def main():
|
|
279
|
+
options = CodeBuddyAgentOptions(
|
|
280
|
+
permission_mode="bypassPermissions"
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
async for message in query(prompt="请解释什么是递归函数", options=options):
|
|
284
|
+
if isinstance(message, AssistantMessage):
|
|
285
|
+
for block in message.content:
|
|
286
|
+
if isinstance(block, TextBlock):
|
|
287
|
+
print(block.text)
|
|
288
|
+
|
|
289
|
+
asyncio.run(main())
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
:::
|
|
293
|
+
|
|
294
|
+
### 提取结果
|
|
295
|
+
|
|
296
|
+
查询完成后,会收到一个 `result` 消息,包含执行统计信息:
|
|
297
|
+
|
|
298
|
+
::: code-group
|
|
299
|
+
|
|
300
|
+
```typescript [TypeScript]
|
|
301
|
+
for await (const message of q) {
|
|
302
|
+
if (message.type === 'result') {
|
|
303
|
+
if (message.subtype === 'success') {
|
|
304
|
+
console.log('完成!耗时:', message.duration_ms, 'ms');
|
|
305
|
+
console.log('费用:', message.total_cost_usd, 'USD');
|
|
306
|
+
} else {
|
|
307
|
+
console.log('执行出错');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```python [Python]
|
|
314
|
+
from codebuddy_agent_sdk import ResultMessage
|
|
315
|
+
|
|
316
|
+
async for message in query(prompt="...", options=options):
|
|
317
|
+
if isinstance(message, ResultMessage):
|
|
318
|
+
if message.subtype == "success":
|
|
319
|
+
print(f"完成!耗时: {message.duration_ms} ms")
|
|
320
|
+
print(f"费用: {message.total_cost_usd} USD")
|
|
321
|
+
else:
|
|
322
|
+
print("执行出错")
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
:::
|
|
326
|
+
|
|
327
|
+
### 消息类型处理
|
|
328
|
+
|
|
329
|
+
SDK 返回多种类型的消息:
|
|
330
|
+
|
|
331
|
+
::: code-group
|
|
332
|
+
|
|
333
|
+
```typescript [TypeScript]
|
|
334
|
+
for await (const message of q) {
|
|
335
|
+
switch (message.type) {
|
|
336
|
+
case 'system':
|
|
337
|
+
// 会话初始化消息
|
|
338
|
+
console.log('会话 ID:', message.session_id);
|
|
339
|
+
console.log('可用工具:', message.tools);
|
|
340
|
+
break;
|
|
341
|
+
|
|
342
|
+
case 'assistant':
|
|
343
|
+
// AI 助手响应
|
|
344
|
+
for (const block of message.message.content) {
|
|
345
|
+
if (block.type === 'text') {
|
|
346
|
+
console.log('[文本]', block.text);
|
|
347
|
+
} else if (block.type === 'tool_use') {
|
|
348
|
+
console.log('[工具调用]', block.name, block.input);
|
|
349
|
+
} else if (block.type === 'tool_result') {
|
|
350
|
+
console.log('[工具结果]', block.content);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
|
|
355
|
+
case 'result':
|
|
356
|
+
// 查询完成
|
|
357
|
+
console.log('执行完成,耗时:', message.duration_ms, 'ms');
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
```python [Python]
|
|
364
|
+
from codebuddy_agent_sdk import (
|
|
365
|
+
SystemMessage, AssistantMessage, ResultMessage,
|
|
366
|
+
TextBlock, ToolUseBlock, ToolResultBlock
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
async for message in query(prompt="...", options=options):
|
|
370
|
+
if isinstance(message, SystemMessage):
|
|
371
|
+
# 会话初始化消息
|
|
372
|
+
print(f"会话 ID: {message.data.get('session_id')}")
|
|
373
|
+
print(f"可用工具: {message.data.get('tools')}")
|
|
374
|
+
|
|
375
|
+
elif isinstance(message, AssistantMessage):
|
|
376
|
+
# AI 助手响应
|
|
377
|
+
for block in message.content:
|
|
378
|
+
if isinstance(block, TextBlock):
|
|
379
|
+
print(f"[文本] {block.text}")
|
|
380
|
+
elif isinstance(block, ToolUseBlock):
|
|
381
|
+
print(f"[工具调用] {block.name}: {block.input}")
|
|
382
|
+
elif isinstance(block, ToolResultBlock):
|
|
383
|
+
print(f"[工具结果] {block.content}")
|
|
384
|
+
|
|
385
|
+
elif isinstance(message, ResultMessage):
|
|
386
|
+
# 查询完成
|
|
387
|
+
print(f"执行完成,耗时: {message.duration_ms} ms")
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
:::
|
|
391
|
+
|
|
392
|
+
## 配置选项
|
|
393
|
+
|
|
394
|
+
### 权限模式
|
|
395
|
+
|
|
396
|
+
通过 `permissionMode` 控制工具调用的权限行为:
|
|
397
|
+
|
|
398
|
+
| 模式 | 说明 |
|
|
399
|
+
|------|------|
|
|
400
|
+
| `default` | 默认模式,所有操作需确认 |
|
|
401
|
+
| `acceptEdits` | 自动批准文件编辑,Bash 仍需确认 |
|
|
402
|
+
| `plan` | 规划模式,仅允许读取操作 |
|
|
403
|
+
| `bypassPermissions` | 跳过所有权限检查(谨慎使用) |
|
|
404
|
+
|
|
405
|
+
::: code-group
|
|
406
|
+
|
|
407
|
+
```typescript [TypeScript]
|
|
408
|
+
const q = query({
|
|
409
|
+
prompt: '分析项目结构',
|
|
410
|
+
options: {
|
|
411
|
+
permissionMode: 'plan' // 只读模式
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
```python [Python]
|
|
417
|
+
options = CodeBuddyAgentOptions(
|
|
418
|
+
permission_mode="plan" # 只读模式
|
|
419
|
+
)
|
|
420
|
+
async for msg in query(prompt="分析项目结构", options=options):
|
|
421
|
+
pass
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
:::
|
|
425
|
+
|
|
426
|
+
### 工作目录
|
|
427
|
+
|
|
428
|
+
指定 Agent 的工作目录:
|
|
429
|
+
|
|
430
|
+
::: code-group
|
|
431
|
+
|
|
432
|
+
```typescript [TypeScript]
|
|
433
|
+
const q = query({
|
|
434
|
+
prompt: '读取 package.json',
|
|
435
|
+
options: {
|
|
436
|
+
cwd: '/path/to/project'
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
```python [Python]
|
|
442
|
+
options = CodeBuddyAgentOptions(
|
|
443
|
+
cwd="/path/to/project"
|
|
444
|
+
)
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
:::
|
|
448
|
+
|
|
449
|
+
### 模型选择
|
|
450
|
+
|
|
451
|
+
指定使用的 AI 模型:
|
|
452
|
+
|
|
453
|
+
::: code-group
|
|
454
|
+
|
|
455
|
+
```typescript [TypeScript]
|
|
456
|
+
const q = query({
|
|
457
|
+
prompt: '...',
|
|
458
|
+
options: {
|
|
459
|
+
model: 'deepseek-v3.1',
|
|
460
|
+
fallbackModel: 'deepseek-v3.1'
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
```python [Python]
|
|
466
|
+
options = CodeBuddyAgentOptions(
|
|
467
|
+
model="deepseek-v3.1",
|
|
468
|
+
fallback_model="deepseek-v3.1"
|
|
469
|
+
)
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
:::
|
|
473
|
+
|
|
474
|
+
### 资源限制
|
|
475
|
+
|
|
476
|
+
限制执行范围:
|
|
477
|
+
|
|
478
|
+
::: code-group
|
|
479
|
+
|
|
480
|
+
```typescript [TypeScript]
|
|
481
|
+
const q = query({
|
|
482
|
+
prompt: '...',
|
|
483
|
+
options: {
|
|
484
|
+
maxTurns:20 // 最大对话轮数
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
```python [Python]
|
|
490
|
+
options = CodeBuddyAgentOptions(
|
|
491
|
+
max_turns=20, # 最大对话轮数
|
|
492
|
+
)
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
:::
|
|
496
|
+
|
|
497
|
+
## 环境隔离(settingSources)
|
|
498
|
+
|
|
499
|
+
### 设计理念
|
|
500
|
+
|
|
501
|
+
SDK 默认**不加载任何文件系统配置**,提供完全干净的运行环境。这是与 CLI 直接使用的关键区别。
|
|
502
|
+
|
|
503
|
+
### 为什么这样设计?
|
|
504
|
+
|
|
505
|
+
1. **可预测性**:SDK 应用的行为完全由代码控制,不受用户或项目配置文件影响
|
|
506
|
+
2. **隔离性**:避免用户的个人偏好或项目设置干扰 SDK 应用的逻辑
|
|
507
|
+
3. **安全性**:敏感配置(如 hooks、权限规则)不会意外泄露到 SDK 环境
|
|
508
|
+
4. **一致性**:在不同机器上运行时,行为保持一致
|
|
509
|
+
|
|
510
|
+
### 默认行为对比
|
|
511
|
+
|
|
512
|
+
| 场景 | Settings | Memory | MCP | Subagent | Commands | Rules | Skills |
|
|
513
|
+
|------|----------|--------|-----|----------|----------|-------|--------|
|
|
514
|
+
| SDK 调用(默认) | ✗ 不加载 | ✗ 不加载 | ✗ 不加载 | ✗ 不加载 | ✗ 不加载 | ✗ 不加载 | ✗ 不加载 |
|
|
515
|
+
| CLI 直接运行 | ✓ 加载全部 | ✓ 加载全部 | ✓ 加载全部 | ✓ 加载全部 | ✓ 加载全部 | ✓ 加载全部 | ✓ 加载全部 |
|
|
516
|
+
|
|
517
|
+
**配置文件位置参考**:
|
|
518
|
+
|
|
519
|
+
| 配置类型 | 用户级位置 | 项目级位置 | 说明 |
|
|
520
|
+
|----------|-----------|-----------|------|
|
|
521
|
+
| Settings | `~/.codebuddy/settings.json` | `.codebuddy/settings.json` | 权限、hooks、环境变量等 |
|
|
522
|
+
| Memory | `~/.codebuddy/CODEBUDDY.md` | `CODEBUDDY.md` | 项目指令和上下文 |
|
|
523
|
+
| MCP | `~/.codebuddy/.mcp.json` | `.mcp.json` | MCP 服务器配置 |
|
|
524
|
+
| Subagent | `~/.codebuddy/agents/` | `.codebuddy/agents/` | 自定义子代理 |
|
|
525
|
+
| Commands | `~/.codebuddy/commands/` | `.codebuddy/commands/` | 自定义斜杠命令 |
|
|
526
|
+
| Rules | `~/.codebuddy/rules/` | `.codebuddy/rules/` | 模块化规则文件 |
|
|
527
|
+
| Skills | `~/.codebuddy/skills/` | `.codebuddy/skills/` | AI 自动调用的技能 |
|
|
528
|
+
|
|
529
|
+
### 显式加载配置
|
|
530
|
+
|
|
531
|
+
如需加载文件系统配置,使用 `settingSources` 显式指定:
|
|
532
|
+
|
|
533
|
+
::: code-group
|
|
534
|
+
|
|
535
|
+
```typescript [TypeScript]
|
|
536
|
+
const q = query({
|
|
537
|
+
prompt: '...',
|
|
538
|
+
options: {
|
|
539
|
+
// 加载项目配置(.codebuddy/settings.json, CODEBUDDY.md)
|
|
540
|
+
settingSources: ['project'],
|
|
541
|
+
|
|
542
|
+
// 或加载全部配置
|
|
543
|
+
// settingSources: ['user', 'project', 'local']
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
```python [Python]
|
|
549
|
+
options = CodeBuddyAgentOptions(
|
|
550
|
+
# 加载项目配置
|
|
551
|
+
setting_sources=["project"],
|
|
552
|
+
|
|
553
|
+
# 或加载全部配置
|
|
554
|
+
# setting_sources=["user", "project", "local"]
|
|
555
|
+
)
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
:::
|
|
559
|
+
|
|
560
|
+
### 配置源说明
|
|
561
|
+
|
|
562
|
+
| 值 | 说明 | 位置 |
|
|
563
|
+
|-----|------|------|
|
|
564
|
+
| `'user'` | 全局用户设置 | `~/.codebuddy/settings.json`, `~/.codebuddy/CODEBUDDY.md` |
|
|
565
|
+
| `'project'` | 项目共享设置 | `.codebuddy/settings.json`, `CODEBUDDY.md` |
|
|
566
|
+
| `'local'` | 项目本地设置 | `.codebuddy/settings.local.json`, `CODEBUDDY.local.md` |
|
|
567
|
+
|
|
568
|
+
### 典型用例
|
|
569
|
+
|
|
570
|
+
**CI/CD 环境**:
|
|
571
|
+
|
|
572
|
+
::: code-group
|
|
573
|
+
|
|
574
|
+
```typescript [TypeScript]
|
|
575
|
+
// 只加载项目配置,忽略用户和本地配置
|
|
576
|
+
const q = query({
|
|
577
|
+
prompt: '运行测试',
|
|
578
|
+
options: {
|
|
579
|
+
settingSources: ['project'],
|
|
580
|
+
permissionMode: 'bypassPermissions'
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
```python [Python]
|
|
586
|
+
# 只加载项目配置,忽略用户和本地配置
|
|
587
|
+
options = CodeBuddyAgentOptions(
|
|
588
|
+
setting_sources=["project"],
|
|
589
|
+
permission_mode="bypassPermissions"
|
|
590
|
+
)
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
:::
|
|
594
|
+
|
|
595
|
+
**完全程序化控制**:
|
|
596
|
+
|
|
597
|
+
::: code-group
|
|
598
|
+
|
|
599
|
+
```typescript [TypeScript]
|
|
600
|
+
// 默认行为:不加载任何配置
|
|
601
|
+
// 所有行为通过 options 显式定义
|
|
602
|
+
const q = query({
|
|
603
|
+
prompt: '...',
|
|
604
|
+
options: {
|
|
605
|
+
agents: { /* 自定义 agent */ },
|
|
606
|
+
mcpServers: { /* 自定义 MCP */ },
|
|
607
|
+
allowedTools: ['Read', 'Grep', 'Glob']
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
```python [Python]
|
|
613
|
+
# 默认行为:不加载任何配置
|
|
614
|
+
# 所有行为通过 options 显式定义
|
|
615
|
+
options = CodeBuddyAgentOptions(
|
|
616
|
+
agents={"reviewer": AgentDefinition(...)},
|
|
617
|
+
mcp_servers={"db": {...}},
|
|
618
|
+
allowed_tools=["Read", "Grep", "Glob"]
|
|
619
|
+
)
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
:::
|
|
623
|
+
|
|
624
|
+
## 权限控制
|
|
625
|
+
|
|
626
|
+
### canUseTool 回调
|
|
627
|
+
|
|
628
|
+
通过 `canUseTool` 回调实现细粒度权限控制:
|
|
629
|
+
|
|
630
|
+
::: code-group
|
|
631
|
+
|
|
632
|
+
```typescript [TypeScript]
|
|
633
|
+
import { query } from '@tencent-ai/agent-sdk';
|
|
634
|
+
|
|
635
|
+
const q = query({
|
|
636
|
+
prompt: '分析项目结构',
|
|
637
|
+
options: {
|
|
638
|
+
canUseTool: async (toolName, input, options) => {
|
|
639
|
+
// 只允许读取类工具
|
|
640
|
+
const readOnlyTools = ['Read', 'Glob', 'Grep'];
|
|
641
|
+
|
|
642
|
+
if (readOnlyTools.includes(toolName)) {
|
|
643
|
+
return {
|
|
644
|
+
behavior: 'allow',
|
|
645
|
+
updatedInput: input
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// 拒绝其他工具
|
|
650
|
+
return {
|
|
651
|
+
behavior: 'deny',
|
|
652
|
+
message: `工具 ${toolName} 不允许使用`
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
```python [Python]
|
|
660
|
+
from codebuddy_agent_sdk import (
|
|
661
|
+
query, CodeBuddyAgentOptions,
|
|
662
|
+
CanUseToolOptions, PermissionResultAllow, PermissionResultDeny
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
async def can_use_tool(
|
|
666
|
+
tool_name: str,
|
|
667
|
+
input_data: dict,
|
|
668
|
+
options: CanUseToolOptions
|
|
669
|
+
):
|
|
670
|
+
# 只允许读取类工具
|
|
671
|
+
read_only_tools = ["Read", "Glob", "Grep"]
|
|
672
|
+
|
|
673
|
+
if tool_name in read_only_tools:
|
|
674
|
+
return PermissionResultAllow(updated_input=input_data)
|
|
675
|
+
|
|
676
|
+
# 拒绝其他工具
|
|
677
|
+
return PermissionResultDeny(
|
|
678
|
+
message=f"工具 {tool_name} 不允许使用"
|
|
679
|
+
)
|
|
680
|
+
|
|
681
|
+
options = CodeBuddyAgentOptions(can_use_tool=can_use_tool)
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
:::
|
|
685
|
+
|
|
686
|
+
### 拦截危险操作
|
|
687
|
+
|
|
688
|
+
结合权限回调拦截危险命令:
|
|
689
|
+
|
|
690
|
+
::: code-group
|
|
691
|
+
|
|
692
|
+
```typescript [TypeScript]
|
|
693
|
+
const dangerousCommands = ['rm -rf', 'sudo', 'chmod 777'];
|
|
694
|
+
|
|
695
|
+
const q = query({
|
|
696
|
+
prompt: '清理临时文件',
|
|
697
|
+
options: {
|
|
698
|
+
canUseTool: async (toolName, input) => {
|
|
699
|
+
if (toolName === 'Bash') {
|
|
700
|
+
const command = input.command as string;
|
|
701
|
+
for (const dangerous of dangerousCommands) {
|
|
702
|
+
if (command.includes(dangerous)) {
|
|
703
|
+
return {
|
|
704
|
+
behavior: 'deny',
|
|
705
|
+
message: `危险命令被拦截: ${dangerous}`,
|
|
706
|
+
interrupt: true // 中断整个会话
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return { behavior: 'allow', updatedInput: input };
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
```python [Python]
|
|
718
|
+
dangerous_commands = ["rm -rf", "sudo", "chmod 777"]
|
|
719
|
+
|
|
720
|
+
async def can_use_tool(tool_name, input_data, options):
|
|
721
|
+
if tool_name == "Bash":
|
|
722
|
+
command = input_data.get("command", "")
|
|
723
|
+
for dangerous in dangerous_commands:
|
|
724
|
+
if dangerous in command:
|
|
725
|
+
return PermissionResultDeny(
|
|
726
|
+
message=f"危险命令被拦截: {dangerous}",
|
|
727
|
+
interrupt=True # 中断整个会话
|
|
728
|
+
)
|
|
729
|
+
return PermissionResultAllow(updated_input=input_data)
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
:::
|
|
733
|
+
|
|
734
|
+
## 多轮对话
|
|
735
|
+
|
|
736
|
+
### 使用 Session/Client API
|
|
737
|
+
|
|
738
|
+
对于需要多轮交互的场景,使用 Session(TypeScript)或 Client(Python)API:
|
|
739
|
+
|
|
740
|
+
::: code-group
|
|
741
|
+
|
|
742
|
+
```typescript [TypeScript]
|
|
743
|
+
import { unstable_v2_createSession } from '@tencent-ai/agent-sdk';
|
|
744
|
+
|
|
745
|
+
async function main() {
|
|
746
|
+
const session = unstable_v2_createSession({
|
|
747
|
+
model: 'deepseek-v3.1'
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// 第一轮对话
|
|
751
|
+
await session.send('分析这个项目的架构');
|
|
752
|
+
for await (const message of session.stream()) {
|
|
753
|
+
console.log(message);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// 第二轮对话(保持上下文)
|
|
757
|
+
await session.send('请详细解释第三点');
|
|
758
|
+
for await (const message of session.stream()) {
|
|
759
|
+
console.log(message);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
session.close();
|
|
763
|
+
}
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
```python [Python]
|
|
767
|
+
from codebuddy_agent_sdk import CodeBuddySDKClient, CodeBuddyAgentOptions
|
|
768
|
+
|
|
769
|
+
async def main():
|
|
770
|
+
options = CodeBuddyAgentOptions(model="deepseek-v3.1")
|
|
771
|
+
|
|
772
|
+
async with CodeBuddySDKClient(options=options) as client:
|
|
773
|
+
# 第一轮对话
|
|
774
|
+
await client.query("分析这个项目的架构")
|
|
775
|
+
async for message in client.receive_response():
|
|
776
|
+
print(message)
|
|
777
|
+
|
|
778
|
+
# 第二轮对话(保持上下文)
|
|
779
|
+
await client.query("请详细解释第三点")
|
|
780
|
+
async for message in client.receive_response():
|
|
781
|
+
print(message)
|
|
782
|
+
|
|
783
|
+
asyncio.run(main())
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
:::
|
|
787
|
+
|
|
788
|
+
### 中断执行
|
|
789
|
+
|
|
790
|
+
在运行过程中中断执行:
|
|
791
|
+
|
|
792
|
+
::: code-group
|
|
793
|
+
|
|
794
|
+
```typescript [TypeScript]
|
|
795
|
+
const q = query({ prompt: '执行长时间任务...' });
|
|
796
|
+
|
|
797
|
+
let count = 0;
|
|
798
|
+
for await (const message of q) {
|
|
799
|
+
if (message.type === 'assistant') {
|
|
800
|
+
for (const block of message.message.content) {
|
|
801
|
+
if (block.type === 'tool_use') {
|
|
802
|
+
count++;
|
|
803
|
+
if (count >= 10) {
|
|
804
|
+
await q.interrupt(); // 中断执行
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
```python [Python]
|
|
814
|
+
async with CodeBuddySDKClient(options=options) as client:
|
|
815
|
+
await client.query("执行长时间任务...")
|
|
816
|
+
|
|
817
|
+
count = 0
|
|
818
|
+
async for message in client.receive_messages():
|
|
819
|
+
if isinstance(message, AssistantMessage):
|
|
820
|
+
for block in message.content:
|
|
821
|
+
if isinstance(block, ToolUseBlock):
|
|
822
|
+
count += 1
|
|
823
|
+
if count >= 10:
|
|
824
|
+
await client.interrupt() # 中断执行
|
|
825
|
+
break
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
:::
|
|
829
|
+
|
|
830
|
+
## Hook 系统
|
|
831
|
+
|
|
832
|
+
Hook 允许在工具执行前后插入自定义逻辑。
|
|
833
|
+
|
|
834
|
+
### PreToolUse Hook
|
|
835
|
+
|
|
836
|
+
在工具执行前拦截和处理:
|
|
837
|
+
|
|
838
|
+
::: code-group
|
|
839
|
+
|
|
840
|
+
```typescript [TypeScript]
|
|
841
|
+
const q = query({
|
|
842
|
+
prompt: '清理临时文件',
|
|
843
|
+
options: {
|
|
844
|
+
hooks: {
|
|
845
|
+
PreToolUse: [{
|
|
846
|
+
matcher: 'Bash', // 只匹配 Bash 工具
|
|
847
|
+
hooks: [
|
|
848
|
+
async (input, toolUseId) => {
|
|
849
|
+
console.log('即将执行命令:', input.command);
|
|
850
|
+
|
|
851
|
+
// 可以阻止执行
|
|
852
|
+
if (input.command.includes('rm')) {
|
|
853
|
+
return {
|
|
854
|
+
decision: 'block',
|
|
855
|
+
reason: '删除命令被阻止'
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
return { continue: true };
|
|
860
|
+
}
|
|
861
|
+
]
|
|
862
|
+
}]
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
```python [Python]
|
|
869
|
+
from codebuddy_agent_sdk import HookMatcher, HookContext
|
|
870
|
+
|
|
871
|
+
async def pre_tool_hook(input_data, tool_use_id, context: HookContext):
|
|
872
|
+
print(f"即将执行命令: {input_data.get('command')}")
|
|
873
|
+
|
|
874
|
+
# 可以阻止执行
|
|
875
|
+
if "rm" in input_data.get("command", ""):
|
|
876
|
+
return {"continue_": False, "reason": "删除命令被阻止"}
|
|
877
|
+
|
|
878
|
+
return {"continue_": True}
|
|
879
|
+
|
|
880
|
+
options = CodeBuddyAgentOptions(
|
|
881
|
+
hooks={
|
|
882
|
+
"PreToolUse": [
|
|
883
|
+
HookMatcher(matcher="Bash", hooks=[pre_tool_hook])
|
|
884
|
+
]
|
|
885
|
+
}
|
|
886
|
+
)
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
:::
|
|
890
|
+
|
|
891
|
+
### Hook 事件类型
|
|
892
|
+
|
|
893
|
+
| 事件 | 触发时机 |
|
|
894
|
+
|------|---------|
|
|
895
|
+
| `PreToolUse` | 工具执行前 |
|
|
896
|
+
| `PostToolUse` | 工具执行成功后 |
|
|
897
|
+
| `PostToolUseFailure` | 工具执行失败后 |
|
|
898
|
+
| `UserPromptSubmit` | 用户提交提示词 |
|
|
899
|
+
| `SessionStart` | 会话开始 |
|
|
900
|
+
| `SessionEnd` | 会话结束 |
|
|
901
|
+
| `WorktreeCreate` | 创建隔离 `worktree` 时 |
|
|
902
|
+
| `WorktreeRemove` | 删除隔离 `worktree` 时 |
|
|
903
|
+
|
|
904
|
+
## 扩展能力
|
|
905
|
+
|
|
906
|
+
### 自定义 Agent
|
|
907
|
+
|
|
908
|
+
定义专门化的子 Agent:
|
|
909
|
+
|
|
910
|
+
::: code-group
|
|
911
|
+
|
|
912
|
+
```typescript [TypeScript]
|
|
913
|
+
const q = query({
|
|
914
|
+
prompt: '使用 code-reviewer 审查代码',
|
|
915
|
+
options: {
|
|
916
|
+
agents: {
|
|
917
|
+
'code-reviewer': {
|
|
918
|
+
description: '专业代码审查助手',
|
|
919
|
+
tools: ['Read', 'Glob', 'Grep'], // 只允许读取
|
|
920
|
+
disallowedTools: ['Bash', 'Write', 'Edit'],
|
|
921
|
+
prompt: `你是代码审查专家,请检查:
|
|
922
|
+
1. 代码规范
|
|
923
|
+
2. 潜在 bug
|
|
924
|
+
3. 性能问题
|
|
925
|
+
4. 安全漏洞`,
|
|
926
|
+
model: 'deepseek-v3.1'
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
```python [Python]
|
|
934
|
+
from codebuddy_agent_sdk import AgentDefinition
|
|
935
|
+
|
|
936
|
+
options = CodeBuddyAgentOptions(
|
|
937
|
+
agents={
|
|
938
|
+
"code-reviewer": AgentDefinition(
|
|
939
|
+
description="专业代码审查助手",
|
|
940
|
+
tools=["Read", "Glob", "Grep"], # 只允许读取
|
|
941
|
+
disallowed_tools=["Bash", "Write", "Edit"],
|
|
942
|
+
prompt="""你是代码审查专家,请检查:
|
|
943
|
+
1. 代码规范
|
|
944
|
+
2. 潜在 bug
|
|
945
|
+
3. 性能问题
|
|
946
|
+
4. 安全漏洞""",
|
|
947
|
+
model="deepseek-v3.1"
|
|
948
|
+
)
|
|
949
|
+
}
|
|
950
|
+
)
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
:::
|
|
954
|
+
|
|
955
|
+
### MCP 服务器配置
|
|
956
|
+
|
|
957
|
+
集成自定义 MCP 服务器:
|
|
958
|
+
|
|
959
|
+
::: code-group
|
|
960
|
+
|
|
961
|
+
```typescript [TypeScript]
|
|
962
|
+
const q = query({
|
|
963
|
+
prompt: '查询数据库',
|
|
964
|
+
options: {
|
|
965
|
+
mcpServers: {
|
|
966
|
+
'database': {
|
|
967
|
+
type: 'stdio',
|
|
968
|
+
command: 'node',
|
|
969
|
+
args: ['./mcp-servers/db-server.js'],
|
|
970
|
+
env: {
|
|
971
|
+
DB_HOST: 'localhost',
|
|
972
|
+
DB_PORT: '5432'
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
```python [Python]
|
|
981
|
+
options = CodeBuddyAgentOptions(
|
|
982
|
+
mcp_servers={
|
|
983
|
+
"database": {
|
|
984
|
+
"type": "stdio",
|
|
985
|
+
"command": "node",
|
|
986
|
+
"args": ["./mcp-servers/db-server.js"],
|
|
987
|
+
"env": {
|
|
988
|
+
"DB_HOST": "localhost",
|
|
989
|
+
"DB_PORT": "5432"
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
)
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
:::
|
|
997
|
+
|
|
998
|
+
### 处理 AskUserQuestion
|
|
999
|
+
|
|
1000
|
+
AI 可能会通过 `AskUserQuestion` 工具向用户提问,可以在权限回调中处理:
|
|
1001
|
+
|
|
1002
|
+
::: code-group
|
|
1003
|
+
|
|
1004
|
+
```typescript [TypeScript]
|
|
1005
|
+
const q = query({
|
|
1006
|
+
prompt: '配置数据库连接',
|
|
1007
|
+
options: {
|
|
1008
|
+
canUseTool: async (toolName, input) => {
|
|
1009
|
+
if (toolName === 'AskUserQuestion') {
|
|
1010
|
+
const questions = input.questions as any[];
|
|
1011
|
+
const answers: Record<string, string> = {};
|
|
1012
|
+
|
|
1013
|
+
for (const q of questions) {
|
|
1014
|
+
console.log(`问题: ${q.question}`);
|
|
1015
|
+
// 这里可以接入实际的用户交互
|
|
1016
|
+
answers[q.question] = q.options[0].label;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
return {
|
|
1020
|
+
behavior: 'allow',
|
|
1021
|
+
updatedInput: { ...input, answers }
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
return { behavior: 'allow', updatedInput: input };
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
```python [Python]
|
|
1031
|
+
async def can_use_tool(tool_name, input_data, options):
|
|
1032
|
+
if tool_name == "AskUserQuestion":
|
|
1033
|
+
questions = input_data.get("questions", [])
|
|
1034
|
+
answers = {}
|
|
1035
|
+
|
|
1036
|
+
for q in questions:
|
|
1037
|
+
print(f"问题: {q['question']}")
|
|
1038
|
+
# 这里可以接入实际的用户交互
|
|
1039
|
+
answers[q["question"]] = q["options"][0]["label"]
|
|
1040
|
+
|
|
1041
|
+
return PermissionResultAllow(
|
|
1042
|
+
updated_input={**input_data, "answers": answers}
|
|
1043
|
+
)
|
|
1044
|
+
|
|
1045
|
+
return PermissionResultAllow(updated_input=input_data)
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
:::
|
|
1049
|
+
|
|
1050
|
+
## 错误处理
|
|
1051
|
+
|
|
1052
|
+
::: code-group
|
|
1053
|
+
|
|
1054
|
+
```typescript [TypeScript]
|
|
1055
|
+
import { query, AbortError } from '@tencent-ai/agent-sdk';
|
|
1056
|
+
|
|
1057
|
+
try {
|
|
1058
|
+
const q = query({ prompt: '...' });
|
|
1059
|
+
for await (const message of q) {
|
|
1060
|
+
// ...
|
|
1061
|
+
}
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
if (error instanceof AbortError) {
|
|
1064
|
+
console.log('操作被中止');
|
|
1065
|
+
} else {
|
|
1066
|
+
console.error('发生错误:', error);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
```python [Python]
|
|
1072
|
+
from codebuddy_agent_sdk import (
|
|
1073
|
+
query, CodeBuddySDKError,
|
|
1074
|
+
CLIConnectionError, CLINotFoundError
|
|
1075
|
+
)
|
|
1076
|
+
|
|
1077
|
+
try:
|
|
1078
|
+
async for message in query(prompt="..."):
|
|
1079
|
+
pass
|
|
1080
|
+
except CLINotFoundError as e:
|
|
1081
|
+
print(f"CLI 未找到: {e}")
|
|
1082
|
+
except CLIConnectionError as e:
|
|
1083
|
+
print(f"连接失败: {e}")
|
|
1084
|
+
except CodeBuddySDKError as e:
|
|
1085
|
+
print(f"SDK 错误: {e}")
|
|
1086
|
+
```
|
|
1087
|
+
|
|
1088
|
+
:::
|
|
1089
|
+
|
|
1090
|
+
## 最佳实践
|
|
1091
|
+
|
|
1092
|
+
1. **权限控制**:在生产环境中使用 `canUseTool` 实现细粒度权限,避免使用 `bypassPermissions`
|
|
1093
|
+
2. **资源限制**:使用 `maxTurns` 限制执行范围,防止意外的资源消耗
|
|
1094
|
+
3. **错误处理**:始终处理 `result` 消息中的错误状态
|
|
1095
|
+
4. **Hook 超时**:为 Hook 设置合理的超时时间
|
|
1096
|
+
|
|
1097
|
+
## 相关文档
|
|
1098
|
+
|
|
1099
|
+
- [TypeScript SDK 参考](sdk-typescript.md) - TypeScript API 详细参考
|
|
1100
|
+
- [Python SDK 参考](sdk-python.md) - Python API 详细参考
|
|
1101
|
+
- [Hook 参考指南](hooks.md) - 详细的 Hook 配置说明
|
|
1102
|
+
- [MCP 集成](mcp.md) - MCP 服务器配置指南
|
|
1103
|
+
- [子 Agent 系统](sub-agents.md) - 子 Agent 详细说明
|
|
1104
|
+
|
|
1105
|
+
*CodeBuddy Agent SDK - 让 AI 编程能力融入你的应用*
|