@defai.digital/ax-cli 4.4.6 → 4.4.10

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 (802) hide show
  1. package/bin/ax-cli +1 -5
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +158 -9
  4. package/dist/index.js.map +1 -1
  5. package/dist/setup.d.ts +27 -0
  6. package/dist/setup.d.ts.map +1 -0
  7. package/dist/setup.js +591 -0
  8. package/dist/setup.js.map +1 -0
  9. package/package.json +43 -135
  10. package/LICENSE +0 -22
  11. package/README.md +0 -387
  12. package/config-defaults/messages.yaml +0 -75
  13. package/config-defaults/models.yaml +0 -57
  14. package/config-defaults/prompts.yaml +0 -948
  15. package/config-defaults/settings.yaml +0 -157
  16. package/dist/agent/agent-executor.d.ts +0 -61
  17. package/dist/agent/agent-executor.js +0 -194
  18. package/dist/agent/agent-executor.js.map +0 -1
  19. package/dist/agent/agent-router.d.ts +0 -68
  20. package/dist/agent/agent-router.js +0 -242
  21. package/dist/agent/agent-router.js.map +0 -1
  22. package/dist/agent/context-manager.d.ts +0 -122
  23. package/dist/agent/context-manager.js +0 -406
  24. package/dist/agent/context-manager.js.map +0 -1
  25. package/dist/agent/core/index.d.ts +0 -8
  26. package/dist/agent/core/index.js +0 -9
  27. package/dist/agent/core/index.js.map +0 -1
  28. package/dist/agent/core/types.d.ts +0 -92
  29. package/dist/agent/core/types.js +0 -11
  30. package/dist/agent/core/types.js.map +0 -1
  31. package/dist/agent/dependency-resolver.d.ts +0 -90
  32. package/dist/agent/dependency-resolver.js +0 -366
  33. package/dist/agent/dependency-resolver.js.map +0 -1
  34. package/dist/agent/execution/index.d.ts +0 -9
  35. package/dist/agent/execution/index.js +0 -9
  36. package/dist/agent/execution/index.js.map +0 -1
  37. package/dist/agent/execution/tool-executor.d.ts +0 -93
  38. package/dist/agent/execution/tool-executor.js +0 -552
  39. package/dist/agent/execution/tool-executor.js.map +0 -1
  40. package/dist/agent/index.d.ts +0 -14
  41. package/dist/agent/index.js +0 -145
  42. package/dist/agent/index.js.map +0 -1
  43. package/dist/agent/llm-agent.d.ts +0 -368
  44. package/dist/agent/llm-agent.js +0 -1931
  45. package/dist/agent/llm-agent.js.map +0 -1
  46. package/dist/agent/loop-detector.d.ts +0 -72
  47. package/dist/agent/loop-detector.js +0 -335
  48. package/dist/agent/loop-detector.js.map +0 -1
  49. package/dist/agent/parallel-tools.d.ts +0 -69
  50. package/dist/agent/parallel-tools.js +0 -188
  51. package/dist/agent/parallel-tools.js.map +0 -1
  52. package/dist/agent/planning/index.d.ts +0 -9
  53. package/dist/agent/planning/index.js +0 -9
  54. package/dist/agent/planning/index.js.map +0 -1
  55. package/dist/agent/planning/plan-executor.d.ts +0 -79
  56. package/dist/agent/planning/plan-executor.js +0 -240
  57. package/dist/agent/planning/plan-executor.js.map +0 -1
  58. package/dist/agent/progress-tracker.d.ts +0 -94
  59. package/dist/agent/progress-tracker.js +0 -225
  60. package/dist/agent/progress-tracker.js.map +0 -1
  61. package/dist/agent/specialized/analysis-agent.d.ts +0 -11
  62. package/dist/agent/specialized/analysis-agent.js +0 -24
  63. package/dist/agent/specialized/analysis-agent.js.map +0 -1
  64. package/dist/agent/specialized/debug-agent.d.ts +0 -11
  65. package/dist/agent/specialized/debug-agent.js +0 -46
  66. package/dist/agent/specialized/debug-agent.js.map +0 -1
  67. package/dist/agent/specialized/documentation-agent.d.ts +0 -11
  68. package/dist/agent/specialized/documentation-agent.js +0 -24
  69. package/dist/agent/specialized/documentation-agent.js.map +0 -1
  70. package/dist/agent/specialized/index.d.ts +0 -11
  71. package/dist/agent/specialized/index.js +0 -12
  72. package/dist/agent/specialized/index.js.map +0 -1
  73. package/dist/agent/specialized/performance-agent.d.ts +0 -11
  74. package/dist/agent/specialized/performance-agent.js +0 -24
  75. package/dist/agent/specialized/performance-agent.js.map +0 -1
  76. package/dist/agent/specialized/refactoring-agent.d.ts +0 -11
  77. package/dist/agent/specialized/refactoring-agent.js +0 -24
  78. package/dist/agent/specialized/refactoring-agent.js.map +0 -1
  79. package/dist/agent/specialized/testing-agent.d.ts +0 -11
  80. package/dist/agent/specialized/testing-agent.js +0 -24
  81. package/dist/agent/specialized/testing-agent.js.map +0 -1
  82. package/dist/agent/status-reporter.d.ts +0 -114
  83. package/dist/agent/status-reporter.js +0 -335
  84. package/dist/agent/status-reporter.js.map +0 -1
  85. package/dist/agent/streaming/index.d.ts +0 -9
  86. package/dist/agent/streaming/index.js +0 -9
  87. package/dist/agent/streaming/index.js.map +0 -1
  88. package/dist/agent/streaming/stream-handler.d.ts +0 -62
  89. package/dist/agent/streaming/stream-handler.js +0 -217
  90. package/dist/agent/streaming/stream-handler.js.map +0 -1
  91. package/dist/agent/subagent-orchestrator.d.ts +0 -166
  92. package/dist/agent/subagent-orchestrator.js +0 -487
  93. package/dist/agent/subagent-orchestrator.js.map +0 -1
  94. package/dist/agent/subagent-types.d.ts +0 -261
  95. package/dist/agent/subagent-types.js +0 -257
  96. package/dist/agent/subagent-types.js.map +0 -1
  97. package/dist/agent/subagent.d.ts +0 -116
  98. package/dist/agent/subagent.js +0 -507
  99. package/dist/agent/subagent.js.map +0 -1
  100. package/dist/checkpoint/index.d.ts +0 -9
  101. package/dist/checkpoint/index.js +0 -11
  102. package/dist/checkpoint/index.js.map +0 -1
  103. package/dist/checkpoint/manager.d.ts +0 -101
  104. package/dist/checkpoint/manager.js +0 -407
  105. package/dist/checkpoint/manager.js.map +0 -1
  106. package/dist/checkpoint/storage.d.ts +0 -39
  107. package/dist/checkpoint/storage.js +0 -350
  108. package/dist/checkpoint/storage.js.map +0 -1
  109. package/dist/checkpoint/types.d.ts +0 -111
  110. package/dist/checkpoint/types.js +0 -17
  111. package/dist/checkpoint/types.js.map +0 -1
  112. package/dist/commands/cache.d.ts +0 -7
  113. package/dist/commands/cache.js +0 -284
  114. package/dist/commands/cache.js.map +0 -1
  115. package/dist/commands/custom-commands.d.ts +0 -77
  116. package/dist/commands/custom-commands.js +0 -251
  117. package/dist/commands/custom-commands.js.map +0 -1
  118. package/dist/commands/design.d.ts +0 -18
  119. package/dist/commands/design.js +0 -511
  120. package/dist/commands/design.js.map +0 -1
  121. package/dist/commands/doctor.d.ts +0 -6
  122. package/dist/commands/doctor.js +0 -773
  123. package/dist/commands/doctor.js.map +0 -1
  124. package/dist/commands/frontend.d.ts +0 -9
  125. package/dist/commands/frontend.js +0 -645
  126. package/dist/commands/frontend.js.map +0 -1
  127. package/dist/commands/init/wizard.d.ts +0 -55
  128. package/dist/commands/init/wizard.js +0 -189
  129. package/dist/commands/init/wizard.js.map +0 -1
  130. package/dist/commands/init.d.ts +0 -8
  131. package/dist/commands/init.js +0 -195
  132. package/dist/commands/init.js.map +0 -1
  133. package/dist/commands/mcp-migrate.d.ts +0 -9
  134. package/dist/commands/mcp-migrate.js +0 -175
  135. package/dist/commands/mcp-migrate.js.map +0 -1
  136. package/dist/commands/mcp.d.ts +0 -2
  137. package/dist/commands/mcp.js +0 -1292
  138. package/dist/commands/mcp.js.map +0 -1
  139. package/dist/commands/memory.d.ts +0 -6
  140. package/dist/commands/memory.js +0 -555
  141. package/dist/commands/memory.js.map +0 -1
  142. package/dist/commands/models.d.ts +0 -5
  143. package/dist/commands/models.js +0 -213
  144. package/dist/commands/models.js.map +0 -1
  145. package/dist/commands/plan.d.ts +0 -43
  146. package/dist/commands/plan.js +0 -362
  147. package/dist/commands/plan.js.map +0 -1
  148. package/dist/commands/rewind.d.ts +0 -19
  149. package/dist/commands/rewind.js +0 -221
  150. package/dist/commands/rewind.js.map +0 -1
  151. package/dist/commands/setup.d.ts +0 -14
  152. package/dist/commands/setup.js +0 -733
  153. package/dist/commands/setup.js.map +0 -1
  154. package/dist/commands/status.d.ts +0 -7
  155. package/dist/commands/status.js +0 -437
  156. package/dist/commands/status.js.map +0 -1
  157. package/dist/commands/templates.d.ts +0 -5
  158. package/dist/commands/templates.js +0 -245
  159. package/dist/commands/templates.js.map +0 -1
  160. package/dist/commands/update.d.ts +0 -49
  161. package/dist/commands/update.js +0 -366
  162. package/dist/commands/update.js.map +0 -1
  163. package/dist/commands/usage.d.ts +0 -8
  164. package/dist/commands/usage.js +0 -264
  165. package/dist/commands/usage.js.map +0 -1
  166. package/dist/commands/vscode.d.ts +0 -7
  167. package/dist/commands/vscode.js +0 -419
  168. package/dist/commands/vscode.js.map +0 -1
  169. package/dist/constants.d.ts +0 -236
  170. package/dist/constants.js +0 -288
  171. package/dist/constants.js.map +0 -1
  172. package/dist/design/figma-alias.d.ts +0 -170
  173. package/dist/design/figma-alias.js +0 -577
  174. package/dist/design/figma-alias.js.map +0 -1
  175. package/dist/design/figma-audit.d.ts +0 -40
  176. package/dist/design/figma-audit.js +0 -383
  177. package/dist/design/figma-audit.js.map +0 -1
  178. package/dist/design/figma-client.d.ts +0 -131
  179. package/dist/design/figma-client.js +0 -369
  180. package/dist/design/figma-client.js.map +0 -1
  181. package/dist/design/figma-map.d.ts +0 -29
  182. package/dist/design/figma-map.js +0 -346
  183. package/dist/design/figma-map.js.map +0 -1
  184. package/dist/design/figma-tokens.d.ts +0 -73
  185. package/dist/design/figma-tokens.js +0 -448
  186. package/dist/design/figma-tokens.js.map +0 -1
  187. package/dist/design/index.d.ts +0 -13
  188. package/dist/design/index.js +0 -20
  189. package/dist/design/index.js.map +0 -1
  190. package/dist/design/types.d.ts +0 -98
  191. package/dist/design/types.js +0 -9
  192. package/dist/design/types.js.map +0 -1
  193. package/dist/hooks/hook-runner.d.ts +0 -142
  194. package/dist/hooks/hook-runner.js +0 -436
  195. package/dist/hooks/hook-runner.js.map +0 -1
  196. package/dist/hooks/index.d.ts +0 -9
  197. package/dist/hooks/index.js +0 -10
  198. package/dist/hooks/index.js.map +0 -1
  199. package/dist/hooks/manager.d.ts +0 -84
  200. package/dist/hooks/manager.js +0 -348
  201. package/dist/hooks/manager.js.map +0 -1
  202. package/dist/hooks/types.d.ts +0 -134
  203. package/dist/hooks/types.js +0 -9
  204. package/dist/hooks/types.js.map +0 -1
  205. package/dist/index.d.ts +0 -2
  206. package/dist/ipc/index.d.ts +0 -9
  207. package/dist/ipc/index.js +0 -10
  208. package/dist/ipc/index.js.map +0 -1
  209. package/dist/ipc/vscode-client.d.ts +0 -200
  210. package/dist/ipc/vscode-client.js +0 -495
  211. package/dist/ipc/vscode-client.js.map +0 -1
  212. package/dist/llm/client.d.ts +0 -205
  213. package/dist/llm/client.js +0 -735
  214. package/dist/llm/client.js.map +0 -1
  215. package/dist/llm/tools.d.ts +0 -102
  216. package/dist/llm/tools.js +0 -275
  217. package/dist/llm/tools.js.map +0 -1
  218. package/dist/llm/types.d.ts +0 -428
  219. package/dist/llm/types.js +0 -194
  220. package/dist/llm/types.js.map +0 -1
  221. package/dist/mcp/automatosx-auto-discovery.d.ts +0 -66
  222. package/dist/mcp/automatosx-auto-discovery.js +0 -169
  223. package/dist/mcp/automatosx-auto-discovery.js.map +0 -1
  224. package/dist/mcp/automatosx-loader.d.ts +0 -99
  225. package/dist/mcp/automatosx-loader.js +0 -250
  226. package/dist/mcp/automatosx-loader.js.map +0 -1
  227. package/dist/mcp/cancellation.d.ts +0 -182
  228. package/dist/mcp/cancellation.js +0 -275
  229. package/dist/mcp/cancellation.js.map +0 -1
  230. package/dist/mcp/client-v2.d.ts +0 -500
  231. package/dist/mcp/client-v2.js +0 -1433
  232. package/dist/mcp/client-v2.js.map +0 -1
  233. package/dist/mcp/client.d.ts +0 -170
  234. package/dist/mcp/client.js +0 -232
  235. package/dist/mcp/client.js.map +0 -1
  236. package/dist/mcp/config-detector.d.ts +0 -90
  237. package/dist/mcp/config-detector.js +0 -250
  238. package/dist/mcp/config-detector.js.map +0 -1
  239. package/dist/mcp/config-migrator.d.ts +0 -68
  240. package/dist/mcp/config-migrator.js +0 -291
  241. package/dist/mcp/config-migrator.js.map +0 -1
  242. package/dist/mcp/config.d.ts +0 -24
  243. package/dist/mcp/config.js +0 -273
  244. package/dist/mcp/config.js.map +0 -1
  245. package/dist/mcp/constants.d.ts +0 -66
  246. package/dist/mcp/constants.js +0 -85
  247. package/dist/mcp/constants.js.map +0 -1
  248. package/dist/mcp/content-length-transport.d.ts +0 -106
  249. package/dist/mcp/content-length-transport.js +0 -413
  250. package/dist/mcp/content-length-transport.js.map +0 -1
  251. package/dist/mcp/debug.d.ts +0 -211
  252. package/dist/mcp/debug.js +0 -404
  253. package/dist/mcp/debug.js.map +0 -1
  254. package/dist/mcp/error-formatter.d.ts +0 -40
  255. package/dist/mcp/error-formatter.js +0 -207
  256. package/dist/mcp/error-formatter.js.map +0 -1
  257. package/dist/mcp/error-remediation.d.ts +0 -45
  258. package/dist/mcp/error-remediation.js +0 -291
  259. package/dist/mcp/error-remediation.js.map +0 -1
  260. package/dist/mcp/health.d.ts +0 -120
  261. package/dist/mcp/health.js +0 -267
  262. package/dist/mcp/health.js.map +0 -1
  263. package/dist/mcp/index.d.ts +0 -56
  264. package/dist/mcp/index.js +0 -89
  265. package/dist/mcp/index.js.map +0 -1
  266. package/dist/mcp/invariants.d.ts +0 -141
  267. package/dist/mcp/invariants.js +0 -243
  268. package/dist/mcp/invariants.js.map +0 -1
  269. package/dist/mcp/mutex-safe.d.ts +0 -151
  270. package/dist/mcp/mutex-safe.js +0 -260
  271. package/dist/mcp/mutex-safe.js.map +0 -1
  272. package/dist/mcp/progress.d.ts +0 -155
  273. package/dist/mcp/progress.js +0 -252
  274. package/dist/mcp/progress.js.map +0 -1
  275. package/dist/mcp/prompts.d.ts +0 -68
  276. package/dist/mcp/prompts.js +0 -129
  277. package/dist/mcp/prompts.js.map +0 -1
  278. package/dist/mcp/provider-mcp-loader.d.ts +0 -130
  279. package/dist/mcp/provider-mcp-loader.js +0 -292
  280. package/dist/mcp/provider-mcp-loader.js.map +0 -1
  281. package/dist/mcp/reconnection.d.ts +0 -101
  282. package/dist/mcp/reconnection.js +0 -253
  283. package/dist/mcp/reconnection.js.map +0 -1
  284. package/dist/mcp/registry.d.ts +0 -75
  285. package/dist/mcp/registry.js +0 -276
  286. package/dist/mcp/registry.js.map +0 -1
  287. package/dist/mcp/resources.d.ts +0 -58
  288. package/dist/mcp/resources.js +0 -144
  289. package/dist/mcp/resources.js.map +0 -1
  290. package/dist/mcp/schema-validator.d.ts +0 -82
  291. package/dist/mcp/schema-validator.js +0 -161
  292. package/dist/mcp/schema-validator.js.map +0 -1
  293. package/dist/mcp/ssrf-protection.d.ts +0 -86
  294. package/dist/mcp/ssrf-protection.js +0 -311
  295. package/dist/mcp/ssrf-protection.js.map +0 -1
  296. package/dist/mcp/subscriptions.d.ts +0 -168
  297. package/dist/mcp/subscriptions.js +0 -248
  298. package/dist/mcp/subscriptions.js.map +0 -1
  299. package/dist/mcp/templates.d.ts +0 -52
  300. package/dist/mcp/templates.js +0 -627
  301. package/dist/mcp/templates.js.map +0 -1
  302. package/dist/mcp/transports.d.ts +0 -80
  303. package/dist/mcp/transports.js +0 -237
  304. package/dist/mcp/transports.js.map +0 -1
  305. package/dist/mcp/type-safety.d.ts +0 -225
  306. package/dist/mcp/type-safety.js +0 -237
  307. package/dist/mcp/type-safety.js.map +0 -1
  308. package/dist/mcp/validation.d.ts +0 -29
  309. package/dist/mcp/validation.js +0 -339
  310. package/dist/mcp/validation.js.map +0 -1
  311. package/dist/mcp/zai-detector.d.ts +0 -63
  312. package/dist/mcp/zai-detector.js +0 -193
  313. package/dist/mcp/zai-detector.js.map +0 -1
  314. package/dist/mcp/zai-templates.d.ts +0 -90
  315. package/dist/mcp/zai-templates.js +0 -157
  316. package/dist/mcp/zai-templates.js.map +0 -1
  317. package/dist/memory/context-generator.d.ts +0 -84
  318. package/dist/memory/context-generator.js +0 -546
  319. package/dist/memory/context-generator.js.map +0 -1
  320. package/dist/memory/context-injector.d.ts +0 -97
  321. package/dist/memory/context-injector.js +0 -159
  322. package/dist/memory/context-injector.js.map +0 -1
  323. package/dist/memory/context-store.d.ts +0 -103
  324. package/dist/memory/context-store.js +0 -264
  325. package/dist/memory/context-store.js.map +0 -1
  326. package/dist/memory/index.d.ts +0 -43
  327. package/dist/memory/index.js +0 -49
  328. package/dist/memory/index.js.map +0 -1
  329. package/dist/memory/provider-context-store.d.ts +0 -127
  330. package/dist/memory/provider-context-store.js +0 -385
  331. package/dist/memory/provider-context-store.js.map +0 -1
  332. package/dist/memory/schemas.d.ts +0 -118
  333. package/dist/memory/schemas.js +0 -106
  334. package/dist/memory/schemas.js.map +0 -1
  335. package/dist/memory/stats-collector.d.ts +0 -73
  336. package/dist/memory/stats-collector.js +0 -170
  337. package/dist/memory/stats-collector.js.map +0 -1
  338. package/dist/memory/types.d.ts +0 -177
  339. package/dist/memory/types.js +0 -73
  340. package/dist/memory/types.js.map +0 -1
  341. package/dist/permissions/index.d.ts +0 -6
  342. package/dist/permissions/index.js +0 -7
  343. package/dist/permissions/index.js.map +0 -1
  344. package/dist/permissions/permission-manager.d.ts +0 -149
  345. package/dist/permissions/permission-manager.js +0 -410
  346. package/dist/permissions/permission-manager.js.map +0 -1
  347. package/dist/planner/dependency-resolver.d.ts +0 -72
  348. package/dist/planner/dependency-resolver.js +0 -272
  349. package/dist/planner/dependency-resolver.js.map +0 -1
  350. package/dist/planner/index.d.ts +0 -12
  351. package/dist/planner/index.js +0 -28
  352. package/dist/planner/index.js.map +0 -1
  353. package/dist/planner/plan-generator.d.ts +0 -74
  354. package/dist/planner/plan-generator.js +0 -244
  355. package/dist/planner/plan-generator.js.map +0 -1
  356. package/dist/planner/plan-storage.d.ts +0 -113
  357. package/dist/planner/plan-storage.js +0 -398
  358. package/dist/planner/plan-storage.js.map +0 -1
  359. package/dist/planner/prompts/planning-prompt.d.ts +0 -62
  360. package/dist/planner/prompts/planning-prompt.js +0 -414
  361. package/dist/planner/prompts/planning-prompt.js.map +0 -1
  362. package/dist/planner/task-planner.d.ts +0 -139
  363. package/dist/planner/task-planner.js +0 -532
  364. package/dist/planner/task-planner.js.map +0 -1
  365. package/dist/planner/token-estimator.d.ts +0 -63
  366. package/dist/planner/token-estimator.js +0 -295
  367. package/dist/planner/token-estimator.js.map +0 -1
  368. package/dist/planner/types.d.ts +0 -425
  369. package/dist/planner/types.js +0 -213
  370. package/dist/planner/types.js.map +0 -1
  371. package/dist/provider/config.d.ts +0 -227
  372. package/dist/provider/config.js +0 -430
  373. package/dist/provider/config.js.map +0 -1
  374. package/dist/schemas/api-schemas.d.ts +0 -45
  375. package/dist/schemas/api-schemas.js +0 -129
  376. package/dist/schemas/api-schemas.js.map +0 -1
  377. package/dist/schemas/confirmation-schemas.d.ts +0 -39
  378. package/dist/schemas/confirmation-schemas.js +0 -48
  379. package/dist/schemas/confirmation-schemas.js.map +0 -1
  380. package/dist/schemas/index-unified.d.ts +0 -12
  381. package/dist/schemas/index-unified.js +0 -17
  382. package/dist/schemas/index-unified.js.map +0 -1
  383. package/dist/schemas/index.d.ts +0 -83
  384. package/dist/schemas/index.js +0 -139
  385. package/dist/schemas/index.js.map +0 -1
  386. package/dist/schemas/settings-schemas.d.ts +0 -186
  387. package/dist/schemas/settings-schemas.js +0 -324
  388. package/dist/schemas/settings-schemas.js.map +0 -1
  389. package/dist/schemas/tool-schemas.d.ts +0 -127
  390. package/dist/schemas/tool-schemas.js +0 -84
  391. package/dist/schemas/tool-schemas.js.map +0 -1
  392. package/dist/schemas/yaml-schemas.d.ts +0 -231
  393. package/dist/schemas/yaml-schemas.js +0 -199
  394. package/dist/schemas/yaml-schemas.js.map +0 -1
  395. package/dist/sdk/errors.d.ts +0 -100
  396. package/dist/sdk/errors.js +0 -138
  397. package/dist/sdk/errors.js.map +0 -1
  398. package/dist/sdk/index.d.ts +0 -901
  399. package/dist/sdk/index.js +0 -1272
  400. package/dist/sdk/index.js.map +0 -1
  401. package/dist/sdk/progress-reporter.d.ts +0 -123
  402. package/dist/sdk/progress-reporter.js +0 -220
  403. package/dist/sdk/progress-reporter.js.map +0 -1
  404. package/dist/sdk/testing.d.ts +0 -427
  405. package/dist/sdk/testing.js +0 -725
  406. package/dist/sdk/testing.js.map +0 -1
  407. package/dist/sdk/tool-registry.d.ts +0 -194
  408. package/dist/sdk/tool-registry.js +0 -326
  409. package/dist/sdk/tool-registry.js.map +0 -1
  410. package/dist/sdk/types.d.ts +0 -53
  411. package/dist/sdk/types.js +0 -8
  412. package/dist/sdk/types.js.map +0 -1
  413. package/dist/sdk/unified-logger.d.ts +0 -173
  414. package/dist/sdk/unified-logger.js +0 -327
  415. package/dist/sdk/unified-logger.js.map +0 -1
  416. package/dist/sdk/version.d.ts +0 -163
  417. package/dist/sdk/version.js +0 -205
  418. package/dist/sdk/version.js.map +0 -1
  419. package/dist/tools/ask-user.d.ts +0 -126
  420. package/dist/tools/ask-user.js +0 -290
  421. package/dist/tools/ask-user.js.map +0 -1
  422. package/dist/tools/ax-agent.d.ts +0 -71
  423. package/dist/tools/ax-agent.js +0 -283
  424. package/dist/tools/ax-agent.js.map +0 -1
  425. package/dist/tools/bash-output.d.ts +0 -25
  426. package/dist/tools/bash-output.js +0 -146
  427. package/dist/tools/bash-output.js.map +0 -1
  428. package/dist/tools/bash.d.ts +0 -67
  429. package/dist/tools/bash.js +0 -522
  430. package/dist/tools/bash.js.map +0 -1
  431. package/dist/tools/confirmation-tool.d.ts +0 -16
  432. package/dist/tools/confirmation-tool.js +0 -76
  433. package/dist/tools/confirmation-tool.js.map +0 -1
  434. package/dist/tools/definitions/ask-user.d.ts +0 -8
  435. package/dist/tools/definitions/ask-user.js +0 -168
  436. package/dist/tools/definitions/ask-user.js.map +0 -1
  437. package/dist/tools/definitions/ax-agent.d.ts +0 -8
  438. package/dist/tools/definitions/ax-agent.js +0 -276
  439. package/dist/tools/definitions/ax-agent.js.map +0 -1
  440. package/dist/tools/definitions/bash-output.d.ts +0 -7
  441. package/dist/tools/definitions/bash-output.js +0 -78
  442. package/dist/tools/definitions/bash-output.js.map +0 -1
  443. package/dist/tools/definitions/bash.d.ts +0 -8
  444. package/dist/tools/definitions/bash.js +0 -152
  445. package/dist/tools/definitions/bash.js.map +0 -1
  446. package/dist/tools/definitions/create-file.d.ts +0 -7
  447. package/dist/tools/definitions/create-file.js +0 -129
  448. package/dist/tools/definitions/create-file.js.map +0 -1
  449. package/dist/tools/definitions/design.d.ts +0 -12
  450. package/dist/tools/definitions/design.js +0 -368
  451. package/dist/tools/definitions/design.js.map +0 -1
  452. package/dist/tools/definitions/index.d.ts +0 -49
  453. package/dist/tools/definitions/index.js +0 -87
  454. package/dist/tools/definitions/index.js.map +0 -1
  455. package/dist/tools/definitions/multi-edit.d.ts +0 -7
  456. package/dist/tools/definitions/multi-edit.js +0 -123
  457. package/dist/tools/definitions/multi-edit.js.map +0 -1
  458. package/dist/tools/definitions/search.d.ts +0 -7
  459. package/dist/tools/definitions/search.js +0 -159
  460. package/dist/tools/definitions/search.js.map +0 -1
  461. package/dist/tools/definitions/str-replace-editor.d.ts +0 -7
  462. package/dist/tools/definitions/str-replace-editor.js +0 -145
  463. package/dist/tools/definitions/str-replace-editor.js.map +0 -1
  464. package/dist/tools/definitions/todo.d.ts +0 -8
  465. package/dist/tools/definitions/todo.js +0 -261
  466. package/dist/tools/definitions/todo.js.map +0 -1
  467. package/dist/tools/definitions/view-file.d.ts +0 -7
  468. package/dist/tools/definitions/view-file.js +0 -111
  469. package/dist/tools/definitions/view-file.js.map +0 -1
  470. package/dist/tools/design-tool.d.ts +0 -68
  471. package/dist/tools/design-tool.js +0 -299
  472. package/dist/tools/design-tool.js.map +0 -1
  473. package/dist/tools/format-generators.d.ts +0 -62
  474. package/dist/tools/format-generators.js +0 -291
  475. package/dist/tools/format-generators.js.map +0 -1
  476. package/dist/tools/index.d.ts +0 -8
  477. package/dist/tools/index.js +0 -11
  478. package/dist/tools/index.js.map +0 -1
  479. package/dist/tools/priority-registry.d.ts +0 -124
  480. package/dist/tools/priority-registry.js +0 -401
  481. package/dist/tools/priority-registry.js.map +0 -1
  482. package/dist/tools/priority.d.ts +0 -158
  483. package/dist/tools/priority.js +0 -350
  484. package/dist/tools/priority.js.map +0 -1
  485. package/dist/tools/registry.d.ts +0 -146
  486. package/dist/tools/registry.js +0 -171
  487. package/dist/tools/registry.js.map +0 -1
  488. package/dist/tools/search.d.ts +0 -85
  489. package/dist/tools/search.js +0 -430
  490. package/dist/tools/search.js.map +0 -1
  491. package/dist/tools/text-editor.d.ts +0 -87
  492. package/dist/tools/text-editor.js +0 -1369
  493. package/dist/tools/text-editor.js.map +0 -1
  494. package/dist/tools/todo-tool.d.ts +0 -20
  495. package/dist/tools/todo-tool.js +0 -186
  496. package/dist/tools/todo-tool.js.map +0 -1
  497. package/dist/tools/types.d.ts +0 -175
  498. package/dist/tools/types.js +0 -11
  499. package/dist/tools/types.js.map +0 -1
  500. package/dist/types/index.d.ts +0 -30
  501. package/dist/types/index.js +0 -2
  502. package/dist/types/index.js.map +0 -1
  503. package/dist/types/project-analysis.d.ts +0 -84
  504. package/dist/types/project-analysis.js +0 -5
  505. package/dist/types/project-analysis.js.map +0 -1
  506. package/dist/types/template.d.ts +0 -53
  507. package/dist/types/template.js +0 -5
  508. package/dist/types/template.js.map +0 -1
  509. package/dist/ui/app.d.ts +0 -7
  510. package/dist/ui/app.js +0 -102
  511. package/dist/ui/app.js.map +0 -1
  512. package/dist/ui/components/api-key-input.d.ts +0 -7
  513. package/dist/ui/components/api-key-input.js +0 -92
  514. package/dist/ui/components/api-key-input.js.map +0 -1
  515. package/dist/ui/components/chat-history.d.ts +0 -12
  516. package/dist/ui/components/chat-history.js +0 -391
  517. package/dist/ui/components/chat-history.js.map +0 -1
  518. package/dist/ui/components/chat-input.d.ts +0 -13
  519. package/dist/ui/components/chat-input.js +0 -179
  520. package/dist/ui/components/chat-input.js.map +0 -1
  521. package/dist/ui/components/chat-interface.d.ts +0 -11
  522. package/dist/ui/components/chat-interface.js +0 -830
  523. package/dist/ui/components/chat-interface.js.map +0 -1
  524. package/dist/ui/components/collapsible-tool-result.d.ts +0 -42
  525. package/dist/ui/components/collapsible-tool-result.js +0 -216
  526. package/dist/ui/components/collapsible-tool-result.js.map +0 -1
  527. package/dist/ui/components/command-suggestions.d.ts +0 -29
  528. package/dist/ui/components/command-suggestions.js +0 -88
  529. package/dist/ui/components/command-suggestions.js.map +0 -1
  530. package/dist/ui/components/confirmation-dialog.d.ts +0 -11
  531. package/dist/ui/components/confirmation-dialog.js +0 -100
  532. package/dist/ui/components/confirmation-dialog.js.map +0 -1
  533. package/dist/ui/components/context-breakdown.d.ts +0 -23
  534. package/dist/ui/components/context-breakdown.js +0 -124
  535. package/dist/ui/components/context-breakdown.js.map +0 -1
  536. package/dist/ui/components/diff-renderer.d.ts +0 -13
  537. package/dist/ui/components/diff-renderer.js +0 -192
  538. package/dist/ui/components/diff-renderer.js.map +0 -1
  539. package/dist/ui/components/index.d.ts +0 -18
  540. package/dist/ui/components/index.js +0 -20
  541. package/dist/ui/components/index.js.map +0 -1
  542. package/dist/ui/components/keyboard-help.d.ts +0 -17
  543. package/dist/ui/components/keyboard-help.js +0 -122
  544. package/dist/ui/components/keyboard-help.js.map +0 -1
  545. package/dist/ui/components/keyboard-hints.d.ts +0 -35
  546. package/dist/ui/components/keyboard-hints.js +0 -142
  547. package/dist/ui/components/keyboard-hints.js.map +0 -1
  548. package/dist/ui/components/loading-spinner.d.ts +0 -9
  549. package/dist/ui/components/loading-spinner.js +0 -120
  550. package/dist/ui/components/loading-spinner.js.map +0 -1
  551. package/dist/ui/components/mcp-dashboard.d.ts +0 -15
  552. package/dist/ui/components/mcp-dashboard.js +0 -520
  553. package/dist/ui/components/mcp-dashboard.js.map +0 -1
  554. package/dist/ui/components/mcp-status.d.ts +0 -5
  555. package/dist/ui/components/mcp-status.js +0 -58
  556. package/dist/ui/components/mcp-status.js.map +0 -1
  557. package/dist/ui/components/model-selection.d.ts +0 -12
  558. package/dist/ui/components/model-selection.js +0 -17
  559. package/dist/ui/components/model-selection.js.map +0 -1
  560. package/dist/ui/components/phase-progress.d.ts +0 -21
  561. package/dist/ui/components/phase-progress.js +0 -185
  562. package/dist/ui/components/phase-progress.js.map +0 -1
  563. package/dist/ui/components/question-dialog.d.ts +0 -17
  564. package/dist/ui/components/question-dialog.js +0 -181
  565. package/dist/ui/components/question-dialog.js.map +0 -1
  566. package/dist/ui/components/quick-actions.d.ts +0 -12
  567. package/dist/ui/components/quick-actions.js +0 -171
  568. package/dist/ui/components/quick-actions.js.map +0 -1
  569. package/dist/ui/components/reasoning-display.d.ts +0 -36
  570. package/dist/ui/components/reasoning-display.js +0 -46
  571. package/dist/ui/components/reasoning-display.js.map +0 -1
  572. package/dist/ui/components/status-bar.d.ts +0 -47
  573. package/dist/ui/components/status-bar.js +0 -310
  574. package/dist/ui/components/status-bar.js.map +0 -1
  575. package/dist/ui/components/subagent-monitor.d.ts +0 -41
  576. package/dist/ui/components/subagent-monitor.js +0 -122
  577. package/dist/ui/components/subagent-monitor.js.map +0 -1
  578. package/dist/ui/components/toast-notification.d.ts +0 -197
  579. package/dist/ui/components/toast-notification.js +0 -190
  580. package/dist/ui/components/toast-notification.js.map +0 -1
  581. package/dist/ui/components/tool-group-display.d.ts +0 -19
  582. package/dist/ui/components/tool-group-display.js +0 -222
  583. package/dist/ui/components/tool-group-display.js.map +0 -1
  584. package/dist/ui/components/virtualized-chat-history.d.ts +0 -33
  585. package/dist/ui/components/virtualized-chat-history.js +0 -182
  586. package/dist/ui/components/virtualized-chat-history.js.map +0 -1
  587. package/dist/ui/components/welcome-panel.d.ts +0 -11
  588. package/dist/ui/components/welcome-panel.js +0 -225
  589. package/dist/ui/components/welcome-panel.js.map +0 -1
  590. package/dist/ui/hooks/use-chat-reducer.d.ts +0 -69
  591. package/dist/ui/hooks/use-chat-reducer.js +0 -118
  592. package/dist/ui/hooks/use-chat-reducer.js.map +0 -1
  593. package/dist/ui/hooks/use-enhanced-input.d.ts +0 -53
  594. package/dist/ui/hooks/use-enhanced-input.js +0 -1275
  595. package/dist/ui/hooks/use-enhanced-input.js.map +0 -1
  596. package/dist/ui/hooks/use-input-handler.d.ts +0 -79
  597. package/dist/ui/hooks/use-input-handler.js +0 -2251
  598. package/dist/ui/hooks/use-input-handler.js.map +0 -1
  599. package/dist/ui/hooks/use-input-history.d.ts +0 -9
  600. package/dist/ui/hooks/use-input-history.js +0 -168
  601. package/dist/ui/hooks/use-input-history.js.map +0 -1
  602. package/dist/ui/shared/max-sized-box.d.ts +0 -17
  603. package/dist/ui/shared/max-sized-box.js +0 -14
  604. package/dist/ui/shared/max-sized-box.js.map +0 -1
  605. package/dist/ui/themes/index.d.ts +0 -5
  606. package/dist/ui/themes/index.js +0 -5
  607. package/dist/ui/themes/index.js.map +0 -1
  608. package/dist/ui/themes/theme-registry.d.ts +0 -55
  609. package/dist/ui/themes/theme-registry.js +0 -202
  610. package/dist/ui/themes/theme-registry.js.map +0 -1
  611. package/dist/ui/utils/bracketed-paste-handler.d.ts +0 -97
  612. package/dist/ui/utils/bracketed-paste-handler.js +0 -322
  613. package/dist/ui/utils/bracketed-paste-handler.js.map +0 -1
  614. package/dist/ui/utils/change-summarizer.d.ts +0 -20
  615. package/dist/ui/utils/change-summarizer.js +0 -282
  616. package/dist/ui/utils/change-summarizer.js.map +0 -1
  617. package/dist/ui/utils/code-colorizer.d.ts +0 -9
  618. package/dist/ui/utils/code-colorizer.js +0 -13
  619. package/dist/ui/utils/code-colorizer.js.map +0 -1
  620. package/dist/ui/utils/colors.d.ts +0 -41
  621. package/dist/ui/utils/colors.js +0 -80
  622. package/dist/ui/utils/colors.js.map +0 -1
  623. package/dist/ui/utils/image-handler.d.ts +0 -29
  624. package/dist/ui/utils/image-handler.js +0 -129
  625. package/dist/ui/utils/image-handler.js.map +0 -1
  626. package/dist/ui/utils/markdown-renderer.d.ts +0 -4
  627. package/dist/ui/utils/markdown-renderer.js +0 -40
  628. package/dist/ui/utils/markdown-renderer.js.map +0 -1
  629. package/dist/ui/utils/semantic-action-detector.d.ts +0 -49
  630. package/dist/ui/utils/semantic-action-detector.js +0 -339
  631. package/dist/ui/utils/semantic-action-detector.js.map +0 -1
  632. package/dist/ui/utils/tool-grouper.d.ts +0 -94
  633. package/dist/ui/utils/tool-grouper.js +0 -618
  634. package/dist/ui/utils/tool-grouper.js.map +0 -1
  635. package/dist/utils/api-error.d.ts +0 -61
  636. package/dist/utils/api-error.js +0 -176
  637. package/dist/utils/api-error.js.map +0 -1
  638. package/dist/utils/audit-logger.d.ts +0 -206
  639. package/dist/utils/audit-logger.js +0 -286
  640. package/dist/utils/audit-logger.js.map +0 -1
  641. package/dist/utils/auto-accept-logger.d.ts +0 -175
  642. package/dist/utils/auto-accept-logger.js +0 -423
  643. package/dist/utils/auto-accept-logger.js.map +0 -1
  644. package/dist/utils/automatosx-detector.d.ts +0 -19
  645. package/dist/utils/automatosx-detector.js +0 -52
  646. package/dist/utils/automatosx-detector.js.map +0 -1
  647. package/dist/utils/background-task-manager.d.ts +0 -114
  648. package/dist/utils/background-task-manager.js +0 -470
  649. package/dist/utils/background-task-manager.js.map +0 -1
  650. package/dist/utils/cache.d.ts +0 -77
  651. package/dist/utils/cache.js +0 -180
  652. package/dist/utils/cache.js.map +0 -1
  653. package/dist/utils/command-security.d.ts +0 -85
  654. package/dist/utils/command-security.js +0 -210
  655. package/dist/utils/command-security.js.map +0 -1
  656. package/dist/utils/config-loader.d.ts +0 -190
  657. package/dist/utils/config-loader.js +0 -108
  658. package/dist/utils/config-loader.js.map +0 -1
  659. package/dist/utils/confirmation-service.d.ts +0 -51
  660. package/dist/utils/confirmation-service.js +0 -220
  661. package/dist/utils/confirmation-service.js.map +0 -1
  662. package/dist/utils/console-messenger.d.ts +0 -80
  663. package/dist/utils/console-messenger.js +0 -142
  664. package/dist/utils/console-messenger.js.map +0 -1
  665. package/dist/utils/custom-instructions.d.ts +0 -1
  666. package/dist/utils/custom-instructions.js +0 -24
  667. package/dist/utils/custom-instructions.js.map +0 -1
  668. package/dist/utils/encryption.d.ts +0 -86
  669. package/dist/utils/encryption.js +0 -236
  670. package/dist/utils/encryption.js.map +0 -1
  671. package/dist/utils/enhanced-error-messages.d.ts +0 -33
  672. package/dist/utils/enhanced-error-messages.js +0 -440
  673. package/dist/utils/enhanced-error-messages.js.map +0 -1
  674. package/dist/utils/error-handler.d.ts +0 -65
  675. package/dist/utils/error-handler.js +0 -148
  676. package/dist/utils/error-handler.js.map +0 -1
  677. package/dist/utils/error-translator.d.ts +0 -25
  678. package/dist/utils/error-translator.js +0 -203
  679. package/dist/utils/error-translator.js.map +0 -1
  680. package/dist/utils/external-editor.d.ts +0 -47
  681. package/dist/utils/external-editor.js +0 -179
  682. package/dist/utils/external-editor.js.map +0 -1
  683. package/dist/utils/file-cache.d.ts +0 -148
  684. package/dist/utils/file-cache.js +0 -413
  685. package/dist/utils/file-cache.js.map +0 -1
  686. package/dist/utils/file-lock.d.ts +0 -141
  687. package/dist/utils/file-lock.js +0 -554
  688. package/dist/utils/file-lock.js.map +0 -1
  689. package/dist/utils/file-mentions.d.ts +0 -68
  690. package/dist/utils/file-mentions.js +0 -225
  691. package/dist/utils/file-mentions.js.map +0 -1
  692. package/dist/utils/history-manager.d.ts +0 -52
  693. package/dist/utils/history-manager.js +0 -211
  694. package/dist/utils/history-manager.js.map +0 -1
  695. package/dist/utils/history-migration.d.ts +0 -9
  696. package/dist/utils/history-migration.js +0 -37
  697. package/dist/utils/history-migration.js.map +0 -1
  698. package/dist/utils/image-processor.d.ts +0 -33
  699. package/dist/utils/image-processor.js +0 -124
  700. package/dist/utils/image-processor.js.map +0 -1
  701. package/dist/utils/index.d.ts +0 -92
  702. package/dist/utils/index.js +0 -111
  703. package/dist/utils/index.js.map +0 -1
  704. package/dist/utils/init-previewer.d.ts +0 -56
  705. package/dist/utils/init-previewer.js +0 -239
  706. package/dist/utils/init-previewer.js.map +0 -1
  707. package/dist/utils/init-validator.d.ts +0 -65
  708. package/dist/utils/init-validator.js +0 -252
  709. package/dist/utils/init-validator.js.map +0 -1
  710. package/dist/utils/input-sanitizer.d.ts +0 -210
  711. package/dist/utils/input-sanitizer.js +0 -362
  712. package/dist/utils/input-sanitizer.js.map +0 -1
  713. package/dist/utils/instruction-generator.d.ts +0 -21
  714. package/dist/utils/instruction-generator.js +0 -233
  715. package/dist/utils/instruction-generator.js.map +0 -1
  716. package/dist/utils/json-utils.d.ts +0 -72
  717. package/dist/utils/json-utils.js +0 -226
  718. package/dist/utils/json-utils.js.map +0 -1
  719. package/dist/utils/llm-optimized-instruction-generator.d.ts +0 -36
  720. package/dist/utils/llm-optimized-instruction-generator.js +0 -365
  721. package/dist/utils/llm-optimized-instruction-generator.js.map +0 -1
  722. package/dist/utils/message-optimizer.d.ts +0 -100
  723. package/dist/utils/message-optimizer.js +0 -297
  724. package/dist/utils/message-optimizer.js.map +0 -1
  725. package/dist/utils/onboarding-manager.d.ts +0 -45
  726. package/dist/utils/onboarding-manager.js +0 -131
  727. package/dist/utils/onboarding-manager.js.map +0 -1
  728. package/dist/utils/parallel-analyzer.d.ts +0 -123
  729. package/dist/utils/parallel-analyzer.js +0 -241
  730. package/dist/utils/parallel-analyzer.js.map +0 -1
  731. package/dist/utils/paste-utils.d.ts +0 -99
  732. package/dist/utils/paste-utils.js +0 -295
  733. package/dist/utils/paste-utils.js.map +0 -1
  734. package/dist/utils/path-helpers.d.ts +0 -8
  735. package/dist/utils/path-helpers.js +0 -35
  736. package/dist/utils/path-helpers.js.map +0 -1
  737. package/dist/utils/path-security.d.ts +0 -92
  738. package/dist/utils/path-security.js +0 -300
  739. package/dist/utils/path-security.js.map +0 -1
  740. package/dist/utils/path-utils.d.ts +0 -83
  741. package/dist/utils/path-utils.js +0 -122
  742. package/dist/utils/path-utils.js.map +0 -1
  743. package/dist/utils/path-validator.d.ts +0 -66
  744. package/dist/utils/path-validator.js +0 -141
  745. package/dist/utils/path-validator.js.map +0 -1
  746. package/dist/utils/performance.d.ts +0 -74
  747. package/dist/utils/performance.js +0 -133
  748. package/dist/utils/performance.js.map +0 -1
  749. package/dist/utils/process-pool.d.ts +0 -109
  750. package/dist/utils/process-pool.js +0 -332
  751. package/dist/utils/process-pool.js.map +0 -1
  752. package/dist/utils/progress-tracker.d.ts +0 -51
  753. package/dist/utils/progress-tracker.js +0 -152
  754. package/dist/utils/progress-tracker.js.map +0 -1
  755. package/dist/utils/project-analyzer.d.ts +0 -49
  756. package/dist/utils/project-analyzer.js +0 -396
  757. package/dist/utils/project-analyzer.js.map +0 -1
  758. package/dist/utils/prompt-builder.d.ts +0 -14
  759. package/dist/utils/prompt-builder.js +0 -100
  760. package/dist/utils/prompt-builder.js.map +0 -1
  761. package/dist/utils/provider-context.d.ts +0 -243
  762. package/dist/utils/provider-context.js +0 -421
  763. package/dist/utils/provider-context.js.map +0 -1
  764. package/dist/utils/provider-file-cache.d.ts +0 -91
  765. package/dist/utils/provider-file-cache.js +0 -165
  766. package/dist/utils/provider-file-cache.js.map +0 -1
  767. package/dist/utils/provider-settings.d.ts +0 -181
  768. package/dist/utils/provider-settings.js +0 -450
  769. package/dist/utils/provider-settings.js.map +0 -1
  770. package/dist/utils/rate-limiter.d.ts +0 -222
  771. package/dist/utils/rate-limiter.js +0 -338
  772. package/dist/utils/rate-limiter.js.map +0 -1
  773. package/dist/utils/retry-helper.d.ts +0 -81
  774. package/dist/utils/retry-helper.js +0 -244
  775. package/dist/utils/retry-helper.js.map +0 -1
  776. package/dist/utils/safety-rules.d.ts +0 -64
  777. package/dist/utils/safety-rules.js +0 -225
  778. package/dist/utils/safety-rules.js.map +0 -1
  779. package/dist/utils/settings-manager.d.ts +0 -256
  780. package/dist/utils/settings-manager.js +0 -967
  781. package/dist/utils/settings-manager.js.map +0 -1
  782. package/dist/utils/setup-validator.d.ts +0 -47
  783. package/dist/utils/setup-validator.js +0 -304
  784. package/dist/utils/setup-validator.js.map +0 -1
  785. package/dist/utils/string-utils.d.ts +0 -19
  786. package/dist/utils/string-utils.js +0 -28
  787. package/dist/utils/string-utils.js.map +0 -1
  788. package/dist/utils/template-manager.d.ts +0 -62
  789. package/dist/utils/template-manager.js +0 -366
  790. package/dist/utils/template-manager.js.map +0 -1
  791. package/dist/utils/text-utils.d.ts +0 -82
  792. package/dist/utils/text-utils.js +0 -203
  793. package/dist/utils/text-utils.js.map +0 -1
  794. package/dist/utils/token-counter.d.ts +0 -76
  795. package/dist/utils/token-counter.js +0 -231
  796. package/dist/utils/token-counter.js.map +0 -1
  797. package/dist/utils/usage-tracker.d.ts +0 -78
  798. package/dist/utils/usage-tracker.js +0 -126
  799. package/dist/utils/usage-tracker.js.map +0 -1
  800. package/dist/utils/version.d.ts +0 -14
  801. package/dist/utils/version.js +0 -70
  802. package/dist/utils/version.js.map +0 -1
