@posthog/agent 1.24.2 → 1.26.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 (606) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +6 -0
  2. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  3. package/dist/_virtual/_tslib.js +74 -0
  4. package/dist/_virtual/_tslib.js.map +1 -0
  5. package/dist/_virtual/additionalItems.js +4 -0
  6. package/dist/_virtual/additionalItems.js.map +1 -0
  7. package/dist/_virtual/additionalProperties.js +4 -0
  8. package/dist/_virtual/additionalProperties.js.map +1 -0
  9. package/dist/_virtual/ajv.js +4 -0
  10. package/dist/_virtual/ajv.js.map +1 -0
  11. package/dist/_virtual/allOf.js +4 -0
  12. package/dist/_virtual/allOf.js.map +1 -0
  13. package/dist/_virtual/anyOf.js +4 -0
  14. package/dist/_virtual/anyOf.js.map +1 -0
  15. package/dist/_virtual/applicability.js +4 -0
  16. package/dist/_virtual/applicability.js.map +1 -0
  17. package/dist/_virtual/boolSchema.js +4 -0
  18. package/dist/_virtual/boolSchema.js.map +1 -0
  19. package/dist/_virtual/code.js +4 -0
  20. package/dist/_virtual/code.js.map +1 -0
  21. package/dist/_virtual/code2.js +4 -0
  22. package/dist/_virtual/code2.js.map +1 -0
  23. package/dist/_virtual/const.js +4 -0
  24. package/dist/_virtual/const.js.map +1 -0
  25. package/dist/_virtual/contains.js +4 -0
  26. package/dist/_virtual/contains.js.map +1 -0
  27. package/dist/_virtual/core.js +4 -0
  28. package/dist/_virtual/core.js.map +1 -0
  29. package/dist/_virtual/dataType.js +4 -0
  30. package/dist/_virtual/dataType.js.map +1 -0
  31. package/dist/_virtual/defaults.js +4 -0
  32. package/dist/_virtual/defaults.js.map +1 -0
  33. package/dist/_virtual/dependencies.js +4 -0
  34. package/dist/_virtual/dependencies.js.map +1 -0
  35. package/dist/_virtual/draft7.js +4 -0
  36. package/dist/_virtual/draft7.js.map +1 -0
  37. package/dist/_virtual/enum.js +4 -0
  38. package/dist/_virtual/enum.js.map +1 -0
  39. package/dist/_virtual/equal.js +4 -0
  40. package/dist/_virtual/equal.js.map +1 -0
  41. package/dist/_virtual/errors.js +4 -0
  42. package/dist/_virtual/errors.js.map +1 -0
  43. package/dist/_virtual/format.js +4 -0
  44. package/dist/_virtual/format.js.map +1 -0
  45. package/dist/_virtual/formats.js +4 -0
  46. package/dist/_virtual/formats.js.map +1 -0
  47. package/dist/_virtual/id.js +4 -0
  48. package/dist/_virtual/id.js.map +1 -0
  49. package/dist/_virtual/if.js +4 -0
  50. package/dist/_virtual/if.js.map +1 -0
  51. package/dist/_virtual/index.js +4 -0
  52. package/dist/_virtual/index.js.map +1 -0
  53. package/dist/_virtual/index10.js +4 -0
  54. package/dist/_virtual/index10.js.map +1 -0
  55. package/dist/_virtual/index11.js +4 -0
  56. package/dist/_virtual/index11.js.map +1 -0
  57. package/dist/_virtual/index2.js +4 -0
  58. package/dist/_virtual/index2.js.map +1 -0
  59. package/dist/_virtual/index3.js +4 -0
  60. package/dist/_virtual/index3.js.map +1 -0
  61. package/dist/_virtual/index4.js +4 -0
  62. package/dist/_virtual/index4.js.map +1 -0
  63. package/dist/_virtual/index5.js +4 -0
  64. package/dist/_virtual/index5.js.map +1 -0
  65. package/dist/_virtual/index6.js +4 -0
  66. package/dist/_virtual/index6.js.map +1 -0
  67. package/dist/_virtual/index7.js +4 -0
  68. package/dist/_virtual/index7.js.map +1 -0
  69. package/dist/_virtual/index8.js +4 -0
  70. package/dist/_virtual/index8.js.map +1 -0
  71. package/dist/_virtual/index9.js +4 -0
  72. package/dist/_virtual/index9.js.map +1 -0
  73. package/dist/_virtual/items.js +4 -0
  74. package/dist/_virtual/items.js.map +1 -0
  75. package/dist/_virtual/items2020.js +4 -0
  76. package/dist/_virtual/items2020.js.map +1 -0
  77. package/dist/_virtual/keyword.js +4 -0
  78. package/dist/_virtual/keyword.js.map +1 -0
  79. package/dist/_virtual/limit.js +4 -0
  80. package/dist/_virtual/limit.js.map +1 -0
  81. package/dist/_virtual/limitItems.js +4 -0
  82. package/dist/_virtual/limitItems.js.map +1 -0
  83. package/dist/_virtual/limitLength.js +4 -0
  84. package/dist/_virtual/limitLength.js.map +1 -0
  85. package/dist/_virtual/limitNumber.js +4 -0
  86. package/dist/_virtual/limitNumber.js.map +1 -0
  87. package/dist/_virtual/limitProperties.js +4 -0
  88. package/dist/_virtual/limitProperties.js.map +1 -0
  89. package/dist/_virtual/metadata.js +4 -0
  90. package/dist/_virtual/metadata.js.map +1 -0
  91. package/dist/_virtual/multipleOf.js +4 -0
  92. package/dist/_virtual/multipleOf.js.map +1 -0
  93. package/dist/_virtual/names.js +4 -0
  94. package/dist/_virtual/names.js.map +1 -0
  95. package/dist/_virtual/not.js +4 -0
  96. package/dist/_virtual/not.js.map +1 -0
  97. package/dist/_virtual/oneOf.js +4 -0
  98. package/dist/_virtual/oneOf.js.map +1 -0
  99. package/dist/_virtual/pattern.js +4 -0
  100. package/dist/_virtual/pattern.js.map +1 -0
  101. package/dist/_virtual/patternProperties.js +4 -0
  102. package/dist/_virtual/patternProperties.js.map +1 -0
  103. package/dist/_virtual/prefixItems.js +4 -0
  104. package/dist/_virtual/prefixItems.js.map +1 -0
  105. package/dist/_virtual/properties.js +4 -0
  106. package/dist/_virtual/properties.js.map +1 -0
  107. package/dist/_virtual/propertyNames.js +4 -0
  108. package/dist/_virtual/propertyNames.js.map +1 -0
  109. package/dist/_virtual/ref.js +4 -0
  110. package/dist/_virtual/ref.js.map +1 -0
  111. package/dist/_virtual/ref_error.js +4 -0
  112. package/dist/_virtual/ref_error.js.map +1 -0
  113. package/dist/_virtual/required.js +4 -0
  114. package/dist/_virtual/required.js.map +1 -0
  115. package/dist/_virtual/resolve.js +4 -0
  116. package/dist/_virtual/resolve.js.map +1 -0
  117. package/dist/_virtual/rules.js +4 -0
  118. package/dist/_virtual/rules.js.map +1 -0
  119. package/dist/_virtual/scope.js +4 -0
  120. package/dist/_virtual/scope.js.map +1 -0
  121. package/dist/_virtual/subschema.js +4 -0
  122. package/dist/_virtual/subschema.js.map +1 -0
  123. package/dist/_virtual/thenElse.js +4 -0
  124. package/dist/_virtual/thenElse.js.map +1 -0
  125. package/dist/_virtual/types.js +4 -0
  126. package/dist/_virtual/types.js.map +1 -0
  127. package/dist/_virtual/ucs2length.js +4 -0
  128. package/dist/_virtual/ucs2length.js.map +1 -0
  129. package/dist/_virtual/uniqueItems.js +4 -0
  130. package/dist/_virtual/uniqueItems.js.map +1 -0
  131. package/dist/_virtual/uri.js +4 -0
  132. package/dist/_virtual/uri.js.map +1 -0
  133. package/dist/_virtual/util.js +4 -0
  134. package/dist/_virtual/util.js.map +1 -0
  135. package/dist/_virtual/validation_error.js +4 -0
  136. package/dist/_virtual/validation_error.js.map +1 -0
  137. package/dist/claude-cli/cli.js +2294 -2146
  138. package/dist/example-client.d.ts +3 -0
  139. package/dist/example-client.d.ts.map +1 -0
  140. package/dist/index.d.ts +19 -11
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +7 -3
  143. package/dist/index.js.map +1 -1
  144. package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +891 -0
  145. package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
  146. package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +876 -0
  147. package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +1 -0
  148. package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +66 -0
  149. package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
  150. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +23 -0
  151. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
  152. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +331 -0
  153. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
  154. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +717 -0
  155. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
  156. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +221 -0
  157. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
  158. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +56 -0
  159. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
  160. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +440 -0
  161. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
  162. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +94 -0
  163. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
  164. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1610 -0
  165. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
  166. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +91 -0
  167. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
  168. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +133 -0
  169. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +1 -0
  170. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +9 -0
  171. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +1 -0
  172. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +9 -0
  173. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
  174. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +112 -0
  175. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
  176. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +136 -0
  177. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +1 -0
  178. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +112 -0
  179. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +1 -0
  180. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +3297 -0
  181. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +1 -0
  182. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +44 -0
  183. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +1 -0
  184. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +36 -0
  185. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +1 -0
  186. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +10 -0
  187. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +1 -0
  188. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +657 -0
  189. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +1 -0
  190. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +449 -0
  191. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +1 -0
  192. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +413 -0
  193. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +1 -0
  194. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +57 -0
  195. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +1 -0
  196. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +38 -0
  197. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +1 -0
  198. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +86 -0
  199. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +1 -0
  200. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +61 -0
  201. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +1 -0
  202. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +80 -0
  203. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +1 -0
  204. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +52 -0
  205. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +1 -0
  206. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +1307 -0
  207. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +1 -0
  208. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +842 -0
  209. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
  210. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +335 -0
  211. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +1 -0
  212. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +8 -0
  213. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +1 -0
  214. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +51 -0
  215. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +1 -0
  216. package/dist/node_modules/ajv/dist/ajv.js +69 -0
  217. package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
  218. package/dist/node_modules/ajv/dist/compile/codegen/code.js +169 -0
  219. package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
  220. package/dist/node_modules/ajv/dist/compile/codegen/index.js +712 -0
  221. package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
  222. package/dist/node_modules/ajv/dist/compile/codegen/scope.js +157 -0
  223. package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
  224. package/dist/node_modules/ajv/dist/compile/errors.js +140 -0
  225. package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
  226. package/dist/node_modules/ajv/dist/compile/index.js +253 -0
  227. package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
  228. package/dist/node_modules/ajv/dist/compile/names.js +40 -0
  229. package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
  230. package/dist/node_modules/ajv/dist/compile/ref_error.js +25 -0
  231. package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
  232. package/dist/node_modules/ajv/dist/compile/resolve.js +162 -0
  233. package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
  234. package/dist/node_modules/ajv/dist/compile/rules.js +29 -0
  235. package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
  236. package/dist/node_modules/ajv/dist/compile/util.js +183 -0
  237. package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
  238. package/dist/node_modules/ajv/dist/compile/validate/applicability.js +30 -0
  239. package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
  240. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +64 -0
  241. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
  242. package/dist/node_modules/ajv/dist/compile/validate/dataType.js +213 -0
  243. package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
  244. package/dist/node_modules/ajv/dist/compile/validate/defaults.js +49 -0
  245. package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
  246. package/dist/node_modules/ajv/dist/compile/validate/index.js +544 -0
  247. package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
  248. package/dist/node_modules/ajv/dist/compile/validate/keyword.js +139 -0
  249. package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
  250. package/dist/node_modules/ajv/dist/compile/validate/subschema.js +95 -0
  251. package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
  252. package/dist/node_modules/ajv/dist/core.js +639 -0
  253. package/dist/node_modules/ajv/dist/core.js.map +1 -0
  254. package/dist/node_modules/ajv/dist/refs/data.json.js +31 -0
  255. package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
  256. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +254 -0
  257. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
  258. package/dist/node_modules/ajv/dist/runtime/equal.js +9 -0
  259. package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
  260. package/dist/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
  261. package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
  262. package/dist/node_modules/ajv/dist/runtime/uri.js +8 -0
  263. package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
  264. package/dist/node_modules/ajv/dist/runtime/validation_error.js +22 -0
  265. package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
  266. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +53 -0
  267. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
  268. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +112 -0
  269. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
  270. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +26 -0
  271. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
  272. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +14 -0
  273. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
  274. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +99 -0
  275. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
  276. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +93 -0
  277. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
  278. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +70 -0
  279. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
  280. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +77 -0
  281. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
  282. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +57 -0
  283. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
  284. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +37 -0
  285. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
  286. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +29 -0
  287. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
  288. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
  289. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
  290. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +80 -0
  291. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
  292. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +15 -0
  293. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
  294. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -0
  295. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
  296. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +42 -0
  297. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
  298. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +16 -0
  299. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
  300. package/dist/node_modules/ajv/dist/vocabularies/code.js +146 -0
  301. package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
  302. package/dist/node_modules/ajv/dist/vocabularies/core/id.js +11 -0
  303. package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
  304. package/dist/node_modules/ajv/dist/vocabularies/core/index.js +21 -0
  305. package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
  306. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +131 -0
  307. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
  308. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +113 -0
  309. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
  310. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +12 -0
  311. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
  312. package/dist/node_modules/ajv/dist/vocabularies/draft7.js +28 -0
  313. package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
  314. package/dist/node_modules/ajv/dist/vocabularies/format/format.js +94 -0
  315. package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
  316. package/dist/node_modules/ajv/dist/vocabularies/format/index.js +9 -0
  317. package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
  318. package/dist/node_modules/ajv/dist/vocabularies/metadata.js +21 -0
  319. package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
  320. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +31 -0
  321. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
  322. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
  323. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
  324. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +54 -0
  325. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
  326. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +26 -0
  327. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
  328. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
  329. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
  330. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +29 -0
  331. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
  332. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +26 -0
  333. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
  334. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +28 -0
  335. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
  336. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +27 -0
  337. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
  338. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +84 -0
  339. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
  340. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +72 -0
  341. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
  342. package/dist/node_modules/ajv-formats/dist/formats.js +212 -0
  343. package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
  344. package/dist/node_modules/ajv-formats/dist/index.js +52 -0
  345. package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
  346. package/dist/node_modules/ajv-formats/dist/limit.js +75 -0
  347. package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
  348. package/dist/node_modules/diff/libesm/diff/base.js +256 -0
  349. package/dist/node_modules/diff/libesm/diff/base.js.map +1 -0
  350. package/dist/node_modules/diff/libesm/diff/line.js +64 -0
  351. package/dist/node_modules/diff/libesm/diff/line.js.map +1 -0
  352. package/dist/node_modules/diff/libesm/patch/create.js +185 -0
  353. package/dist/node_modules/diff/libesm/patch/create.js.map +1 -0
  354. package/dist/node_modules/fast-deep-equal/index.js +47 -0
  355. package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
  356. package/dist/node_modules/fast-uri/index.js +347 -0
  357. package/dist/node_modules/fast-uri/index.js.map +1 -0
  358. package/dist/node_modules/fast-uri/lib/schemes.js +255 -0
  359. package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
  360. package/dist/node_modules/fast-uri/lib/utils.js +334 -0
  361. package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
  362. package/dist/node_modules/json-schema-traverse/index.js +98 -0
  363. package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
  364. package/dist/node_modules/uuid/dist/rng.js +14 -0
  365. package/dist/node_modules/uuid/dist/rng.js.map +1 -0
  366. package/dist/node_modules/uuid/dist/stringify.js +29 -0
  367. package/dist/node_modules/uuid/dist/stringify.js.map +1 -0
  368. package/dist/node_modules/uuid/dist/v7.js +65 -0
  369. package/dist/node_modules/uuid/dist/v7.js.map +1 -0
  370. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
  371. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
  372. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
  373. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
  374. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
  375. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
  376. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
  377. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
  378. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
  379. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
  380. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
  381. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
  382. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
  383. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
  384. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
  385. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
  386. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
  387. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
  388. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
  389. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
  390. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
  391. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
  392. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
  393. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
  394. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
  395. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
  396. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
  397. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
  398. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
  399. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
  400. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
  401. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
  402. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
  403. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
  404. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
  405. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
  406. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
  407. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
  408. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
  409. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
  410. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
  411. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
  412. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
  413. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
  414. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
  415. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
  416. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
  417. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
  418. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
  419. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
  420. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
  421. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
  422. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
  423. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
  424. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
  425. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
  426. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
  427. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
  428. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
  429. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
  430. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
  431. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
  432. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
  433. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
  434. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
  435. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
  436. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
  437. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
  438. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
  439. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
  440. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +109 -0
  441. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
  442. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
  443. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
  444. package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +42 -0
  445. package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +1 -0
  446. package/dist/package.json.js +8 -0
  447. package/dist/package.json.js.map +1 -0
  448. package/dist/src/acp-extensions.d.ts +91 -0
  449. package/dist/src/acp-extensions.d.ts.map +1 -0
  450. package/dist/src/acp-extensions.js +38 -0
  451. package/dist/src/acp-extensions.js.map +1 -0
  452. package/dist/src/adapters/claude/claude.d.ts +136 -0
  453. package/dist/src/adapters/claude/claude.d.ts.map +1 -0
  454. package/dist/src/adapters/claude/claude.js +1128 -0
  455. package/dist/src/adapters/claude/claude.js.map +1 -0
  456. package/dist/src/adapters/claude/mcp-server.d.ts +30 -0
  457. package/dist/src/adapters/claude/mcp-server.d.ts.map +1 -0
  458. package/dist/src/adapters/claude/mcp-server.js +668 -0
  459. package/dist/src/adapters/claude/mcp-server.js.map +1 -0
  460. package/dist/src/adapters/claude/tools.d.ts +35 -0
  461. package/dist/src/adapters/claude/tools.d.ts.map +1 -0
  462. package/dist/src/adapters/claude/tools.js +473 -0
  463. package/dist/src/adapters/claude/tools.js.map +1 -0
  464. package/dist/src/adapters/claude/utils.d.ts +48 -0
  465. package/dist/src/adapters/claude/utils.d.ts.map +1 -0
  466. package/dist/src/adapters/claude/utils.js +158 -0
  467. package/dist/src/adapters/claude/utils.js.map +1 -0
  468. package/dist/src/agent.d.ts +24 -28
  469. package/dist/src/agent.d.ts.map +1 -1
  470. package/dist/src/agent.js +343 -172
  471. package/dist/src/agent.js.map +1 -1
  472. package/dist/src/agents/execution.js.map +1 -1
  473. package/dist/src/agents/planning.js.map +1 -1
  474. package/dist/src/agents/research.js.map +1 -1
  475. package/dist/src/file-manager.d.ts +6 -6
  476. package/dist/src/file-manager.d.ts.map +1 -1
  477. package/dist/src/file-manager.js +72 -63
  478. package/dist/src/file-manager.js.map +1 -1
  479. package/dist/src/git-manager.d.ts +2 -1
  480. package/dist/src/git-manager.d.ts.map +1 -1
  481. package/dist/src/git-manager.js +105 -70
  482. package/dist/src/git-manager.js.map +1 -1
  483. package/dist/src/posthog-api.d.ts +8 -14
  484. package/dist/src/posthog-api.d.ts.map +1 -1
  485. package/dist/src/posthog-api.js +35 -23
  486. package/dist/src/posthog-api.js.map +1 -1
  487. package/dist/src/prompt-builder.d.ts +4 -4
  488. package/dist/src/prompt-builder.d.ts.map +1 -1
  489. package/dist/src/prompt-builder.js +129 -99
  490. package/dist/src/prompt-builder.js.map +1 -1
  491. package/dist/src/schemas.d.ts +980 -0
  492. package/dist/src/schemas.d.ts.map +1 -0
  493. package/dist/src/schemas.js +196 -0
  494. package/dist/src/schemas.js.map +1 -0
  495. package/dist/src/session-store.d.ts +58 -0
  496. package/dist/src/session-store.d.ts.map +1 -0
  497. package/dist/src/session-store.js +206 -0
  498. package/dist/src/session-store.js.map +1 -0
  499. package/dist/src/task-manager.d.ts +7 -7
  500. package/dist/src/task-manager.d.ts.map +1 -1
  501. package/dist/src/task-manager.js +19 -18
  502. package/dist/src/task-manager.js.map +1 -1
  503. package/dist/src/template-manager.d.ts +1 -1
  504. package/dist/src/template-manager.d.ts.map +1 -1
  505. package/dist/src/template-manager.js +30 -28
  506. package/dist/src/template-manager.js.map +1 -1
  507. package/dist/src/todo-manager.d.ts +5 -5
  508. package/dist/src/todo-manager.d.ts.map +1 -1
  509. package/dist/src/todo-manager.js +33 -24
  510. package/dist/src/todo-manager.js.map +1 -1
  511. package/dist/src/tools/registry.d.ts +1 -1
  512. package/dist/src/tools/registry.js +60 -60
  513. package/dist/src/tools/registry.js.map +1 -1
  514. package/dist/src/tools/types.d.ts +31 -31
  515. package/dist/src/types.d.ts +62 -167
  516. package/dist/src/types.d.ts.map +1 -1
  517. package/dist/src/types.js +1 -0
  518. package/dist/src/types.js.map +1 -1
  519. package/dist/src/utils/logger.d.ts +14 -6
  520. package/dist/src/utils/logger.d.ts.map +1 -1
  521. package/dist/src/utils/logger.js +37 -22
  522. package/dist/src/utils/logger.js.map +1 -1
  523. package/dist/src/utils/tapped-stream.d.ts +17 -0
  524. package/dist/src/utils/tapped-stream.d.ts.map +1 -0
  525. package/dist/src/utils/tapped-stream.js +45 -0
  526. package/dist/src/utils/tapped-stream.js.map +1 -0
  527. package/dist/src/workflow/config.d.ts +1 -1
  528. package/dist/src/workflow/config.d.ts.map +1 -1
  529. package/dist/src/workflow/config.js +18 -18
  530. package/dist/src/workflow/config.js.map +1 -1
  531. package/dist/src/workflow/steps/build.d.ts +1 -1
  532. package/dist/src/workflow/steps/build.d.ts.map +1 -1
  533. package/dist/src/workflow/steps/build.js +53 -39
  534. package/dist/src/workflow/steps/build.js.map +1 -1
  535. package/dist/src/workflow/steps/finalize.d.ts +1 -1
  536. package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
  537. package/dist/src/workflow/steps/finalize.js +58 -52
  538. package/dist/src/workflow/steps/finalize.js.map +1 -1
  539. package/dist/src/workflow/steps/plan.d.ts +1 -1
  540. package/dist/src/workflow/steps/plan.d.ts.map +1 -1
  541. package/dist/src/workflow/steps/plan.js +69 -47
  542. package/dist/src/workflow/steps/plan.js.map +1 -1
  543. package/dist/src/workflow/steps/research.d.ts +1 -1
  544. package/dist/src/workflow/steps/research.d.ts.map +1 -1
  545. package/dist/src/workflow/steps/research.js +86 -67
  546. package/dist/src/workflow/steps/research.js.map +1 -1
  547. package/dist/src/workflow/types.d.ts +19 -14
  548. package/dist/src/workflow/types.d.ts.map +1 -1
  549. package/dist/src/workflow/utils.d.ts +1 -1
  550. package/dist/src/workflow/utils.d.ts.map +1 -1
  551. package/dist/src/workflow/utils.js +7 -4
  552. package/dist/src/workflow/utils.js.map +1 -1
  553. package/dist/src/worktree-manager.d.ts +39 -0
  554. package/dist/src/worktree-manager.d.ts.map +1 -0
  555. package/dist/src/worktree-manager.js +808 -0
  556. package/dist/src/worktree-manager.js.map +1 -0
  557. package/package.json +20 -16
  558. package/src/acp-extensions.ts +117 -0
  559. package/src/adapters/claude/claude.ts +1514 -0
  560. package/src/adapters/claude/mcp-server.ts +810 -0
  561. package/src/adapters/claude/tools.ts +616 -0
  562. package/src/adapters/claude/utils.ts +267 -0
  563. package/src/agent.ts +717 -441
  564. package/src/agents/execution.ts +1 -1
  565. package/src/agents/planning.ts +1 -1
  566. package/src/agents/research.ts +0 -1
  567. package/src/file-manager.ts +80 -70
  568. package/src/git-manager.ts +164 -88
  569. package/src/posthog-api.ts +155 -94
  570. package/src/prompt-builder.ts +196 -143
  571. package/src/schemas.ts +241 -0
  572. package/src/session-store.ts +259 -0
  573. package/src/task-manager.ts +41 -33
  574. package/src/template-manager.ts +98 -45
  575. package/src/todo-manager.ts +43 -32
  576. package/src/tools/registry.ts +62 -62
  577. package/src/tools/types.ts +36 -36
  578. package/src/types.ts +130 -239
  579. package/src/utils/logger.ts +89 -58
  580. package/src/utils/tapped-stream.ts +60 -0
  581. package/src/workflow/config.ts +48 -48
  582. package/src/workflow/steps/build.ts +127 -113
  583. package/src/workflow/steps/finalize.ts +207 -182
  584. package/src/workflow/steps/plan.ts +155 -130
  585. package/src/workflow/steps/research.ts +207 -187
  586. package/src/workflow/types.ts +47 -36
  587. package/src/workflow/utils.ts +37 -34
  588. package/src/worktree-manager.ts +881 -0
  589. package/dist/src/adapters/claude/claude-adapter.d.ts +0 -18
  590. package/dist/src/adapters/claude/claude-adapter.d.ts.map +0 -1
  591. package/dist/src/adapters/claude/claude-adapter.js +0 -311
  592. package/dist/src/adapters/claude/claude-adapter.js.map +0 -1
  593. package/dist/src/adapters/claude/tool-mapper.d.ts +0 -19
  594. package/dist/src/adapters/claude/tool-mapper.d.ts.map +0 -1
  595. package/dist/src/adapters/claude/tool-mapper.js +0 -44
  596. package/dist/src/adapters/claude/tool-mapper.js.map +0 -1
  597. package/dist/src/adapters/types.d.ts +0 -33
  598. package/dist/src/adapters/types.d.ts.map +0 -1
  599. package/dist/src/task-progress-reporter.d.ts +0 -43
  600. package/dist/src/task-progress-reporter.d.ts.map +0 -1
  601. package/dist/src/task-progress-reporter.js +0 -393
  602. package/dist/src/task-progress-reporter.js.map +0 -1
  603. package/src/adapters/claude/claude-adapter.ts +0 -338
  604. package/src/adapters/claude/tool-mapper.ts +0 -46
  605. package/src/adapters/types.ts +0 -37
  606. package/src/task-progress-reporter.ts +0 -443
