@tencent-ai/agent-sdk 0.3.99 → 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.
Files changed (458) hide show
  1. package/cli/CHANGELOG.md +26 -0
  2. package/cli/dist/codebuddy-headless.js +53 -53
  3. package/cli/dist/web-ui/assets/index-BoMlEqUE.js +439 -0
  4. package/cli/dist/web-ui/assets/index-Dt1puyHn.css +32 -0
  5. package/cli/dist/web-ui/docs/cn/cli/acp.md +152 -0
  6. package/cli/dist/web-ui/docs/cn/cli/agent-teams.md +327 -0
  7. package/cli/dist/web-ui/docs/cn/cli/bash-sandboxing.md +290 -0
  8. package/cli/dist/web-ui/docs/cn/cli/best-practices.md +554 -0
  9. package/cli/dist/web-ui/docs/cn/cli/channels-reference.md +293 -0
  10. package/cli/dist/web-ui/docs/cn/cli/channels.md +215 -0
  11. package/cli/dist/web-ui/docs/cn/cli/checkpointing.md +51 -0
  12. package/cli/dist/web-ui/docs/cn/cli/cli-reference.md +187 -0
  13. package/cli/dist/web-ui/docs/cn/cli/common-workflows.md +1013 -0
  14. package/cli/dist/web-ui/docs/cn/cli/costs.md +174 -0
  15. package/cli/dist/web-ui/docs/cn/cli/devcontainer.md +553 -0
  16. package/cli/dist/web-ui/docs/cn/cli/env-vars.md +326 -0
  17. package/cli/dist/web-ui/docs/cn/cli/gitlab-ci-cd.md +357 -0
  18. package/cli/dist/web-ui/docs/cn/cli/headless.md +258 -0
  19. package/cli/dist/web-ui/docs/cn/cli/hooks-guide.md +9 -0
  20. package/cli/dist/web-ui/docs/cn/cli/hooks.md +805 -0
  21. package/cli/dist/web-ui/docs/cn/cli/iam.md +530 -0
  22. package/cli/dist/web-ui/docs/cn/cli/ide-integrations.md +92 -0
  23. package/cli/dist/web-ui/docs/cn/cli/installation.md +291 -0
  24. package/cli/dist/web-ui/docs/cn/cli/interactive-mode.md +233 -0
  25. package/cli/dist/web-ui/docs/cn/cli/mcp.md +739 -0
  26. package/cli/dist/web-ui/docs/cn/cli/memory.md +436 -0
  27. package/cli/dist/web-ui/docs/cn/cli/models.md +356 -0
  28. package/cli/dist/web-ui/docs/cn/cli/overview.md +100 -0
  29. package/cli/dist/web-ui/docs/cn/cli/plugin-marketplaces.md +533 -0
  30. package/cli/dist/web-ui/docs/cn/cli/plugins-reference.md +774 -0
  31. package/cli/dist/web-ui/docs/cn/cli/plugins.md +689 -0
  32. package/cli/dist/web-ui/docs/cn/cli/quickstart.md +249 -0
  33. package/cli/dist/web-ui/docs/cn/cli/release-notes/README.md +199 -0
  34. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.0.md +23 -0
  35. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.1.md +5 -0
  36. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.11.0.md +24 -0
  37. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.12.0.md +21 -0
  38. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.13.0.md +20 -0
  39. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.0.md +22 -0
  40. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.1.md +8 -0
  41. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.0.md +18 -0
  42. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.1.md +11 -0
  43. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.16.0.md +20 -0
  44. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.17.0.md +29 -0
  45. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.18.0.md +17 -0
  46. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.0.md +11 -0
  47. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.1.md +14 -0
  48. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.2.md +11 -0
  49. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.0.md +23 -0
  50. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.1.md +15 -0
  51. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.21.0.md +13 -0
  52. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.22.0.md +16 -0
  53. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.0.md +20 -0
  54. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.2.md +5 -0
  55. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.3.md +5 -0
  56. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.4.md +15 -0
  57. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.5.md +11 -0
  58. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.24.0.md +17 -0
  59. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.0.md +18 -0
  60. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.1.md +21 -0
  61. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.26.0.md +18 -0
  62. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.0.md +16 -0
  63. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.1.md +16 -0
  64. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.2.md +7 -0
  65. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.3.md +15 -0
  66. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.0.md +26 -0
  67. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.1.md +5 -0
  68. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.29.0.md +35 -0
  69. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.3.1.md +16 -0
  70. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.0.md +19 -0
  71. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.1.md +5 -0
  72. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.0.md +51 -0
  73. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.1.md +11 -0
  74. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.2.md +16 -0
  75. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.32.0.md +19 -0
  76. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.0.md +28 -0
  77. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.1.md +7 -0
  78. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.36.3.md +17 -0
  79. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.0.md +15 -0
  80. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.1.md +15 -0
  81. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.10.md +5 -0
  82. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.11.md +8 -0
  83. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.12.md +14 -0
  84. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.13.md +11 -0
  85. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.14.md +24 -0
  86. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.15.md +11 -0
  87. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.16.md +9 -0
  88. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.17.md +5 -0
  89. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.18.md +9 -0
  90. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.19.md +5 -0
  91. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.2.md +28 -0
  92. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.20.md +8 -0
  93. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.3.md +22 -0
  94. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.4.md +19 -0
  95. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.5.md +5 -0
  96. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.6.md +5 -0
  97. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.7.md +5 -0
  98. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.8.md +5 -0
  99. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.9.md +8 -0
  100. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.0.md +22 -0
  101. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.1.md +6 -0
  102. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.2.md +9 -0
  103. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.39.0.md +18 -0
  104. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.4.0.md +19 -0
  105. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.0.md +20 -0
  106. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.1.md +6 -0
  107. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.0.md +15 -0
  108. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.1.md +6 -0
  109. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.2.md +5 -0
  110. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.3.md +8 -0
  111. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.4.md +5 -0
  112. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.5.md +10 -0
  113. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.6.md +9 -0
  114. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.7.md +14 -0
  115. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.8.md +18 -0
  116. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.0.md +39 -0
  117. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.1.md +8 -0
  118. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.3.md +18 -0
  119. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.0.md +27 -0
  120. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.1.md +27 -0
  121. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.0.md +11 -0
  122. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.1.md +22 -0
  123. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.0.md +34 -0
  124. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.1.md +7 -0
  125. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.46.0.md +12 -0
  126. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.47.0.md +20 -0
  127. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.0.md +32 -0
  128. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.1.md +11 -0
  129. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.0.md +26 -0
  130. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.1.md +14 -0
  131. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.2.md +39 -0
  132. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.3.md +7 -0
  133. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.5.md +11 -0
  134. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.6.md +9 -0
  135. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.7.md +7 -0
  136. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.5.0.md +24 -0
  137. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.0.md +25 -0
  138. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.1.md +9 -0
  139. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.2.md +11 -0
  140. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.3.md +5 -0
  141. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.4.md +17 -0
  142. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.5.md +16 -0
  143. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.6.md +15 -0
  144. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.7.md +15 -0
  145. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.0.md +24 -0
  146. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.1.md +17 -0
  147. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.2.md +5 -0
  148. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.0.md +30 -0
  149. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.1.md +28 -0
  150. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.2.md +12 -0
  151. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.3.md +13 -0
  152. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.4.md +27 -0
  153. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.5.md +21 -0
  154. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.6.md +7 -0
  155. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.53.0.md +29 -0
  156. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.54.0.md +26 -0
  157. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.0.md +21 -0
  158. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.1.md +13 -0
  159. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.0.md +20 -0
  160. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.1.md +5 -0
  161. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.0.md +32 -0
  162. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.1.md +10 -0
  163. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.58.0.md +34 -0
  164. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.59.0.md +28 -0
  165. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.0.md +5 -0
  166. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.1.md +10 -0
  167. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.60.0.md +20 -0
  168. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.0.md +29 -0
  169. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.1.md +5 -0
  170. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.2.md +6 -0
  171. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.3.md +13 -0
  172. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.0.md +21 -0
  173. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.1.md +11 -0
  174. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.0.md +19 -0
  175. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.1.md +5 -0
  176. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.2.md +7 -0
  177. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.3.md +6 -0
  178. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.4.md +8 -0
  179. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.5.md +6 -0
  180. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.0.md +37 -0
  181. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.1.md +6 -0
  182. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.2.md +11 -0
  183. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.0.md +19 -0
  184. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.1.md +11 -0
  185. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.0.md +15 -0
  186. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.1.md +14 -0
  187. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.2.md +5 -0
  188. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.67.0.md +33 -0
  189. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.7.0.md +16 -0
  190. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.0.md +18 -0
  191. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.1.md +17 -0
  192. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.2.md +5 -0
  193. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.3.md +14 -0
  194. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.4.md +9 -0
  195. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.5.md +5 -0
  196. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.6.md +14 -0
  197. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.9.0.md +5 -0
  198. package/cli/dist/web-ui/docs/cn/cli/remote-control.md +247 -0
  199. package/cli/dist/web-ui/docs/cn/cli/sandboxing.md +316 -0
  200. package/cli/dist/web-ui/docs/cn/cli/scheduled-tasks.md +161 -0
  201. package/cli/dist/web-ui/docs/cn/cli/sdk-custom-tools.md +1195 -0
  202. package/cli/dist/web-ui/docs/cn/cli/sdk-demos.md +347 -0
  203. package/cli/dist/web-ui/docs/cn/cli/sdk-hooks.md +803 -0
  204. package/cli/dist/web-ui/docs/cn/cli/sdk-mcp.md +643 -0
  205. package/cli/dist/web-ui/docs/cn/cli/sdk-permissions.md +501 -0
  206. package/cli/dist/web-ui/docs/cn/cli/sdk-python.md +783 -0
  207. package/cli/dist/web-ui/docs/cn/cli/sdk-sessions.md +332 -0
  208. package/cli/dist/web-ui/docs/cn/cli/sdk-typescript.md +759 -0
  209. package/cli/dist/web-ui/docs/cn/cli/sdk.md +1105 -0
  210. package/cli/dist/web-ui/docs/cn/cli/security.md +387 -0
  211. package/cli/dist/web-ui/docs/cn/cli/settings.md +602 -0
  212. package/cli/dist/web-ui/docs/cn/cli/skills.md +448 -0
  213. package/cli/dist/web-ui/docs/cn/cli/slash-commands.md +397 -0
  214. package/cli/dist/web-ui/docs/cn/cli/statusline.md +525 -0
  215. package/cli/dist/web-ui/docs/cn/cli/sub-agents.md +634 -0
  216. package/cli/dist/web-ui/docs/cn/cli/terminal-config.md +77 -0
  217. package/cli/dist/web-ui/docs/cn/cli/tools-reference.md +99 -0
  218. package/cli/dist/web-ui/docs/cn/cli/troubleshooting.md +190 -0
  219. package/cli/dist/web-ui/docs/cn/cli/web-ui.md +164 -0
  220. package/cli/dist/web-ui/docs/cn/cli/wecom-bot-setup.md +274 -0
  221. package/cli/dist/web-ui/docs/cn/cli/worktree.md +660 -0
  222. package/cli/dist/web-ui/docs/en/cli/acp.md +126 -0
  223. package/cli/dist/web-ui/docs/en/cli/agent-teams.md +327 -0
  224. package/cli/dist/web-ui/docs/en/cli/bash-sandboxing.md +357 -0
  225. package/cli/dist/web-ui/docs/en/cli/best-practices.md +554 -0
  226. package/cli/dist/web-ui/docs/en/cli/channels-reference.md +293 -0
  227. package/cli/dist/web-ui/docs/en/cli/channels.md +215 -0
  228. package/cli/dist/web-ui/docs/en/cli/checkpointing.md +53 -0
  229. package/cli/dist/web-ui/docs/en/cli/cli-reference.md +187 -0
  230. package/cli/dist/web-ui/docs/en/cli/common-workflows.md +1011 -0
  231. package/cli/dist/web-ui/docs/en/cli/costs.md +174 -0
  232. package/cli/dist/web-ui/docs/en/cli/devcontainer.md +553 -0
  233. package/cli/dist/web-ui/docs/en/cli/env-vars.md +326 -0
  234. package/cli/dist/web-ui/docs/en/cli/gitlab-ci-cd.md +357 -0
  235. package/cli/dist/web-ui/docs/en/cli/headless.md +258 -0
  236. package/cli/dist/web-ui/docs/en/cli/hooks-guide.md +9 -0
  237. package/cli/dist/web-ui/docs/en/cli/hooks.md +801 -0
  238. package/cli/dist/web-ui/docs/en/cli/iam.md +526 -0
  239. package/cli/dist/web-ui/docs/en/cli/ide-integrations.md +92 -0
  240. package/cli/dist/web-ui/docs/en/cli/installation.md +266 -0
  241. package/cli/dist/web-ui/docs/en/cli/interactive-mode.md +233 -0
  242. package/cli/dist/web-ui/docs/en/cli/mcp.md +739 -0
  243. package/cli/dist/web-ui/docs/en/cli/memory.md +436 -0
  244. package/cli/dist/web-ui/docs/en/cli/models.md +355 -0
  245. package/cli/dist/web-ui/docs/en/cli/overview.md +100 -0
  246. package/cli/dist/web-ui/docs/en/cli/plugin-marketplaces.md +534 -0
  247. package/cli/dist/web-ui/docs/en/cli/plugins-reference.md +774 -0
  248. package/cli/dist/web-ui/docs/en/cli/plugins.md +688 -0
  249. package/cli/dist/web-ui/docs/en/cli/quickstart.md +249 -0
  250. package/cli/dist/web-ui/docs/en/cli/release-notes/README.md +193 -0
  251. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.0.md +23 -0
  252. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.1.md +5 -0
  253. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.11.0.md +24 -0
  254. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.12.0.md +21 -0
  255. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.13.0.md +20 -0
  256. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.0.md +22 -0
  257. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.1.md +8 -0
  258. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.0.md +18 -0
  259. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.1.md +11 -0
  260. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.16.0.md +20 -0
  261. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.17.0.md +29 -0
  262. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.18.0.md +17 -0
  263. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.0.md +11 -0
  264. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.1.md +14 -0
  265. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.2.md +11 -0
  266. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.0.md +23 -0
  267. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.1.md +15 -0
  268. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.21.0.md +13 -0
  269. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.22.0.md +16 -0
  270. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.0.md +41 -0
  271. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.2.md +5 -0
  272. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.3.md +5 -0
  273. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.4.md +15 -0
  274. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.5.md +11 -0
  275. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.24.0.md +17 -0
  276. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.0.md +18 -0
  277. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.1.md +21 -0
  278. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.26.0.md +18 -0
  279. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.0.md +16 -0
  280. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.1.md +16 -0
  281. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.2.md +7 -0
  282. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.3.md +15 -0
  283. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.0.md +26 -0
  284. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.1.md +5 -0
  285. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.29.0.md +35 -0
  286. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.3.1.md +16 -0
  287. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.0.md +19 -0
  288. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.1.md +5 -0
  289. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.0.md +51 -0
  290. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.1.md +11 -0
  291. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.2.md +16 -0
  292. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.32.0.md +19 -0
  293. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.0.md +28 -0
  294. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.1.md +7 -0
  295. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.0.md +27 -0
  296. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.1.md +7 -0
  297. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.35.0.md +22 -0
  298. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.0.md +23 -0
  299. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.1.md +5 -0
  300. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.2.md +22 -0
  301. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.3.md +17 -0
  302. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.0.md +15 -0
  303. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.1.md +15 -0
  304. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.10.md +5 -0
  305. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.11.md +8 -0
  306. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.12.md +14 -0
  307. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.13.md +11 -0
  308. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.14.md +24 -0
  309. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.15.md +11 -0
  310. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.16.md +9 -0
  311. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.17.md +5 -0
  312. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.18.md +9 -0
  313. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.19.md +5 -0
  314. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.2.md +28 -0
  315. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.20.md +8 -0
  316. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.3.md +22 -0
  317. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.4.md +19 -0
  318. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.5.md +5 -0
  319. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.6.md +5 -0
  320. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.7.md +5 -0
  321. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.8.md +5 -0
  322. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.9.md +8 -0
  323. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.0.md +22 -0
  324. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.1.md +6 -0
  325. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.2.md +9 -0
  326. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.39.0.md +18 -0
  327. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.4.0.md +19 -0
  328. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.0.md +20 -0
  329. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.1.md +6 -0
  330. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.0.md +15 -0
  331. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.1.md +6 -0
  332. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.2.md +5 -0
  333. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.3.md +8 -0
  334. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.4.md +5 -0
  335. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.5.md +10 -0
  336. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.6.md +9 -0
  337. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.7.md +14 -0
  338. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.8.md +18 -0
  339. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.0.md +39 -0
  340. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.1.md +8 -0
  341. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.3.md +18 -0
  342. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.0.md +27 -0
  343. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.1.md +27 -0
  344. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.0.md +11 -0
  345. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.1.md +22 -0
  346. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.0.md +34 -0
  347. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.1.md +7 -0
  348. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.46.0.md +12 -0
  349. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.47.0.md +20 -0
  350. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.0.md +32 -0
  351. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.1.md +11 -0
  352. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.0.md +26 -0
  353. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.1.md +14 -0
  354. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.2.md +39 -0
  355. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.3.md +7 -0
  356. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.5.md +11 -0
  357. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.6.md +9 -0
  358. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.7.md +7 -0
  359. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.5.0.md +24 -0
  360. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.0.md +25 -0
  361. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.1.md +9 -0
  362. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.2.md +11 -0
  363. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.3.md +5 -0
  364. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.4.md +17 -0
  365. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.5.md +16 -0
  366. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.6.md +15 -0
  367. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.7.md +15 -0
  368. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.0.md +24 -0
  369. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.1.md +17 -0
  370. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.2.md +5 -0
  371. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.0.md +30 -0
  372. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.1.md +28 -0
  373. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.2.md +12 -0
  374. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.3.md +13 -0
  375. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.4.md +27 -0
  376. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.5.md +21 -0
  377. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.6.md +7 -0
  378. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.53.0.md +29 -0
  379. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.54.0.md +26 -0
  380. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.0.md +21 -0
  381. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.1.md +13 -0
  382. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.0.md +20 -0
  383. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.1.md +5 -0
  384. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.0.md +32 -0
  385. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.1.md +10 -0
  386. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.58.0.md +34 -0
  387. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.59.0.md +28 -0
  388. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.0.md +5 -0
  389. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.1.md +10 -0
  390. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.60.0.md +20 -0
  391. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.0.md +29 -0
  392. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.1.md +5 -0
  393. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.2.md +6 -0
  394. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.3.md +13 -0
  395. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.0.md +21 -0
  396. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.1.md +11 -0
  397. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.0.md +19 -0
  398. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.1.md +5 -0
  399. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.2.md +7 -0
  400. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.3.md +6 -0
  401. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.4.md +8 -0
  402. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.5.md +6 -0
  403. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.0.md +37 -0
  404. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.1.md +6 -0
  405. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.2.md +11 -0
  406. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.0.md +19 -0
  407. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.1.md +11 -0
  408. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.0.md +15 -0
  409. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.1.md +14 -0
  410. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.2.md +5 -0
  411. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.67.0.md +33 -0
  412. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.7.0.md +16 -0
  413. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.0.md +18 -0
  414. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.1.md +17 -0
  415. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.2.md +5 -0
  416. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.3.md +14 -0
  417. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.4.md +9 -0
  418. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.5.md +5 -0
  419. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.6.md +14 -0
  420. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.9.0.md +5 -0
  421. package/cli/dist/web-ui/docs/en/cli/remote-control.md +247 -0
  422. package/cli/dist/web-ui/docs/en/cli/sandboxing.md +316 -0
  423. package/cli/dist/web-ui/docs/en/cli/scheduled-tasks.md +160 -0
  424. package/cli/dist/web-ui/docs/en/cli/sdk-custom-tools.md +1131 -0
  425. package/cli/dist/web-ui/docs/en/cli/sdk-demos.md +347 -0
  426. package/cli/dist/web-ui/docs/en/cli/sdk-hooks.md +813 -0
  427. package/cli/dist/web-ui/docs/en/cli/sdk-mcp.md +645 -0
  428. package/cli/dist/web-ui/docs/en/cli/sdk-permissions.md +461 -0
  429. package/cli/dist/web-ui/docs/en/cli/sdk-python.md +797 -0
  430. package/cli/dist/web-ui/docs/en/cli/sdk-sessions.md +340 -0
  431. package/cli/dist/web-ui/docs/en/cli/sdk-typescript.md +770 -0
  432. package/cli/dist/web-ui/docs/en/cli/sdk.md +1103 -0
  433. package/cli/dist/web-ui/docs/en/cli/security.md +388 -0
  434. package/cli/dist/web-ui/docs/en/cli/settings.md +602 -0
  435. package/cli/dist/web-ui/docs/en/cli/skills.md +448 -0
  436. package/cli/dist/web-ui/docs/en/cli/slash-commands.md +397 -0
  437. package/cli/dist/web-ui/docs/en/cli/statusline.md +525 -0
  438. package/cli/dist/web-ui/docs/en/cli/sub-agents.md +621 -0
  439. package/cli/dist/web-ui/docs/en/cli/terminal-config.md +77 -0
  440. package/cli/dist/web-ui/docs/en/cli/tools-reference.md +99 -0
  441. package/cli/dist/web-ui/docs/en/cli/troubleshooting.md +190 -0
  442. package/cli/dist/web-ui/docs/en/cli/web-ui.md +164 -0
  443. package/cli/dist/web-ui/docs/en/cli/wecom-bot-setup.md +274 -0
  444. package/cli/dist/web-ui/docs/en/cli/worktree.md +660 -0
  445. package/cli/dist/web-ui/docs/search-index-en.json +1 -0
  446. package/cli/dist/web-ui/docs/search-index-zh.json +1 -0
  447. package/cli/dist/web-ui/docs/sidebar-en.json +1 -0
  448. package/cli/dist/web-ui/docs/sidebar-zh.json +1 -0
  449. package/cli/dist/web-ui/index.html +2 -2
  450. package/cli/package.json +1 -1
  451. package/cli/product.cloudhosted.json +2 -2
  452. package/cli/product.internal.json +2 -2
  453. package/cli/product.ioa.json +2 -2
  454. package/cli/product.json +3 -3
  455. package/cli/product.selfhosted.json +2 -2
  456. package/package.json +1 -1
  457. package/cli/dist/web-ui/assets/index-BPT-qRRx.js +0 -411
  458. package/cli/dist/web-ui/assets/index-f_ibHSHw.css +0 -32
