@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/dist/src/agent.js CHANGED
@@ -1,82 +1,88 @@
1
- import { query } from '@anthropic-ai/claude-agent-sdk';
2
- import { TaskManager } from './task-manager.js';
3
- import { PostHogAPIClient } from './posthog-api.js';
1
+ import { ClientSideConnection } from '../node_modules/@agentclientprotocol/sdk/dist/acp.js';
2
+ import { POSTHOG_NOTIFICATIONS } from './acp-extensions.js';
3
+ import { createAcpConnection } from './adapters/claude/claude.js';
4
4
  import { PostHogFileManager } from './file-manager.js';
5
5
  import { GitManager } from './git-manager.js';
6
+ import { PostHogAPIClient } from './posthog-api.js';
7
+ import { PromptBuilder } from './prompt-builder.js';
8
+ import { SessionStore } from './session-store.js';
9
+ import { TaskManager } from './task-manager.js';
6
10
  import { TemplateManager } from './template-manager.js';
7
- import { ClaudeAdapter } from './adapters/claude/claude-adapter.js';
8
11
  import { Logger } from './utils/logger.js';
9
- import { PromptBuilder } from './prompt-builder.js';
10
- import { TaskProgressReporter } from './task-progress-reporter.js';
11
12
  import { TASK_WORKFLOW } from './workflow/config.js';
12
13
  export { PermissionMode } from './types.js';
14
+ import { PROTOCOL_VERSION } from '../node_modules/@agentclientprotocol/sdk/dist/schema.js';
15
+ import { ndJsonStream } from '../node_modules/@agentclientprotocol/sdk/dist/stream.js';
13
16
 
14
17
  class Agent {
15
18
  workingDirectory;
16
- onEvent;
17
19
  taskManager;
18
20
  posthogAPI;
19
21
  fileManager;
20
22
  gitManager;
21
23
  templateManager;
22
- adapter;
23
24
  logger;
24
- progressReporter;
25
+ acpConnection;
25
26
  promptBuilder;
26
27
  mcpServers;
27
28
  canUseTool;
29
+ currentRunId;
30
+ sessionStore;
28
31
  debug;
29
32
  constructor(config) {
30
33
  this.workingDirectory = config.workingDirectory || process.cwd();
31
- this.onEvent = config.onEvent;
32
34
  this.canUseTool = config.canUseTool;
33
35
  this.debug = config.debug || false;
34
36
  // Build default PostHog MCP server configuration
35
- const posthogMcpUrl = config.posthogMcpUrl
36
- || process.env.POSTHOG_MCP_URL
37
- || 'https://mcp.posthog.com/mcp';
37
+ const posthogMcpUrl = config.posthogMcpUrl ||
38
+ process.env.POSTHOG_MCP_URL ||
39
+ "https://mcp.posthog.com/mcp";
38
40
  // Add auth if API key provided
39
41
  const headers = {};
40
42
  if (config.posthogApiKey) {
41
- headers['Authorization'] = `Bearer ${config.posthogApiKey}`;
43
+ headers.Authorization = `Bearer ${config.posthogApiKey}`;
42
44
  }
43
45
  const defaultMcpServers = {
44
46
  posthog: {
45
- type: 'http',
47
+ type: "http",
46
48
  url: posthogMcpUrl,
47
49
  ...(Object.keys(headers).length > 0 ? { headers } : {}),
48
- }
50
+ },
49
51
  };
50
52
  // Merge default PostHog MCP with user-provided servers (user config takes precedence)
51
53
  this.mcpServers = {
52
54
  ...defaultMcpServers,
53
- ...config.mcpServers
55
+ ...config.mcpServers,
54
56
  };
55
- this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });
57
+ this.logger = new Logger({
58
+ debug: this.debug,
59
+ prefix: "[PostHog Agent]",
60
+ onLog: config.onLog,
61
+ });
56
62
  this.taskManager = new TaskManager();
