@posthog/agent 1.24.2 → 1.25.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 (604) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +6 -0
  2. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  3. package/dist/_virtual/additionalItems.js +4 -0
  4. package/dist/_virtual/additionalItems.js.map +1 -0
  5. package/dist/_virtual/additionalProperties.js +4 -0
  6. package/dist/_virtual/additionalProperties.js.map +1 -0
  7. package/dist/_virtual/ajv.js +4 -0
  8. package/dist/_virtual/ajv.js.map +1 -0
  9. package/dist/_virtual/allOf.js +4 -0
  10. package/dist/_virtual/allOf.js.map +1 -0
  11. package/dist/_virtual/anyOf.js +4 -0
  12. package/dist/_virtual/anyOf.js.map +1 -0
  13. package/dist/_virtual/applicability.js +4 -0
  14. package/dist/_virtual/applicability.js.map +1 -0
  15. package/dist/_virtual/boolSchema.js +4 -0
  16. package/dist/_virtual/boolSchema.js.map +1 -0
  17. package/dist/_virtual/code.js +4 -0
  18. package/dist/_virtual/code.js.map +1 -0
  19. package/dist/_virtual/code2.js +4 -0
  20. package/dist/_virtual/code2.js.map +1 -0
  21. package/dist/_virtual/const.js +4 -0
  22. package/dist/_virtual/const.js.map +1 -0
  23. package/dist/_virtual/contains.js +4 -0
  24. package/dist/_virtual/contains.js.map +1 -0
  25. package/dist/_virtual/core.js +4 -0
  26. package/dist/_virtual/core.js.map +1 -0
  27. package/dist/_virtual/dataType.js +4 -0
  28. package/dist/_virtual/dataType.js.map +1 -0
  29. package/dist/_virtual/defaults.js +4 -0
  30. package/dist/_virtual/defaults.js.map +1 -0
  31. package/dist/_virtual/dependencies.js +4 -0
  32. package/dist/_virtual/dependencies.js.map +1 -0
  33. package/dist/_virtual/draft7.js +4 -0
  34. package/dist/_virtual/draft7.js.map +1 -0
  35. package/dist/_virtual/enum.js +4 -0
  36. package/dist/_virtual/enum.js.map +1 -0
  37. package/dist/_virtual/equal.js +4 -0
  38. package/dist/_virtual/equal.js.map +1 -0
  39. package/dist/_virtual/errors.js +4 -0
  40. package/dist/_virtual/errors.js.map +1 -0
  41. package/dist/_virtual/format.js +4 -0
  42. package/dist/_virtual/format.js.map +1 -0
  43. package/dist/_virtual/formats.js +4 -0
  44. package/dist/_virtual/formats.js.map +1 -0
  45. package/dist/_virtual/id.js +4 -0
  46. package/dist/_virtual/id.js.map +1 -0
  47. package/dist/_virtual/if.js +4 -0
  48. package/dist/_virtual/if.js.map +1 -0
  49. package/dist/_virtual/index.js +4 -0
  50. package/dist/_virtual/index.js.map +1 -0
  51. package/dist/_virtual/index10.js +4 -0
  52. package/dist/_virtual/index10.js.map +1 -0
  53. package/dist/_virtual/index11.js +4 -0
  54. package/dist/_virtual/index11.js.map +1 -0
  55. package/dist/_virtual/index2.js +4 -0
  56. package/dist/_virtual/index2.js.map +1 -0
  57. package/dist/_virtual/index3.js +4 -0
  58. package/dist/_virtual/index3.js.map +1 -0
  59. package/dist/_virtual/index4.js +4 -0
  60. package/dist/_virtual/index4.js.map +1 -0
  61. package/dist/_virtual/index5.js +4 -0
  62. package/dist/_virtual/index5.js.map +1 -0
  63. package/dist/_virtual/index6.js +4 -0
  64. package/dist/_virtual/index6.js.map +1 -0
  65. package/dist/_virtual/index7.js +4 -0
  66. package/dist/_virtual/index7.js.map +1 -0
  67. package/dist/_virtual/index8.js +4 -0
  68. package/dist/_virtual/index8.js.map +1 -0
  69. package/dist/_virtual/index9.js +4 -0
  70. package/dist/_virtual/index9.js.map +1 -0
  71. package/dist/_virtual/items.js +4 -0
  72. package/dist/_virtual/items.js.map +1 -0
  73. package/dist/_virtual/items2020.js +4 -0
  74. package/dist/_virtual/items2020.js.map +1 -0
  75. package/dist/_virtual/keyword.js +4 -0
  76. package/dist/_virtual/keyword.js.map +1 -0
  77. package/dist/_virtual/limit.js +4 -0
  78. package/dist/_virtual/limit.js.map +1 -0
  79. package/dist/_virtual/limitItems.js +4 -0
  80. package/dist/_virtual/limitItems.js.map +1 -0
  81. package/dist/_virtual/limitLength.js +4 -0
  82. package/dist/_virtual/limitLength.js.map +1 -0
  83. package/dist/_virtual/limitNumber.js +4 -0
  84. package/dist/_virtual/limitNumber.js.map +1 -0
  85. package/dist/_virtual/limitProperties.js +4 -0
  86. package/dist/_virtual/limitProperties.js.map +1 -0
  87. package/dist/_virtual/metadata.js +4 -0
  88. package/dist/_virtual/metadata.js.map +1 -0
  89. package/dist/_virtual/multipleOf.js +4 -0
  90. package/dist/_virtual/multipleOf.js.map +1 -0
  91. package/dist/_virtual/names.js +4 -0
  92. package/dist/_virtual/names.js.map +1 -0
  93. package/dist/_virtual/not.js +4 -0
  94. package/dist/_virtual/not.js.map +1 -0
  95. package/dist/_virtual/oneOf.js +4 -0
  96. package/dist/_virtual/oneOf.js.map +1 -0
  97. package/dist/_virtual/pattern.js +4 -0
  98. package/dist/_virtual/pattern.js.map +1 -0
  99. package/dist/_virtual/patternProperties.js +4 -0
  100. package/dist/_virtual/patternProperties.js.map +1 -0
  101. package/dist/_virtual/prefixItems.js +4 -0
  102. package/dist/_virtual/prefixItems.js.map +1 -0
  103. package/dist/_virtual/properties.js +4 -0
  104. package/dist/_virtual/properties.js.map +1 -0
  105. package/dist/_virtual/propertyNames.js +4 -0
  106. package/dist/_virtual/propertyNames.js.map +1 -0
  107. package/dist/_virtual/ref.js +4 -0
  108. package/dist/_virtual/ref.js.map +1 -0
  109. package/dist/_virtual/ref_error.js +4 -0
  110. package/dist/_virtual/ref_error.js.map +1 -0
  111. package/dist/_virtual/required.js +4 -0
  112. package/dist/_virtual/required.js.map +1 -0
  113. package/dist/_virtual/resolve.js +4 -0
  114. package/dist/_virtual/resolve.js.map +1 -0
  115. package/dist/_virtual/rules.js +4 -0
  116. package/dist/_virtual/rules.js.map +1 -0
  117. package/dist/_virtual/scope.js +4 -0
  118. package/dist/_virtual/scope.js.map +1 -0
  119. package/dist/_virtual/subschema.js +4 -0
  120. package/dist/_virtual/subschema.js.map +1 -0
  121. package/dist/_virtual/thenElse.js +4 -0
  122. package/dist/_virtual/thenElse.js.map +1 -0
  123. package/dist/_virtual/types.js +4 -0
  124. package/dist/_virtual/types.js.map +1 -0
  125. package/dist/_virtual/ucs2length.js +4 -0
  126. package/dist/_virtual/ucs2length.js.map +1 -0
  127. package/dist/_virtual/uniqueItems.js +4 -0
  128. package/dist/_virtual/uniqueItems.js.map +1 -0
  129. package/dist/_virtual/uri.js +4 -0
  130. package/dist/_virtual/uri.js.map +1 -0
  131. package/dist/_virtual/util.js +4 -0
  132. package/dist/_virtual/util.js.map +1 -0
  133. package/dist/_virtual/validation_error.js +4 -0
  134. package/dist/_virtual/validation_error.js.map +1 -0
  135. package/dist/claude-cli/cli.js +2294 -2146
  136. package/dist/example-client.d.ts +3 -0
  137. package/dist/example-client.d.ts.map +1 -0
  138. package/dist/index.d.ts +19 -11
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.js +7 -3
  141. package/dist/index.js.map +1 -1
  142. package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +610 -0
  143. package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
  144. package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +875 -0
  145. package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +1 -0
  146. package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +66 -0
  147. package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
  148. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +23 -0
  149. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
  150. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +331 -0
  151. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
  152. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +717 -0
  153. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
  154. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +221 -0
  155. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
  156. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +56 -0
  157. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
  158. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +440 -0
  159. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
  160. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +94 -0
  161. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
  162. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1610 -0
  163. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
  164. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +91 -0
  165. package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
  166. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +133 -0
  167. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +1 -0
  168. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +9 -0
  169. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +1 -0
  170. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +9 -0
  171. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
  172. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +112 -0
  173. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
  174. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +136 -0
  175. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +1 -0
  176. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +112 -0
  177. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +1 -0
  178. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +3297 -0
  179. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +1 -0
  180. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +44 -0
  181. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +1 -0
  182. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +36 -0
  183. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +1 -0
  184. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +10 -0
  185. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +1 -0
  186. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +657 -0
  187. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +1 -0
  188. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +449 -0
  189. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +1 -0
  190. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +413 -0
  191. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +1 -0
  192. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +57 -0
  193. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +1 -0
  194. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +38 -0
  195. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +1 -0
  196. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +86 -0
  197. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +1 -0
  198. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +61 -0
  199. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +1 -0
  200. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +80 -0
  201. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +1 -0
  202. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +52 -0
  203. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +1 -0
  204. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +1307 -0
  205. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +1 -0
  206. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +842 -0
  207. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
  208. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +335 -0
  209. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +1 -0
  210. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +8 -0
  211. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +1 -0
  212. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +51 -0
  213. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +1 -0
  214. package/dist/node_modules/ajv/dist/ajv.js +69 -0
  215. package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
  216. package/dist/node_modules/ajv/dist/compile/codegen/code.js +169 -0
  217. package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
  218. package/dist/node_modules/ajv/dist/compile/codegen/index.js +712 -0
  219. package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
  220. package/dist/node_modules/ajv/dist/compile/codegen/scope.js +157 -0
  221. package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
  222. package/dist/node_modules/ajv/dist/compile/errors.js +140 -0
  223. package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
  224. package/dist/node_modules/ajv/dist/compile/index.js +253 -0
  225. package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
  226. package/dist/node_modules/ajv/dist/compile/names.js +40 -0
  227. package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
  228. package/dist/node_modules/ajv/dist/compile/ref_error.js +25 -0
  229. package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
  230. package/dist/node_modules/ajv/dist/compile/resolve.js +162 -0
  231. package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
  232. package/dist/node_modules/ajv/dist/compile/rules.js +29 -0
  233. package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
  234. package/dist/node_modules/ajv/dist/compile/util.js +183 -0
  235. package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
  236. package/dist/node_modules/ajv/dist/compile/validate/applicability.js +30 -0
  237. package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
  238. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +64 -0
  239. package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
  240. package/dist/node_modules/ajv/dist/compile/validate/dataType.js +213 -0
  241. package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
  242. package/dist/node_modules/ajv/dist/compile/validate/defaults.js +49 -0
  243. package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
  244. package/dist/node_modules/ajv/dist/compile/validate/index.js +544 -0
  245. package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
  246. package/dist/node_modules/ajv/dist/compile/validate/keyword.js +139 -0
  247. package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
  248. package/dist/node_modules/ajv/dist/compile/validate/subschema.js +95 -0
  249. package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
  250. package/dist/node_modules/ajv/dist/core.js +639 -0
  251. package/dist/node_modules/ajv/dist/core.js.map +1 -0
  252. package/dist/node_modules/ajv/dist/refs/data.json.js +31 -0
  253. package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
  254. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +254 -0
  255. package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
  256. package/dist/node_modules/ajv/dist/runtime/equal.js +9 -0
  257. package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
  258. package/dist/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
  259. package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
  260. package/dist/node_modules/ajv/dist/runtime/uri.js +8 -0
  261. package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
  262. package/dist/node_modules/ajv/dist/runtime/validation_error.js +22 -0
  263. package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
  264. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +53 -0
  265. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
  266. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +112 -0
  267. package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
  268. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +26 -0
  269. package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
  270. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +14 -0
  271. package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
  272. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +99 -0
  273. package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
  274. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +93 -0
  275. package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
  276. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +70 -0
  277. package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
  278. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +77 -0
  279. package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
  280. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +57 -0
  281. package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
  282. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +37 -0
  283. package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
  284. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +29 -0
  285. package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
  286. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
  287. package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
  288. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +80 -0
  289. package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
  290. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +15 -0
  291. package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
  292. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -0
  293. package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
  294. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +42 -0
  295. package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
  296. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +16 -0
  297. package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
  298. package/dist/node_modules/ajv/dist/vocabularies/code.js +146 -0
  299. package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
  300. package/dist/node_modules/ajv/dist/vocabularies/core/id.js +11 -0
  301. package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
  302. package/dist/node_modules/ajv/dist/vocabularies/core/index.js +21 -0
  303. package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
  304. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +131 -0
  305. package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
  306. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +113 -0
  307. package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
  308. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +12 -0
  309. package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
  310. package/dist/node_modules/ajv/dist/vocabularies/draft7.js +28 -0
  311. package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
  312. package/dist/node_modules/ajv/dist/vocabularies/format/format.js +94 -0
  313. package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
  314. package/dist/node_modules/ajv/dist/vocabularies/format/index.js +9 -0
  315. package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
  316. package/dist/node_modules/ajv/dist/vocabularies/metadata.js +21 -0
  317. package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
  318. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +31 -0
  319. package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
  320. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
  321. package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
  322. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +54 -0
  323. package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
  324. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +26 -0
  325. package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
  326. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
  327. package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
  328. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +29 -0
  329. package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
  330. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +26 -0
  331. package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
  332. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +28 -0
  333. package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
  334. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +27 -0
  335. package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
  336. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +84 -0
  337. package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
  338. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +72 -0
  339. package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
  340. package/dist/node_modules/ajv-formats/dist/formats.js +212 -0
  341. package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
  342. package/dist/node_modules/ajv-formats/dist/index.js +52 -0
  343. package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
  344. package/dist/node_modules/ajv-formats/dist/limit.js +75 -0
  345. package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
  346. package/dist/node_modules/diff/libesm/diff/base.js +256 -0
  347. package/dist/node_modules/diff/libesm/diff/base.js.map +1 -0
  348. package/dist/node_modules/diff/libesm/diff/line.js +64 -0
  349. package/dist/node_modules/diff/libesm/diff/line.js.map +1 -0
  350. package/dist/node_modules/diff/libesm/patch/create.js +185 -0
  351. package/dist/node_modules/diff/libesm/patch/create.js.map +1 -0
  352. package/dist/node_modules/fast-deep-equal/index.js +47 -0
  353. package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
  354. package/dist/node_modules/fast-uri/index.js +347 -0
  355. package/dist/node_modules/fast-uri/index.js.map +1 -0
  356. package/dist/node_modules/fast-uri/lib/schemes.js +255 -0
  357. package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
  358. package/dist/node_modules/fast-uri/lib/utils.js +334 -0
  359. package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
  360. package/dist/node_modules/json-schema-traverse/index.js +98 -0
  361. package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
  362. package/dist/node_modules/uuid/dist/rng.js +14 -0
  363. package/dist/node_modules/uuid/dist/rng.js.map +1 -0
  364. package/dist/node_modules/uuid/dist/stringify.js +29 -0
  365. package/dist/node_modules/uuid/dist/stringify.js.map +1 -0
  366. package/dist/node_modules/uuid/dist/v7.js +65 -0
  367. package/dist/node_modules/uuid/dist/v7.js.map +1 -0
  368. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
  369. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
  370. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
  371. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
  372. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
  373. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
  374. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
  375. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
  376. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
  377. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
  378. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
  379. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
  380. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
  381. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
  382. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
  383. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
  384. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
  385. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
  386. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
  387. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
  388. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
  389. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
  390. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
  391. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
  392. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
  393. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
  394. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
  395. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
  396. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
  397. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
  398. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
  399. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
  400. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
  401. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
  402. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
  403. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
  404. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
  405. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
  406. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
  407. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
  408. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
  409. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
  410. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
  411. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
  412. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
  413. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
  414. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
  415. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
  416. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
  417. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
  418. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
  419. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
  420. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
  421. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
  422. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
  423. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
  424. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
  425. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
  426. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
  427. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
  428. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
  429. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
  430. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
  431. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
  432. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
  433. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
  434. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
  435. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
  436. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
  437. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
  438. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +109 -0
  439. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
  440. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
  441. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
  442. package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +42 -0
  443. package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +1 -0
  444. package/dist/package.json.js +8 -0
  445. package/dist/package.json.js.map +1 -0
  446. package/dist/src/acp-extensions.d.ts +91 -0
  447. package/dist/src/acp-extensions.d.ts.map +1 -0
  448. package/dist/src/acp-extensions.js +38 -0
  449. package/dist/src/acp-extensions.js.map +1 -0
  450. package/dist/src/adapters/claude/claude.d.ts +136 -0
  451. package/dist/src/adapters/claude/claude.d.ts.map +1 -0
  452. package/dist/src/adapters/claude/claude.js +1112 -0
  453. package/dist/src/adapters/claude/claude.js.map +1 -0
  454. package/dist/src/adapters/claude/mcp-server.d.ts +30 -0
  455. package/dist/src/adapters/claude/mcp-server.d.ts.map +1 -0
  456. package/dist/src/adapters/claude/mcp-server.js +655 -0
  457. package/dist/src/adapters/claude/mcp-server.js.map +1 -0
  458. package/dist/src/adapters/claude/tools.d.ts +35 -0
  459. package/dist/src/adapters/claude/tools.d.ts.map +1 -0
  460. package/dist/src/adapters/claude/tools.js +466 -0
  461. package/dist/src/adapters/claude/tools.js.map +1 -0
  462. package/dist/src/adapters/claude/utils.d.ts +48 -0
  463. package/dist/src/adapters/claude/utils.d.ts.map +1 -0
  464. package/dist/src/adapters/claude/utils.js +158 -0
  465. package/dist/src/adapters/claude/utils.js.map +1 -0
  466. package/dist/src/agent.d.ts +18 -28
  467. package/dist/src/agent.d.ts.map +1 -1
  468. package/dist/src/agent.js +195 -175
  469. package/dist/src/agent.js.map +1 -1
  470. package/dist/src/agents/execution.js.map +1 -1
  471. package/dist/src/agents/planning.js.map +1 -1
  472. package/dist/src/agents/research.js.map +1 -1
  473. package/dist/src/file-manager.d.ts +6 -6
  474. package/dist/src/file-manager.d.ts.map +1 -1
  475. package/dist/src/file-manager.js +72 -63
  476. package/dist/src/file-manager.js.map +1 -1
  477. package/dist/src/git-manager.d.ts +2 -1
  478. package/dist/src/git-manager.d.ts.map +1 -1
  479. package/dist/src/git-manager.js +105 -70
  480. package/dist/src/git-manager.js.map +1 -1
  481. package/dist/src/posthog-api.d.ts +8 -14
  482. package/dist/src/posthog-api.d.ts.map +1 -1
  483. package/dist/src/posthog-api.js +35 -23
  484. package/dist/src/posthog-api.js.map +1 -1
  485. package/dist/src/prompt-builder.d.ts +4 -4
  486. package/dist/src/prompt-builder.d.ts.map +1 -1
  487. package/dist/src/prompt-builder.js +129 -99
  488. package/dist/src/prompt-builder.js.map +1 -1
  489. package/dist/src/schemas.d.ts +980 -0
  490. package/dist/src/schemas.d.ts.map +1 -0
  491. package/dist/src/schemas.js +196 -0
  492. package/dist/src/schemas.js.map +1 -0
  493. package/dist/src/session-store.d.ts +53 -0
  494. package/dist/src/session-store.d.ts.map +1 -0
  495. package/dist/src/session-store.js +195 -0
  496. package/dist/src/session-store.js.map +1 -0
  497. package/dist/src/task-manager.d.ts +7 -7
  498. package/dist/src/task-manager.d.ts.map +1 -1
  499. package/dist/src/task-manager.js +19 -18
  500. package/dist/src/task-manager.js.map +1 -1
  501. package/dist/src/template-manager.d.ts +1 -1
  502. package/dist/src/template-manager.d.ts.map +1 -1
  503. package/dist/src/template-manager.js +30 -28
  504. package/dist/src/template-manager.js.map +1 -1
  505. package/dist/src/todo-manager.d.ts +5 -5
  506. package/dist/src/todo-manager.d.ts.map +1 -1
  507. package/dist/src/todo-manager.js +33 -24
  508. package/dist/src/todo-manager.js.map +1 -1
  509. package/dist/src/tools/registry.d.ts +1 -1
  510. package/dist/src/tools/registry.js +60 -60
  511. package/dist/src/tools/registry.js.map +1 -1
  512. package/dist/src/tools/types.d.ts +31 -31
  513. package/dist/src/types.d.ts +62 -167
  514. package/dist/src/types.d.ts.map +1 -1
  515. package/dist/src/types.js +1 -0
  516. package/dist/src/types.js.map +1 -1
  517. package/dist/src/utils/logger.d.ts +14 -6
  518. package/dist/src/utils/logger.d.ts.map +1 -1
  519. package/dist/src/utils/logger.js +37 -22
  520. package/dist/src/utils/logger.js.map +1 -1
  521. package/dist/src/utils/tapped-stream.d.ts +17 -0
  522. package/dist/src/utils/tapped-stream.d.ts.map +1 -0
  523. package/dist/src/utils/tapped-stream.js +45 -0
  524. package/dist/src/utils/tapped-stream.js.map +1 -0
  525. package/dist/src/workflow/config.d.ts +1 -1
  526. package/dist/src/workflow/config.d.ts.map +1 -1
  527. package/dist/src/workflow/config.js +18 -18
  528. package/dist/src/workflow/config.js.map +1 -1
  529. package/dist/src/workflow/steps/build.d.ts +1 -1
  530. package/dist/src/workflow/steps/build.d.ts.map +1 -1
  531. package/dist/src/workflow/steps/build.js +53 -39
  532. package/dist/src/workflow/steps/build.js.map +1 -1
  533. package/dist/src/workflow/steps/finalize.d.ts +1 -1
  534. package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
  535. package/dist/src/workflow/steps/finalize.js +58 -52
  536. package/dist/src/workflow/steps/finalize.js.map +1 -1
  537. package/dist/src/workflow/steps/plan.d.ts +1 -1
  538. package/dist/src/workflow/steps/plan.d.ts.map +1 -1
  539. package/dist/src/workflow/steps/plan.js +69 -47
  540. package/dist/src/workflow/steps/plan.js.map +1 -1
  541. package/dist/src/workflow/steps/research.d.ts +1 -1
  542. package/dist/src/workflow/steps/research.d.ts.map +1 -1
  543. package/dist/src/workflow/steps/research.js +86 -67
  544. package/dist/src/workflow/steps/research.js.map +1 -1
  545. package/dist/src/workflow/types.d.ts +19 -14
  546. package/dist/src/workflow/types.d.ts.map +1 -1
  547. package/dist/src/workflow/utils.d.ts +1 -1
  548. package/dist/src/workflow/utils.d.ts.map +1 -1
  549. package/dist/src/workflow/utils.js +7 -4
  550. package/dist/src/workflow/utils.js.map +1 -1
  551. package/dist/src/worktree-manager.d.ts +39 -0
  552. package/dist/src/worktree-manager.d.ts.map +1 -0
  553. package/dist/src/worktree-manager.js +810 -0
  554. package/dist/src/worktree-manager.js.map +1 -0
  555. package/package.json +20 -16
  556. package/src/acp-extensions.ts +117 -0
  557. package/src/adapters/claude/claude.ts +1498 -0
  558. package/src/adapters/claude/mcp-server.ts +810 -0
  559. package/src/adapters/claude/tools.ts +609 -0
  560. package/src/adapters/claude/utils.ts +267 -0
  561. package/src/agent.ts +511 -447
  562. package/src/agents/execution.ts +1 -1
  563. package/src/agents/planning.ts +1 -1
  564. package/src/agents/research.ts +0 -1
  565. package/src/file-manager.ts +80 -70
  566. package/src/git-manager.ts +164 -88
  567. package/src/posthog-api.ts +155 -94
  568. package/src/prompt-builder.ts +196 -143
  569. package/src/schemas.ts +241 -0
  570. package/src/session-store.ts +244 -0
  571. package/src/task-manager.ts +41 -33
  572. package/src/template-manager.ts +98 -45
  573. package/src/todo-manager.ts +43 -32
  574. package/src/tools/registry.ts +62 -62
  575. package/src/tools/types.ts +36 -36
  576. package/src/types.ts +130 -239
  577. package/src/utils/logger.ts +89 -58
  578. package/src/utils/tapped-stream.ts +60 -0
  579. package/src/workflow/config.ts +48 -48
  580. package/src/workflow/steps/build.ts +127 -113
  581. package/src/workflow/steps/finalize.ts +207 -182
  582. package/src/workflow/steps/plan.ts +155 -130
  583. package/src/workflow/steps/research.ts +207 -187
  584. package/src/workflow/types.ts +47 -36
  585. package/src/workflow/utils.ts +37 -34
  586. package/src/worktree-manager.ts +884 -0
  587. package/dist/src/adapters/claude/claude-adapter.d.ts +0 -18
  588. package/dist/src/adapters/claude/claude-adapter.d.ts.map +0 -1
  589. package/dist/src/adapters/claude/claude-adapter.js +0 -311
  590. package/dist/src/adapters/claude/claude-adapter.js.map +0 -1
  591. package/dist/src/adapters/claude/tool-mapper.d.ts +0 -19
  592. package/dist/src/adapters/claude/tool-mapper.d.ts.map +0 -1
  593. package/dist/src/adapters/claude/tool-mapper.js +0 -44
  594. package/dist/src/adapters/claude/tool-mapper.js.map +0 -1
  595. package/dist/src/adapters/types.d.ts +0 -33
  596. package/dist/src/adapters/types.d.ts.map +0 -1
  597. package/dist/src/task-progress-reporter.d.ts +0 -43
  598. package/dist/src/task-progress-reporter.d.ts.map +0 -1
  599. package/dist/src/task-progress-reporter.js +0 -393
  600. package/dist/src/task-progress-reporter.js.map +0 -1
  601. package/src/adapters/claude/claude-adapter.ts +0 -338
  602. package/src/adapters/claude/tool-mapper.ts +0 -46
  603. package/src/adapters/types.ts +0 -37
  604. package/src/task-progress-reporter.ts +0 -443
