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