package/dist/sdk/index.js DELETED
@@ -1,1272 +0,0 @@
1
- /**
2
- * AX CLI SDK v1.4.0 - Programmatic API for AX CLI
3
- *
4
- * Use AX CLI as a library for integrations, VSCode extensions, and programmatic AI agents.
5
- *
6
- * ## Installation
7
- *
8
- * ```bash
9
- * npm install @defai.digital/ax-cli
10
- * ```
11
- *
12
- * ## Quick Start
13
- *
14
- * ```typescript
15
- * import { createAgent, createGLMAgent, createGrokAgent } from '@defai.digital/ax-cli/sdk';
16
- *
17
- * // Option 1: Auto-detect provider
18
- * const agent = await createAgent();
19
- *
20
- * // Option 2: Explicit provider
21
- * const glmAgent = await createGLMAgent(); // Uses ~/.ax-glm/config.json
22
- * const grokAgent = await createGrokAgent(); // Uses ~/.ax-grok/config.json
23
- *
24
- * // Process messages
25
- * const result = await agent.processUserMessage('Analyze this code');
26
- * agent.dispose();
27
- * ```
28
- *
29
- * ## Public API (v1.4.0)
30
- *
31
- * ### Agent Creation
32
- * - `createAgent(options?)` - Create agent with auto-detected or specified provider
33
- * - `createGLMAgent(options?)` - Create GLM (Z.AI) agent
34
- * - `createGrokAgent(options?)` - Create Grok (xAI) agent
35
- * - `tryCreateAgent(options?)` - Create agent without throwing (returns result object)
36
- * - `withAgent(fn, options?)` - Run function with auto-disposed agent
37
- *
38
- * ### Error Handling
39
- * - `SDKError` - Structured error class with error codes
40
- * - `SDKErrorCode` - Error code enum (SETUP_NOT_RUN, API_KEY_MISSING, etc.)
41
- *
42
- * ### Agent Utilities
43
- * - `getAgentInfo(agent)` - Get provider, model, config info
44
- * - `getAgentStatus(agent)` - Check if agent is available/busy/disposed
45
- * - `isAgentDisposed(agent)` - Check disposal state
46
- * - `disposeAsync(agent)` - Dispose with async hook support
47
- *
48
- * ### Provider Utilities
49
- * - `detectProvider()` - Auto-detect configured provider
50
- * - `checkProviderHealth(provider?)` - Check if provider is configured
51
- * - `getAllProviderHealth()` - Check all providers
52
- *
53
- * ### Version Info
54
- * - `SDK_VERSION`, `CLI_VERSION` - Version constants
55
- * - `getSDKVersion()`, `getCLIVersion()` - Version strings
56
- * - `isSDKVersionCompatible(minVersion)` - Version check
57
- *
58
- * ### Testing
59
- * - `createMockAgent(responses)` - Create mock for testing
60
- * - `createMockSettings(overrides)` - Mock settings manager
61
- *
62
- * ## Example: Streaming Responses
63
- *
64
- * ```typescript
65
- * import { createGLMAgent, SDKError, SDKErrorCode } from '@defai.digital/ax-cli/sdk';
66
- *
67
- * const agent = await createGLMAgent();
68
- *
69
- * agent.on('stream', (chunk) => {
70
- * if (chunk.type === 'content') {
71
- * process.stdout.write(chunk.content);
72
- * }
73
- * });
74
- *
75
- * try {
76
- * await agent.processUserMessage('Explain async/await');
77
- * } catch (error) {
78
- * if (SDKError.isSDKError(error)) {
79
- * console.error(`Error [${error.code}]: ${error.message}`);
80
- * }
81
- * } finally {
82
- * agent.dispose();
83
- * }
84
- * ```
85
- *
86
- * ## Example: Parallel Providers
87
- *
88
- * ```typescript
89
- * import { createGLMAgent, createGrokAgent } from '@defai.digital/ax-cli/sdk';
90
- *
91
- * // Run GLM and Grok in parallel
92
- * const [glm, grok] = await Promise.all([
93
- * createGLMAgent(),
94
- * createGrokAgent(),
95
- * ]);
96
- *
97
- * const [glmResult, grokResult] = await Promise.all([
98
- * glm.processUserMessage('Analyze with GLM'),
99
- * grok.processUserMessage('Analyze with Grok'),
100
- * ]);
101
- *
102
- * glm.dispose();
103
- * grok.dispose();
104
- * ```
105
- *
106
- * ## Example: Testing
107
- *
108
- * ```typescript
109
- * import { createMockAgent } from '@defai.digital/ax-cli/sdk';
110
- *
111
- * const mock = createMockAgent(['Hello!', 'How can I help?']);
112
- * const result = await mock.processUserMessage('Hi');
113
- * expect(result).toContain('Hello!');
114
- * ```
115
- *
116
- * @packageDocumentation
117
- */
118
- // ============================================================================
119
- // Core Agent Classes
120
- // ============================================================================
121
- export { LLMAgent } from '../agent/llm-agent.js';
122
- export { Subagent } from '../agent/subagent.js';
123
- export { SubagentOrchestrator } from '../agent/subagent-orchestrator.js';
124
- export { ContextManager } from '../agent/context-manager.js';
125
- // Internal imports for SDK functions
126
- import { LLMAgent } from '../agent/llm-agent.js';
127
- import { Subagent } from '../agent/subagent.js';
128
- import { initializeMCPServers } from '../llm/tools.js';
129
- import { z } from 'zod';
130
- import { SDKError, SDKErrorCode } from './errors.js';
131
- // Provider-aware imports
132
- import { ProviderContext, detectProvider, PROVIDER_CONFIGS, } from '../utils/provider-context.js';
133
- import { ProviderSettingsManager, } from '../utils/provider-settings.js';
134
- // File locking utilities - re-exported for SDK users
135
- export { withFileLock, withFileLockSync, SafeJsonFile, LockGuard, cleanupStaleLocks, } from '../utils/file-lock.js';
136
- // ============================================================================
137
- // LLM Client
138
- // ============================================================================
139
- export { LLMClient } from '../llm/client.js';
140
- export { SubagentRole, SubagentState, } from '../agent/subagent-types.js';
141
- // ============================================================================
142
- // NOTE: Internal utilities removed in SDK v1.4.0 to reduce API surface
143
- // ============================================================================
144
- // The following were intentionally removed from public exports:
145
- // - Settings utilities (getSettingsManager, createTokenCounter, etc.)
146
- // - MCP internals (MCPManager, MCPManagerV2, etc.) - use createAgent() instead
147
- // - Z.AI MCP templates/detector - internal implementation details
148
- // - Permission system internals
149
- // - Planning system internals
150
- // - Checkpoint system internals
151
- // - Memory/Context internals
152
- // - Progress reporting
153
- // - Unified logging
154
- // - Tool registry internals
155
- //
156
- // If you need these, import directly from the specific modules.
157
- // The SDK public API focuses on: createAgent, createGLMAgent, createGrokAgent, SDKError
158
- // ============================================================================
159
- // SDK Version (Phase 1.5: Best Practices)
160
- // ============================================================================
161
- export { CLI_VERSION, SDK_VERSION, SDK_API_VERSION, getCLIVersion, getSDKVersion, getSDKInfo, getVersionString, isSDKVersionCompatible, } from './version.js';
162
- // ============================================================================
163
- // SDK Errors (Phase 1: Best Practices)
164
- // ============================================================================
165
- export { SDKError, SDKErrorCode } from './errors.js';
166
- // ============================================================================
167
- // Testing Utilities (Phase 1: Best Practices)
168
- // ============================================================================
169
- export { MockAgent, createMockAgent, MockSettingsManager, createMockSettings, MockMCPServer, createMockMCPServer, waitForAgent, createMockToolResult, assertToolSuccess, assertToolFailure } from './testing.js';
170
- // Re-export detectProvider for advanced users who need provider detection
171
- export { detectProvider } from '../utils/provider-context.js';
172
- // Note: Internal utilities (withFileLock, SafeJsonFile, ProviderFileCache,
173
- // ProviderContextStore, etc.) are intentionally NOT exported.
174
- // These are implementation details, not part of the public SDK API.
175
- /**
176
- * Validation schema for agent options
177
- * @internal
178
- */
179
- const AgentOptionsSchema = z.object({
180
- provider: z.enum(['glm', 'grok', 'generic']).optional(),
181
- maxToolRounds: z.number().int().min(1).max(1000).optional(),
182
- debug: z.boolean().optional(),
183
- autoCleanup: z.boolean().optional(),
184
- // Zod v4: z.function() no longer uses .args()/.returns() - use custom type
185
- onDispose: z.custom((val) => typeof val === 'function').optional(),
186
- onError: z.custom((val) => typeof val === 'function').optional(),
187
- }).strict();
188
- /**
189
- * Create a new LLM Agent with configuration
190
- *
191
- * SECURITY: All credentials (API key, base URL, model) must be configured
192
- * via "ax-cli setup" command. This prevents security vulnerabilities where
193
- * credentials could be exposed in code or logs.
194
- *
195
- * @param options - Agent configuration options (non-sensitive only)
196
- * @returns Configured LLM Agent instance
197
- * @throws {SDKError} With code SETUP_NOT_RUN if ax-cli setup has not been run
198
- * @throws {SDKError} With code API_KEY_MISSING if API key not configured
199
- * @throws {SDKError} With code BASE_URL_MISSING if base URL not configured
200
- * @throws {SDKError} With code MODEL_MISSING if model not configured
201
- * @throws {SDKError} With code VALIDATION_ERROR if options are invalid
202
- *
203
- * @example
204
- * ```typescript
205
- * import { createAgent, SDKError, SDKErrorCode } from '@defai.digital/ax-cli/sdk';
206
- *
207
- * // First, user must run: ax-cli setup
208
- * // Then use SDK with settings from setup:
209
- *
210
- * const agent = await createAgent({
211
- * maxToolRounds: 50 // Optional: 1-1000, default 400
212
- * });
213
- *
214
- * try {
215
- * agent.on('stream', (chunk) => {
216
- * if (chunk.type === 'content') {
217
- * console.log(chunk.content);
218
- * }
219
- * });
220
- *
221
- * const result = await agent.processUserMessage('Analyze this codebase');
222
- * console.log(result);
223
- * } catch (error) {
224
- * if (SDKError.isSDKError(error)) {
225
- * switch (error.code) {
226
- * case SDKErrorCode.SETUP_NOT_RUN:
227
- * console.error('Run ax-cli setup first');
228
- * break;
229
- * case SDKErrorCode.API_KEY_MISSING:
230
- * console.error('API key not configured');
231
- * break;
232
- * }
233
- * }
234
- * } finally {
235
- * // Always cleanup resources
236
- * agent.dispose();
237
- * }
238
- * ```
239
- */
240
- export async function createAgent(options = {}) {
241
- // Validate input options
242
- let validated;
243
- try {
244
- validated = AgentOptionsSchema.parse(options);
245
- }
246
- catch (error) {
247
- throw new SDKError(SDKErrorCode.VALIDATION_ERROR, `Invalid agent options: ${error instanceof Error ? error.message : 'Unknown validation error'}`, error instanceof Error ? error : undefined);
248
- }
249
- // Determine provider (explicit > auto-detect)
250
- const provider = validated.provider ?? detectProvider();
251
- // Create provider context WITHOUT activating globally
252
- // This is critical for parallel agent support - each agent gets its own context
253
- // without affecting the global state that other agents might be using
254
- const providerContext = ProviderContext.create(provider);
255
- // Get provider-specific settings manager using the context
256
- const providerSettings = ProviderSettingsManager.forContext(providerContext);
257
- // Load settings from provider-specific config
258
- try {
259
- providerSettings.loadUserSettings();
260
- }
261
- catch (error) {
262
- const cliName = PROVIDER_CONFIGS[provider].cliName;
263
- throw new SDKError(SDKErrorCode.SETUP_NOT_RUN, `${cliName} setup has not been run. Please run "${cliName} setup" to configure your API key, model, and base URL before using the SDK.`, error instanceof Error ? error : undefined);
264
- }
265
- // Get configuration from provider-specific settings
266
- const apiKey = providerSettings.getApiKey();
267
- const model = providerSettings.getCurrentModel();
268
- const baseURL = providerSettings.getBaseURL();
269
- // Validate required settings exist
270
- const cliName = PROVIDER_CONFIGS[provider].cliName;
271
- if (!apiKey) {
272
- throw new SDKError(SDKErrorCode.API_KEY_MISSING, `No API key configured for ${provider}. Please run "${cliName} setup" to configure your credentials.`);
273
- }
274
- if (!baseURL) {
275
- throw new SDKError(SDKErrorCode.BASE_URL_MISSING, `No base URL configured for ${provider}. Please run "${cliName} setup" to configure your API provider.`);
276
- }
277
- // BUG FIX: Validate model is configured before creating agent
278
- // Without this, undefined model would fall back to getSettingsManager().getCurrentModel()
279
- // which uses the OLD singleton-based settings manager, not the provider-aware one.
280
- // This could cause the agent to use a different model in multi-provider scenarios.
281
- if (!model) {
282
- throw new SDKError(SDKErrorCode.MODEL_MISSING, `No model configured for ${provider}. Please run "${cliName} setup" to configure your AI model.`);
283
- }
284
- // Apply defaults for optional values
285
- const maxToolRounds = validated.maxToolRounds; // undefined is valid, LLMAgent uses 400 as default
286
- const debug = validated.debug ?? false;
287
- const autoCleanup = validated.autoCleanup ?? true; // Default: true (backward compatible)
288
- const onDispose = validated.onDispose;
289
- const onError = validated.onError;
290
- // Debug logging
291
- if (debug) {
292
- console.error('[AX SDK DEBUG] Creating agent with settings:');
293
- console.error('[AX SDK DEBUG] Provider:', provider);
294
- console.error('[AX SDK DEBUG] Config dir:', providerContext.userDir);
295
- console.error('[AX SDK DEBUG] Model:', model);
296
- console.error('[AX SDK DEBUG] Base URL:', baseURL);
297
- console.error('[AX SDK DEBUG] Max tool rounds:', maxToolRounds ?? 400);
298
- console.error('[AX SDK DEBUG] Auto cleanup:', autoCleanup);
299
- console.error('[AX SDK DEBUG] API key configured:', !!apiKey);
300
- console.error('[AX SDK DEBUG] Lifecycle hooks:', {
301
- onDispose: !!onDispose,
302
- onError: !!onError
303
- });
304
- }
305
- // Create agent instance with provider-specific settings
306
- const agent = new LLMAgent(apiKey, baseURL, model, maxToolRounds);
307
- // Store provider context on agent for later use
308
- agent._sdkProvider = provider;
309
- agent._sdkProviderContext = providerContext;
310
- agent._sdkProviderSettings = providerSettings;
311
- // Store the actual model and baseURL used at creation time
312
- // This prevents getAgentInfo from returning wrong values if config changes
313
- agent._sdkModel = model;
314
- agent._sdkBaseURL = baseURL;
315
- // Store creation timestamp for debugging and lifecycle tracking
316
- agent._sdkCreatedAt = new Date();
317
- // Store lifecycle hooks on agent
318
- agent._sdkLifecycleHooks = {
319
- onDispose,
320
- onError
321
- };
322
- // Store debug flag so disposeAsync can access it for logging
323
- agent._sdkDebug = debug;
324
- // BUG FIX: Track SDK-added listeners so they can be removed on dispose
325
- // Without this, listeners would persist after disposal causing memory leaks
326
- const sdkListeners = [];
327
- // Enable debug mode on agent if requested
328
- if (debug) {
329
- // Add debug event listener
330
- const debugStreamListener = (chunk) => {
331
- if (chunk.type === 'tool_calls' && chunk.toolCalls) {
332
- const toolNames = chunk.toolCalls.map((tc) => tc.function.name).join(', ');
333
- console.error('[AX SDK DEBUG] Tool calls:', toolNames);
334
- }
335
- else if (chunk.type === 'tool_result' && chunk.toolResult) {
336
- console.error('[AX SDK DEBUG] Tool result:', chunk.toolResult.success ? 'success' : 'failed');
337
- }
338
- };
339
- agent.on('stream', debugStreamListener);
340
- sdkListeners.push({ event: 'stream', listener: debugStreamListener });
341
- console.error('[AX SDK DEBUG] Agent created successfully');
342
- }
343
- // Phase 3: Add onError lifecycle hook integration
344
- if (onError) {
345
- // Wrap agent's processUserMessage to catch errors
346
- const originalProcessUserMessage = agent.processUserMessage.bind(agent);
347
- agent.processUserMessage = async (prompt) => {
348
- try {
349
- return await originalProcessUserMessage(prompt);
350
- }
351
- catch (error) {
352
- // BUG FIX: Handle non-Error throwables by wrapping them
353
- // Without this, throwing a string/null/undefined would skip the onError hook
354
- // but still propagate the error, leaving the user unaware
355
- const normalizedError = error instanceof Error
356
- ? error
357
- : new Error(String(error ?? 'Unknown error'));
358
- onError(normalizedError);
359
- throw error; // Re-throw original error to preserve behavior
360
- }
361
- };
362
- // Also listen to stream errors
363
- const errorListener = (error) => {
364
- onError(error);
365
- };
366
- agent.on('error', errorListener);
367
- sdkListeners.push({ event: 'error', listener: errorListener });
368
- }
369
- // Store listeners reference for cleanup
370
- agent._sdkListeners = sdkListeners;
371
- // BUG FIX: Track if SDK dispose wrapper has been called to prevent double disposal
372
- // Without this, calling dispose() multiple times would run cleanup logic and
373
- // onDispose hook multiple times, which could cause errors or unexpected behavior
374
- let sdkDisposeCompleted = false;
375
- // Store a reliable disposed flag that works regardless of autoCleanup setting
376
- agent._sdkDisposed = false;
377
- // Phase 3: Wrap dispose() to call onDispose hook
378
- const originalDispose = agent.dispose.bind(agent);
379
- // Store original dispose on agent so disposeAsync can access it
380
- agent._sdkOriginalDispose = originalDispose;
381
- agent.dispose = () => {
382
- // BUG FIX: Guard against double disposal in SDK wrapper
383
- // Check BOTH the closure variable AND the agent property
384
- // This handles the case where disposeAsync() was called first (sets _sdkDisposed)
385
- // or where dispose() was called first (sets sdkDisposeCompleted)
386
- if (sdkDisposeCompleted || agent._sdkDisposed === true) {
387
- return;
388
- }
389
- sdkDisposeCompleted = true;
390
- // Set the reliable disposed flag (works regardless of autoCleanup)
391
- agent._sdkDisposed = true;
392
- // Mark as disposed in SDK internal state to prevent auto-cleanup from running again
393
- const markDisposed = agent._sdkMarkDisposed;
394
- if (markDisposed) {
395
- markDisposed();
396
- }
397
- // BUG FIX: Remove cleanup handlers from process event listeners to prevent memory leaks
398
- // This must happen before onDispose hook in case the hook throws
399
- const cleanupHandler = agent._sdkCleanupHandler;
400
- if (cleanupHandler) {
401
- process.removeListener('exit', cleanupHandler);
402
- process.removeListener('SIGINT', cleanupHandler);
403
- process.removeListener('SIGTERM', cleanupHandler);
404
- process.removeListener('SIGHUP', cleanupHandler);
405
- delete agent._sdkCleanupHandler;
406
- }
407
- // BUG FIX: Remove SDK-added event listeners to prevent memory leaks
408
- // These include debug stream listener and onError listener
409
- const listeners = agent._sdkListeners;
410
- if (listeners && listeners.length > 0 && typeof agent.off === 'function') {
411
- for (const { event, listener } of listeners) {
412
- agent.off(event, listener);
413
- }
414
- delete agent._sdkListeners;
415
- }
416
- // Handle onDispose hook - if async, we can't await it in synchronous dispose
417
- // but we'll call it and let it run (fire-and-forget for async hooks)
418
- if (onDispose) {
419
- try {
420
- if (debug) {
421
- console.error('[AX SDK DEBUG] Calling onDispose hook');
422
- }
423
- const result = onDispose();
424
- // If it's a promise, handle errors but don't block
425
- if (result && typeof result.catch === 'function') {
426
- result.catch((error) => {
427
- if (debug) {
428
- console.error('[AX SDK DEBUG] Error in async onDispose hook:', error);
429
- }
430
- });
431
- }
432
- }
433
- catch (error) {
434
- if (debug) {
435
- console.error('[AX SDK DEBUG] Error in onDispose hook:', error);
436
- }
437
- // Continue with disposal even if hook fails
438
- }
439
- }
440
- // Call original dispose (synchronous)
441
- return originalDispose();
442
- };
443
- // Phase 3: Auto-cleanup on process exit (OPTIONAL)
444
- if (autoCleanup) {
445
- // Track if this agent has been disposed to avoid double cleanup
446
- let isDisposed = false;
447
- const cleanupHandler = () => {
448
- // Prevent double cleanup
449
- if (isDisposed) {
450
- return;
451
- }
452
- isDisposed = true;
453
- try {
454
- if (debug) {
455
- console.error('[AX SDK DEBUG] Auto-cleanup: disposing agent on process exit');
456
- }
457
- // Note: dispose() is synchronous in LLMAgent
458
- // For clean shutdown, call agent.dispose() explicitly before process exits.
459
- agent.dispose();
460
- }
461
- catch (error) {
462
- // Ignore errors during emergency cleanup
463
- if (debug) {
464
- console.error('[AX SDK DEBUG] Error during auto-cleanup:', error);
465
- }
466
- }
467
- };
468
- // Use process.on() instead of process.once() to allow multiple agents
469
- // Each agent has its own cleanup handler that tracks disposal state
470
- process.on('exit', cleanupHandler);
471
- process.on('SIGINT', cleanupHandler);
472
- process.on('SIGTERM', cleanupHandler);
473
- process.on('SIGHUP', cleanupHandler);
474
- // Store cleanup handler reference for manual removal if needed
475
- agent._sdkCleanupHandler = cleanupHandler;
476
- agent._sdkIsDisposed = () => isDisposed;
477
- agent._sdkMarkDisposed = () => { isDisposed = true; };
478
- }
479
- else {
480
- if (debug) {
481
- console.error('[AX SDK DEBUG] Auto-cleanup disabled, manual cleanup required');
482
- }
483
- }
484
- return agent;
485
- }
486
- /**
487
- * Create an agent configured for GLM (Z.AI)
488
- *
489
- * Convenience function that creates an agent with provider: 'glm'.
490
- * Uses configuration from ~/.ax-glm/config.json.
491
- *
492
- * @param options - Agent options (provider is set to 'glm')
493
- * @returns Configured LLM Agent for GLM
494
- *
495
- * @example
496
- * ```typescript
497
- * const agent = await createGLMAgent();
498
- * const result = await agent.processUserMessage('Hello');
499
- * agent.dispose();
500
- * ```
501
- */
502
- export async function createGLMAgent(options = {}) {
503
- return createAgent({ ...options, provider: 'glm' });
504
- }
505
- /**
506
- * Create an agent configured for Grok (xAI)
507
- *
508
- * Convenience function that creates an agent with provider: 'grok'.
509
- * Uses configuration from ~/.ax-grok/config.json.
510
- *
511
- * @param options - Agent options (provider is set to 'grok')
512
- * @returns Configured LLM Agent for Grok
513
- *
514
- * @example
515
- * ```typescript
516
- * const agent = await createGrokAgent();
517
- * const result = await agent.processUserMessage('Hello');
518
- * agent.dispose();
519
- * ```
520
- */
521
- export async function createGrokAgent(options = {}) {
522
- return createAgent({ ...options, provider: 'grok' });
523
- }
524
- /**
525
- * Create an agent without throwing errors
526
- *
527
- * Unlike createAgent(), this function returns a result object instead of throwing.
528
- * Useful for graceful error handling without try-catch blocks.
529
- *
530
- * @param options - Agent configuration options
531
- * @returns Result object with either agent or error
532
- *
533
- * @example
534
- * ```typescript
535
- * const result = await tryCreateAgent({ provider: 'glm' });
536
- *
537
- * if (result.success) {
538
- * // Use agent
539
- * await result.agent.processUserMessage('Hello');
540
- * result.agent.dispose();
541
- * } else {
542
- * // Handle error without try-catch
543
- * console.error('Failed:', result.error.code, result.error.message);
544
- * }
545
- * ```
546
- */
547
- export async function tryCreateAgent(options = {}) {
548
- try {
549
- const agent = await createAgent(options);
550
- return { success: true, agent, error: undefined };
551
- }
552
- catch (error) {
553
- const sdkError = SDKError.isSDKError(error)
554
- ? error
555
- : new SDKError(SDKErrorCode.INTERNAL_ERROR, error instanceof Error ? error.message : 'Unknown error creating agent', error instanceof Error ? error : undefined);
556
- return { success: false, agent: undefined, error: sdkError };
557
- }
558
- }
559
- /**
560
- * Run a function with a temporary agent that is automatically disposed
561
- *
562
- * This helper creates an agent, runs your function, and ensures the agent
563
- * is properly disposed even if an error occurs. Useful for:
564
- * - One-off agent operations
565
- * - Scripts that need cleanup guarantees
566
- * - Testing scenarios
567
- *
568
- * @param fn - Function to run with the agent
569
- * @param options - Agent configuration options
570
- * @returns Result of the function
571
- *
572
- * @example
573
- * ```typescript
574
- * // Simple usage
575
- * const result = await withAgent(async (agent) => {
576
- * return await agent.processUserMessage('Analyze this code');
577
- * });
578
- *
579
- * // With options
580
- * const result = await withAgent(
581
- * async (agent) => {
582
- * agent.on('stream', console.log);
583
- * return await agent.processUserMessage('Hello');
584
- * },
585
- * { provider: 'glm', maxToolRounds: 50 }
586
- * );
587
- * ```
588
- */
589
- export async function withAgent(fn, options = {}) {
590
- const agent = await createAgent(options);
591
- try {
592
- return await fn(agent);
593
- }
594
- finally {
595
- // Use disposeAsync to properly await any async onDispose hooks
596
- await disposeAsync(agent);
597
- }
598
- }
599
- /**
600
- * Run a function with a temporary agent, returning result or error
601
- *
602
- * Combines withAgent and tryCreateAgent - creates agent, runs function,
603
- * disposes, and returns result without throwing. Ideal for error-tolerant
604
- * workflows.
605
- *
606
- * @param fn - Function to run with the agent
607
- * @param options - Agent configuration options
608
- * @returns Result object with either value or error
609
- *
610
- * @example
611
- * ```typescript
612
- * const result = await tryWithAgent(async (agent) => {
613
- * return await agent.processUserMessage('Hello');
614
- * }, { provider: 'grok' });
615
- *
616
- * if (result.success) {
617
- * console.log('Got response:', result.value);
618
- * } else {
619
- * console.error('Failed:', result.error.message);
620
- * }
621
- * ```
622
- */
623
- export async function tryWithAgent(fn, options = {}) {
624
- const createResult = await tryCreateAgent(options);
625
- if (!createResult.success) {
626
- return { success: false, value: undefined, error: createResult.error };
627
- }
628
- try {
629
- const value = await fn(createResult.agent);
630
- return { success: true, value, error: undefined };
631
- }
632
- catch (error) {
633
- const sdkError = SDKError.isSDKError(error)
634
- ? error
635
- : new SDKError(SDKErrorCode.INTERNAL_ERROR, error instanceof Error ? error.message : 'Unknown error during agent operation', error instanceof Error ? error : undefined);
636
- return { success: false, value: undefined, error: sdkError };
637
- }
638
- finally {
639
- await disposeAsync(createResult.agent);
640
- }
641
- }
642
- /**
643
- * Create a specialized subagent for specific tasks
644
- *
645
- * @param role - The role/specialty of the subagent
646
- * @param options - Optional configuration including provider
647
- * @returns Configured Subagent instance
648
- *
649
- * @example
650
- * ```typescript
651
- * // Basic usage
652
- * const testAgent = createSubagent(SubagentRole.TESTING, {
653
- * maxToolRounds: 20,
654
- * priority: 2
655
- * });
656
- *
657
- * // With provider for parallel support
658
- * const glmSubagent = createSubagent(SubagentRole.ANALYSIS, {
659
- * provider: 'glm',
660
- * maxToolRounds: 30
661
- * });
662
- *
663
- * const result = await testAgent.execute({
664
- * id: 'task-1',
665
- * description: 'Write unit tests for auth module',
666
- * context: { files: ['src/auth.ts'] }
667
- * });
668
- * ```
669
- */
670
- export function createSubagent(role, options) {
671
- // BUG FIX: Clone config to prevent external mutation affecting the subagent
672
- // Without this, the caller could modify config.allowedTools array after creation
673
- // and unexpectedly change which tools the subagent can use
674
- let clonedConfig;
675
- if (options) {
676
- // BUG FIX: Use destructuring to exclude provider instead of setting undefined
677
- // Setting `provider: undefined` explicitly could cause issues if Subagent
678
- // constructor checks for presence of `provider` key vs undefined value
679
- const { provider: _provider, allowedTools, ...rest } = options;
680
- clonedConfig = {
681
- ...rest,
682
- // Deep clone arrays to prevent mutation
683
- allowedTools: allowedTools ? [...allowedTools] : undefined,
684
- };
685
- }
686
- // Create subagent
687
- const subagent = new Subagent(role, clonedConfig);
688
- // Store provider context if specified for later use
689
- if (options?.provider) {
690
- const providerContext = ProviderContext.create(options.provider);
691
- const providerSettings = ProviderSettingsManager.forContext(providerContext);
692
- subagent._sdkProvider = options.provider;
693
- subagent._sdkProviderContext = providerContext;
694
- subagent._sdkProviderSettings = providerSettings;
695
- }
696
- return subagent;
697
- }
698
- /**
699
- * Remove auto-cleanup handlers from an agent
700
- *
701
- * Use this function to remove the automatic cleanup handlers registered by createAgent()
702
- * when autoCleanup was enabled (default). This gives you manual control over when the
703
- * agent is disposed.
704
- *
705
- * **Use Cases:**
706
- * - Long-running services that manage agent lifecycle manually
707
- * - Testing scenarios where you want precise control over cleanup
708
- * - Library code that embeds agents
709
- *
710
- * **Note:** Only works if agent was created with autoCleanup: true (default).
711
- * If autoCleanup was false, this function does nothing.
712
- *
713
- * @param agent - The agent instance created with createAgent()
714
- *
715
- * @example
716
- * ```typescript
717
- * // Create agent with auto-cleanup (default)
718
- * const agent = await createAgent();
719
- *
720
- * // Later, take manual control
721
- * removeCleanupHandlers(agent);
722
- *
723
- * // Now you must manually dispose
724
- * agent.dispose();
725
- * ```
726
- *
727
- * @example
728
- * ```typescript
729
- * // For manual cleanup from the start, use autoCleanup: false
730
- * const agent = await createAgent({ autoCleanup: false });
731
- * // No need to call removeCleanupHandlers
732
- * agent.dispose(); // Manual cleanup
733
- * ```
734
- */
735
- export function removeCleanupHandlers(agent) {
736
- const cleanupHandler = agent._sdkCleanupHandler;
737
- const markDisposed = agent._sdkMarkDisposed;
738
- if (!cleanupHandler) {
739
- // No cleanup handlers registered (autoCleanup was false)
740
- return;
741
- }
742
- // Mark as disposed to prevent cleanup handler from running if signal fires later
743
- if (markDisposed) {
744
- markDisposed();
745
- }
746
- // Remove all process event listeners
747
- process.removeListener('exit', cleanupHandler);
748
- process.removeListener('SIGINT', cleanupHandler);
749
- process.removeListener('SIGTERM', cleanupHandler);
750
- process.removeListener('SIGHUP', cleanupHandler);
751
- // Clear the references
752
- delete agent._sdkCleanupHandler;
753
- delete agent._sdkIsDisposed;
754
- delete agent._sdkMarkDisposed;
755
- }
756
- /**
757
- * Initialize SDK and MCP servers
758
- *
759
- * SECURITY: This function does NOT accept credentials. All credentials must be
760
- * configured via "ax-cli setup" command. This function only initializes MCP servers.
761
- *
762
- * @example
763
- * ```typescript
764
- * // Initialize MCP servers from ax-cli settings
765
- * await initializeSDK();
766
- * ```
767
- *
768
- * @deprecated Most SDK users don't need to call this - createAgent() handles initialization.
769
- * Only call this if you need to pre-initialize MCP servers.
770
- */
771
- export async function initializeSDK() {
772
- // Initialize MCP servers from settings configured via ax-cli setup
773
- await initializeMCPServers();
774
- }
775
- /**
776
- * Get information about an agent created with createAgent()
777
- *
778
- * This function extracts the provider, model, and configuration information
779
- * from an agent instance. Useful for debugging, logging, and multi-provider
780
- * scenarios where you need to know which provider an agent is using.
781
- *
782
- * @param agent - The agent instance created with createAgent()
783
- * @returns AgentInfo object with provider/model details, or null if not SDK-created
784
- *
785
- * @example
786
- * ```typescript
787
- * const glmAgent = await createAgent({ provider: 'glm' });
788
- * const grokAgent = await createAgent({ provider: 'grok' });
789
- *
790
- * const glmInfo = getAgentInfo(glmAgent);
791
- * console.log(glmInfo?.provider); // 'glm'
792
- * console.log(glmInfo?.model); // 'glm-4.6'
793
- *
794
- * const grokInfo = getAgentInfo(grokAgent);
795
- * console.log(grokInfo?.provider); // 'grok'
796
- * console.log(grokInfo?.model); // 'grok-4-0709'
797
- * ```
798
- */
799
- export function getAgentInfo(agent) {
800
- const provider = agent._sdkProvider;
801
- const providerContext = agent._sdkProviderContext;
802
- // BUG FIX: Use stored model/baseURL from creation time, not from settings
803
- // Settings could change after agent creation, giving wrong info
804
- const model = agent._sdkModel;
805
- const baseURL = agent._sdkBaseURL;
806
- // BUG FIX: Use the reliable _sdkDisposed flag instead of _sdkIsDisposed function
807
- // _sdkIsDisposed only exists when autoCleanup: true, but _sdkDisposed is always set
808
- const isDisposed = agent._sdkDisposed;
809
- const createdAt = agent._sdkCreatedAt;
810
- if (!provider || !providerContext || !createdAt) {
811
- // Not created via SDK createAgent()
812
- return null;
813
- }
814
- const config = PROVIDER_CONFIGS[provider];
815
- return {
816
- provider,
817
- providerDisplayName: config.displayName,
818
- model,
819
- baseURL,
820
- isDisposed: isDisposed ?? false,
821
- configDir: providerContext.userDir,
822
- cliName: config.cliName,
823
- createdAt,
824
- };
825
- }
826
- /**
827
- * Get the model an agent is using
828
- *
829
- * Quick accessor to get just the model name from an SDK-created agent.
830
- * Returns undefined if the agent was not created via createAgent().
831
- *
832
- * @param agent - The agent instance
833
- * @returns The model name or undefined
834
- *
835
- * @example
836
- * ```typescript
837
- * const agent = await createAgent({ provider: 'glm' });
838
- * console.log(getAgentModel(agent)); // 'glm-4.6'
839
- * ```
840
- */
841
- export function getAgentModel(agent) {
842
- return agent._sdkModel;
843
- }
844
- /**
845
- * Get the base URL an agent is using
846
- *
847
- * Quick accessor to get just the base URL from an SDK-created agent.
848
- * Returns undefined if the agent was not created via createAgent().
849
- *
850
- * @param agent - The agent instance
851
- * @returns The base URL or undefined
852
- *
853
- * @example
854
- * ```typescript
855
- * const agent = await createAgent({ provider: 'grok' });
856
- * console.log(getAgentBaseURL(agent)); // 'https://api.x.ai/v1'
857
- * ```
858
- */
859
- export function getAgentBaseURL(agent) {
860
- return agent._sdkBaseURL;
861
- }
862
- /**
863
- * Get the provider an agent is using
864
- *
865
- * Quick accessor to get just the provider type from an SDK-created agent.
866
- * Returns undefined if the agent was not created via createAgent().
867
- *
868
- * @param agent - The agent instance
869
- * @returns The provider type or undefined
870
- *
871
- * @example
872
- * ```typescript
873
- * const agent = await createAgent({ provider: 'glm' });
874
- * console.log(getAgentProvider(agent)); // 'glm'
875
- * ```
876
- */
877
- export function getAgentProvider(agent) {
878
- return agent._sdkProvider;
879
- }
880
- /**
881
- * Get when an agent was created
882
- *
883
- * Quick accessor to get the creation timestamp from an SDK-created agent.
884
- * Useful for logging, monitoring, and debugging agent lifecycle.
885
- * Returns undefined if the agent was not created via createAgent().
886
- *
887
- * @param agent - The agent instance
888
- * @returns The creation Date or undefined
889
- *
890
- * @example
891
- * ```typescript
892
- * const agent = await createAgent();
893
- * console.log(getAgentCreatedAt(agent)); // Date object
894
- * ```
895
- */
896
- export function getAgentCreatedAt(agent) {
897
- return agent._sdkCreatedAt;
898
- }
899
- /**
900
- * Get how long an agent has been running (age in milliseconds)
901
- *
902
- * Returns the time elapsed since the agent was created. Useful for:
903
- * - Monitoring long-running agents
904
- * - Implementing agent timeouts
905
- * - Debugging performance issues
906
- * - Logging agent lifecycle metrics
907
- *
908
- * @param agent - The agent instance
909
- * @returns Age in milliseconds, or undefined if not SDK-created
910
- *
911
- * @example
912
- * ```typescript
913
- * const agent = await createAgent();
914
- *
915
- * // ... some work ...
916
- *
917
- * const ageMs = getAgentAge(agent);
918
- * if (ageMs !== undefined) {
919
- * console.log(`Agent running for ${Math.round(ageMs / 1000)}s`);
920
- *
921
- * // Implement timeout
922
- * if (ageMs > 5 * 60 * 1000) { // 5 minutes
923
- * console.warn('Agent running too long, disposing');
924
- * agent.dispose();
925
- * }
926
- * }
927
- * ```
928
- */
929
- export function getAgentAge(agent) {
930
- const createdAt = agent._sdkCreatedAt;
931
- if (!createdAt) {
932
- return undefined;
933
- }
934
- return Date.now() - createdAt.getTime();
935
- }
936
- /**
937
- * Format agent age as human-readable string
938
- *
939
- * Convenience function to get agent age as a formatted string.
940
- * Returns undefined if agent was not created via createAgent().
941
- *
942
- * @param agent - The agent instance
943
- * @returns Formatted age string (e.g., "1m 30s", "2h 15m"), or undefined
944
- *
945
- * @example
946
- * ```typescript
947
- * const agent = await createAgent();
948
- * // ... work ...
949
- * console.log(`Agent age: ${formatAgentAge(agent)}`); // "Agent age: 1m 30s"
950
- * ```
951
- */
952
- export function formatAgentAge(agent) {
953
- const ageMs = getAgentAge(agent);
954
- if (ageMs === undefined) {
955
- return undefined;
956
- }
957
- const seconds = Math.floor(ageMs / 1000);
958
- const minutes = Math.floor(seconds / 60);
959
- const hours = Math.floor(minutes / 60);
960
- if (hours > 0) {
961
- const remainingMinutes = minutes % 60;
962
- return `${hours}h ${remainingMinutes}m`;
963
- }
964
- else if (minutes > 0) {
965
- const remainingSeconds = seconds % 60;
966
- return `${minutes}m ${remainingSeconds}s`;
967
- }
968
- else {
969
- return `${seconds}s`;
970
- }
971
- }
972
- /**
973
- * Check if an agent is busy (bash executing) or disposed
974
- *
975
- * This function provides a quick check to determine if an agent is available
976
- * to process new messages. An agent is considered "busy" if:
977
- * - It has been disposed (cannot be used at all)
978
- * - It is currently executing a bash command
979
- *
980
- * Useful for:
981
- * - Pre-flight checks before sending messages
982
- * - Implementing request queuing
983
- * - Health monitoring dashboards
984
- *
985
- * @param agent - The agent instance to check
986
- * @returns Object with availability status
987
- *
988
- * @example
989
- * ```typescript
990
- * const agent = await createAgent();
991
- *
992
- * // Check before processing
993
- * const status = getAgentStatus(agent);
994
- * if (!status.available) {
995
- * console.log('Agent not available:', status.reason);
996
- * return;
997
- * }
998
- *
999
- * await agent.processUserMessage('Hello');
1000
- * ```
1001
- */
1002
- export function getAgentStatus(agent) {
1003
- const disposed = isAgentDisposed(agent);
1004
- const isBusy = typeof agent.isBashExecuting === 'function'
1005
- ? agent.isBashExecuting()
1006
- : false;
1007
- const isDisposed = disposed === true;
1008
- const available = !isDisposed && !isBusy;
1009
- let reason;
1010
- if (isDisposed) {
1011
- reason = 'Agent has been disposed';
1012
- }
1013
- else if (isBusy) {
1014
- reason = 'Agent is currently executing bash command';
1015
- }
1016
- return {
1017
- available,
1018
- isDisposed,
1019
- isBusy,
1020
- reason,
1021
- ageMs: getAgentAge(agent),
1022
- };
1023
- }
1024
- /**
1025
- * Check if a provider is properly configured and ready to use
1026
- *
1027
- * This function validates that a provider has all required configuration
1028
- * (API key, base URL, model) without actually creating an agent or making
1029
- * API calls. Useful for:
1030
- * - Pre-flight checks before creating agents
1031
- * - Setup wizards and configuration UIs
1032
- * - Health checks in long-running services
1033
- *
1034
- * @param provider - Provider to check (defaults to auto-detect)
1035
- * @returns ProviderHealthResult with configuration status
1036
- *
1037
- * @example
1038
- * ```typescript
1039
- * // Check specific provider
1040
- * const glmHealth = checkProviderHealth('glm');
1041
- * if (!glmHealth.healthy) {
1042
- * console.error('GLM not configured:', glmHealth.message);
1043
- * console.log('Run: ax-glm setup');
1044
- * }
1045
- *
1046
- * // Check all providers
1047
- * const providers: ProviderType[] = ['glm', 'grok'];
1048
- * for (const p of providers) {
1049
- * const health = checkProviderHealth(p);
1050
- * console.log(`${p}: ${health.healthy ? '✓' : '✗'} ${health.message}`);
1051
- * }
1052
- * ```
1053
- */
1054
- export function checkProviderHealth(provider) {
1055
- const targetProvider = provider ?? detectProvider();
1056
- const config = PROVIDER_CONFIGS[targetProvider];
1057
- const settings = ProviderSettingsManager.forProvider(targetProvider);
1058
- const hasApiKey = !!settings.getApiKey();
1059
- const hasBaseURL = !!settings.getBaseURL();
1060
- const hasModel = !!settings.getCurrentModel();
1061
- const issues = [];
1062
- if (!hasApiKey)
1063
- issues.push('API key missing');
1064
- if (!hasBaseURL)
1065
- issues.push('Base URL missing');
1066
- if (!hasModel)
1067
- issues.push('Model not set');
1068
- const healthy = hasApiKey && hasBaseURL && hasModel;
1069
- let message;
1070
- if (healthy) {
1071
- message = `${config.displayName} is configured and ready`;
1072
- }
1073
- else {
1074
- message = `${config.displayName} needs configuration: ${issues.join(', ')}`;
1075
- }
1076
- return {
1077
- healthy,
1078
- provider: targetProvider,
1079
- hasApiKey,
1080
- hasBaseURL,
1081
- hasModel,
1082
- message,
1083
- error: healthy ? undefined : `Run "${config.cliName} setup" to configure`,
1084
- };
1085
- }
1086
- /**
1087
- * Get health status for all supported providers
1088
- *
1089
- * @returns Array of health results for all providers
1090
- *
1091
- * @example
1092
- * ```typescript
1093
- * const allHealth = getAllProviderHealth();
1094
- * const configured = allHealth.filter(h => h.healthy);
1095
- * console.log(`${configured.length} providers ready`);
1096
- * ```
1097
- */
1098
- export function getAllProviderHealth() {
1099
- const providers = ['glm', 'grok', 'generic'];
1100
- return providers.map(p => checkProviderHealth(p));
1101
- }
1102
- // ============================================================================
1103
- // Agent Lifecycle Utilities (v5.1 - High-Value Features)
1104
- // ============================================================================
1105
- /**
1106
- * Check if an agent has been disposed
1107
- *
1108
- * This function provides a reliable way to check if an agent created with
1109
- * createAgent() has been disposed. Works regardless of the `autoCleanup` setting.
1110
- *
1111
- * @param agent - The agent instance to check
1112
- * @returns true if the agent has been disposed, false otherwise
1113
- * @returns undefined if the agent was not created via createAgent()
1114
- *
1115
- * @example
1116
- * ```typescript
1117
- * const agent = await createAgent();
1118
- * console.log(isAgentDisposed(agent)); // false
1119
- *
1120
- * agent.dispose();
1121
- * console.log(isAgentDisposed(agent)); // true
1122
- * ```
1123
- */
1124
- export function isAgentDisposed(agent) {
1125
- const disposed = agent._sdkDisposed;
1126
- if (disposed === undefined) {
1127
- // Not created via SDK createAgent()
1128
- return undefined;
1129
- }
1130
- return disposed;
1131
- }
1132
- /**
1133
- * Dispose an agent asynchronously, properly awaiting the onDispose hook
1134
- *
1135
- * The standard `agent.dispose()` is synchronous and fires async onDispose hooks
1136
- * in a fire-and-forget manner. Use this function when you need to ensure the
1137
- * onDispose hook completes before continuing.
1138
- *
1139
- * @param agent - The agent instance to dispose
1140
- * @returns Promise that resolves when disposal is complete
1141
- *
1142
- * @example
1143
- * ```typescript
1144
- * const agent = await createAgent({
1145
- * onDispose: async () => {
1146
- * await saveState(); // This WILL be awaited with disposeAsync
1147
- * }
1148
- * });
1149
- *
1150
- * // ... use agent ...
1151
- *
1152
- * // Properly await cleanup
1153
- * await disposeAsync(agent);
1154
- * console.log('Cleanup complete, state saved');
1155
- * ```
1156
- */
1157
- export async function disposeAsync(agent) {
1158
- // Get debug flag for logging
1159
- const debug = agent._sdkDebug;
1160
- // Check if this is an SDK-created agent
1161
- const originalDispose = agent._sdkOriginalDispose;
1162
- if (typeof originalDispose !== 'function') {
1163
- // Not created via SDK createAgent() - fall back to regular dispose
1164
- // This is a graceful fallback for non-SDK agents
1165
- if (debug) {
1166
- console.error('[AX SDK DEBUG] disposeAsync: Agent not created via createAgent(), using regular dispose');
1167
- }
1168
- agent.dispose();
1169
- return;
1170
- }
1171
- // Check if already disposed
1172
- const disposed = agent._sdkDisposed;
1173
- if (disposed === true) {
1174
- if (debug) {
1175
- console.error('[AX SDK DEBUG] disposeAsync: Agent already disposed, skipping');
1176
- }
1177
- return; // Already disposed
1178
- }
1179
- // Get the onDispose hook if it exists
1180
- const hooks = agent._sdkLifecycleHooks;
1181
- const onDispose = hooks?.onDispose;
1182
- // Mark as disposed to prevent sync dispose() from running cleanup again
1183
- agent._sdkDisposed = true;
1184
- // Also mark the autoCleanup tracker as disposed to prevent signal handlers from triggering
1185
- const markDisposed = agent._sdkMarkDisposed;
1186
- if (markDisposed) {
1187
- markDisposed();
1188
- }
1189
- // Call onDispose hook and await if it returns a promise
1190
- if (onDispose) {
1191
- try {
1192
- if (debug) {
1193
- console.error('[AX SDK DEBUG] disposeAsync: Calling onDispose hook');
1194
- }
1195
- const result = onDispose();
1196
- if (result && typeof result.then === 'function') {
1197
- await result;
1198
- }
1199
- if (debug) {
1200
- console.error('[AX SDK DEBUG] disposeAsync: onDispose hook completed');
1201
- }
1202
- }
1203
- catch (error) {
1204
- // Log but don't throw - disposal should complete even if hook fails
1205
- if (debug) {
1206
- console.error('[AX SDK DEBUG] disposeAsync: Error in onDispose hook:', error);
1207
- }
1208
- // Users should handle errors in their onDispose hook
1209
- }
1210
- }
1211
- // Remove cleanup handlers from process event listeners
1212
- const cleanupHandler = agent._sdkCleanupHandler;
1213
- if (cleanupHandler) {
1214
- process.removeListener('exit', cleanupHandler);
1215
- process.removeListener('SIGINT', cleanupHandler);
1216
- process.removeListener('SIGTERM', cleanupHandler);
1217
- process.removeListener('SIGHUP', cleanupHandler);
1218
- delete agent._sdkCleanupHandler;
1219
- }
1220
- // Remove SDK-added event listeners
1221
- const listeners = agent._sdkListeners;
1222
- if (listeners && listeners.length > 0 && typeof agent.off === 'function') {
1223
- for (const { event, listener } of listeners) {
1224
- agent.off(event, listener);
1225
- }
1226
- delete agent._sdkListeners;
1227
- }
1228
- // Call the stored original dispose directly, NOT agent.dispose()
1229
- // agent.dispose() would call our wrapper which would:
1230
- // 1. Skip because sdkDisposeCompleted might be false (closure variable)
1231
- // 2. Or run the full wrapper logic including onDispose hook AGAIN
1232
- // Instead, call _sdkOriginalDispose which is the unwrapped LLMAgent.dispose()
1233
- originalDispose();
1234
- if (debug) {
1235
- console.error('[AX SDK DEBUG] disposeAsync: Disposal complete');
1236
- }
1237
- }
1238
- /**
1239
- * Get information about a subagent created with createSubagent()
1240
- *
1241
- * @param subagent - The subagent instance
1242
- * @returns SubagentInfo object with provider details
1243
- *
1244
- * @example
1245
- * ```typescript
1246
- * const subagent = createSubagent(SubagentRole.TESTING, { provider: 'glm' });
1247
- * const info = getSubagentInfo(subagent);
1248
- * console.log(info.provider); // 'glm'
1249
- * console.log(info.role); // SubagentRole.TESTING
1250
- * ```
1251
- */
1252
- export function getSubagentInfo(subagent) {
1253
- const provider = subagent._sdkProvider;
1254
- const providerContext = subagent._sdkProviderContext;
1255
- let providerDisplayName;
1256
- let configDir;
1257
- let cliName;
1258
- if (provider && providerContext) {
1259
- const config = PROVIDER_CONFIGS[provider];
1260
- providerDisplayName = config.displayName;
1261
- configDir = providerContext.userDir;
1262
- cliName = config.cliName;
1263
- }
1264
- return {
1265
- provider,
1266
- providerDisplayName,
1267
- configDir,
1268
- cliName,
1269
- role: subagent.role,
1270
- };
1271
- }
1272
- //# sourceMappingURL=index.js.map