package/src/agent.ts CHANGED
@@ -1,322 +1,338 @@
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 { POSTHOG_NOTIFICATIONS } from "./acp-extensions.js";
2
+ import {
3
+ createAcpConnection,
4
+ type InProcessAcpConnection,
5
+ } from "./adapters/claude/claude.js";
6
+ import { PostHogFileManager } from "./file-manager.js";
7
+ import { GitManager } from "./git-manager.js";
8
+ import { PostHogAPIClient } from "./posthog-api.js";
9
+ import { PromptBuilder } from "./prompt-builder.js";
10
+ import { SessionStore } from "./session-store.js";
11
+ import { TaskManager } from "./task-manager.js";
12
+ import { TemplateManager } from "./template-manager.js";
13
+ import type { AgentConfig, CanUseTool, Task } from "./types.js";
14
+ import { Logger } from "./utils/logger.js";
15
+ import { TASK_WORKFLOW } from "./workflow/config.js";
16
+ import type { SendNotification, WorkflowRuntime } from "./workflow/types.js";
15
17
 
16
18
  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);
19
+ private workingDirectory: string;
20
+ private taskManager: TaskManager;
21
+ private posthogAPI?: PostHogAPIClient;
22
+ private fileManager: PostHogFileManager;
23
+ private gitManager: GitManager;
24
+ private templateManager: TemplateManager;
25
+ private logger: Logger;
26
+ private acpConnection?: InProcessAcpConnection;
27
+ private promptBuilder: PromptBuilder;
28
+ private mcpServers?: Record<string, any>;
29
+ private canUseTool?: CanUseTool;
30
+ private currentRunId?: string;
31
+ private sessionStore?: SessionStore;
32
+ public debug: boolean;
33
+
34
+ constructor(config: AgentConfig) {
35
+ this.workingDirectory = config.workingDirectory || process.cwd();
36
+ this.canUseTool = config.canUseTool;
37
+ this.debug = config.debug || false;
38
+
39
+ // Build default PostHog MCP server configuration
40
+ const posthogMcpUrl =
41
+ config.posthogMcpUrl ||
42
+ process.env.POSTHOG_MCP_URL ||
43
+ "https://mcp.posthog.com/mcp";
44
+
45
+ // Add auth if API key provided
46
+ const headers: Record<string, string> = {};
47
+ if (config.posthogApiKey) {
48
+ headers.Authorization = `Bearer ${config.posthogApiKey}`;
93
49
  }
94
50
 
95
- /**
96
- * Enable or disable debug logging
97
- */
98
- setDebug(enabled: boolean) {
99
- this.debug = enabled;
100
- this.logger.setDebug(enabled);
51
+ const defaultMcpServers = {
52
+ posthog: {
53
+ type: "http" as const,
54
+ url: posthogMcpUrl,
55
+ ...(Object.keys(headers).length > 0 ? { headers } : {}),
56
+ },
57
+ };
58
+
59
+ // Merge default PostHog MCP with user-provided servers (user config takes precedence)
60
+ this.mcpServers = {
61
+ ...defaultMcpServers,
62
+ ...config.mcpServers,
63
+ };
64
+ this.logger = new Logger({
65
+ debug: this.debug,
66
+ prefix: "[PostHog Agent]",
67
+ onLog: config.onLog,
68
+ });
69
+ this.taskManager = new TaskManager();
70
+
71
+ this.fileManager = new PostHogFileManager(
72
+ this.workingDirectory,
73
+ this.logger.child("FileManager"),
74
+ );
75
+ this.gitManager = new GitManager({
76
+ repositoryPath: this.workingDirectory,
77
+ logger: this.logger.child("GitManager"),
78
+ });
79
+ this.templateManager = new TemplateManager();
80
+
81
+ if (
82
+ config.posthogApiUrl &&
83
+ config.posthogApiKey &&
84
+ config.posthogProjectId
85
+ ) {
86
+ this.posthogAPI = new PostHogAPIClient({
87
+ apiUrl: config.posthogApiUrl,
88
+ apiKey: config.posthogApiKey,
89
+ projectId: config.posthogProjectId,
90
+ });
91
+
92
+ // Create SessionStore from the API client for ACP connection
93
+ this.sessionStore = new SessionStore(
94
+ this.posthogAPI,
95
+ this.logger.child("SessionStore"),
96
+ );
101
97
  }
102
98
 
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
- }
99
+ this.promptBuilder = new PromptBuilder({
100
+ getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),
101
+ generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),
102
+ posthogClient: this.posthogAPI,
103
+ logger: this.logger.child("PromptBuilder"),
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Enable or disable debug logging
109
+ */
110
+ setDebug(enabled: boolean) {
111
+ this.debug = enabled;
112
+ this.logger.setDebug(enabled);
113
+ }
114
+
115
+ /**
116
+ * Configure LLM gateway environment variables for Claude Code CLI
117
+ */
118
+ private async _configureLlmGateway(): Promise<void> {
119
+ if (!this.posthogAPI) {
120
+ return;
188
121
  }
189
122
 
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);
123
+ try {
124
+ const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();
125
+ const apiKey = this.posthogAPI.getApiKey();
126
+ process.env.ANTHROPIC_BASE_URL = gatewayUrl;
127
+ process.env.ANTHROPIC_AUTH_TOKEN = apiKey;
128
+ this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);
129
+ } catch (error) {
130
+ this.logger.error("Failed to configure LLM gateway", error);
131
+ throw error;
236
132
  }
