@tencent-ai/agent-sdk 0.0.33 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/README.md +70 -7
  2. package/cli/CHANGELOG.md +2418 -0
  3. package/cli/LICENSE.txt +19 -0
  4. package/cli/README.md +26 -0
  5. package/cli/bin/codebuddy +39 -0
  6. package/cli/dist/codebuddy.js +20 -0
  7. package/cli/package.json +44 -0
  8. package/cli/product.cloudhosted.json +242 -0
  9. package/cli/product.internal.json +244 -0
  10. package/cli/product.ioa.json +467 -0
  11. package/cli/product.json +948 -0
  12. package/cli/product.selfhosted.json +196 -0
  13. package/cli/vendor/ripgrep/COPYING +3 -0
  14. package/cli/vendor/ripgrep/arm64-darwin/rg +0 -0
  15. package/cli/vendor/ripgrep/arm64-darwin/ripgrep.node +0 -0
  16. package/cli/vendor/ripgrep/arm64-linux/rg +0 -0
  17. package/cli/vendor/ripgrep/arm64-linux/ripgrep.node +0 -0
  18. package/cli/vendor/ripgrep/x64-darwin/rg +0 -0
  19. package/cli/vendor/ripgrep/x64-darwin/ripgrep.node +0 -0
  20. package/cli/vendor/ripgrep/x64-linux/rg +0 -0
  21. package/cli/vendor/ripgrep/x64-linux/ripgrep.node +0 -0
  22. package/cli/vendor/ripgrep/x64-win32/rg.exe +0 -0
  23. package/cli/vendor/ripgrep/x64-win32/ripgrep.node +0 -0
  24. package/lib/errors.d.ts +10 -0
  25. package/lib/errors.d.ts.map +1 -0
  26. package/lib/errors.js +17 -0
  27. package/lib/errors.js.map +1 -0
  28. package/lib/index.d.ts +36 -0
  29. package/lib/index.d.ts.map +1 -0
  30. package/lib/index.js +40 -0
  31. package/lib/index.js.map +1 -0
  32. package/lib/package.spec.js +3 -2
  33. package/lib/package.spec.js.map +1 -1
  34. package/lib/query.d.ts +46 -0
  35. package/lib/query.d.ts.map +1 -0
  36. package/lib/query.js +270 -0
  37. package/lib/query.js.map +1 -0
  38. package/lib/session.d.ts +53 -0
  39. package/lib/session.d.ts.map +1 -0
  40. package/lib/session.js +163 -0
  41. package/lib/session.js.map +1 -0
  42. package/lib/transport/index.d.ts +104 -0
  43. package/lib/transport/index.d.ts.map +1 -0
  44. package/lib/transport/index.js +20 -0
  45. package/lib/transport/index.js.map +1 -0
  46. package/lib/transport/process-transport.d.ts +65 -0
  47. package/lib/transport/process-transport.d.ts.map +1 -0
  48. package/lib/transport/process-transport.js +380 -0
  49. package/lib/transport/process-transport.js.map +1 -0
  50. package/lib/types.d.ts +603 -0
  51. package/lib/types.d.ts.map +1 -0
  52. package/lib/types.js +58 -0
  53. package/lib/types.js.map +1 -0
  54. package/lib/utils/cli-resolver.d.ts +36 -0
  55. package/lib/utils/cli-resolver.d.ts.map +1 -0
  56. package/lib/utils/cli-resolver.js +123 -0
  57. package/lib/utils/cli-resolver.js.map +1 -0
  58. package/lib/utils/env-utils.d.ts +9 -0
  59. package/lib/utils/env-utils.d.ts.map +1 -0
  60. package/lib/utils/env-utils.js +19 -0
  61. package/lib/utils/env-utils.js.map +1 -0
  62. package/lib/utils/index.d.ts +8 -0
  63. package/lib/utils/index.d.ts.map +1 -0
  64. package/lib/utils/index.js +17 -0
  65. package/lib/utils/index.js.map +1 -0
  66. package/lib/utils/process.d.ts +8 -0
  67. package/lib/utils/process.d.ts.map +1 -0
  68. package/lib/utils/process.js +16 -0
  69. package/lib/utils/process.js.map +1 -0
  70. package/lib/utils/stream.d.ts +24 -0
  71. package/lib/utils/stream.d.ts.map +1 -0
  72. package/lib/utils/stream.js +85 -0
  73. package/lib/utils/stream.js.map +1 -0
  74. package/package.json +21 -17
  75. package/dist/952.agent-sdk.js +0 -1
  76. package/dist/agent-sdk.js +0 -7
  77. package/lib/common/application-utils.d.ts +0 -5
  78. package/lib/common/application-utils.d.ts.map +0 -1
  79. package/lib/common/application-utils.js +0 -23
  80. package/lib/common/application-utils.js.map +0 -1
  81. package/lib/common/component-registry.d.ts +0 -10
  82. package/lib/common/component-registry.d.ts.map +0 -1
  83. package/lib/common/component-registry.js +0 -50
  84. package/lib/common/component-registry.js.map +0 -1
  85. package/lib/common/index.d.ts +0 -5
  86. package/lib/common/index.d.ts.map +0 -1
  87. package/lib/common/index.js +0 -21
  88. package/lib/common/index.js.map +0 -1
  89. package/lib/common/services/agent.d.ts +0 -12
  90. package/lib/common/services/agent.d.ts.map +0 -1
  91. package/lib/common/services/agent.js +0 -28
  92. package/lib/common/services/agent.js.map +0 -1
  93. package/lib/common/services/auth.d.ts +0 -59
  94. package/lib/common/services/auth.d.ts.map +0 -1
  95. package/lib/common/services/auth.js +0 -91
  96. package/lib/common/services/auth.js.map +0 -1
  97. package/lib/common/services/codebase.d.ts +0 -44
  98. package/lib/common/services/codebase.d.ts.map +0 -1
  99. package/lib/common/services/codebase.js +0 -87
  100. package/lib/common/services/codebase.js.map +0 -1
  101. package/lib/common/services/event.d.ts +0 -8
  102. package/lib/common/services/event.d.ts.map +0 -1
  103. package/lib/common/services/event.js +0 -18
  104. package/lib/common/services/event.js.map +0 -1
  105. package/lib/common/services/filepath.d.ts +0 -7
  106. package/lib/common/services/filepath.d.ts.map +0 -1
  107. package/lib/common/services/filepath.js +0 -16
  108. package/lib/common/services/filepath.js.map +0 -1
  109. package/lib/common/services/http.d.ts +0 -5
  110. package/lib/common/services/http.d.ts.map +0 -1
  111. package/lib/common/services/http.js +0 -12
  112. package/lib/common/services/http.js.map +0 -1
  113. package/lib/common/services/index.d.ts +0 -10
  114. package/lib/common/services/index.d.ts.map +0 -1
  115. package/lib/common/services/index.js +0 -26
  116. package/lib/common/services/index.js.map +0 -1
  117. package/lib/common/services/logger.d.ts +0 -7
  118. package/lib/common/services/logger.d.ts.map +0 -1
  119. package/lib/common/services/logger.js +0 -17
  120. package/lib/common/services/logger.js.map +0 -1
  121. package/lib/common/services/product.d.ts +0 -12
  122. package/lib/common/services/product.d.ts.map +0 -1
  123. package/lib/common/services/product.js +0 -29
  124. package/lib/common/services/product.js.map +0 -1
  125. package/lib/common/services/storage.d.ts +0 -7
  126. package/lib/common/services/storage.d.ts.map +0 -1
  127. package/lib/common/services/storage.js +0 -17
  128. package/lib/common/services/storage.js.map +0 -1
  129. package/lib/common/services/tracing.d.ts +0 -10
  130. package/lib/common/services/tracing.d.ts.map +0 -1
  131. package/lib/common/services/tracing.js +0 -29
  132. package/lib/common/services/tracing.js.map +0 -1
  133. package/lib/common/types/agents/agent.d.ts +0 -49
  134. package/lib/common/types/agents/agent.d.ts.map +0 -1
  135. package/lib/common/types/agents/agent.js +0 -9
  136. package/lib/common/types/agents/agent.js.map +0 -1
  137. package/lib/common/types/agents/ai.d.ts +0 -96
  138. package/lib/common/types/agents/ai.d.ts.map +0 -1
  139. package/lib/common/types/agents/ai.js +0 -3
  140. package/lib/common/types/agents/ai.js.map +0 -1
  141. package/lib/common/types/agents/completion.d.ts +0 -192
  142. package/lib/common/types/agents/completion.d.ts.map +0 -1
  143. package/lib/common/types/agents/completion.js +0 -4
  144. package/lib/common/types/agents/completion.js.map +0 -1
  145. package/lib/common/types/agents/conversation-manager.d.ts +0 -256
  146. package/lib/common/types/agents/conversation-manager.d.ts.map +0 -1
  147. package/lib/common/types/agents/conversation-manager.js +0 -3
  148. package/lib/common/types/agents/conversation-manager.js.map +0 -1
  149. package/lib/common/types/agents/craft-history.d.ts +0 -111
  150. package/lib/common/types/agents/craft-history.d.ts.map +0 -1
  151. package/lib/common/types/agents/craft-history.js +0 -3
  152. package/lib/common/types/agents/craft-history.js.map +0 -1
  153. package/lib/common/types/agents/craft.d.ts +0 -17
  154. package/lib/common/types/agents/craft.d.ts.map +0 -1
  155. package/lib/common/types/agents/craft.js +0 -3
  156. package/lib/common/types/agents/craft.js.map +0 -1
  157. package/lib/common/types/agents/file-tree.d.ts +0 -169
  158. package/lib/common/types/agents/file-tree.d.ts.map +0 -1
  159. package/lib/common/types/agents/file-tree.js +0 -17
  160. package/lib/common/types/agents/file-tree.js.map +0 -1
  161. package/lib/common/types/agents/index.d.ts +0 -10
  162. package/lib/common/types/agents/index.d.ts.map +0 -1
  163. package/lib/common/types/agents/index.js +0 -26
  164. package/lib/common/types/agents/index.js.map +0 -1
  165. package/lib/common/types/agents/run.d.ts +0 -133
  166. package/lib/common/types/agents/run.d.ts.map +0 -1
  167. package/lib/common/types/agents/run.js +0 -27
  168. package/lib/common/types/agents/run.js.map +0 -1
  169. package/lib/common/types/agents/tools.d.ts +0 -343
  170. package/lib/common/types/agents/tools.d.ts.map +0 -1
  171. package/lib/common/types/agents/tools.js +0 -67
  172. package/lib/common/types/agents/tools.js.map +0 -1
  173. package/lib/common/types/agents/user-reference.d.ts +0 -78
  174. package/lib/common/types/agents/user-reference.d.ts.map +0 -1
  175. package/lib/common/types/agents/user-reference.js +0 -3
  176. package/lib/common/types/agents/user-reference.js.map +0 -1
  177. package/lib/common/types/auth.d.ts +0 -73
  178. package/lib/common/types/auth.d.ts.map +0 -1
  179. package/lib/common/types/auth.js +0 -3
  180. package/lib/common/types/auth.js.map +0 -1
  181. package/lib/common/types/client-info.d.ts +0 -47
  182. package/lib/common/types/client-info.d.ts.map +0 -1
  183. package/lib/common/types/client-info.js +0 -3
  184. package/lib/common/types/client-info.js.map +0 -1
  185. package/lib/common/types/codebase.d.ts +0 -69
  186. package/lib/common/types/codebase.d.ts.map +0 -1
  187. package/lib/common/types/codebase.js +0 -3
  188. package/lib/common/types/codebase.js.map +0 -1
  189. package/lib/common/types/event/activity.d.ts +0 -5
  190. package/lib/common/types/event/activity.d.ts.map +0 -1
  191. package/lib/common/types/event/activity.js +0 -3
  192. package/lib/common/types/event/activity.js.map +0 -1
  193. package/lib/common/types/event/authentication.d.ts +0 -14
  194. package/lib/common/types/event/authentication.d.ts.map +0 -1
  195. package/lib/common/types/event/authentication.js +0 -9
  196. package/lib/common/types/event/authentication.js.map +0 -1
  197. package/lib/common/types/event/chat.d.ts +0 -48
  198. package/lib/common/types/event/chat.d.ts.map +0 -1
  199. package/lib/common/types/event/chat.js +0 -3
  200. package/lib/common/types/event/chat.js.map +0 -1
  201. package/lib/common/types/event/check-point.d.ts +0 -13
  202. package/lib/common/types/event/check-point.d.ts.map +0 -1
  203. package/lib/common/types/event/check-point.js +0 -3
  204. package/lib/common/types/event/check-point.js.map +0 -1
  205. package/lib/common/types/event/code.d.ts +0 -22
  206. package/lib/common/types/event/code.d.ts.map +0 -1
  207. package/lib/common/types/event/code.js +0 -14
  208. package/lib/common/types/event/code.js.map +0 -1
  209. package/lib/common/types/event/commit-message.d.ts +0 -25
  210. package/lib/common/types/event/commit-message.d.ts.map +0 -1
  211. package/lib/common/types/event/commit-message.js +0 -3
  212. package/lib/common/types/event/commit-message.js.map +0 -1
  213. package/lib/common/types/event/completion.d.ts +0 -313
  214. package/lib/common/types/event/completion.d.ts.map +0 -1
  215. package/lib/common/types/event/completion.js +0 -38
  216. package/lib/common/types/event/completion.js.map +0 -1
  217. package/lib/common/types/event/craft.d.ts +0 -256
  218. package/lib/common/types/event/craft.d.ts.map +0 -1
  219. package/lib/common/types/event/craft.js +0 -3
  220. package/lib/common/types/event/craft.js.map +0 -1
  221. package/lib/common/types/event/document.d.ts +0 -42
  222. package/lib/common/types/event/document.d.ts.map +0 -1
  223. package/lib/common/types/event/document.js +0 -3
  224. package/lib/common/types/event/document.js.map +0 -1
  225. package/lib/common/types/event/element.d.ts +0 -11
  226. package/lib/common/types/event/element.d.ts.map +0 -1
  227. package/lib/common/types/event/element.js +0 -3
  228. package/lib/common/types/event/element.js.map +0 -1
  229. package/lib/common/types/event/events.d.ts +0 -131
  230. package/lib/common/types/event/events.d.ts.map +0 -1
  231. package/lib/common/types/event/events.js +0 -88
  232. package/lib/common/types/event/events.js.map +0 -1
  233. package/lib/common/types/event/ide-event.d.ts +0 -44
  234. package/lib/common/types/event/ide-event.d.ts.map +0 -1
  235. package/lib/common/types/event/ide-event.js +0 -15
  236. package/lib/common/types/event/ide-event.js.map +0 -1
  237. package/lib/common/types/event/index.d.ts +0 -14
  238. package/lib/common/types/event/index.d.ts.map +0 -1
  239. package/lib/common/types/event/index.js +0 -30
  240. package/lib/common/types/event/index.js.map +0 -1
  241. package/lib/common/types/event/legacy-completion.d.ts +0 -196
  242. package/lib/common/types/event/legacy-completion.d.ts.map +0 -1
  243. package/lib/common/types/event/legacy-completion.js +0 -38
  244. package/lib/common/types/event/legacy-completion.js.map +0 -1
  245. package/lib/common/types/event/mcp.d.ts +0 -20
  246. package/lib/common/types/event/mcp.d.ts.map +0 -1
  247. package/lib/common/types/event/mcp.js +0 -3
  248. package/lib/common/types/event/mcp.js.map +0 -1
  249. package/lib/common/types/event/plugin-status.d.ts +0 -7
  250. package/lib/common/types/event/plugin-status.d.ts.map +0 -1
  251. package/lib/common/types/event/plugin-status.js +0 -3
  252. package/lib/common/types/event/plugin-status.js.map +0 -1
  253. package/lib/common/types/event/protocol.d.ts +0 -117
  254. package/lib/common/types/event/protocol.d.ts.map +0 -1
  255. package/lib/common/types/event/protocol.js +0 -5
  256. package/lib/common/types/event/protocol.js.map +0 -1
  257. package/lib/common/types/filepath.d.ts +0 -35
  258. package/lib/common/types/filepath.d.ts.map +0 -1
  259. package/lib/common/types/filepath.js +0 -3
  260. package/lib/common/types/filepath.js.map +0 -1
  261. package/lib/common/types/http.d.ts +0 -3
  262. package/lib/common/types/http.d.ts.map +0 -1
  263. package/lib/common/types/http.js +0 -3
  264. package/lib/common/types/http.js.map +0 -1
  265. package/lib/common/types/index.d.ts +0 -13
  266. package/lib/common/types/index.d.ts.map +0 -1
  267. package/lib/common/types/index.js +0 -29
  268. package/lib/common/types/index.js.map +0 -1
  269. package/lib/common/types/local-storage.d.ts +0 -26
  270. package/lib/common/types/local-storage.d.ts.map +0 -1
  271. package/lib/common/types/local-storage.js +0 -5
  272. package/lib/common/types/local-storage.js.map +0 -1
  273. package/lib/common/types/logger.d.ts +0 -10
  274. package/lib/common/types/logger.d.ts.map +0 -1
  275. package/lib/common/types/logger.js +0 -3
  276. package/lib/common/types/logger.js.map +0 -1
  277. package/lib/common/types/product/activities.d.ts +0 -5
  278. package/lib/common/types/product/activities.d.ts.map +0 -1
  279. package/lib/common/types/product/activities.js +0 -3
  280. package/lib/common/types/product/activities.js.map +0 -1
  281. package/lib/common/types/product/agent-tools.d.ts +0 -5
  282. package/lib/common/types/product/agent-tools.d.ts.map +0 -1
  283. package/lib/common/types/product/agent-tools.js +0 -3
  284. package/lib/common/types/product/agent-tools.js.map +0 -1
  285. package/lib/common/types/product/agent.d.ts +0 -45
  286. package/lib/common/types/product/agent.d.ts.map +0 -1
  287. package/lib/common/types/product/agent.js +0 -10
  288. package/lib/common/types/product/agent.js.map +0 -1
  289. package/lib/common/types/product/authentication.d.ts +0 -76
  290. package/lib/common/types/product/authentication.d.ts.map +0 -1
  291. package/lib/common/types/product/authentication.js +0 -28
  292. package/lib/common/types/product/authentication.js.map +0 -1
  293. package/lib/common/types/product/codebase.d.ts +0 -40
  294. package/lib/common/types/product/codebase.d.ts.map +0 -1
  295. package/lib/common/types/product/codebase.js +0 -3
  296. package/lib/common/types/product/codebase.js.map +0 -1
  297. package/lib/common/types/product/command.d.ts +0 -24
  298. package/lib/common/types/product/command.d.ts.map +0 -1
  299. package/lib/common/types/product/command.js +0 -3
  300. package/lib/common/types/product/command.js.map +0 -1
  301. package/lib/common/types/product/commit-message.d.ts +0 -7
  302. package/lib/common/types/product/commit-message.d.ts.map +0 -1
  303. package/lib/common/types/product/commit-message.js +0 -3
  304. package/lib/common/types/product/commit-message.js.map +0 -1
  305. package/lib/common/types/product/completion.d.ts +0 -35
  306. package/lib/common/types/product/completion.d.ts.map +0 -1
  307. package/lib/common/types/product/completion.js +0 -3
  308. package/lib/common/types/product/completion.js.map +0 -1
  309. package/lib/common/types/product/config.d.ts +0 -6
  310. package/lib/common/types/product/config.d.ts.map +0 -1
  311. package/lib/common/types/product/config.js +0 -3
  312. package/lib/common/types/product/config.js.map +0 -1
  313. package/lib/common/types/product/features.d.ts +0 -193
  314. package/lib/common/types/product/features.d.ts.map +0 -1
  315. package/lib/common/types/product/features.js +0 -198
  316. package/lib/common/types/product/features.js.map +0 -1
  317. package/lib/common/types/product/index.d.ts +0 -24
  318. package/lib/common/types/product/index.d.ts.map +0 -1
  319. package/lib/common/types/product/index.js +0 -40
  320. package/lib/common/types/product/index.js.map +0 -1
  321. package/lib/common/types/product/inline-chat.d.ts +0 -15
  322. package/lib/common/types/product/inline-chat.d.ts.map +0 -1
  323. package/lib/common/types/product/inline-chat.js +0 -3
  324. package/lib/common/types/product/inline-chat.js.map +0 -1
  325. package/lib/common/types/product/instruction.d.ts +0 -10
  326. package/lib/common/types/product/instruction.d.ts.map +0 -1
  327. package/lib/common/types/product/instruction.js +0 -8
  328. package/lib/common/types/product/instruction.js.map +0 -1
  329. package/lib/common/types/product/knowledge-base.d.ts +0 -16
  330. package/lib/common/types/product/knowledge-base.d.ts.map +0 -1
  331. package/lib/common/types/product/knowledge-base.js +0 -3
  332. package/lib/common/types/product/knowledge-base.js.map +0 -1
  333. package/lib/common/types/product/language-model.d.ts +0 -42
  334. package/lib/common/types/product/language-model.d.ts.map +0 -1
  335. package/lib/common/types/product/language-model.js +0 -3
  336. package/lib/common/types/product/language-model.js.map +0 -1
  337. package/lib/common/types/product/links.d.ts +0 -20
  338. package/lib/common/types/product/links.d.ts.map +0 -1
  339. package/lib/common/types/product/links.js +0 -3
  340. package/lib/common/types/product/links.js.map +0 -1
  341. package/lib/common/types/product/log.d.ts +0 -39
  342. package/lib/common/types/product/log.d.ts.map +0 -1
  343. package/lib/common/types/product/log.js +0 -12
  344. package/lib/common/types/product/log.js.map +0 -1
  345. package/lib/common/types/product/product-provider.d.ts +0 -12
  346. package/lib/common/types/product/product-provider.d.ts.map +0 -1
  347. package/lib/common/types/product/product-provider.js +0 -5
  348. package/lib/common/types/product/product-provider.js.map +0 -1
  349. package/lib/common/types/product/product.d.ts +0 -203
  350. package/lib/common/types/product/product.d.ts.map +0 -1
  351. package/lib/common/types/product/product.js +0 -19
  352. package/lib/common/types/product/product.js.map +0 -1
  353. package/lib/common/types/product/prompt-template.d.ts +0 -6
  354. package/lib/common/types/product/prompt-template.d.ts.map +0 -1
  355. package/lib/common/types/product/prompt-template.js +0 -3
  356. package/lib/common/types/product/prompt-template.js.map +0 -1
  357. package/lib/common/types/product/remote-agent.d.ts +0 -20
  358. package/lib/common/types/product/remote-agent.d.ts.map +0 -1
  359. package/lib/common/types/product/remote-agent.js +0 -3
  360. package/lib/common/types/product/remote-agent.js.map +0 -1
  361. package/lib/common/types/product/replacement.d.ts +0 -38
  362. package/lib/common/types/product/replacement.d.ts.map +0 -1
  363. package/lib/common/types/product/replacement.js +0 -18
  364. package/lib/common/types/product/replacement.js.map +0 -1
  365. package/lib/common/types/product/telemetry.d.ts +0 -22
  366. package/lib/common/types/product/telemetry.d.ts.map +0 -1
  367. package/lib/common/types/product/telemetry.js +0 -3
  368. package/lib/common/types/product/telemetry.js.map +0 -1
  369. package/lib/common/types/product/updates.d.ts +0 -17
  370. package/lib/common/types/product/updates.d.ts.map +0 -1
  371. package/lib/common/types/product/updates.js +0 -8
  372. package/lib/common/types/product/updates.js.map +0 -1
  373. package/lib/common/types/protocol.d.ts +0 -31
  374. package/lib/common/types/protocol.d.ts.map +0 -1
  375. package/lib/common/types/protocol.js +0 -10
  376. package/lib/common/types/protocol.js.map +0 -1
  377. package/lib/common/types/tracing.d.ts +0 -74
  378. package/lib/common/types/tracing.d.ts.map +0 -1
  379. package/lib/common/types/tracing.js +0 -3
  380. package/lib/common/types/tracing.js.map +0 -1
  381. package/lib/common/utils.d.ts +0 -3
  382. package/lib/common/utils.d.ts.map +0 -1
  383. package/lib/common/utils.js +0 -10
  384. package/lib/common/utils.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ /**
2
+ * CLI Resolver
3
+ *
4
+ * Resolves the path to the CodeBuddy CLI.
5
+ * Supports multiple resolution strategies:
6
+ * 1. Environment variable (CODEBUDDY_CODE_PATH)
7
+ * 2. Bundled CLI in package's cli/ directory
8
+ * 3. Monorepo development path (fallback)
9
+ */
10
+ /**
11
+ * Error thrown when CLI cannot be found.
12
+ */
13
+ export declare class CLINotFoundError extends Error {
14
+ readonly platform: string;
15
+ readonly arch: string;
16
+ constructor(message: string, platform: string, arch: string);
17
+ }
18
+ /**
19
+ * Resolve the path to the CodeBuddy CLI.
20
+ *
21
+ * Resolution order:
22
+ * 1. CODEBUDDY_CODE_PATH environment variable
23
+ * 2. Bundled CLI in package's cli/ directory
24
+ * 3. Monorepo development path
25
+ *
26
+ * @returns The absolute path to the CLI
27
+ * @throws CLINotFoundError if the CLI cannot be found
28
+ */
29
+ export declare function resolveCLIPath(): string;
30
+ /**
31
+ * Check if CLI is available without throwing.
32
+ *
33
+ * @returns The CLI path if found, null otherwise
34
+ */
35
+ export declare function tryCLIPath(): string | null;
36
+ //# sourceMappingURL=cli-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/cli-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAeH;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;aAGnB,QAAQ,EAAE,MAAM;aAChB,IAAI,EAAE,MAAM;gBAF5B,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM;CAKnC;AAuCD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAuCvC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAM1C"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ /**
3
+ * CLI Resolver
4
+ *
5
+ * Resolves the path to the CodeBuddy CLI.
6
+ * Supports multiple resolution strategies:
7
+ * 1. Environment variable (CODEBUDDY_CODE_PATH)
8
+ * 2. Bundled CLI in package's cli/ directory
9
+ * 3. Monorepo development path (fallback)
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CLINotFoundError = void 0;
13
+ exports.resolveCLIPath = resolveCLIPath;
14
+ exports.tryCLIPath = tryCLIPath;
15
+ const os_1 = require("os");
16
+ const path_1 = require("path");
17
+ const fs_1 = require("fs");
18
+ /**
19
+ * Binary name per platform.
20
+ */
21
+ const BINARY_NAMES = {
22
+ win32: 'codebuddy.exe',
23
+ darwin: 'codebuddy',
24
+ linux: 'codebuddy',
25
+ };
26
+ /**
27
+ * Error thrown when CLI cannot be found.
28
+ */
29
+ class CLINotFoundError extends Error {
30
+ constructor(message, platform, arch) {
31
+ super(message);
32
+ this.platform = platform;
33
+ this.arch = arch;
34
+ this.name = 'CLINotFoundError';
35
+ }
36
+ }
37
+ exports.CLINotFoundError = CLINotFoundError;
38
+ /**
39
+ * Try to resolve CLI path from bundled cli/ directory.
40
+ * The SDK package bundles the CLI in its cli/ directory.
41
+ */
42
+ function resolveFromBundled() {
43
+ // The bundled CLI is at: package-root/cli/bin/codebuddy
44
+ // __dirname is lib/utils, so we go up to package root
45
+ const bundledBinPath = (0, path_1.resolve)(__dirname, '../../cli/bin/codebuddy');
46
+ if ((0, fs_1.existsSync)(bundledBinPath)) {
47
+ return bundledBinPath;
48
+ }
49
+ return null;
50
+ }
51
+ /**
52
+ * Try to resolve CLI path from monorepo development structure.
53
+ */
54
+ function resolveFromMonorepo() {
55
+ // Try relative to this package (agent-sdk-js -> agent-cli)
56
+ // First try the bin script (for Node.js execution)
57
+ const binScriptPath = (0, path_1.resolve)(__dirname, '../../../agent-cli/bin/codebuddy');
58
+ if ((0, fs_1.existsSync)(binScriptPath)) {
59
+ return binScriptPath;
60
+ }
61
+ // Fall back to looking for compiled binary in dist
62
+ const binaryName = BINARY_NAMES[(0, os_1.platform)()] || 'codebuddy';
63
+ const distPath = (0, path_1.resolve)(__dirname, '../../../agent-cli/dist', binaryName);
64
+ if ((0, fs_1.existsSync)(distPath)) {
65
+ return distPath;
66
+ }
67
+ return null;
68
+ }
69
+ /**
70
+ * Resolve the path to the CodeBuddy CLI.
71
+ *
72
+ * Resolution order:
73
+ * 1. CODEBUDDY_CODE_PATH environment variable
74
+ * 2. Bundled CLI in package's cli/ directory
75
+ * 3. Monorepo development path
76
+ *
77
+ * @returns The absolute path to the CLI
78
+ * @throws CLINotFoundError if the CLI cannot be found
79
+ */
80
+ function resolveCLIPath() {
81
+ const currentPlatform = (0, os_1.platform)();
82
+ const currentArch = process.arch;
83
+ // 1. Environment variable takes precedence
84
+ const envPath = process.env.CODEBUDDY_CODE_PATH;
85
+ if (envPath) {
86
+ if ((0, fs_1.existsSync)(envPath)) {
87
+ return envPath;
88
+ }
89
+ // Warn but continue to try other methods
90
+ console.warn(`Warning: CODEBUDDY_CODE_PATH is set to "${envPath}" but file does not exist. ` +
91
+ 'Falling back to other resolution methods.');
92
+ }
93
+ // 2. Try bundled CLI
94
+ const bundledPath = resolveFromBundled();
95
+ if (bundledPath) {
96
+ return bundledPath;
97
+ }
98
+ // 3. Try monorepo development path
99
+ const monorepoPath = resolveFromMonorepo();
100
+ if (monorepoPath) {
101
+ return monorepoPath;
102
+ }
103
+ // 4. Nothing found - throw helpful error
104
+ throw new CLINotFoundError(`CodeBuddy CLI not found.\n\n` +
105
+ `Possible solutions:\n` +
106
+ ` 1. Reinstall the SDK package:\n` +
107
+ ` npm install @tencent-ai/agent-sdk\n\n` +
108
+ ` 2. Set CODEBUDDY_CODE_PATH environment variable to the CLI path\n`, currentPlatform, currentArch);
109
+ }
110
+ /**
111
+ * Check if CLI is available without throwing.
112
+ *
113
+ * @returns The CLI path if found, null otherwise
114
+ */
115
+ function tryCLIPath() {
116
+ try {
117
+ return resolveCLIPath();
118
+ }
119
+ catch (_a) {
120
+ return null;
121
+ }
122
+ }
123
+ //# sourceMappingURL=cli-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-resolver.js","sourceRoot":"","sources":["../../src/utils/cli-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA6EH,wCAuCC;AAOD,gCAMC;AA/HD,2BAA8B;AAC9B,+BAA+B;AAC/B,2BAAgC;AAEhC;;GAEG;AACH,MAAM,YAAY,GAA2B;IACzC,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,WAAW;CACrB,CAAC;AAEF;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IACvC,YACI,OAAe,EACC,QAAgB,EAChB,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACnC,CAAC;CACJ;AATD,4CASC;AAED;;;GAGG;AACH,SAAS,kBAAkB;IACvB,wDAAwD;IACxD,sDAAsD;IACtD,MAAM,cAAc,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;IAErE,IAAI,IAAA,eAAU,EAAC,cAAc,CAAC,EAAE,CAAC;QAC7B,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB;IACxB,2DAA2D;IAC3D,mDAAmD;IACnD,MAAM,aAAa,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC;IAC7E,IAAI,IAAA,eAAU,EAAC,aAAa,CAAC,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,mDAAmD;IACnD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAA,aAAQ,GAAE,CAAC,IAAI,WAAW,CAAC;IAC3D,MAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,yBAAyB,EAAE,UAAU,CAAC,CAAC;IAC3E,IAAI,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,cAAc;IAC1B,MAAM,eAAe,GAAG,IAAA,aAAQ,GAAE,CAAC;IACnC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjC,2CAA2C;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChD,IAAI,OAAO,EAAE,CAAC;QACV,IAAI,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACtB,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,yCAAyC;QACzC,OAAO,CAAC,IAAI,CACR,2CAA2C,OAAO,6BAA6B;YAC/E,2CAA2C,CAC9C,CAAC;IACN,CAAC;IAED,qBAAqB;IACrB,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;IACzC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,mCAAmC;IACnC,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAC;IAC3C,IAAI,YAAY,EAAE,CAAC;QACf,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,yCAAyC;IACzC,MAAM,IAAI,gBAAgB,CACtB,8BAA8B;QAC9B,uBAAuB;QACvB,mCAAmC;QACnC,4CAA4C;QAC5C,qEAAqE,EACrE,eAAe,EACf,WAAW,CACd,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU;IACtB,IAAI,CAAC;QACD,OAAO,cAAc,EAAE,CAAC;IAC5B,CAAC;IAAC,WAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Environment variable utilities.
3
+ */
4
+ /**
5
+ * Check if an environment variable value is truthy.
6
+ * Accepts: '1', 'true', 'yes', 'on' (case-insensitive)
7
+ */
8
+ export declare function isEnvTruthy(envVar: string | boolean | undefined): boolean;
9
+ //# sourceMappingURL=env-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-utils.d.ts","sourceRoot":"","sources":["../../src/utils/env-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAKzE"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Environment variable utilities.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isEnvTruthy = isEnvTruthy;
7
+ /**
8
+ * Check if an environment variable value is truthy.
9
+ * Accepts: '1', 'true', 'yes', 'on' (case-insensitive)
10
+ */
11
+ function isEnvTruthy(envVar) {
12
+ if (!envVar)
13
+ return false;
14
+ if (typeof envVar === 'boolean')
15
+ return envVar;
16
+ const normalizedValue = envVar.toLowerCase().trim();
17
+ return ['1', 'true', 'yes', 'on'].includes(normalizedValue);
18
+ }
19
+ //# sourceMappingURL=env-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env-utils.js","sourceRoot":"","sources":["../../src/utils/env-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAMH,kCAKC;AATD;;;GAGG;AACH,SAAgB,WAAW,CAAC,MAAoC;IAC5D,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,OAAO,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAC/C,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IACpD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Utility exports
3
+ */
4
+ export { Stream } from './stream';
5
+ export { writeToStderr } from './process';
6
+ export { isEnvTruthy } from './env-utils';
7
+ export { resolveCLIPath, tryCLIPath, CLINotFoundError } from './cli-resolver';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLINotFoundError = exports.tryCLIPath = exports.resolveCLIPath = exports.isEnvTruthy = exports.writeToStderr = exports.Stream = void 0;
4
+ /**
5
+ * Utility exports
6
+ */
7
+ var stream_1 = require("./stream");
8
+ Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return stream_1.Stream; } });
9
+ var process_1 = require("./process");
10
+ Object.defineProperty(exports, "writeToStderr", { enumerable: true, get: function () { return process_1.writeToStderr; } });
11
+ var env_utils_1 = require("./env-utils");
12
+ Object.defineProperty(exports, "isEnvTruthy", { enumerable: true, get: function () { return env_utils_1.isEnvTruthy; } });
13
+ var cli_resolver_1 = require("./cli-resolver");
14
+ Object.defineProperty(exports, "resolveCLIPath", { enumerable: true, get: function () { return cli_resolver_1.resolveCLIPath; } });
15
+ Object.defineProperty(exports, "tryCLIPath", { enumerable: true, get: function () { return cli_resolver_1.tryCLIPath; } });
16
+ Object.defineProperty(exports, "CLINotFoundError", { enumerable: true, get: function () { return cli_resolver_1.CLINotFoundError; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,+CAA8E;AAArE,8GAAA,cAAc,OAAA;AAAE,0GAAA,UAAU,OAAA;AAAE,gHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Process utilities for safe I/O operations.
3
+ */
4
+ /**
5
+ * Write data to stderr in chunks to avoid buffer overflow.
6
+ */
7
+ export declare function writeToStderr(data: string): void;
8
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAIhD"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Process utilities for safe I/O operations.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.writeToStderr = writeToStderr;
7
+ const CHUNK_SIZE = 2000;
8
+ /**
9
+ * Write data to stderr in chunks to avoid buffer overflow.
10
+ */
11
+ function writeToStderr(data) {
12
+ for (let i = 0; i < data.length; i += CHUNK_SIZE) {
13
+ process.stderr.write(data.substring(i, i + CHUNK_SIZE));
14
+ }
15
+ }
16
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAOH,sCAIC;AATD,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAY;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC;QAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Stream - A clean AsyncGenerator implementation with queue support.
3
+ *
4
+ * Provides a simple way to create async iterables that can be
5
+ * fed values from external sources (like process stdout).
6
+ */
7
+ export declare class Stream<T, TReturn = void> implements AsyncGenerator<T, TReturn, unknown> {
8
+ private returned?;
9
+ private queue;
10
+ private readResolve?;
11
+ private readReject?;
12
+ private isDone;
13
+ private hasError?;
14
+ private started;
15
+ constructor(returned?: () => void);
16
+ [Symbol.asyncIterator](): AsyncGenerator<T, TReturn, unknown>;
17
+ next(): Promise<IteratorResult<T, TReturn>>;
18
+ enqueue(value: T): void;
19
+ done(): void;
20
+ error(error: Error): void;
21
+ return(): Promise<IteratorResult<T, TReturn>>;
22
+ throw(e?: Error): Promise<IteratorResult<T, TReturn>>;
23
+ }
24
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CACjC,YAAW,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;IAE9C,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,WAAW,CAAC,CAA+C;IACnE,OAAO,CAAC,UAAU,CAAC,CAAyB;IAC5C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAC,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAS;gBAEZ,QAAQ,CAAC,EAAE,MAAM,IAAI;IAIjC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;IAQ7D,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAsB3C,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAWvB,IAAI,IAAI,IAAI;IAUZ,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAUzB,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAQ7C,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAKxD"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stream = void 0;
4
+ /**
5
+ * Stream - A clean AsyncGenerator implementation with queue support.
6
+ *
7
+ * Provides a simple way to create async iterables that can be
8
+ * fed values from external sources (like process stdout).
9
+ */
10
+ class Stream {
11
+ constructor(returned) {
12
+ this.queue = [];
13
+ this.isDone = false;
14
+ this.started = false;
15
+ this.returned = returned;
16
+ }
17
+ [Symbol.asyncIterator]() {
18
+ if (this.started) {
19
+ throw new Error('Stream can only be iterated once');
20
+ }
21
+ this.started = true;
22
+ return this;
23
+ }
24
+ next() {
25
+ if (this.queue.length > 0) {
26
+ return Promise.resolve({
27
+ done: false,
28
+ value: this.queue.shift(),
29
+ });
30
+ }
31
+ if (this.isDone) {
32
+ return Promise.resolve({ done: true, value: undefined });
33
+ }
34
+ if (this.hasError) {
35
+ return Promise.reject(this.hasError);
36
+ }
37
+ return new Promise((resolve, reject) => {
38
+ this.readResolve = resolve;
39
+ this.readReject = reject;
40
+ });
41
+ }
42
+ enqueue(value) {
43
+ if (this.readResolve) {
44
+ const resolve = this.readResolve;
45
+ this.readResolve = undefined;
46
+ this.readReject = undefined;
47
+ resolve({ done: false, value });
48
+ }
49
+ else {
50
+ this.queue.push(value);
51
+ }
52
+ }
53
+ done() {
54
+ this.isDone = true;
55
+ if (this.readResolve) {
56
+ const resolve = this.readResolve;
57
+ this.readResolve = undefined;
58
+ this.readReject = undefined;
59
+ resolve({ done: true, value: undefined });
60
+ }
61
+ }
62
+ error(error) {
63
+ this.hasError = error;
64
+ if (this.readReject) {
65
+ const reject = this.readReject;
66
+ this.readResolve = undefined;
67
+ this.readReject = undefined;
68
+ reject(error);
69
+ }
70
+ }
71
+ return() {
72
+ this.isDone = true;
73
+ if (this.returned) {
74
+ this.returned();
75
+ }
76
+ return Promise.resolve({ done: true, value: undefined });
77
+ }
78
+ throw(e) {
79
+ this.hasError = e;
80
+ this.isDone = true;
81
+ return Promise.reject(e);
82
+ }
83
+ }
84
+ exports.Stream = Stream;
85
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,25 +1,29 @@
1
1
  {
2
2
  "name": "@tencent-ai/agent-sdk",
3
- "version": "0.0.33",
4
- "description": "Tencent AI Agent SDK",
5
- "main": "./dist/agent-sdk.js",
6
- "typings": "lib/common/index.d.ts",
7
- "license": "MIT",
8
- "dependencies": {
9
- "axios": "^1.8.2",
10
- "rxjs": "^6.6.0"
11
- },
12
- "publishConfig": {
13
- "access": "public"
3
+ "version": "0.1.0",
4
+ "description": "CodeBuddy Code SDK for JavaScript/TypeScript",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./lib/index.d.ts",
10
+ "import": "./lib/index.js",
11
+ "require": "./lib/index.js"
12
+ }
14
13
  },
15
- "keywords": [
16
- "agent-sdk"
17
- ],
14
+ "license": "MIT",
18
15
  "files": [
19
- "dist",
20
- "lib"
16
+ "lib",
17
+ "cli"
18
+ ],
19
+ "keywords": [
20
+ "agent-sdk",
21
+ "codebuddy-code"
21
22
  ],
22
23
  "scripts": {},
24
+ "dependencies": {},
23
25
  "devDependencies": {},
24
- "gitHead": "37ea19db9c246b9656da491092ce2aa2cb98f4f6"
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
25
29
  }
@@ -1 +0,0 @@
1
- "use strict";exports.id=952,exports.ids=[952],exports.modules={26952:(e,t,n)=>{n.d(t,{toFormData:()=>toFormData});var a=n(48695),r=n(79814);let i=0;const o={START_BOUNDARY:i++,HEADER_FIELD_START:i++,HEADER_FIELD:i++,HEADER_VALUE_START:i++,HEADER_VALUE:i++,HEADER_VALUE_ALMOST_DONE:i++,HEADERS_ALMOST_DONE:i++,PART_DATA_START:i++,PART_DATA:i++,END:i++};let s=1;const d=s,E=s*=2,lower=e=>32|e,noop=()=>{};class MultipartParser{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=noop,this.onHeaderField=noop,this.onHeadersEnd=noop,this.onHeaderValue=noop,this.onPartBegin=noop,this.onPartData=noop,this.onPartEnd=noop,this.boundaryChars={},e="\r\n--"+e;const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=o.START_BOUNDARY}write(e){let t=0;const n=e.length;let a=this.index,{lookbehind:r,boundary:i,boundaryChars:s,index:A,state:h,flags:l}=this;const D=this.boundary.length,c=D-1,f=e.length;let T,_;const mark=e=>{this[e+"Mark"]=t},clear=e=>{delete this[e+"Mark"]},callback=(e,t,n,a)=>{void 0!==t&&t===n||this[e](a&&a.subarray(t,n))},dataCallback=(n,a)=>{const r=n+"Mark";r in this&&(a?(callback(n,this[r],t,e),delete this[r]):(callback(n,this[r],e.length,e),this[r]=0))};for(t=0;t<n;t++)switch(T=e[t],h){case o.START_BOUNDARY:if(A===i.length-2){if(45===T)l|=E;else if(13!==T)return;A++;break}if(A-1==i.length-2){if(l&E&&45===T)h=o.END,l=0;else{if(l&E||10!==T)return;A=0,callback("onPartBegin"),h=o.HEADER_FIELD_START}break}T!==i[A+2]&&(A=-2),T===i[A+2]&&A++;break;case o.HEADER_FIELD_START:h=o.HEADER_FIELD,mark("onHeaderField"),A=0;case o.HEADER_FIELD:if(13===T){clear("onHeaderField"),h=o.HEADERS_ALMOST_DONE;break}if(A++,45===T)break;if(58===T){if(1===A)return;dataCallback("onHeaderField",!0),h=o.HEADER_VALUE_START;break}if(_=lower(T),_<97||_>122)return;break;case o.HEADER_VALUE_START:if(32===T)break;mark("onHeaderValue"),h=o.HEADER_VALUE;case o.HEADER_VALUE:13===T&&(dataCallback("onHeaderValue",!0),callback("onHeaderEnd"),h=o.HEADER_VALUE_ALMOST_DONE);break;case o.HEADER_VALUE_ALMOST_DONE:if(10!==T)return;h=o.HEADER_FIELD_START;break;case o.HEADERS_ALMOST_DONE:if(10!==T)return;callback("onHeadersEnd"),h=o.PART_DATA_START;break;case o.PART_DATA_START:h=o.PART_DATA,mark("onPartData");case o.PART_DATA:if(a=A,0===A){for(t+=c;t<f&&!(e[t]in s);)t+=D;t-=c,T=e[t]}if(A<i.length)i[A]===T?(0===A&&dataCallback("onPartData",!0),A++):A=0;else if(A===i.length)A++,13===T?l|=d:45===T?l|=E:A=0;else if(A-1===i.length)if(l&d){if(A=0,10===T){l&=~d,callback("onPartEnd"),callback("onPartBegin"),h=o.HEADER_FIELD_START;break}}else l&E&&45===T?(callback("onPartEnd"),h=o.END,l=0):A=0;if(A>0)r[A-1]=T;else if(a>0){const e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);callback("onPartData",0,a,e),a=0,mark("onPartData"),t--}break;case o.END:break;default:throw new Error(`Unexpected state entered: ${h}`)}dataCallback("onHeaderField"),dataCallback("onHeaderValue"),dataCallback("onPartData"),this.index=A,this.state=h,this.flags=l}end(){if(this.state===o.HEADER_FIELD_START&&0===this.index||this.state===o.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==o.END)throw new Error("MultipartParser.end(): stream ended unexpectedly")}}async function toFormData(e,t){if(!/multipart/i.test(t))throw new TypeError("Failed to fetch");const n=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new TypeError("no or bad content-type header, no multipart boundary");const i=new MultipartParser(n[1]||n[2]);let o,s,d,E,A,h;const l=[],D=new r.fS,onPartData=e=>{d+=c.decode(e,{stream:!0})},appendToFile=e=>{l.push(e)},appendFileToFormData=()=>{const e=new a.ZH(l,h,{type:A});D.append(E,e)},appendEntryToFormData=()=>{D.append(E,d)},c=new TextDecoder("utf-8");c.decode(),i.onPartBegin=function(){i.onPartData=onPartData,i.onPartEnd=appendEntryToFormData,o="",s="",d="",E="",A="",h=null,l.length=0},i.onHeaderField=function(e){o+=c.decode(e,{stream:!0})},i.onHeaderValue=function(e){s+=c.decode(e,{stream:!0})},i.onHeaderEnd=function(){if(s+=c.decode(),o=o.toLowerCase(),"content-disposition"===o){const e=s.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(E=e[2]||e[3]||""),h=function _fileName(e){const t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;const n=t[2]||t[3]||"";let a=n.slice(n.lastIndexOf("\\")+1);return a=a.replace(/%22/g,'"'),a=a.replace(/&#(\d{4});/g,((e,t)=>String.fromCharCode(t))),a}(s),h&&(i.onPartData=appendToFile,i.onPartEnd=appendFileToFormData)}else"content-type"===o&&(A=s);s="",o=""};for await(const t of e)i.write(t);return i.end(),D}}};