57
- // Hardcode Claude adapter for now - extensible for other providers later
58
- this.adapter = new ClaudeAdapter();
59
- this.fileManager = new PostHogFileManager(this.workingDirectory, this.logger.child('FileManager'));
63
+ this.fileManager = new PostHogFileManager(this.workingDirectory, this.logger.child("FileManager"));
60
64
  this.gitManager = new GitManager({
61
65
  repositoryPath: this.workingDirectory,
62
- logger: this.logger.child('GitManager')
63
- // TODO: Add author config from environment or config
66
+ logger: this.logger.child("GitManager"),
64
67
  });
65
68
  this.templateManager = new TemplateManager();
66
- if (config.posthogApiUrl && config.posthogApiKey) {
69
+ if (config.posthogApiUrl &&
70
+ config.posthogApiKey &&
71
+ config.posthogProjectId) {
67
72
  this.posthogAPI = new PostHogAPIClient({
68
73
  apiUrl: config.posthogApiUrl,
69
74
  apiKey: config.posthogApiKey,
70
75
  projectId: config.posthogProjectId,
71
76
  });
77
+ // Create SessionStore from the API client for ACP connection
78
+ this.sessionStore = new SessionStore(this.posthogAPI, this.logger.child("SessionStore"));
72
79
  }
73
80
  this.promptBuilder = new PromptBuilder({
74
81
  getTaskFiles: (taskId) => this.getTaskFiles(taskId),
75
82
  generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),
76
83
  posthogClient: this.posthogAPI,
77
- logger: this.logger.child('PromptBuilder')
84
+ logger: this.logger.child("PromptBuilder"),
78
85
  });
79
- this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);
80
86
  }