133
+ }
237
134
 
238
- getPostHogClient(): PostHogAPIClient | undefined {
239
- return this.posthogAPI;
135
+ private getOrCreateConnection(): InProcessAcpConnection {
136
+ if (!this.acpConnection) {
137
+ this.acpConnection = createAcpConnection({
138
+ sessionStore: this.sessionStore,
139
+ });
240
140
  }
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.');
141
+ return this.acpConnection;
142
+ }
143
+
144
+ // Adaptive task execution orchestrated via workflow steps
145
+ async runTask(
146
+ taskId: string,
147
+ taskRunId: string,
148
+ options: import("./types.js").TaskExecutionOptions = {},
149
+ ): Promise<void> {
150
+ // await this._configureLlmGateway();
151
+
152
+ const task = await this.fetchTask(taskId);
153
+ const cwd = options.repositoryPath || this.workingDirectory;
154
+ const isCloudMode = options.isCloudMode ?? false;
155
+ const taskSlug = (task as any).slug || task.id;
156
+
157
+ // Use taskRunId as sessionId - they are the same identifier
158
+ this.currentRunId = taskRunId;
159
+
160
+ this.logger.info("Starting adaptive task execution", {
161
+ taskId: task.id,
162
+ taskSlug,
163
+ taskRunId,
164
+ isCloudMode,
165
+ });
166
+
167
+ const connection = this.getOrCreateConnection();
168
+
169
+ // Create sendNotification using ACP connection's extNotification
170
+ const sendNotification: SendNotification = async (method, params) => {
171
+ this.logger.debug(`Notification: ${method}`, params);
172
+ await connection.agentConnection.extNotification?.(method, params);
173
+ };
174
+
175
+ await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
176
+ sessionId: taskRunId,
177
+ runId: taskRunId,
178
+ });
179
+
180
+ await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
181
+
182
+ let taskError: Error | undefined;
183
+ try {
184
+ const workflowContext: WorkflowRuntime = {
185
+ task,
186
+ taskSlug,
187
+ runId: taskRunId,
188
+ cwd,
189
+ isCloudMode,
190
+ options,
191
+ logger: this.logger,
192
+ fileManager: this.fileManager,
193
+ gitManager: this.gitManager,
194
+ promptBuilder: this.promptBuilder,
195
+ connection: connection.agentConnection,
196
+ sessionId: taskRunId,
197
+ sendNotification,
198
+ mcpServers: this.mcpServers,
199
+ posthogAPI: this.posthogAPI,
200
+ stepResults: {},
201
+ };
202
+
203
+ for (const step of TASK_WORKFLOW) {
204
+ const result = await step.run({ step, context: workflowContext });
205
+ if (result.halt) {
206
+ return;
249
207
  }
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);
208
+ }
209
+
210
+ const shouldCreatePR = options.createPR ?? isCloudMode;
211
+ if (shouldCreatePR) {
212
+ await this.ensurePullRequest(
213
+ task,
214
+ workflowContext.stepResults,
215
+ sendNotification,
216
+ );
217
+ }
218
+
219
+ this.logger.info("Task execution complete", { taskId: task.id });
220
+ await sendNotification(POSTHOG_NOTIFICATIONS.TASK_COMPLETE, {
221
+ sessionId: taskRunId,
222
+ taskId: task.id,
223
+ });
224
+ } catch (error) {
225
+ taskError = error instanceof Error ? error : new Error(String(error));
226
+ this.logger.error("Task execution failed", {
227
+ taskId: task.id,
228
+ error: taskError.message,
229
+ });
230
+ await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
231
+ sessionId: taskRunId,
232
+ message: taskError.message,
233
+ });
234
+ throw taskError;
274
235
  }