@@ -0,0 +1,1103 @@
1
+ # CodeBuddy Agent SDK
2
+
3
+ > **Version Requirements**: This documentation is for CodeBuddy Agent SDK v0.1.0 and above.
4
+ > **Feature Status**: The SDK is currently in **Preview** stage, and interfaces and behaviors may be adjusted in future versions.
5
+
6
+ ::: warning Important: Environment Isolation
7
+ The SDK **does not load any filesystem configurations by default**, including `settings.json`, `CODEBUDDY.md`, MCP servers, sub-agents, slash commands, Rules, and Skills. This is a key difference from direct CLI usage, ensuring SDK application behavior is completely controlled by code with predictability and consistency.
8
+
9
+ To load these configurations, use the `settingSources` option to explicitly specify. See [Environment Isolation](#environment-isolation-settingsources) section for details.
10
+ :::
11
+
12
+ CodeBuddy Agent SDK allows you to programmatically control CodeBuddy Agent in your applications. It supports TypeScript/JavaScript and Python, enabling scenarios such as automated task execution, custom permission control, and building AI-powered development tools.
13
+
14
+ ## Why Use the SDK
15
+
16
+ CodeBuddy Agent SDK gives you programmatic access to all of CodeBuddy's capabilities, not just through command-line interaction.
17
+
18
+ ### Beyond Command Line
19
+
20
+ - **Programmatic Control**: Embed AI programming assistants in your applications to implement automated workflows
21
+ - **Custom Interactions**: Build user interfaces and interaction methods that suit your needs
22
+ - **Batch Processing**: Perform batch AI operations on multiple files or projects
23
+ - **Integrate with Existing Systems**: Seamlessly integrate AI capabilities into CI/CD, IDE plugins, or other development tools
24
+
25
+ ### Fine-grained Control
26
+
27
+ - **Permission Management**: Implement enterprise-level permission policies through `canUseTool` callbacks
28
+ - **Behavior Customization**: Use the Hook system to intercept and modify Agent behavior
29
+ - **Resource Limits**: Control token consumption, execution time, and budget
30
+ - **Session Management**: Persist and restore conversation contexts
31
+
32
+ ### Extended Capabilities
33
+
34
+ - **Custom Agents**: Create specialized sub-agents to handle domain-specific tasks
35
+ - **MCP Integration**: Connect custom tools and services
36
+ - **Multi-model Support**: Flexibly switch and configure different AI models
37
+
38
+ ## What You Can Build
39
+
40
+ ### Development Tool Enhancements
41
+
42
+ - **IDE Plugins**: Build intelligent programming assistants for VS Code, JetBrains, and other IDEs
43
+ - **Code Review Tools**: Automate code quality checks and security scans
44
+ - **Documentation Generators**: Automatically generate API documentation, READMEs, and code comments
45
+
46
+ ### Automated Workflows
47
+
48
+ - **CI/CD Integration**: Perform intelligent code analysis and fixes in pipelines
49
+ - **Test Generation**: Automatically generate unit tests and integration tests
50
+ - **Refactoring Assistants**: Batch execute code refactoring and migration tasks
51
+
52
+ ### Enterprise Applications
53
+
54
+ - **Internal Development Platforms**: Build enterprise-level AI programming platforms
55
+ - **Knowledge Base Q&A**: Intelligent Q&A systems based on codebases
56
+ - **Training Tools**: Interactive programming learning and code review systems
57
+
58
+ ## Feature Overview
59
+
60
+ - **Message Streaming**: Receive system messages, assistant responses, and tool call results in real-time
61
+ - **Multi-turn Conversations**: Support maintaining conversation context across multiple reasoning calls
62
+ - **Session Management**: Continue or resume existing conversations through session IDs
63
+ - **Permission Control**: Fine-grained tool access permission management
64
+ - **Hook System**: Insert custom logic before and after tool execution
65
+ - **Custom Agents**: Define specialized sub-agents to handle specific tasks
66
+ - **MCP Integration**: Support configuring custom MCP servers to extend functionality
67
+
68
+ ## Installation
69
+
70
+ ::: code-group
71
+
72
+ ```bash [TypeScript]
73
+ npm install @tencent-ai/agent-sdk
74
+ # or
75
+ yarn add @tencent-ai/agent-sdk
76
+ # or
77
+ pnpm add @tencent-ai/agent-sdk
78
+ ```
79
+
80
+ ```bash [Python]
81
+ uv add codebuddy-agent-sdk
82
+ # or
83
+ pip install codebuddy-agent-sdk
84
+ ```
85
+
86
+ :::
87
+
88
+ ### Environment Requirements
89
+
90
+ | Language | Version Requirement |
91
+ |----------|---------------------|
92
+ | TypeScript/JavaScript | Node.js >= 18.20 |
93
+ | Python | Python >= 3.10 |
94
+
95
+ ### Authentication Configuration
96
+
97
+ #### Using Existing Login Credentials
98
+
99
+ If you've already completed interactive login in the terminal via the `codebuddy` command, the SDK will automatically use that authentication information without additional configuration.
100
+
101
+ #### Using API Key
102
+
103
+ If not logged in or need to use different credentials, you can authenticate via API Key:
104
+
105
+ ```bash
106
+ export CODEBUDDY_API_KEY="your-api-key"
107
+ ```
108
+
109
+ **Get API Key:**
110
+
111
+ | Edition | Get API Key at |
112
+ |:--------|:---------------|
113
+ | International | <https://www.codebuddy.ai/profile/keys> |
114
+ | China | <https://copilot.tencent.com/profile/> |
115
+ | iOA | <https://tencent.sso.copilot.tencent.com/profile/keys> |
116
+
117
+ > **Note**: When using `CODEBUDDY_API_KEY`, you must correctly configure the `CODEBUDDY_INTERNET_ENVIRONMENT` environment variable based on your edition:
118
+ > - International: Do not set (default)
119
+ > - China: `export CODEBUDDY_INTERNET_ENVIRONMENT=internal`
120
+ > - iOA: `export CODEBUDDY_INTERNET_ENVIRONMENT=ioa`
121
+ >
122
+ > See [Identity and Access Management documentation](iam.md#personal-user-get-api-key) for details.
123
+
124
+ You can also pass it in code through the `env` option:
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
+ // China edition users need to set:
135
+ // CODEBUDDY_INTERNET_ENVIRONMENT: 'internal'
136
+ // iOA edition users need to set:
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
+ # China edition users need to set:
148
+ # "CODEBUDDY_INTERNET_ENVIRONMENT": "internal"
149
+ # iOA edition users need to set:
150
+ # "CODEBUDDY_INTERNET_ENVIRONMENT": "ioa"
151
+ }
152
+ )
153
+ ```
154
+
155
+ :::
156
+
157
+ #### Enterprise Users: OAuth Client Credentials
158
+
159
+ > Currently only introducing the Client Credentials authorization method, suitable for server-side applications and CI/CD scenarios.
160
+
161
+ Enterprise users need to first obtain an access token through the OAuth 2.0 Client Credentials flow, then pass it to the SDK.
162
+
163
+ **Step 1: Create Application to Obtain Credentials**
164
+
165
+ Refer to [Enterprise Developer Quick Start](https://copilot.tencent.com/apiDocs/open-platform.html) to create an application and obtain Client ID and Client Secret.
166
+
167
+ **Step 2: Get Token and Call SDK**
168
+
169
+ ::: code-group
170
+
171
+ ```typescript [TypeScript]
172
+ async function getOAuthToken(clientId: string, clientSecret: string): Promise<string> {
173
+ const response = await fetch('https://copilot.tencent.com/oauth2/token', {
174
+ method: 'POST',
175
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
176
+ body: new URLSearchParams({
177
+ grant_type: 'client_credentials',
178
+ client_id: clientId,
179
+ client_secret: clientSecret,
180
+ }),
181
+ });
182
+ const data = await response.json();
183
+ return data.access_token;
184
+ }
185
+
186
+ // Get token and call SDK
187
+ const token = await getOAuthToken('your-client-id', 'your-client-secret');
188
+
189
+ for await (const msg of query({
190
+ prompt: 'Hello',
191
+ options: {
192
+ env: { CODEBUDDY_AUTH_TOKEN: token },
193
+ },
194
+ })) {
195
+ console.log(msg);
196
+ }
197
+ ```
198
+
199
+ ```python [Python]
200
+ import httpx
201
+ from codebuddy_agent_sdk import query, CodeBuddyAgentOptions
202
+
203
+ async def get_oauth_token(client_id: str, client_secret: str) -> str:
204
+ async with httpx.AsyncClient() as client:
205
+ response = await client.post(
206
+ "https://copilot.tencent.com/oauth2/token",
207
+ data={
208
+ "grant_type": "client_credentials",
209
+ "client_id": client_id,
210
+ "client_secret": client_secret,
211
+ },
212
+ )
213
+ return response.json()["access_token"]
214
+
215
+ # Get token and call SDK
216
+ token = await get_oauth_token("your-client-id", "your-client-secret")
217
+
218
+ options = CodeBuddyAgentOptions(
219
+ env={"CODEBUDDY_AUTH_TOKEN": token}
220
+ )
221
+
222
+ async for msg in query(prompt="Hello", options=options):
223
+ print(msg)
224
+ ```
225
+
226
+ :::
227
+
228
+ For detailed authentication configuration instructions, please refer to [Identity Authentication](iam.md#authentication-methods).
229
+
230
+ ### Other Environment Variables
231
+
232
+ | Variable Name | Description | Required |
233
+ |---------------|-------------|----------|
234
+ | `CODEBUDDY_CODE_PATH` | Path to CodeBuddy CLI executable | Optional |
235
+
236
+ If not set, the SDK will automatically attempt to locate the CLI.
237
+
238
+ ## Basic Usage
239
+
240
+ ### Simple Query
241
+
242
+ The most basic usage is to send a prompt and handle the response:
243
+
244
+ ::: code-group
245
+
246
+ ```typescript [TypeScript]
247
+ import { query } from '@tencent-ai/agent-sdk';
248
+
249
+ async function main() {
250
+ const q = query({
251
+ prompt: 'Please explain what a recursive function is',
252
+ options: {
253
+ permissionMode: 'bypassPermissions'
254
+ }
255
+ });
256
+
257
+ for await (const message of q) {
258
+ if (message.type === 'assistant') {
259
+ for (const block of message.message.content) {
260
+ if (block.type === 'text') {
261
+ console.log(block.text);
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+
268
+ main();
269
+ ```
270
+
271
+ ```python [Python]
272
+ import asyncio
273
+ from codebuddy_agent_sdk import query, CodeBuddyAgentOptions
274
+ from codebuddy_agent_sdk import AssistantMessage, TextBlock
275
+
276
+ async def main():
277
+ options = CodeBuddyAgentOptions(
278
+ permission_mode="bypassPermissions"
279
+ )
280
+
281
+ async for message in query(prompt="Please explain what a recursive function is", options=options):
282
+ if isinstance(message, AssistantMessage):
283
+ for block in message.content:
284
+ if isinstance(block, TextBlock):
285
+ print(block.text)
286
+
287
+ asyncio.run(main())
288
+ ```
289
+
290
+ :::
291
+
292
+ ### Extracting Results
293
+
294
+ After the query completes, you'll receive a `result` message containing execution statistics:
295
+
296
+ ::: code-group
297
+
298
+ ```typescript [TypeScript]
299
+ for await (const message of q) {
300
+ if (message.type === 'result') {
301
+ if (message.subtype === 'success') {
302
+ console.log('Complete! Duration:', message.duration_ms, 'ms');
303
+ console.log('Cost:', message.total_cost_usd, 'USD');
304
+ } else {
305
+ console.log('Execution error');
306
+ }
307
+ }
308
+ }
309
+ ```
310
+
311
+ ```python [Python]
312
+ from codebuddy_agent_sdk import ResultMessage
313
+
314
+ async for message in query(prompt="...", options=options):
315
+ if isinstance(message, ResultMessage):
316
+ if message.subtype == "success":
317
+ print(f"Complete! Duration: {message.duration_ms} ms")
318
+ print(f"Cost: {message.total_cost_usd} USD")
319
+ else:
320
+ print("Execution error")
321
+ ```
322
+
323
+ :::
324
+
325
+ ### Message Type Handling
326
+
327
+ The SDK returns multiple types of messages:
328
+
329
+ ::: code-group
330
+
331
+ ```typescript [TypeScript]
332
+ for await (const message of q) {
333
+ switch (message.type) {
334
+ case 'system':
335
+ // Session initialization message
336
+ console.log('Session ID:', message.session_id);
337
+ console.log('Available tools:', message.tools);
338
+ break;
339
+
340
+ case 'assistant':
341
+ // AI assistant response
342
+ for (const block of message.message.content) {
343
+ if (block.type === 'text') {
344
+ console.log('[Text]', block.text);
345
+ } else if (block.type === 'tool_use') {
346
+ console.log('[Tool Call]', block.name, block.input);
347
+ } else if (block.type === 'tool_result') {
348
+ console.log('[Tool Result]', block.content);
349
+ }
350
+ }
351
+ break;
352
+
353
+ case 'result':
354
+ // Query complete
355
+ console.log('Execution complete, duration:', message.duration_ms, 'ms');
356
+ break;
357
+ }
358
+ }
359
+ ```
360
+
361
+ ```python [Python]
362
+ from codebuddy_agent_sdk import (
363
+ SystemMessage, AssistantMessage, ResultMessage,
364
+ TextBlock, ToolUseBlock, ToolResultBlock
365
+ )
366
+
367
+ async for message in query(prompt="...", options=options):
368
+ if isinstance(message, SystemMessage):
369
+ # Session initialization message
370
+ print(f"Session ID: {message.data.get('session_id')}")
371
+ print(f"Available tools: {message.data.get('tools')}")
372
+
373
+ elif isinstance(message, AssistantMessage):
374
+ # AI assistant response
375
+ for block in message.content:
376
+ if isinstance(block, TextBlock):
377
+ print(f"[Text] {block.text}")
378
+ elif isinstance(block, ToolUseBlock):
379
+ print(f"[Tool Call] {block.name}: {block.input}")
380
+ elif isinstance(block, ToolResultBlock):
381
+ print(f"[Tool Result] {block.content}")
382
+
383
+ elif isinstance(message, ResultMessage):
384
+ # Query complete
385
+ print(f"Execution complete, duration: {message.duration_ms} ms")
386
+ ```
387
+
388
+ :::
389
+
390
+ ## Configuration Options
391
+
392
+ ### Permission Mode
393
+
394
+ Control tool invocation permission behavior through `permissionMode`:
395
+
396
+ | Mode | Description |
397
+ |------|-------------|
398
+ | `default` | Default mode, all operations require confirmation |
399
+ | `acceptEdits` | Automatically approve file edits, Bash still requires confirmation |
400
+ | `plan` | Plan mode, only read operations allowed |
401
+ | `bypassPermissions` | Skip all permission checks (use with caution) |
402
+
403
+ ::: code-group
404
+
405
+ ```typescript [TypeScript]
406
+ const q = query({
407
+ prompt: 'Analyze project structure',
408
+ options: {
409
+ permissionMode: 'plan' // Read-only mode
410
+ }
411
+ });
412
+ ```
413
+
414
+ ```python [Python]
415
+ options = CodeBuddyAgentOptions(
416
+ permission_mode="plan" # Read-only mode
417
+ )
418
+ async for msg in query(prompt="Analyze project structure", options=options):
419
+ pass
420
+ ```
421
+
422
+ :::
423
+
424
+ ### Working Directory
425
+
426
+ Specify the Agent's working directory:
427
+
428
+ ::: code-group
429
+
430
+ ```typescript [TypeScript]
431
+ const q = query({
432
+ prompt: 'Read package.json',
433
+ options: {
434
+ cwd: '/path/to/project'
435
+ }
436
+ });
437
+ ```
438
+
439
+ ```python [Python]
440
+ options = CodeBuddyAgentOptions(
441
+ cwd="/path/to/project"
442
+ )
443
+ ```
444
+
445
+ :::
446
+
447
+ ### Model Selection
448
+
449
+ Specify the AI model to use:
450
+
451
+ ::: code-group
452
+
453
+ ```typescript [TypeScript]
454
+ const q = query({
455
+ prompt: '...',
456
+ options: {
457
+ model: 'deepseek-v3.1',
458
+ fallbackModel: 'deepseek-v3.1'
459
+ }
460
+ });
461
+ ```
462
+
463
+ ```python [Python]
464
+ options = CodeBuddyAgentOptions(
465
+ model="deepseek-v3.1",
466
+ fallback_model="deepseek-v3.1"
467
+ )
468
+ ```
469
+
470
+ :::
471
+
472
+ ### Resource Limits
473
+
474
+ Limit execution scope:
475
+
476
+ ::: code-group
477
+
478
+ ```typescript [TypeScript]
479
+ const q = query({
480
+ prompt: '...',
481
+ options: {
482
+ maxTurns: 20 // Maximum conversation turns
483
+ }
484
+ });
485
+ ```
486
+
487
+ ```python [Python]
488
+ options = CodeBuddyAgentOptions(
489
+ max_turns=20, # Maximum conversation turns
490
+ )
491
+ ```
492
+
493
+ :::
494
+
495
+ ## Environment Isolation (settingSources)
496
+
497
+ ### Design Philosophy
498
+
499
+ The SDK **does not load any filesystem configurations by default**, providing a completely clean runtime environment. This is a key difference from direct CLI usage.
500
+
501
+ ### Why This Design?
502
+
503
+ 1. **Predictability**: SDK application behavior is completely controlled by code, unaffected by user or project configuration files
504
+ 2. **Isolation**: Avoid user preferences or project settings interfering with SDK application logic
505
+ 3. **Security**: Sensitive configurations (such as hooks, permission rules) won't accidentally leak into the SDK environment
506
+ 4. **Consistency**: Behavior remains consistent when running on different machines
507
+
508
+ ### Default Behavior Comparison
509
+
510
+ | Scenario | Settings | Memory | MCP | Subagent | Commands | Rules | Skills |
511
+ |----------|----------|--------|-----|----------|----------|-------|--------|
512
+ | SDK Call (default) | ✗ Not loaded | ✗ Not loaded | ✗ Not loaded | ✗ Not loaded | ✗ Not loaded | ✗ Not loaded | ✗ Not loaded |
513
+ | CLI Direct Run | ✓ Load all | ✓ Load all | ✓ Load all | ✓ Load all | ✓ Load all | ✓ Load all | ✓ Load all |
514
+
515
+ **Configuration File Location Reference**:
516
+
517
+ | Config Type | User Level Location | Project Level Location | Description |
518
+ |-------------|--------------------|-----------------------|-------------|
519
+ | Settings | `~/.codebuddy/settings.json` | `.codebuddy/settings.json` | Permissions, hooks, environment variables, etc. |
520
+ | Memory | `~/.codebuddy/CODEBUDDY.md` | `CODEBUDDY.md` | Project instructions and context |
521
+ | MCP | `~/.codebuddy/.mcp.json` | `.mcp.json` | MCP server configuration |
522
+ | Subagent | `~/.codebuddy/agents/` | `.codebuddy/agents/` | Custom sub-agents |
523
+ | Commands | `~/.codebuddy/commands/` | `.codebuddy/commands/` | Custom slash commands |
524
+ | Rules | `~/.codebuddy/rules/` | `.codebuddy/rules/` | Modular rule files |
525
+ | Skills | `~/.codebuddy/skills/` | `.codebuddy/skills/` | AI auto-invoked skills |
526
+
527
+ ### Explicitly Loading Configuration
528
+
529
+ To load filesystem configurations, use `settingSources` to explicitly specify:
530
+
531
+ ::: code-group
532
+
533
+ ```typescript [TypeScript]
534
+ const q = query({
535
+ prompt: '...',
536
+ options: {
537
+ // Load project configuration (.codebuddy/settings.json, CODEBUDDY.md)
538
+ settingSources: ['project'],
539
+
540
+ // Or load all configurations
541
+ // settingSources: ['user', 'project', 'local']
542
+ }
543
+ });
544
+ ```
545
+
546
+ ```python [Python]
547
+ options = CodeBuddyAgentOptions(
548
+ # Load project configuration
549
+ setting_sources=["project"],
550
+
551
+ # Or load all configurations
552
+ # setting_sources=["user", "project", "local"]
553
+ )
554
+ ```
555
+
556
+ :::
557
+
558
+ ### Configuration Source Descriptions
559
+
560
+ | Value | Description | Location |
561
+ |-------|-------------|----------|
562
+ | `'user'` | Global user settings | `~/.codebuddy/settings.json`, `~/.codebuddy/CODEBUDDY.md` |
563
+ | `'project'` | Project shared settings | `.codebuddy/settings.json`, `CODEBUDDY.md` |
564
+ | `'local'` | Project local settings | `.codebuddy/settings.local.json`, `CODEBUDDY.local.md` |
565
+
566
+ ### Typical Use Cases
567
+
568
+ **CI/CD Environment**:
569
+
570
+ ::: code-group
571
+
572
+ ```typescript [TypeScript]
573
+ // Only load project configuration, ignore user and local configurations
574
+ const q = query({
575
+ prompt: 'Run tests',
576
+ options: {
577
+ settingSources: ['project'],
578
+ permissionMode: 'bypassPermissions'
579
+ }
580
+ });
581
+ ```
582
+
583
+ ```python [Python]
584
+ # Only load project configuration, ignore user and local configurations
585
+ options = CodeBuddyAgentOptions(
586
+ setting_sources=["project"],
587
+ permission_mode="bypassPermissions"
588
+ )
589
+ ```
590
+
591
+ :::
592
+
593
+ **Fully Programmatic Control**:
594
+
595
+ ::: code-group
596
+
597
+ ```typescript [TypeScript]
598
+ // Default behavior: Don't load any configuration
599
+ // All behavior explicitly defined through options
600
+ const q = query({
601
+ prompt: '...',
602
+ options: {
603
+ agents: { /* custom agent */ },
604
+ mcpServers: { /* custom MCP */ },
605
+ allowedTools: ['Read', 'Grep', 'Glob']
606
+ }
607
+ });
608
+ ```
609
+
610
+ ```python [Python]
611
+ # Default behavior: Don't load any configuration
612
+ # All behavior explicitly defined through options
613
+ options = CodeBuddyAgentOptions(
614
+ agents={"reviewer": AgentDefinition(...)},
615
+ mcp_servers={"db": {...}},
616
+ allowed_tools=["Read", "Grep", "Glob"]
617
+ )
618
+ ```
619
+
620
+ :::
621
+
622
+ ## Permission Control
623
+
624
+ ### canUseTool Callback
625
+
626
+ Implement fine-grained permission control through the `canUseTool` callback:
627
+
628
+ ::: code-group
629
+
630
+ ```typescript [TypeScript]
631
+ import { query } from '@tencent-ai/agent-sdk';
632
+
633
+ const q = query({
634
+ prompt: 'Analyze project structure',
635
+ options: {
636
+ canUseTool: async (toolName, input, options) => {
637
+ // Only allow read-only tools
638
+ const readOnlyTools = ['Read', 'Glob', 'Grep'];
639
+
640
+ if (readOnlyTools.includes(toolName)) {
641
+ return {
642
+ behavior: 'allow',
643
+ updatedInput: input
644
+ };
645
+ }
646
+
647
+ // Deny other tools
648
+ return {
649
+ behavior: 'deny',
650
+ message: `Tool ${toolName} is not allowed`
651
+ };
652
+ }
653
+ }
654
+ });
655
+ ```
656
+
657
+ ```python [Python]
658
+ from codebuddy_agent_sdk import (
659
+ query, CodeBuddyAgentOptions,
660
+ CanUseToolOptions, PermissionResultAllow, PermissionResultDeny
661
+ )
662
+
663
+ async def can_use_tool(
664
+ tool_name: str,
665
+ input_data: dict,
666
+ options: CanUseToolOptions
667
+ ):
668
+ # Only allow read-only tools
669
+ read_only_tools = ["Read", "Glob", "Grep"]
670
+
671
+ if tool_name in read_only_tools:
672
+ return PermissionResultAllow(updated_input=input_data)
673
+
674
+ # Deny other tools
675
+ return PermissionResultDeny(
676
+ message=f"Tool {tool_name} is not allowed"
677
+ )
678
+
679
+ options = CodeBuddyAgentOptions(can_use_tool=can_use_tool)
680
+ ```
681
+
682
+ :::
683
+
684
+ ### Intercepting Dangerous Operations
685
+
686
+ Combine permission callbacks to intercept dangerous commands:
687
+
688
+ ::: code-group
689
+
690
+ ```typescript [TypeScript]
691
+ const dangerousCommands = ['rm -rf', 'sudo', 'chmod 777'];
692
+
693
+ const q = query({
694
+ prompt: 'Clean temporary files',
695
+ options: {
696
+ canUseTool: async (toolName, input) => {
697
+ if (toolName === 'Bash') {
698
+ const command = input.command as string;
699
+ for (const dangerous of dangerousCommands) {
700
+ if (command.includes(dangerous)) {
701
+ return {
702
+ behavior: 'deny',
703
+ message: `Dangerous command intercepted: ${dangerous}`,
704
+ interrupt: true // Interrupt the entire session
705
+ };
706
+ }
707
+ }
708
+ }
709
+ return { behavior: 'allow', updatedInput: input };
710
+ }
711
+ }
712
+ });
713
+ ```
714
+
715
+ ```python [Python]
716
+ dangerous_commands = ["rm -rf", "sudo", "chmod 777"]
717
+
718
+ async def can_use_tool(tool_name, input_data, options):
719
+ if tool_name == "Bash":
720
+ command = input_data.get("command", "")
721
+ for dangerous in dangerous_commands:
722
+ if dangerous in command:
723
+ return PermissionResultDeny(
724
+ message=f"Dangerous command intercepted: {dangerous}",
725
+ interrupt=True # Interrupt the entire session
726
+ )
727
+ return PermissionResultAllow(updated_input=input_data)
728
+ ```
729
+
730
+ :::
731
+
732
+ ## Multi-turn Conversations
733
+
734
+ ### Using Session/Client API
735
+
736
+ For scenarios requiring multi-turn interactions, use the Session (TypeScript) or Client (Python) API:
737
+
738
+ ::: code-group
739
+
740
+ ```typescript [TypeScript]
741
+ import { unstable_v2_createSession } from '@tencent-ai/agent-sdk';
742
+
743
+ async function main() {
744
+ const session = unstable_v2_createSession({
745
+ model: 'deepseek-v3.1'
746
+ });
747
+
748
+ // First turn
749
+ await session.send('Analyze this project\'s architecture');
750
+ for await (const message of session.stream()) {
751
+ console.log(message);
752
+ }
753
+
754
+ // Second turn (maintaining context)
755
+ await session.send('Please explain point three in detail');
756
+ for await (const message of session.stream()) {
757
+ console.log(message);
758
+ }
759
+
760
+ session.close();
761
+ }
762
+ ```
763
+
764
+ ```python [Python]
765
+ from codebuddy_agent_sdk import CodeBuddySDKClient, CodeBuddyAgentOptions
766
+
767
+ async def main():
768
+ options = CodeBuddyAgentOptions(model="deepseek-v3.1")
769
+
770
+ async with CodeBuddySDKClient(options=options) as client:
771
+ # First turn
772
+ await client.query("Analyze this project's architecture")
773
+ async for message in client.receive_response():
774
+ print(message)
775
+
776
+ # Second turn (maintaining context)
777
+ await client.query("Please explain point three in detail")
778
+ async for message in client.receive_response():
779
+ print(message)
780
+
781
+ asyncio.run(main())
782
+ ```
783
+
784
+ :::
785
+
786
+ ### Interrupting Execution
787
+
788
+ Interrupt execution during runtime:
789
+
790
+ ::: code-group
791
+
792
+ ```typescript [TypeScript]
793
+ const q = query({ prompt: 'Execute long-running task...' });
794
+
795
+ let count = 0;
796
+ for await (const message of q) {
797
+ if (message.type === 'assistant') {
798
+ for (const block of message.message.content) {
799
+ if (block.type === 'tool_use') {
800
+ count++;
801
+ if (count >= 10) {
802
+ await q.interrupt(); // Interrupt execution
803
+ break;
804
+ }
805
+ }
806
+ }
807
+ }
808
+ }
809
+ ```
810
+
811
+ ```python [Python]
812
+ async with CodeBuddySDKClient(options=options) as client:
813
+ await client.query("Execute long-running task...")
814
+
815
+ count = 0
816
+ async for message in client.receive_messages():
817
+ if isinstance(message, AssistantMessage):
818
+ for block in message.content:
819
+ if isinstance(block, ToolUseBlock):
820
+ count += 1
821
+ if count >= 10:
822
+ await client.interrupt() # Interrupt execution
823
+ break
824
+ ```
825
+
826
+ :::
827
+
828
+ ## Hook System
829
+
830
+ Hooks allow you to insert custom logic before and after tool execution.
831
+
832
+ ### PreToolUse Hook
833
+
834
+ Intercept and handle before tool execution:
835
+
836
+ ::: code-group
837
+
838
+ ```typescript [TypeScript]
839
+ const q = query({
840
+ prompt: 'Clean temporary files',
841
+ options: {
842
+ hooks: {
843
+ PreToolUse: [{
844
+ matcher: 'Bash', // Only match Bash tool
845
+ hooks: [
846
+ async (input, toolUseId) => {
847
+ console.log('About to execute command:', input.command);
848
+
849
+ // Can block execution
850
+ if (input.command.includes('rm')) {
851
+ return {
852
+ decision: 'block',
853
+ reason: 'Delete command blocked'
854
+ };
855
+ }
856
+
857
+ return { continue: true };
858
+ }
859
+ ]
860
+ }]
861
+ }
862
+ }
863
+ });
864
+ ```
865
+
866
+ ```python [Python]
867
+ from codebuddy_agent_sdk import HookMatcher, HookContext
868
+
869
+ async def pre_tool_hook(input_data, tool_use_id, context: HookContext):
870
+ print(f"About to execute command: {input_data.get('command')}")
871
+
872
+ # Can block execution
873
+ if "rm" in input_data.get("command", ""):
874
+ return {"continue_": False, "reason": "Delete command blocked"}
875
+
876
+ return {"continue_": True}
877
+
878
+ options = CodeBuddyAgentOptions(
879
+ hooks={
880
+ "PreToolUse": [
881
+ HookMatcher(matcher="Bash", hooks=[pre_tool_hook])
882
+ ]
883
+ }
884
+ )
885
+ ```
886
+
887
+ :::
888
+
889
+ ### Hook Event Types
890
+
891
+ | Event | Trigger Timing |
892
+ |-------|----------------|
893
+ | `PreToolUse` | Before tool execution |
894
+ | `PostToolUse` | After successful tool execution |
895
+ | `PostToolUseFailure` | After failed tool execution |
896
+ | `UserPromptSubmit` | User submits prompt |
897
+ | `SessionStart` | Session starts |
898
+ | `SessionEnd` | Session ends |
899
+ | `WorktreeCreate` | When creating an isolated `worktree` |
900
+ | `WorktreeRemove` | When removing an isolated `worktree` |
901
+
902
+ ## Extended Capabilities
903
+
904
+ ### Custom Agents
905
+
906
+ Define specialized sub-agents:
907
+
908
+ ::: code-group
909
+
910
+ ```typescript [TypeScript]
911
+ const q = query({
912
+ prompt: 'Use code-reviewer to review code',
913
+ options: {
914
+ agents: {
915
+ 'code-reviewer': {
916
+ description: 'Professional code review assistant',
917
+ tools: ['Read', 'Glob', 'Grep'], // Read-only
918
+ disallowedTools: ['Bash', 'Write', 'Edit'],
919
+ prompt: `You are a code review expert. Please check:
920
+ 1. Code standards
921
+ 2. Potential bugs
922
+ 3. Performance issues
923
+ 4. Security vulnerabilities`,
924
+ model: 'deepseek-v3.1'
925
+ }
926
+ }
927
+ }
928
+ });
929
+ ```
930
+
931
+ ```python [Python]
932
+ from codebuddy_agent_sdk import AgentDefinition
933
+
934
+ options = CodeBuddyAgentOptions(
935
+ agents={
936
+ "code-reviewer": AgentDefinition(
937
+ description="Professional code review assistant",
938
+ tools=["Read", "Glob", "Grep"], # Read-only
939
+ disallowed_tools=["Bash", "Write", "Edit"],
940
+ prompt="""You are a code review expert. Please check:
941
+ 1. Code standards
942
+ 2. Potential bugs
943
+ 3. Performance issues
944
+ 4. Security vulnerabilities""",
945
+ model="deepseek-v3.1"
946
+ )
947
+ }
948
+ )
949
+ ```
950
+
951
+ :::
952
+
953
+ ### MCP Server Configuration
954
+
955
+ Integrate custom MCP servers:
956
+
957
+ ::: code-group
958
+
959
+ ```typescript [TypeScript]
960
+ const q = query({
961
+ prompt: 'Query database',
962
+ options: {
963
+ mcpServers: {
964
+ 'database': {
965
+ type: 'stdio',
966
+ command: 'node',
967
+ args: ['./mcp-servers/db-server.js'],
968
+ env: {
969
+ DB_HOST: 'localhost',
970
+ DB_PORT: '5432'
971
+ }
972
+ }
973
+ }
974
+ }
975
+ });
976
+ ```
977
+
978
+ ```python [Python]
979
+ options = CodeBuddyAgentOptions(
980
+ mcp_servers={
981
+ "database": {
982
+ "type": "stdio",
983
+ "command": "node",
984
+ "args": ["./mcp-servers/db-server.js"],
985
+ "env": {
986
+ "DB_HOST": "localhost",
987
+ "DB_PORT": "5432"
988
+ }
989
+ }
990
+ }
991
+ )
992
+ ```
993
+
994
+ :::
995
+
996
+ ### Handling AskUserQuestion
997
+
998
+ AI may ask users questions through the `AskUserQuestion` tool, which can be handled in the permission callback:
999
+
1000
+ ::: code-group
1001
+
1002
+ ```typescript [TypeScript]
1003
+ const q = query({
1004
+ prompt: 'Configure database connection',
1005
+ options: {
1006
+ canUseTool: async (toolName, input) => {
1007
+ if (toolName === 'AskUserQuestion') {
1008
+ const questions = input.questions as any[];
1009
+ const answers: Record<string, string> = {};
1010
+
1011
+ for (const q of questions) {
1012
+ console.log(`Question: ${q.question}`);
1013
+ // Can integrate actual user interaction here
1014
+ answers[q.question] = q.options[0].label;
1015
+ }
1016
+
1017
+ return {
1018
+ behavior: 'allow',
1019
+ updatedInput: { ...input, answers }
1020
+ };
1021
+ }
1022
+ return { behavior: 'allow', updatedInput: input };
1023
+ }
1024
+ }
1025
+ });
1026
+ ```
1027
+
1028
+ ```python [Python]
1029
+ async def can_use_tool(tool_name, input_data, options):
1030
+ if tool_name == "AskUserQuestion":
1031
+ questions = input_data.get("questions", [])
1032
+ answers = {}
1033
+
1034
+ for q in questions:
1035
+ print(f"Question: {q['question']}")
1036
+ # Can integrate actual user interaction here
1037
+ answers[q["question"]] = q["options"][0]["label"]
1038
+
1039
+ return PermissionResultAllow(
1040
+ updated_input={**input_data, "answers": answers}
1041
+ )
1042
+
1043
+ return PermissionResultAllow(updated_input=input_data)
1044
+ ```
1045
+
1046
+ :::
1047
+
1048
+ ## Error Handling
1049
+
1050
+ ::: code-group
1051
+
1052
+ ```typescript [TypeScript]
1053
+ import { query, AbortError } from '@tencent-ai/agent-sdk';
1054
+
1055
+ try {
1056
+ const q = query({ prompt: '...' });
1057
+ for await (const message of q) {
1058
+ // ...
1059
+ }
1060
+ } catch (error) {
1061
+ if (error instanceof AbortError) {
1062
+ console.log('Operation aborted');
1063
+ } else {
1064
+ console.error('Error occurred:', error);
1065
+ }
1066
+ }
1067
+ ```
1068
+
1069
+ ```python [Python]
1070
+ from codebuddy_agent_sdk import (
1071
+ query, CodeBuddySDKError,
1072
+ CLIConnectionError, CLINotFoundError
1073
+ )
1074
+
1075
+ try:
1076
+ async for message in query(prompt="..."):
1077
+ pass
1078
+ except CLINotFoundError as e:
1079
+ print(f"CLI not found: {e}")
1080
+ except CLIConnectionError as e:
1081
+ print(f"Connection failed: {e}")
1082
+ except CodeBuddySDKError as e:
1083
+ print(f"SDK error: {e}")
1084
+ ```
1085
+
1086
+ :::
1087
+
1088
+ ## Best Practices
1089
+
1090
+ 1. **Permission Control**: In production environments, use `canUseTool` for fine-grained permissions, avoid using `bypassPermissions`
1091
+ 2. **Resource Limits**: Use `maxTurns` to limit execution scope and prevent unexpected resource consumption
1092
+ 3. **Error Handling**: Always handle error states in `result` messages
1093
+ 4. **Hook Timeouts**: Set reasonable timeout values for Hooks
1094
+
1095
+ ## Related Documentation
1096
+
1097
+ - [TypeScript SDK Reference](sdk-typescript.md) - Detailed TypeScript API reference
1098
+ - [Python SDK Reference](sdk-python.md) - Detailed Python API reference
1099
+ - [Hook Reference Guide](hooks.md) - Detailed Hook configuration instructions
1100
+ - [MCP Integration](mcp.md) - MCP server configuration guide
1101
+ - [Sub-Agent System](sub-agents.md) - Detailed sub-agent explanation
1102
+
1103
+ *CodeBuddy Agent SDK - Integrate AI programming capabilities into your applications*