package/src/agent.ts CHANGED
@@ -1,322 +1,377 @@
1
- import { query } from "@anthropic-ai/claude-agent-sdk";
2
- import type { Task, ExecutionResult, AgentConfig, CanUseTool } from './types.js';
3
- import { TaskManager } from './task-manager.js';
4
- import { PostHogAPIClient } from './posthog-api.js';
5
- import { PostHogFileManager } from './file-manager.js';
6
- import { GitManager } from './git-manager.js';
7
- import { TemplateManager } from './template-manager.js';
8
- import { ClaudeAdapter } from './adapters/claude/claude-adapter.js';
9
- import type { ProviderAdapter } from './adapters/types.js';
10
- import { Logger } from './utils/logger.js';
11
- import { PromptBuilder } from './prompt-builder.js';
12
- import { TaskProgressReporter } from './task-progress-reporter.js';
13
- import { TASK_WORKFLOW } from './workflow/config.js';
14
- import type { WorkflowRuntime } from './workflow/types.js';
1
+ import {
2
+ type Client,
3
+ ClientSideConnection,
4
+ type ContentBlock,
5
+ ndJsonStream,
6
+ PROTOCOL_VERSION,
7
+ type RequestPermissionRequest,
8
+ type RequestPermissionResponse,
9
+ type SessionNotification,
10
+ } from "@agentclientprotocol/sdk";
11
+ import { POSTHOG_NOTIFICATIONS } from "./acp-extensions.js";
12
+ import {
13
+ createAcpConnection,
14
+ type InProcessAcpConnection,
15
+ } from "./adapters/claude/claude.js";
16
+ import { PostHogFileManager } from "./file-manager.js";
17
+ import { GitManager } from "./git-manager.js";
18
+ import { PostHogAPIClient } from "./posthog-api.js";
19
+ import { PromptBuilder } from "./prompt-builder.js";
20
+ import { SessionStore } from "./session-store.js";
21
+ import { TaskManager } from "./task-manager.js";
22
+ import { TemplateManager } from "./template-manager.js";
23
+ import type {
24
+ AgentConfig,
25
+ CanUseTool,
26
+ StoredNotification,
27
+ Task,
28
+ TaskExecutionOptions,
29
+ } from "./types.js";
30
+ import { Logger } from "./utils/logger.js";
31
+ import { TASK_WORKFLOW } from "./workflow/config.js";
32
+ import type { SendNotification, WorkflowRuntime } from "./workflow/types.js";
15
33
 