275
-
276
- async readPlan(taskId: string): Promise<string | null> {
277
- this.logger.debug('Reading plan', { taskId });
278
- return await this.fileManager.readPlan(taskId);
236
+ }
237
+
238
+ /**
239
+ * Creates an in-process ACP connection for client communication.
240
+ * Sets up git branch for the task, configures LLM gateway.
241
+ * The client handles all prompting/querying via the returned streams.
242
+ *
243
+ * @returns InProcessAcpConnection with clientStreams for the client to use
244
+ */
245
+ async runTaskV2(
246
+ taskId: string,
247
+ taskRunId: string,
248
+ options: import("./types.js").TaskExecutionOptions = {},
249
+ ): Promise<InProcessAcpConnection> {
250
+ await this._configureLlmGateway();
251
+
252
+ const task = await this.fetchTask(taskId);
253
+ const taskSlug = (task as any).slug || task.id;
254
+ const isCloudMode = options.isCloudMode ?? false;
255
+ const _cwd = options.repositoryPath || this.workingDirectory;
256
+
257
+ // Use taskRunId as sessionId - they are the same identifier
258
+ this.currentRunId = taskRunId;
259
+
260
+ this.acpConnection = createAcpConnection({
261
+ sessionStore: this.sessionStore,
262
+ sessionId: taskRunId,
263
+ taskId: task.id,
264
+ });
265
+
266
+ const sendNotification: SendNotification = async (method, params) => {
267
+ this.logger.debug(`Notification: ${method}`, params);
268
+ await this.acpConnection?.agentConnection.extNotification?.(
269
+ method,
270
+ params,
271
+ );
272
+ };
273
+
274
+ await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
275
+ sessionId: taskRunId,
276
+ runId: taskRunId,
277
+ });
278
+
279
+ if (!options.skipGitBranch) {
280
+ try {
281
+ await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
282
+ } catch (error) {
283
+ const errorMessage =
284
+ error instanceof Error ? error.message : String(error);
285
+ this.logger.error("Failed to prepare task branch", {
286
+ error: errorMessage,
287
+ });
288
+ await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
289
+ sessionId: taskRunId,
290
+ message: errorMessage,
291
+ });
292
+ throw error;
293
+ }
279
294
  }
