@posthog/agent 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +33 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/additionalItems.js +4 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +4 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +4 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/allOf.js +4 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +4 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +4 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +4 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +4 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +4 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +4 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +4 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +4 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +4 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +4 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +4 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +4 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +4 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +4 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +4 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +4 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +4 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +4 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +4 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +4 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +4 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +4 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +4 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +4 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +4 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +4 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +4 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +4 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +4 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +4 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +4 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +4 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +4 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +4 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +4 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +4 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +4 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +4 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +4 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +4 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +4 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +4 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +4 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +4 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +4 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +4 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +4 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +4 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +4 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +4 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +4 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +4 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +4 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +4 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +4 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +4 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +4 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +4 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +4 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +4 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/claude-cli/cli.js +2294 -2146
- package/dist/example-client.d.ts +3 -0
- package/dist/example-client.d.ts.map +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +610 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +875 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +66 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +23 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +331 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +717 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +221 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +56 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +440 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +94 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1610 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +91 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +133 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +136 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +3297 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +36 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +10 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +657 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +449 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +413 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +57 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +86 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +61 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +80 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +1307 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +842 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +335 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +8 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +51 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +69 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +169 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +712 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +157 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +140 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +253 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +40 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +25 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +162 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +29 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +183 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +30 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +64 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +213 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +49 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +544 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +139 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +95 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +639 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +31 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +254 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js +9 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +8 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +22 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +53 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +112 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +14 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +99 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +93 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +70 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +77 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +57 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +80 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +15 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +42 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +146 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +11 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +131 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +113 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +12 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +94 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +9 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +84 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +72 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +212 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +52 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +75 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/base.js +256 -0
- package/dist/node_modules/diff/libesm/diff/base.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/line.js +64 -0
- package/dist/node_modules/diff/libesm/diff/line.js.map +1 -0
- package/dist/node_modules/diff/libesm/patch/create.js +185 -0
- package/dist/node_modules/diff/libesm/patch/create.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +47 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +347 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +255 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +334 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +98 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/uuid/dist/rng.js +14 -0
- package/dist/node_modules/uuid/dist/rng.js.map +1 -0
- package/dist/node_modules/uuid/dist/stringify.js +29 -0
- package/dist/node_modules/uuid/dist/stringify.js.map +1 -0
- package/dist/node_modules/uuid/dist/v7.js +65 -0
- package/dist/node_modules/uuid/dist/v7.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +109 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +42 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +1 -0
- package/dist/package.json.js +8 -0
- package/dist/package.json.js.map +1 -0
- package/dist/src/acp-extensions.d.ts +91 -0
- package/dist/src/acp-extensions.d.ts.map +1 -0
- package/dist/src/acp-extensions.js +38 -0
- package/dist/src/acp-extensions.js.map +1 -0
- package/dist/src/adapters/claude/claude.d.ts +136 -0
- package/dist/src/adapters/claude/claude.d.ts.map +1 -0
- package/dist/src/adapters/claude/claude.js +1112 -0
- package/dist/src/adapters/claude/claude.js.map +1 -0
- package/dist/src/adapters/claude/mcp-server.d.ts +30 -0
- package/dist/src/adapters/claude/mcp-server.d.ts.map +1 -0
- package/dist/src/adapters/claude/mcp-server.js +655 -0
- package/dist/src/adapters/claude/mcp-server.js.map +1 -0
- package/dist/src/adapters/claude/tools.d.ts +35 -0
- package/dist/src/adapters/claude/tools.d.ts.map +1 -0
- package/dist/src/adapters/claude/tools.js +466 -0
- package/dist/src/adapters/claude/tools.js.map +1 -0
- package/dist/src/adapters/claude/utils.d.ts +48 -0
- package/dist/src/adapters/claude/utils.d.ts.map +1 -0
- package/dist/src/adapters/claude/utils.js +158 -0
- package/dist/src/adapters/claude/utils.js.map +1 -0
- package/dist/src/agent.d.ts +15 -25
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +118 -156
- package/dist/src/agent.js.map +1 -1
- package/dist/src/file-manager.d.ts +2 -2
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +13 -5
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +1 -0
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +18 -0
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +8 -13
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +14 -2
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +2 -2
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +7 -7
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/schemas.d.ts +980 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +196 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/session-store.d.ts +53 -0
- package/dist/src/session-store.d.ts.map +1 -0
- package/dist/src/session-store.js +195 -0
- package/dist/src/session-store.js.map +1 -0
- package/dist/src/task-manager.d.ts +3 -3
- package/dist/src/task-manager.d.ts.map +1 -1
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +6 -6
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/todo-manager.d.ts +2 -2
- package/dist/src/todo-manager.d.ts.map +1 -1
- package/dist/src/todo-manager.js +5 -1
- package/dist/src/todo-manager.js.map +1 -1
- package/dist/src/types.d.ts +54 -159
- 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 +10 -2
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +35 -20
- 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/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +15 -9
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
- package/dist/src/workflow/steps/finalize.js +4 -4
- package/dist/src/workflow/steps/finalize.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +22 -12
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +33 -26
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/dist/src/workflow/types.d.ts +10 -5
- package/dist/src/workflow/types.d.ts.map +1 -1
- package/dist/src/worktree-manager.d.ts +39 -0
- package/dist/src/worktree-manager.d.ts.map +1 -0
- package/dist/src/worktree-manager.js +810 -0
- package/dist/src/worktree-manager.js.map +1 -0
- package/package.json +19 -15
- package/src/acp-extensions.ts +117 -0
- package/src/adapters/claude/claude.ts +1498 -0
- package/src/adapters/claude/mcp-server.ts +810 -0
- package/src/adapters/claude/tools.ts +609 -0
- package/src/adapters/claude/utils.ts +267 -0
- package/src/agent.ts +151 -222
- package/src/file-manager.ts +16 -7
- package/src/git-manager.ts +20 -0
- package/src/posthog-api.ts +38 -17
- package/src/prompt-builder.ts +23 -15
- package/src/schemas.ts +241 -0
- package/src/session-store.ts +244 -0
- package/src/task-manager.ts +3 -3
- package/src/template-manager.ts +8 -8
- package/src/todo-manager.ts +9 -3
- package/src/types.ts +79 -210
- package/src/utils/logger.ts +47 -22
- package/src/utils/tapped-stream.ts +60 -0
- package/src/workflow/steps/build.ts +16 -11
- package/src/workflow/steps/finalize.ts +4 -11
- package/src/workflow/steps/plan.ts +24 -19
- package/src/workflow/steps/research.ts +34 -33
- package/src/workflow/types.ts +14 -5
- package/src/worktree-manager.ts +884 -0
- package/dist/src/adapters/claude/claude-adapter.d.ts +0 -18
- package/dist/src/adapters/claude/claude-adapter.d.ts.map +0 -1
- package/dist/src/adapters/claude/claude-adapter.js +0 -356
- 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 -42
- package/dist/src/task-progress-reporter.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.js +0 -398
- package/dist/src/task-progress-reporter.js.map +0 -1
- package/src/adapters/claude/claude-adapter.ts +0 -390
- package/src/adapters/claude/tool-mapper.ts +0 -46
- package/src/adapters/types.ts +0 -37
- package/src/task-progress-reporter.ts +0 -454
package/src/agent.ts
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { POSTHOG_NOTIFICATIONS } from "./acp-extensions.js";
|
|
2
|
+
import {
|
|
3
|
+
createAcpConnection,
|
|
4
|
+
type InProcessAcpConnection,
|
|
5
|
+
} from "./adapters/claude/claude.js";
|
|
4
6
|
import { PostHogFileManager } from "./file-manager.js";
|
|
5
7
|
import { GitManager } from "./git-manager.js";
|
|
6
8
|
import { PostHogAPIClient } from "./posthog-api.js";
|
|
7
9
|
import { PromptBuilder } from "./prompt-builder.js";
|
|
10
|
+
import { SessionStore } from "./session-store.js";
|
|
8
11
|
import { TaskManager } from "./task-manager.js";
|
|
9
|
-
import { TaskProgressReporter } from "./task-progress-reporter.js";
|
|
10
12
|
import { TemplateManager } from "./template-manager.js";
|
|
11
|
-
import type {
|
|
12
|
-
AgentConfig,
|
|
13
|
-
CanUseTool,
|
|
14
|
-
ExecutionResult,
|
|
15
|
-
Task,
|
|
16
|
-
} from "./types.js";
|
|
13
|
+
import type { AgentConfig, CanUseTool, Task } from "./types.js";
|
|
17
14
|
import { Logger } from "./utils/logger.js";
|
|
18
15
|
import { TASK_WORKFLOW } from "./workflow/config.js";
|
|
19
|
-
import type { WorkflowRuntime } from "./workflow/types.js";
|
|
16
|
+
import type { SendNotification, WorkflowRuntime } from "./workflow/types.js";
|
|
20
17
|
|
|
21
18
|
export class Agent {
|
|
22
19
|
private workingDirectory: string;
|
|
23
|
-
private onEvent?: (event: any) => void;
|
|
24
20
|
private taskManager: TaskManager;
|
|
25
21
|
private posthogAPI?: PostHogAPIClient;
|
|
26
22
|
private fileManager: PostHogFileManager;
|
|
27
23
|
private gitManager: GitManager;
|
|
28
24
|
private templateManager: TemplateManager;
|
|
29
|
-
private adapter: ProviderAdapter;
|
|
30
25
|
private logger: Logger;
|
|
31
|
-
private
|
|
26
|
+
private acpConnection?: InProcessAcpConnection;
|
|
32
27
|
private promptBuilder: PromptBuilder;
|
|
33
28
|
private mcpServers?: Record<string, any>;
|
|
34
29
|
private canUseTool?: CanUseTool;
|
|
30
|
+
private currentRunId?: string;
|
|
31
|
+
private sessionStore?: SessionStore;
|
|
35
32
|
public debug: boolean;
|
|
36
33
|
|
|
37
34
|
constructor(config: AgentConfig) {
|
|
38
35
|
this.workingDirectory = config.workingDirectory || process.cwd();
|
|
39
|
-
this.onEvent = config.onEvent;
|
|
40
36
|
this.canUseTool = config.canUseTool;
|
|
41
37
|
this.debug = config.debug || false;
|
|
42
38
|
|
|
@@ -65,10 +61,12 @@ export class Agent {
|
|
|
65
61
|
...defaultMcpServers,
|
|
66
62
|
...config.mcpServers,
|
|
67
63
|
};
|
|
68
|
-
this.logger = new Logger({
|
|
64
|
+
this.logger = new Logger({
|
|
65
|
+
debug: this.debug,
|
|
66
|
+
prefix: "[PostHog Agent]",
|
|
67
|
+
onLog: config.onLog,
|
|
68
|
+
});
|
|
69
69
|
this.taskManager = new TaskManager();
|
|
70
|
-
// Hardcode Claude adapter for now - extensible for other providers later
|
|
71
|
-
this.adapter = new ClaudeAdapter();
|
|
72
70
|
|
|
73
71
|
this.fileManager = new PostHogFileManager(
|
|
74
72
|
this.workingDirectory,
|
|
@@ -77,16 +75,25 @@ export class Agent {
|
|
|
77
75
|
this.gitManager = new GitManager({
|
|
78
76
|
repositoryPath: this.workingDirectory,
|
|
79
77
|
logger: this.logger.child("GitManager"),
|
|
80
|
-
// TODO: Add author config from environment or config
|
|
81
78
|
});
|
|
82
79
|
this.templateManager = new TemplateManager();
|
|
83
80
|
|
|
84
|
-
if (
|
|
81
|
+
if (
|
|
82
|
+
config.posthogApiUrl &&
|
|
83
|
+
config.posthogApiKey &&
|
|
84
|
+
config.posthogProjectId
|
|
85
|
+
) {
|
|
85
86
|
this.posthogAPI = new PostHogAPIClient({
|
|
86
87
|
apiUrl: config.posthogApiUrl,
|
|
87
88
|
apiKey: config.posthogApiKey,
|
|
88
89
|
projectId: config.posthogProjectId,
|
|
89
90
|
});
|
|
91
|
+
|
|
92
|
+
// Create SessionStore from the API client for ACP connection
|
|
93
|
+
this.sessionStore = new SessionStore(
|
|
94
|
+
this.posthogAPI,
|
|
95
|
+
this.logger.child("SessionStore"),
|
|
96
|
+
);
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
this.promptBuilder = new PromptBuilder({
|
|
@@ -95,10 +102,6 @@ export class Agent {
|
|
|
95
102
|
posthogClient: this.posthogAPI,
|
|
96
103
|
logger: this.logger.child("PromptBuilder"),
|
|
97
104
|
});
|
|
98
|
-
this.progressReporter = new TaskProgressReporter(
|
|
99
|
-
this.posthogAPI,
|
|
100
|
-
this.logger,
|
|
101
|
-
);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
/**
|
|
@@ -120,54 +123,68 @@ export class Agent {
|
|
|
120
123
|
try {
|
|
121
124
|
const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();
|
|
122
125
|
const apiKey = this.posthogAPI.getApiKey();
|
|
123
|
-
|
|
124
126
|
process.env.ANTHROPIC_BASE_URL = gatewayUrl;
|
|
125
127
|
process.env.ANTHROPIC_AUTH_TOKEN = apiKey;
|
|
126
128
|
this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);
|
|
127
|
-
|
|
128
|
-
this.logger.debug("Configured LLM gateway", { gatewayUrl });
|
|
129
129
|
} catch (error) {
|
|
130
130
|
this.logger.error("Failed to configure LLM gateway", error);
|
|
131
131
|
throw error;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
private getOrCreateConnection(): InProcessAcpConnection {
|
|
136
|
+
if (!this.acpConnection) {
|
|
137
|
+
this.acpConnection = createAcpConnection({
|
|
138
|
+
sessionStore: this.sessionStore,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return this.acpConnection;
|
|
142
|
+
}
|
|
143
|
+
|
|
135
144
|
// Adaptive task execution orchestrated via workflow steps
|
|
136
145
|
async runTask(
|
|
137
|
-
|
|
146
|
+
taskId: string,
|
|
147
|
+
taskRunId: string,
|
|
138
148
|
options: import("./types.js").TaskExecutionOptions = {},
|
|
139
149
|
): Promise<void> {
|
|
140
|
-
await this._configureLlmGateway();
|
|
150
|
+
// await this._configureLlmGateway();
|
|
141
151
|
|
|
142
|
-
const task =
|
|
143
|
-
typeof taskOrId === "string" ? await this.fetchTask(taskOrId) : taskOrId;
|
|
152
|
+
const task = await this.fetchTask(taskId);
|
|
144
153
|
const cwd = options.repositoryPath || this.workingDirectory;
|
|
145
154
|
const isCloudMode = options.isCloudMode ?? false;
|
|
146
155
|
const taskSlug = (task as any).slug || task.id;
|
|
147
156
|
|
|
157
|
+
// Use taskRunId as sessionId - they are the same identifier
|
|
158
|
+
this.currentRunId = taskRunId;
|
|
159
|
+
|
|
148
160
|
this.logger.info("Starting adaptive task execution", {
|
|
149
161
|
taskId: task.id,
|
|
150
162
|
taskSlug,
|
|
163
|
+
taskRunId,
|
|
151
164
|
isCloudMode,
|
|
152
165
|
});
|
|
153
166
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
const connection = this.getOrCreateConnection();
|
|
168
|
+
|
|
169
|
+
// Create sendNotification using ACP connection's extNotification
|
|
170
|
+
const sendNotification: SendNotification = async (method, params) => {
|
|
171
|
+
this.logger.debug(`Notification: ${method}`, params);
|
|
172
|
+
await connection.agentConnection.extNotification?.(method, params);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
|
|
176
|
+
sessionId: taskRunId,
|
|
177
|
+
runId: taskRunId,
|
|
157
178
|
});
|
|
158
|
-
this.emitEvent(
|
|
159
|
-
this.adapter.createStatusEvent("run_started", {
|
|
160
|
-
runId: this.progressReporter.runId,
|
|
161
|
-
}),
|
|
162
|
-
);
|
|
163
179
|
|
|
164
|
-
await this.prepareTaskBranch(taskSlug, isCloudMode);
|
|
180
|
+
await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
|
|
165
181
|
|
|
166
182
|
let taskError: Error | undefined;
|
|
167
183
|
try {
|
|
168
184
|
const workflowContext: WorkflowRuntime = {
|
|
169
185
|
task,
|
|
170
186
|
taskSlug,
|
|
187
|
+
runId: taskRunId,
|
|
171
188
|
cwd,
|
|
172
189
|
isCloudMode,
|
|
173
190
|
options,
|
|
@@ -175,11 +192,11 @@ export class Agent {
|
|
|
175
192
|
fileManager: this.fileManager,
|
|
176
193
|
gitManager: this.gitManager,
|
|
177
194
|
promptBuilder: this.promptBuilder,
|
|
178
|
-
|
|
179
|
-
|
|
195
|
+
connection: connection.agentConnection,
|
|
196
|
+
sessionId: taskRunId,
|
|
197
|
+
sendNotification,
|
|
180
198
|
mcpServers: this.mcpServers,
|
|
181
199
|
posthogAPI: this.posthogAPI,
|
|
182
|
-
emitEvent: (event: any) => this.emitEvent(event),
|
|
183
200
|
stepResults: {},
|
|
184
201
|
};
|
|
185
202
|
|
|
@@ -192,83 +209,95 @@ export class Agent {
|
|
|
192
209
|
|
|
193
210
|
const shouldCreatePR = options.createPR ?? isCloudMode;
|
|
194
211
|
if (shouldCreatePR) {
|
|
195
|
-
await this.ensurePullRequest(
|
|
212
|
+
await this.ensurePullRequest(
|
|
213
|
+
task,
|
|
214
|
+
workflowContext.stepResults,
|
|
215
|
+
sendNotification,
|
|
216
|
+
);
|
|
196
217
|
}
|
|
197
218
|
|
|
198
219
|
this.logger.info("Task execution complete", { taskId: task.id });
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
220
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.TASK_COMPLETE, {
|
|
221
|
+
sessionId: taskRunId,
|
|
222
|
+
taskId: task.id,
|
|
223
|
+
});
|
|
202
224
|
} catch (error) {
|
|
203
225
|
taskError = error instanceof Error ? error : new Error(String(error));
|
|
204
226
|
this.logger.error("Task execution failed", {
|
|
205
227
|
taskId: task.id,
|
|
206
228
|
error: taskError.message,
|
|
207
229
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
} else {
|
|
214
|
-
await this.progressReporter.complete();
|
|
215
|
-
}
|
|
230
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
|
|
231
|
+
sessionId: taskRunId,
|
|
232
|
+
message: taskError.message,
|
|
233
|
+
});
|
|
234
|
+
throw taskError;
|
|
216
235
|
}
|
|
217
236
|
}
|
|
218
237
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Creates an in-process ACP connection for client communication.
|
|
240
|
+
* Sets up git branch for the task, configures LLM gateway.
|
|
241
|
+
* The client handles all prompting/querying via the returned streams.
|
|
242
|
+
*
|
|
243
|
+
* @returns InProcessAcpConnection with clientStreams for the client to use
|
|
244
|
+
*/
|
|
245
|
+
async runTaskV2(
|
|
246
|
+
taskId: string,
|
|
247
|
+
taskRunId: string,
|
|
248
|
+
options: import("./types.js").TaskExecutionOptions = {},
|
|
249
|
+
): Promise<InProcessAcpConnection> {
|
|
229
250
|
await this._configureLlmGateway();
|
|
230
|
-
const baseOptions: Record<string, any> = {
|
|
231
|
-
model: "claude-sonnet-4-5-20250929",
|
|
232
|
-
cwd: options.repositoryPath || this.workingDirectory,
|
|
233
|
-
permissionMode: (options.permissionMode as any) || "default",
|
|
234
|
-
settingSources: ["local"],
|
|
235
|
-
mcpServers: this.mcpServers,
|
|
236
|
-
};
|
|
237
251
|
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
252
|
+
const task = await this.fetchTask(taskId);
|
|
253
|
+
const taskSlug = (task as any).slug || task.id;
|
|
254
|
+
const isCloudMode = options.isCloudMode ?? false;
|
|
255
|
+
const _cwd = options.repositoryPath || this.workingDirectory;
|
|
256
|
+
|
|
257
|
+
// Use taskRunId as sessionId - they are the same identifier
|
|
258
|
+
this.currentRunId = taskRunId;
|
|
243
259
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
260
|
+
this.acpConnection = createAcpConnection({
|
|
261
|
+
sessionStore: this.sessionStore,
|
|
262
|
+
sessionId: taskRunId,
|
|
263
|
+
taskId: task.id,
|
|
247
264
|
});
|
|
248
265
|
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
266
|
+
const sendNotification: SendNotification = async (method, params) => {
|
|
267
|
+
this.logger.debug(`Notification: ${method}`, params);
|
|
268
|
+
await this.acpConnection?.agentConnection.extNotification?.(
|
|
269
|
+
method,
|
|
270
|
+
params,
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {
|
|
275
|
+
sessionId: taskRunId,
|
|
276
|
+
runId: taskRunId,
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
if (!options.skipGitBranch) {
|
|
280
|
+
try {
|
|
281
|
+
await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);
|
|
282
|
+
} catch (error) {
|
|
283
|
+
const errorMessage =
|
|
284
|
+
error instanceof Error ? error.message : String(error);
|
|
285
|
+
this.logger.error("Failed to prepare task branch", {
|
|
286
|
+
error: errorMessage,
|
|
287
|
+
});
|
|
288
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {
|
|
289
|
+
sessionId: taskRunId,
|
|
290
|
+
message: errorMessage,
|
|
291
|
+
});
|
|
292
|
+
throw error;
|
|
260
293
|
}
|
|
261
|
-
} catch (error) {
|
|
262
|
-
this.logger.error("Error during direct run", error);
|
|
263
|
-
throw error;
|
|
264
294
|
}
|
|
265
295
|
|
|
266
|
-
return
|
|
296
|
+
return this.acpConnection;
|
|
267
297
|
}
|
|
268
298
|
|
|
269
299
|
// PostHog task operations
|
|
270
300
|
async fetchTask(taskId: string): Promise<Task> {
|
|
271
|
-
this.logger.debug("Fetching task from PostHog", { taskId });
|
|
272
301
|
if (!this.posthogAPI) {
|
|
273
302
|
const error = new Error(
|
|
274
303
|
"PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.",
|
|
@@ -283,44 +312,6 @@ export class Agent {
|
|
|
283
312
|
return this.posthogAPI;
|
|
284
313
|
}
|
|
285
314
|
|
|
286
|
-
async listTasks(filters?: {
|
|
287
|
-
repository?: string;
|
|
288
|
-
organization?: string;
|
|
289
|
-
origin_product?: string;
|
|
290
|
-
}): Promise<Task[]> {
|
|
291
|
-
if (!this.posthogAPI) {
|
|
292
|
-
throw new Error(
|
|
293
|
-
"PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.",
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
return this.posthogAPI.listTasks(filters);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// File system operations for task artifacts
|
|
300
|
-
async writeTaskFile(
|
|
301
|
-
taskId: string,
|
|
302
|
-
fileName: string,
|
|
303
|
-
content: string,
|
|
304
|
-
type: "plan" | "context" | "reference" | "output" = "reference",
|
|
305
|
-
): Promise<void> {
|
|
306
|
-
this.logger.debug("Writing task file", {
|
|
307
|
-
taskId,
|
|
308
|
-
fileName,
|
|
309
|
-
type,
|
|
310
|
-
contentLength: content.length,
|
|
311
|
-
});
|
|
312
|
-
await this.fileManager.writeTaskFile(taskId, {
|
|
313
|
-
name: fileName,
|
|
314
|
-
content,
|
|
315
|
-
type,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
async readTaskFile(taskId: string, fileName: string): Promise<string | null> {
|
|
320
|
-
this.logger.debug("Reading task file", { taskId, fileName });
|
|
321
|
-
return await this.fileManager.readTaskFile(taskId, fileName);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
315
|
async getTaskFiles(taskId: string): Promise<any[]> {
|
|
325
316
|
this.logger.debug("Getting task files", { taskId });
|
|
326
317
|
const files = await this.fileManager.getTaskFiles(taskId);
|
|
@@ -328,62 +319,6 @@ export class Agent {
|
|
|
328
319
|
return files;
|
|
329
320
|
}
|
|
330
321
|
|
|
331
|
-
async writePlan(taskId: string, plan: string): Promise<void> {
|
|
332
|
-
this.logger.info("Writing plan", { taskId, planLength: plan.length });
|
|
333
|
-
await this.fileManager.writePlan(taskId, plan);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
async readPlan(taskId: string): Promise<string | null> {
|
|
337
|
-
this.logger.debug("Reading plan", { taskId });
|
|
338
|
-
return await this.fileManager.readPlan(taskId);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Git operations for task execution
|
|
342
|
-
async createPlanningBranch(taskId: string): Promise<string> {
|
|
343
|
-
this.logger.info("Creating planning branch", { taskId });
|
|
344
|
-
const branchName = await this.gitManager.createTaskPlanningBranch(taskId);
|
|
345
|
-
this.logger.debug("Planning branch created", { taskId, branchName });
|
|
346
|
-
return branchName;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
async commitPlan(taskId: string, taskTitle: string): Promise<string> {
|
|
350
|
-
this.logger.info("Committing plan", { taskId, taskTitle });
|
|
351
|
-
const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);
|
|
352
|
-
this.logger.debug("Plan committed", { taskId, commitHash });
|
|
353
|
-
return commitHash;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
async createImplementationBranch(
|
|
357
|
-
taskId: string,
|
|
358
|
-
planningBranchName?: string,
|
|
359
|
-
): Promise<string> {
|
|
360
|
-
this.logger.info("Creating implementation branch", {
|
|
361
|
-
taskId,
|
|
362
|
-
fromBranch: planningBranchName,
|
|
363
|
-
});
|
|
364
|
-
const branchName = await this.gitManager.createTaskImplementationBranch(
|
|
365
|
-
taskId,
|
|
366
|
-
planningBranchName,
|
|
367
|
-
);
|
|
368
|
-
this.logger.debug("Implementation branch created", { taskId, branchName });
|
|
369
|
-
return branchName;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
async commitImplementation(
|
|
373
|
-
taskId: string,
|
|
374
|
-
taskTitle: string,
|
|
375
|
-
planSummary?: string,
|
|
376
|
-
): Promise<string> {
|
|
377
|
-
this.logger.info("Committing implementation", { taskId, taskTitle });
|
|
378
|
-
const commitHash = await this.gitManager.commitImplementation(
|
|
379
|
-
taskId,
|
|
380
|
-
taskTitle,
|
|
381
|
-
planSummary,
|
|
382
|
-
);
|
|
383
|
-
this.logger.debug("Implementation committed", { taskId, commitHash });
|
|
384
|
-
return commitHash;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
322
|
async createPullRequest(
|
|
388
323
|
taskId: string,
|
|
389
324
|
branchName: string,
|
|
@@ -424,7 +359,7 @@ Generated by PostHog Agent`;
|
|
|
424
359
|
): Promise<void> {
|
|
425
360
|
this.logger.info("Attaching PR to task run", { taskId, prUrl, branchName });
|
|
426
361
|
|
|
427
|
-
if (!this.posthogAPI || !this.
|
|
362
|
+
if (!this.posthogAPI || !this.currentRunId) {
|
|
428
363
|
const error = new Error(
|
|
429
364
|
"PostHog API not configured or no active run. Cannot attach PR to task.",
|
|
430
365
|
);
|
|
@@ -439,14 +374,10 @@ Generated by PostHog Agent`;
|
|
|
439
374
|
updates.branch = branchName;
|
|
440
375
|
}
|
|
441
376
|
|
|
442
|
-
await this.posthogAPI.updateTaskRun(
|
|
443
|
-
taskId,
|
|
444
|
-
this.progressReporter.runId,
|
|
445
|
-
updates,
|
|
446
|
-
);
|
|
377
|
+
await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, updates);
|
|
447
378
|
this.logger.debug("PR attached to task run", {
|
|
448
379
|
taskId,
|
|
449
|
-
runId: this.
|
|
380
|
+
runId: this.currentRunId,
|
|
450
381
|
prUrl,
|
|
451
382
|
});
|
|
452
383
|
}
|
|
@@ -454,7 +385,7 @@ Generated by PostHog Agent`;
|
|
|
454
385
|
async updateTaskBranch(taskId: string, branchName: string): Promise<void> {
|
|
455
386
|
this.logger.info("Updating task run branch", { taskId, branchName });
|
|
456
387
|
|
|
457
|
-
if (!this.posthogAPI || !this.
|
|
388
|
+
if (!this.posthogAPI || !this.currentRunId) {
|
|
458
389
|
const error = new Error(
|
|
459
390
|
"PostHog API not configured or no active run. Cannot update branch.",
|
|
460
391
|
);
|
|
@@ -462,12 +393,12 @@ Generated by PostHog Agent`;
|
|
|
462
393
|
throw error;
|
|
463
394
|
}
|
|
464
395
|
|
|
465
|
-
await this.posthogAPI.updateTaskRun(taskId, this.
|
|
396
|
+
await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, {
|
|
466
397
|
branch: branchName,
|
|
467
398
|
});
|
|
468
399
|
this.logger.debug("Task run branch updated", {
|
|
469
400
|
taskId,
|
|
470
|
-
runId: this.
|
|
401
|
+
runId: this.currentRunId,
|
|
471
402
|
branchName,
|
|
472
403
|
});
|
|
473
404
|
}
|
|
@@ -496,6 +427,7 @@ Generated by PostHog Agent`;
|
|
|
496
427
|
private async prepareTaskBranch(
|
|
497
428
|
taskSlug: string,
|
|
498
429
|
isCloudMode: boolean,
|
|
430
|
+
sendNotification: SendNotification,
|
|
499
431
|
): Promise<void> {
|
|
500
432
|
if (await this.gitManager.hasChanges()) {
|
|
501
433
|
throw new Error(
|
|
@@ -503,16 +435,28 @@ Generated by PostHog Agent`;
|
|
|
503
435
|
);
|
|
504
436
|
}
|
|
505
437
|
|
|
438
|
+
// If we're running in a worktree, we're already on the correct branch
|
|
439
|
+
// (the worktree was created with its own branch). Skip branch creation.
|
|
440
|
+
const isWorktree = await this.gitManager.isWorktree();
|
|
441
|
+
if (isWorktree) {
|
|
442
|
+
const currentBranch = await this.gitManager.getCurrentBranch();
|
|
443
|
+
this.logger.info("Running in worktree, using existing branch", {
|
|
444
|
+
branch: currentBranch,
|
|
445
|
+
});
|
|
446
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
|
|
447
|
+
branch: currentBranch,
|
|
448
|
+
});
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
506
452
|
await this.gitManager.resetToDefaultBranchIfNeeded();
|
|
507
453
|
|
|
508
454
|
const existingBranch = await this.gitManager.getTaskBranch(taskSlug);
|
|
509
455
|
if (!existingBranch) {
|
|
510
456
|
const branchName = await this.gitManager.createTaskBranch(taskSlug);
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}),
|
|
515
|
-
);
|
|
457
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {
|
|
458
|
+
branch: branchName,
|
|
459
|
+
});
|
|
516
460
|
|
|
517
461
|
await this.gitManager.addAllPostHogFiles();
|
|
518
462
|
|
|
@@ -552,6 +496,7 @@ Generated by PostHog Agent`;
|
|
|
552
496
|
private async ensurePullRequest(
|
|
553
497
|
task: Task,
|
|
554
498
|
stepResults: Record<string, any>,
|
|
499
|
+
sendNotification: SendNotification,
|
|
555
500
|
): Promise<void> {
|
|
556
501
|
const latestRun = task.latest_run;
|
|
557
502
|
const existingPr =
|
|
@@ -588,7 +533,7 @@ Generated by PostHog Agent`;
|
|
|
588
533
|
prBody,
|
|
589
534
|
);
|
|
590
535
|
|
|
591
|
-
|
|
536
|
+
await sendNotification(POSTHOG_NOTIFICATIONS.PR_CREATED, { prUrl });
|
|
592
537
|
|
|
593
538
|
try {
|
|
594
539
|
await this.attachPullRequestToTask(task.id, prUrl, branchName);
|
|
@@ -602,22 +547,6 @@ Generated by PostHog Agent`;
|
|
|
602
547
|
});
|
|
603
548
|
}
|
|
604
549
|
}
|
|
605
|
-
|
|
606
|
-
private emitEvent(event: any): void {
|
|
607
|
-
if (this.debug && event.type !== "token") {
|
|
608
|
-
// Log all events except tokens (too verbose)
|
|
609
|
-
this.logger.debug("Emitting event", { type: event.type, ts: event.ts });
|
|
610
|
-
}
|
|
611
|
-
const persistPromise = this.progressReporter.recordEvent(event);
|
|
612
|
-
if (persistPromise && typeof persistPromise.then === "function") {
|
|
613
|
-
persistPromise.catch((error: Error) =>
|
|
614
|
-
this.logger.debug("Failed to persist agent event", {
|
|
615
|
-
message: error.message,
|
|
616
|
-
}),
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
this.onEvent?.(event);
|
|
620
|
-
}
|
|
621
550
|
}
|
|
622
551
|
|
|
623
552
|
export type {
|
package/src/file-manager.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import { extname, join } from "node:path";
|
|
3
|
+
import z from "zod";
|
|
3
4
|
import type { ResearchEvaluation, SupportingFile } from "./types.js";
|
|
4
5
|
import { Logger } from "./utils/logger.js";
|
|
5
6
|
|
|
@@ -194,27 +195,35 @@ export class PostHogFileManager {
|
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
async writeTodos(taskId: string, data:
|
|
198
|
+
async writeTodos(taskId: string, data: unknown): Promise<void> {
|
|
199
|
+
const todos = z.object({
|
|
200
|
+
metadata: z.object({
|
|
201
|
+
total: z.number(),
|
|
202
|
+
completed: z.number(),
|
|
203
|
+
}),
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const validatedData = todos.parse(data);
|
|
198
207
|
this.logger.debug("Writing todos", {
|
|
199
208
|
taskId,
|
|
200
|
-
total:
|
|
201
|
-
completed:
|
|
209
|
+
total: validatedData.metadata?.total ?? 0,
|
|
210
|
+
completed: validatedData.metadata?.completed ?? 0,
|
|
202
211
|
});
|
|
203
212
|
|
|
204
213
|
await this.writeTaskFile(taskId, {
|
|
205
214
|
name: "todos.json",
|
|
206
|
-
content: JSON.stringify(
|
|
215
|
+
content: JSON.stringify(validatedData, null, 2),
|
|
207
216
|
type: "artifact",
|
|
208
217
|
});
|
|
209
218
|
|
|
210
219
|
this.logger.info("Todos file written", {
|
|
211
220
|
taskId,
|
|
212
|
-
total:
|
|
213
|
-
completed:
|
|
221
|
+
total: validatedData.metadata?.total ?? 0,
|
|
222
|
+
completed: validatedData.metadata?.completed ?? 0,
|
|
214
223
|
});
|
|
215
224
|
}
|
|
216
225
|
|
|
217
|
-
async readTodos(taskId: string): Promise<
|
|
226
|
+
async readTodos(taskId: string): Promise<unknown | null> {
|
|
218
227
|
try {
|
|
219
228
|
const content = await this.readTaskFile(taskId, "todos.json");
|
|
220
229
|
return content ? JSON.parse(content) : null;
|
package/src/git-manager.ts
CHANGED
|
@@ -572,4 +572,24 @@ Generated by PostHog Agent`;
|
|
|
572
572
|
message,
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
|
+
|
|
576
|
+
async isWorktree(): Promise<boolean> {
|
|
577
|
+
try {
|
|
578
|
+
// In a worktree, .git is a file pointing to the main repo's .git/worktrees/{name}
|
|
579
|
+
// In a normal repo, .git is a directory
|
|
580
|
+
const result = await this.runGitCommand(
|
|
581
|
+
"rev-parse --git-common-dir --git-dir",
|
|
582
|
+
);
|
|
583
|
+
const lines = result.split("\n");
|
|
584
|
+
if (lines.length >= 2) {
|
|
585
|
+
const commonDir = lines[0].trim();
|
|
586
|
+
const gitDir = lines[1].trim();
|
|
587
|
+
// If they're different, we're in a worktree
|
|
588
|
+
return commonDir !== gitDir;
|
|
589
|
+
}
|
|
590
|
+
return false;
|
|
591
|
+
} catch {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
575
595
|
}
|