16
34
  export class Agent {
17
- private workingDirectory: string;
18
- private onEvent?: (event: any) => void;
19
- private taskManager: TaskManager;
20
- private posthogAPI?: PostHogAPIClient;
21
- private fileManager: PostHogFileManager;
22
- private gitManager: GitManager;
23
- private templateManager: TemplateManager;
24
- private adapter: ProviderAdapter;
25
- private logger: Logger;
26
- private progressReporter: TaskProgressReporter;
27
- private promptBuilder: PromptBuilder;
28
- private mcpServers?: Record<string, any>;
29
- private canUseTool?: CanUseTool;
30
- public debug: boolean;
31
-
32
- constructor(config: AgentConfig) {
33
- this.workingDirectory = config.workingDirectory || process.cwd();
34
- this.onEvent = config.onEvent;
35
- this.canUseTool = config.canUseTool;
36
- this.debug = config.debug || false;
37
-
38
- // Build default PostHog MCP server configuration
39
- const posthogMcpUrl = config.posthogMcpUrl
40
- || process.env.POSTHOG_MCP_URL
41
- || 'https://mcp.posthog.com/mcp';
42
-
43
- // Add auth if API key provided
44
- const headers: Record<string, string> = {};
45
- if (config.posthogApiKey) {
46
- headers['Authorization'] = `Bearer ${config.posthogApiKey}`;
47
- }
48
-
49
- const defaultMcpServers = {
50
- posthog: {
51
- type: 'http' as const,
52
- url: posthogMcpUrl,
53
- ...(Object.keys(headers).length > 0 ? { headers } : {}),
54
- }
55
- };
56
-
57
- // Merge default PostHog MCP with user-provided servers (user config takes precedence)
58
- this.mcpServers = {
59
- ...defaultMcpServers,
60
- ...config.mcpServers
61
- };
62
- this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });
63
- this.taskManager = new TaskManager();
64
- // Hardcode Claude adapter for now - extensible for other providers later
65
- this.adapter = new ClaudeAdapter();
66
-
67
- this.fileManager = new PostHogFileManager(
68
- this.workingDirectory,
69
- this.logger.child('FileManager')
70
- );
71
- this.gitManager = new GitManager({
72
- repositoryPath: this.workingDirectory,
73
- logger: this.logger.child('GitManager')
74
- // TODO: Add author config from environment or config
75
- });
76
- this.templateManager = new TemplateManager();
77
-
78
- if (config.posthogApiUrl && config.posthogApiKey) {
79
- this.posthogAPI = new PostHogAPIClient({
80
- apiUrl: config.posthogApiUrl,
81
- apiKey: config.posthogApiKey,
82
- projectId: config.posthogProjectId,
83
- });
84
- }
85
-
86
- this.promptBuilder = new PromptBuilder({
87
- getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),
88
- generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),
89
- posthogClient: this.posthogAPI,
90
- logger: this.logger.child('PromptBuilder')
91
- });
92
- this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);
35
+ private workingDirectory: string;
36
+ private taskManager: TaskManager;
37
+ private posthogAPI?: PostHogAPIClient;
38
+ private fileManager: PostHogFileManager;
39
+ private gitManager: GitManager;
40
+ private templateManager: TemplateManager;
41
+ private logger: Logger;
42
+ private acpConnection?: InProcessAcpConnection;
43
+ private promptBuilder: PromptBuilder;
44
+ private mcpServers?: Record<string, any>;
45
+ private canUseTool?: CanUseTool;
46
+ private currentRunId?: string;
47
+ private sessionStore?: SessionStore;
48
+ public debug: boolean;
49
+
50
+ constructor(config: AgentConfig) {
51
+ this.workingDirectory = config.workingDirectory || process.cwd();
52
+ this.canUseTool = config.canUseTool;
53
+ this.debug = config.debug || false;
54
+
55
+ // Build default PostHog MCP server configuration
56
+ const posthogMcpUrl =
57
+ config.posthogMcpUrl ||
58
+ process.env.POSTHOG_MCP_URL ||
59
+ "https://mcp.posthog.com/mcp";
60
+
61
+ // Add auth if API key provided
62
+ const headers: Record<string, string> = {};
63
+ if (config.posthogApiKey) {
64
+ headers.Authorization = `Bearer ${config.posthogApiKey}`;
93
65
  }
94
66
 
95
- /**
96
- * Enable or disable debug logging
97
- */
98
- setDebug(enabled: boolean) {
99
- this.debug = enabled;
100
- this.logger.setDebug(enabled);
67
+ const defaultMcpServers = {
68
+ posthog: {
69
+ type: "http" as const,
70
+ url: posthogMcpUrl,
71
+ ...(Object.keys(headers).length > 0 ? { headers } : {}),
72
+ },
73
+ };
74
+
75
+ // Merge default PostHog MCP with user-provided servers (user config takes precedence)
76
+ this.mcpServers = {
77
+ ...defaultMcpServers,
78
+ ...config.mcpServers,
79
+ };
80
+ this.logger = new Logger({
81
+ debug: this.debug,
82
+ prefix: "[PostHog Agent]",
83
+ onLog: config.onLog,
84
+ });
85
+ this.taskManager = new TaskManager();
86
+
87
+ this.fileManager = new PostHogFileManager(
88
+ this.workingDirectory,
89
+ this.logger.child("FileManager"),
90
+ );
91
+ this.gitManager = new GitManager({
92
+ repositoryPath: this.workingDirectory,
93
+ logger: this.logger.child("GitManager"),
94
+ });
95
+ this.templateManager = new TemplateManager();
96
+
97
+ if (
98
+ config.posthogApiUrl &&
99
+ config.posthogApiKey &&
100
+ config.posthogProjectId
101
+ ) {
102
+ this.posthogAPI = new PostHogAPIClient({
103
+ apiUrl: config.posthogApiUrl,
104
+ apiKey: config.posthogApiKey,
105
+ projectId: config.posthogProjectId,
106
+ });
107
+
108
+ // Create SessionStore from the API client for ACP connection
109
+ this.sessionStore = new SessionStore(
110
+ this.posthogAPI,
111
+ this.logger.child("SessionStore"),
112
+ );
101
113
  }
102
114
 
103
- /**
104
- * Configure LLM gateway environment variables for Claude Code CLI
105
- */
106
- private async _configureLlmGateway(): Promise<void> {
107
- if (!this.posthogAPI) {
108
- return;
109
- }
110
-
111
- try {
112
- const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();
113
- const apiKey = this.posthogAPI.getApiKey();
114
-
115
- process.env.ANTHROPIC_BASE_URL = gatewayUrl;
116
- process.env.ANTHROPIC_AUTH_TOKEN = apiKey;
117
- this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);
118
-
119
- this.logger.debug('Configured LLM gateway', { gatewayUrl });
120
- } catch (error) {
121
- this.logger.error('Failed to configure LLM gateway', error);
122
- throw error;
123
- }
124
- }
125
-
126
- // Adaptive task execution orchestrated via workflow steps
127
- async runTask(taskOrId: Task | string, options: import('./types.js').TaskExecutionOptions = {}): Promise<void> {
128
- await this._configureLlmGateway();
129
-
130
- const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;
131
- const cwd = options.repositoryPath || this.workingDirectory;
132
- const isCloudMode = options.isCloudMode ?? false;
133
- const taskSlug = (task as any).slug || task.id;
134
-
135
- this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });
136
-
137
- // Initialize progress reporter for task run tracking (needed for PR attachment)
138
- await this.progressReporter.start(task.id, { totalSteps: TASK_WORKFLOW.length });
139
- this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));
140
-
141
- await this.prepareTaskBranch(taskSlug, isCloudMode);
142
-
143
- let taskError: Error | undefined;
144
- try {
145
- const workflowContext: WorkflowRuntime = {
146
- task,
147
- taskSlug,
148
- cwd,
149
- isCloudMode,
150
- options,
151
- logger: this.logger,
152
- fileManager: this.fileManager,
153
- gitManager: this.gitManager,
154
- promptBuilder: this.promptBuilder,
155
- progressReporter: this.progressReporter,
156
- adapter: this.adapter,
157
- mcpServers: this.mcpServers,
158
- posthogAPI: this.posthogAPI,
159
- emitEvent: (event: any) => this.emitEvent(event),
160
- stepResults: {},
161
- };
162
-
163
- for (const step of TASK_WORKFLOW) {
164
- const result = await step.run({ step, context: workflowContext });
165
- if (result.halt) {
166
- return;
167
- }
168
- }
169
-
170
- const shouldCreatePR = options.createPR ?? isCloudMode;
171
- if (shouldCreatePR) {
172
- await this.ensurePullRequest(task, workflowContext.stepResults);
173
- }
174
-
175
- this.logger.info('Task execution complete', { taskId: task.id });
176
- this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));
177
- } catch (error) {
178
- taskError = error instanceof Error ? error : new Error(String(error));
179
- this.logger.error('Task execution failed', { taskId: task.id, error: taskError.message });
180
- } finally {
181
- if (taskError) {
182
- await this.progressReporter.fail(taskError);
183
- throw taskError;
184
- } else {
185
- await this.progressReporter.complete();
186
- }
187
- }
115
+ this.promptBuilder = new PromptBuilder({
116
+ getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),
117
+ generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),
118
+ posthogClient: this.posthogAPI,
119
+ logger: this.logger.child("PromptBuilder"),
120
+ });
121
+ }
122
+
123
+ /**
124
+ * Enable or disable debug logging
125
+ */
126
+ setDebug(enabled: boolean) {
127
+ this.debug = enabled;
128
+ this.logger.setDebug(enabled);
129
+ }
130
+
131
+ /**
132
+ * Configure LLM gateway environment variables for Claude Code CLI
133
+ */
134
+ private async _configureLlmGateway(): Promise<void> {
135
+ if (!this.posthogAPI) {
136
+ return;
188
137
  }
189
138
 
190
- // Direct prompt execution - still supported for low-level usage
191
- async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any>; canUseTool?: CanUseTool } = {}): Promise<ExecutionResult> {
192
- await this._configureLlmGateway();
193
- const baseOptions: Record<string, any> = {
194
- model: "claude-sonnet-4-5-20250929",
195
- cwd: options.repositoryPath || this.workingDirectory,
196
- permissionMode: (options.permissionMode as any) || "default",
197
- settingSources: ["local"],
198
- mcpServers: this.mcpServers,
199
- };
200
-
201
- // Add canUseTool hook if provided (options take precedence over instance config)
202
- const canUseTool = options.canUseTool || this.canUseTool;
203
- if (canUseTool) {
204
- baseOptions.canUseTool = canUseTool;
205
- }
206
-
207
- const response = query({
208
- prompt,
209
- options: { ...baseOptions, ...(options.queryOverrides || {}) },
210
- });
211
-
212
- const results = [];
213
- for await (const message of response) {
214
- this.logger.debug('Received message in direct run', message);
215
- // Emit raw SDK event
216
- this.emitEvent(this.adapter.createRawSDKEvent(message));
217
- const transformedEvents = this.adapter.transform(message);
218
- for (const event of transformedEvents) {
219
- this.emitEvent(event);
220
- }
221
- results.push(message);
222
- }
223
-
224
- return { results };
225
- }
226
-
227
- // PostHog task operations
228
- async fetchTask(taskId: string): Promise<Task> {
229
- this.logger.debug('Fetching task from PostHog', { taskId });
230
- if (!this.posthogAPI) {
231
- const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');
232
- this.logger.error('PostHog API not configured', error);
233
- throw error;
234
- }
235
- return this.posthogAPI.fetchTask(taskId);
139
+ try {
140
+ const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();
141
+ const apiKey = this.posthogAPI.getApiKey();
142
+ process.env.ANTHROPIC_BASE_URL = gatewayUrl;
143
+ process.env.ANTHROPIC_AUTH_TOKEN = apiKey;
144
+ this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);
145
+ } catch (error) {
146
+ this.logger.error("Failed to configure LLM gateway", error);
147
+ throw error;
236
148
  }