81
87
  /**
82
88
  * Enable or disable debug logging
@@ -98,30 +104,52 @@ class Agent {
98
104
  process.env.ANTHROPIC_BASE_URL = gatewayUrl;
99
105
  process.env.ANTHROPIC_AUTH_TOKEN = apiKey;
100
106
  this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);
101
- this.logger.debug('Configured LLM gateway', { gatewayUrl });
102
107
  }
103
108
  catch (error) {
104
- this.logger.error('Failed to configure LLM gateway', error);
109
+ this.logger.error("Failed to configure LLM gateway", error);
105
110
  throw error;
106
111
  }
107
112
  }
113
+ getOrCreateConnection() {
114
+ if (!this.acpConnection) {
115
+ this.acpConnection = createAcpConnection({
116
+ sessionStore: this.sessionStore,
117
+ });
118
+ }
119
+ return this.acpConnection;
120
+ }
108
121
  // Adaptive task execution orchestrated via workflow steps
109
- async runTask(taskOrId, options = {}) {
110
- await this._configureLlmGateway();
111
- const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;
122
+ async runTask(taskId, taskRunId, options = {}) {
123
+ // await this._configureLlmGateway();
124
+ const task = await this.fetchTask(taskId);
112
125
  const cwd = options.repositoryPath || this.workingDirectory;
113
126
  const isCloudMode = options.isCloudMode ?? false;
114
127
  const taskSlug = task.slug || task.id;
115
- this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });
116
- // Initialize progress reporter for task run tracking (needed for PR attachment)
117
- await this.progressReporter.start(task.id, { totalSteps: TASK_WORKFLOW.length });
118
- this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));
119
- await this.prepareTaskBranch(taskSlug, isCloudMode);
128
+ // Use taskRunId as sessionId - they are the same identifier
129
+ this.currentRunId = taskRunId;
130
+ this.logger.info("Starting adaptive task execution", {
131
+ taskId: task.id,
132
+ taskSlug,
133
+ taskRunId,
134
+ isCloudMode,
135
+ });
136
+ const connection = this.getOrCreateConnection();
137
+ // Create sendNotification using ACP connection's extNotification
138
+ const sendNotification = async (method, params) => {
139
+ this.logger.debug(`Notification: ${method}`, params);
140
+ await connection.agentConnection.extNotification?.(method, params);
141
+ };
142
+ await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
143
+ sessionId: taskRunId,
144
+ runId: taskRunId,
145
+ });
146
+ await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
120
147
  let taskError;
121
148
  try {
122
149
  const workflowContext = {
123
150
  task,
124
151
  taskSlug,
152
+ runId: taskRunId,
125
153
  cwd,
126
154
  isCloudMode,
127
155
  options,
@@ -129,11 +157,11 @@ class Agent {
129
157
  fileManager: this.fileManager,
130
158
  gitManager: this.gitManager,
131
159
  promptBuilder: this.promptBuilder,
132
- progressReporter: this.progressReporter,
133
- adapter: this.adapter,
160
+ connection: connection.agentConnection,
161
+ sessionId: taskRunId,
162
+ sendNotification,
134
163
  mcpServers: this.mcpServers,
135
164
  posthogAPI: this.posthogAPI,
136
- emitEvent: (event) => this.emitEvent(event),
137
165
  stepResults: {},
138
166
  };
139
167
  for (const step of TASK_WORKFLOW) {
@@ -144,63 +172,78 @@ class Agent {
144
172
  }
145
173
  const shouldCreatePR = options.createPR ?? isCloudMode;
146
174
  if (shouldCreatePR) {
147
- await this.ensurePullRequest(task, workflowContext.stepResults);
175
+ await this.ensurePullRequest(task, workflowContext.stepResults, sendNotification);
148
176
  }
149
- this.logger.info('Task execution complete', { taskId: task.id });
150
- this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));
177
+ this.logger.info("Task execution complete", { taskId: task.id });
178
+ await sendNotification(POSTHOG_NOTIFICATIONS.TASK_COMPLETE, {
179
+ sessionId: taskRunId,
180
+ taskId: task.id,
181
+ });
151
182
  }
152
183
  catch (error) {
153
184
  taskError = error instanceof Error ? error : new Error(String(error));
154
- this.logger.error('Task execution failed', { taskId: task.id, error: taskError.message });
155
- }
156
- finally {
157
- if (taskError) {
158
- await this.progressReporter.fail(taskError);
159
- throw taskError;
160
- }
161
- else {
162
- await this.progressReporter.complete();
163
- }
185
+ this.logger.error("Task execution failed", {
186
+ taskId: task.id,
187
+ error: taskError.message,
188
+ });
189
+ await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
190
+ sessionId: taskRunId,
191
+ message: taskError.message,
192
+ });
193
+ throw taskError;
164
194
  }
165
195
  }
166
- // Direct prompt execution - still supported for low-level usage
167
- async run(prompt, options = {}) {
196
+ /**
197
+ * Creates an in-process ACP connection for client communication.
198
+ * Sets up git branch for the task, configures LLM gateway.
199
+ * The client handles all prompting/querying via the returned streams.
200
+ *
201
+ * @returns InProcessAcpConnection with clientStreams for the client to use
202
+ */
203
+ async runTaskV2(taskId, taskRunId, options = {}) {
168
204
  await this._configureLlmGateway();
169
- const baseOptions = {
170
- model: "claude-sonnet-4-5-20250929",
171
- cwd: options.repositoryPath || this.workingDirectory,
172
- permissionMode: options.permissionMode || "default",
173
- settingSources: ["local"],
174
- mcpServers: this.mcpServers,
205
+ const task = await this.fetchTask(taskId);
206
+ const taskSlug = task.slug || task.id;
207
+ const isCloudMode = options.isCloudMode ?? false;
208
+ options.repositoryPath || this.workingDirectory;
209
+ // Use taskRunId as sessionId - they are the same identifier
210
+ this.currentRunId = taskRunId;
211
+ this.acpConnection = createAcpConnection({
212
+ sessionStore: this.sessionStore,
213
+ sessionId: taskRunId,
214
+ taskId: task.id,
215
+ });
216
+ const sendNotification = async (method, params) => {
217
+ this.logger.debug(`Notification: ${method}`, params);
218
+ await this.acpConnection?.agentConnection.extNotification?.(method, params);
175
219
  };
176
- // Add canUseTool hook if provided (options take precedence over instance config)
177
- const canUseTool = options.canUseTool || this.canUseTool;
178
- if (canUseTool) {
179
- baseOptions.canUseTool = canUseTool;
180
- }
181
- const response = query({
182
- prompt,
183
- options: { ...baseOptions, ...(options.queryOverrides || {}) },
220
+ await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
221
+ sessionId: taskRunId,
222
+ runId: taskRunId,
184
223
  });
185
- const results = [];
186
- for await (const message of response) {
187
- this.logger.debug('Received message in direct run', message);
188
- // Emit raw SDK event
189
- this.emitEvent(this.adapter.createRawSDKEvent(message));
190
- const transformedEvents = this.adapter.transform(message);
191
- for (const event of transformedEvents) {
192
- this.emitEvent(event);
224
+ if (!options.skipGitBranch) {
225
+ try {
226
+ await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
227
+ }
228
+ catch (error) {
229
+ const errorMessage = error instanceof Error ? error.message : String(error);
230
+ this.logger.error("Failed to prepare task branch", {
231
+ error: errorMessage,
232
+ });
233
+ await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
234
+ sessionId: taskRunId,
235
+ message: errorMessage,
236
+ });
237
+ throw error;
193
238
  }
194
- results.push(message);
195
239
  }
196
- return { results };
240
+ return this.acpConnection;
197
241
  }
198
242
  // PostHog task operations
199
243
  async fetchTask(taskId) {
200
- this.logger.debug('Fetching task from PostHog', { taskId });
201
244
  if (!this.posthogAPI) {
202
- const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');
203
- this.logger.error('PostHog API not configured', error);
245
+ const error = new Error("PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.");
246
+ this.logger.error("PostHog API not configured", error);
204
247
  throw error;
205
248
  }
206
249
  return this.posthogAPI.fetchTask(taskId);
@@ -208,62 +251,33 @@ class Agent {
208
251
  getPostHogClient() {
209
252
  return this.posthogAPI;
210
253
  }
211
- async listTasks(filters) {
254
+ /**
255
+ * Send a notification to a cloud task run's S3 log.
256
+ * The cloud runner will pick up new notifications via interrupt polling.
257
+ */
258
+ async sendNotification(taskId, runId, notification) {
212
259
  if (!this.posthogAPI) {
213
- throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');
260
+ throw new Error("PostHog API not configured. Cannot send notification to cloud task.");
214
261
  }
215
- return this.posthogAPI.listTasks(filters);
216
- }
217
- // File system operations for task artifacts
218
- async writeTaskFile(taskId, fileName, content, type = 'reference') {
219
- this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });
220
- await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });
221
- }
222
- async readTaskFile(taskId, fileName) {
223
- this.logger.debug('Reading task file', { taskId, fileName });
224
- return await this.fileManager.readTaskFile(taskId, fileName);
262
+ await this.posthogAPI.appendTaskRunLog(taskId, runId, [notification]);
263
+ this.logger.debug("Notification sent to cloud task", {
264
+ taskId,
265
+ runId,
266
+ method: notification.notification.method,
267
+ });
225
268
  }
