@posthog/agent 1.24.2 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/_tslib.js +74 -0
- package/dist/_virtual/_tslib.js.map +1 -0
- package/dist/_virtual/additionalItems.js +4 -0
- package/dist/_virtual/additionalItems.js.map +1 -0
- package/dist/_virtual/additionalProperties.js +4 -0
- package/dist/_virtual/additionalProperties.js.map +1 -0
- package/dist/_virtual/ajv.js +4 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/allOf.js +4 -0
- package/dist/_virtual/allOf.js.map +1 -0
- package/dist/_virtual/anyOf.js +4 -0
- package/dist/_virtual/anyOf.js.map +1 -0
- package/dist/_virtual/applicability.js +4 -0
- package/dist/_virtual/applicability.js.map +1 -0
- package/dist/_virtual/boolSchema.js +4 -0
- package/dist/_virtual/boolSchema.js.map +1 -0
- package/dist/_virtual/code.js +4 -0
- package/dist/_virtual/code.js.map +1 -0
- package/dist/_virtual/code2.js +4 -0
- package/dist/_virtual/code2.js.map +1 -0
- package/dist/_virtual/const.js +4 -0
- package/dist/_virtual/const.js.map +1 -0
- package/dist/_virtual/contains.js +4 -0
- package/dist/_virtual/contains.js.map +1 -0
- package/dist/_virtual/core.js +4 -0
- package/dist/_virtual/core.js.map +1 -0
- package/dist/_virtual/dataType.js +4 -0
- package/dist/_virtual/dataType.js.map +1 -0
- package/dist/_virtual/defaults.js +4 -0
- package/dist/_virtual/defaults.js.map +1 -0
- package/dist/_virtual/dependencies.js +4 -0
- package/dist/_virtual/dependencies.js.map +1 -0
- package/dist/_virtual/draft7.js +4 -0
- package/dist/_virtual/draft7.js.map +1 -0
- package/dist/_virtual/enum.js +4 -0
- package/dist/_virtual/enum.js.map +1 -0
- package/dist/_virtual/equal.js +4 -0
- package/dist/_virtual/equal.js.map +1 -0
- package/dist/_virtual/errors.js +4 -0
- package/dist/_virtual/errors.js.map +1 -0
- package/dist/_virtual/format.js +4 -0
- package/dist/_virtual/format.js.map +1 -0
- package/dist/_virtual/formats.js +4 -0
- package/dist/_virtual/formats.js.map +1 -0
- package/dist/_virtual/id.js +4 -0
- package/dist/_virtual/id.js.map +1 -0
- package/dist/_virtual/if.js +4 -0
- package/dist/_virtual/if.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index10.js +4 -0
- package/dist/_virtual/index10.js.map +1 -0
- package/dist/_virtual/index11.js +4 -0
- package/dist/_virtual/index11.js.map +1 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/index3.js +4 -0
- package/dist/_virtual/index3.js.map +1 -0
- package/dist/_virtual/index4.js +4 -0
- package/dist/_virtual/index4.js.map +1 -0
- package/dist/_virtual/index5.js +4 -0
- package/dist/_virtual/index5.js.map +1 -0
- package/dist/_virtual/index6.js +4 -0
- package/dist/_virtual/index6.js.map +1 -0
- package/dist/_virtual/index7.js +4 -0
- package/dist/_virtual/index7.js.map +1 -0
- package/dist/_virtual/index8.js +4 -0
- package/dist/_virtual/index8.js.map +1 -0
- package/dist/_virtual/index9.js +4 -0
- package/dist/_virtual/index9.js.map +1 -0
- package/dist/_virtual/items.js +4 -0
- package/dist/_virtual/items.js.map +1 -0
- package/dist/_virtual/items2020.js +4 -0
- package/dist/_virtual/items2020.js.map +1 -0
- package/dist/_virtual/keyword.js +4 -0
- package/dist/_virtual/keyword.js.map +1 -0
- package/dist/_virtual/limit.js +4 -0
- package/dist/_virtual/limit.js.map +1 -0
- package/dist/_virtual/limitItems.js +4 -0
- package/dist/_virtual/limitItems.js.map +1 -0
- package/dist/_virtual/limitLength.js +4 -0
- package/dist/_virtual/limitLength.js.map +1 -0
- package/dist/_virtual/limitNumber.js +4 -0
- package/dist/_virtual/limitNumber.js.map +1 -0
- package/dist/_virtual/limitProperties.js +4 -0
- package/dist/_virtual/limitProperties.js.map +1 -0
- package/dist/_virtual/metadata.js +4 -0
- package/dist/_virtual/metadata.js.map +1 -0
- package/dist/_virtual/multipleOf.js +4 -0
- package/dist/_virtual/multipleOf.js.map +1 -0
- package/dist/_virtual/names.js +4 -0
- package/dist/_virtual/names.js.map +1 -0
- package/dist/_virtual/not.js +4 -0
- package/dist/_virtual/not.js.map +1 -0
- package/dist/_virtual/oneOf.js +4 -0
- package/dist/_virtual/oneOf.js.map +1 -0
- package/dist/_virtual/pattern.js +4 -0
- package/dist/_virtual/pattern.js.map +1 -0
- package/dist/_virtual/patternProperties.js +4 -0
- package/dist/_virtual/patternProperties.js.map +1 -0
- package/dist/_virtual/prefixItems.js +4 -0
- package/dist/_virtual/prefixItems.js.map +1 -0
- package/dist/_virtual/properties.js +4 -0
- package/dist/_virtual/properties.js.map +1 -0
- package/dist/_virtual/propertyNames.js +4 -0
- package/dist/_virtual/propertyNames.js.map +1 -0
- package/dist/_virtual/ref.js +4 -0
- package/dist/_virtual/ref.js.map +1 -0
- package/dist/_virtual/ref_error.js +4 -0
- package/dist/_virtual/ref_error.js.map +1 -0
- package/dist/_virtual/required.js +4 -0
- package/dist/_virtual/required.js.map +1 -0
- package/dist/_virtual/resolve.js +4 -0
- package/dist/_virtual/resolve.js.map +1 -0
- package/dist/_virtual/rules.js +4 -0
- package/dist/_virtual/rules.js.map +1 -0
- package/dist/_virtual/scope.js +4 -0
- package/dist/_virtual/scope.js.map +1 -0
- package/dist/_virtual/subschema.js +4 -0
- package/dist/_virtual/subschema.js.map +1 -0
- package/dist/_virtual/thenElse.js +4 -0
- package/dist/_virtual/thenElse.js.map +1 -0
- package/dist/_virtual/types.js +4 -0
- package/dist/_virtual/types.js.map +1 -0
- package/dist/_virtual/ucs2length.js +4 -0
- package/dist/_virtual/ucs2length.js.map +1 -0
- package/dist/_virtual/uniqueItems.js +4 -0
- package/dist/_virtual/uniqueItems.js.map +1 -0
- package/dist/_virtual/uri.js +4 -0
- package/dist/_virtual/uri.js.map +1 -0
- package/dist/_virtual/util.js +4 -0
- package/dist/_virtual/util.js.map +1 -0
- package/dist/_virtual/validation_error.js +4 -0
- package/dist/_virtual/validation_error.js.map +1 -0
- package/dist/claude-cli/cli.js +2294 -2146
- package/dist/example-client.d.ts +3 -0
- package/dist/example-client.d.ts.map +1 -0
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js +891 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js +876 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/schema.js.map +1 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js +66 -0
- package/dist/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +23 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +331 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +717 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +221 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +56 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +440 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +94 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1610 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +91 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js +133 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js +136 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js +112 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js +3297 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js +36 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js +10 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js +657 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js +449 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js +413 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js +57 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js +38 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js +86 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js +61 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js +80 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js +52 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js +1307 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js +842 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js +335 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js +8 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js +51 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/zod/v4/mini/schemas.js.map +1 -0
- package/dist/node_modules/ajv/dist/ajv.js +69 -0
- package/dist/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js +169 -0
- package/dist/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js +712 -0
- package/dist/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js +157 -0
- package/dist/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/errors.js +140 -0
- package/dist/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +253 -0
- package/dist/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/names.js +40 -0
- package/dist/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js +25 -0
- package/dist/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js +162 -0
- package/dist/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/rules.js +29 -0
- package/dist/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/util.js +183 -0
- package/dist/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js +30 -0
- package/dist/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js +64 -0
- package/dist/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js +213 -0
- package/dist/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js +49 -0
- package/dist/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js +544 -0
- package/dist/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js +139 -0
- package/dist/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js +95 -0
- package/dist/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/ajv/dist/core.js +639 -0
- package/dist/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js +31 -0
- package/dist/node_modules/ajv/dist/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +254 -0
- package/dist/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js +9 -0
- package/dist/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
- package/dist/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js +8 -0
- package/dist/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js +22 -0
- package/dist/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +53 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +112 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +14 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js +99 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +93 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js +70 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +77 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js +57 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js +37 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +64 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +80 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +15 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +42 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +16 -0
- package/dist/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js +146 -0
- package/dist/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js +11 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js +131 -0
- package/dist/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js +113 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js +12 -0
- package/dist/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js +94 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +9 -0
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js +21 -0
- package/dist/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js +31 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +54 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +29 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +26 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +28 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js +27 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js +84 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +72 -0
- package/dist/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/formats.js +212 -0
- package/dist/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/index.js +52 -0
- package/dist/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/ajv-formats/dist/limit.js +75 -0
- package/dist/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/base.js +256 -0
- package/dist/node_modules/diff/libesm/diff/base.js.map +1 -0
- package/dist/node_modules/diff/libesm/diff/line.js +64 -0
- package/dist/node_modules/diff/libesm/diff/line.js.map +1 -0
- package/dist/node_modules/diff/libesm/patch/create.js +185 -0
- package/dist/node_modules/diff/libesm/patch/create.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +47 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-uri/index.js +347 -0
- package/dist/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/schemes.js +255 -0
- package/dist/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/fast-uri/lib/utils.js +334 -0
- package/dist/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +98 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/uuid/dist/rng.js +14 -0
- package/dist/node_modules/uuid/dist/rng.js.map +1 -0
- package/dist/node_modules/uuid/dist/stringify.js +29 -0
- package/dist/node_modules/uuid/dist/stringify.js.map +1 -0
- package/dist/node_modules/uuid/dist/v7.js +65 -0
- package/dist/node_modules/uuid/dist/v7.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +109 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
- package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js +42 -0
- package/dist/node_modules/zod-to-json-schema/node_modules/zod/v3/types.js.map +1 -0
- package/dist/package.json.js +8 -0
- package/dist/package.json.js.map +1 -0
- package/dist/src/acp-extensions.d.ts +91 -0
- package/dist/src/acp-extensions.d.ts.map +1 -0
- package/dist/src/acp-extensions.js +38 -0
- package/dist/src/acp-extensions.js.map +1 -0
- package/dist/src/adapters/claude/claude.d.ts +136 -0
- package/dist/src/adapters/claude/claude.d.ts.map +1 -0
- package/dist/src/adapters/claude/claude.js +1128 -0
- package/dist/src/adapters/claude/claude.js.map +1 -0
- package/dist/src/adapters/claude/mcp-server.d.ts +30 -0
- package/dist/src/adapters/claude/mcp-server.d.ts.map +1 -0
- package/dist/src/adapters/claude/mcp-server.js +668 -0
- package/dist/src/adapters/claude/mcp-server.js.map +1 -0
- package/dist/src/adapters/claude/tools.d.ts +35 -0
- package/dist/src/adapters/claude/tools.d.ts.map +1 -0
- package/dist/src/adapters/claude/tools.js +473 -0
- package/dist/src/adapters/claude/tools.js.map +1 -0
- package/dist/src/adapters/claude/utils.d.ts +48 -0
- package/dist/src/adapters/claude/utils.d.ts.map +1 -0
- package/dist/src/adapters/claude/utils.js +158 -0
- package/dist/src/adapters/claude/utils.js.map +1 -0
- package/dist/src/agent.d.ts +24 -28
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +343 -172
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/file-manager.d.ts +6 -6
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +72 -63
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +2 -1
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +105 -70
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +8 -14
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +35 -23
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +4 -4
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +129 -99
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/schemas.d.ts +980 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +196 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/session-store.d.ts +58 -0
- package/dist/src/session-store.d.ts.map +1 -0
- package/dist/src/session-store.js +206 -0
- package/dist/src/session-store.js.map +1 -0
- package/dist/src/task-manager.d.ts +7 -7
- package/dist/src/task-manager.d.ts.map +1 -1
- package/dist/src/task-manager.js +19 -18
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/template-manager.d.ts +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +30 -28
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/todo-manager.d.ts +5 -5
- package/dist/src/todo-manager.d.ts.map +1 -1
- package/dist/src/todo-manager.js +33 -24
- package/dist/src/todo-manager.js.map +1 -1
- package/dist/src/tools/registry.d.ts +1 -1
- package/dist/src/tools/registry.js +60 -60
- package/dist/src/tools/registry.js.map +1 -1
- package/dist/src/tools/types.d.ts +31 -31
- package/dist/src/types.d.ts +62 -167
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/logger.d.ts +14 -6
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/dist/src/utils/logger.js +37 -22
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/utils/tapped-stream.d.ts +17 -0
- package/dist/src/utils/tapped-stream.d.ts.map +1 -0
- package/dist/src/utils/tapped-stream.js +45 -0
- package/dist/src/utils/tapped-stream.js.map +1 -0
- package/dist/src/workflow/config.d.ts +1 -1
- package/dist/src/workflow/config.d.ts.map +1 -1
- package/dist/src/workflow/config.js +18 -18
- package/dist/src/workflow/config.js.map +1 -1
- package/dist/src/workflow/steps/build.d.ts +1 -1
- package/dist/src/workflow/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +53 -39
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/finalize.d.ts +1 -1
- package/dist/src/workflow/steps/finalize.d.ts.map +1 -1
- package/dist/src/workflow/steps/finalize.js +58 -52
- package/dist/src/workflow/steps/finalize.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +69 -47
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +86 -67
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/dist/src/workflow/types.d.ts +19 -14
- package/dist/src/workflow/types.d.ts.map +1 -1
- package/dist/src/workflow/utils.d.ts +1 -1
- package/dist/src/workflow/utils.d.ts.map +1 -1
- package/dist/src/workflow/utils.js +7 -4
- package/dist/src/workflow/utils.js.map +1 -1
- package/dist/src/worktree-manager.d.ts +39 -0
- package/dist/src/worktree-manager.d.ts.map +1 -0
- package/dist/src/worktree-manager.js +808 -0
- package/dist/src/worktree-manager.js.map +1 -0
- package/package.json +20 -16
- package/src/acp-extensions.ts +117 -0
- package/src/adapters/claude/claude.ts +1514 -0
- package/src/adapters/claude/mcp-server.ts +810 -0
- package/src/adapters/claude/tools.ts +616 -0
- package/src/adapters/claude/utils.ts +267 -0
- package/src/agent.ts +717 -441
- package/src/agents/execution.ts +1 -1
- package/src/agents/planning.ts +1 -1
- package/src/agents/research.ts +0 -1
- package/src/file-manager.ts +80 -70
- package/src/git-manager.ts +164 -88
- package/src/posthog-api.ts +155 -94
- package/src/prompt-builder.ts +196 -143
- package/src/schemas.ts +241 -0
- package/src/session-store.ts +259 -0
- package/src/task-manager.ts +41 -33
- package/src/template-manager.ts +98 -45
- package/src/todo-manager.ts +43 -32
- package/src/tools/registry.ts +62 -62
- package/src/tools/types.ts +36 -36
- package/src/types.ts +130 -239
- package/src/utils/logger.ts +89 -58
- package/src/utils/tapped-stream.ts +60 -0
- package/src/workflow/config.ts +48 -48
- package/src/workflow/steps/build.ts +127 -113
- package/src/workflow/steps/finalize.ts +207 -182
- package/src/workflow/steps/plan.ts +155 -130
- package/src/workflow/steps/research.ts +207 -187
- package/src/workflow/types.ts +47 -36
- package/src/workflow/utils.ts +37 -34
- package/src/worktree-manager.ts +881 -0
- package/dist/src/adapters/claude/claude-adapter.d.ts +0 -18
- package/dist/src/adapters/claude/claude-adapter.d.ts.map +0 -1
- package/dist/src/adapters/claude/claude-adapter.js +0 -311
- package/dist/src/adapters/claude/claude-adapter.js.map +0 -1
- package/dist/src/adapters/claude/tool-mapper.d.ts +0 -19
- package/dist/src/adapters/claude/tool-mapper.d.ts.map +0 -1
- package/dist/src/adapters/claude/tool-mapper.js +0 -44
- package/dist/src/adapters/claude/tool-mapper.js.map +0 -1
- package/dist/src/adapters/types.d.ts +0 -33
- package/dist/src/adapters/types.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.d.ts +0 -43
- package/dist/src/task-progress-reporter.d.ts.map +0 -1
- package/dist/src/task-progress-reporter.js +0 -393
- package/dist/src/task-progress-reporter.js.map +0 -1
- package/src/adapters/claude/claude-adapter.ts +0 -338
- package/src/adapters/claude/tool-mapper.ts +0 -46
- package/src/adapters/types.ts +0 -37
- package/src/task-progress-reporter.ts +0 -443
package/dist/src/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sources":["../../src/agent.ts"],"sourcesContent":["import { query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Task, ExecutionResult, AgentConfig, CanUseTool } from './types.js';\nimport { TaskManager } from './task-manager.js';\nimport { PostHogAPIClient } from './posthog-api.js';\nimport { PostHogFileManager } from './file-manager.js';\nimport { GitManager } from './git-manager.js';\nimport { TemplateManager } from './template-manager.js';\nimport { ClaudeAdapter } from './adapters/claude/claude-adapter.js';\nimport type { ProviderAdapter } from './adapters/types.js';\nimport { Logger } from './utils/logger.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\nimport { TASK_WORKFLOW } from './workflow/config.js';\nimport type { WorkflowRuntime } from './workflow/types.js';\n\nexport class Agent {\n private workingDirectory: string;\n private onEvent?: (event: any) => void;\n private taskManager: TaskManager;\n private posthogAPI?: PostHogAPIClient;\n private fileManager: PostHogFileManager;\n private gitManager: GitManager;\n private templateManager: TemplateManager;\n private adapter: ProviderAdapter;\n private logger: Logger;\n private progressReporter: TaskProgressReporter;\n private promptBuilder: PromptBuilder;\n private mcpServers?: Record<string, any>;\n private canUseTool?: CanUseTool;\n public debug: boolean;\n\n constructor(config: AgentConfig) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.canUseTool = config.canUseTool;\n this.debug = config.debug || false;\n\n // Build default PostHog MCP server configuration\n const posthogMcpUrl = config.posthogMcpUrl\n || process.env.POSTHOG_MCP_URL\n || 'https://mcp.posthog.com/mcp';\n\n // Add auth if API key provided\n const headers: Record<string, string> = {};\n if (config.posthogApiKey) {\n headers['Authorization'] = `Bearer ${config.posthogApiKey}`;\n }\n\n const defaultMcpServers = {\n posthog: {\n type: 'http' as const,\n url: posthogMcpUrl,\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n }\n };\n\n // Merge default PostHog MCP with user-provided servers (user config takes precedence)\n this.mcpServers = {\n ...defaultMcpServers,\n ...config.mcpServers\n };\n this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });\n this.taskManager = new TaskManager();\n // Hardcode Claude adapter for now - extensible for other providers later\n this.adapter = new ClaudeAdapter();\n\n this.fileManager = new PostHogFileManager(\n this.workingDirectory,\n this.logger.child('FileManager')\n );\n this.gitManager = new GitManager({\n repositoryPath: this.workingDirectory,\n logger: this.logger.child('GitManager')\n // TODO: Add author config from environment or config\n });\n this.templateManager = new TemplateManager();\n\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n projectId: config.posthogProjectId,\n });\n }\n\n this.promptBuilder = new PromptBuilder({\n getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),\n generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),\n posthogClient: this.posthogAPI,\n logger: this.logger.child('PromptBuilder')\n });\n this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n }\n\n /**\n * Enable or disable debug logging\n */\n setDebug(enabled: boolean) {\n this.debug = enabled;\n this.logger.setDebug(enabled);\n }\n\n /**\n * Configure LLM gateway environment variables for Claude Code CLI\n */\n private async _configureLlmGateway(): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n try {\n const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();\n const apiKey = this.posthogAPI.getApiKey();\n\n process.env.ANTHROPIC_BASE_URL = gatewayUrl;\n process.env.ANTHROPIC_AUTH_TOKEN = apiKey;\n this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);\n\n this.logger.debug('Configured LLM gateway', { gatewayUrl });\n } catch (error) {\n this.logger.error('Failed to configure LLM gateway', error);\n throw error;\n }\n }\n\n // Adaptive task execution orchestrated via workflow steps\n async runTask(taskOrId: Task | string, options: import('./types.js').TaskExecutionOptions = {}): Promise<void> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n const cwd = options.repositoryPath || this.workingDirectory;\n const isCloudMode = options.isCloudMode ?? false;\n const taskSlug = (task as any).slug || task.id;\n\n this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });\n\n // Initialize progress reporter for task run tracking (needed for PR attachment)\n await this.progressReporter.start(task.id, { totalSteps: TASK_WORKFLOW.length });\n this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));\n\n await this.prepareTaskBranch(taskSlug, isCloudMode);\n\n let taskError: Error | undefined;\n try {\n const workflowContext: WorkflowRuntime = {\n task,\n taskSlug,\n cwd,\n isCloudMode,\n options,\n logger: this.logger,\n fileManager: this.fileManager,\n gitManager: this.gitManager,\n promptBuilder: this.promptBuilder,\n progressReporter: this.progressReporter,\n adapter: this.adapter,\n mcpServers: this.mcpServers,\n posthogAPI: this.posthogAPI,\n emitEvent: (event: any) => this.emitEvent(event),\n stepResults: {},\n };\n\n for (const step of TASK_WORKFLOW) {\n const result = await step.run({ step, context: workflowContext });\n if (result.halt) {\n return;\n }\n }\n\n const shouldCreatePR = options.createPR ?? isCloudMode;\n if (shouldCreatePR) {\n await this.ensurePullRequest(task, workflowContext.stepResults);\n }\n\n this.logger.info('Task execution complete', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));\n } catch (error) {\n taskError = error instanceof Error ? error : new Error(String(error));\n this.logger.error('Task execution failed', { taskId: task.id, error: taskError.message });\n } finally {\n if (taskError) {\n await this.progressReporter.fail(taskError);\n throw taskError;\n } else {\n await this.progressReporter.complete();\n }\n }\n }\n\n // Direct prompt execution - still supported for low-level usage\n async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any>; canUseTool?: CanUseTool } = {}): Promise<ExecutionResult> {\n await this._configureLlmGateway();\n const baseOptions: Record<string, any> = {\n model: \"claude-sonnet-4-5-20250929\",\n cwd: options.repositoryPath || this.workingDirectory,\n permissionMode: (options.permissionMode as any) || \"default\",\n settingSources: [\"local\"],\n mcpServers: this.mcpServers,\n };\n\n // Add canUseTool hook if provided (options take precedence over instance config)\n const canUseTool = options.canUseTool || this.canUseTool;\n if (canUseTool) {\n baseOptions.canUseTool = canUseTool;\n }\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n const results = [];\n for await (const message of response) {\n this.logger.debug('Received message in direct run', message);\n // Emit raw SDK event\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformedEvents = this.adapter.transform(message);\n for (const event of transformedEvents) {\n this.emitEvent(event);\n }\n results.push(message);\n }\n \n return { results };\n }\n \n // PostHog task operations\n async fetchTask(taskId: string): Promise<Task> {\n this.logger.debug('Fetching task from PostHog', { taskId });\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n return this.posthogAPI.fetchTask(taskId);\n }\n\n getPostHogClient(): PostHogAPIClient | undefined {\n return this.posthogAPI;\n }\n \n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n }): Promise<Task[]> {\n if (!this.posthogAPI) {\n throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n }\n return this.posthogAPI.listTasks(filters);\n }\n \n // File system operations for task artifacts\n async writeTaskFile(taskId: string, fileName: string, content: string, type: 'plan' | 'context' | 'reference' | 'output' = 'reference'): Promise<void> {\n this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });\n await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });\n }\n \n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n this.logger.debug('Reading task file', { taskId, fileName });\n return await this.fileManager.readTaskFile(taskId, fileName);\n }\n \n async getTaskFiles(taskId: string): Promise<any[]> {\n this.logger.debug('Getting task files', { taskId });\n const files = await this.fileManager.getTaskFiles(taskId);\n this.logger.debug('Found task files', { taskId, fileCount: files.length });\n return files;\n }\n \n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.info('Writing plan', { taskId, planLength: plan.length });\n await this.fileManager.writePlan(taskId, plan);\n }\n \n async readPlan(taskId: string): Promise<string | null> {\n this.logger.debug('Reading plan', { taskId });\n return await this.fileManager.readPlan(taskId);\n }\n\n // Git operations for task execution\n async createPlanningBranch(taskId: string): Promise<string> {\n this.logger.info('Creating planning branch', { taskId });\n const branchName = await this.gitManager.createTaskPlanningBranch(taskId);\n this.logger.debug('Planning branch created', { taskId, branchName });\n return branchName;\n }\n \n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n this.logger.info('Committing plan', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);\n this.logger.debug('Plan committed', { taskId, commitHash });\n return commitHash;\n }\n \n async createImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });\n const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);\n this.logger.debug('Implementation branch created', { taskId, branchName });\n return branchName;\n }\n \n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n this.logger.info('Committing implementation', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);\n this.logger.debug('Implementation committed', { taskId, commitHash });\n return commitHash;\n }\n\n async createPullRequest(\n taskId: string,\n branchName: string,\n taskTitle: string,\n taskDescription: string,\n customBody?: string\n ): Promise<string> {\n this.logger.info('Creating pull request', { taskId, branchName, taskTitle });\n\n const defaultBody = `## Task Details\n**Task ID**: ${taskId}\n**Description**: ${taskDescription}\n\n## Changes\nThis PR implements the changes described in the task.\n\nGenerated by PostHog Agent`;\n const prBody = customBody || defaultBody;\n\n const prUrl = await this.gitManager.createPullRequest(\n branchName,\n taskTitle,\n prBody\n );\n\n this.logger.info('Pull request created', { taskId, prUrl });\n return prUrl;\n }\n\n async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {\n this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n const updates: any = {\n output: { pr_url: prUrl }\n };\n if (branchName) {\n updates.branch = branchName;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);\n this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info('Updating task run branch', { taskId, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot update branch.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });\n this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, branchName });\n }\n\n // Execution management\n cancelTask(taskId: string): void {\n // Find the execution for this task and cancel it\n for (const [executionId, execution] of this.taskManager['executionStates']) {\n if (execution.taskId === taskId && execution.status === 'running') {\n this.taskManager.cancelExecution(executionId);\n break;\n }\n }\n }\n\n getTaskExecutionStatus(taskId: string): string | null {\n // Find the execution for this task\n for (const execution of this.taskManager['executionStates'].values()) {\n if (execution.taskId === taskId) {\n return execution.status;\n }\n }\n return null;\n }\n\n private async prepareTaskBranch(taskSlug: string, isCloudMode: boolean): Promise<void> {\n if (await this.gitManager.hasChanges()) {\n throw new Error('Cannot start task with uncommitted changes. Please commit or stash your changes first.');\n }\n\n await this.gitManager.resetToDefaultBranchIfNeeded();\n\n const existingBranch = await this.gitManager.getTaskBranch(taskSlug);\n if (!existingBranch) {\n const branchName = await this.gitManager.createTaskBranch(taskSlug);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));\n\n await this.gitManager.addAllPostHogFiles();\n \n // Only commit if there are changes or we're in cloud mode\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });\n } else {\n // Check if there are any changes before committing\n const hasChanges = await this.gitManager.hasStagedChanges();\n if (hasChanges) {\n await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);\n }\n }\n } else {\n this.logger.info('Switching to existing task branch', { branch: existingBranch });\n await this.gitManager.switchToBranch(existingBranch);\n }\n }\n\n private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {\n const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;\n const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;\n\n if (resolvedGatewayUrl) {\n process.env.OPENAI_BASE_URL = resolvedGatewayUrl;\n }\n\n if (resolvedToken) {\n process.env.OPENAI_API_KEY = resolvedToken;\n }\n }\n\n private async ensurePullRequest(task: Task, stepResults: Record<string, any>): Promise<void> {\n const latestRun = task.latest_run;\n const existingPr =\n latestRun?.output && typeof latestRun.output === 'object'\n ? (latestRun.output as any).pr_url\n : null;\n\n if (existingPr) {\n this.logger.info('PR already exists, skipping creation', { taskId: task.id, prUrl: existingPr });\n return;\n }\n\n const buildResult = stepResults['build'];\n if (!buildResult?.commitCreated) {\n this.logger.warn('Build step did not produce a commit; skipping PR creation', { taskId: task.id });\n return;\n }\n\n const branchName = await this.gitManager.getCurrentBranch();\n const finalizeResult = stepResults['finalize'];\n const prBody = finalizeResult?.prBody;\n\n const prUrl = await this.createPullRequest(\n task.id,\n branchName,\n task.title,\n task.description ?? '',\n prBody\n );\n\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));\n\n try {\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });\n } catch (error) {\n this.logger.warn('Could not attach PR to task', {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n private emitEvent(event: any): void {\n if (this.debug && event.type !== 'token') {\n // Log all events except tokens (too verbose)\n this.logger.debug('Emitting event', { type: event.type, ts: event.ts });\n }\n const persistPromise = this.progressReporter.recordEvent(event);\n if (persistPromise && typeof persistPromise.then === 'function') {\n persistPromise.catch((error: Error) =>\n this.logger.debug('Failed to persist agent event', { message: error.message })\n );\n }\n this.onEvent?.(event);\n }\n}\n\nexport { PermissionMode } from './types.js';\nexport type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAea,KAAK,CAAA;AACN,IAAA,gBAAgB;AAChB,IAAA,OAAO;AACP,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,eAAe;AACf,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,UAAU;AACV,IAAA,UAAU;AACX,IAAA,KAAK;AAEZ,IAAA,WAAA,CAAY,MAAmB,EAAA;QAC3B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE;AAChE,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAC7B,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK;;AAGlC,QAAA,MAAM,aAAa,GAAG,MAAM,CAAC;eACtB,OAAO,CAAC,GAAG,CAAC;AACZ,eAAA,6BAA6B;;QAGpC,MAAM,OAAO,GAA2B,EAAE;AAC1C,QAAA,IAAI,MAAM,CAAC,aAAa,EAAE;YACtB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,CAAC,aAAa,CAAA,CAAE;QAC/D;AAEA,QAAA,MAAM,iBAAiB,GAAG;AACtB,YAAA,OAAO,EAAE;AACL,gBAAA,IAAI,EAAE,MAAe;AACrB,gBAAA,GAAG,EAAE,aAAa;gBAClB,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,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G,KAAK,CAAC;IACzB;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"agent.js","sources":["../../src/agent.ts"],"sourcesContent":["import {\n type Client,\n ClientSideConnection,\n type ContentBlock,\n ndJsonStream,\n PROTOCOL_VERSION,\n type RequestPermissionRequest,\n type RequestPermissionResponse,\n type SessionNotification,\n} from \"@agentclientprotocol/sdk\";\nimport { POSTHOG_NOTIFICATIONS } from \"./acp-extensions.js\";\nimport {\n createAcpConnection,\n type InProcessAcpConnection,\n} from \"./adapters/claude/claude.js\";\nimport { PostHogFileManager } from \"./file-manager.js\";\nimport { GitManager } from \"./git-manager.js\";\nimport { PostHogAPIClient } from \"./posthog-api.js\";\nimport { PromptBuilder } from \"./prompt-builder.js\";\nimport { SessionStore } from \"./session-store.js\";\nimport { TaskManager } from \"./task-manager.js\";\nimport { TemplateManager } from \"./template-manager.js\";\nimport type {\n AgentConfig,\n CanUseTool,\n StoredNotification,\n Task,\n TaskExecutionOptions,\n} from \"./types.js\";\nimport { Logger } from \"./utils/logger.js\";\nimport { TASK_WORKFLOW } from \"./workflow/config.js\";\nimport type { SendNotification, WorkflowRuntime } from \"./workflow/types.js\";\n\nexport class Agent {\n private workingDirectory: string;\n private taskManager: TaskManager;\n private posthogAPI?: PostHogAPIClient;\n private fileManager: PostHogFileManager;\n private gitManager: GitManager;\n private templateManager: TemplateManager;\n private logger: Logger;\n private acpConnection?: InProcessAcpConnection;\n private promptBuilder: PromptBuilder;\n private mcpServers?: Record<string, any>;\n private canUseTool?: CanUseTool;\n private currentRunId?: string;\n private sessionStore?: SessionStore;\n public debug: boolean;\n\n constructor(config: AgentConfig) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.canUseTool = config.canUseTool;\n this.debug = config.debug || false;\n\n // Build default PostHog MCP server configuration\n const posthogMcpUrl =\n config.posthogMcpUrl ||\n process.env.POSTHOG_MCP_URL ||\n \"https://mcp.posthog.com/mcp\";\n\n // Add auth if API key provided\n const headers: Record<string, string> = {};\n if (config.posthogApiKey) {\n headers.Authorization = `Bearer ${config.posthogApiKey}`;\n }\n\n const defaultMcpServers = {\n posthog: {\n type: \"http\" as const,\n url: posthogMcpUrl,\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n },\n };\n\n // Merge default PostHog MCP with user-provided servers (user config takes precedence)\n this.mcpServers = {\n ...defaultMcpServers,\n ...config.mcpServers,\n };\n this.logger = new Logger({\n debug: this.debug,\n prefix: \"[PostHog Agent]\",\n onLog: config.onLog,\n });\n this.taskManager = new TaskManager();\n\n this.fileManager = new PostHogFileManager(\n this.workingDirectory,\n this.logger.child(\"FileManager\"),\n );\n this.gitManager = new GitManager({\n repositoryPath: this.workingDirectory,\n logger: this.logger.child(\"GitManager\"),\n });\n this.templateManager = new TemplateManager();\n\n if (\n config.posthogApiUrl &&\n config.posthogApiKey &&\n config.posthogProjectId\n ) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n projectId: config.posthogProjectId,\n });\n\n // Create SessionStore from the API client for ACP connection\n this.sessionStore = new SessionStore(\n this.posthogAPI,\n this.logger.child(\"SessionStore\"),\n );\n }\n\n this.promptBuilder = new PromptBuilder({\n getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),\n generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),\n posthogClient: this.posthogAPI,\n logger: this.logger.child(\"PromptBuilder\"),\n });\n }\n\n /**\n * Enable or disable debug logging\n */\n setDebug(enabled: boolean) {\n this.debug = enabled;\n this.logger.setDebug(enabled);\n }\n\n /**\n * Configure LLM gateway environment variables for Claude Code CLI\n */\n private async _configureLlmGateway(): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n try {\n const gatewayUrl = this.posthogAPI.getLlmGatewayUrl();\n const apiKey = this.posthogAPI.getApiKey();\n process.env.ANTHROPIC_BASE_URL = gatewayUrl;\n process.env.ANTHROPIC_AUTH_TOKEN = apiKey;\n this.ensureOpenAIGatewayEnv(gatewayUrl, apiKey);\n } catch (error) {\n this.logger.error(\"Failed to configure LLM gateway\", error);\n throw error;\n }\n }\n\n private getOrCreateConnection(): InProcessAcpConnection {\n if (!this.acpConnection) {\n this.acpConnection = createAcpConnection({\n sessionStore: this.sessionStore,\n });\n }\n return this.acpConnection;\n }\n\n // Adaptive task execution orchestrated via workflow steps\n async runTask(\n taskId: string,\n taskRunId: string,\n options: import(\"./types.js\").TaskExecutionOptions = {},\n ): Promise<void> {\n // await this._configureLlmGateway();\n\n const task = await this.fetchTask(taskId);\n const cwd = options.repositoryPath || this.workingDirectory;\n const isCloudMode = options.isCloudMode ?? false;\n const taskSlug = (task as any).slug || task.id;\n\n // Use taskRunId as sessionId - they are the same identifier\n this.currentRunId = taskRunId;\n\n this.logger.info(\"Starting adaptive task execution\", {\n taskId: task.id,\n taskSlug,\n taskRunId,\n isCloudMode,\n });\n\n const connection = this.getOrCreateConnection();\n\n // Create sendNotification using ACP connection's extNotification\n const sendNotification: SendNotification = async (method, params) => {\n this.logger.debug(`Notification: ${method}`, params);\n await connection.agentConnection.extNotification?.(method, params);\n };\n\n await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {\n sessionId: taskRunId,\n runId: taskRunId,\n });\n\n await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);\n\n let taskError: Error | undefined;\n try {\n const workflowContext: WorkflowRuntime = {\n task,\n taskSlug,\n runId: taskRunId,\n cwd,\n isCloudMode,\n options,\n logger: this.logger,\n fileManager: this.fileManager,\n gitManager: this.gitManager,\n promptBuilder: this.promptBuilder,\n connection: connection.agentConnection,\n sessionId: taskRunId,\n sendNotification,\n mcpServers: this.mcpServers,\n posthogAPI: this.posthogAPI,\n stepResults: {},\n };\n\n for (const step of TASK_WORKFLOW) {\n const result = await step.run({ step, context: workflowContext });\n if (result.halt) {\n return;\n }\n }\n\n const shouldCreatePR = options.createPR ?? isCloudMode;\n if (shouldCreatePR) {\n await this.ensurePullRequest(\n task,\n workflowContext.stepResults,\n sendNotification,\n );\n }\n\n this.logger.info(\"Task execution complete\", { taskId: task.id });\n await sendNotification(POSTHOG_NOTIFICATIONS.TASK_COMPLETE, {\n sessionId: taskRunId,\n taskId: task.id,\n });\n } catch (error) {\n taskError = error instanceof Error ? error : new Error(String(error));\n this.logger.error(\"Task execution failed\", {\n taskId: task.id,\n error: taskError.message,\n });\n await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {\n sessionId: taskRunId,\n message: taskError.message,\n });\n throw taskError;\n }\n }\n\n /**\n * Creates an in-process ACP connection for client communication.\n * Sets up git branch for the task, configures LLM gateway.\n * The client handles all prompting/querying via the returned streams.\n *\n * @returns InProcessAcpConnection with clientStreams for the client to use\n */\n async runTaskV2(\n taskId: string,\n taskRunId: string,\n options: import(\"./types.js\").TaskExecutionOptions = {},\n ): Promise<InProcessAcpConnection> {\n await this._configureLlmGateway();\n\n const task = await this.fetchTask(taskId);\n const taskSlug = (task as any).slug || task.id;\n const isCloudMode = options.isCloudMode ?? false;\n const _cwd = options.repositoryPath || this.workingDirectory;\n\n // Use taskRunId as sessionId - they are the same identifier\n this.currentRunId = taskRunId;\n\n this.acpConnection = createAcpConnection({\n sessionStore: this.sessionStore,\n sessionId: taskRunId,\n taskId: task.id,\n });\n\n const sendNotification: SendNotification = async (method, params) => {\n this.logger.debug(`Notification: ${method}`, params);\n await this.acpConnection?.agentConnection.extNotification?.(\n method,\n params,\n );\n };\n\n await sendNotification(POSTHOG_NOTIFICATIONS.RUN_STARTED, {\n sessionId: taskRunId,\n runId: taskRunId,\n });\n\n if (!options.skipGitBranch) {\n try {\n await this.prepareTaskBranch(taskSlug, isCloudMode, sendNotification);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(\"Failed to prepare task branch\", {\n error: errorMessage,\n });\n await sendNotification(POSTHOG_NOTIFICATIONS.ERROR, {\n sessionId: taskRunId,\n message: errorMessage,\n });\n throw error;\n }\n }\n\n return this.acpConnection;\n }\n\n // PostHog task operations\n async fetchTask(taskId: string): Promise<Task> {\n if (!this.posthogAPI) {\n const error = new Error(\n \"PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.\",\n );\n this.logger.error(\"PostHog API not configured\", error);\n throw error;\n }\n return this.posthogAPI.fetchTask(taskId);\n }\n\n getPostHogClient(): PostHogAPIClient | undefined {\n return this.posthogAPI;\n }\n\n /**\n * Send a notification to a cloud task run's S3 log.\n * The cloud runner will pick up new notifications via interrupt polling.\n */\n async sendNotification(\n taskId: string,\n runId: string,\n notification: StoredNotification,\n ): Promise<void> {\n if (!this.posthogAPI) {\n throw new Error(\n \"PostHog API not configured. Cannot send notification to cloud task.\",\n );\n }\n\n await this.posthogAPI.appendTaskRunLog(taskId, runId, [notification]);\n this.logger.debug(\"Notification sent to cloud task\", {\n taskId,\n runId,\n method: notification.notification.method,\n });\n }\n\n async getTaskFiles(taskId: string): Promise<any[]> {\n this.logger.debug(\"Getting task files\", { taskId });\n const files = await this.fileManager.getTaskFiles(taskId);\n this.logger.debug(\"Found task files\", { taskId, fileCount: files.length });\n return files;\n }\n\n async createPullRequest(\n taskId: string,\n branchName: string,\n taskTitle: string,\n taskDescription: string,\n customBody?: string,\n ): Promise<string> {\n this.logger.info(\"Creating pull request\", {\n taskId,\n branchName,\n taskTitle,\n });\n\n const defaultBody = `## Task Details\n**Task ID**: ${taskId}\n**Description**: ${taskDescription}\n\n## Changes\nThis PR implements the changes described in the task.\n\nGenerated by PostHog Agent`;\n const prBody = customBody || defaultBody;\n\n const prUrl = await this.gitManager.createPullRequest(\n branchName,\n taskTitle,\n prBody,\n );\n\n this.logger.info(\"Pull request created\", { taskId, prUrl });\n return prUrl;\n }\n\n async attachPullRequestToTask(\n taskId: string,\n prUrl: string,\n branchName?: string,\n ): Promise<void> {\n this.logger.info(\"Attaching PR to task run\", { taskId, prUrl, branchName });\n\n if (!this.posthogAPI || !this.currentRunId) {\n const error = new Error(\n \"PostHog API not configured or no active run. Cannot attach PR to task.\",\n );\n this.logger.error(\"PostHog API not configured\", error);\n throw error;\n }\n\n const updates: any = {\n output: { pr_url: prUrl },\n };\n if (branchName) {\n updates.branch = branchName;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, updates);\n this.logger.debug(\"PR attached to task run\", {\n taskId,\n runId: this.currentRunId,\n prUrl,\n });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info(\"Updating task run branch\", { taskId, branchName });\n\n if (!this.posthogAPI || !this.currentRunId) {\n const error = new Error(\n \"PostHog API not configured or no active run. Cannot update branch.\",\n );\n this.logger.error(\"PostHog API not configured\", error);\n throw error;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.currentRunId, {\n branch: branchName,\n });\n this.logger.debug(\"Task run branch updated\", {\n taskId,\n runId: this.currentRunId,\n branchName,\n });\n }\n\n // Execution management\n cancelTask(taskId: string): void {\n // Find the execution for this task and cancel it\n for (const [executionId, execution] of this.taskManager.executionStates) {\n if (execution.taskId === taskId && execution.status === \"running\") {\n this.taskManager.cancelExecution(executionId);\n break;\n }\n }\n }\n\n getTaskExecutionStatus(taskId: string): string | null {\n // Find the execution for this task\n for (const execution of this.taskManager.executionStates.values()) {\n if (execution.taskId === taskId) {\n return execution.status;\n }\n }\n return null;\n }\n\n private async prepareTaskBranch(\n taskSlug: string,\n isCloudMode: boolean,\n sendNotification: SendNotification,\n ): Promise<void> {\n if (await this.gitManager.hasChanges()) {\n throw new Error(\n \"Cannot start task with uncommitted changes. Please commit or stash your changes first.\",\n );\n }\n\n // If we're running in a worktree, we're already on the correct branch\n // (the worktree was created with its own branch). Skip branch creation.\n const isWorktree = await this.gitManager.isWorktree();\n if (isWorktree) {\n const currentBranch = await this.gitManager.getCurrentBranch();\n this.logger.info(\"Running in worktree, using existing branch\", {\n branch: currentBranch,\n });\n await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {\n branch: currentBranch,\n });\n return;\n }\n\n await this.gitManager.resetToDefaultBranchIfNeeded();\n\n const existingBranch = await this.gitManager.getTaskBranch(taskSlug);\n if (!existingBranch) {\n const branchName = await this.gitManager.createTaskBranch(taskSlug);\n await sendNotification(POSTHOG_NOTIFICATIONS.BRANCH_CREATED, {\n branch: branchName,\n });\n\n await this.gitManager.addAllPostHogFiles();\n\n // Only commit if there are changes or we're in cloud mode\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, {\n allowEmpty: true,\n });\n } else {\n // Check if there are any changes before committing\n const hasChanges = await this.gitManager.hasStagedChanges();\n if (hasChanges) {\n await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);\n }\n }\n } else {\n this.logger.info(\"Switching to existing task branch\", {\n branch: existingBranch,\n });\n await this.gitManager.switchToBranch(existingBranch);\n }\n }\n\n private ensureOpenAIGatewayEnv(gatewayUrl?: string, token?: string): void {\n const resolvedGatewayUrl = gatewayUrl || process.env.ANTHROPIC_BASE_URL;\n const resolvedToken = token || process.env.ANTHROPIC_AUTH_TOKEN;\n\n if (resolvedGatewayUrl) {\n process.env.OPENAI_BASE_URL = resolvedGatewayUrl;\n }\n\n if (resolvedToken) {\n process.env.OPENAI_API_KEY = resolvedToken;\n }\n }\n\n async runTaskCloud(\n taskId: string,\n taskRunId: string,\n options: TaskExecutionOptions = {},\n ): Promise<void> {\n await this._configureLlmGateway();\n\n const task = await this.fetchTask(taskId);\n const cwd = options.repositoryPath || this.workingDirectory;\n const taskSlug = (task as any).slug || task.id;\n\n this.currentRunId = taskRunId;\n\n this.logger.info(\"Starting cloud task execution\", {\n taskId: task.id,\n taskSlug,\n taskRunId,\n cwd,\n });\n\n if (!this.sessionStore) {\n throw new Error(\n \"SessionStore required for cloud mode. Ensure PostHog API credentials are configured.\",\n );\n }\n\n // Start session in SessionStore (updates task run status to in_progress)\n const taskRun = await this.sessionStore.start(taskRunId, taskId, taskRunId);\n this.logger.debug(\"Session started\", {\n taskRunId,\n logUrl: taskRun?.log_url,\n });\n\n // Create internal ACP connection with S3 persistence\n const acpConnection = createAcpConnection({\n sessionStore: this.sessionStore,\n sessionId: taskRunId,\n taskId: task.id,\n });\n\n // Create client connection using the client-side streams\n const clientStream = ndJsonStream(\n acpConnection.clientStreams.writable as WritableStream<Uint8Array>,\n acpConnection.clientStreams.readable as ReadableStream<Uint8Array>,\n );\n\n // Create auto-approving client for headless cloud mode\n const cloudClient: Client = {\n async requestPermission(params) {\n const allowOption = params.options.find(\n (o) => o.kind === \"allow_once\" || o.kind === \"allow_always\",\n );\n return {\n outcome: {\n outcome: \"selected\",\n optionId: allowOption?.optionId ?? params.options[0].optionId,\n },\n };\n },\n async sessionUpdate(_params) {\n // Notifications are already being persisted to S3 via tapped streams\n },\n };\n\n const clientConnection = new ClientSideConnection(\n (_agent) => cloudClient,\n clientStream,\n );\n\n try {\n // Initialize the connection\n await clientConnection.initialize({\n protocolVersion: PROTOCOL_VERSION,\n clientCapabilities: {},\n });\n\n // Create new session\n await clientConnection.newSession({\n cwd,\n mcpServers: [],\n _meta: { sessionId: taskRunId },\n });\n\n // Prepare git branch if not skipped\n if (!options.skipGitBranch) {\n const sendNotification: SendNotification = async (method, params) => {\n this.logger.debug(`Notification: ${method}`, params);\n await acpConnection.agentConnection.extNotification?.(method, params);\n };\n await this.prepareTaskBranch(taskSlug, true, sendNotification);\n }\n\n // Build initial prompt from task description\n const initialPrompt: ContentBlock[] = [\n {\n type: \"text\",\n text: `# Task: ${task.title}\\n\\n${task.description}`,\n },\n ];\n\n // Track the last known log entry count for interrupt polling\n let lastKnownEntryCount = 0;\n let isPolling = true;\n\n // Start interrupt polling in background\n const pollForInterrupts = async () => {\n while (isPolling) {\n await new Promise((resolve) => setTimeout(resolve, 2000)); // Poll every 2 seconds\n if (!isPolling) break;\n\n try {\n const newEntries = await this.sessionStore!.pollForNewEntries(\n taskRunId,\n lastKnownEntryCount,\n );\n\n for (const entry of newEntries) {\n lastKnownEntryCount++;\n // Look for user_message notifications\n if (\n entry.notification?.method === \"sessionUpdate\" &&\n (entry.notification?.params as any)?.sessionUpdate ===\n \"user_message\"\n ) {\n const content = (entry.notification?.params as any)?.content;\n if (content) {\n this.logger.info(\"Processing user interrupt\", { content });\n // Send as new prompt - will be processed after current prompt completes\n await clientConnection.prompt({\n sessionId: taskRunId,\n prompt: Array.isArray(content) ? content : [content],\n });\n }\n }\n }\n } catch (err) {\n this.logger.warn(\"Interrupt polling error\", { error: err });\n }\n }\n };\n\n // Start polling in background (don't await)\n const pollingPromise = pollForInterrupts();\n\n // Send initial prompt and wait for completion\n this.logger.info(\"Sending initial prompt to agent\");\n const result = await clientConnection.prompt({\n sessionId: taskRunId,\n prompt: initialPrompt,\n });\n\n // Stop interrupt polling\n isPolling = false;\n await pollingPromise;\n\n this.logger.info(\"Task execution complete\", {\n taskId: task.id,\n stopReason: result.stopReason,\n });\n\n await this.sessionStore.complete(taskRunId);\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(\"Cloud task execution failed\", {\n taskId: task.id,\n error: errorMessage,\n });\n await this.sessionStore.fail(taskRunId, errorMessage);\n throw error;\n }\n }\n\n private async ensurePullRequest(\n task: Task,\n stepResults: Record<string, any>,\n sendNotification: SendNotification,\n ): Promise<void> {\n const latestRun = task.latest_run;\n const existingPr =\n latestRun?.output && typeof latestRun.output === \"object\"\n ? (latestRun.output as any).pr_url\n : null;\n\n if (existingPr) {\n this.logger.info(\"PR already exists, skipping creation\", {\n taskId: task.id,\n prUrl: existingPr,\n });\n return;\n }\n\n const buildResult = stepResults.build;\n if (!buildResult?.commitCreated) {\n this.logger.warn(\n \"Build step did not produce a commit; skipping PR creation\",\n { taskId: task.id },\n );\n return;\n }\n\n const branchName = await this.gitManager.getCurrentBranch();\n const finalizeResult = stepResults.finalize;\n const prBody = finalizeResult?.prBody;\n\n const prUrl = await this.createPullRequest(\n task.id,\n branchName,\n task.title,\n task.description ?? \"\",\n prBody,\n );\n\n await sendNotification(POSTHOG_NOTIFICATIONS.PR_CREATED, { prUrl });\n\n try {\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.logger.info(\"PR attached to task successfully\", {\n taskId: task.id,\n prUrl,\n });\n } catch (error) {\n this.logger.warn(\"Could not attach PR to task\", {\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n}\n\nexport type {\n AgentConfig,\n ExecutionResult,\n SupportingFile,\n Task,\n} from \"./types.js\";\nexport { PermissionMode } from \"./types.js\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;MAiCa,KAAK,CAAA;AACR,IAAA,gBAAgB;AAChB,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,eAAe;AACf,IAAA,MAAM;AACN,IAAA,aAAa;AACb,IAAA,aAAa;AACb,IAAA,UAAU;AACV,IAAA,UAAU;AACV,IAAA,YAAY;AACZ,IAAA,YAAY;AACb,IAAA,KAAK;AAEZ,IAAA,WAAA,CAAY,MAAmB,EAAA;QAC7B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE;AAChE,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;QACnC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK;;AAGlC,QAAA,MAAM,aAAa,GACjB,MAAM,CAAC,aAAa;YACpB,OAAO,CAAC,GAAG,CAAC,eAAe;AAC3B,YAAA,6BAA6B;;QAG/B,MAAM,OAAO,GAA2B,EAAE;AAC1C,QAAA,IAAI,MAAM,CAAC,aAAa,EAAE;YACxB,OAAO,CAAC,aAAa,GAAG,CAAA,OAAA,EAAU,MAAM,CAAC,aAAa,EAAE;QAC1D;AAEA,QAAA,MAAM,iBAAiB,GAAG;AACxB,YAAA,OAAO,EAAE;AACP,gBAAA,IAAI,EAAE,MAAe;AACrB,gBAAA,GAAG,EAAE,aAAa;gBAClB,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,G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B,EAAE;AAC9C,gBAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9D,aAAA,CAAC;QACJ;IACF;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sources":["../../../src/agents/execution.ts"],"sourcesContent":["export const EXECUTION_SYSTEM_PROMPT = `<role>\nPostHog AI Execution Agent — autonomously implement tasks as merge-ready code following project conventions.\n</role>\n\n<context>\nYou have access to local repository files and PostHog MCP server. Work primarily with local files for implementation. Commit changes regularly.\n</context>\n\n<constraints>\n- Follow existing code style, patterns, and conventions found in the repository\n- Minimize new external dependencies — only add when necessary\n- Implement structured logging and error handling (never log secrets)\n- Avoid destructive shell commands\n- Create/update .gitignore to exclude build artifacts, dependencies, and temp files\n</constraints>\n\n<approach>\n1. Review the implementation plan if provided, or create your own todo list\n2. Execute changes step by step\n3. Test thoroughly and verify functionality\n4. Commit changes with clear messages\n</approach>\n\n<checklist>\nBefore completing the task, verify:\n- .gitignore includes build artifacts, node_modules, __pycache__, etc.\n- Dependency files (package.json, requirements.txt) use exact versions\n- Code compiles and tests pass\n- Added or updated relevant tests\n- Captured meaningful events with PostHog SDK where appropriate\n- Wrapped new logic in PostHog feature flags where appropriate\n- Updated documentation, README, or type hints as needed\n</checklist>\n\n<output_format>\nProvide a concise summary of changes made when finished.\n</output_format
|
|
1
|
+
{"version":3,"file":"execution.js","sources":["../../../src/agents/execution.ts"],"sourcesContent":["export const EXECUTION_SYSTEM_PROMPT = `<role>\nPostHog AI Execution Agent — autonomously implement tasks as merge-ready code following project conventions.\n</role>\n\n<context>\nYou have access to local repository files and PostHog MCP server. Work primarily with local files for implementation. Commit changes regularly.\n</context>\n\n<constraints>\n- Follow existing code style, patterns, and conventions found in the repository\n- Minimize new external dependencies — only add when necessary\n- Implement structured logging and error handling (never log secrets)\n- Avoid destructive shell commands\n- Create/update .gitignore to exclude build artifacts, dependencies, and temp files\n</constraints>\n\n<approach>\n1. Review the implementation plan if provided, or create your own todo list\n2. Execute changes step by step\n3. Test thoroughly and verify functionality\n4. Commit changes with clear messages\n</approach>\n\n<checklist>\nBefore completing the task, verify:\n- .gitignore includes build artifacts, node_modules, __pycache__, etc.\n- Dependency files (package.json, requirements.txt) use exact versions\n- Code compiles and tests pass\n- Added or updated relevant tests\n- Captured meaningful events with PostHog SDK where appropriate\n- Wrapped new logic in PostHog feature flags where appropriate\n- Updated documentation, README, or type hints as needed\n</checklist>\n\n<output_format>\nProvide a concise summary of changes made when finished.\n</output_format>`;\n"],"names":[],"mappings":"AAAO,MAAM,uBAAuB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning.js","sources":["../../../src/agents/planning.ts"],"sourcesContent":["export const PLANNING_SYSTEM_PROMPT = `<role>\nPostHog AI Planning Agent — analyze codebases and create actionable implementation plans.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or edits\n- Output ONLY the plan markdown — no preamble, no acknowledgment, no meta-commentary\n</constraints>\n\n<objective>\nCreate a detailed, actionable implementation plan that an execution agent can follow to complete the task successfully.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Break down task requirements and identify technical constraints\n4. Define step-by-step implementation approach\n5. Specify files to modify/create with exact paths\n6. Identify testing requirements and potential risks\n</process>\n\n<output_format>\nOutput the plan DIRECTLY as markdown with NO preamble text. Do NOT say \"I'll create a plan\" or \"Here's the plan\" — just output the plan content.\n\nRequired sections (follow the template provided in the task prompt):\n- Summary: Brief overview of approach\n- Files to Create/Modify: Specific paths and purposes\n- Implementation Steps: Ordered list of actions\n- Testing Strategy: How to verify it works\n- Considerations: Dependencies, risks, edge cases\n</output_format>\n\n<examples>\n<bad_example>\n\"Sure! I'll create a detailed implementation plan for you to add authentication. Here's what we'll do...\"\nReason: No preamble — output the plan directly\n</bad_example>\n\n<good_example>\n\"# Implementation Plan\n\n## Summary\nAdd JWT-based authentication to API endpoints using existing middleware pattern...\n\n## Files to Modify\n- src/middleware/auth.ts: Add JWT verification\n...\"\nReason: Direct plan output with no meta-commentary\n</good_example>\n</examples>\n\n<context_integration>\nIf research findings, context files, or reference materials are provided:\n- Incorporate research findings into your analysis\n- Follow patterns and approaches identified in research\n- Build upon or refine any existing planning work\n- Reference specific files and components mentioned in context\n</context_integration
|
|
1
|
+
{"version":3,"file":"planning.js","sources":["../../../src/agents/planning.ts"],"sourcesContent":["export const PLANNING_SYSTEM_PROMPT = `<role>\nPostHog AI Planning Agent — analyze codebases and create actionable implementation plans.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or edits\n- Output ONLY the plan markdown — no preamble, no acknowledgment, no meta-commentary\n</constraints>\n\n<objective>\nCreate a detailed, actionable implementation plan that an execution agent can follow to complete the task successfully.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Break down task requirements and identify technical constraints\n4. Define step-by-step implementation approach\n5. Specify files to modify/create with exact paths\n6. Identify testing requirements and potential risks\n</process>\n\n<output_format>\nOutput the plan DIRECTLY as markdown with NO preamble text. Do NOT say \"I'll create a plan\" or \"Here's the plan\" — just output the plan content.\n\nRequired sections (follow the template provided in the task prompt):\n- Summary: Brief overview of approach\n- Files to Create/Modify: Specific paths and purposes\n- Implementation Steps: Ordered list of actions\n- Testing Strategy: How to verify it works\n- Considerations: Dependencies, risks, edge cases\n</output_format>\n\n<examples>\n<bad_example>\n\"Sure! I'll create a detailed implementation plan for you to add authentication. Here's what we'll do...\"\nReason: No preamble — output the plan directly\n</bad_example>\n\n<good_example>\n\"# Implementation Plan\n\n## Summary\nAdd JWT-based authentication to API endpoints using existing middleware pattern...\n\n## Files to Modify\n- src/middleware/auth.ts: Add JWT verification\n...\"\nReason: Direct plan output with no meta-commentary\n</good_example>\n</examples>\n\n<context_integration>\nIf research findings, context files, or reference materials are provided:\n- Incorporate research findings into your analysis\n- Follow patterns and approaches identified in research\n- Build upon or refine any existing planning work\n- Reference specific files and components mentioned in context\n</context_integration>`;\n"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research.js","sources":["../../../src/agents/research.ts"],"sourcesContent":["export const RESEARCH_SYSTEM_PROMPT = `<role>\nPostHog AI Research Agent — analyze codebases to evaluate task actionability and identify missing information.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or code changes\n- Output structured JSON only\n</constraints>\n\n<objective>\nYour PRIMARY goal is to evaluate whether a task is actionable and assign an actionability score.\n\nCalculate an actionabilityScore (0-1) based on:\n- **Task clarity** (0.4 weight): Is the task description specific and unambiguous?\n- **Codebase context** (0.3 weight): Can you locate the relevant code and patterns?\n- **Architectural decisions** (0.2 weight): Are the implementation approaches clear?\n- **Dependencies** (0.1 weight): Are required dependencies and constraints understood?\n\nIf actionabilityScore < 0.7, generate specific clarifying questions to increase confidence.\n\nQuestions must present complete implementation choices, NOT request information from the user:\noptions: array of strings\n- GOOD: options: [\"Use Redux Toolkit (matches pattern in src/store/)\", \"Zustand (lighter weight)\"]\n- BAD: \"Tell me which state management library to use\"\n- GOOD: options: [\"Place in Button.tsx (existing component)\", \"create NewButton.tsx (separate concerns)?\"]\n- BAD: \"Where should I put this code?\"\n\nDO NOT ask questions like \"how should I fix this\" or \"tell me the pattern\" — present concrete options that can be directly chosen and acted upon.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Calculate actionabilityScore based on clarity, context, architecture, and dependencies\n4. Identify key files that will need modification\n5. If score < 0.7: generate 2-4 specific questions to resolve blockers\n6. Output JSON matching ResearchEvaluation schema\n</process>\n\n<output_format>\nOutput ONLY valid JSON with no markdown wrappers, no preamble, no explanation:\n\n{\n \"actionabilityScore\": 0.85,\n \"context\": \"Brief 2-3 sentence summary of the task and implementation approach\",\n \"keyFiles\": [\"path/to/file1.ts\", \"path/to/file2.ts\"],\n \"blockers\": [\"Optional: what's preventing full confidence\"],\n \"questions\": [\n {\n \"id\": \"q1\",\n \"question\": \"Specific architectural decision needed?\",\n \"options\": [\n \"First approach with concrete details\",\n \"Alternative approach with concrete details\",\n \"Third option if needed\"\n ]\n }\n ]\n}\n\nRules:\n- actionabilityScore: number between 0 and 1\n- context: concise summary for planning phase\n- keyFiles: array of file paths that need modification\n- blockers: optional array explaining confidence gaps\n- questions: ONLY include if actionabilityScore < 0.7\n- Each question must have 2-3 options (maximum 3)\n- Max 3 questions total\n- Options must be complete, actionable choices that require NO additional user input\n- NEVER use options like \"Tell me the pattern\", \"Show me examples\", \"Specify the approach\"\n- Each option must be a full implementation decision that can be directly acted upon\n</output_format>\n\n<scoring_examples>\n<example score=\"0.9\">\nTask: \"Fix typo in login button text\"\nReasoning: Completely clear task, found exact component, no architectural decisions\n</example>\n\n<example score=\"0.75\">\nTask: \"Add caching to API endpoints\"\nReasoning: Clear goal, found endpoints, but multiple caching strategies possible\n</example>\n\n<example score=\"0.55\">\nTask: \"Improve performance\"\nReasoning: Vague task, unclear scope, needs questions about which areas to optimize\nQuestions needed: Which features are slow? What metrics define success?\n</example>\n\n<example score=\"0.3\">\nTask: \"Add the new feature\"\nReasoning: Extremely vague, no context, cannot locate relevant code\nQuestions needed: What feature? Which product area? What should it do?\n</example>\n</scoring_examples>\n\n<question_examples>\n<good_example>\n{\n \"id\": \"q1\",\n \"question\": \"Which caching layer should we use for API responses?\",\n \"options\": [\n \"Redis with 1-hour TTL (existing infrastructure, requires Redis client setup)\",\n \"In-memory LRU cache with 100MB limit (simpler, single-server only)\",\n \"HTTP Cache-Control headers only (minimal backend changes, relies on browser/CDN)\"\n ]\n}\nReason: Each option is a complete, actionable decision with concrete details\n</good_example>\n\n<good_example>\n{\n \"id\": \"q2\",\n \"question\": \"Where should the new analytics tracking code be placed?\",\n \"options\": [\n \"In the existing UserAnalytics.ts module alongside page view tracking\",\n \"Create a new EventTracking.ts module in src/analytics/ for all event tracking\",\n \"Add directly to each component that needs tracking (no centralized module)\"\n ]\n}\nReason: Specific file paths and architectural patterns, no user input needed\n</good_example>\n\n<bad_example>\n{\n \"id\": \"q1\", \n \"question\": \"How should I implement this?\",\n \"options\": [\"One way\", \"Another way\"]\n}\nReason: Too vague, doesn't explain the tradeoffs or provide concrete details\n</bad_example>\n\n<bad_example>\n{\n \"id\": \"q2\",\n \"question\": \"Which pattern should we follow for state management?\",\n \"options\": [\n \"Tell me which pattern the codebase currently uses\",\n \"Show me examples of state management\",\n \"Whatever you think is best\"\n ]\n}\nReason: Options request user input instead of being actionable choices. Should be concrete patterns like \"Zustand stores (matching existing patterns in src/stores/)\" or \"React Context (simpler, no new dependencies)\"\n</bad_example>\n\n<bad_example>\n{\n \"id\": \"q3\",\n \"question\": \"What color scheme should the button use?\",\n \"options\": [\n \"Use the existing theme colors\",\n \"Let me specify custom colors\",\n \"Match the design system\"\n ]\n}\nReason: \"Let me specify\" requires user input. Should be \"Primary blue (#0066FF, existing theme)\" or \"Secondary gray (#6B7280, existing theme)\"\n</bad_example>\n</question_examples>`;\n
|
|
1
|
+
{"version":3,"file":"research.js","sources":["../../../src/agents/research.ts"],"sourcesContent":["export const RESEARCH_SYSTEM_PROMPT = `<role>\nPostHog AI Research Agent — analyze codebases to evaluate task actionability and identify missing information.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or code changes\n- Output structured JSON only\n</constraints>\n\n<objective>\nYour PRIMARY goal is to evaluate whether a task is actionable and assign an actionability score.\n\nCalculate an actionabilityScore (0-1) based on:\n- **Task clarity** (0.4 weight): Is the task description specific and unambiguous?\n- **Codebase context** (0.3 weight): Can you locate the relevant code and patterns?\n- **Architectural decisions** (0.2 weight): Are the implementation approaches clear?\n- **Dependencies** (0.1 weight): Are required dependencies and constraints understood?\n\nIf actionabilityScore < 0.7, generate specific clarifying questions to increase confidence.\n\nQuestions must present complete implementation choices, NOT request information from the user:\noptions: array of strings\n- GOOD: options: [\"Use Redux Toolkit (matches pattern in src/store/)\", \"Zustand (lighter weight)\"]\n- BAD: \"Tell me which state management library to use\"\n- GOOD: options: [\"Place in Button.tsx (existing component)\", \"create NewButton.tsx (separate concerns)?\"]\n- BAD: \"Where should I put this code?\"\n\nDO NOT ask questions like \"how should I fix this\" or \"tell me the pattern\" — present concrete options that can be directly chosen and acted upon.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Calculate actionabilityScore based on clarity, context, architecture, and dependencies\n4. Identify key files that will need modification\n5. If score < 0.7: generate 2-4 specific questions to resolve blockers\n6. Output JSON matching ResearchEvaluation schema\n</process>\n\n<output_format>\nOutput ONLY valid JSON with no markdown wrappers, no preamble, no explanation:\n\n{\n \"actionabilityScore\": 0.85,\n \"context\": \"Brief 2-3 sentence summary of the task and implementation approach\",\n \"keyFiles\": [\"path/to/file1.ts\", \"path/to/file2.ts\"],\n \"blockers\": [\"Optional: what's preventing full confidence\"],\n \"questions\": [\n {\n \"id\": \"q1\",\n \"question\": \"Specific architectural decision needed?\",\n \"options\": [\n \"First approach with concrete details\",\n \"Alternative approach with concrete details\",\n \"Third option if needed\"\n ]\n }\n ]\n}\n\nRules:\n- actionabilityScore: number between 0 and 1\n- context: concise summary for planning phase\n- keyFiles: array of file paths that need modification\n- blockers: optional array explaining confidence gaps\n- questions: ONLY include if actionabilityScore < 0.7\n- Each question must have 2-3 options (maximum 3)\n- Max 3 questions total\n- Options must be complete, actionable choices that require NO additional user input\n- NEVER use options like \"Tell me the pattern\", \"Show me examples\", \"Specify the approach\"\n- Each option must be a full implementation decision that can be directly acted upon\n</output_format>\n\n<scoring_examples>\n<example score=\"0.9\">\nTask: \"Fix typo in login button text\"\nReasoning: Completely clear task, found exact component, no architectural decisions\n</example>\n\n<example score=\"0.75\">\nTask: \"Add caching to API endpoints\"\nReasoning: Clear goal, found endpoints, but multiple caching strategies possible\n</example>\n\n<example score=\"0.55\">\nTask: \"Improve performance\"\nReasoning: Vague task, unclear scope, needs questions about which areas to optimize\nQuestions needed: Which features are slow? What metrics define success?\n</example>\n\n<example score=\"0.3\">\nTask: \"Add the new feature\"\nReasoning: Extremely vague, no context, cannot locate relevant code\nQuestions needed: What feature? Which product area? What should it do?\n</example>\n</scoring_examples>\n\n<question_examples>\n<good_example>\n{\n \"id\": \"q1\",\n \"question\": \"Which caching layer should we use for API responses?\",\n \"options\": [\n \"Redis with 1-hour TTL (existing infrastructure, requires Redis client setup)\",\n \"In-memory LRU cache with 100MB limit (simpler, single-server only)\",\n \"HTTP Cache-Control headers only (minimal backend changes, relies on browser/CDN)\"\n ]\n}\nReason: Each option is a complete, actionable decision with concrete details\n</good_example>\n\n<good_example>\n{\n \"id\": \"q2\",\n \"question\": \"Where should the new analytics tracking code be placed?\",\n \"options\": [\n \"In the existing UserAnalytics.ts module alongside page view tracking\",\n \"Create a new EventTracking.ts module in src/analytics/ for all event tracking\",\n \"Add directly to each component that needs tracking (no centralized module)\"\n ]\n}\nReason: Specific file paths and architectural patterns, no user input needed\n</good_example>\n\n<bad_example>\n{\n \"id\": \"q1\", \n \"question\": \"How should I implement this?\",\n \"options\": [\"One way\", \"Another way\"]\n}\nReason: Too vague, doesn't explain the tradeoffs or provide concrete details\n</bad_example>\n\n<bad_example>\n{\n \"id\": \"q2\",\n \"question\": \"Which pattern should we follow for state management?\",\n \"options\": [\n \"Tell me which pattern the codebase currently uses\",\n \"Show me examples of state management\",\n \"Whatever you think is best\"\n ]\n}\nReason: Options request user input instead of being actionable choices. Should be concrete patterns like \"Zustand stores (matching existing patterns in src/stores/)\" or \"React Context (simpler, no new dependencies)\"\n</bad_example>\n\n<bad_example>\n{\n \"id\": \"q3\",\n \"question\": \"What color scheme should the button use?\",\n \"options\": [\n \"Use the existing theme colors\",\n \"Let me specify custom colors\",\n \"Match the design system\"\n ]\n}\nReason: \"Let me specify\" requires user input. Should be \"Primary blue (#0066FF, existing theme)\" or \"Secondary gray (#6B7280, existing theme)\"\n</bad_example>\n</question_examples>`;\n"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Logger } from
|
|
1
|
+
import type { ResearchEvaluation, SupportingFile } from "./types.js";
|
|
2
|
+
import { Logger } from "./utils/logger.js";
|
|
3
3
|
export interface TaskFile {
|
|
4
4
|
name: string;
|
|
5
5
|
content: string;
|
|
6
|
-
type:
|
|
6
|
+
type: "plan" | "context" | "reference" | "output" | "artifact";
|
|
7
7
|
}
|
|
8
8
|
export interface LocalArtifact {
|
|
9
9
|
name: string;
|
|
10
10
|
content: string;
|
|
11
|
-
type: TaskFile[
|
|
11
|
+
type: TaskFile["type"];
|
|
12
12
|
contentType: string;
|
|
13
13
|
size: number;
|
|
14
14
|
}
|
|
@@ -33,8 +33,8 @@ export declare class PostHogFileManager {
|
|
|
33
33
|
readRequirements(taskId: string): Promise<string | null>;
|
|
34
34
|
writeResearch(taskId: string, data: ResearchEvaluation): Promise<void>;
|
|
35
35
|
readResearch(taskId: string): Promise<ResearchEvaluation | null>;
|
|
36
|
-
writeTodos(taskId: string, data:
|
|
37
|
-
readTodos(taskId: string): Promise<
|
|
36
|
+
writeTodos(taskId: string, data: unknown): Promise<void>;
|
|
37
|
+
readTodos(taskId: string): Promise<unknown | null>;
|
|
38
38
|
getTaskFiles(taskId: string): Promise<SupportingFile[]>;
|
|
39
39
|
collectTaskArtifacts(taskId: string): Promise<LocalArtifact[]>;
|
|
40
40
|
private resolveFileType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-manager.d.ts","sourceRoot":"","sources":["../../src/file-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-manager.d.ts","sourceRoot":"","sources":["../../src/file-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;CAChE;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAS;gBAEX,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAMnD,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IAIjB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASlD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5D,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CA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cAAc,EAAE,CAAC;IAsBvD,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA0BpE,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAazB"}
|
package/dist/src/file-manager.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { promises } from 'fs';
|
|
2
|
-
import { join, extname } from 'path';
|
|
1
|
+
import { promises } from 'node:fs';
|
|
2
|
+
import { join, extname } from 'node:path';
|
|
3
|
+
import z from 'zod';
|
|
3
4
|
import { Logger } from './utils/logger.js';
|
|
4
5
|
|
|
5
6
|
class PostHogFileManager {
|
|
@@ -7,10 +8,11 @@ class PostHogFileManager {
|
|
|
7
8
|
logger;
|
|
8
9
|
constructor(repositoryPath, logger) {
|
|
9
10
|
this.repositoryPath = repositoryPath;
|
|
10
|
-
this.logger =
|
|
11
|
+
this.logger =
|
|
12
|
+
logger || new Logger({ debug: false, prefix: "[FileManager]" });
|
|
11
13
|
}
|
|
12
14
|
getTaskDirectory(taskId) {
|
|
13
|
-
return join(this.repositoryPath,
|
|
15
|
+
return join(this.repositoryPath, ".posthog", taskId);
|
|
14
16
|
}
|
|
15
17
|
getTaskFilePath(taskId, fileName) {
|
|
16
18
|
return join(this.getTaskDirectory(taskId), fileName);
|
|
@@ -27,21 +29,21 @@ class PostHogFileManager {
|
|
|
27
29
|
async writeTaskFile(taskId, file) {
|
|
28
30
|
await this.ensureTaskDirectory(taskId);
|
|
29
31
|
const filePath = this.getTaskFilePath(taskId, file.name);
|
|
30
|
-
this.logger.debug(
|
|
32
|
+
this.logger.debug("Writing task file", {
|
|
31
33
|
filePath,
|
|
32
34
|
contentLength: file.content.length,
|
|
33
|
-
contentType: typeof file.content
|
|
35
|
+
contentType: typeof file.content,
|
|
34
36
|
});
|
|
35
|
-
await promises.writeFile(filePath, file.content,
|
|
36
|
-
this.logger.debug(
|
|
37
|
+
await promises.writeFile(filePath, file.content, "utf8");
|
|
38
|
+
this.logger.debug("File written successfully", { filePath });
|
|
37
39
|
}
|
|
38
40
|
async readTaskFile(taskId, fileName) {
|
|
39
41
|
try {
|
|
40
42
|
const filePath = this.getTaskFilePath(taskId, fileName);
|
|
41
|
-
return await promises.readFile(filePath,
|
|
43
|
+
return await promises.readFile(filePath, "utf8");
|
|
42
44
|
}
|
|
43
45
|
catch (error) {
|
|
44
|
-
if (error.code ===
|
|
46
|
+
if (error.code === "ENOENT") {
|
|
45
47
|
return null;
|
|
46
48
|
}
|
|
47
49
|
throw error;
|
|
@@ -51,10 +53,10 @@ class PostHogFileManager {
|
|
|
51
53
|
try {
|
|
52
54
|
const taskDir = this.getTaskDirectory(taskId);
|
|
53
55
|
const files = await promises.readdir(taskDir);
|
|
54
|
-
return files.filter(file => !file.startsWith(
|
|
56
|
+
return files.filter((file) => !file.startsWith("."));
|
|
55
57
|
}
|
|
56
58
|
catch (error) {
|
|
57
|
-
if (error.code ===
|
|
59
|
+
if (error.code === "ENOENT") {
|
|
58
60
|
return [];
|
|
59
61
|
}
|
|
60
62
|
throw error;
|
|
@@ -66,7 +68,7 @@ class PostHogFileManager {
|
|
|
66
68
|
await promises.unlink(filePath);
|
|
67
69
|
}
|
|
68
70
|
catch (error) {
|
|
69
|
-
if (error.code !==
|
|
71
|
+
if (error.code !== "ENOENT") {
|
|
70
72
|
throw error;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -87,50 +89,50 @@ class PostHogFileManager {
|
|
|
87
89
|
await promises.rm(taskDir, { recursive: true, force: true });
|
|
88
90
|
}
|
|
89
91
|
catch (error) {
|
|
90
|
-
if (error.code !==
|
|
92
|
+
if (error.code !== "ENOENT") {
|
|
91
93
|
throw error;
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
// Convenience methods for common file types
|
|
96
98
|
async writePlan(taskId, plan) {
|
|
97
|
-
this.logger.debug(
|
|
99
|
+
this.logger.debug("Writing plan", {
|
|
98
100
|
taskId,
|
|
99
101
|
planLength: plan.length,
|
|
100
|
-
contentPreview: plan.substring(0, 200)
|
|
102
|
+
contentPreview: plan.substring(0, 200),
|
|
101
103
|
});
|
|
102
104
|
await this.writeTaskFile(taskId, {
|
|
103
|
-
name:
|
|
105
|
+
name: "plan.md",
|
|
104
106
|
content: plan,
|
|
105
|
-
type:
|
|
107
|
+
type: "plan",
|
|
106
108
|
});
|
|
107
|
-
this.logger.info(
|
|
109
|
+
this.logger.info("Plan file written", { taskId });
|
|
108
110
|
}
|
|
109
111
|
async readPlan(taskId) {
|
|
110
|
-
return await this.readTaskFile(taskId,
|
|
112
|
+
return await this.readTaskFile(taskId, "plan.md");
|
|
111
113
|
}
|
|
112
114
|
async writeContext(taskId, context) {
|
|
113
115
|
await this.writeTaskFile(taskId, {
|
|
114
|
-
name:
|
|
116
|
+
name: "context.md",
|
|
115
117
|
content: context,
|
|
116
|
-
type:
|
|
118
|
+
type: "context",
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
121
|
async readContext(taskId) {
|
|
120
|
-
return await this.readTaskFile(taskId,
|
|
122
|
+
return await this.readTaskFile(taskId, "context.md");
|
|
121
123
|
}
|
|
122
124
|
async writeRequirements(taskId, requirements) {
|
|
123
125
|
await this.writeTaskFile(taskId, {
|
|
124
|
-
name:
|
|
126
|
+
name: "requirements.md",
|
|
125
127
|
content: requirements,
|
|
126
|
-
type:
|
|
128
|
+
type: "reference",
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
async readRequirements(taskId) {
|
|
130
|
-
return await this.readTaskFile(taskId,
|
|
132
|
+
return await this.readTaskFile(taskId, "requirements.md");
|
|
131
133
|
}
|
|
132
134
|
async writeResearch(taskId, data) {
|
|
133
|
-
this.logger.debug(
|
|
135
|
+
this.logger.debug("Writing research", {
|
|
134
136
|
taskId,
|
|
135
137
|
score: data.actionabilityScore,
|
|
136
138
|
hasQuestions: !!data.questions,
|
|
@@ -138,11 +140,11 @@ class PostHogFileManager {
|
|
|
138
140
|
answered: data.answered ?? false,
|
|
139
141
|
});
|
|
140
142
|
await this.writeTaskFile(taskId, {
|
|
141
|
-
name:
|
|
143
|
+
name: "research.json",
|
|
142
144
|
content: JSON.stringify(data, null, 2),
|
|
143
|
-
type:
|
|
145
|
+
type: "artifact",
|
|
144
146
|
});
|
|
145
|
-
this.logger.info(
|
|
147
|
+
this.logger.info("Research file written", {
|
|
146
148
|
taskId,
|
|
147
149
|
score: data.actionabilityScore,
|
|
148
150
|
hasQuestions: !!data.questions,
|
|
@@ -151,38 +153,45 @@ class PostHogFileManager {
|
|
|
151
153
|
}
|
|
152
154
|
async readResearch(taskId) {
|
|
153
155
|
try {
|
|
154
|
-
const content = await this.readTaskFile(taskId,
|
|
156
|
+
const content = await this.readTaskFile(taskId, "research.json");
|
|
155
157
|
return content ? JSON.parse(content) : null;
|
|
156
158
|
}
|
|
157
159
|
catch (error) {
|
|
158
|
-
this.logger.debug(
|
|
160
|
+
this.logger.debug("Failed to parse research.json", { error });
|
|
159
161
|
return null;
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
async writeTodos(taskId, data) {
|
|
163
|
-
|
|
165
|
+
const todos = z.object({
|
|
166
|
+
metadata: z.object({
|
|
167
|
+
total: z.number(),
|
|
168
|
+
completed: z.number(),
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
const validatedData = todos.parse(data);
|
|
172
|
+
this.logger.debug("Writing todos", {
|
|
164
173
|
taskId,
|
|
165
|
-
total:
|
|
166
|
-
completed:
|
|
174
|
+
total: validatedData.metadata?.total ?? 0,
|
|
175
|
+
completed: validatedData.metadata?.completed ?? 0,
|
|
167
176
|
});
|
|
168
177
|
await this.writeTaskFile(taskId, {
|
|
169
|
-
name:
|
|
170
|
-
content: JSON.stringify(
|
|
171
|
-
type:
|
|
178
|
+
name: "todos.json",
|
|
179
|
+
content: JSON.stringify(validatedData, null, 2),
|
|
180
|
+
type: "artifact",
|
|
172
181
|
});
|
|
173
|
-
this.logger.info(
|
|
182
|
+
this.logger.info("Todos file written", {
|
|
174
183
|
taskId,
|
|
175
|
-
total:
|
|
176
|
-
completed:
|
|
184
|
+
total: validatedData.metadata?.total ?? 0,
|
|
185
|
+
completed: validatedData.metadata?.completed ?? 0,
|
|
177
186
|
});
|
|
178
187
|
}
|
|
179
188
|
async readTodos(taskId) {
|
|
180
189
|
try {
|
|
181
|
-
const content = await this.readTaskFile(taskId,
|
|
190
|
+
const content = await this.readTaskFile(taskId, "todos.json");
|
|
182
191
|
return content ? JSON.parse(content) : null;
|
|
183
192
|
}
|
|
184
193
|
catch (error) {
|
|
185
|
-
this.logger.debug(
|
|
194
|
+
this.logger.debug("Failed to parse todos.json", { error });
|
|
186
195
|
return null;
|
|
187
196
|
}
|
|
188
197
|
}
|
|
@@ -198,7 +207,7 @@ class PostHogFileManager {
|
|
|
198
207
|
name: fileName,
|
|
199
208
|
content,
|
|
200
209
|
type,
|
|
201
|
-
created_at: new Date().toISOString() // Could be enhanced with file stats
|
|
210
|
+
created_at: new Date().toISOString(), // Could be enhanced with file stats
|
|
202
211
|
});
|
|
203
212
|
}
|
|
204
213
|
}
|
|
@@ -214,7 +223,7 @@ class PostHogFileManager {
|
|
|
214
223
|
}
|
|
215
224
|
const type = this.resolveFileType(fileName);
|
|
216
225
|
const contentType = this.inferContentType(fileName);
|
|
217
|
-
const size = Buffer.byteLength(content,
|
|
226
|
+
const size = Buffer.byteLength(content, "utf8");
|
|
218
227
|
artifacts.push({
|
|
219
228
|
name: fileName,
|
|
220
229
|
content,
|
|
@@ -226,29 +235,29 @@ class PostHogFileManager {
|
|
|
226
235
|
return artifacts;
|
|
227
236
|
}
|
|
228
237
|
resolveFileType(fileName) {
|
|
229
|
-
if (fileName ===
|
|
230
|
-
return
|
|
231
|
-
if (fileName ===
|
|
232
|
-
return
|
|
233
|
-
if (fileName ===
|
|
234
|
-
return
|
|
235
|
-
if (fileName.startsWith(
|
|
236
|
-
return
|
|
237
|
-
if (fileName.endsWith(
|
|
238
|
-
return
|
|
239
|
-
return
|
|
238
|
+
if (fileName === "plan.md")
|
|
239
|
+
return "plan";
|
|
240
|
+
if (fileName === "context.md")
|
|
241
|
+
return "context";
|
|
242
|
+
if (fileName === "requirements.md")
|
|
243
|
+
return "reference";
|
|
244
|
+
if (fileName.startsWith("output_"))
|
|
245
|
+
return "output";
|
|
246
|
+
if (fileName.endsWith(".md"))
|
|
247
|
+
return "reference";
|
|
248
|
+
return "artifact";
|
|
240
249
|
}
|
|
241
250
|
inferContentType(fileName) {
|
|
242
251
|
const extension = extname(fileName).toLowerCase();
|
|
243
252
|
switch (extension) {
|
|
244
|
-
case
|
|
245
|
-
return
|
|
246
|
-
case
|
|
247
|
-
return
|
|
248
|
-
case
|
|
249
|
-
return
|
|
253
|
+
case ".md":
|
|
254
|
+
return "text/markdown";
|
|
255
|
+
case ".json":
|
|
256
|
+
return "application/json";
|
|
257
|
+
case ".txt":
|
|
258
|
+
return "text/plain";
|
|
250
259
|
default:
|
|
251
|
-
return
|
|
260
|
+
return "text/plain";
|
|
252
261
|
}
|
|
253
262
|
}
|
|
254
263
|
}
|