149
+ }
237
150
 
238
- getPostHogClient(): PostHogAPIClient | undefined {
239
- return this.posthogAPI;
151
+ private getOrCreateConnection(): InProcessAcpConnection {
152
+ if (!this.acpConnection) {
153
+ this.acpConnection = createAcpConnection({
154
+ sessionStore: this.sessionStore,
155
+ });
240
156
  }
241
-
242
- async listTasks(filters?: {
243
- repository?: string;
244
- organization?: string;
245
- origin_product?: string;
246
- }): Promise<Task[]> {
247
- if (!this.posthogAPI) {
248
- throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');
157
+ return this.acpConnection;
158
+ }
159
+
160
+ // Adaptive task execution orchestrated via workflow steps
161
+ async runTask(
162
+ taskId: string,
163
+ taskRunId: string,
164
+ options: import("./types.js").TaskExecutionOptions = {},
165
+ ): Promise<void> {
166
+ // await this._configureLlmGateway();
167
+
168
+ const task = await this.fetchTask(taskId);
169
+ const cwd = options.repositoryPath || this.workingDirectory;
170
+ const isCloudMode = options.isCloudMode ?? false;
171
+ const taskSlug = (task as any).slug || task.id;
172
+
173
+ // Use taskRunId as sessionId - they are the same identifier
174
+ this.currentRunId = taskRunId;
175
+
176
+ this.logger.info("Starting adaptive task execution", {
177
+ taskId: task.id,
178
+ taskSlug,
179
+ taskRunId,
180
+ isCloudMode,
181
+ });
182
+
183
+ const connection = this.getOrCreateConnection();
184
+
185
+ // Create sendNotification using ACP connection's extNotification
186
+ const sendNotification: SendNotification = async (method, params) => {
187
+ this.logger.debug(`Notification: ${method}`, params);
188
+ await connection.agentConnection.extNotification?.(method, params);
189
+ };
190
+
191
+ await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
192
+ sessionId: taskRunId,
193
+ runId: taskRunId,
194
+ });
195
+
196
+ await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
197
+
198
+ let taskError: Error | undefined;
199
+ try {
200
+ const workflowContext: WorkflowRuntime = {
201
+ task,
202
+ taskSlug,
203
+ runId: taskRunId,
204
+ cwd,
205
+ isCloudMode,
206
+ options,
207
+ logger: this.logger,
208
+ fileManager: this.fileManager,
209
+ gitManager: this.gitManager,
210
+ promptBuilder: this.promptBuilder,
211
+ connection: connection.agentConnection,
212
+ sessionId: taskRunId,
213
+ sendNotification,
214
+ mcpServers: this.mcpServers,
215
+ posthogAPI: this.posthogAPI,
216
+ stepResults: {},
217
+ };
218
+
219
+ for (const step of TASK_WORKFLOW) {
220
+ const result = await step.run({ step, context: workflowContext });
221
+ if (result.halt) {
222
+ return;
249
223
  }
250
- return this.posthogAPI.listTasks(filters);
251
- }
252
-
253
- // File system operations for task artifacts
254
- async writeTaskFile(taskId: string, fileName: string, content: string, type: 'plan' | 'context' | 'reference' | 'output' = 'reference'): Promise<void> {
255
- this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });
256
- await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });
257
- }
258
-
259
- async readTaskFile(taskId: string, fileName: string): Promise<string | null> {
260
- this.logger.debug('Reading task file', { taskId, fileName });
261
- return await this.fileManager.readTaskFile(taskId, fileName);
262
- }
263
-
264
- async getTaskFiles(taskId: string): Promise<any[]> {
265
- this.logger.debug('Getting task files', { taskId });
266
- const files = await this.fileManager.getTaskFiles(taskId);
267
- this.logger.debug('Found task files', { taskId, fileCount: files.length });
268
- return files;
269
- }
270
-
271
- async writePlan(taskId: string, plan: string): Promise<void> {
272
- this.logger.info('Writing plan', { taskId, planLength: plan.length });
273
- await this.fileManager.writePlan(taskId, plan);
224
+ }
225
+
226
+ const shouldCreatePR = options.createPR ?? isCloudMode;
227
+ if (shouldCreatePR) {
228
+ await this.ensurePullRequest(
229
+ task,
230
+ workflowContext.stepResults,
231
+ sendNotification,
232
+ );
233
+ }
234
+
235
+ this.logger.info("Task execution complete", { taskId: task.id });
236
+ await sendNotification(POSTHOG_NOTIFICATIONS.TASK_COMPLETE, {
237
+ sessionId: taskRunId,
238
+ taskId: task.id,
239
+ });
240
+ } catch (error) {
241
+ taskError = error instanceof Error ? error : new Error(String(error));
242
+ this.logger.error("Task execution failed", {
243
+ taskId: task.id,
244
+ error: taskError.message,
245
+ });
246
+ await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
247
+ sessionId: taskRunId,
248
+ message: taskError.message,
249
+ });
250
+ throw taskError;
274
251
  }