226
269
  async getTaskFiles(taskId) {
227
- this.logger.debug('Getting task files', { taskId });
270
+ this.logger.debug("Getting task files", { taskId });
228
271
  const files = await this.fileManager.getTaskFiles(taskId);
229
- this.logger.debug('Found task files', { taskId, fileCount: files.length });
272
+ this.logger.debug("Found task files", { taskId, fileCount: files.length });
230
273
  return files;
231
274
  }
232
- async writePlan(taskId, plan) {
233
- this.logger.info('Writing plan', { taskId, planLength: plan.length });
234
- await this.fileManager.writePlan(taskId, plan);
235
- }
236
- async readPlan(taskId) {
237
- this.logger.debug('Reading plan', { taskId });
238
- return await this.fileManager.readPlan(taskId);
239
- }
240
- // Git operations for task execution
241
- async createPlanningBranch(taskId) {
242
- this.logger.info('Creating planning branch', { taskId });
243
- const branchName = await this.gitManager.createTaskPlanningBranch(taskId);
244
- this.logger.debug('Planning branch created', { taskId, branchName });
245
- return branchName;
246
- }
247
- async commitPlan(taskId, taskTitle) {
248
- this.logger.info('Committing plan', { taskId, taskTitle });
249
- const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);
250
- this.logger.debug('Plan committed', { taskId, commitHash });
251
- return commitHash;
252
- }
253
- async createImplementationBranch(taskId, planningBranchName) {
254
- this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });
255
- const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);
256
- this.logger.debug('Implementation branch created', { taskId, branchName });
257
- return branchName;
258
- }
259
- async commitImplementation(taskId, taskTitle, planSummary) {
260
- this.logger.info('Committing implementation', { taskId, taskTitle });
261
- const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);
262
- this.logger.debug('Implementation committed', { taskId, commitHash });
263
- return commitHash;
264
- }
265
275
  async createPullRequest(taskId, branchName, taskTitle, taskDescription, customBody) {
266
- this.logger.info('Creating pull request', { taskId, branchName, taskTitle });
276
+ this.logger.info("Creating pull request", {
277
+ taskId,
278
+ branchName,
279
+ taskTitle,
280
+ });
267
281
  const defaultBody = `## Task Details
268
282
  **Task ID**: ${taskId}
269
283
  **Description**: ${taskDescription}
@@ -274,40 +288,50 @@ This PR implements the changes described in the task.
274
288
  Generated by PostHog Agent`;
275
289
  const prBody = customBody || defaultBody;
276
290
  const prUrl = await this.gitManager.createPullRequest(branchName, taskTitle, prBody);
277
- this.logger.info('Pull request created', { taskId, prUrl });
291
+ this.logger.info("Pull request created", { taskId, prUrl });
278
292
  return prUrl;
279
293
  }