280
295
 
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;
296
+ return this.acpConnection;
297
+ }
298
+
299
+ // PostHog task operations
300
+ async fetchTask(taskId: string): Promise<Task> {
301
+ if (!this.posthogAPI) {
302
+ const error = new Error(
303
+ "PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.",
304
+ );
305
+ this.logger.error("PostHog API not configured", error);
306
+ throw error;
294
307
  }
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;
301
- }
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;
308
- }
309
-
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
308
+ return this.posthogAPI.fetchTask(taskId);
309
+ }
310
+
311
+ getPostHogClient(): PostHogAPIClient | undefined {
312
+ return this.posthogAPI;
313
+ }
314
+
315
+ async getTaskFiles(taskId: string): Promise<any[]> {
316
+ this.logger.debug("Getting task files", { taskId });
317
+ const files = await this.fileManager.getTaskFiles(taskId);
318
+ this.logger.debug("Found task files", { taskId, fileCount: files.length });
319
+ return files;
320
+ }
321
+
322
+ async createPullRequest(
323
+ taskId: string,
324
+ branchName: string,
325
+ taskTitle: string,
326
+ taskDescription: string,
327
+ customBody?: string,
328
+ ): Promise<string> {
329
+ this.logger.info("Creating pull request", {
330
+ taskId,
331
+ branchName,
332
+ taskTitle,
333
+ });
334
+
335
+ const defaultBody = `## Task Details
320
336
  **Task ID**: ${taskId}
321
337
  **Description**: ${taskDescription}
322
338
 
@@ -324,171 +340,219 @@ export class Agent {
324
340
  This PR implements the changes described in the task.
325
341
 
326
342
  Generated by PostHog Agent`;
327
- const prBody = customBody || defaultBody;
328
-
329
- const prUrl = await this.gitManager.createPullRequest(
330
- branchName,
331
- taskTitle,
332
- prBody
333
- );
334
-
335
- this.logger.info('Pull request created', { taskId, prUrl });
336
- return prUrl;
343
+ const prBody = customBody || defaultBody;
344
+
345
+ const prUrl = await this.gitManager.createPullRequest(
346
+ branchName,
347
+ taskTitle,
348
+ prBody,
349
+ );
350
+
351
+ this.logger.info("Pull request created", { taskId, prUrl });
352
+ return prUrl;
353
+ }
354
+
355
+ async attachPullRequestToTask(
356
+ taskId: string,
357
+ prUrl: string,
358
+ branchName?: string,
359
+ ): Promise<void> {
360
+ this.logger.info("Attaching PR to task run", { taskId, prUrl, branchName });
361
+
362
+ if (!this.posthogAPI || !this.currentRunId) {
363
+ const error = new Error(
364
+ "PostHog API not configured or no active run. Cannot attach PR to task.",
365
+ );
366
+ this.logger.error("PostHog API not configured", error);
367
+ throw error;
337
368
  }
338
369
 
339
- async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {
340
- this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });
341
-
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
- }
347
-
348
- const updates: any = {
349
- output: { pr_url: prUrl }
350
- };
351
- if (branchName) {
352
- updates.branch = branchName;
353
- }
354
-
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 });
370
+ const updates: any = {
371
+ output: { pr_url: prUrl },
372
+ };
373
+ if (branchName) {
374
+ updates.branch = branchName;
357
375
  }
