@posthog/agent 1.26.0 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (571) hide show
  1. package/dist/index.d.ts +1274 -20
  2. package/dist/index.js +7296 -11
  3. package/dist/index.js.map +1 -1
  4. package/package.json +6 -12
  5. package/src/agent.ts +42 -5
  6. package/src/types.ts +1 -1
  7. package/dist/_virtual/_commonjsHelpers.js +0 -6
  8. package/dist/_virtual/_commonjsHelpers.js.map +0 -1
  9. package/dist/_virtual/_tslib.js +0 -74
  10. package/dist/_virtual/_tslib.js.map +0 -1
  11. package/dist/_virtual/additionalItems.js +0 -4
  12. package/dist/_virtual/additionalItems.js.map +0 -1
  13. package/dist/_virtual/additionalProperties.js +0 -4
  14. package/dist/_virtual/additionalProperties.js.map +0 -1
  15. package/dist/_virtual/ajv.js +0 -4
  16. package/dist/_virtual/ajv.js.map +0 -1
  17. package/dist/_virtual/allOf.js +0 -4
  18. package/dist/_virtual/allOf.js.map +0 -1
  19. package/dist/_virtual/anyOf.js +0 -4
  20. package/dist/_virtual/anyOf.js.map +0 -1
  21. package/dist/_virtual/applicability.js +0 -4
  22. package/dist/_virtual/applicability.js.map +0 -1
  23. package/dist/_virtual/boolSchema.js +0 -4
  24. package/dist/_virtual/boolSchema.js.map +0 -1
  25. package/dist/_virtual/code.js +0 -4
  26. package/dist/_virtual/code.js.map +0 -1
  27. package/dist/_virtual/code2.js +0 -4
  28. package/dist/_virtual/code2.js.map +0 -1
  29. package/dist/_virtual/const.js +0 -4
  30. package/dist/_virtual/const.js.map +0 -1
  31. package/dist/_virtual/contains.js +0 -4
  32. package/dist/_virtual/contains.js.map +0 -1
  33. package/dist/_virtual/core.js +0 -4
  34. package/dist/_virtual/core.js.map +0 -1
  35. package/dist/_virtual/dataType.js +0 -4
  36. package/dist/_virtual/dataType.js.map +0 -1
  37. package/dist/_virtual/defaults.js +0 -4
  38. package/dist/_virtual/defaults.js.map +0 -1
  39. package/dist/_virtual/dependencies.js +0 -4
  40. package/dist/_virtual/dependencies.js.map +0 -1
  41. package/dist/_virtual/draft7.js +0 -4
  42. package/dist/_virtual/draft7.js.map +0 -1
  43. package/dist/_virtual/enum.js +0 -4
  44. package/dist/_virtual/enum.js.map +0 -1
  45. package/dist/_virtual/equal.js +0 -4
  46. package/dist/_virtual/equal.js.map +0 -1
  47. package/dist/_virtual/errors.js +0 -4
  48. package/dist/_virtual/errors.js.map +0 -1
  49. package/dist/_virtual/format.js +0 -4
  50. package/dist/_virtual/format.js.map +0 -1
  51. package/dist/_virtual/formats.js +0 -4
  52. package/dist/_virtual/formats.js.map +0 -1
  53. package/dist/_virtual/id.js +0 -4
  54. package/dist/_virtual/id.js.map +0 -1
  55. package/dist/_virtual/if.js +0 -4
  56. package/dist/_virtual/if.js.map +0 -1
  57. package/dist/_virtual/index.js +0 -4
  58. package/dist/_virtual/index.js.map +0 -1
  59. package/dist/_virtual/index10.js +0 -4
  60. package/dist/_virtual/index10.js.map +0 -1
  61. package/dist/_virtual/index11.js +0 -4
  62. package/dist/_virtual/index11.js.map +0 -1
  63. package/dist/_virtual/index2.js +0 -4
  64. package/dist/_virtual/index2.js.map +0 -1
  65. package/dist/_virtual/index3.js +0 -4
  66. package/dist/_virtual/index3.js.map +0 -1
  67. package/dist/_virtual/index4.js +0 -4
  68. package/dist/_virtual/index4.js.map +0 -1
  69. package/dist/_virtual/index5.js +0 -4
  70. package/dist/_virtual/index5.js.map +0 -1
  71. package/dist/_virtual/index6.js +0 -4
  72. package/dist/_virtual/index6.js.map +0 -1
  73. package/dist/_virtual/index7.js +0 -4
  74. package/dist/_virtual/index7.js.map +0 -1
  75. package/dist/_virtual/index8.js +0 -4
  76. package/dist/_virtual/index8.js.map +0 -1
  77. package/dist/_virtual/index9.js +0 -4
  78. package/dist/_virtual/index9.js.map +0 -1
  79. package/dist/_virtual/items.js +0 -4
  80. package/dist/_virtual/items.js.map +0 -1
  81. package/dist/_virtual/items2020.js +0 -4
  82. package/dist/_virtual/items2020.js.map +0 -1
  83. package/dist/_virtual/keyword.js +0 -4
  84. package/dist/_virtual/keyword.js.map +0 -1
  85. package/dist/_virtual/limit.js +0 -4
  86. package/dist/_virtual/limit.js.map +0 -1
  87. package/dist/_virtual/limitItems.js +0 -4
  88. package/dist/_virtual/limitItems.js.map +0 -1
  89. package/dist/_virtual/limitLength.js +0 -4
  90. package/dist/_virtual/limitLength.js.map +0 -1
  91. package/dist/_virtual/limitNumber.js +0 -4
  92. package/dist/_virtual/limitNumber.js.map +0 -1
  93. package/dist/_virtual/limitProperties.js +0 -4
  94. package/dist/_virtual/limitProperties.js.map +0 -1
  95. package/dist/_virtual/metadata.js +0 -4
  96. package/dist/_virtual/metadata.js.map +0 -1
  97. package/dist/_virtual/multipleOf.js +0 -4
  98. package/dist/_virtual/multipleOf.js.map +0 -1
  99. package/dist/_virtual/names.js +0 -4
  100. package/dist/_virtual/names.js.map +0 -1
  101. package/dist/_virtual/not.js +0 -4
  102. package/dist/_virtual/not.js.map +0 -1
  103. package/dist/_virtual/oneOf.js +0 -4
  104. package/dist/_virtual/oneOf.js.map +0 -1
  105. package/dist/_virtual/pattern.js +0 -4
  106. package/dist/_virtual/pattern.js.map +0 -1
  107. package/dist/_virtual/patternProperties.js +0 -4
  108. package/dist/_virtual/patternProperties.js.map +0 -1
  109. package/dist/_virtual/prefixItems.js +0 -4
  110. package/dist/_virtual/prefixItems.js.map +0 -1
  111. package/dist/_virtual/properties.js +0 -4
  112. package/dist/_virtual/properties.js.map +0 -1
  113. package/dist/_virtual/propertyNames.js +0 -4
  114. package/dist/_virtual/propertyNames.js.map +0 -1
  115. package/dist/_virtual/ref.js +0 -4
  116. package/dist/_virtual/ref.js.map +0 -1
  117. package/dist/_virtual/ref_error.js +0 -4
  118. package/dist/_virtual/ref_error.js.map +0 -1
  119. package/dist/_virtual/required.js +0 -4
  120. package/dist/_virtual/required.js.map +0 -1
  121. package/dist/_virtual/resolve.js +0 -4
  122. package/dist/_virtual/resolve.js.map +0 -1
  123. package/dist/_virtual/rules.js +0 -4
  124. package/dist/_virtual/rules.js.map +0 -1
  125. package/dist/_virtual/scope.js +0 -4
  126. package/dist/_virtual/scope.js.map +0 -1
  127. package/dist/_virtual/subschema.js +0 -4
  128. package/dist/_virtual/subschema.js.map +0 -1
  129. package/dist/_virtual/thenElse.js +0 -4
  130. package/dist/_virtual/thenElse.js.map +0 -1
  131. package/dist/_virtual/types.js +0 -4
  132. package/dist/_virtual/types.js.map +0 -1
  133. package/dist/_virtual/ucs2length.js +0 -4
  134. package/dist/_virtual/ucs2length.js.map +0 -1
  135. package/dist/_virtual/uniqueItems.js +0 -4
  136. package/dist/_virtual/uniqueItems.js.map +0 -1
  137. package/dist/_virtual/uri.js +0 -4
  138. package/dist/_virtual/uri.js.map +0 -1
  139. package/dist/_virtual/util.js +0 -4
  140. package/dist/_virtual/util.js.map +0 -1
  141. package/dist/_virtual/validation_error.js +0 -4
  142. package/dist/_virtual/validation_error.js.map +0 -1
  143. package/dist/example-client.d.ts +0 -3
  144. package/dist/example-client.d.ts.map +0 -1
  145. package/dist/example.d.ts +0 -3
  146. package/dist/example.d.ts.map +0 -1
  147. package/dist/index.d.ts.map +0 -1
  148. package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +0 -891
  149. package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +0 -1
  150. package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +0 -876
  151. package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +0 -1
  152. package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +0 -66
  153. package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +0 -1
  154. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +0 -23
  155. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +0 -1
  156. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +0 -331
  157. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +0 -1
  158. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +0 -717
  159. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +0 -1
  160. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +0 -221
  161. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +0 -1
  162. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +0 -56
  163. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +0 -1
  164. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +0 -440
  165. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +0 -1
  166. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +0 -94
  167. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +0 -1
  168. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +0 -1610
  169. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +0 -1
  170. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +0 -91
  171. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +0 -1
  172. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +0 -133
  173. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +0 -1
  174. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +0 -9
  175. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +0 -1
  176. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +0 -9
  177. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +0 -1
  178. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +0 -112
  179. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +0 -1
  180. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +0 -136
  181. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +0 -1
  182. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +0 -112
  183. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +0 -1
  184. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +0 -3297
  185. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +0 -1
  186. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +0 -44
  187. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +0 -1
  188. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +0 -36
  189. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +0 -1
  190. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +0 -10
  191. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +0 -1
  192. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +0 -657
  193. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +0 -1
  194. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +0 -449
  195. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +0 -1
  196. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +0 -413
  197. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +0 -1
  198. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +0 -57
  199. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +0 -1
  200. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +0 -38
  201. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +0 -1
  202. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +0 -86
  203. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +0 -1
  204. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +0 -61
  205. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +0 -1
  206. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +0 -80
  207. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +0 -1
  208. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +0 -52
  209. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +0 -1
  210. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +0 -1307
  211. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +0 -1
  212. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +0 -842
  213. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
  214. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +0 -335
  215. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +0 -1
  216. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +0 -8
  217. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +0 -1
  218. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +0 -51
  219. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +0 -1
  220. package/dist/node_modules/ajv/dist/ajv.js +0 -69
  221. package/dist/node_modules/ajv/dist/ajv.js.map +0 -1
  222. package/dist/node_modules/ajv/dist/compile/codegen/code.js +0 -169
  223. package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +0 -1
  224. package/dist/node_modules/ajv/dist/compile/codegen/index.js +0 -712
  225. package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +0 -1
  226. package/dist/node_modules/ajv/dist/compile/codegen/scope.js +0 -157
  227. package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +0 -1
  228. package/dist/node_modules/ajv/dist/compile/errors.js +0 -140
  229. package/dist/node_modules/ajv/dist/compile/errors.js.map +0 -1
  230. package/dist/node_modules/ajv/dist/compile/index.js +0 -253
  231. package/dist/node_modules/ajv/dist/compile/index.js.map +0 -1
  232. package/dist/node_modules/ajv/dist/compile/names.js +0 -40
  233. package/dist/node_modules/ajv/dist/compile/names.js.map +0 -1
  234. package/dist/node_modules/ajv/dist/compile/ref_error.js +0 -25
  235. package/dist/node_modules/ajv/dist/compile/ref_error.js.map +0 -1
  236. package/dist/node_modules/ajv/dist/compile/resolve.js +0 -162
  237. package/dist/node_modules/ajv/dist/compile/resolve.js.map +0 -1
  238. package/dist/node_modules/ajv/dist/compile/rules.js +0 -29
  239. package/dist/node_modules/ajv/dist/compile/rules.js.map +0 -1
  240. package/dist/node_modules/ajv/dist/compile/util.js +0 -183
  241. package/dist/node_modules/ajv/dist/compile/util.js.map +0 -1
  242. package/dist/node_modules/ajv/dist/compile/validate/applicability.js +0 -30
  243. package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +0 -1
  244. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -64
  245. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +0 -1
  246. package/dist/node_modules/ajv/dist/compile/validate/dataType.js +0 -213
  247. package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +0 -1
  248. package/dist/node_modules/ajv/dist/compile/validate/defaults.js +0 -49
  249. package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +0 -1
  250. package/dist/node_modules/ajv/dist/compile/validate/index.js +0 -544
  251. package/dist/node_modules/ajv/dist/compile/validate/index.js.map +0 -1
  252. package/dist/node_modules/ajv/dist/compile/validate/keyword.js +0 -139
  253. package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +0 -1
  254. package/dist/node_modules/ajv/dist/compile/validate/subschema.js +0 -95
  255. package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +0 -1
  256. package/dist/node_modules/ajv/dist/core.js +0 -639
  257. package/dist/node_modules/ajv/dist/core.js.map +0 -1
  258. package/dist/node_modules/ajv/dist/refs/data.json.js +0 -31
  259. package/dist/node_modules/ajv/dist/refs/data.json.js.map +0 -1
  260. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +0 -254
  261. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +0 -1
  262. package/dist/node_modules/ajv/dist/runtime/equal.js +0 -9
  263. package/dist/node_modules/ajv/dist/runtime/equal.js.map +0 -1
  264. package/dist/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
  265. package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +0 -1
  266. package/dist/node_modules/ajv/dist/runtime/uri.js +0 -8
  267. package/dist/node_modules/ajv/dist/runtime/uri.js.map +0 -1
  268. package/dist/node_modules/ajv/dist/runtime/validation_error.js +0 -22
  269. package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +0 -1
  270. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -53
  271. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +0 -1
  272. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -112
  273. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +0 -1
  274. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -26
  275. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +0 -1
  276. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -14
  277. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +0 -1
  278. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -99
  279. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +0 -1
  280. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -93
  281. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +0 -1
  282. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -70
  283. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +0 -1
  284. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -77
  285. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +0 -1
  286. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -57
  287. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +0 -1
  288. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -37
  289. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +0 -1
  290. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -29
  291. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +0 -1
  292. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -64
  293. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +0 -1
  294. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -80
  295. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +0 -1
  296. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -15
  297. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +0 -1
  298. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -61
  299. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +0 -1
  300. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -42
  301. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +0 -1
  302. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -16
  303. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +0 -1
  304. package/dist/node_modules/ajv/dist/vocabularies/code.js +0 -146
  305. package/dist/node_modules/ajv/dist/vocabularies/code.js.map +0 -1
  306. package/dist/node_modules/ajv/dist/vocabularies/core/id.js +0 -11
  307. package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +0 -1
  308. package/dist/node_modules/ajv/dist/vocabularies/core/index.js +0 -21
  309. package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +0 -1
  310. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +0 -131
  311. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +0 -1
  312. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -113
  313. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +0 -1
  314. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -12
  315. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +0 -1
  316. package/dist/node_modules/ajv/dist/vocabularies/draft7.js +0 -28
  317. package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +0 -1
  318. package/dist/node_modules/ajv/dist/vocabularies/format/format.js +0 -94
  319. package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +0 -1
  320. package/dist/node_modules/ajv/dist/vocabularies/format/index.js +0 -9
  321. package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +0 -1
  322. package/dist/node_modules/ajv/dist/vocabularies/metadata.js +0 -21
  323. package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +0 -1
  324. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +0 -31
  325. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +0 -1
  326. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -54
  327. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +0 -1
  328. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +0 -54
  329. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +0 -1
  330. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -26
  331. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +0 -1
  332. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
  333. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +0 -1
  334. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -29
  335. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +0 -1
  336. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -26
  337. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +0 -1
  338. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -28
  339. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +0 -1
  340. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -27
  341. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +0 -1
  342. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +0 -84
  343. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +0 -1
  344. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -72
  345. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +0 -1
  346. package/dist/node_modules/ajv-formats/dist/formats.js +0 -212
  347. package/dist/node_modules/ajv-formats/dist/formats.js.map +0 -1
  348. package/dist/node_modules/ajv-formats/dist/index.js +0 -52
  349. package/dist/node_modules/ajv-formats/dist/index.js.map +0 -1
  350. package/dist/node_modules/ajv-formats/dist/limit.js +0 -75
  351. package/dist/node_modules/ajv-formats/dist/limit.js.map +0 -1
  352. package/dist/node_modules/diff/libesm/diff/base.js +0 -256
  353. package/dist/node_modules/diff/libesm/diff/base.js.map +0 -1
  354. package/dist/node_modules/diff/libesm/diff/line.js +0 -64
  355. package/dist/node_modules/diff/libesm/diff/line.js.map +0 -1
  356. package/dist/node_modules/diff/libesm/patch/create.js +0 -185
  357. package/dist/node_modules/diff/libesm/patch/create.js.map +0 -1
  358. package/dist/node_modules/fast-deep-equal/index.js +0 -47
  359. package/dist/node_modules/fast-deep-equal/index.js.map +0 -1
  360. package/dist/node_modules/fast-uri/index.js +0 -347
  361. package/dist/node_modules/fast-uri/index.js.map +0 -1
  362. package/dist/node_modules/fast-uri/lib/schemes.js +0 -255
  363. package/dist/node_modules/fast-uri/lib/schemes.js.map +0 -1
  364. package/dist/node_modules/fast-uri/lib/utils.js +0 -334
  365. package/dist/node_modules/fast-uri/lib/utils.js.map +0 -1
  366. package/dist/node_modules/json-schema-traverse/index.js +0 -98
  367. package/dist/node_modules/json-schema-traverse/index.js.map +0 -1
  368. package/dist/node_modules/uuid/dist/rng.js +0 -14
  369. package/dist/node_modules/uuid/dist/rng.js.map +0 -1
  370. package/dist/node_modules/uuid/dist/stringify.js +0 -29
  371. package/dist/node_modules/uuid/dist/stringify.js.map +0 -1
  372. package/dist/node_modules/uuid/dist/v7.js +0 -65
  373. package/dist/node_modules/uuid/dist/v7.js.map +0 -1
  374. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +0 -37
  375. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +0 -1
  376. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +0 -26
  377. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +0 -1
  378. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +0 -17
  379. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +0 -1
  380. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +0 -11
  381. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +0 -1
  382. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +0 -66
  383. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +0 -1
  384. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +0 -21
  385. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +0 -1
  386. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +0 -30
  387. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +0 -1
  388. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +0 -53
  389. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +0 -1
  390. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +0 -8
  391. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +0 -1
  392. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +0 -8
  393. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +0 -1
  394. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +0 -8
  395. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +0 -1
  396. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +0 -50
  397. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +0 -1
  398. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +0 -11
  399. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +0 -1
  400. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +0 -11
  401. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +0 -1
  402. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +0 -9
  403. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +0 -1
  404. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +0 -56
  405. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +0 -1
  406. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +0 -24
  407. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +0 -1
  408. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +0 -30
  409. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +0 -1
  410. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +0 -19
  411. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +0 -1
  412. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +0 -15
  413. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +0 -1
  414. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +0 -13
  415. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +0 -1
  416. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +0 -37
  417. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +0 -1
  418. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +0 -56
  419. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +0 -1
  420. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +0 -76
  421. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +0 -1
  422. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +0 -25
  423. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +0 -1
  424. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +0 -24
  425. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +0 -1
  426. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +0 -8
  427. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +0 -1
  428. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +0 -8
  429. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +0 -1
  430. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +0 -65
  431. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +0 -1
  432. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +0 -24
  433. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +0 -1
  434. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +0 -350
  435. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +0 -1
  436. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +0 -36
  437. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +0 -1
  438. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +0 -10
  439. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +0 -1
  440. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +0 -84
  441. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +0 -1
  442. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +0 -8
  443. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +0 -1
  444. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +0 -109
  445. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +0 -1
  446. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +0 -90
  447. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +0 -1
  448. package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +0 -42
  449. package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +0 -1
  450. package/dist/package.json.js +0 -8
  451. package/dist/package.json.js.map +0 -1
  452. package/dist/src/acp-extensions.d.ts +0 -91
  453. package/dist/src/acp-extensions.d.ts.map +0 -1
  454. package/dist/src/acp-extensions.js +0 -38
  455. package/dist/src/acp-extensions.js.map +0 -1
  456. package/dist/src/adapters/claude/claude.d.ts +0 -136
  457. package/dist/src/adapters/claude/claude.d.ts.map +0 -1
  458. package/dist/src/adapters/claude/claude.js +0 -1128
  459. package/dist/src/adapters/claude/claude.js.map +0 -1
  460. package/dist/src/adapters/claude/mcp-server.d.ts +0 -30
  461. package/dist/src/adapters/claude/mcp-server.d.ts.map +0 -1
  462. package/dist/src/adapters/claude/mcp-server.js +0 -668
  463. package/dist/src/adapters/claude/mcp-server.js.map +0 -1
  464. package/dist/src/adapters/claude/tools.d.ts +0 -35
  465. package/dist/src/adapters/claude/tools.d.ts.map +0 -1
  466. package/dist/src/adapters/claude/tools.js +0 -473
  467. package/dist/src/adapters/claude/tools.js.map +0 -1
  468. package/dist/src/adapters/claude/utils.d.ts +0 -48
  469. package/dist/src/adapters/claude/utils.d.ts.map +0 -1
  470. package/dist/src/adapters/claude/utils.js +0 -158
  471. package/dist/src/adapters/claude/utils.js.map +0 -1
  472. package/dist/src/agent.d.ts +0 -58
  473. package/dist/src/agent.d.ts.map +0 -1
  474. package/dist/src/agent.js +0 -576
  475. package/dist/src/agent.js.map +0 -1
  476. package/dist/src/agents/execution.d.ts +0 -2
  477. package/dist/src/agents/execution.d.ts.map +0 -1
  478. package/dist/src/agents/execution.js +0 -40
  479. package/dist/src/agents/execution.js.map +0 -1
  480. package/dist/src/agents/planning.d.ts +0 -2
  481. package/dist/src/agents/planning.d.ts.map +0 -1
  482. package/dist/src/agents/planning.js +0 -63
  483. package/dist/src/agents/planning.js.map +0 -1
  484. package/dist/src/agents/research.d.ts +0 -2
  485. package/dist/src/agents/research.d.ts.map +0 -1
  486. package/dist/src/agents/research.js +0 -163
  487. package/dist/src/agents/research.js.map +0 -1
  488. package/dist/src/file-manager.d.ts +0 -43
  489. package/dist/src/file-manager.d.ts.map +0 -1
  490. package/dist/src/file-manager.js +0 -266
  491. package/dist/src/file-manager.js.map +0 -1
  492. package/dist/src/git-manager.d.ts +0 -79
  493. package/dist/src/git-manager.d.ts.map +0 -1
  494. package/dist/src/git-manager.js +0 -454
  495. package/dist/src/git-manager.js.map +0 -1
  496. package/dist/src/posthog-api.d.ts +0 -48
  497. package/dist/src/posthog-api.d.ts.map +0 -1
  498. package/dist/src/posthog-api.js +0 -260
  499. package/dist/src/posthog-api.js.map +0 -1
  500. package/dist/src/prompt-builder.d.ts +0 -49
  501. package/dist/src/prompt-builder.d.ts.map +0 -1
  502. package/dist/src/prompt-builder.js +0 -397
  503. package/dist/src/prompt-builder.js.map +0 -1
  504. package/dist/src/schemas.d.ts +0 -980
  505. package/dist/src/schemas.d.ts.map +0 -1
  506. package/dist/src/schemas.js +0 -196
  507. package/dist/src/schemas.js.map +0 -1
  508. package/dist/src/session-store.d.ts +0 -58
  509. package/dist/src/session-store.d.ts.map +0 -1
  510. package/dist/src/session-store.js +0 -206
  511. package/dist/src/session-store.js.map +0 -1
  512. package/dist/src/task-manager.d.ts +0 -25
  513. package/dist/src/task-manager.d.ts.map +0 -1
  514. package/dist/src/task-manager.js +0 -123
  515. package/dist/src/task-manager.js.map +0 -1
  516. package/dist/src/template-manager.d.ts +0 -30
  517. package/dist/src/template-manager.d.ts.map +0 -1
  518. package/dist/src/template-manager.js +0 -152
  519. package/dist/src/template-manager.js.map +0 -1
  520. package/dist/src/todo-manager.d.ts +0 -29
  521. package/dist/src/todo-manager.d.ts.map +0 -1
  522. package/dist/src/todo-manager.js +0 -135
  523. package/dist/src/todo-manager.js.map +0 -1
  524. package/dist/src/tools/registry.d.ts +0 -25
  525. package/dist/src/tools/registry.d.ts.map +0 -1
  526. package/dist/src/tools/registry.js +0 -120
  527. package/dist/src/tools/registry.js.map +0 -1
  528. package/dist/src/tools/types.d.ts +0 -80
  529. package/dist/src/tools/types.d.ts.map +0 -1
  530. package/dist/src/types.d.ts +0 -193
  531. package/dist/src/types.d.ts.map +0 -1
  532. package/dist/src/types.js +0 -11
  533. package/dist/src/types.js.map +0 -1
  534. package/dist/src/utils/logger.d.ts +0 -37
  535. package/dist/src/utils/logger.d.ts.map +0 -1
  536. package/dist/src/utils/logger.js +0 -83
  537. package/dist/src/utils/logger.js.map +0 -1
  538. package/dist/src/utils/tapped-stream.d.ts +0 -17
  539. package/dist/src/utils/tapped-stream.d.ts.map +0 -1
  540. package/dist/src/utils/tapped-stream.js +0 -45
  541. package/dist/src/utils/tapped-stream.js.map +0 -1
  542. package/dist/src/workflow/config.d.ts +0 -3
  543. package/dist/src/workflow/config.d.ts.map +0 -1
  544. package/dist/src/workflow/config.js +0 -54
  545. package/dist/src/workflow/config.js.map +0 -1
  546. package/dist/src/workflow/steps/build.d.ts +0 -3
  547. package/dist/src/workflow/steps/build.d.ts.map +0 -1
  548. package/dist/src/workflow/steps/build.js +0 -108
  549. package/dist/src/workflow/steps/build.js.map +0 -1
  550. package/dist/src/workflow/steps/finalize.d.ts +0 -3
  551. package/dist/src/workflow/steps/finalize.d.ts.map +0 -1
  552. package/dist/src/workflow/steps/finalize.js +0 -188
  553. package/dist/src/workflow/steps/finalize.js.map +0 -1
  554. package/dist/src/workflow/steps/plan.d.ts +0 -3
  555. package/dist/src/workflow/steps/plan.d.ts.map +0 -1
  556. package/dist/src/workflow/steps/plan.js +0 -136
  557. package/dist/src/workflow/steps/plan.js.map +0 -1
  558. package/dist/src/workflow/steps/research.d.ts +0 -3
  559. package/dist/src/workflow/steps/research.d.ts.map +0 -1
  560. package/dist/src/workflow/steps/research.js +0 -189
  561. package/dist/src/workflow/steps/research.js.map +0 -1
  562. package/dist/src/workflow/types.d.ts +0 -51
  563. package/dist/src/workflow/types.d.ts.map +0 -1
  564. package/dist/src/workflow/utils.d.ts +0 -12
  565. package/dist/src/workflow/utils.d.ts.map +0 -1
  566. package/dist/src/workflow/utils.js +0 -41
  567. package/dist/src/workflow/utils.js.map +0 -1
  568. package/dist/src/worktree-manager.d.ts +0 -39
  569. package/dist/src/worktree-manager.d.ts.map +0 -1
  570. package/dist/src/worktree-manager.js +0 -808
  571. package/dist/src/worktree-manager.js.map +0 -1