280
294
  async attachPullRequestToTask(taskId, prUrl, branchName) {
281
- this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });
282
- if (!this.posthogAPI || !this.progressReporter.runId) {
283
- const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');
284
- this.logger.error('PostHog API not configured', error);
295
+ this.logger.info("Attaching PR to task run", { taskId, prUrl, branchName });
296
+ if (!this.posthogAPI || !this.currentRunId) {
297
+ const error = new Error("PostHog API not configured or no active run. Cannot attach PR to task.");
298
+ this.logger.error("PostHog API not configured", error);
285
299
  throw error;
286
300
  }
287
301
  const updates = {
288
- output: { pr_url: prUrl }
302
+ output: { pr_url: prUrl },
289
303
  };
290
304
  if (branchName) {
291
305
  updates.branch = branchName;
292
306
  }
293
- await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);
294
- this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });
307
+ await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, updates);
308
+ this.logger.debug("PR attached to task run", {
309
+ taskId,
310
+ runId: this.currentRunId,
311
+ prUrl,
312
+ });
295
313
  }
296
314
  async updateTaskBranch(taskId, branchName) {
297
- this.logger.info('Updating task run branch', { taskId, branchName });
298
- if (!this.posthogAPI || !this.progressReporter.runId) {
299
- const error = new Error('PostHog API not configured or no active run. Cannot update branch.');
300
- this.logger.error('PostHog API not configured', error);
315
+ this.logger.info("Updating task run branch", { taskId, branchName });
316
+ if (!this.posthogAPI || !this.currentRunId) {
317
+ const error = new Error("PostHog API not configured or no active run. Cannot update branch.");
318
+ this.logger.error("PostHog API not configured", error);
301
319
  throw error;
302
320
  }
303
- await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });
304
- this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, branchName });
321
+ await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, {
322
+ branch: branchName,
323
+ });
324
+ this.logger.debug("Task run branch updated", {
325
+ taskId,
326
+ runId: this.currentRunId,
327
+ branchName,
328
+ });
305
329
  }
