@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.
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/_tslib.js +74 -0
- package/dist/_virtual/_tslib.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 +891 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +876 -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 +1128 -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 +668 -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 +473 -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 +24 -28
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +343 -172
- 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 +58 -0
- package/dist/src/session-store.d.ts.map +1 -0
- package/dist/src/session-store.js +206 -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 +808 -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 +1514 -0
- package/src/adapters/claude/mcp-server.ts +810 -0
- package/src/adapters/claude/tools.ts +616 -0
- package/src/adapters/claude/utils.ts +267 -0
- package/src/agent.ts +717 -441
- 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 +259 -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 +881 -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/dist/src/agent.js
CHANGED
|
@@ -1,82 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
|
43
|
+
headers.Authorization = `Bearer ${config.posthogApiKey}`;
|
|
42
44
|
}
|
|
43
45
|
const defaultMcpServers = {
|
|
44
46
|
posthog: {
|
|
45
|
-
type:
|
|
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({
|
|
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
|
-
|
|
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(
|
|
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 &&
|
|
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(
|
|
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(
|
|
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(
|
|
110
|
-
await this._configureLlmGateway();
|
|
111
|
-
const task =
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
133
|
-
|
|
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(
|
|
150
|
-
|
|
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(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
167
|
-
|
|
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
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
|
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(
|
|
203
|
-
this.logger.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
|
-
|
|
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(
|
|
260
|
+
throw new Error("PostHog API not configured. Cannot send notification to cloud task.");
|
|
214
261
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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(
|
|
270
|
+
this.logger.debug("Getting task files", { taskId });
|
|
228
271
|
const files = await this.fileManager.getTaskFiles(taskId);
|
|
229
|
-
this.logger.debug(
|
|
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(
|
|
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(
|
|
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(
|
|
282
|
-
if (!this.posthogAPI || !this.
|
|
283
|
-
const error = new Error(
|
|
284
|
-
this.logger.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.
|
|
294
|
-
this.logger.debug(
|
|
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(
|
|
298
|
-
if (!this.posthogAPI || !this.
|
|
299
|
-
const error = new Error(
|
|
300
|
-
this.logger.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.
|
|
304
|
-
|
|
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
|
|
310
|
-
if (execution.taskId === taskId && execution.status ===
|
|
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
|
|
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(
|
|
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
|
-
|
|
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}`, {
|
|
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(
|
|
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
|
|
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 ===
|
|
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(
|
|
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
|
|
550
|
+
const buildResult = stepResults.build;
|
|
372
551
|
if (!buildResult?.commitCreated) {
|
|
373
|
-
this.logger.warn(
|
|
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
|
|
556
|
+
const finalizeResult = stepResults.finalize;
|
|
378
557
|
const prBody = finalizeResult?.prBody;
|
|
379
|
-
const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description ??
|
|
380
|
-
|
|
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(
|
|
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(
|
|
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 };
|