275
-
276
- async readPlan(taskId: string): Promise<string | null> {
277
- this.logger.debug('Reading plan', { taskId });
278
- return await this.fileManager.readPlan(taskId);
252
+ }
253
+
254
+ /**
255
+ * Creates an in-process ACP connection for client communication.
256
+ * Sets up git branch for the task, configures LLM gateway.
257
+ * The client handles all prompting/querying via the returned streams.
258
+ *
259
+ * @returns InProcessAcpConnection with clientStreams for the client to use
260
+ */
261
+ async runTaskV2(
262
+ taskId: string,
263
+ taskRunId: string,
264
+ options: import("./types.js").TaskExecutionOptions = {},
265
+ ): Promise<InProcessAcpConnection> {
266
+ await this._configureLlmGateway();
267
+
268
+ const task = await this.fetchTask(taskId);
269
+ const taskSlug = (task as any).slug || task.id;
270
+ const isCloudMode = options.isCloudMode ?? false;
271
+ const _cwd = options.repositoryPath || this.workingDirectory;
272
+
273
+ // Use taskRunId as sessionId - they are the same identifier
274
+ this.currentRunId = taskRunId;
275
+
276
+ this.acpConnection = createAcpConnection({
277
+ sessionStore: this.sessionStore,
278
+ sessionId: taskRunId,
279
+ taskId: task.id,
280
+ });
281
+
282
+ const sendNotification: SendNotification = async (method, params) => {
283
+ this.logger.debug(`Notification: ${method}`, params);
284
+ await this.acpConnection?.agentConnection.extNotification?.(
285
+ method,
286
+ params,
287
+ );
288
+ };
289
+
290
+ await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
291
+ sessionId: taskRunId,
292
+ runId: taskRunId,
293
+ });
294
+
295
+ if (!options.skipGitBranch) {
296
+ try {
297
+ await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
298
+ } catch (error) {
299
+ const errorMessage =
300
+ error instanceof Error ? error.message : String(error);
301
+ this.logger.error("Failed to prepare task branch", {
302
+ error: errorMessage,
303
+ });
304
+ await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
305
+ sessionId: taskRunId,
306
+ message: errorMessage,
307
+ });
308
+ throw error;
309
+ }
279
310
  }