358
376
 
359
- async updateTaskBranch(taskId: string, branchName: string): Promise<void> {
360
- this.logger.info('Updating task run branch', { taskId, branchName });
361
-
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;
366
- }
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 });
377
+ await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, updates);
378
+ this.logger.debug("PR attached to task run", {
379
+ taskId,
380
+ runId: this.currentRunId,
381
+ prUrl,
382
+ });
383
+ }
384
+
385
+ async updateTaskBranch(taskId: string, branchName: string): Promise<void> {
386
+ this.logger.info("Updating task run branch", { taskId, branchName });
387
+
388
+ if (!this.posthogAPI || !this.currentRunId) {
389
+ const error = new Error(
390
+ "PostHog API not configured or no active run. Cannot update branch.",
391
+ );
392
+ this.logger.error("PostHog API not configured", error);
393
+ throw error;
370
394
  }
371
395
 
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
- }
396
+ await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, {
397
+ branch: branchName,
398
+ });
399
+ this.logger.debug("Task run branch updated", {
400
+ taskId,
401
+ runId: this.currentRunId,
402
+ branchName,
403
+ });
404
+ }
405
+
406
+ // Execution management
407
+ cancelTask(taskId: string): void {
408
+ // Find the execution for this task and cancel it
409
+ for (const [executionId, execution] of this.taskManager.executionStates) {
410
+ if (execution.taskId === taskId && execution.status === "running") {
411
+ this.taskManager.cancelExecution(executionId);
412
+ break;
413
+ }
381
414
  }
382
-
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;
415
+ }
416
+
417
+ getTaskExecutionStatus(taskId: string): string | null {
418
+ // Find the execution for this task
419
+ for (const execution of this.taskManager.executionStates.values()) {
420
+ if (execution.taskId === taskId) {
421
+ return execution.status;
422
+ }
391
423
  }
392
-
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
- }
397
-
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}`);
415
- }
416
- }
417
- } else {
418
- this.logger.info('Switching to existing task branch', { branch: existingBranch });
419
- await this.gitManager.switchToBranch(existingBranch);
420
- }
424
+ return null;
425
+ }
426
+
427
+ private async prepareTaskBranch(
428
+ taskSlug: string,
429
+ isCloudMode: boolean,
430
+ sendNotification: SendNotification,
431
+ ): Promise<void> {
432
+ if (await this.gitManager.hasChanges()) {
433
+ throw new Error(
434
+ "Cannot start task with uncommitted changes. Please commit or stash your changes first.",
435
+ );
421
436
  }
422
437
 
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
- }
438
+ // If we're running in a worktree, we're already on the correct branch
439
+ // (the worktree was created with its own branch). Skip branch creation.
440
+ const isWorktree = await this.gitManager.isWorktree();
441
+ if (isWorktree) {
442
+ const currentBranch = await this.gitManager.getCurrentBranch();
443
+ this.logger.info("Running in worktree, using existing branch", {
444
+ branch: currentBranch,
445
+ });
446
+ await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
447
+ branch: currentBranch,
448
+ });
449
+ return;
434
450
  }
435
451
 
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;
452
+ await this.gitManager.resetToDefaultBranchIfNeeded();
442
453
 
443
- if (existingPr) {
444
- this.logger.info('PR already exists, skipping creation', { taskId: task.id, prUrl: existingPr });
445
- return;
446
- }
454
+ const existingBranch = await this.gitManager.getTaskBranch(taskSlug);
455
+ if (!existingBranch) {
456
+ const branchName = await this.gitManager.createTaskBranch(taskSlug);
457
+ await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
458
+ branch: branchName,
459
+ });
447
460
 
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;
461
+ await this.gitManager.addAllPostHogFiles();
462
+
463
+ // Only commit if there are changes or we're in cloud mode
464
+ if (isCloudMode) {
465
+ await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, {
466
+ allowEmpty: true,
467
+ });
468
+ } else {
469
+ // Check if there are any changes before committing
470
+ const hasChanges = await this.gitManager.hasStagedChanges();
471
+ if (hasChanges) {
472
+ await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);
452
473
  }
474
+ }
475
+ } else {
476
+ this.logger.info("Switching to existing task branch", {
477
+ branch: existingBranch,
478
+ });
479
+ await this.gitManager.switchToBranch(existingBranch);
480
+ }
481
+ }
453
482
 
454
- const branchName = await this.gitManager.getCurrentBranch();
455
- const finalizeResult = stepResults['finalize'];
456
- const prBody = finalizeResult?.prBody;
483
+ private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {
484
+ const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;
485
+ const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;
457
486
 
458
- const prUrl = await this.createPullRequest(
459
- task.id,
460
- branchName,
461
- task.title,
462
- task.description ?? '',
463
- prBody
464
- );
487
+ if (resolvedGatewayUrl) {
488
+ process.env.OPENAI_BASE_URL = resolvedGatewayUrl;
489
+ }
465
490
 
466
- this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));
491
+ if (resolvedToken) {
492
+ process.env.OPENAI_API_KEY = resolvedToken;
493
+ }
494
+ }
495
+
496
+ private async ensurePullRequest(
497
+ task: Task,
498
+ stepResults: Record<string, any>,
499
+ sendNotification: SendNotification,
500
+ ): Promise<void> {
501
+ const latestRun = task.latest_run;
502
+ const existingPr =
503
+ latestRun?.output && typeof latestRun.output === "object"
504
+ ? (latestRun.output as any).pr_url
505
+ : null;
506
+
507
+ if (existingPr) {
508
+ this.logger.info("PR already exists, skipping creation", {
509
+ taskId: task.id,
510
+ prUrl: existingPr,
511
+ });
512
+ return;
513
+ }
467
514
 
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
- }
515
+ const buildResult = stepResults.build;
516
+ if (!buildResult?.commitCreated) {
517
+ this.logger.warn(
518
+ "Build step did not produce a commit; skipping PR creation",
519
+ { taskId: task.id },
520
+ );
521
+ return;
476
522
  }
477
523
 
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);
524
+ const branchName = await this.gitManager.getCurrentBranch();
525
+ const finalizeResult = stepResults.finalize;
526
+ const prBody = finalizeResult?.prBody;
527
+
528
+ const prUrl = await this.createPullRequest(
529
+ task.id,
530
+ branchName,
531
+ task.title,
532
+ task.description ?? "",
533
+ prBody,
534
+ );
535
+
536
+ await sendNotification(POSTHOG_NOTIFICATIONS.PR_CREATED, { prUrl });
537
+
538
+ try {
539
+ await this.attachPullRequestToTask(task.id, prUrl, branchName);
540
+ this.logger.info("PR attached to task successfully", {
541
+ taskId: task.id,
542
+ prUrl,
543
+ });
544
+ } catch (error) {
545
+ this.logger.warn("Could not attach PR to task", {
546
+ error: error instanceof Error ? error.message : String(error),
547
+ });
490
548
  }
549
+ }
491
550
  }
492
551
 
493
- export { PermissionMode } from './types.js';
494
- export type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';
552
+ export type {
553
+ AgentConfig,
554
+ ExecutionResult,
555
+ SupportingFile,
556
+ Task,
557
+ } from "./types.js";
558
+ export { PermissionMode } from "./types.js";