@@ -1,891 +0,0 @@
1
- import { z } from 'zod';
2
- import { CLIENT_METHODS, AGENT_METHODS, setSessionModelRequestSchema, promptRequestSchema, authenticateRequestSchema, setSessionModeRequestSchema, loadSessionRequestSchema, newSessionRequestSchema, initializeRequestSchema, cancelNotificationSchema, killTerminalCommandRequestSchema, waitForTerminalExitRequestSchema, releaseTerminalRequestSchema, terminalOutputRequestSchema, createTerminalRequestSchema, requestPermissionRequestSchema, readTextFileRequestSchema, writeTextFileRequestSchema, sessionNotificationSchema } from './schema.js';
3
- export { PROTOCOL_VERSION, agentCapabilitiesSchema, agentNotificationSchema, agentOutgoingMessageSchema, agentRequestSchema, agentResponseSchema, annotationsSchema, authMethodSchema, authenticateResponseSchema, availableCommandInputSchema, availableCommandSchema, blobResourceContentsSchema, clientCapabilitiesSchema, clientNotificationSchema, clientOutgoingMessageSchema, clientRequestSchema, clientResponseSchema, contentBlockSchema, createTerminalResponseSchema, embeddedResourceResourceSchema, envVariableSchema, errorSchema, extMethodRequest1Schema, extMethodRequestSchema, extMethodResponse1Schema, extMethodResponseSchema, extNotification1Schema, extNotificationSchema, fileSystemCapabilitySchema, httpHeaderSchema, implementationSchema, initializeResponseSchema, killTerminalResponseSchema, loadSessionResponseSchema, mcpCapabilitiesSchema, mcpServerSchema, modelInfoSchema, newSessionResponseSchema, notification1Schema, notificationSchema, null1Schema, nullSchema, number1Schema, numberSchema, permissionOptionSchema, planEntrySchema, promptCapabilitiesSchema, promptResponseSchema, readTextFileResponseSchema, releaseTerminalResponseSchema, request1Schema, requestPermissionResponseSchema, requestSchema, response1Schema, responseSchema, roleSchema, sessionModeIdSchema, sessionModeSchema, sessionModeStateSchema, sessionModelStateSchema, setSessionModeResponseSchema, setSessionModelResponseSchema, stdioSchema, string1Schema, stringSchema, terminalExitStatusSchema, terminalOutputResponseSchema, textResourceContentsSchema, toolCallContentSchema, toolCallLocationSchema, toolCallStatusSchema, toolKindSchema, unstructuredCommandInputSchema, waitForTerminalExitResponseSchema, writeTextFileResponseSchema } from './schema.js';
4
-
5
- /**
6
- * An agent-side connection to a client.
7
- *
8
- * This class provides the agent's view of an ACP connection, allowing
9
- * agents to communicate with clients. It implements the {@link Client} interface
10
- * to provide methods for requesting permissions, accessing the file system,
11
- * and sending session updates.
12
- *
13
- * See protocol docs: [Agent](https://agentclientprotocol.com/protocol/overview#agent)
14
- */
15
- class AgentSideConnection {
16
- #connection;
17
- /**
18
- * Creates a new agent-side connection to a client.
19
- *
20
- * This establishes the communication channel from the agent's perspective
21
- * following the ACP specification.
22
- *
23
- * @param toAgent - A function that creates an Agent handler to process incoming client requests
24
- * @param stream - The bidirectional message stream for communication. Typically created using
25
- * {@link ndJsonStream} for stdio-based connections.
26
- *
27
- * See protocol docs: [Communication Model](https://agentclientprotocol.com/protocol/overview#communication-model)
28
- */
29
- constructor(toAgent, stream) {
30
- const agent = toAgent(this);
31
- const requestHandler = async (method, params) => {
32
- switch (method) {
33
- case AGENT_METHODS.initialize: {
34
- const validatedParams = initializeRequestSchema.parse(params);
35
- return agent.initialize(validatedParams);
36
- }
37
- case AGENT_METHODS.session_new: {
38
- const validatedParams = newSessionRequestSchema.parse(params);
39
- return agent.newSession(validatedParams);
40
- }
41
- case AGENT_METHODS.session_load: {
42
- if (!agent.loadSession) {
43
- throw RequestError.methodNotFound(method);
44
- }
45
- const validatedParams = loadSessionRequestSchema.parse(params);
46
- return agent.loadSession(validatedParams);
47
- }
48
- case AGENT_METHODS.session_set_mode: {
49
- if (!agent.setSessionMode) {
50
- throw RequestError.methodNotFound(method);
51
- }
52
- const validatedParams = setSessionModeRequestSchema.parse(params);
53
- const result = await agent.setSessionMode(validatedParams);
54
- return result ?? {};
55
- }
56
- case AGENT_METHODS.authenticate: {
57
- const validatedParams = authenticateRequestSchema.parse(params);
58
- const result = await agent.authenticate(validatedParams);
59
- return result ?? {};
60
- }
61
- case AGENT_METHODS.session_prompt: {
62
- const validatedParams = promptRequestSchema.parse(params);
63
- return agent.prompt(validatedParams);
64
- }
65
- case AGENT_METHODS.session_set_model: {
66
- if (!agent.setSessionModel) {
67
- throw RequestError.methodNotFound(method);
68
- }
69
- const validatedParams = setSessionModelRequestSchema.parse(params);
70
- const result = await agent.setSessionModel(validatedParams);
71
- return result ?? {};
72
- }
73
- default:
74
- if (method.startsWith("_")) {
75
- if (!agent.extMethod) {
76
- throw RequestError.methodNotFound(method);
77
- }
78
- return agent.extMethod(method.substring(1), params);
79
- }
80
- throw RequestError.methodNotFound(method);
81
- }
82
- };
83
- const notificationHandler = async (method, params) => {
84
- switch (method) {
85
- case AGENT_METHODS.session_cancel: {
86
- const validatedParams = cancelNotificationSchema.parse(params);
87
- return agent.cancel(validatedParams);
88
- }
89
- default:
90
- if (method.startsWith("_")) {
91
- if (!agent.extNotification) {
92
- return;
93
- }
94
- return agent.extNotification(method.substring(1), params);
95
- }
96
- throw RequestError.methodNotFound(method);
97
- }
98
- };
99
- this.#connection = new Connection(requestHandler, notificationHandler, stream);
100
- }
101
- /**
102
- * Handles session update notifications from the agent.
103
- *
104
- * This is a notification endpoint (no response expected) that sends
105
- * real-time updates about session progress, including message chunks,
106
- * tool calls, and execution plans.
107
- *
108
- * Note: Clients SHOULD continue accepting tool call updates even after
109
- * sending a `session/cancel` notification, as the agent may send final
110
- * updates before responding with the cancelled stop reason.
111
- *
112
- * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
113
- */
114
- async sessionUpdate(params) {
115
- return await this.#connection.sendNotification(CLIENT_METHODS.session_update, params);
116
- }
117
- /**
118
- * Requests permission from the user for a tool call operation.
119
- *
120
- * Called by the agent when it needs user authorization before executing
121
- * a potentially sensitive operation. The client should present the options
122
- * to the user and return their decision.
123
- *
124
- * If the client cancels the prompt turn via `session/cancel`, it MUST
125
- * respond to this request with `RequestPermissionOutcome::Cancelled`.
126
- *
127
- * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
128
- */
129
- async requestPermission(params) {
130
- return await this.#connection.sendRequest(CLIENT_METHODS.session_request_permission, params);
131
- }
132
- /**
133
- * Reads content from a text file in the client's file system.
134
- *
135
- * Only available if the client advertises the `fs.readTextFile` capability.
136
- * Allows the agent to access file contents within the client's environment.
137
- *
138
- * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
139
- */
140
- async readTextFile(params) {
141
- return await this.#connection.sendRequest(CLIENT_METHODS.fs_read_text_file, params);
142
- }
143
- /**
144
- * Writes content to a text file in the client's file system.
145
- *
146
- * Only available if the client advertises the `fs.writeTextFile` capability.
147
- * Allows the agent to create or modify files within the client's environment.
148
- *
149
- * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
150
- */
151
- async writeTextFile(params) {
152
- return ((await this.#connection.sendRequest(CLIENT_METHODS.fs_write_text_file, params)) ?? {});
153
- }
154
- /**
155
- * Executes a command in a new terminal.
156
- *
157
- * Returns a `TerminalHandle` that can be used to get output, wait for exit,
158
- * kill the command, or release the terminal.
159
- *
160
- * The terminal can also be embedded in tool calls by using its ID in
161
- * `ToolCallContent` with type "terminal".
162
- *
163
- * @param params - The terminal creation parameters
164
- * @returns A handle to control and monitor the terminal
165
- */
166
- async createTerminal(params) {
167
- const response = await this.#connection.sendRequest(CLIENT_METHODS.terminal_create, params);
168
- return new TerminalHandle(response.terminalId, params.sessionId, this.#connection);
169
- }
170
- /**
171
- * Extension method
172
- *
173
- * Allows the Agent to send an arbitrary request that is not part of the ACP spec.
174
- */
175
- async extMethod(method, params) {
176
- return await this.#connection.sendRequest(`_${method}`, params);
177
- }
178
- /**
179
- * Extension notification
180
- *
181
- * Allows the Agent to send an arbitrary notification that is not part of the ACP spec.
182
- */
183
- async extNotification(method, params) {
184
- return await this.#connection.sendNotification(`_${method}`, params);
185
- }
186
- /**
187
- * AbortSignal that aborts when the connection closes.
188
- *
189
- * This signal can be used to:
190
- * - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
191
- * - Check connection status synchronously: `if (connection.signal.aborted) {...}`
192
- * - Pass to other APIs (fetch, setTimeout) for automatic cancellation
193
- *
194
- * The connection closes when the underlying stream ends, either normally or due to an error.
195
- *
196
- * @example
197
- * ```typescript
198
- * const connection = new AgentSideConnection(agent, stream);
199
- *
200
- * // Listen for closure
201
- * connection.signal.addEventListener('abort', () => {
202
- * console.log('Connection closed - performing cleanup');
203
- * });
204
- *
205
- * // Check status
206
- * if (connection.signal.aborted) {
207
- * console.log('Connection is already closed');
208
- * }
209
- *
210
- * // Pass to other APIs
211
- * fetch(url, { signal: connection.signal });
212
- * ```
213
- */
214
- get signal() {
215
- return this.#connection.signal;
216
- }
217
- /**
218
- * Promise that resolves when the connection closes.
219
- *
220
- * The connection closes when the underlying stream ends, either normally or due to an error.
221
- * Once closed, the connection cannot send or receive any more messages.
222
- *
223
- * This is useful for async/await style cleanup:
224
- *
225
- * @example
226
- * ```typescript
227
- * const connection = new AgentSideConnection(agent, stream);
228
- * await connection.closed;
229
- * console.log('Connection closed - performing cleanup');
230
- * ```
231
- */
232
- get closed() {
233
- return this.#connection.closed;
234
- }
235
- }
236
- /**
237
- * Handle for controlling and monitoring a terminal created via `createTerminal`.
238
- *
239
- * Provides methods to:
240
- * - Get current output without waiting
241
- * - Wait for command completion
242
- * - Kill the running command
243
- * - Release terminal resources
244
- *
245
- * **Important:** Always call `release()` when done with the terminal to free resources.
246
-
247
- * The terminal supports async disposal via `Symbol.asyncDispose` for automatic cleanup.
248
-
249
- * You can use `await using` to ensure the terminal is automatically released when it
250
- * goes out of scope.
251
- */
252
- class TerminalHandle {
253
- id;
254
- #sessionId;
255
- #connection;
256
- constructor(id, sessionId, conn) {
257
- this.id = id;
258
- this.#sessionId = sessionId;
259
- this.#connection = conn;
260
- }
261
- /**
262
- * Gets the current terminal output without waiting for the command to exit.
263
- */
264
- async currentOutput() {
265
- return await this.#connection.sendRequest(CLIENT_METHODS.terminal_output, {
266
- sessionId: this.#sessionId,
267
- terminalId: this.id,
268
- });
269
- }
270
- /**
271
- * Waits for the terminal command to complete and returns its exit status.
272
- */
273
- async waitForExit() {
274
- return await this.#connection.sendRequest(CLIENT_METHODS.terminal_wait_for_exit, {
275
- sessionId: this.#sessionId,
276
- terminalId: this.id,
277
- });
278
- }
279
- /**
280
- * Kills the terminal command without releasing the terminal.
281
- *
282
- * The terminal remains valid after killing, allowing you to:
283
- * - Get the final output with `currentOutput()`
284
- * - Check the exit status
285
- * - Release the terminal when done
286
- *
287
- * Useful for implementing timeouts or cancellation.
288
- */
289
- async kill() {
290
- return ((await this.#connection.sendRequest(CLIENT_METHODS.terminal_kill, {
291
- sessionId: this.#sessionId,
292
- terminalId: this.id,
293
- })) ?? {});
294
- }
295
- /**
296
- * Releases the terminal and frees all associated resources.
297
- *
298
- * If the command is still running, it will be killed.
299
- * After release, the terminal ID becomes invalid and cannot be used
300
- * with other terminal methods.
301
- *
302
- * Tool calls that already reference this terminal will continue to
303
- * display its output.
304
- *
305
- * **Important:** Always call this method when done with the terminal.
306
- */
307
- async release() {
308
- return ((await this.#connection.sendRequest(CLIENT_METHODS.terminal_release, {
309
- sessionId: this.#sessionId,
310
- terminalId: this.id,
311
- })) ?? {});
312
- }
313
- async [Symbol.asyncDispose]() {
314
- await this.release();
315
- }
316
- }
317
- /**
318
- * A client-side connection to an agent.
319
- *
320
- * This class provides the client's view of an ACP connection, allowing
321
- * clients (such as code editors) to communicate with agents. It implements
322
- * the {@link Agent} interface to provide methods for initializing sessions, sending
323
- * prompts, and managing the agent lifecycle.
324
- *
325
- * See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
326
- */
327
- class ClientSideConnection {
328
- #connection;
329
- /**
330
- * Creates a new client-side connection to an agent.
331
- *
332
- * This establishes the communication channel between a client and agent
333
- * following the ACP specification.
334
- *
335
- * @param toClient - A function that creates a Client handler to process incoming agent requests
336
- * @param stream - The bidirectional message stream for communication. Typically created using
337
- * {@link ndJsonStream} for stdio-based connections.
338
- *
339
- * See protocol docs: [Communication Model](https://agentclientprotocol.com/protocol/overview#communication-model)
340
- */
341
- constructor(toClient, stream) {
342
- const client = toClient(this);
343
- const requestHandler = async (method, params) => {
344
- switch (method) {
345
- case CLIENT_METHODS.fs_write_text_file: {
346
- const validatedParams = writeTextFileRequestSchema.parse(params);
347
- return client.writeTextFile?.(validatedParams);
348
- }
349
- case CLIENT_METHODS.fs_read_text_file: {
350
- const validatedParams = readTextFileRequestSchema.parse(params);
351
- return client.readTextFile?.(validatedParams);
352
- }
353
- case CLIENT_METHODS.session_request_permission: {
354
- const validatedParams = requestPermissionRequestSchema.parse(params);
355
- return client.requestPermission(validatedParams);
356
- }
357
- case CLIENT_METHODS.terminal_create: {
358
- const validatedParams = createTerminalRequestSchema.parse(params);
359
- return client.createTerminal?.(validatedParams);
360
- }
361
- case CLIENT_METHODS.terminal_output: {
362
- const validatedParams = terminalOutputRequestSchema.parse(params);
363
- return client.terminalOutput?.(validatedParams);
364
- }
365
- case CLIENT_METHODS.terminal_release: {
366
- const validatedParams = releaseTerminalRequestSchema.parse(params);
367
- const result = await client.releaseTerminal?.(validatedParams);
368
- return result ?? {};
369
- }
370
- case CLIENT_METHODS.terminal_wait_for_exit: {
371
- const validatedParams = waitForTerminalExitRequestSchema.parse(params);
372
- return client.waitForTerminalExit?.(validatedParams);
373
- }
374
- case CLIENT_METHODS.terminal_kill: {
375
- const validatedParams = killTerminalCommandRequestSchema.parse(params);
376
- const result = await client.killTerminal?.(validatedParams);
377
- return result ?? {};
378
- }
379
- default:
380
- // Handle extension methods (any method starting with '_')
381
- if (method.startsWith("_")) {
382
- const customMethod = method.substring(1);
383
- if (!client.extMethod) {
384
- throw RequestError.methodNotFound(method);
385
- }
386
- return client.extMethod(customMethod, params);
387
- }
388
- throw RequestError.methodNotFound(method);
389
- }
390
- };
391
- const notificationHandler = async (method, params) => {
392
- switch (method) {
393
- case CLIENT_METHODS.session_update: {
394
- const validatedParams = sessionNotificationSchema.parse(params);
395
- return client.sessionUpdate(validatedParams);
396
- }
397
- default:
398
- // Handle extension notifications (any method starting with '_')
399
- if (method.startsWith("_")) {
400
- const customMethod = method.substring(1);
401
- if (!client.extNotification) {
402
- return;
403
- }
404
- return client.extNotification(customMethod, params);
405
- }
406
- throw RequestError.methodNotFound(method);
407
- }
408
- };
409
- this.#connection = new Connection(requestHandler, notificationHandler, stream);
410
- }
411
- /**
412
- * Establishes the connection with a client and negotiates protocol capabilities.
413
- *
414
- * This method is called once at the beginning of the connection to:
415
- * - Negotiate the protocol version to use
416
- * - Exchange capability information between client and agent
417
- * - Determine available authentication methods
418
- *
419
- * The agent should respond with its supported protocol version and capabilities.
420
- *
421
- * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
422
- */
423
- async initialize(params) {
424
- return await this.#connection.sendRequest(AGENT_METHODS.initialize, params);
425
- }
426
- /**
427
- * Creates a new conversation session with the agent.
428
- *
429
- * Sessions represent independent conversation contexts with their own history and state.
430
- *
431
- * The agent should:
432
- * - Create a new session context
433
- * - Connect to any specified MCP servers
434
- * - Return a unique session ID for future requests
435
- *
436
- * May return an `auth_required` error if the agent requires authentication.
437
- *
438
- * See protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)
439
- */
440
- async newSession(params) {
441
- return await this.#connection.sendRequest(AGENT_METHODS.session_new, params);
442
- }
443
- /**
444
- * Loads an existing session to resume a previous conversation.
445
- *
446
- * This method is only available if the agent advertises the `loadSession` capability.
447
- *
448
- * The agent should:
449
- * - Restore the session context and conversation history
450
- * - Connect to the specified MCP servers
451
- * - Stream the entire conversation history back to the client via notifications
452
- *
453
- * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
454
- */
455
- async loadSession(params) {
456
- return ((await this.#connection.sendRequest(AGENT_METHODS.session_load, params)) ?? {});
457
- }
458
- /**
459
- * Sets the operational mode for a session.
460
- *
461
- * Allows switching between different agent modes (e.g., "ask", "architect", "code")
462
- * that affect system prompts, tool availability, and permission behaviors.
463
- *
464
- * The mode must be one of the modes advertised in `availableModes` during session
465
- * creation or loading. Agents may also change modes autonomously and notify the
466
- * client via `current_mode_update` notifications.
467
- *
468
- * This method can be called at any time during a session, whether the Agent is
469
- * idle or actively generating a turn.
470
- *
471
- * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
472
- */
473
- async setSessionMode(params) {
474
- return ((await this.#connection.sendRequest(AGENT_METHODS.session_set_mode, params)) ?? {});
475
- }
476
- /**
477
- * **UNSTABLE**
478
- *
479
- * This capability is not part of the spec yet, and may be removed or changed at any point.
480
- *
481
- * Select a model for a given session.
482
- */
483
- async setSessionModel(params) {
484
- return ((await this.#connection.sendRequest(AGENT_METHODS.session_set_model, params)) ?? {});
485
- }
486
- /**
487
- * Authenticates the client using the specified authentication method.
488
- *
489
- * Called when the agent requires authentication before allowing session creation.
490
- * The client provides the authentication method ID that was advertised during initialization.
491
- *
492
- * After successful authentication, the client can proceed to create sessions with
493
- * `newSession` without receiving an `auth_required` error.
494
- *
495
- * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
496
- */
497
- async authenticate(params) {
498
- return ((await this.#connection.sendRequest(AGENT_METHODS.authenticate, params)) ?? {});
499
- }
500
- /**
501
- * Processes a user prompt within a session.
502
- *
503
- * This method handles the whole lifecycle of a prompt:
504
- * - Receives user messages with optional context (files, images, etc.)
505
- * - Processes the prompt using language models
506
- * - Reports language model content and tool calls to the Clients
507
- * - Requests permission to run tools
508
- * - Executes any requested tool calls
509
- * - Returns when the turn is complete with a stop reason
510
- *
511
- * See protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)
512
- */
513
- async prompt(params) {
514
- return await this.#connection.sendRequest(AGENT_METHODS.session_prompt, params);
515
- }
516
- /**
517
- * Cancels ongoing operations for a session.
518
- *
519
- * This is a notification sent by the client to cancel an ongoing prompt turn.
520
- *
521
- * Upon receiving this notification, the Agent SHOULD:
522
- * - Stop all language model requests as soon as possible
523
- * - Abort all tool call invocations in progress
524
- * - Send any pending `session/update` notifications
525
- * - Respond to the original `session/prompt` request with `StopReason::Cancelled`
526
- *
527
- * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
528
- */
529
- async cancel(params) {
530
- return await this.#connection.sendNotification(AGENT_METHODS.session_cancel, params);
531
- }
532
- /**
533
- * Extension method
534
- *
535
- * Allows the Client to send an arbitrary request that is not part of the ACP spec.
536
- */
537
- async extMethod(method, params) {
538
- return await this.#connection.sendRequest(`_${method}`, params);
539
- }
540
- /**
541
- * Extension notification
542
- *
543
- * Allows the Client to send an arbitrary notification that is not part of the ACP spec.
544
- */
545
- async extNotification(method, params) {
546
- return await this.#connection.sendNotification(`_${method}`, params);
547
- }
548
- /**
549
- * AbortSignal that aborts when the connection closes.
550
- *
551
- * This signal can be used to:
552
- * - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
553
- * - Check connection status synchronously: `if (connection.signal.aborted) {...}`
554
- * - Pass to other APIs (fetch, setTimeout) for automatic cancellation
555
- *
556
- * The connection closes when the underlying stream ends, either normally or due to an error.
557
- *
558
- * @example
559
- * ```typescript
560
- * const connection = new ClientSideConnection(client, stream);
561
- *
562
- * // Listen for closure
563
- * connection.signal.addEventListener('abort', () => {
564
- * console.log('Connection closed - performing cleanup');
565
- * });
566
- *
567
- * // Check status
568
- * if (connection.signal.aborted) {
569
- * console.log('Connection is already closed');
570
- * }
571
- *
572
- * // Pass to other APIs
573
- * fetch(url, { signal: connection.signal });
574
- * ```
575
- */
576
- get signal() {
577
- return this.#connection.signal;
578
- }
579
- /**
580
- * Promise that resolves when the connection closes.
581
- *
582
- * The connection closes when the underlying stream ends, either normally or due to an error.
583
- * Once closed, the connection cannot send or receive any more messages.
584
- *
585
- * This is useful for async/await style cleanup:
586
- *
587
- * @example
588
- * ```typescript
589
- * const connection = new ClientSideConnection(client, stream);
590
- * await connection.closed;
591
- * console.log('Connection closed - performing cleanup');
592
- * ```
593
- */
594
- get closed() {
595
- return this.#connection.closed;
596
- }
597
- }
598
- class Connection {
599
- #pendingResponses = new Map();
600
- #nextRequestId = 0;
601
- #requestHandler;
602
- #notificationHandler;
603
- #stream;
604
- #writeQueue = Promise.resolve();
605
- #abortController = new AbortController();
606
- #closedPromise;
607
- constructor(requestHandler, notificationHandler, stream) {
608
- this.#requestHandler = requestHandler;
609
- this.#notificationHandler = notificationHandler;
610
- this.#stream = stream;
611
- this.#closedPromise = new Promise((resolve) => {
612
- this.#abortController.signal.addEventListener("abort", () => resolve());
613
- });
614
- this.#receive();
615
- }
616
- /**
617
- * AbortSignal that aborts when the connection closes.
618
- *
619
- * This signal can be used to:
620
- * - Listen for connection closure via event listeners
621
- * - Check connection status synchronously with `signal.aborted`
622
- * - Pass to other APIs (fetch, setTimeout) for automatic cancellation
623
- */
624
- get signal() {
625
- return this.#abortController.signal;
626
- }
627
- /**
628
- * Promise that resolves when the connection closes.
629
- *
630
- * The connection closes when the underlying stream ends, either normally
631
- * or due to an error. Once closed, the connection cannot send or receive
632
- * any more messages.
633
- *
634
- * @example
635
- * ```typescript
636
- * const connection = new ClientSideConnection(client, stream);
637
- * await connection.closed;
638
- * console.log('Connection closed - performing cleanup');
639
- * ```
640
- */
641
- get closed() {
642
- return this.#closedPromise;
643
- }
644
- async #receive() {
645
- const reader = this.#stream.readable.getReader();
646
- try {
647
- while (true) {
648
- const { value: message, done } = await reader.read();
649
- if (done) {
650
- break;
651
- }
652
- if (!message) {
653
- continue;
654
- }
655
- try {
656
- this.#processMessage(message);
657
- }
658
- catch (err) {
659
- console.error("Unexpected error during message processing:", message, err);
660
- // Only send error response if the message had an id (was a request)
661
- if ("id" in message && message.id !== undefined) {
662
- this.#sendMessage({
663
- jsonrpc: "2.0",
664
- id: message.id,
665
- error: {
666
- code: -32700,
667
- message: "Parse error",
668
- },
669
- });
670
- }
671
- }
672
- }
673
- }
674
- finally {
675
- reader.releaseLock();
676
- this.#abortController.abort();
677
- }
678
- }
679
- async #processMessage(message) {
680
- if ("method" in message && "id" in message) {
681
- // It's a request
682
- const response = await this.#tryCallRequestHandler(message.method, message.params);
683
- if ("error" in response) {
684
- console.error("Error handling request", message, response.error);
685
- }
686
- await this.#sendMessage({
687
- jsonrpc: "2.0",
688
- id: message.id,
689
- ...response,
690
- });
691
- }
692
- else if ("method" in message) {
693
- // It's a notification
694
- const response = await this.#tryCallNotificationHandler(message.method, message.params);
695
- if ("error" in response) {
696
- console.error("Error handling notification", message, response.error);
697
- }
698
- }
699
- else if ("id" in message) {
700
- // It's a response
701
- this.#handleResponse(message);
702
- }
703
- else {
704
- console.error("Invalid message", { message });
705
- }
706
- }
707
- async #tryCallRequestHandler(method, params) {
708
- try {
709
- const result = await this.#requestHandler(method, params);
710
- return { result: result ?? null };
711
- }
712
- catch (error) {
713
- if (error instanceof RequestError) {
714
- return error.toResult();
715
- }
716
- if (error instanceof z.ZodError) {
717
- return RequestError.invalidParams(error.format()).toResult();
718
- }
719
- let details;
720
- if (error instanceof Error) {
721
- details = error.message;
722
- }
723
- else if (typeof error === "object" &&
724
- error != null &&
725
- "message" in error &&
726
- typeof error.message === "string") {
727
- details = error.message;
728
- }
729
- try {
730
- return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
731
- }
732
- catch {
733
- return RequestError.internalError({ details }).toResult();
734
- }
735
- }
736
- }
737
- async #tryCallNotificationHandler(method, params) {
738
- try {
739
- await this.#notificationHandler(method, params);
740
- return { result: null };
741
- }
742
- catch (error) {
743
- if (error instanceof RequestError) {
744
- return error.toResult();
745
- }
746
- if (error instanceof z.ZodError) {
747
- return RequestError.invalidParams(error.format()).toResult();
748
- }
749
- let details;
750
- if (error instanceof Error) {
751
- details = error.message;
752
- }
753
- else if (typeof error === "object" &&
754
- error != null &&
755
- "message" in error &&
756
- typeof error.message === "string") {
757
- details = error.message;
758
- }
759
- try {
760
- return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
761
- }
762
- catch {
763
- return RequestError.internalError({ details }).toResult();
764
- }
765
- }
766
- }
767
- #handleResponse(response) {
768
- const pendingResponse = this.#pendingResponses.get(response.id);
769
- if (pendingResponse) {
770
- if ("result" in response) {
771
- pendingResponse.resolve(response.result);
772
- }
773
- else if ("error" in response) {
774
- pendingResponse.reject(response.error);
775
- }
776
- this.#pendingResponses.delete(response.id);
777
- }
778
- else {
779
- console.error("Got response to unknown request", response.id);
780
- }
781
- }
782
- async sendRequest(method, params) {
783
- const id = this.#nextRequestId++;
784
- const responsePromise = new Promise((resolve, reject) => {
785
- this.#pendingResponses.set(id, { resolve, reject });
786
- });
787
- await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
788
- return responsePromise;
789
- }
790
- async sendNotification(method, params) {
791
- await this.#sendMessage({ jsonrpc: "2.0", method, params });
792
- }
793
- async #sendMessage(message) {
794
- this.#writeQueue = this.#writeQueue
795
- .then(async () => {
796
- const writer = this.#stream.writable.getWriter();
797
- try {
798
- await writer.write(message);
799
- }
800
- finally {
801
- writer.releaseLock();
802
- }
803
- })
804
- .catch((error) => {
805
- // Continue processing writes on error
806
- console.error("ACP write error:", error);
807
- });
808
- return this.#writeQueue;
809
- }
810
- }
811
- /**
812
- * JSON-RPC error object.
813
- *
814
- * Represents an error that occurred during method execution, following the
815
- * JSON-RPC 2.0 error object specification with optional additional data.
816
- *
817
- * See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)
818
- */
819
- class RequestError extends Error {
820
- code;
821
- data;
822
- constructor(code, message, data) {
823
- super(message);
824
- this.code = code;
825
- this.name = "RequestError";
826
- this.data = data;
827
- }
828
- /**
829
- * Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
830
- */
831
- static parseError(data, additionalMessage) {
832
- return new RequestError(-32700, `Parse error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
833
- }
834
- /**
835
- * The JSON sent is not a valid Request object.
836
- */
837
- static invalidRequest(data, additionalMessage) {
838
- return new RequestError(-32600, `Invalid request${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
839
- }
840
- /**
841
- * The method does not exist / is not available.
842
- */
843
- static methodNotFound(method) {
844
- return new RequestError(-32601, `"Method not found": ${method}`, {
845
- method,
846
- });
847
- }
848
- /**
849
- * Invalid method parameter(s).
850
- */
851
- static invalidParams(data, additionalMessage) {
852
- return new RequestError(-32602, `Invalid params${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
853
- }
854
- /**
855
- * Internal JSON-RPC error.
856
- */
857
- static internalError(data, additionalMessage) {
858
- return new RequestError(-32603, `Internal error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
859
- }
860
- /**
861
- * Authentication required.
862
- */
863
- static authRequired(data, additionalMessage) {
864
- return new RequestError(-32e3, `Authentication required${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
865
- }
866
- /**
867
- * Resource, such as a file, was not found
868
- */
869
- static resourceNotFound(uri) {
870
- return new RequestError(-32002, `Resource not found${uri ? `: ${uri}` : ""}`, uri && { uri });
871
- }
872
- toResult() {
873
- return {
874
- error: {
875
- code: this.code,
876
- message: this.message,
877
- data: this.data,
878
- },
879
- };
880
- }
881
- toErrorResponse() {
882
- return {
883
- code: this.code,
884
- message: this.message,
885
- data: this.data,
886
- };
887
- }
888
- }
889
-
890
- export { AGENT_METHODS, AgentSideConnection, CLIENT_METHODS, ClientSideConnection, RequestError, TerminalHandle, authenticateRequestSchema, cancelNotificationSchema, createTerminalRequestSchema, initializeRequestSchema, killTerminalCommandRequestSchema, loadSessionRequestSchema, newSessionRequestSchema, promptRequestSchema, readTextFileRequestSchema, releaseTerminalRequestSchema, requestPermissionRequestSchema, sessionNotificationSchema, setSessionModeRequestSchema, setSessionModelRequestSchema, terminalOutputRequestSchema, waitForTerminalExitRequestSchema, writeTextFileRequestSchema };
891
- //# sourceMappingURL=acp.js.map