280
311
 
281
- // Git operations for task execution
282
- async createPlanningBranch(taskId: string): Promise<string> {
283
- this.logger.info('Creating planning branch', { taskId });
284
- const branchName = await this.gitManager.createTaskPlanningBranch(taskId);
285
- this.logger.debug('Planning branch created', { taskId, branchName });
286
- return branchName;
287
- }
288
-
289
- async commitPlan(taskId: string, taskTitle: string): Promise<string> {
290
- this.logger.info('Committing plan', { taskId, taskTitle });
291
- const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);
292
- this.logger.debug('Plan committed', { taskId, commitHash });
293
- return commitHash;
294
- }
295
-
296
- async createImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {
297
- this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });
298
- const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);
299
- this.logger.debug('Implementation branch created', { taskId, branchName });
300
- return branchName;
312
+ return this.acpConnection;
313
+ }
314
+
315
+ // PostHog task operations
316
+ async fetchTask(taskId: string): Promise<Task> {
317
+ if (!this.posthogAPI) {
318
+ const error = new Error(
319
+ "PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.",
320
+ );
321
+ this.logger.error("PostHog API not configured", error);
322
+ throw error;
301
323
  }
302
-
303
- async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {
304
- this.logger.info('Committing implementation', { taskId, taskTitle });
305
- const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);
306
- this.logger.debug('Implementation committed', { taskId, commitHash });
307
- return commitHash;
324
+ return this.posthogAPI.fetchTask(taskId);
325
+ }
326
+
327
+ getPostHogClient(): PostHogAPIClient | undefined {
328
+ return this.posthogAPI;
329
+ }
330
+
331
+ /**
332
+ * Send a notification to a cloud task run's S3 log.
333
+ * The cloud runner will pick up new notifications via interrupt polling.
334
+ */
335
+ async sendNotification(
336
+ taskId: string,
337
+ runId: string,
338
+ notification: StoredNotification,
339
+ ): Promise<void> {
340
+ if (!this.posthogAPI) {
341
+ throw new Error(
342
+ "PostHog API not configured. Cannot send notification to cloud task.",
343
+ );
308
344
  }
309
345
 
310
- async createPullRequest(
311
- taskId: string,
312
- branchName: string,
313
- taskTitle: string,
314
- taskDescription: string,
315
- customBody?: string
316
- ): Promise<string> {
317
- this.logger.info('Creating pull request', { taskId, branchName, taskTitle });
318
-
319
- const defaultBody = `## Task Details
346
+ await this.posthogAPI.appendTaskRunLog(taskId, runId, [notification]);
347
+ this.logger.debug("Notification sent to cloud task", {
348
+ taskId,
349
+ runId,
350
+ method: notification.notification.method,
351
+ });
352
+ }
353
+
354
+ async getTaskFiles(taskId: string): Promise<any[]> {
355
+ this.logger.debug("Getting task files", { taskId });
356
+ const files = await this.fileManager.getTaskFiles(taskId);
357
+ this.logger.debug("Found task files", { taskId, fileCount: files.length });
358
+ return files;
359
+ }
360
+
361
+ async createPullRequest(
362
+ taskId: string,
363
+ branchName: string,
364
+ taskTitle: string,
365
+ taskDescription: string,
366
+ customBody?: string,
367
+ ): Promise<string> {
368
+ this.logger.info("Creating pull request", {
369
+ taskId,
370
+ branchName,
371
+ taskTitle,
372
+ });
373
+
374
+ const defaultBody = `## Task Details
320
375
  **Task ID**: ${taskId}
321
376
  **Description**: ${taskDescription}
322
377
 
@@ -324,171 +379,392 @@ export class Agent {
324
379
  This PR implements the changes described in the task.
325
380
 
326
381
  Generated by PostHog Agent`;
327
- const prBody = customBody || defaultBody;
382
+ const prBody = customBody || defaultBody;
383
+
384
+ const prUrl = await this.gitManager.createPullRequest(
385
+ branchName,
386
+ taskTitle,
387
+ prBody,
388
+ );
389
+
390
+ this.logger.info("Pull request created", { taskId, prUrl });
391
+ return prUrl;
392
+ }
393
+
394
+ async attachPullRequestToTask(
395
+ taskId: string,
396
+ prUrl: string,
397
+ branchName?: string,
398
+ ): Promise<void> {
399
+ this.logger.info("Attaching PR to task run", { taskId, prUrl, branchName });
400
+
401
+ if (!this.posthogAPI || !this.currentRunId) {
402
+ const error = new Error(
403
+ "PostHog API not configured or no active run. Cannot attach PR to task.",
404
+ );
405
+ this.logger.error("PostHog API not configured", error);
406
+ throw error;
407
+ }
328
408
 
329
- const prUrl = await this.gitManager.createPullRequest(
330
- branchName,
331
- taskTitle,
332
- prBody
333
- );
409
+ const updates: any = {
410
+ output: { pr_url: prUrl },
411
+ };
412
+ if (branchName) {
413
+ updates.branch = branchName;
414
+ }
334
415
 
335
- this.logger.info('Pull request created', { taskId, prUrl });
336
- return prUrl;
416
+ await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, updates);
417
+ this.logger.debug("PR attached to task run", {
418
+ taskId,
419
+ runId: this.currentRunId,
420
+ prUrl,
421
+ });
422
+ }
423
+
424
+ async updateTaskBranch(taskId: string, branchName: string): Promise<void> {
425
+ this.logger.info("Updating task run branch", { taskId, branchName });
426
+
427
+ if (!this.posthogAPI || !this.currentRunId) {
428
+ const error = new Error(
429
+ "PostHog API not configured or no active run. Cannot update branch.",
430
+ );
431
+ this.logger.error("PostHog API not configured", error);
432
+ throw error;
337
433
  }
338
434
 
339
- async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {
340
- this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });
435
+ await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, {
436
+ branch: branchName,
437
+ });
438
+ this.logger.debug("Task run branch updated", {
439
+ taskId,
440
+ runId: this.currentRunId,
441
+ branchName,
442
+ });
443
+ }
444
+
445
+ // Execution management
446
+ cancelTask(taskId: string): void {
447
+ // Find the execution for this task and cancel it
448
+ for (const [executionId, execution] of this.taskManager.executionStates) {
449
+ if (execution.taskId === taskId && execution.status === "running") {
450
+ this.taskManager.cancelExecution(executionId);
451
+ break;
452
+ }
453
+ }
454
+ }
455
+
456
+ getTaskExecutionStatus(taskId: string): string | null {
457
+ // Find the execution for this task
458
+ for (const execution of this.taskManager.executionStates.values()) {
459
+ if (execution.taskId === taskId) {
460
+ return execution.status;
461
+ }
462
+ }
463
+ return null;
464
+ }
465
+
466
+ private async prepareTaskBranch(
467
+ taskSlug: string,
468
+ isCloudMode: boolean,
469
+ sendNotification: SendNotification,
470
+ ): Promise<void> {
471
+ if (await this.gitManager.hasChanges()) {
472
+ throw new Error(
473
+ "Cannot start task with uncommitted changes. Please commit or stash your changes first.",
474
+ );
475
+ }
341
476
 
342
- if (!this.posthogAPI || !this.progressReporter.runId) {
343
- const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');
344
- this.logger.error('PostHog API not configured', error);
345
- throw error;
346
- }
477
+ // If we're running in a worktree, we're already on the correct branch
478
+ // (the worktree was created with its own branch). Skip branch creation.
479
+ const isWorktree = await this.gitManager.isWorktree();
480
+ if (isWorktree) {
481
+ const currentBranch = await this.gitManager.getCurrentBranch();
482
+ this.logger.info("Running in worktree, using existing branch", {
483
+ branch: currentBranch,
484
+ });
485
+ await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
486
+ branch: currentBranch,
487
+ });
488
+ return;
489
+ }
347
490
 
348
- const updates: any = {
349
- output: { pr_url: prUrl }
350
- };
351
- if (branchName) {
352
- updates.branch = branchName;
353
- }
491
+ await this.gitManager.resetToDefaultBranchIfNeeded();
354
492
 
355
- await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);
356
- this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });
357
- }
493
+ const existingBranch = await this.gitManager.getTaskBranch(taskSlug);
494
+ if (!existingBranch) {
495
+ const branchName = await this.gitManager.createTaskBranch(taskSlug);
496
+ await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
497
+ branch: branchName,
498
+ });
358
499
 
359
- async updateTaskBranch(taskId: string, branchName: string): Promise<void> {
360
- this.logger.info('Updating task run branch', { taskId, branchName });
500
+ await this.gitManager.addAllPostHogFiles();
361
501
 
362
- if (!this.posthogAPI || !this.progressReporter.runId) {
363
- const error = new Error('PostHog API not configured or no active run. Cannot update branch.');
364
- this.logger.error('PostHog API not configured', error);
365
- throw error;
502
+ // Only commit if there are changes or we're in cloud mode
503
+ if (isCloudMode) {
504
+ await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, {
505
+ allowEmpty: true,
506
+ });
507
+ } else {
508
+ // Check if there are any changes before committing
509
+ const hasChanges = await this.gitManager.hasStagedChanges();
510
+ if (hasChanges) {
511
+ await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);
366
512
  }
367
-
368
- await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });
369
- this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, branchName });
513
+ }
514
+ } else {
515
+ this.logger.info("Switching to existing task branch", {
516
+ branch: existingBranch,
517
+ });
518
+ await this.gitManager.switchToBranch(existingBranch);
370
519
  }
520
+ }
371
521
 
372
- // Execution management
373
- cancelTask(taskId: string): void {
374
- // Find the execution for this task and cancel it
375
- for (const [executionId, execution] of this.taskManager['executionStates']) {
376
- if (execution.taskId === taskId && execution.status === 'running') {
377
- this.taskManager.cancelExecution(executionId);
378
- break;
379
- }
380
- }
522
+ private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {
523
+ const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;
524
+ const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;
525
+
526
+ if (resolvedGatewayUrl) {
527
+ process.env.OPENAI_BASE_URL = resolvedGatewayUrl;
381
528
  }
382
529
 
383
- getTaskExecutionStatus(taskId: string): string | null {
384
- // Find the execution for this task
385
- for (const execution of this.taskManager['executionStates'].values()) {
386
- if (execution.taskId === taskId) {
387
- return execution.status;
388
- }
389
- }
390
- return null;
530
+ if (resolvedToken) {
531
+ process.env.OPENAI_API_KEY = resolvedToken;
532
+ }
533
+ }
534
+
535
+ async runTaskCloud(
536
+ taskId: string,
537
+ taskRunId: string,
538
+ options: TaskExecutionOptions = {},
539
+ ): Promise<void> {
540
+ await this._configureLlmGateway();
541
+
542
+ const task = await this.fetchTask(taskId);
543
+ const cwd = options.repositoryPath || this.workingDirectory;
544
+ const taskSlug = (task as any).slug || task.id;
545
+
546
+ this.currentRunId = taskRunId;
547
+
548
+ this.logger.info("Starting cloud task execution", {
549
+ taskId: task.id,
550
+ taskSlug,
551
+ taskRunId,
552
+ cwd,
553
+ });
554
+
555
+ if (!this.sessionStore) {
556
+ throw new Error(
557
+ "SessionStore required for cloud mode. Ensure PostHog API credentials are configured.",
558
+ );
391
559
  }
392
560
 
393
- private async prepareTaskBranch(taskSlug: string, isCloudMode: boolean): Promise<void> {
394
- if (await this.gitManager.hasChanges()) {
395
- throw new Error('Cannot start task with uncommitted changes. Please commit or stash your changes first.');
396
- }
561
+ // Start session in SessionStore (updates task run status to in_progress)
562
+ const taskRun = await this.sessionStore.start(taskRunId, taskId, taskRunId);
563
+ this.logger.debug("Session started", {
564
+ taskRunId,
565
+ logUrl: taskRun?.log_url,
566
+ });
567
+
568
+ // Create internal ACP connection with S3 persistence
569
+ const acpConnection = createAcpConnection({
570
+ sessionStore: this.sessionStore,
571
+ sessionId: taskRunId,
572
+ taskId: task.id,
573
+ });
574
+
575
+ // Create client connection using the client-side streams
576
+ const clientStream = ndJsonStream(
577
+ acpConnection.clientStreams.writable as WritableStream<Uint8Array>,
578
+ acpConnection.clientStreams.readable as ReadableStream<Uint8Array>,
579
+ );
580
+
581
+ // Create auto-approving client for headless cloud mode
582
+ const cloudClient: Client = {
583
+ async requestPermission(params) {
584
+ const allowOption = params.options.find(
585
+ (o) => o.kind === "allow_once" || o.kind === "allow_always",
586
+ );
587
+ return {
588
+ outcome: {
589
+ outcome: "selected",
590
+ optionId: allowOption?.optionId ?? params.options[0].optionId,
591
+ },
592
+ };
593
+ },
594
+ async sessionUpdate(_params) {
595
+ // Notifications are already being persisted to S3 via tapped streams
596
+ },
597
+ };
598
+
599
+ const clientConnection = new ClientSideConnection(
600
+ (_agent) => cloudClient,
601
+ clientStream,
602
+ );
603
+
604
+ try {
605
+ // Initialize the connection
606
+ await clientConnection.initialize({
607
+ protocolVersion: PROTOCOL_VERSION,
608
+ clientCapabilities: {},
609
+ });
610
+
611
+ // Create new session
612
+ await clientConnection.newSession({
613
+ cwd,
614
+ mcpServers: [],
615
+ _meta: { sessionId: taskRunId },
616
+ });
617
+
618
+ // Prepare git branch if not skipped
619
+ if (!options.skipGitBranch) {
620
+ const sendNotification: SendNotification = async (method, params) => {
621
+ this.logger.debug(`Notification: ${method}`, params);
622
+ await acpConnection.agentConnection.extNotification?.(method, params);
623
+ };
624
+ await this.prepareTaskBranch(taskSlug, true, sendNotification);
625
+ }
626
+
627
+ // Build initial prompt from task description
628
+ const initialPrompt: ContentBlock[] = [
629
+ {
630
+ type: "text",
631
+ text: `# Task: ${task.title}\n\n${task.description}`,
632
+ },
633
+ ];
634
+
635
+ // Track the last known log entry count for interrupt polling
636
+ let lastKnownEntryCount = 0;
637
+ let isPolling = true;
638
+
639
+ // Start interrupt polling in background
640
+ const pollForInterrupts = async () => {
641
+ while (isPolling) {
642
+ await new Promise((resolve) => setTimeout(resolve, 2000)); // Poll every 2 seconds
643
+ if (!isPolling) break;
644
+
645
+ try {
646
+ const newEntries = await this.sessionStore!.pollForNewEntries(
647
+ taskRunId,
648
+ lastKnownEntryCount,
649
+ );
397
650
 
398
- await this.gitManager.resetToDefaultBranchIfNeeded();
399
-
400
- const existingBranch = await this.gitManager.getTaskBranch(taskSlug);
401
- if (!existingBranch) {
402
- const branchName = await this.gitManager.createTaskBranch(taskSlug);
403
- this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));
404
-
405
- await this.gitManager.addAllPostHogFiles();
406
-
407
- // Only commit if there are changes or we're in cloud mode
408
- if (isCloudMode) {
409
- await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });
410
- } else {
411
- // Check if there are any changes before committing
412
- const hasChanges = await this.gitManager.hasStagedChanges();
413
- if (hasChanges) {
414
- await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);
651
+ for (const entry of newEntries) {
652
+ lastKnownEntryCount++;
653
+ // Look for user_message notifications
654
+ if (
655
+ entry.notification?.method === "sessionUpdate" &&
656
+ (entry.notification?.params as any)?.sessionUpdate ===
657
+ "user_message"
658
+ ) {
659
+ const content = (entry.notification?.params as any)?.content;
660
+ if (content) {
661
+ this.logger.info("Processing user interrupt", { content });
662
+ // Send as new prompt - will be processed after current prompt completes
663
+ await clientConnection.prompt({
664
+ sessionId: taskRunId,
665
+ prompt: Array.isArray(content) ? content : [content],
666
+ });
415
667
  }
668
+ }
416
669
  }
417
- } else {
418
- this.logger.info('Switching to existing task branch', { branch: existingBranch });
419
- await this.gitManager.switchToBranch(existingBranch);
670
+ } catch (err) {
671
+ this.logger.warn("Interrupt polling error", { error: err });
672
+ }
420
673
  }
