@amplitude/ai 0.1.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/.cursor/skills/instrument-with-amplitude-ai/SKILL.md +50 -0
- package/AGENTS.md +79 -0
- package/LICENSE +21 -0
- package/README.md +2111 -0
- package/bin/amplitude-ai-completions.mjs +19 -0
- package/bin/amplitude-ai-doctor.mjs +26 -0
- package/bin/amplitude-ai-init.mjs +27 -0
- package/bin/amplitude-ai-instrument.mjs +52 -0
- package/bin/amplitude-ai-mcp.mjs +8 -0
- package/bin/amplitude-ai-register-catalog.mjs +156 -0
- package/bin/amplitude-ai-status.mjs +28 -0
- package/bin/amplitude-ai.mjs +43 -0
- package/bin/validate-catalog-constants.mjs +134 -0
- package/data/agent_event_catalog.json +1277 -0
- package/dist/_virtual/rolldown_runtime.js +31 -0
- package/dist/bound-agent.d.ts +56 -0
- package/dist/bound-agent.d.ts.map +1 -0
- package/dist/bound-agent.js +155 -0
- package/dist/bound-agent.js.map +1 -0
- package/dist/cli/doctor.d.ts +17 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +89 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/init.d.ts +14 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +40 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/providers.d.ts +32 -0
- package/dist/cli/providers.d.ts.map +1 -0
- package/dist/cli/providers.js +46 -0
- package/dist/cli/providers.js.map +1 -0
- package/dist/cli/status.d.ts +14 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +38 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/client.d.ts +246 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +369 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +44 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +53 -0
- package/dist/context.js.map +1 -0
- package/dist/core/constants.d.ts +96 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +105 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/enrichments.d.ts +139 -0
- package/dist/core/enrichments.d.ts.map +1 -0
- package/dist/core/enrichments.js +177 -0
- package/dist/core/enrichments.js.map +1 -0
- package/dist/core/privacy.d.ts +53 -0
- package/dist/core/privacy.d.ts.map +1 -0
- package/dist/core/privacy.js +235 -0
- package/dist/core/privacy.js.map +1 -0
- package/dist/core/tracking.d.ts +242 -0
- package/dist/core/tracking.d.ts.map +1 -0
- package/dist/core/tracking.js +469 -0
- package/dist/core/tracking.js.map +1 -0
- package/dist/decorators.d.ts +109 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +281 -0
- package/dist/decorators.js.map +1 -0
- package/dist/exceptions.d.ts +19 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +35 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +38 -0
- package/dist/integrations/anthropic-tools.d.ts +38 -0
- package/dist/integrations/anthropic-tools.d.ts.map +1 -0
- package/dist/integrations/anthropic-tools.js +175 -0
- package/dist/integrations/anthropic-tools.js.map +1 -0
- package/dist/integrations/crewai.d.ts +14 -0
- package/dist/integrations/crewai.d.ts.map +1 -0
- package/dist/integrations/crewai.js +19 -0
- package/dist/integrations/crewai.js.map +1 -0
- package/dist/integrations/langchain.d.ts +37 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +189 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/integrations/llamaindex.d.ts +44 -0
- package/dist/integrations/llamaindex.d.ts.map +1 -0
- package/dist/integrations/llamaindex.js +144 -0
- package/dist/integrations/llamaindex.js.map +1 -0
- package/dist/integrations/openai-agents.d.ts +35 -0
- package/dist/integrations/openai-agents.d.ts.map +1 -0
- package/dist/integrations/openai-agents.js +248 -0
- package/dist/integrations/openai-agents.js.map +1 -0
- package/dist/integrations/opentelemetry.d.ts +40 -0
- package/dist/integrations/opentelemetry.d.ts.map +1 -0
- package/dist/integrations/opentelemetry.js +146 -0
- package/dist/integrations/opentelemetry.js.map +1 -0
- package/dist/internals.d.ts +5 -0
- package/dist/internals.js +5 -0
- package/dist/mcp/contract.d.ts +27 -0
- package/dist/mcp/contract.d.ts.map +1 -0
- package/dist/mcp/contract.js +25 -0
- package/dist/mcp/contract.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/patterns.d.ts +11 -0
- package/dist/mcp/patterns.d.ts.map +1 -0
- package/dist/mcp/patterns.js +38 -0
- package/dist/mcp/patterns.js.map +1 -0
- package/dist/mcp/server.d.ts +10 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +241 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/validate-file.d.ts +20 -0
- package/dist/mcp/validate-file.d.ts.map +1 -0
- package/dist/mcp/validate-file.js +122 -0
- package/dist/mcp/validate-file.js.map +1 -0
- package/dist/middleware.d.ts +32 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +67 -0
- package/dist/middleware.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js +54 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js +20 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js +34 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js +225 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +22 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +351 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +634 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +60 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +122 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +37 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +858 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +32 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +74 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1262 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +83 -0
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js +195 -0
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js +44 -0
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js +88 -0
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js +107 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js +142 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js +678 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js +145 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js +106 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js +227 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js +33 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js +137 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js +65 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js +150 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js +52 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js +176 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js +437 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js +117 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js +76 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js +587 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.js +145 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js +29 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js +20 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +61 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +101 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +34 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +21 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +94 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +91 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js +64 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js +63 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +39 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js +36 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +56 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +66 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +57 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +46 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js +134 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js +19 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js +116 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +106 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js +31 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js +97 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js +15 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js +32 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js +54 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js +53 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +33 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +38 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +52 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +33 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +32 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +43 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js +77 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +75 -0
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +37 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +240 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +194 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js.map +1 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +286 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +82 -0
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js +30 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +16 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js +57 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +17 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +23 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +36 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +39 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +13 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +11 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +47 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +17 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +38 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +16 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +13 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +11 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +46 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +37 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +64 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +20 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +27 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +56 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +21 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +250 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +38 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +64 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +10 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js +78 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +70 -0
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js +104 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +11 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js +10 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js +110 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js +99 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js +84 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js +3160 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/errors.js +23 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/errors.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/iso.js +38 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/iso.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/parse.js +12 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/parse.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/schemas.js +611 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/schemas.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/api.js +437 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/api.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/checks.js +360 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/checks.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js +50 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/doc.js +34 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/doc.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/errors.js +71 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/errors.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/parse.js +74 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/parse.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/regexes.js +63 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/regexes.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/registries.js +50 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/registries.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/schemas.js +1098 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/schemas.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/to-json-schema.js +599 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/util.js +267 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/util.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/versions.js +10 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/versions.js.map +1 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/mini/schemas.js +50 -0
- package/dist/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/mini/schemas.js.map +1 -0
- package/dist/patching.d.ts +59 -0
- package/dist/patching.d.ts.map +1 -0
- package/dist/patching.js +891 -0
- package/dist/patching.js.map +1 -0
- package/dist/propagation.d.ts +8 -0
- package/dist/propagation.d.ts.map +1 -0
- package/dist/propagation.js +46 -0
- package/dist/propagation.js.map +1 -0
- package/dist/providers/anthropic.d.ts +44 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +287 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/azure-openai.d.ts +32 -0
- package/dist/providers/azure-openai.d.ts.map +1 -0
- package/dist/providers/azure-openai.js +39 -0
- package/dist/providers/azure-openai.js.map +1 -0
- package/dist/providers/base.d.ts +70 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +141 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/bedrock.d.ts +41 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +229 -0
- package/dist/providers/bedrock.js.map +1 -0
- package/dist/providers/gemini.d.ts +34 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +225 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/mistral.d.ts +32 -0
- package/dist/providers/mistral.d.ts.map +1 -0
- package/dist/providers/mistral.js +218 -0
- package/dist/providers/mistral.js.map +1 -0
- package/dist/providers/openai.d.ts +61 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +530 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +46 -0
- package/dist/register.js.map +1 -0
- package/dist/session.d.ts +46 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +144 -0
- package/dist/session.js.map +1 -0
- package/dist/tenant.d.ts +30 -0
- package/dist/tenant.d.ts.map +1 -0
- package/dist/tenant.js +23 -0
- package/dist/tenant.js.map +1 -0
- package/dist/testing.d.ts +46 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +120 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +384 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/costs.d.ts +27 -0
- package/dist/utils/costs.d.ts.map +1 -0
- package/dist/utils/costs.js +63 -0
- package/dist/utils/costs.js.map +1 -0
- package/dist/utils/debug.d.ts +6 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +73 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +18 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/model-tiers.d.ts +8 -0
- package/dist/utils/model-tiers.d.ts.map +1 -0
- package/dist/utils/model-tiers.js +76 -0
- package/dist/utils/model-tiers.js.map +1 -0
- package/dist/utils/providers.d.ts +5 -0
- package/dist/utils/providers.d.ts.map +1 -0
- package/dist/utils/providers.js +20 -0
- package/dist/utils/providers.js.map +1 -0
- package/dist/utils/resolve-module.d.ts +5 -0
- package/dist/utils/resolve-module.d.ts.map +1 -0
- package/dist/utils/resolve-module.js +29 -0
- package/dist/utils/resolve-module.js.map +1 -0
- package/dist/utils/streaming.d.ts +55 -0
- package/dist/utils/streaming.d.ts.map +1 -0
- package/dist/utils/streaming.js +72 -0
- package/dist/utils/streaming.js.map +1 -0
- package/dist/utils/tokens.d.ts +16 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/tokens.js +80 -0
- package/dist/utils/tokens.js.map +1 -0
- package/dist/wrappers.d.ts +37 -0
- package/dist/wrappers.d.ts.map +1 -0
- package/dist/wrappers.js +61 -0
- package/dist/wrappers.js.map +1 -0
- package/llms-full.txt +127 -0
- package/llms.txt +28 -0
- package/mcp.schema.json +18 -0
- package/package.json +189 -0
package/dist/patching.js
ADDED
|
@@ -0,0 +1,891 @@
|
|
|
1
|
+
import { getActiveContext } from "./context.js";
|
|
2
|
+
import { ANTHROPIC_AVAILABLE, _AnthropicModule } from "./providers/anthropic.js";
|
|
3
|
+
import { BEDROCK_AVAILABLE, _BedrockModule } from "./providers/bedrock.js";
|
|
4
|
+
import { GEMINI_AVAILABLE, _GeminiModule } from "./providers/gemini.js";
|
|
5
|
+
import { MISTRAL_AVAILABLE, _MistralModule } from "./providers/mistral.js";
|
|
6
|
+
import { OPENAI_AVAILABLE, _OpenAIModule } from "./providers/openai.js";
|
|
7
|
+
|
|
8
|
+
//#region src/patching.ts
|
|
9
|
+
var PatchOwnershipError = class extends Error {};
|
|
10
|
+
const _activePatches = [];
|
|
11
|
+
const _patchedProviders = /* @__PURE__ */ new Set();
|
|
12
|
+
const _providerOwners = /* @__PURE__ */ new Map();
|
|
13
|
+
function patchedProviders() {
|
|
14
|
+
return [..._patchedProviders];
|
|
15
|
+
}
|
|
16
|
+
function _isMethodPatched(target, methodName) {
|
|
17
|
+
return target[methodName]?.__amplitudePatched === true;
|
|
18
|
+
}
|
|
19
|
+
function _patchMethod(target, methodName, wrapper, providerName) {
|
|
20
|
+
const original = target[methodName];
|
|
21
|
+
if (typeof original !== "function") return;
|
|
22
|
+
if (_isMethodPatched(target, methodName)) return;
|
|
23
|
+
const patched = function(...args) {
|
|
24
|
+
return wrapper(original.bind(this), ...args);
|
|
25
|
+
};
|
|
26
|
+
patched.__amplitudePatched = true;
|
|
27
|
+
target[methodName] = patched;
|
|
28
|
+
_activePatches.push({
|
|
29
|
+
module: target,
|
|
30
|
+
method: methodName,
|
|
31
|
+
original,
|
|
32
|
+
provider: providerName
|
|
33
|
+
});
|
|
34
|
+
_patchedProviders.add(providerName);
|
|
35
|
+
}
|
|
36
|
+
function _assertPatchOwner(providerName, ai) {
|
|
37
|
+
const existingOwner = _providerOwners.get(providerName);
|
|
38
|
+
if (existingOwner == null) {
|
|
39
|
+
_providerOwners.set(providerName, ai);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (existingOwner !== ai) throw new PatchOwnershipError(`Provider "${providerName}" is already patched by another AmplitudeAI instance. Call unpatch() before patching with a different instance.`);
|
|
43
|
+
}
|
|
44
|
+
function patchOpenAI(options) {
|
|
45
|
+
const { amplitudeAI } = options;
|
|
46
|
+
const mod = options.module ?? _OpenAIModule;
|
|
47
|
+
if (mod == null) throw new Error("openai package is not installed. Install it with: npm install openai — or pass the module via the modules option.");
|
|
48
|
+
_assertPatchOwner("openai", amplitudeAI);
|
|
49
|
+
if (_patchOpenAIClass(mod.OpenAI, mod, "OpenAI", amplitudeAI, "openai")) _patchedProviders.add("openai");
|
|
50
|
+
}
|
|
51
|
+
function patchAnthropic(options) {
|
|
52
|
+
const { amplitudeAI } = options;
|
|
53
|
+
const mod = options.module ?? _AnthropicModule;
|
|
54
|
+
if (mod == null) throw new Error("@anthropic-ai/sdk package is not installed. Install it with: npm install @anthropic-ai/sdk — or pass the module via the modules option.");
|
|
55
|
+
_assertPatchOwner("anthropic", amplitudeAI);
|
|
56
|
+
const AnthropicClass = mod.Anthropic;
|
|
57
|
+
if (!AnthropicClass?.prototype) return;
|
|
58
|
+
let didPatch = false;
|
|
59
|
+
const messagesProto = _getNestedPrototype(AnthropicClass, ["messages"]);
|
|
60
|
+
if (messagesProto) {
|
|
61
|
+
const target = messagesProto;
|
|
62
|
+
_patchMethod(target, "create", _makeCompletionWrapper(amplitudeAI, "anthropic"), "anthropic");
|
|
63
|
+
_patchMethod(target, "stream", _makeAnthropicStreamWrapper(amplitudeAI), "anthropic");
|
|
64
|
+
didPatch = _isMethodPatched(target, "create") || _isMethodPatched(target, "stream");
|
|
65
|
+
}
|
|
66
|
+
if (didPatch) _patchedProviders.add("anthropic");
|
|
67
|
+
}
|
|
68
|
+
function patchAzureOpenAI(options) {
|
|
69
|
+
const { amplitudeAI } = options;
|
|
70
|
+
const mod = options.module ?? _OpenAIModule;
|
|
71
|
+
if (mod == null) throw new Error("openai package is not installed. Install it with: npm install openai — or pass the module via the modules option.");
|
|
72
|
+
_assertPatchOwner("azure-openai", amplitudeAI);
|
|
73
|
+
if (_patchOpenAIClass(mod.AzureOpenAI, mod, "AzureOpenAI", amplitudeAI, "azure-openai")) _patchedProviders.add("azure-openai");
|
|
74
|
+
}
|
|
75
|
+
function patchGemini(options) {
|
|
76
|
+
const { amplitudeAI } = options;
|
|
77
|
+
const mod = options.module ?? _GeminiModule;
|
|
78
|
+
if (mod == null) throw new Error("@google/generative-ai is not installed. Install it with: npm install @google/generative-ai — or pass the module via the modules option.");
|
|
79
|
+
_assertPatchOwner("gemini", amplitudeAI);
|
|
80
|
+
const GeminiClass = mod.GoogleGenerativeAI;
|
|
81
|
+
if (!GeminiClass?.prototype) return;
|
|
82
|
+
const proto = GeminiClass.prototype;
|
|
83
|
+
_patchMethod(proto, "getGenerativeModel", (original, ...args) => {
|
|
84
|
+
const modelObj = original(...args);
|
|
85
|
+
if (modelObj == null || typeof modelObj !== "object") return modelObj;
|
|
86
|
+
const model = modelObj;
|
|
87
|
+
if (typeof model.generateContent === "function" && !(model.generateContent.__amplitudePatched === true)) _patchMethod(model, "generateContent", (innerOriginal, ...innerArgs) => {
|
|
88
|
+
const startTime = performance.now();
|
|
89
|
+
const result = innerOriginal(...innerArgs);
|
|
90
|
+
if (result instanceof Promise) return result.then((response) => {
|
|
91
|
+
_trackGeminiResponse(amplitudeAI, response, startTime);
|
|
92
|
+
return response;
|
|
93
|
+
}).catch((err) => {
|
|
94
|
+
_trackCompletionError(amplitudeAI, err, startTime, innerArgs[0], "gemini");
|
|
95
|
+
throw err;
|
|
96
|
+
});
|
|
97
|
+
return result;
|
|
98
|
+
}, "gemini");
|
|
99
|
+
if (typeof model.generateContentStream === "function" && !(model.generateContentStream.__amplitudePatched === true)) _patchMethod(model, "generateContentStream", (innerOriginal, ...innerArgs) => {
|
|
100
|
+
const startTime = performance.now();
|
|
101
|
+
const result = innerOriginal(...innerArgs);
|
|
102
|
+
if (result instanceof Promise) return result.then((response) => {
|
|
103
|
+
const streamResp = response;
|
|
104
|
+
const stream = streamResp.stream;
|
|
105
|
+
if (_isAsyncIterable(stream)) return {
|
|
106
|
+
...streamResp,
|
|
107
|
+
stream: _wrapPatchedStream(amplitudeAI, stream, startTime, innerArgs[0], "gemini")
|
|
108
|
+
};
|
|
109
|
+
return response;
|
|
110
|
+
}).catch((err) => {
|
|
111
|
+
_trackCompletionError(amplitudeAI, err, startTime, innerArgs[0], "gemini");
|
|
112
|
+
throw err;
|
|
113
|
+
});
|
|
114
|
+
return result;
|
|
115
|
+
}, "gemini");
|
|
116
|
+
return modelObj;
|
|
117
|
+
}, "gemini");
|
|
118
|
+
if (_isMethodPatched(proto, "getGenerativeModel")) _patchedProviders.add("gemini");
|
|
119
|
+
}
|
|
120
|
+
function patchMistral(options) {
|
|
121
|
+
const { amplitudeAI } = options;
|
|
122
|
+
const mod = options.module ?? _MistralModule;
|
|
123
|
+
if (mod == null) throw new Error("@mistralai/mistralai is not installed. Install it with: npm install @mistralai/mistralai — or pass the module via the modules option.");
|
|
124
|
+
_assertPatchOwner("mistral", amplitudeAI);
|
|
125
|
+
const MistralClass = mod.Mistral ?? mod.MistralClient ?? mod.default;
|
|
126
|
+
if (!MistralClass?.prototype) return;
|
|
127
|
+
const chatProto = _getNestedPrototype(MistralClass, ["chat"]);
|
|
128
|
+
let didPatch = false;
|
|
129
|
+
if (chatProto) {
|
|
130
|
+
const target = chatProto;
|
|
131
|
+
_patchMethod(target, "complete", _makeCompletionWrapper(amplitudeAI, "mistral"), "mistral");
|
|
132
|
+
_patchMethod(target, "stream", _makeCompletionWrapper(amplitudeAI, "mistral"), "mistral");
|
|
133
|
+
didPatch = _isMethodPatched(target, "complete") || _isMethodPatched(target, "stream");
|
|
134
|
+
}
|
|
135
|
+
if (didPatch) _patchedProviders.add("mistral");
|
|
136
|
+
}
|
|
137
|
+
function patchBedrock(options) {
|
|
138
|
+
const { amplitudeAI } = options;
|
|
139
|
+
const mod = options.module ?? _BedrockModule;
|
|
140
|
+
if (mod == null) throw new Error("@aws-sdk/client-bedrock-runtime is not installed. Install it with: npm install @aws-sdk/client-bedrock-runtime — or pass the module via the modules option.");
|
|
141
|
+
_assertPatchOwner("bedrock", amplitudeAI);
|
|
142
|
+
const ClientClass = mod.BedrockRuntimeClient;
|
|
143
|
+
if (!ClientClass?.prototype) return;
|
|
144
|
+
_patchMethod(ClientClass.prototype, "send", (original, ...args) => {
|
|
145
|
+
const command = args[0];
|
|
146
|
+
const commandName = String(command?.constructor?.name ?? "");
|
|
147
|
+
const shouldTrack = commandName.includes("ConverseCommand") || commandName.includes("ConverseStreamCommand");
|
|
148
|
+
const startTime = performance.now();
|
|
149
|
+
const result = original(...args);
|
|
150
|
+
if (result instanceof Promise) return result.then((response) => {
|
|
151
|
+
if (!shouldTrack) return response;
|
|
152
|
+
if (commandName.includes("ConverseStreamCommand")) {
|
|
153
|
+
const streamResp = response;
|
|
154
|
+
const stream = streamResp.stream;
|
|
155
|
+
if (_isAsyncIterable(stream)) return {
|
|
156
|
+
...streamResp,
|
|
157
|
+
stream: _wrapPatchedBedrockStream(amplitudeAI, stream, startTime, args[0])
|
|
158
|
+
};
|
|
159
|
+
} else _trackBedrockResponse(amplitudeAI, response, startTime, args[0]);
|
|
160
|
+
return response;
|
|
161
|
+
}).catch((err) => {
|
|
162
|
+
if (shouldTrack) _trackCompletionError(amplitudeAI, err, startTime, args[0], "bedrock");
|
|
163
|
+
throw err;
|
|
164
|
+
});
|
|
165
|
+
return result;
|
|
166
|
+
}, "bedrock");
|
|
167
|
+
if (_isMethodPatched(ClientClass.prototype, "send")) _patchedProviders.add("bedrock");
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Auto-detects installed provider SDKs and patches each supported surface.
|
|
171
|
+
*
|
|
172
|
+
* Returns the list of provider names that were successfully patched.
|
|
173
|
+
* Ownership conflicts (same provider patched by a different `AmplitudeAI` instance)
|
|
174
|
+
* throw immediately to prevent ambiguous instrumentation state.
|
|
175
|
+
*
|
|
176
|
+
* In bundler environments where `tryRequire` cannot resolve modules, pass them
|
|
177
|
+
* explicitly via `modules`:
|
|
178
|
+
* ```ts
|
|
179
|
+
* import OpenAI from 'openai';
|
|
180
|
+
* import Anthropic from '@anthropic-ai/sdk';
|
|
181
|
+
* patch({ amplitudeAI: ai, modules: { openai: OpenAI, anthropic: Anthropic } });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
function patch(options) {
|
|
185
|
+
const patched = [];
|
|
186
|
+
const mods = options.modules ?? {};
|
|
187
|
+
const providers = [
|
|
188
|
+
{
|
|
189
|
+
fn: patchOpenAI,
|
|
190
|
+
available: OPENAI_AVAILABLE || mods.openai != null,
|
|
191
|
+
name: "openai",
|
|
192
|
+
moduleKey: "openai"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
fn: patchAzureOpenAI,
|
|
196
|
+
available: OPENAI_AVAILABLE || mods.openai != null,
|
|
197
|
+
name: "azure-openai",
|
|
198
|
+
moduleKey: "openai"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
fn: patchAnthropic,
|
|
202
|
+
available: ANTHROPIC_AVAILABLE || mods.anthropic != null,
|
|
203
|
+
name: "anthropic",
|
|
204
|
+
moduleKey: "anthropic"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
fn: patchGemini,
|
|
208
|
+
available: GEMINI_AVAILABLE || mods.gemini != null,
|
|
209
|
+
name: "gemini",
|
|
210
|
+
moduleKey: "gemini"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
fn: patchMistral,
|
|
214
|
+
available: MISTRAL_AVAILABLE || mods.mistral != null,
|
|
215
|
+
name: "mistral",
|
|
216
|
+
moduleKey: "mistral"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
fn: patchBedrock,
|
|
220
|
+
available: BEDROCK_AVAILABLE || mods.bedrock != null,
|
|
221
|
+
name: "bedrock",
|
|
222
|
+
moduleKey: "bedrock"
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
for (const { fn, available, name, moduleKey } of providers) {
|
|
226
|
+
if (!available) continue;
|
|
227
|
+
try {
|
|
228
|
+
fn({
|
|
229
|
+
amplitudeAI: options.amplitudeAI,
|
|
230
|
+
module: mods[moduleKey]
|
|
231
|
+
});
|
|
232
|
+
if (_patchedProviders.has(name)) patched.push(name);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (error instanceof PatchOwnershipError) throw error;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return patched;
|
|
238
|
+
}
|
|
239
|
+
function unpatch() {
|
|
240
|
+
for (const record of _activePatches.reverse()) {
|
|
241
|
+
const target = record.module;
|
|
242
|
+
target[record.method] = record.original;
|
|
243
|
+
}
|
|
244
|
+
_activePatches.length = 0;
|
|
245
|
+
_patchedProviders.clear();
|
|
246
|
+
_providerOwners.clear();
|
|
247
|
+
}
|
|
248
|
+
function unpatchOpenAI() {
|
|
249
|
+
_unpatchByProvider("openai");
|
|
250
|
+
}
|
|
251
|
+
function unpatchAnthropic() {
|
|
252
|
+
_unpatchByProvider("anthropic");
|
|
253
|
+
}
|
|
254
|
+
function unpatchGemini() {
|
|
255
|
+
_unpatchByProvider("gemini");
|
|
256
|
+
}
|
|
257
|
+
function unpatchMistral() {
|
|
258
|
+
_unpatchByProvider("mistral");
|
|
259
|
+
}
|
|
260
|
+
function unpatchBedrock() {
|
|
261
|
+
_unpatchByProvider("bedrock");
|
|
262
|
+
}
|
|
263
|
+
function unpatchAzureOpenAI() {
|
|
264
|
+
_unpatchByProvider("azure-openai");
|
|
265
|
+
}
|
|
266
|
+
function _unpatchByProvider(providerName) {
|
|
267
|
+
const toRemove = [];
|
|
268
|
+
for (let i = _activePatches.length - 1; i >= 0; i--) {
|
|
269
|
+
const record = _activePatches[i];
|
|
270
|
+
if (record == null) continue;
|
|
271
|
+
if (record.provider === providerName) {
|
|
272
|
+
const target = record.module;
|
|
273
|
+
target[record.method] = record.original;
|
|
274
|
+
toRemove.push(i);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
for (const idx of toRemove) _activePatches.splice(idx, 1);
|
|
278
|
+
_patchedProviders.delete(providerName);
|
|
279
|
+
_providerOwners.delete(providerName);
|
|
280
|
+
}
|
|
281
|
+
function _makeCompletionWrapper(amplitudeAI, providerName) {
|
|
282
|
+
return (original, ...args) => {
|
|
283
|
+
const startTime = performance.now();
|
|
284
|
+
const result = original(...args);
|
|
285
|
+
if (result instanceof Promise) return result.then((response) => {
|
|
286
|
+
if (_isAsyncIterable(response)) {
|
|
287
|
+
if (providerName === "anthropic") return _wrapPatchedAnthropicStream(amplitudeAI, response, startTime, args[0]);
|
|
288
|
+
return _wrapPatchedStream(amplitudeAI, response, startTime, args[0], providerName);
|
|
289
|
+
}
|
|
290
|
+
if (providerName === "anthropic") _trackAnthropicResponse(amplitudeAI, response, startTime, args[0]);
|
|
291
|
+
else _trackCompletionResponse(amplitudeAI, response, startTime, args[0], providerName);
|
|
292
|
+
return response;
|
|
293
|
+
}).catch((err) => {
|
|
294
|
+
_trackCompletionError(amplitudeAI, err, startTime, args[0], providerName);
|
|
295
|
+
throw err;
|
|
296
|
+
});
|
|
297
|
+
return result;
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function _makeAnthropicStreamWrapper(amplitudeAI) {
|
|
301
|
+
return (original, ...args) => {
|
|
302
|
+
const startTime = performance.now();
|
|
303
|
+
const result = original(...args);
|
|
304
|
+
if (!(result instanceof Promise)) return result;
|
|
305
|
+
return result.then((response) => {
|
|
306
|
+
if (_isAsyncIterable(response)) return _wrapPatchedAnthropicStream(amplitudeAI, response, startTime, args[0]);
|
|
307
|
+
const respObj = response;
|
|
308
|
+
const stream = respObj.stream;
|
|
309
|
+
if (_isAsyncIterable(stream)) return {
|
|
310
|
+
...respObj,
|
|
311
|
+
stream: _wrapPatchedAnthropicStream(amplitudeAI, stream, startTime, args[0])
|
|
312
|
+
};
|
|
313
|
+
return response;
|
|
314
|
+
}).catch((err) => {
|
|
315
|
+
_trackCompletionError(amplitudeAI, err, startTime, args[0], "anthropic");
|
|
316
|
+
throw err;
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function _isAsyncIterable(value) {
|
|
321
|
+
return value != null && typeof value[Symbol.asyncIterator] === "function";
|
|
322
|
+
}
|
|
323
|
+
async function* _wrapPatchedStream(ai, stream, startTime, requestOpts, providerName) {
|
|
324
|
+
if (providerName === "gemini") {
|
|
325
|
+
yield* _wrapPatchedGeminiStream(ai, stream, startTime, requestOpts);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const ctx = getActiveContext();
|
|
329
|
+
if (ctx == null) {
|
|
330
|
+
yield* stream;
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
let content = "";
|
|
334
|
+
let model = "unknown";
|
|
335
|
+
let finishReason = "";
|
|
336
|
+
let inputTokens;
|
|
337
|
+
let outputTokens;
|
|
338
|
+
let totalTokens;
|
|
339
|
+
let isError = false;
|
|
340
|
+
let errorMessage;
|
|
341
|
+
try {
|
|
342
|
+
for await (const chunk of stream) {
|
|
343
|
+
const c = chunk;
|
|
344
|
+
const choices = c.choices;
|
|
345
|
+
const delta = choices?.[0]?.delta;
|
|
346
|
+
if (delta?.content != null) content += String(delta.content);
|
|
347
|
+
if (c.model != null) model = String(c.model);
|
|
348
|
+
if (choices?.[0]?.finish_reason != null) finishReason = String(choices[0].finish_reason);
|
|
349
|
+
const usage = c.usage;
|
|
350
|
+
if (usage != null) {
|
|
351
|
+
inputTokens = usage.prompt_tokens;
|
|
352
|
+
outputTokens = usage.completion_tokens;
|
|
353
|
+
totalTokens = usage.total_tokens;
|
|
354
|
+
}
|
|
355
|
+
yield chunk;
|
|
356
|
+
}
|
|
357
|
+
} catch (error) {
|
|
358
|
+
isError = true;
|
|
359
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
360
|
+
throw error;
|
|
361
|
+
} finally {
|
|
362
|
+
const latencyMs = performance.now() - startTime;
|
|
363
|
+
ai.trackAiMessage({
|
|
364
|
+
userId: ctx.userId ?? "unknown",
|
|
365
|
+
content,
|
|
366
|
+
sessionId: ctx.sessionId,
|
|
367
|
+
model,
|
|
368
|
+
provider: providerName,
|
|
369
|
+
latencyMs,
|
|
370
|
+
traceId: ctx.traceId,
|
|
371
|
+
inputTokens,
|
|
372
|
+
outputTokens,
|
|
373
|
+
totalTokens,
|
|
374
|
+
finishReason,
|
|
375
|
+
agentId: ctx.agentId,
|
|
376
|
+
env: ctx.env,
|
|
377
|
+
isStreaming: true,
|
|
378
|
+
isError,
|
|
379
|
+
errorMessage,
|
|
380
|
+
..._contextExtras(ctx)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
async function* _wrapPatchedAnthropicStream(ai, stream, startTime, requestOpts) {
|
|
385
|
+
const ctx = getActiveContext();
|
|
386
|
+
if (ctx == null) {
|
|
387
|
+
yield* stream;
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const req = requestOpts;
|
|
391
|
+
let content = "";
|
|
392
|
+
let model = String(req?.model ?? "unknown");
|
|
393
|
+
let finishReason = "";
|
|
394
|
+
let inputTokens;
|
|
395
|
+
let outputTokens;
|
|
396
|
+
let isError = false;
|
|
397
|
+
let errorMessage;
|
|
398
|
+
try {
|
|
399
|
+
for await (const chunk of stream) {
|
|
400
|
+
const c = chunk;
|
|
401
|
+
if (c.type === "message_start") {
|
|
402
|
+
const message = c.message;
|
|
403
|
+
if (typeof message?.model === "string") model = message.model;
|
|
404
|
+
const usage = message?.usage;
|
|
405
|
+
if (typeof usage?.input_tokens === "number") inputTokens = usage.input_tokens;
|
|
406
|
+
}
|
|
407
|
+
if (c.type === "content_block_delta") {
|
|
408
|
+
const delta = c.delta;
|
|
409
|
+
if (typeof delta?.text === "string") content += delta.text;
|
|
410
|
+
}
|
|
411
|
+
if (c.type === "message_delta") {
|
|
412
|
+
const delta = c.delta;
|
|
413
|
+
if (typeof delta?.stop_reason === "string") finishReason = delta.stop_reason;
|
|
414
|
+
else if (typeof c.stop_reason === "string") finishReason = c.stop_reason;
|
|
415
|
+
const usage = c.usage;
|
|
416
|
+
if (typeof usage?.output_tokens === "number") outputTokens = usage.output_tokens;
|
|
417
|
+
}
|
|
418
|
+
if (c.type === "message_stop") {
|
|
419
|
+
const usage = c.usage;
|
|
420
|
+
if (typeof usage?.output_tokens === "number") outputTokens = usage.output_tokens;
|
|
421
|
+
}
|
|
422
|
+
yield chunk;
|
|
423
|
+
}
|
|
424
|
+
} catch (error) {
|
|
425
|
+
isError = true;
|
|
426
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
427
|
+
throw error;
|
|
428
|
+
} finally {
|
|
429
|
+
const latencyMs = performance.now() - startTime;
|
|
430
|
+
ai.trackAiMessage({
|
|
431
|
+
userId: ctx.userId ?? "unknown",
|
|
432
|
+
content,
|
|
433
|
+
sessionId: ctx.sessionId,
|
|
434
|
+
model,
|
|
435
|
+
provider: "anthropic",
|
|
436
|
+
latencyMs,
|
|
437
|
+
traceId: ctx.traceId,
|
|
438
|
+
inputTokens,
|
|
439
|
+
outputTokens,
|
|
440
|
+
finishReason,
|
|
441
|
+
agentId: ctx.agentId,
|
|
442
|
+
env: ctx.env,
|
|
443
|
+
isStreaming: true,
|
|
444
|
+
isError,
|
|
445
|
+
errorMessage,
|
|
446
|
+
..._contextExtras(ctx)
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
async function* _wrapPatchedGeminiStream(ai, stream, startTime, _requestOpts) {
|
|
451
|
+
const ctx = getActiveContext();
|
|
452
|
+
if (ctx == null) {
|
|
453
|
+
yield* stream;
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
let content = "";
|
|
457
|
+
const model = "gemini";
|
|
458
|
+
let finishReason = "";
|
|
459
|
+
let inputTokens;
|
|
460
|
+
let outputTokens;
|
|
461
|
+
let totalTokens;
|
|
462
|
+
let isError = false;
|
|
463
|
+
let errorMessage;
|
|
464
|
+
try {
|
|
465
|
+
for await (const chunk of stream) {
|
|
466
|
+
const c = chunk;
|
|
467
|
+
const respObj = c.response ?? c;
|
|
468
|
+
const textFn = respObj.text;
|
|
469
|
+
if (typeof textFn === "function") content += String(textFn());
|
|
470
|
+
const usage = respObj.usageMetadata;
|
|
471
|
+
if (typeof usage?.promptTokenCount === "number") inputTokens = usage.promptTokenCount;
|
|
472
|
+
if (typeof usage?.candidatesTokenCount === "number") outputTokens = usage.candidatesTokenCount;
|
|
473
|
+
if (typeof usage?.totalTokenCount === "number") totalTokens = usage.totalTokenCount;
|
|
474
|
+
const candidates = respObj.candidates;
|
|
475
|
+
if (typeof candidates?.[0]?.finishReason === "string") finishReason = candidates[0].finishReason;
|
|
476
|
+
yield chunk;
|
|
477
|
+
}
|
|
478
|
+
} catch (error) {
|
|
479
|
+
isError = true;
|
|
480
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
481
|
+
throw error;
|
|
482
|
+
} finally {
|
|
483
|
+
ai.trackAiMessage({
|
|
484
|
+
userId: ctx.userId ?? "unknown",
|
|
485
|
+
content,
|
|
486
|
+
sessionId: ctx.sessionId,
|
|
487
|
+
model,
|
|
488
|
+
provider: "gemini",
|
|
489
|
+
latencyMs: performance.now() - startTime,
|
|
490
|
+
traceId: ctx.traceId,
|
|
491
|
+
inputTokens,
|
|
492
|
+
outputTokens,
|
|
493
|
+
totalTokens,
|
|
494
|
+
finishReason,
|
|
495
|
+
agentId: ctx.agentId,
|
|
496
|
+
env: ctx.env,
|
|
497
|
+
isStreaming: true,
|
|
498
|
+
isError,
|
|
499
|
+
errorMessage,
|
|
500
|
+
..._contextExtras(ctx)
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
async function* _wrapPatchedBedrockStream(ai, stream, startTime, requestOpts) {
|
|
505
|
+
const ctx = getActiveContext();
|
|
506
|
+
if (ctx == null) {
|
|
507
|
+
yield* stream;
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const opts = requestOpts;
|
|
511
|
+
let model = String(opts?.modelId ?? "unknown");
|
|
512
|
+
let content = "";
|
|
513
|
+
let finishReason = "";
|
|
514
|
+
let inputTokens;
|
|
515
|
+
let outputTokens;
|
|
516
|
+
let totalTokens;
|
|
517
|
+
let isError = false;
|
|
518
|
+
let errorMessage;
|
|
519
|
+
try {
|
|
520
|
+
for await (const rawEvent of stream) {
|
|
521
|
+
const event = rawEvent;
|
|
522
|
+
const delta = event.contentBlockDelta?.delta;
|
|
523
|
+
if (typeof delta?.text === "string") content += delta.text;
|
|
524
|
+
const messageStart = event.messageStart;
|
|
525
|
+
if (typeof messageStart?.model === "string") model = messageStart.model;
|
|
526
|
+
const messageStop = event.messageStop;
|
|
527
|
+
if (typeof messageStop?.stopReason === "string") finishReason = messageStop.stopReason;
|
|
528
|
+
const usage = event.metadata?.usage;
|
|
529
|
+
if (typeof usage?.inputTokens === "number") inputTokens = usage.inputTokens;
|
|
530
|
+
if (typeof usage?.outputTokens === "number") outputTokens = usage.outputTokens;
|
|
531
|
+
if (typeof usage?.totalTokens === "number") totalTokens = usage.totalTokens;
|
|
532
|
+
yield rawEvent;
|
|
533
|
+
}
|
|
534
|
+
} catch (error) {
|
|
535
|
+
isError = true;
|
|
536
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
537
|
+
throw error;
|
|
538
|
+
} finally {
|
|
539
|
+
ai.trackAiMessage({
|
|
540
|
+
userId: ctx.userId ?? "unknown",
|
|
541
|
+
content,
|
|
542
|
+
sessionId: ctx.sessionId,
|
|
543
|
+
model,
|
|
544
|
+
provider: "bedrock",
|
|
545
|
+
latencyMs: performance.now() - startTime,
|
|
546
|
+
traceId: ctx.traceId,
|
|
547
|
+
inputTokens,
|
|
548
|
+
outputTokens,
|
|
549
|
+
totalTokens,
|
|
550
|
+
finishReason,
|
|
551
|
+
agentId: ctx.agentId,
|
|
552
|
+
env: ctx.env,
|
|
553
|
+
isStreaming: true,
|
|
554
|
+
isError,
|
|
555
|
+
errorMessage,
|
|
556
|
+
..._contextExtras(ctx)
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function _patchConstructor(cls, moduleExports, exportKey, amplitudeAI, providerName) {
|
|
561
|
+
if (moduleExports[exportKey]?.__amplitudeCtorPatched === true) return;
|
|
562
|
+
const originalCtor = cls;
|
|
563
|
+
const proxy = new Proxy(originalCtor, { construct(target, args, newTarget) {
|
|
564
|
+
const instance = Reflect.construct(target, args, newTarget);
|
|
565
|
+
_patchInstanceCompletions(instance, amplitudeAI, providerName);
|
|
566
|
+
return instance;
|
|
567
|
+
} });
|
|
568
|
+
proxy.__amplitudeCtorPatched = true;
|
|
569
|
+
const mod = moduleExports;
|
|
570
|
+
let patchedExportKey = null;
|
|
571
|
+
if (mod[exportKey] === originalCtor) {
|
|
572
|
+
mod[exportKey] = proxy;
|
|
573
|
+
patchedExportKey = exportKey;
|
|
574
|
+
} else for (const key of Object.keys(mod)) if (mod[key] === originalCtor) {
|
|
575
|
+
mod[key] = proxy;
|
|
576
|
+
patchedExportKey = key;
|
|
577
|
+
}
|
|
578
|
+
if (patchedExportKey != null) _activePatches.push({
|
|
579
|
+
module: mod,
|
|
580
|
+
method: patchedExportKey,
|
|
581
|
+
original: originalCtor,
|
|
582
|
+
provider: providerName
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function _patchOpenAIClass(maybeClass, moduleExports, exportKey, amplitudeAI, providerName) {
|
|
586
|
+
const OpenAIClass = maybeClass;
|
|
587
|
+
if (!OpenAIClass?.prototype) return false;
|
|
588
|
+
const completionsProto = _getNestedPrototype(OpenAIClass, ["chat", "completions"]);
|
|
589
|
+
if (completionsProto) {
|
|
590
|
+
const target = completionsProto;
|
|
591
|
+
_patchMethod(target, "create", _makeCompletionWrapper(amplitudeAI, providerName), providerName);
|
|
592
|
+
_patchMethod(target, "parse", _makeCompletionWrapper(amplitudeAI, providerName), providerName);
|
|
593
|
+
} else _patchConstructor(OpenAIClass, moduleExports, exportKey, amplitudeAI, providerName);
|
|
594
|
+
const responsesProto = _getNestedPrototype(OpenAIClass, ["responses"]);
|
|
595
|
+
if (responsesProto) {
|
|
596
|
+
const target = responsesProto;
|
|
597
|
+
_patchMethod(target, "create", _makeResponsesWrapper(amplitudeAI, providerName), providerName);
|
|
598
|
+
_patchMethod(target, "stream", _makeResponsesWrapper(amplitudeAI, providerName), providerName);
|
|
599
|
+
}
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
602
|
+
function _patchInstanceCompletions(instance, amplitudeAI, providerName) {
|
|
603
|
+
try {
|
|
604
|
+
const completions = instance.chat?.completions;
|
|
605
|
+
if (completions && typeof completions.create === "function") {
|
|
606
|
+
const original = completions.create.bind(completions);
|
|
607
|
+
completions.create = (...args) => _makeCompletionWrapper(amplitudeAI, providerName)(original, ...args);
|
|
608
|
+
}
|
|
609
|
+
if (completions && typeof completions.parse === "function") {
|
|
610
|
+
const originalParse = completions.parse.bind(completions);
|
|
611
|
+
completions.parse = (...args) => _makeCompletionWrapper(amplitudeAI, providerName)(originalParse, ...args);
|
|
612
|
+
}
|
|
613
|
+
const responses = instance.responses;
|
|
614
|
+
if (responses && typeof responses.create === "function") {
|
|
615
|
+
const originalResponses = responses.create.bind(responses);
|
|
616
|
+
responses.create = (...args) => _makeResponsesWrapper(amplitudeAI, providerName)(originalResponses, ...args);
|
|
617
|
+
}
|
|
618
|
+
if (responses && typeof responses.stream === "function") {
|
|
619
|
+
const originalResponsesStream = responses.stream.bind(responses);
|
|
620
|
+
responses.stream = (...args) => _makeResponsesWrapper(amplitudeAI, providerName)(originalResponsesStream, ...args);
|
|
621
|
+
}
|
|
622
|
+
} catch {}
|
|
623
|
+
}
|
|
624
|
+
function _makeResponsesWrapper(amplitudeAI, providerName) {
|
|
625
|
+
return (original, ...args) => {
|
|
626
|
+
const startTime = performance.now();
|
|
627
|
+
const result = original(...args);
|
|
628
|
+
if (result instanceof Promise) return result.then((response) => {
|
|
629
|
+
if (_isAsyncIterable(response)) return _wrapPatchedResponsesStream(amplitudeAI, response, startTime, args[0], providerName);
|
|
630
|
+
_trackResponsesResponse(amplitudeAI, response, startTime, args[0], providerName);
|
|
631
|
+
return response;
|
|
632
|
+
}).catch((err) => {
|
|
633
|
+
_trackCompletionError(amplitudeAI, err, startTime, args[0], providerName);
|
|
634
|
+
throw err;
|
|
635
|
+
});
|
|
636
|
+
return result;
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function _getNestedPrototype(cls, path) {
|
|
640
|
+
let current = cls.prototype;
|
|
641
|
+
for (const key of path) {
|
|
642
|
+
if (current == null || typeof current !== "object") return null;
|
|
643
|
+
const obj = current;
|
|
644
|
+
if (typeof obj[key] === "object" && obj[key] != null) current = obj[key];
|
|
645
|
+
else return null;
|
|
646
|
+
}
|
|
647
|
+
return current;
|
|
648
|
+
}
|
|
649
|
+
function _trackCompletionResponse(ai, response, startTime, _requestOpts, providerName) {
|
|
650
|
+
if (response == null || typeof response !== "object") return;
|
|
651
|
+
const ctx = getActiveContext();
|
|
652
|
+
if (ctx == null) return;
|
|
653
|
+
const resp = response;
|
|
654
|
+
const usage = resp.usage;
|
|
655
|
+
const choice = resp.choices?.[0];
|
|
656
|
+
const message = choice?.message;
|
|
657
|
+
const latencyMs = performance.now() - startTime;
|
|
658
|
+
ai.trackAiMessage({
|
|
659
|
+
userId: ctx.userId ?? "unknown",
|
|
660
|
+
content: String(message?.content ?? ""),
|
|
661
|
+
sessionId: ctx.sessionId,
|
|
662
|
+
model: String(resp.model ?? "unknown"),
|
|
663
|
+
provider: providerName,
|
|
664
|
+
latencyMs,
|
|
665
|
+
traceId: ctx.traceId,
|
|
666
|
+
inputTokens: usage?.prompt_tokens,
|
|
667
|
+
outputTokens: usage?.completion_tokens,
|
|
668
|
+
totalTokens: usage?.total_tokens,
|
|
669
|
+
finishReason: String(choice?.finish_reason ?? ""),
|
|
670
|
+
agentId: ctx.agentId,
|
|
671
|
+
env: ctx.env,
|
|
672
|
+
..._contextExtras(ctx)
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
function _trackAnthropicResponse(ai, response, startTime, _requestOpts) {
|
|
676
|
+
if (response == null || typeof response !== "object") return;
|
|
677
|
+
const ctx = getActiveContext();
|
|
678
|
+
if (ctx == null) return;
|
|
679
|
+
const resp = response;
|
|
680
|
+
const usage = resp.usage;
|
|
681
|
+
const textBlock = resp.content?.find((b) => b.type === "text");
|
|
682
|
+
const latencyMs = performance.now() - startTime;
|
|
683
|
+
ai.trackAiMessage({
|
|
684
|
+
userId: ctx.userId ?? "unknown",
|
|
685
|
+
content: String(textBlock?.text ?? ""),
|
|
686
|
+
sessionId: ctx.sessionId,
|
|
687
|
+
model: String(resp.model ?? "unknown"),
|
|
688
|
+
provider: "anthropic",
|
|
689
|
+
latencyMs,
|
|
690
|
+
traceId: ctx.traceId,
|
|
691
|
+
inputTokens: usage?.input_tokens,
|
|
692
|
+
outputTokens: usage?.output_tokens,
|
|
693
|
+
finishReason: String(resp.stop_reason ?? ""),
|
|
694
|
+
agentId: ctx.agentId,
|
|
695
|
+
env: ctx.env,
|
|
696
|
+
..._contextExtras(ctx)
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
function _trackCompletionError(ai, error, startTime, requestOpts, providerName) {
|
|
700
|
+
const ctx = getActiveContext();
|
|
701
|
+
if (ctx == null) return;
|
|
702
|
+
const opts = requestOpts;
|
|
703
|
+
const latencyMs = performance.now() - startTime;
|
|
704
|
+
ai.trackAiMessage({
|
|
705
|
+
userId: ctx.userId ?? "unknown",
|
|
706
|
+
content: "",
|
|
707
|
+
sessionId: ctx.sessionId,
|
|
708
|
+
model: String(opts?.model ?? opts?.modelId ?? "unknown"),
|
|
709
|
+
provider: providerName,
|
|
710
|
+
latencyMs,
|
|
711
|
+
traceId: ctx.traceId,
|
|
712
|
+
isError: true,
|
|
713
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
714
|
+
agentId: ctx.agentId,
|
|
715
|
+
env: ctx.env,
|
|
716
|
+
..._contextExtras(ctx)
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function _trackGeminiResponse(ai, response, startTime) {
|
|
720
|
+
if (response == null || typeof response !== "object") return;
|
|
721
|
+
const ctx = getActiveContext();
|
|
722
|
+
if (ctx == null) return;
|
|
723
|
+
const resp = response;
|
|
724
|
+
const respObj = resp.response ?? resp;
|
|
725
|
+
const text = typeof respObj.text === "function" ? String(respObj.text()) : "";
|
|
726
|
+
const usage = respObj.usageMetadata;
|
|
727
|
+
const latencyMs = performance.now() - startTime;
|
|
728
|
+
ai.trackAiMessage({
|
|
729
|
+
userId: ctx.userId ?? "unknown",
|
|
730
|
+
content: text,
|
|
731
|
+
sessionId: ctx.sessionId,
|
|
732
|
+
model: "gemini",
|
|
733
|
+
provider: "gemini",
|
|
734
|
+
latencyMs,
|
|
735
|
+
traceId: ctx.traceId,
|
|
736
|
+
inputTokens: usage?.promptTokenCount,
|
|
737
|
+
outputTokens: usage?.candidatesTokenCount,
|
|
738
|
+
totalTokens: usage?.totalTokenCount,
|
|
739
|
+
agentId: ctx.agentId,
|
|
740
|
+
env: ctx.env,
|
|
741
|
+
..._contextExtras(ctx)
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function _trackBedrockResponse(ai, response, startTime, requestOpts) {
|
|
745
|
+
if (response == null || typeof response !== "object") return;
|
|
746
|
+
const ctx = getActiveContext();
|
|
747
|
+
if (ctx == null) return;
|
|
748
|
+
const resp = response;
|
|
749
|
+
const textBlock = ((resp.output?.message)?.content)?.find((b) => b.text != null);
|
|
750
|
+
const usage = resp.usage;
|
|
751
|
+
const opts = requestOpts;
|
|
752
|
+
const latencyMs = performance.now() - startTime;
|
|
753
|
+
ai.trackAiMessage({
|
|
754
|
+
userId: ctx.userId ?? "unknown",
|
|
755
|
+
content: String(textBlock?.text ?? ""),
|
|
756
|
+
sessionId: ctx.sessionId,
|
|
757
|
+
model: String(opts?.modelId ?? "unknown"),
|
|
758
|
+
provider: "bedrock",
|
|
759
|
+
latencyMs,
|
|
760
|
+
traceId: ctx.traceId,
|
|
761
|
+
inputTokens: usage?.inputTokens,
|
|
762
|
+
outputTokens: usage?.outputTokens,
|
|
763
|
+
totalTokens: usage?.totalTokens,
|
|
764
|
+
finishReason: String(resp.stopReason ?? ""),
|
|
765
|
+
agentId: ctx.agentId,
|
|
766
|
+
env: ctx.env,
|
|
767
|
+
..._contextExtras(ctx)
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
function _trackResponsesResponse(ai, response, startTime, requestOpts, providerName) {
|
|
771
|
+
if (response == null || typeof response !== "object") return;
|
|
772
|
+
const ctx = getActiveContext();
|
|
773
|
+
if (ctx == null) return;
|
|
774
|
+
const resp = response;
|
|
775
|
+
const usage = resp.usage;
|
|
776
|
+
const outputText = typeof resp.output_text === "string" ? resp.output_text : _extractResponsesText(resp.output);
|
|
777
|
+
const opts = requestOpts;
|
|
778
|
+
ai.trackAiMessage({
|
|
779
|
+
userId: ctx.userId ?? "unknown",
|
|
780
|
+
content: outputText,
|
|
781
|
+
sessionId: ctx.sessionId,
|
|
782
|
+
model: String(resp.model ?? opts?.model ?? "unknown"),
|
|
783
|
+
provider: providerName,
|
|
784
|
+
latencyMs: performance.now() - startTime,
|
|
785
|
+
traceId: ctx.traceId,
|
|
786
|
+
inputTokens: typeof usage?.input_tokens === "number" ? usage.input_tokens : void 0,
|
|
787
|
+
outputTokens: typeof usage?.output_tokens === "number" ? usage.output_tokens : void 0,
|
|
788
|
+
totalTokens: typeof usage?.total_tokens === "number" ? usage.total_tokens : void 0,
|
|
789
|
+
reasoningTokens: typeof (usage?.output_tokens_details)?.reasoning_tokens === "number" ? (usage?.output_tokens_details).reasoning_tokens : void 0,
|
|
790
|
+
finishReason: _extractResponsesFinishReason(resp),
|
|
791
|
+
agentId: ctx.agentId,
|
|
792
|
+
env: ctx.env,
|
|
793
|
+
..._contextExtras(ctx)
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
async function* _wrapPatchedResponsesStream(ai, stream, startTime, requestOpts, providerName) {
|
|
797
|
+
const ctx = getActiveContext();
|
|
798
|
+
if (ctx == null) {
|
|
799
|
+
yield* stream;
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const opts = requestOpts;
|
|
803
|
+
const model = String(opts?.model ?? "unknown");
|
|
804
|
+
let content = "";
|
|
805
|
+
let finishReason = "";
|
|
806
|
+
let inputTokens;
|
|
807
|
+
let outputTokens;
|
|
808
|
+
let totalTokens;
|
|
809
|
+
let isError = false;
|
|
810
|
+
let errorMessage;
|
|
811
|
+
try {
|
|
812
|
+
for await (const event of stream) {
|
|
813
|
+
const e = event;
|
|
814
|
+
const type = e.type;
|
|
815
|
+
if (type === "response.output_text.delta") {
|
|
816
|
+
const delta = e.delta;
|
|
817
|
+
if (typeof delta === "string") content += delta;
|
|
818
|
+
} else if (type === "response.completed") {
|
|
819
|
+
const response = e.response;
|
|
820
|
+
const usage = response?.usage;
|
|
821
|
+
const outputText = response?.output_text;
|
|
822
|
+
if (typeof outputText === "string" && outputText.length > 0) content = outputText;
|
|
823
|
+
if (typeof usage?.input_tokens === "number") inputTokens = usage.input_tokens;
|
|
824
|
+
if (typeof usage?.output_tokens === "number") outputTokens = usage.output_tokens;
|
|
825
|
+
if (typeof usage?.total_tokens === "number") totalTokens = usage.total_tokens;
|
|
826
|
+
const status = response?.status;
|
|
827
|
+
if (typeof status === "string") finishReason = status;
|
|
828
|
+
}
|
|
829
|
+
yield event;
|
|
830
|
+
}
|
|
831
|
+
} catch (error) {
|
|
832
|
+
isError = true;
|
|
833
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
834
|
+
throw error;
|
|
835
|
+
} finally {
|
|
836
|
+
ai.trackAiMessage({
|
|
837
|
+
userId: ctx.userId ?? "unknown",
|
|
838
|
+
content,
|
|
839
|
+
sessionId: ctx.sessionId,
|
|
840
|
+
model,
|
|
841
|
+
provider: providerName,
|
|
842
|
+
latencyMs: performance.now() - startTime,
|
|
843
|
+
traceId: ctx.traceId,
|
|
844
|
+
inputTokens,
|
|
845
|
+
outputTokens,
|
|
846
|
+
totalTokens,
|
|
847
|
+
finishReason,
|
|
848
|
+
agentId: ctx.agentId,
|
|
849
|
+
env: ctx.env,
|
|
850
|
+
isStreaming: true,
|
|
851
|
+
isError,
|
|
852
|
+
errorMessage,
|
|
853
|
+
..._contextExtras(ctx)
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function _extractResponsesText(output) {
|
|
858
|
+
if (!Array.isArray(output)) return "";
|
|
859
|
+
let text = "";
|
|
860
|
+
for (const item of output) {
|
|
861
|
+
if (item == null || typeof item !== "object") continue;
|
|
862
|
+
const content = item.content;
|
|
863
|
+
if (!Array.isArray(content)) continue;
|
|
864
|
+
for (const part of content) {
|
|
865
|
+
if (part == null || typeof part !== "object") continue;
|
|
866
|
+
const partText = part.text;
|
|
867
|
+
if (typeof partText === "string") text += partText;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
return text;
|
|
871
|
+
}
|
|
872
|
+
function _extractResponsesFinishReason(response) {
|
|
873
|
+
if (typeof response.status === "string" && response.status.length > 0) return response.status;
|
|
874
|
+
const output = response.output;
|
|
875
|
+
if (!Array.isArray(output) || output.length === 0) return void 0;
|
|
876
|
+
const first = output[0];
|
|
877
|
+
return typeof first?.status === "string" ? first.status : void 0;
|
|
878
|
+
}
|
|
879
|
+
function _contextExtras(ctx) {
|
|
880
|
+
return {
|
|
881
|
+
parentAgentId: ctx.parentAgentId ?? void 0,
|
|
882
|
+
customerOrgId: ctx.customerOrgId ?? void 0,
|
|
883
|
+
agentVersion: ctx.agentVersion ?? void 0,
|
|
884
|
+
context: ctx.context ?? void 0,
|
|
885
|
+
groups: ctx.groups ?? void 0
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
//#endregion
|
|
890
|
+
export { patch, patchAnthropic, patchAzureOpenAI, patchBedrock, patchGemini, patchMistral, patchOpenAI, patchedProviders, unpatch, unpatchAnthropic, unpatchAzureOpenAI, unpatchBedrock, unpatchGemini, unpatchMistral, unpatchOpenAI };
|
|
891
|
+
//# sourceMappingURL=patching.js.map
|