@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.
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/additionalItems.js +4 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +4 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +4 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/allOf.js +4 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +4 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +4 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +4 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +4 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +4 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +4 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +4 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +4 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +4 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +4 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +4 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +4 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +4 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +4 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +4 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +4 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +4 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +4 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +4 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +4 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +4 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +4 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +4 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +4 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +4 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +4 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +4 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +4 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +4 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +4 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +4 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +4 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +4 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +4 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +4 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +4 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +4 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +4 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +4 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +4 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +4 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +4 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +4 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +4 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +4 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +4 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +4 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +4 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +4 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +4 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +4 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +4 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +4 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +4 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +4 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +4 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +4 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +4 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +4 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +4 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/claude-cli/cli.js +2294 -2146
- package/dist/example-client.d.ts +3 -0
- package/dist/example-client.d.ts.map +1 -0
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +610 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +875 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +66 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +23 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +331 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +717 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +221 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +56 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +440 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +94 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1610 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +91 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +133 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +136 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +3297 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +36 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +10 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +657 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +449 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +413 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +57 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +86 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +61 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +80 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +1307 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +842 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +335 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +8 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +51 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +69 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +169 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +712 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +157 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +140 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +253 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +40 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +25 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +162 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +29 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +183 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +30 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +64 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +213 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +49 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +544 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +139 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +95 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +639 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +31 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +254 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js +9 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +8 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +22 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +53 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +112 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +14 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +99 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +93 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +70 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +77 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +57 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +80 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +15 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +42 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +146 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +11 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +131 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +113 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +12 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +94 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +9 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +84 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +72 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +212 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +52 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +75 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/base.js +256 -0
- package/dist/node_modules/diff/libesm/diff/base.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/line.js +64 -0
- package/dist/node_modules/diff/libesm/diff/line.js.map +1 -0
- package/dist/node_modules/diff/libesm/patch/create.js +185 -0
- package/dist/node_modules/diff/libesm/patch/create.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +47 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +347 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +255 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +334 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +98 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/uuid/dist/rng.js +14 -0
- package/dist/node_modules/uuid/dist/rng.js.map +1 -0
- package/dist/node_modules/uuid/dist/stringify.js +29 -0
- package/dist/node_modules/uuid/dist/stringify.js.map +1 -0
- package/dist/node_modules/uuid/dist/v7.js +65 -0
- package/dist/node_modules/uuid/dist/v7.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +109 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +42 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +1 -0
- package/dist/package.json.js +8 -0
- package/dist/package.json.js.map +1 -0
- package/dist/src/acp-extensions.d.ts +91 -0
- package/dist/src/acp-extensions.d.ts.map +1 -0
- package/dist/src/acp-extensions.js +38 -0
- package/dist/src/acp-extensions.js.map +1 -0
- package/dist/src/adapters/claude/claude.d.ts +136 -0
- package/dist/src/adapters/claude/claude.d.ts.map +1 -0
- package/dist/src/adapters/claude/claude.js +1112 -0
- package/dist/src/adapters/claude/claude.js.map +1 -0
- package/dist/src/adapters/claude/mcp-server.d.ts +30 -0
- package/dist/src/adapters/claude/mcp-server.d.ts.map +1 -0
- package/dist/src/adapters/claude/mcp-server.js +655 -0
- package/dist/src/adapters/claude/mcp-server.js.map +1 -0
- package/dist/src/adapters/claude/tools.d.ts +35 -0
- package/dist/src/adapters/claude/tools.d.ts.map +1 -0
- package/dist/src/adapters/claude/tools.js +466 -0
- package/dist/src/adapters/claude/tools.js.map +1 -0
- package/dist/src/adapters/claude/utils.d.ts +48 -0
- package/dist/src/adapters/claude/utils.d.ts.map +1 -0
- package/dist/src/adapters/claude/utils.js +158 -0
- package/dist/src/adapters/claude/utils.js.map +1 -0
- package/dist/src/agent.d.ts +18 -28
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +195 -175
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/file-manager.d.ts +6 -6
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +72 -63
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +2 -1
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +105 -70
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +8 -14
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +35 -23
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +4 -4
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +129 -99
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/schemas.d.ts +980 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +196 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/session-store.d.ts +53 -0
- package/dist/src/session-store.d.ts.map +1 -0
- package/dist/src/session-store.js +195 -0
- package/dist/src/session-store.js.map +1 -0
- package/dist/src/task-manager.d.ts +7 -7
- package/dist/src/task-manager.d.ts.map +1 -1
- package/dist/src/task-manager.js +19 -18
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/template-manager.d.ts +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +30 -28
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/todo-manager.d.ts +5 -5
- package/dist/src/todo-manager.d.ts.map +1 -1
- package/dist/src/todo-manager.js +33 -24
- package/dist/src/todo-manager.js.map +1 -1
- package/dist/src/tools/registry.d.ts +1 -1
- package/dist/src/tools/registry.js +60 -60
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/types.d.ts +31 -31
- package/dist/src/types.d.ts +62 -167
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/logger.d.ts +14 -6
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +37 -22
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/utils/tapped-stream.d.ts +17 -0
- package/dist/src/utils/tapped-stream.d.ts.map +1 -0
- package/dist/src/utils/tapped-stream.js +45 -0
- package/dist/src/utils/tapped-stream.js.map +1 -0
- package/dist/src/workflow/config.d.ts +1 -1
- package/dist/src/workflow/config.d.ts.map +1 -1
- package/dist/src/workflow/config.js +18 -18
- package/dist/src/workflow/config.js.map +1 -1
- package/dist/src/workflow/steps/build.d.ts +1 -1
- package/dist/src/workflow/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +53 -39
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/finalize.d.ts +1 -1
- package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
- package/dist/src/workflow/steps/finalize.js +58 -52
- package/dist/src/workflow/steps/finalize.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +69 -47
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +86 -67
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/dist/src/workflow/types.d.ts +19 -14
- package/dist/src/workflow/types.d.ts.map +1 -1
- package/dist/src/workflow/utils.d.ts +1 -1
- package/dist/src/workflow/utils.d.ts.map +1 -1
- package/dist/src/workflow/utils.js +7 -4
- package/dist/src/workflow/utils.js.map +1 -1
- package/dist/src/worktree-manager.d.ts +39 -0
- package/dist/src/worktree-manager.d.ts.map +1 -0
- package/dist/src/worktree-manager.js +810 -0
- package/dist/src/worktree-manager.js.map +1 -0
- package/package.json +20 -16
- package/src/acp-extensions.ts +117 -0
- package/src/adapters/claude/claude.ts +1498 -0
- package/src/adapters/claude/mcp-server.ts +810 -0
- package/src/adapters/claude/tools.ts +609 -0
- package/src/adapters/claude/utils.ts +267 -0
- package/src/agent.ts +511 -447
- package/src/agents/execution.ts +1 -1
- package/src/agents/planning.ts +1 -1
- package/src/agents/research.ts +0 -1
- package/src/file-manager.ts +80 -70
- package/src/git-manager.ts +164 -88
- package/src/posthog-api.ts +155 -94
- package/src/prompt-builder.ts +196 -143
- package/src/schemas.ts +241 -0
- package/src/session-store.ts +244 -0
- package/src/task-manager.ts +41 -33
- package/src/template-manager.ts +98 -45
- package/src/todo-manager.ts +43 -32
- package/src/tools/registry.ts +62 -62
- package/src/tools/types.ts +36 -36
- package/src/types.ts +130 -239
- package/src/utils/logger.ts +89 -58
- package/src/utils/tapped-stream.ts +60 -0
- package/src/workflow/config.ts +48 -48
- package/src/workflow/steps/build.ts +127 -113
- package/src/workflow/steps/finalize.ts +207 -182
- package/src/workflow/steps/plan.ts +155 -130
- package/src/workflow/steps/research.ts +207 -187
- package/src/workflow/types.ts +47 -36
- package/src/workflow/utils.ts +37 -34
- package/src/worktree-manager.ts +884 -0
- package/dist/src/adapters/claude/claude-adapter.d.ts +0 -18
- package/dist/src/adapters/claude/claude-adapter.d.ts.map +0 -1
- package/dist/src/adapters/claude/claude-adapter.js +0 -311
- package/dist/src/adapters/claude/claude-adapter.js.map +0 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts +0 -19
- package/dist/src/adapters/claude/tool-mapper.d.ts.map +0 -1
- package/dist/src/adapters/claude/tool-mapper.js +0 -44
- package/dist/src/adapters/claude/tool-mapper.js.map +0 -1
- package/dist/src/adapters/types.d.ts +0 -33
- package/dist/src/adapters/types.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.d.ts +0 -43
- package/dist/src/task-progress-reporter.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.js +0 -393
- package/dist/src/task-progress-reporter.js.map +0 -1
- package/src/adapters/claude/claude-adapter.ts +0 -338
- package/src/adapters/claude/tool-mapper.ts +0 -46
- package/src/adapters/types.ts +0 -37
- package/src/task-progress-reporter.ts +0 -443
package/src/agent.ts
CHANGED
|
@@ -1,322 +1,338 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
239
|
-
|
|
135
|
+
private getOrCreateConnection(): InProcessAcpConnection {
|
|
136
|
+
if (!this.acpConnection) {
|
|
137
|
+
this.acpConnection = createAcpConnection({
|
|
138
|
+
sessionStore: this.sessionStore,
|
|
139
|
+
});
|
|
240
140
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
-
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
task.title,
|
|
462
|
-
task.description ?? '',
|
|
463
|
-
prBody
|
|
464
|
-
);
|
|
487
|
+
if (resolvedGatewayUrl) {
|
|
488
|
+
process.env.OPENAI_BASE_URL = resolvedGatewayUrl;
|
|
489
|
+
}
|
|
465
490
|
|
|
466
|
-
|
|
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
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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 {
|
|
494
|
-
|
|
552
|
+
export type {
|
|
553
|
+
AgentConfig,
|
|
554
|
+
ExecutionResult,
|
|
555
|
+
SupportingFile,
|
|
556
|
+
Task,
|
|
557
|
+
} from "./types.js";
|
|
558
|
+
export { PermissionMode } from "./types.js";
|