674
+ };
675
+
676
+ // Start polling in background (don't await)
677
+ const pollingPromise = pollForInterrupts();
678
+
679
+ // Send initial prompt and wait for completion
680
+ this.logger.info("Sending initial prompt to agent");
681
+ const result = await clientConnection.prompt({
682
+ sessionId: taskRunId,
683
+ prompt: initialPrompt,
684
+ });
685
+
686
+ // Stop interrupt polling
687
+ isPolling = false;
688
+ await pollingPromise;
689
+
690
+ this.logger.info("Task execution complete", {
691
+ taskId: task.id,
692
+ stopReason: result.stopReason,
693
+ });
694
+
695
+ await this.sessionStore.complete(taskRunId);
696
+ } catch (error) {
697
+ const errorMessage =
698
+ error instanceof Error ? error.message : String(error);
699
+ this.logger.error("Cloud task execution failed", {
700
+ taskId: task.id,
701
+ error: errorMessage,
702
+ });
703
+ await this.sessionStore.fail(taskRunId, errorMessage);
704
+ throw error;
421
705
  }
422
-
423
- private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {
424
- const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;
425
- const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;
426
-
427
- if (resolvedGatewayUrl) {
428
- process.env.OPENAI_BASE_URL = resolvedGatewayUrl;
429
- }
430
-
431
- if (resolvedToken) {
432
- process.env.OPENAI_API_KEY = resolvedToken;
433
- }
706
+ }
707
+
708
+ private async ensurePullRequest(
709
+ task: Task,
710
+ stepResults: Record<string, any>,
711
+ sendNotification: SendNotification,
712
+ ): Promise<void> {
713
+ const latestRun = task.latest_run;
714
+ const existingPr =
715
+ latestRun?.output && typeof latestRun.output === "object"
716
+ ? (latestRun.output as any).pr_url
717
+ : null;
718
+
719
+ if (existingPr) {
720
+ this.logger.info("PR already exists, skipping creation", {
721
+ taskId: task.id,
722
+ prUrl: existingPr,
723
+ });
724
+ return;
434
725
  }
435
726
 
436
- private async ensurePullRequest(task: Task, stepResults: Record<string, any>): Promise<void> {
437
- const latestRun = task.latest_run;
438
- const existingPr =
439
- latestRun?.output && typeof latestRun.output === 'object'
440
- ? (latestRun.output as any).pr_url
441
- : null;
442
-
443
- if (existingPr) {
444
- this.logger.info('PR already exists, skipping creation', { taskId: task.id, prUrl: existingPr });
445
- return;
446
- }
447
-
448
- const buildResult = stepResults['build'];
449
- if (!buildResult?.commitCreated) {
450
- this.logger.warn('Build step did not produce a commit; skipping PR creation', { taskId: task.id });
451
- return;
452
- }
453
-
454
- const branchName = await this.gitManager.getCurrentBranch();
455
- const finalizeResult = stepResults['finalize'];
456
- const prBody = finalizeResult?.prBody;
457
-
458
- const prUrl = await this.createPullRequest(
459
- task.id,
460
- branchName,
461
- task.title,
462
- task.description ?? '',
463
- prBody
464
- );
465
-
466
- this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));
467
-
468
- try {
469
- await this.attachPullRequestToTask(task.id, prUrl, branchName);
470
- this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });
471
- } catch (error) {
472
- this.logger.warn('Could not attach PR to task', {
473
- error: error instanceof Error ? error.message : String(error),
474
- });
475
- }
727
+ const buildResult = stepResults.build;
728
+ if (!buildResult?.commitCreated) {
729
+ this.logger.warn(
730
+ "Build step did not produce a commit; skipping PR creation",
731
+ { taskId: task.id },
732
+ );
733
+ return;
476
734
  }