306
330
  // Execution management
307
331
  cancelTask(taskId) {
308
332
  // Find the execution for this task and cancel it
309
- for (const [executionId, execution] of this.taskManager['executionStates']) {
310
- if (execution.taskId === taskId && execution.status === 'running') {
333
+ for (const [executionId, execution] of this.taskManager.executionStates) {
334
+ if (execution.taskId === taskId && execution.status === "running") {
311
335
  this.taskManager.cancelExecution(executionId);
312
336
  break;
313
337
  }
@@ -315,26 +339,43 @@ Generated by PostHog Agent`;
315
339
  }
316
340
  getTaskExecutionStatus(taskId) {
317
341
  // Find the execution for this task
318
- for (const execution of this.taskManager['executionStates'].values()) {
342
+ for (const execution of this.taskManager.executionStates.values()) {
319
343
  if (execution.taskId === taskId) {
320
344
  return execution.status;
321
345
  }
322
346
  }
323
347
  return null;
324
348
  }
325
- async prepareTaskBranch(taskSlug, isCloudMode) {
349
+ async prepareTaskBranch(taskSlug, isCloudMode, sendNotification) {
326
350
  if (await this.gitManager.hasChanges()) {
327
- throw new Error('Cannot start task with uncommitted changes. Please commit or stash your changes first.');
351
+ throw new Error("Cannot start task with uncommitted changes. Please commit or stash your changes first.");
352
+ }
353
+ // If we're running in a worktree, we're already on the correct branch
354
+ // (the worktree was created with its own branch). Skip branch creation.
355
+ const isWorktree = await this.gitManager.isWorktree();
356
+ if (isWorktree) {
357
+ const currentBranch = await this.gitManager.getCurrentBranch();
358
+ this.logger.info("Running in worktree, using existing branch", {
359
+ branch: currentBranch,
360
+ });
361
+ await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
362
+ branch: currentBranch,
363
+ });
364
+ return;
328
365
  }
329
366
  await this.gitManager.resetToDefaultBranchIfNeeded();
330
367
  const existingBranch = await this.gitManager.getTaskBranch(taskSlug);
331
368
  if (!existingBranch) {
332
369
  const branchName = await this.gitManager.createTaskBranch(taskSlug);
333
- this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));
370
+ await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
371
+ branch: branchName,
372
+ });
334
373
  await this.gitManager.addAllPostHogFiles();
335
374
  // Only commit if there are changes or we're in cloud mode
336
375
  if (isCloudMode) {
337
- await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });
376
+ await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, {
377
+ allowEmpty: true,
378
+ });
338
379
  }
339
380
  else {
340
381
  // Check if there are any changes before committing
@@ -345,7 +386,9 @@ Generated by PostHog Agent`;
345
386
  }
346
387
  }
347
388
  else {
348
- this.logger.info('Switching to existing task branch', { branch: existingBranch });
389
+ this.logger.info("Switching to existing task branch", {
390
+ branch: existingBranch,
391
+ });
349
392
  await this.gitManager.switchToBranch(existingBranch);
350
393
  }
351
394
  }
@@ -359,46 +402,174 @@ Generated by PostHog Agent`;
359
402
  process.env.OPENAI_API_KEY = resolvedToken;
360
403
  }
361
404
  }
362
- async ensurePullRequest(task, stepResults) {
405
+ async runTaskCloud(taskId, taskRunId, options = {}) {
406
+ await this._configureLlmGateway();
407
+ const task = await this.fetchTask(taskId);
408
+ const cwd = options.repositoryPath || this.workingDirectory;
409
+ const taskSlug = task.slug || task.id;
410
+ this.currentRunId = taskRunId;
411
+ this.logger.info("Starting cloud task execution", {
412
+ taskId: task.id,
413
+ taskSlug,
414
+ taskRunId,
415
+ cwd,
416
+ });
417
+ if (!this.sessionStore) {
418
+ throw new Error("SessionStore required for cloud mode. Ensure PostHog API credentials are configured.");
419
+ }
420
+ // Start session in SessionStore (updates task run status to in_progress)
421
+ const taskRun = await this.sessionStore.start(taskRunId, taskId, taskRunId);
422
+ this.logger.debug("Session started", {
423
+ taskRunId,
424
+ logUrl: taskRun?.log_url,
425
+ });
426
+ // Create internal ACP connection with S3 persistence
427
+ const acpConnection = createAcpConnection({
428
+ sessionStore: this.sessionStore,
429
+ sessionId: taskRunId,
430
+ taskId: task.id,
431
+ });
432
+ // Create client connection using the client-side streams
433
+ const clientStream = ndJsonStream(acpConnection.clientStreams.writable, acpConnection.clientStreams.readable);
434
+ // Create auto-approving client for headless cloud mode
435
+ const cloudClient = {
436
+ async requestPermission(params) {
437
+ const allowOption = params.options.find((o) => o.kind === "allow_once" || o.kind === "allow_always");
438
+ return {
439
+ outcome: {
440
+ outcome: "selected",
441
+ optionId: allowOption?.optionId ?? params.options[0].optionId,
442
+ },
443
+ };
444
+ },
445
+ async sessionUpdate(_params) {
446
+ // Notifications are already being persisted to S3 via tapped streams
447
+ },
448
+ };
449
+ const clientConnection = new ClientSideConnection((_agent) => cloudClient, clientStream);
450
+ try {
451
+ // Initialize the connection
452
+ await clientConnection.initialize({
453
+ protocolVersion: PROTOCOL_VERSION,
454
+ clientCapabilities: {},
455
+ });
456
+ // Create new session
457
+ await clientConnection.newSession({
458
+ cwd,
459
+ mcpServers: [],
460
+ _meta: { sessionId: taskRunId },
461
+ });
462
+ // Prepare git branch if not skipped
463
+ if (!options.skipGitBranch) {
464
+ const sendNotification = async (method, params) => {
465
+ this.logger.debug(`Notification: ${method}`, params);
466
+ await acpConnection.agentConnection.extNotification?.(method, params);
467
+ };
468
+ await this.prepareTaskBranch(taskSlug, true, sendNotification);
469
+ }
470
+ // Build initial prompt from task description
471
+ const initialPrompt = [
472
+ {
473
+ type: "text",
474
+ text: `# Task: ${task.title}\n\n${task.description}`,
475
+ },
476
+ ];
477
+ // Track the last known log entry count for interrupt polling
478
+ let lastKnownEntryCount = 0;
479
+ let isPolling = true;
480
+ // Start interrupt polling in background
481
+ const pollForInterrupts = async () => {
482
+ while (isPolling) {
483
+ await new Promise((resolve) => setTimeout(resolve, 2000)); // Poll every 2 seconds
484
+ if (!isPolling)
485
+ break;
486
+ try {
487
+ const newEntries = await this.sessionStore.pollForNewEntries(taskRunId, lastKnownEntryCount);
488
+ for (const entry of newEntries) {
489
+ lastKnownEntryCount++;
490
+ // Look for user_message notifications
491
+ if (entry.notification?.method === "sessionUpdate" &&
492
+ entry.notification?.params?.sessionUpdate ===
493
+ "user_message") {
494
+ const content = entry.notification?.params?.content;
495
+ if (content) {
496
+ this.logger.info("Processing user interrupt", { content });
497
+ // Send as new prompt - will be processed after current prompt completes
498
+ await clientConnection.prompt({
499
+ sessionId: taskRunId,
500
+ prompt: Array.isArray(content) ? content : [content],
501
+ });
502
+ }
503
+ }
504
+ }
505
+ }
506
+ catch (err) {
507
+ this.logger.warn("Interrupt polling error", { error: err });
508
+ }
509
+ }
510
+ };
511
+ // Start polling in background (don't await)
512
+ const pollingPromise = pollForInterrupts();
513
+ // Send initial prompt and wait for completion
514
+ this.logger.info("Sending initial prompt to agent");
515
+ const result = await clientConnection.prompt({
516
+ sessionId: taskRunId,
517
+ prompt: initialPrompt,
518
+ });
519
+ // Stop interrupt polling
520
+ isPolling = false;
521
+ await pollingPromise;
522
+ this.logger.info("Task execution complete", {
523
+ taskId: task.id,
524
+ stopReason: result.stopReason,
525
+ });
526
+ await this.sessionStore.complete(taskRunId);
527
+ }
528
+ catch (error) {
529
+ const errorMessage = error instanceof Error ? error.message : String(error);
530
+ this.logger.error("Cloud task execution failed", {
531
+ taskId: task.id,
532
+ error: errorMessage,
533
+ });
534
+ await this.sessionStore.fail(taskRunId, errorMessage);
535
+ throw error;
536
+ }
537
+ }
538
+ async ensurePullRequest(task, stepResults, sendNotification) {
363
539
  const latestRun = task.latest_run;
364
- const existingPr = latestRun?.output && typeof latestRun.output === 'object'
540
+ const existingPr = latestRun?.output && typeof latestRun.output === "object"
365
541
  ? latestRun.output.pr_url
366
542
  : null;
367
543
  if (existingPr) {
368
- this.logger.info('PR already exists, skipping creation', { taskId: task.id, prUrl: existingPr });
544
+ this.logger.info("PR already exists, skipping creation", {
545
+ taskId: task.id,
546
+ prUrl: existingPr,
547
+ });
369
548
  return;
370
549
  }
371
- const buildResult = stepResults['build'];
550
+ const buildResult = stepResults.build;
372
551
  if (!buildResult?.commitCreated) {
373
- this.logger.warn('Build step did not produce a commit; skipping PR creation', { taskId: task.id });
552
+ this.logger.warn("Build step did not produce a commit; skipping PR creation", { taskId: task.id });
374
553
  return;
375
554
  }
376
555
  const branchName = await this.gitManager.getCurrentBranch();
377
- const finalizeResult = stepResults['finalize'];
556
+ const finalizeResult = stepResults.finalize;
378
557
  const prBody = finalizeResult?.prBody;
379
- const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description ?? '', prBody);
380
- this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));
558
+ const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description ?? "", prBody);
559
+ await sendNotification(POSTHOG_NOTIFICATIONS.PR_CREATED, { prUrl });
381
560
  try {
382
561
  await this.attachPullRequestToTask(task.id, prUrl, branchName);
383
- this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });
562
+ this.logger.info("PR attached to task successfully", {
563
+ taskId: task.id,
564
+ prUrl,
565
+ });
384
566
  }
385
567
  catch (error) {
386
- this.logger.warn('Could not attach PR to task', {
568
+ this.logger.warn("Could not attach PR to task", {
387
569
  error: error instanceof Error ? error.message : String(error),
388
570
  });
389
571
  }
390
572
  }
391
- emitEvent(event) {
392
- if (this.debug && event.type !== 'token') {
393
- // Log all events except tokens (too verbose)
394
- this.logger.debug('Emitting event', { type: event.type, ts: event.ts });
395
- }
396
- const persistPromise = this.progressReporter.recordEvent(event);
397
- if (persistPromise && typeof persistPromise.then === 'function') {
398
- persistPromise.catch((error) => this.logger.debug('Failed to persist agent event', { message: error.message }));
399
- }
400
- this.onEvent?.(event);
401
- }
402
573
  }
403
574
 
404
575
  export { Agent };