477
735
 
478
- private emitEvent(event: any): void {
479
- if (this.debug && event.type !== 'token') {
480
- // Log all events except tokens (too verbose)
481
- this.logger.debug('Emitting event', { type: event.type, ts: event.ts });
482
- }
483
- const persistPromise = this.progressReporter.recordEvent(event);
484
- if (persistPromise && typeof persistPromise.then === 'function') {
485
- persistPromise.catch((error: Error) =>
486
- this.logger.debug('Failed to persist agent event', { message: error.message })
487
- );
488
- }
489
- this.onEvent?.(event);
736
+ const branchName = await this.gitManager.getCurrentBranch();
737
+ const finalizeResult = stepResults.finalize;
738
+ const prBody = finalizeResult?.prBody;
739
+
740
+ const prUrl = await this.createPullRequest(
741
+ task.id,
742
+ branchName,
743
+ task.title,
744
+ task.description ?? "",
745
+ prBody,
746
+ );
747
+
748
+ await sendNotification(POSTHOG_NOTIFICATIONS.PR_CREATED, { prUrl });
749
+
750
+ try {
751
+ await this.attachPullRequestToTask(task.id, prUrl, branchName);
752
+ this.logger.info("PR attached to task successfully", {
753
+ taskId: task.id,
754
+ prUrl,
755
+ });
756
+ } catch (error) {
757
+ this.logger.warn("Could not attach PR to task", {
758
+ error: error instanceof Error ? error.message : String(error),
759
+ });
490
760
  }
761
+ }
491
762
  }
492
763
 
493
- export { PermissionMode } from './types.js';
494
- export type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';
764
+ export type {
765
+ AgentConfig,
766
+ ExecutionResult,
767
+ SupportingFile,
768
+ Task,
769
+ } from "./types.js";
770
+ export { PermissionMode } from "./types.js";