@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
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { trackUserMessage } from "../core/tracking.js";
|
|
2
|
+
import { getDefaultPropagateContext, injectContext } from "../propagation.js";
|
|
3
|
+
import { tryRequire } from "../utils/resolve-module.js";
|
|
4
|
+
import { calculateCost } from "../utils/costs.js";
|
|
5
|
+
import { StreamingAccumulator } from "../utils/streaming.js";
|
|
6
|
+
import { BaseAIProvider, applySessionContext } from "./base.js";
|
|
7
|
+
|
|
8
|
+
//#region src/providers/openai.ts
|
|
9
|
+
const _resolved = tryRequire("openai");
|
|
10
|
+
const OPENAI_AVAILABLE = _resolved != null;
|
|
11
|
+
const _OpenAIModule = _resolved;
|
|
12
|
+
var OpenAI = class extends BaseAIProvider {
|
|
13
|
+
_client;
|
|
14
|
+
chat;
|
|
15
|
+
responses;
|
|
16
|
+
_propagateContext;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super({
|
|
19
|
+
amplitude: options.amplitude,
|
|
20
|
+
privacyConfig: options.privacyConfig,
|
|
21
|
+
providerName: "openai"
|
|
22
|
+
});
|
|
23
|
+
const mod = options.openaiModule ?? _OpenAIModule;
|
|
24
|
+
if (mod == null) throw new Error("openai package is required. Install it with: npm install openai — or pass the module directly via the openaiModule option.");
|
|
25
|
+
const OpenAISDK = mod.OpenAI;
|
|
26
|
+
const clientOpts = {};
|
|
27
|
+
if (options.apiKey) clientOpts.apiKey = options.apiKey;
|
|
28
|
+
if (options.baseUrl) clientOpts.baseURL = options.baseUrl;
|
|
29
|
+
this._client = new OpenAISDK(clientOpts);
|
|
30
|
+
this._propagateContext = options.propagateContext ?? getDefaultPropagateContext();
|
|
31
|
+
this.chat = new WrappedChat(this._client, this.trackFn(), this._amplitude, this._privacyConfig, this._propagateContext);
|
|
32
|
+
this.responses = new WrappedResponses(this._client, this.trackFn(), this._amplitude, this._privacyConfig, this._propagateContext);
|
|
33
|
+
}
|
|
34
|
+
get client() {
|
|
35
|
+
return this._client;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var WrappedChat = class {
|
|
39
|
+
completions;
|
|
40
|
+
constructor(client, trackFn, amplitude, privacyConfig, propagateContext) {
|
|
41
|
+
const chat = client.chat;
|
|
42
|
+
this.completions = new WrappedCompletions(chat.completions, trackFn, amplitude, privacyConfig, propagateContext);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var WrappedCompletions = class {
|
|
46
|
+
_original;
|
|
47
|
+
_trackFn;
|
|
48
|
+
_amplitude;
|
|
49
|
+
_privacyConfig;
|
|
50
|
+
_propagateContext;
|
|
51
|
+
_providerName;
|
|
52
|
+
constructor(completions, trackFn, amplitude, privacyConfig, propagateContext, providerName = "openai") {
|
|
53
|
+
this._original = completions;
|
|
54
|
+
this._trackFn = typeof trackFn === "function" ? trackFn : trackFn.trackFn();
|
|
55
|
+
this._amplitude = amplitude;
|
|
56
|
+
this._privacyConfig = privacyConfig;
|
|
57
|
+
this._propagateContext = propagateContext;
|
|
58
|
+
this._providerName = providerName;
|
|
59
|
+
}
|
|
60
|
+
async create(params, amplitudeOverrides) {
|
|
61
|
+
const createFn = this._original.create;
|
|
62
|
+
const startTime = performance.now();
|
|
63
|
+
let requestParams = this._withContextHeaders(params);
|
|
64
|
+
const ctx = applySessionContext(amplitudeOverrides);
|
|
65
|
+
if (requestParams.stream === true && requestParams.stream_options == null) requestParams = {
|
|
66
|
+
...requestParams,
|
|
67
|
+
stream_options: { include_usage: true }
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
this._trackInputMessages(requestParams.messages, ctx, amplitudeOverrides?.trackInputMessages ?? true);
|
|
71
|
+
const response = await createFn.call(this._original, requestParams);
|
|
72
|
+
if (requestParams.stream === true && _isAsyncIterable(response)) return this._wrapStream(response, requestParams, startTime, ctx);
|
|
73
|
+
const latencyMs = performance.now() - startTime;
|
|
74
|
+
const resp = response;
|
|
75
|
+
const usage = resp.usage;
|
|
76
|
+
const choice = resp.choices?.[0];
|
|
77
|
+
const modelName = String(resp.model ?? requestParams.model ?? "unknown");
|
|
78
|
+
const toolCalls = choice?.message?.tool_calls;
|
|
79
|
+
const usageExt = usage;
|
|
80
|
+
const promptDetails = usageExt?.prompt_tokens_details;
|
|
81
|
+
const reasoningTokens = (usageExt?.completion_tokens_details)?.reasoning_tokens;
|
|
82
|
+
const cachedTokens = promptDetails?.cached_tokens;
|
|
83
|
+
let costUsd = null;
|
|
84
|
+
if (usage?.prompt_tokens != null && usage?.completion_tokens != null) try {
|
|
85
|
+
costUsd = calculateCost({
|
|
86
|
+
modelName,
|
|
87
|
+
inputTokens: usage.prompt_tokens,
|
|
88
|
+
outputTokens: usage.completion_tokens,
|
|
89
|
+
reasoningTokens: reasoningTokens ?? 0,
|
|
90
|
+
cacheReadInputTokens: cachedTokens ?? 0
|
|
91
|
+
});
|
|
92
|
+
} catch {}
|
|
93
|
+
this._trackFn({
|
|
94
|
+
userId: ctx.userId ?? "unknown",
|
|
95
|
+
modelName,
|
|
96
|
+
provider: this._providerName,
|
|
97
|
+
responseContent: String(choice?.message?.content ?? ""),
|
|
98
|
+
latencyMs,
|
|
99
|
+
sessionId: ctx.sessionId,
|
|
100
|
+
traceId: ctx.traceId,
|
|
101
|
+
turnId: ctx.turnId ?? void 0,
|
|
102
|
+
agentId: ctx.agentId,
|
|
103
|
+
env: ctx.env,
|
|
104
|
+
inputTokens: usage?.prompt_tokens,
|
|
105
|
+
outputTokens: usage?.completion_tokens,
|
|
106
|
+
totalTokens: usage?.total_tokens,
|
|
107
|
+
reasoningTokens,
|
|
108
|
+
cacheReadInputTokens: cachedTokens,
|
|
109
|
+
totalCostUsd: costUsd,
|
|
110
|
+
finishReason: choice?.finish_reason,
|
|
111
|
+
toolCalls: toolCalls ?? void 0,
|
|
112
|
+
isStreaming: false,
|
|
113
|
+
systemPrompt: extractSystemPrompt(requestParams),
|
|
114
|
+
temperature: requestParams.temperature,
|
|
115
|
+
maxOutputTokens: requestParams.max_tokens,
|
|
116
|
+
topP: requestParams.top_p
|
|
117
|
+
});
|
|
118
|
+
return response;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
const latencyMs = performance.now() - startTime;
|
|
121
|
+
this._trackFn({
|
|
122
|
+
userId: ctx.userId ?? "unknown",
|
|
123
|
+
modelName: String(requestParams.model ?? "unknown"),
|
|
124
|
+
provider: this._providerName,
|
|
125
|
+
responseContent: "",
|
|
126
|
+
latencyMs,
|
|
127
|
+
sessionId: ctx.sessionId,
|
|
128
|
+
traceId: ctx.traceId,
|
|
129
|
+
agentId: ctx.agentId,
|
|
130
|
+
env: ctx.env,
|
|
131
|
+
isError: true,
|
|
132
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
133
|
+
});
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async parse(params, amplitudeOverrides) {
|
|
138
|
+
const parseFn = this._original.parse;
|
|
139
|
+
if (typeof parseFn !== "function") throw new Error("OpenAI SDK does not expose chat.completions.parse");
|
|
140
|
+
const originalCreate = this._original.create;
|
|
141
|
+
this._original.create = parseFn;
|
|
142
|
+
try {
|
|
143
|
+
return await this.create(params, amplitudeOverrides);
|
|
144
|
+
} finally {
|
|
145
|
+
this._original.create = originalCreate;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async *_wrapStream(stream, params, _startTime, sessionCtx) {
|
|
149
|
+
const accumulator = new StreamingAccumulator();
|
|
150
|
+
accumulator.model = String(params.model ?? "unknown");
|
|
151
|
+
let reasoningContent = "";
|
|
152
|
+
try {
|
|
153
|
+
for await (const chunk of stream) {
|
|
154
|
+
const c = chunk;
|
|
155
|
+
const choices = c.choices;
|
|
156
|
+
const delta = choices?.[0]?.delta;
|
|
157
|
+
if (delta?.content != null) accumulator.addContent(String(delta.content));
|
|
158
|
+
const deltaToolCalls = delta?.tool_calls;
|
|
159
|
+
if (Array.isArray(deltaToolCalls)) for (const call of deltaToolCalls) accumulator.addToolCall(call);
|
|
160
|
+
if (delta?.reasoning_content != null) reasoningContent += String(delta.reasoning_content);
|
|
161
|
+
const finishReason = choices?.[0]?.finish_reason;
|
|
162
|
+
if (finishReason != null) accumulator.finishReason = String(finishReason);
|
|
163
|
+
const usage = c.usage;
|
|
164
|
+
if (usage != null) {
|
|
165
|
+
const promptDetails = usage.prompt_tokens_details;
|
|
166
|
+
const completionDetails = usage.completion_tokens_details;
|
|
167
|
+
accumulator.setUsage({
|
|
168
|
+
inputTokens: usage.prompt_tokens,
|
|
169
|
+
outputTokens: usage.completion_tokens,
|
|
170
|
+
totalTokens: usage.total_tokens,
|
|
171
|
+
reasoningTokens: completionDetails?.reasoning_tokens,
|
|
172
|
+
cacheReadTokens: promptDetails?.cached_tokens
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
yield chunk;
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
accumulator.setError(error instanceof Error ? error.message : String(error));
|
|
179
|
+
throw error;
|
|
180
|
+
} finally {
|
|
181
|
+
const state = accumulator.getState();
|
|
182
|
+
const modelName = String(accumulator.model ?? params.model ?? "unknown");
|
|
183
|
+
let costUsd = null;
|
|
184
|
+
if (state.inputTokens != null && state.outputTokens != null) try {
|
|
185
|
+
costUsd = calculateCost({
|
|
186
|
+
modelName,
|
|
187
|
+
inputTokens: state.inputTokens,
|
|
188
|
+
outputTokens: state.outputTokens,
|
|
189
|
+
reasoningTokens: state.reasoningTokens ?? 0,
|
|
190
|
+
cacheReadInputTokens: state.cacheReadTokens ?? 0
|
|
191
|
+
});
|
|
192
|
+
} catch {}
|
|
193
|
+
this._trackFn({
|
|
194
|
+
userId: sessionCtx.userId ?? "unknown",
|
|
195
|
+
modelName,
|
|
196
|
+
provider: this._providerName,
|
|
197
|
+
responseContent: state.content,
|
|
198
|
+
latencyMs: accumulator.elapsedMs,
|
|
199
|
+
sessionId: sessionCtx.sessionId,
|
|
200
|
+
traceId: sessionCtx.traceId,
|
|
201
|
+
turnId: sessionCtx.turnId ?? void 0,
|
|
202
|
+
agentId: sessionCtx.agentId,
|
|
203
|
+
env: sessionCtx.env,
|
|
204
|
+
inputTokens: state.inputTokens,
|
|
205
|
+
outputTokens: state.outputTokens,
|
|
206
|
+
totalTokens: state.totalTokens,
|
|
207
|
+
reasoningTokens: state.reasoningTokens,
|
|
208
|
+
cacheReadInputTokens: state.cacheReadTokens,
|
|
209
|
+
totalCostUsd: costUsd,
|
|
210
|
+
finishReason: state.finishReason,
|
|
211
|
+
toolCalls: state.toolCalls.length > 0 ? state.toolCalls : void 0,
|
|
212
|
+
providerTtfbMs: state.ttfbMs,
|
|
213
|
+
isStreaming: true,
|
|
214
|
+
isError: state.isError,
|
|
215
|
+
errorMessage: state.errorMessage,
|
|
216
|
+
reasoningContent: reasoningContent || void 0,
|
|
217
|
+
systemPrompt: extractSystemPrompt(params),
|
|
218
|
+
temperature: params.temperature,
|
|
219
|
+
maxOutputTokens: params.max_tokens,
|
|
220
|
+
topP: params.top_p
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
_withContextHeaders(params) {
|
|
225
|
+
if (!this._propagateContext) return params;
|
|
226
|
+
const injected = injectContext(params.extra_headers ?? params.headers);
|
|
227
|
+
return {
|
|
228
|
+
...params,
|
|
229
|
+
extra_headers: injected
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
_trackInputMessages(messages, ctx, shouldTrackInputMessages) {
|
|
233
|
+
if (!shouldTrackInputMessages) return;
|
|
234
|
+
if (ctx.userId == null || ctx.sessionId == null) return;
|
|
235
|
+
if (!Array.isArray(messages)) return;
|
|
236
|
+
for (const msg of messages) {
|
|
237
|
+
if (msg?.role !== "user") continue;
|
|
238
|
+
const content = msg.content;
|
|
239
|
+
if (typeof content !== "string" || content.length === 0) continue;
|
|
240
|
+
trackUserMessage({
|
|
241
|
+
amplitude: this._amplitude,
|
|
242
|
+
userId: ctx.userId,
|
|
243
|
+
messageContent: content,
|
|
244
|
+
sessionId: ctx.sessionId,
|
|
245
|
+
traceId: ctx.traceId,
|
|
246
|
+
turnId: ctx.turnId ?? void 0,
|
|
247
|
+
agentId: ctx.agentId,
|
|
248
|
+
parentAgentId: ctx.parentAgentId,
|
|
249
|
+
customerOrgId: ctx.customerOrgId,
|
|
250
|
+
env: ctx.env,
|
|
251
|
+
groups: ctx.groups,
|
|
252
|
+
privacyConfig: this._privacyConfig
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var WrappedResponses = class {
|
|
258
|
+
_original;
|
|
259
|
+
_trackFn;
|
|
260
|
+
_amplitude;
|
|
261
|
+
_privacyConfig;
|
|
262
|
+
_propagateContext;
|
|
263
|
+
_providerName;
|
|
264
|
+
constructor(client, trackFn, amplitude, privacyConfig, propagateContext, providerName = "openai") {
|
|
265
|
+
this._original = client.responses ?? {};
|
|
266
|
+
this._trackFn = typeof trackFn === "function" ? trackFn : trackFn.trackFn();
|
|
267
|
+
this._amplitude = amplitude;
|
|
268
|
+
this._privacyConfig = privacyConfig;
|
|
269
|
+
this._propagateContext = propagateContext;
|
|
270
|
+
this._providerName = providerName;
|
|
271
|
+
}
|
|
272
|
+
async create(params, amplitudeOverrides) {
|
|
273
|
+
const createFn = this._original.create;
|
|
274
|
+
const startTime = performance.now();
|
|
275
|
+
const requestParams = this._withContextHeaders(params);
|
|
276
|
+
const ctx = applySessionContext(amplitudeOverrides);
|
|
277
|
+
try {
|
|
278
|
+
this._trackInputMessages(requestParams.input, ctx, amplitudeOverrides?.trackInputMessages ?? true);
|
|
279
|
+
const response = await createFn.call(this._original, requestParams);
|
|
280
|
+
if (requestParams.stream === true && _isAsyncIterable(response)) return this._wrapStream(response, requestParams, startTime, ctx);
|
|
281
|
+
const latencyMs = performance.now() - startTime;
|
|
282
|
+
const resp = response;
|
|
283
|
+
const usage = resp.usage;
|
|
284
|
+
const responseText = extractResponsesText(resp);
|
|
285
|
+
const responseToolCalls = extractResponsesToolCalls(resp);
|
|
286
|
+
const modelName = String(resp.model ?? requestParams.model ?? "unknown");
|
|
287
|
+
let costUsd = null;
|
|
288
|
+
if (usage?.input_tokens != null && usage?.output_tokens != null) try {
|
|
289
|
+
costUsd = calculateCost({
|
|
290
|
+
modelName,
|
|
291
|
+
inputTokens: usage.input_tokens,
|
|
292
|
+
outputTokens: usage.output_tokens,
|
|
293
|
+
reasoningTokens: usage.output_tokens_details?.reasoning_tokens ?? 0
|
|
294
|
+
});
|
|
295
|
+
} catch {}
|
|
296
|
+
this._trackFn({
|
|
297
|
+
userId: ctx.userId ?? "unknown",
|
|
298
|
+
modelName,
|
|
299
|
+
provider: this._providerName,
|
|
300
|
+
responseContent: responseText,
|
|
301
|
+
latencyMs,
|
|
302
|
+
sessionId: ctx.sessionId,
|
|
303
|
+
traceId: ctx.traceId,
|
|
304
|
+
turnId: ctx.turnId ?? void 0,
|
|
305
|
+
agentId: ctx.agentId,
|
|
306
|
+
env: ctx.env,
|
|
307
|
+
inputTokens: usage?.input_tokens,
|
|
308
|
+
outputTokens: usage?.output_tokens,
|
|
309
|
+
totalTokens: usage?.total_tokens,
|
|
310
|
+
reasoningTokens: usage?.output_tokens_details?.reasoning_tokens,
|
|
311
|
+
totalCostUsd: costUsd,
|
|
312
|
+
finishReason: extractResponsesFinishReason(resp),
|
|
313
|
+
toolCalls: responseToolCalls.length > 0 ? responseToolCalls : void 0,
|
|
314
|
+
isStreaming: false,
|
|
315
|
+
systemPrompt: extractResponsesSystemPrompt(requestParams),
|
|
316
|
+
temperature: requestParams.temperature,
|
|
317
|
+
maxOutputTokens: requestParams.max_output_tokens,
|
|
318
|
+
topP: requestParams.top_p
|
|
319
|
+
});
|
|
320
|
+
return response;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const latencyMs = performance.now() - startTime;
|
|
323
|
+
this._trackFn({
|
|
324
|
+
userId: ctx.userId ?? "unknown",
|
|
325
|
+
modelName: String(requestParams.model ?? "unknown"),
|
|
326
|
+
provider: this._providerName,
|
|
327
|
+
responseContent: "",
|
|
328
|
+
latencyMs,
|
|
329
|
+
sessionId: ctx.sessionId,
|
|
330
|
+
traceId: ctx.traceId,
|
|
331
|
+
agentId: ctx.agentId,
|
|
332
|
+
env: ctx.env,
|
|
333
|
+
isError: true,
|
|
334
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
335
|
+
});
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async stream(params, amplitudeOverrides) {
|
|
340
|
+
const streamFn = this._original.stream;
|
|
341
|
+
if (typeof streamFn !== "function") throw new Error("OpenAI SDK does not expose responses.stream");
|
|
342
|
+
const startTime = performance.now();
|
|
343
|
+
const requestParams = this._withContextHeaders(params);
|
|
344
|
+
const ctx = applySessionContext(amplitudeOverrides);
|
|
345
|
+
try {
|
|
346
|
+
this._trackInputMessages(requestParams.input, ctx, amplitudeOverrides?.trackInputMessages ?? true);
|
|
347
|
+
const response = await streamFn.call(this._original, requestParams);
|
|
348
|
+
if (!_isAsyncIterable(response)) throw new Error("OpenAI responses.stream did not return AsyncIterable");
|
|
349
|
+
return this._wrapStream(response, requestParams, startTime, ctx);
|
|
350
|
+
} catch (error) {
|
|
351
|
+
this._trackFn({
|
|
352
|
+
userId: ctx.userId ?? "unknown",
|
|
353
|
+
modelName: String(requestParams.model ?? "unknown"),
|
|
354
|
+
provider: this._providerName,
|
|
355
|
+
responseContent: "",
|
|
356
|
+
latencyMs: performance.now() - startTime,
|
|
357
|
+
sessionId: ctx.sessionId,
|
|
358
|
+
traceId: ctx.traceId,
|
|
359
|
+
agentId: ctx.agentId,
|
|
360
|
+
env: ctx.env,
|
|
361
|
+
isError: true,
|
|
362
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
363
|
+
isStreaming: true
|
|
364
|
+
});
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
async *_wrapStream(stream, params, _startTime, sessionCtx) {
|
|
369
|
+
const accumulator = new StreamingAccumulator();
|
|
370
|
+
accumulator.model = String(params.model ?? "unknown");
|
|
371
|
+
try {
|
|
372
|
+
for await (const event of stream) {
|
|
373
|
+
const e = event;
|
|
374
|
+
const type = e.type;
|
|
375
|
+
if (type === "response.output_text.delta") {
|
|
376
|
+
const delta = e.delta;
|
|
377
|
+
if (typeof delta === "string") accumulator.addContent(delta);
|
|
378
|
+
} else if (type === "response.completed") {
|
|
379
|
+
const response = e.response;
|
|
380
|
+
if (response != null) {
|
|
381
|
+
const outputText = extractResponsesText(response);
|
|
382
|
+
if (outputText.length > 0) accumulator.content = outputText;
|
|
383
|
+
const usage = response.usage;
|
|
384
|
+
accumulator.setUsage({
|
|
385
|
+
inputTokens: usage?.input_tokens,
|
|
386
|
+
outputTokens: usage?.output_tokens,
|
|
387
|
+
totalTokens: usage?.total_tokens,
|
|
388
|
+
reasoningTokens: usage?.output_tokens_details?.reasoning_tokens
|
|
389
|
+
});
|
|
390
|
+
const finishReason = extractResponsesFinishReason(response);
|
|
391
|
+
if (finishReason != null) accumulator.finishReason = finishReason;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
yield event;
|
|
395
|
+
}
|
|
396
|
+
} catch (error) {
|
|
397
|
+
accumulator.setError(error instanceof Error ? error.message : String(error));
|
|
398
|
+
throw error;
|
|
399
|
+
} finally {
|
|
400
|
+
const state = accumulator.getState();
|
|
401
|
+
let costUsd = null;
|
|
402
|
+
if (state.inputTokens != null && state.outputTokens != null) try {
|
|
403
|
+
costUsd = calculateCost({
|
|
404
|
+
modelName: String(accumulator.model ?? params.model ?? "unknown"),
|
|
405
|
+
inputTokens: state.inputTokens,
|
|
406
|
+
outputTokens: state.outputTokens,
|
|
407
|
+
reasoningTokens: state.reasoningTokens ?? 0
|
|
408
|
+
});
|
|
409
|
+
} catch {}
|
|
410
|
+
this._trackFn({
|
|
411
|
+
userId: sessionCtx.userId ?? "unknown",
|
|
412
|
+
modelName: String(accumulator.model ?? params.model ?? "unknown"),
|
|
413
|
+
provider: this._providerName,
|
|
414
|
+
responseContent: state.content,
|
|
415
|
+
latencyMs: accumulator.elapsedMs,
|
|
416
|
+
sessionId: sessionCtx.sessionId,
|
|
417
|
+
traceId: sessionCtx.traceId,
|
|
418
|
+
turnId: sessionCtx.turnId ?? void 0,
|
|
419
|
+
agentId: sessionCtx.agentId,
|
|
420
|
+
env: sessionCtx.env,
|
|
421
|
+
inputTokens: state.inputTokens,
|
|
422
|
+
outputTokens: state.outputTokens,
|
|
423
|
+
totalTokens: state.totalTokens,
|
|
424
|
+
reasoningTokens: state.reasoningTokens,
|
|
425
|
+
totalCostUsd: costUsd,
|
|
426
|
+
finishReason: state.finishReason,
|
|
427
|
+
providerTtfbMs: state.ttfbMs,
|
|
428
|
+
isStreaming: true,
|
|
429
|
+
isError: state.isError,
|
|
430
|
+
errorMessage: state.errorMessage,
|
|
431
|
+
systemPrompt: extractResponsesSystemPrompt(params),
|
|
432
|
+
temperature: params.temperature,
|
|
433
|
+
maxOutputTokens: params.max_output_tokens,
|
|
434
|
+
topP: params.top_p
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
_withContextHeaders(params) {
|
|
439
|
+
if (!this._propagateContext) return params;
|
|
440
|
+
const injected = injectContext(params.extra_headers ?? params.headers);
|
|
441
|
+
return {
|
|
442
|
+
...params,
|
|
443
|
+
extra_headers: injected
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
_trackInputMessages(input, ctx, shouldTrackInputMessages) {
|
|
447
|
+
if (!shouldTrackInputMessages) return;
|
|
448
|
+
if (ctx.userId == null || ctx.sessionId == null) return;
|
|
449
|
+
for (const text of extractResponsesUserInputs(input)) {
|
|
450
|
+
if (!text) continue;
|
|
451
|
+
trackUserMessage({
|
|
452
|
+
amplitude: this._amplitude,
|
|
453
|
+
userId: ctx.userId,
|
|
454
|
+
messageContent: text,
|
|
455
|
+
sessionId: ctx.sessionId,
|
|
456
|
+
traceId: ctx.traceId,
|
|
457
|
+
turnId: ctx.turnId ?? void 0,
|
|
458
|
+
agentId: ctx.agentId,
|
|
459
|
+
parentAgentId: ctx.parentAgentId,
|
|
460
|
+
customerOrgId: ctx.customerOrgId,
|
|
461
|
+
env: ctx.env,
|
|
462
|
+
groups: ctx.groups,
|
|
463
|
+
privacyConfig: this._privacyConfig
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
function _isAsyncIterable(value) {
|
|
469
|
+
return value != null && typeof value[Symbol.asyncIterator] === "function";
|
|
470
|
+
}
|
|
471
|
+
function extractSystemPrompt(params) {
|
|
472
|
+
const messages = params.messages;
|
|
473
|
+
if (!messages?.length) return void 0;
|
|
474
|
+
const systemMsg = messages.find((m) => m.role === "system" || m.role === "developer");
|
|
475
|
+
return systemMsg ? String(systemMsg.content ?? "") : void 0;
|
|
476
|
+
}
|
|
477
|
+
function extractResponsesSystemPrompt(params) {
|
|
478
|
+
const instructions = params.instructions;
|
|
479
|
+
return typeof instructions === "string" ? instructions : void 0;
|
|
480
|
+
}
|
|
481
|
+
function extractResponsesFinishReason(resp) {
|
|
482
|
+
const status = resp.status;
|
|
483
|
+
if (typeof status === "string" && status.length > 0) return status;
|
|
484
|
+
const out = resp.output?.[0];
|
|
485
|
+
if (out != null && typeof out.status === "string") return out.status;
|
|
486
|
+
}
|
|
487
|
+
function extractResponsesText(resp) {
|
|
488
|
+
if (typeof resp.output_text === "string") return resp.output_text;
|
|
489
|
+
const outputs = resp.output ?? [];
|
|
490
|
+
let text = "";
|
|
491
|
+
for (const item of outputs) text += extractOutputItemText(item);
|
|
492
|
+
return text;
|
|
493
|
+
}
|
|
494
|
+
function extractResponsesToolCalls(resp) {
|
|
495
|
+
const toolCalls = [];
|
|
496
|
+
const outputs = resp.output ?? [];
|
|
497
|
+
for (const item of outputs) {
|
|
498
|
+
if (!Array.isArray(item.content)) continue;
|
|
499
|
+
for (const contentItem of item.content) if (contentItem?.type === "tool_call" || contentItem?.type === "function_call") toolCalls.push(contentItem);
|
|
500
|
+
}
|
|
501
|
+
return toolCalls;
|
|
502
|
+
}
|
|
503
|
+
function extractOutputItemText(item) {
|
|
504
|
+
if (!Array.isArray(item.content)) return "";
|
|
505
|
+
let text = "";
|
|
506
|
+
for (const c of item.content) if (typeof c?.text === "string") text += c.text;
|
|
507
|
+
return text;
|
|
508
|
+
}
|
|
509
|
+
function extractResponsesUserInputs(input) {
|
|
510
|
+
if (typeof input === "string") return [input];
|
|
511
|
+
if (!Array.isArray(input)) return [];
|
|
512
|
+
const result = [];
|
|
513
|
+
for (const entry of input) {
|
|
514
|
+
if (typeof entry === "string") {
|
|
515
|
+
result.push(entry);
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (entry.role !== "user") continue;
|
|
519
|
+
const content = entry.content;
|
|
520
|
+
if (typeof content === "string") result.push(content);
|
|
521
|
+
else if (Array.isArray(content)) {
|
|
522
|
+
for (const part of content) if (typeof part?.text === "string") result.push(part.text);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return result;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
//#endregion
|
|
529
|
+
export { OPENAI_AVAILABLE, OpenAI, WrappedChat, WrappedCompletions, WrappedResponses, _OpenAIModule, extractSystemPrompt };
|
|
530
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","names":["_OpenAIModule: Record<string, unknown> | null","clientOpts: Record<string, unknown>","costUsd: number | null","toolCalls: Array<Record<string, unknown>>","result: string[]"],"sources":["../../src/providers/openai.ts"],"sourcesContent":["/**\n * OpenAI provider wrapper with automatic tracking.\n *\n * Wraps the OpenAI client and instruments:\n * - chat.completions.create()\n * - responses.create()\n * to track AI response events via Amplitude.\n */\n\nimport type { PrivacyConfig } from '../core/privacy.js';\nimport { trackUserMessage } from '../core/tracking.js';\nimport { getDefaultPropagateContext, injectContext } from '../propagation.js';\nimport type {\n AmplitudeLike,\n AmplitudeOrAI,\n ChatCompletionResponse,\n ChatMessage,\n OpenAIResponse,\n OpenAIResponseInput,\n OpenAIResponseOutputItem,\n TrackFn,\n} from '../types.js';\nimport { calculateCost } from '../utils/costs.js';\nimport { tryRequire } from '../utils/resolve-module.js';\nimport { StreamingAccumulator } from '../utils/streaming.js';\nimport {\n applySessionContext,\n BaseAIProvider,\n type ProviderTrackOptions,\n} from './base.js';\n\nconst _resolved = tryRequire('openai');\nexport const OPENAI_AVAILABLE = _resolved != null;\nconst _OpenAIModule: Record<string, unknown> | null = _resolved;\n\nexport { _OpenAIModule };\n\nexport interface OpenAIOptions {\n amplitude: AmplitudeOrAI;\n apiKey?: string;\n baseUrl?: string;\n privacyConfig?: PrivacyConfig | null;\n propagateContext?: boolean;\n /** Pass the `openai` module directly to bypass `tryRequire` (required in bundler environments). */\n openaiModule?: unknown;\n}\n\nexport class OpenAI<\n TClient extends Record<string, unknown> = Record<string, unknown>,\n> extends BaseAIProvider {\n private _client: TClient;\n readonly chat: WrappedChat;\n readonly responses: WrappedResponses;\n private _propagateContext: boolean;\n\n constructor(options: OpenAIOptions) {\n super({\n amplitude: options.amplitude,\n privacyConfig: options.privacyConfig,\n providerName: 'openai',\n });\n\n const mod =\n (options.openaiModule as Record<string, unknown> | null) ?? _OpenAIModule;\n if (mod == null) {\n throw new Error(\n 'openai package is required. Install it with: npm install openai — or pass the module directly via the openaiModule option.',\n );\n }\n\n const OpenAISDK = mod.OpenAI as new (\n opts: Record<string, unknown>,\n ) => unknown;\n\n const clientOpts: Record<string, unknown> = {};\n if (options.apiKey) clientOpts.apiKey = options.apiKey;\n if (options.baseUrl) clientOpts.baseURL = options.baseUrl;\n\n this._client = new OpenAISDK(clientOpts) as TClient;\n this._propagateContext =\n options.propagateContext ?? getDefaultPropagateContext();\n this.chat = new WrappedChat(\n this._client,\n this.trackFn(),\n this._amplitude,\n this._privacyConfig,\n this._propagateContext,\n );\n this.responses = new WrappedResponses(\n this._client,\n this.trackFn(),\n this._amplitude,\n this._privacyConfig,\n this._propagateContext,\n );\n }\n\n get client(): TClient {\n return this._client;\n }\n}\n\nexport class WrappedChat {\n readonly completions: WrappedCompletions;\n\n constructor(\n client: unknown,\n trackFn: TrackFn,\n amplitude: AmplitudeLike,\n privacyConfig: PrivacyConfig | null,\n propagateContext: boolean,\n ) {\n const clientObj = client as Record<string, unknown>;\n const chat = clientObj.chat as Record<string, unknown>;\n this.completions = new WrappedCompletions(\n chat.completions as Record<string, unknown>,\n trackFn,\n amplitude,\n privacyConfig,\n propagateContext,\n );\n }\n}\n\nexport class WrappedCompletions {\n _original: Record<string, unknown>;\n private _trackFn: TrackFn;\n private _amplitude: AmplitudeLike;\n private _privacyConfig: PrivacyConfig | null;\n private _propagateContext: boolean;\n private _providerName: string;\n\n constructor(\n completions: Record<string, unknown>,\n trackFn: TrackFn,\n amplitude: AmplitudeLike,\n privacyConfig: PrivacyConfig | null,\n propagateContext: boolean,\n providerName = 'openai',\n ) {\n this._original = completions;\n this._trackFn =\n typeof trackFn === 'function'\n ? trackFn\n : (trackFn as unknown as { trackFn(): TrackFn }).trackFn();\n this._amplitude = amplitude;\n this._privacyConfig = privacyConfig;\n this._propagateContext = propagateContext;\n this._providerName = providerName;\n }\n\n async create(\n params: Record<string, unknown>,\n amplitudeOverrides?: ProviderTrackOptions,\n ): Promise<ChatCompletionResponse | AsyncIterable<unknown>> {\n const createFn = this._original.create as (\n ...args: unknown[]\n ) => Promise<unknown>;\n const startTime = performance.now();\n let requestParams = this._withContextHeaders(params);\n const ctx = applySessionContext(amplitudeOverrides);\n\n if (requestParams.stream === true && requestParams.stream_options == null) {\n requestParams = {\n ...requestParams,\n stream_options: { include_usage: true },\n };\n }\n\n try {\n this._trackInputMessages(\n requestParams.messages as unknown,\n ctx,\n amplitudeOverrides?.trackInputMessages ?? true,\n );\n const response = await createFn.call(this._original, requestParams);\n\n if (requestParams.stream === true && _isAsyncIterable(response)) {\n return this._wrapStream(\n response as AsyncIterable<unknown>,\n requestParams,\n startTime,\n ctx,\n );\n }\n\n const latencyMs = performance.now() - startTime;\n\n const resp = response as ChatCompletionResponse;\n const usage = resp.usage;\n const choice = resp.choices?.[0];\n const modelName = String(resp.model ?? requestParams.model ?? 'unknown');\n const toolCalls = choice?.message?.tool_calls;\n\n const usageExt = usage as Record<string, unknown> | undefined;\n const promptDetails = usageExt?.prompt_tokens_details as\n | Record<string, number>\n | undefined;\n const completionDetails = usageExt?.completion_tokens_details as\n | Record<string, number>\n | undefined;\n const reasoningTokens = completionDetails?.reasoning_tokens;\n const cachedTokens = promptDetails?.cached_tokens;\n\n let costUsd: number | null = null;\n if (usage?.prompt_tokens != null && usage?.completion_tokens != null) {\n try {\n costUsd = calculateCost({\n modelName,\n inputTokens: usage.prompt_tokens,\n outputTokens: usage.completion_tokens,\n reasoningTokens: reasoningTokens ?? 0,\n cacheReadInputTokens: cachedTokens ?? 0,\n });\n } catch {\n // cost calculation is best-effort\n }\n }\n\n this._trackFn({\n userId: ctx.userId ?? 'unknown',\n modelName,\n provider: this._providerName,\n responseContent: String(choice?.message?.content ?? ''),\n latencyMs,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n turnId: ctx.turnId ?? undefined,\n agentId: ctx.agentId,\n env: ctx.env,\n inputTokens: usage?.prompt_tokens,\n outputTokens: usage?.completion_tokens,\n totalTokens: usage?.total_tokens,\n reasoningTokens,\n cacheReadInputTokens: cachedTokens,\n totalCostUsd: costUsd,\n finishReason: choice?.finish_reason,\n toolCalls: toolCalls ?? undefined,\n isStreaming: false,\n systemPrompt: extractSystemPrompt(requestParams),\n temperature: requestParams.temperature as number | undefined,\n maxOutputTokens: requestParams.max_tokens as number | undefined,\n topP: requestParams.top_p as number | undefined,\n });\n\n return response as ChatCompletionResponse;\n } catch (error) {\n const latencyMs = performance.now() - startTime;\n this._trackFn({\n userId: ctx.userId ?? 'unknown',\n modelName: String(requestParams.model ?? 'unknown'),\n provider: this._providerName,\n responseContent: '',\n latencyMs,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n agentId: ctx.agentId,\n env: ctx.env,\n isError: true,\n errorMessage: error instanceof Error ? error.message : String(error),\n });\n\n throw error;\n }\n }\n\n async parse(\n params: Record<string, unknown>,\n amplitudeOverrides?: ProviderTrackOptions,\n ): Promise<ChatCompletionResponse | AsyncIterable<unknown>> {\n const parseFn = this._original.parse as\n | ((...args: unknown[]) => Promise<unknown>)\n | undefined;\n if (typeof parseFn !== 'function') {\n throw new Error('OpenAI SDK does not expose chat.completions.parse');\n }\n const originalCreate = this._original.create;\n this._original.create = parseFn;\n try {\n return await this.create(params, amplitudeOverrides);\n } finally {\n this._original.create = originalCreate;\n }\n }\n\n private async *_wrapStream(\n stream: AsyncIterable<unknown>,\n params: Record<string, unknown>,\n _startTime: number,\n sessionCtx: ProviderTrackOptions,\n ): AsyncGenerator<unknown> {\n const accumulator = new StreamingAccumulator();\n accumulator.model = String(params.model ?? 'unknown');\n let reasoningContent = '';\n\n try {\n for await (const chunk of stream) {\n const c = chunk as Record<string, unknown>;\n const choices = c.choices as Array<Record<string, unknown>> | undefined;\n const delta = choices?.[0]?.delta as\n | Record<string, unknown>\n | undefined;\n\n if (delta?.content != null) {\n accumulator.addContent(String(delta.content));\n }\n\n const deltaToolCalls = delta?.tool_calls as\n | Array<Record<string, unknown>>\n | undefined;\n if (Array.isArray(deltaToolCalls)) {\n for (const call of deltaToolCalls) {\n accumulator.addToolCall(call);\n }\n }\n\n if (delta?.reasoning_content != null) {\n reasoningContent += String(delta.reasoning_content);\n }\n\n const finishReason = choices?.[0]?.finish_reason;\n if (finishReason != null) {\n accumulator.finishReason = String(finishReason);\n }\n\n const usage = c.usage as Record<string, unknown> | undefined;\n if (usage != null) {\n const promptDetails = usage.prompt_tokens_details as\n | Record<string, number>\n | undefined;\n const completionDetails = usage.completion_tokens_details as\n | Record<string, number>\n | undefined;\n\n accumulator.setUsage({\n inputTokens: usage.prompt_tokens as number | undefined,\n outputTokens: usage.completion_tokens as number | undefined,\n totalTokens: usage.total_tokens as number | undefined,\n reasoningTokens: completionDetails?.reasoning_tokens,\n cacheReadTokens: promptDetails?.cached_tokens,\n });\n }\n\n yield chunk;\n }\n } catch (error) {\n accumulator.setError(\n error instanceof Error ? error.message : String(error),\n );\n throw error;\n } finally {\n const state = accumulator.getState();\n const modelName = String(accumulator.model ?? params.model ?? 'unknown');\n\n let costUsd: number | null = null;\n if (state.inputTokens != null && state.outputTokens != null) {\n try {\n costUsd = calculateCost({\n modelName,\n inputTokens: state.inputTokens,\n outputTokens: state.outputTokens,\n reasoningTokens: state.reasoningTokens ?? 0,\n cacheReadInputTokens: state.cacheReadTokens ?? 0,\n });\n } catch {\n // cost calculation is best-effort\n }\n }\n\n this._trackFn({\n userId: sessionCtx.userId ?? 'unknown',\n modelName,\n provider: this._providerName,\n responseContent: state.content,\n latencyMs: accumulator.elapsedMs,\n sessionId: sessionCtx.sessionId,\n traceId: sessionCtx.traceId,\n turnId: sessionCtx.turnId ?? undefined,\n agentId: sessionCtx.agentId,\n env: sessionCtx.env,\n inputTokens: state.inputTokens,\n outputTokens: state.outputTokens,\n totalTokens: state.totalTokens,\n reasoningTokens: state.reasoningTokens,\n cacheReadInputTokens: state.cacheReadTokens,\n totalCostUsd: costUsd,\n finishReason: state.finishReason,\n toolCalls: state.toolCalls.length > 0 ? state.toolCalls : undefined,\n providerTtfbMs: state.ttfbMs,\n isStreaming: true,\n isError: state.isError,\n errorMessage: state.errorMessage,\n reasoningContent: reasoningContent || undefined,\n systemPrompt: extractSystemPrompt(params),\n temperature: params.temperature as number | undefined,\n maxOutputTokens: params.max_tokens as number | undefined,\n topP: params.top_p as number | undefined,\n });\n }\n }\n\n private _withContextHeaders(\n params: Record<string, unknown>,\n ): Record<string, unknown> {\n if (!this._propagateContext) return params;\n const existing = (params.extra_headers ?? params.headers) as\n | Record<string, string>\n | undefined;\n const injected = injectContext(existing);\n return {\n ...params,\n extra_headers: injected,\n };\n }\n\n private _trackInputMessages(\n messages: unknown,\n ctx: ProviderTrackOptions,\n shouldTrackInputMessages: boolean,\n ): void {\n if (!shouldTrackInputMessages) return;\n if (ctx.userId == null || ctx.sessionId == null) return;\n if (!Array.isArray(messages)) return;\n for (const msg of messages as ChatMessage[]) {\n if (msg?.role !== 'user') continue;\n const content = msg.content;\n if (typeof content !== 'string' || content.length === 0) continue;\n trackUserMessage({\n amplitude: this._amplitude,\n userId: ctx.userId,\n messageContent: content,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n turnId: ctx.turnId ?? undefined,\n agentId: ctx.agentId,\n parentAgentId: ctx.parentAgentId,\n customerOrgId: ctx.customerOrgId,\n env: ctx.env,\n groups: ctx.groups,\n privacyConfig: this._privacyConfig,\n });\n }\n }\n}\n\nexport class WrappedResponses {\n _original: Record<string, unknown>;\n private _trackFn: TrackFn;\n private _amplitude: AmplitudeLike;\n private _privacyConfig: PrivacyConfig | null;\n private _propagateContext: boolean;\n private _providerName: string;\n\n constructor(\n client: unknown,\n trackFn: TrackFn,\n amplitude: AmplitudeLike,\n privacyConfig: PrivacyConfig | null,\n propagateContext: boolean,\n providerName = 'openai',\n ) {\n const clientObj = client as Record<string, unknown>;\n const responses = (clientObj.responses ?? {}) as Record<string, unknown>;\n this._original = responses;\n this._trackFn =\n typeof trackFn === 'function'\n ? trackFn\n : (trackFn as unknown as { trackFn(): TrackFn }).trackFn();\n this._amplitude = amplitude;\n this._privacyConfig = privacyConfig;\n this._propagateContext = propagateContext;\n this._providerName = providerName;\n }\n\n async create(\n params: Record<string, unknown>,\n amplitudeOverrides?: ProviderTrackOptions,\n ): Promise<OpenAIResponse | AsyncIterable<unknown>> {\n const createFn = this._original.create as (\n ...args: unknown[]\n ) => Promise<unknown>;\n const startTime = performance.now();\n const requestParams = this._withContextHeaders(params);\n const ctx = applySessionContext(amplitudeOverrides);\n\n try {\n this._trackInputMessages(\n requestParams.input as unknown,\n ctx,\n amplitudeOverrides?.trackInputMessages ?? true,\n );\n const response = await createFn.call(this._original, requestParams);\n if (requestParams.stream === true && _isAsyncIterable(response)) {\n return this._wrapStream(\n response as AsyncIterable<unknown>,\n requestParams,\n startTime,\n ctx,\n );\n }\n\n const latencyMs = performance.now() - startTime;\n const resp = response as OpenAIResponse;\n const usage = resp.usage;\n const responseText = extractResponsesText(resp);\n const responseToolCalls = extractResponsesToolCalls(resp);\n const modelName = String(resp.model ?? requestParams.model ?? 'unknown');\n\n let costUsd: number | null = null;\n if (usage?.input_tokens != null && usage?.output_tokens != null) {\n try {\n costUsd = calculateCost({\n modelName,\n inputTokens: usage.input_tokens,\n outputTokens: usage.output_tokens,\n reasoningTokens: usage.output_tokens_details?.reasoning_tokens ?? 0,\n });\n } catch {\n // cost calculation is best-effort\n }\n }\n\n this._trackFn({\n userId: ctx.userId ?? 'unknown',\n modelName,\n provider: this._providerName,\n responseContent: responseText,\n latencyMs,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n turnId: ctx.turnId ?? undefined,\n agentId: ctx.agentId,\n env: ctx.env,\n inputTokens: usage?.input_tokens,\n outputTokens: usage?.output_tokens,\n totalTokens: usage?.total_tokens,\n reasoningTokens: usage?.output_tokens_details?.reasoning_tokens,\n totalCostUsd: costUsd,\n finishReason: extractResponsesFinishReason(resp),\n toolCalls: responseToolCalls.length > 0 ? responseToolCalls : undefined,\n isStreaming: false,\n systemPrompt: extractResponsesSystemPrompt(requestParams),\n temperature: requestParams.temperature as number | undefined,\n maxOutputTokens: requestParams.max_output_tokens as number | undefined,\n topP: requestParams.top_p as number | undefined,\n });\n\n return response as OpenAIResponse;\n } catch (error) {\n const latencyMs = performance.now() - startTime;\n this._trackFn({\n userId: ctx.userId ?? 'unknown',\n modelName: String(requestParams.model ?? 'unknown'),\n provider: this._providerName,\n responseContent: '',\n latencyMs,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n agentId: ctx.agentId,\n env: ctx.env,\n isError: true,\n errorMessage: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n }\n\n async stream(\n params: Record<string, unknown>,\n amplitudeOverrides?: ProviderTrackOptions,\n ): Promise<AsyncIterable<unknown>> {\n const streamFn = this._original.stream as\n | ((...args: unknown[]) => Promise<unknown>)\n | undefined;\n if (typeof streamFn !== 'function') {\n throw new Error('OpenAI SDK does not expose responses.stream');\n }\n const startTime = performance.now();\n const requestParams = this._withContextHeaders(params);\n const ctx = applySessionContext(amplitudeOverrides);\n\n try {\n this._trackInputMessages(\n requestParams.input as unknown,\n ctx,\n amplitudeOverrides?.trackInputMessages ?? true,\n );\n const response = await streamFn.call(this._original, requestParams);\n if (!_isAsyncIterable(response)) {\n throw new Error('OpenAI responses.stream did not return AsyncIterable');\n }\n return this._wrapStream(\n response as AsyncIterable<unknown>,\n requestParams,\n startTime,\n ctx,\n );\n } catch (error) {\n this._trackFn({\n userId: ctx.userId ?? 'unknown',\n modelName: String(requestParams.model ?? 'unknown'),\n provider: this._providerName,\n responseContent: '',\n latencyMs: performance.now() - startTime,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n agentId: ctx.agentId,\n env: ctx.env,\n isError: true,\n errorMessage: error instanceof Error ? error.message : String(error),\n isStreaming: true,\n });\n throw error;\n }\n }\n\n private async *_wrapStream(\n stream: AsyncIterable<unknown>,\n params: Record<string, unknown>,\n _startTime: number,\n sessionCtx: ProviderTrackOptions,\n ): AsyncGenerator<unknown> {\n const accumulator = new StreamingAccumulator();\n accumulator.model = String(params.model ?? 'unknown');\n\n try {\n for await (const event of stream) {\n const e = event as Record<string, unknown>;\n const type = e.type as string | undefined;\n if (type === 'response.output_text.delta') {\n const delta = e.delta;\n if (typeof delta === 'string') accumulator.addContent(delta);\n } else if (type === 'response.completed') {\n const response = e.response as OpenAIResponse | undefined;\n if (response != null) {\n const outputText = extractResponsesText(response);\n if (outputText.length > 0) {\n accumulator.content = outputText;\n }\n const usage = response.usage;\n accumulator.setUsage({\n inputTokens: usage?.input_tokens,\n outputTokens: usage?.output_tokens,\n totalTokens: usage?.total_tokens,\n reasoningTokens: usage?.output_tokens_details?.reasoning_tokens,\n });\n const finishReason = extractResponsesFinishReason(response);\n if (finishReason != null) accumulator.finishReason = finishReason;\n }\n }\n yield event;\n }\n } catch (error) {\n accumulator.setError(\n error instanceof Error ? error.message : String(error),\n );\n throw error;\n } finally {\n const state = accumulator.getState();\n let costUsd: number | null = null;\n if (state.inputTokens != null && state.outputTokens != null) {\n try {\n costUsd = calculateCost({\n modelName: String(accumulator.model ?? params.model ?? 'unknown'),\n inputTokens: state.inputTokens,\n outputTokens: state.outputTokens,\n reasoningTokens: state.reasoningTokens ?? 0,\n });\n } catch {\n // cost calculation is best-effort\n }\n }\n this._trackFn({\n userId: sessionCtx.userId ?? 'unknown',\n modelName: String(accumulator.model ?? params.model ?? 'unknown'),\n provider: this._providerName,\n responseContent: state.content,\n latencyMs: accumulator.elapsedMs,\n sessionId: sessionCtx.sessionId,\n traceId: sessionCtx.traceId,\n turnId: sessionCtx.turnId ?? undefined,\n agentId: sessionCtx.agentId,\n env: sessionCtx.env,\n inputTokens: state.inputTokens,\n outputTokens: state.outputTokens,\n totalTokens: state.totalTokens,\n reasoningTokens: state.reasoningTokens,\n totalCostUsd: costUsd,\n finishReason: state.finishReason,\n providerTtfbMs: state.ttfbMs,\n isStreaming: true,\n isError: state.isError,\n errorMessage: state.errorMessage,\n systemPrompt: extractResponsesSystemPrompt(params),\n temperature: params.temperature as number | undefined,\n maxOutputTokens: params.max_output_tokens as number | undefined,\n topP: params.top_p as number | undefined,\n });\n }\n }\n\n private _withContextHeaders(\n params: Record<string, unknown>,\n ): Record<string, unknown> {\n if (!this._propagateContext) return params;\n const existing = (params.extra_headers ?? params.headers) as\n | Record<string, string>\n | undefined;\n const injected = injectContext(existing);\n return {\n ...params,\n extra_headers: injected,\n };\n }\n\n private _trackInputMessages(\n input: unknown,\n ctx: ProviderTrackOptions,\n shouldTrackInputMessages: boolean,\n ): void {\n if (!shouldTrackInputMessages) return;\n if (ctx.userId == null || ctx.sessionId == null) return;\n for (const text of extractResponsesUserInputs(input)) {\n if (!text) continue;\n trackUserMessage({\n amplitude: this._amplitude,\n userId: ctx.userId,\n messageContent: text,\n sessionId: ctx.sessionId,\n traceId: ctx.traceId,\n turnId: ctx.turnId ?? undefined,\n agentId: ctx.agentId,\n parentAgentId: ctx.parentAgentId,\n customerOrgId: ctx.customerOrgId,\n env: ctx.env,\n groups: ctx.groups,\n privacyConfig: this._privacyConfig,\n });\n }\n }\n}\n\nfunction _isAsyncIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n value != null &&\n typeof (value as Record<symbol, unknown>)[Symbol.asyncIterator] ===\n 'function'\n );\n}\n\nexport function extractSystemPrompt(\n params: Record<string, unknown>,\n): string | undefined {\n const messages = params.messages as\n | Array<Record<string, unknown>>\n | undefined;\n if (!messages?.length) return undefined;\n const systemMsg = messages.find(\n (m) => m.role === 'system' || m.role === 'developer',\n );\n return systemMsg ? String(systemMsg.content ?? '') : undefined;\n}\n\nfunction extractResponsesSystemPrompt(\n params: Record<string, unknown>,\n): string | undefined {\n const instructions = params.instructions;\n return typeof instructions === 'string' ? instructions : undefined;\n}\n\nfunction extractResponsesFinishReason(\n resp: OpenAIResponse,\n): string | undefined {\n const status = resp.status;\n if (typeof status === 'string' && status.length > 0) return status;\n const out = resp.output?.[0];\n if (out != null && typeof out.status === 'string') return out.status;\n return undefined;\n}\n\nfunction extractResponsesText(resp: OpenAIResponse): string {\n if (typeof resp.output_text === 'string') return resp.output_text;\n const outputs = resp.output ?? [];\n let text = '';\n for (const item of outputs) {\n text += extractOutputItemText(item);\n }\n return text;\n}\n\nfunction extractResponsesToolCalls(\n resp: OpenAIResponse,\n): Array<Record<string, unknown>> {\n const toolCalls: Array<Record<string, unknown>> = [];\n const outputs = resp.output ?? [];\n for (const item of outputs) {\n if (!Array.isArray(item.content)) continue;\n for (const contentItem of item.content) {\n if (\n contentItem?.type === 'tool_call' ||\n contentItem?.type === 'function_call'\n ) {\n toolCalls.push(contentItem as Record<string, unknown>);\n }\n }\n }\n return toolCalls;\n}\n\nfunction extractOutputItemText(item: OpenAIResponseOutputItem): string {\n if (!Array.isArray(item.content)) return '';\n let text = '';\n for (const c of item.content) {\n if (typeof c?.text === 'string') text += c.text;\n }\n return text;\n}\n\nfunction extractResponsesUserInputs(input: unknown): string[] {\n if (typeof input === 'string') return [input];\n if (!Array.isArray(input)) return [];\n\n const result: string[] = [];\n for (const entry of input as OpenAIResponseInput[]) {\n if (typeof entry === 'string') {\n result.push(entry);\n continue;\n }\n const role = entry.role;\n if (role !== 'user') continue;\n const content = entry.content;\n if (typeof content === 'string') {\n result.push(content);\n } else if (Array.isArray(content)) {\n for (const part of content) {\n if (typeof part?.text === 'string') result.push(part.text);\n }\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;AA+BA,MAAM,YAAY,WAAW,SAAS;AACtC,MAAa,mBAAmB,aAAa;AAC7C,MAAMA,gBAAgD;AActD,IAAa,SAAb,cAEU,eAAe;CACvB,AAAQ;CACR,AAAS;CACT,AAAS;CACT,AAAQ;CAER,YAAY,SAAwB;AAClC,QAAM;GACJ,WAAW,QAAQ;GACnB,eAAe,QAAQ;GACvB,cAAc;GACf,CAAC;EAEF,MAAM,MACH,QAAQ,gBAAmD;AAC9D,MAAI,OAAO,KACT,OAAM,IAAI,MACR,6HACD;EAGH,MAAM,YAAY,IAAI;EAItB,MAAMC,aAAsC,EAAE;AAC9C,MAAI,QAAQ,OAAQ,YAAW,SAAS,QAAQ;AAChD,MAAI,QAAQ,QAAS,YAAW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AS,sBAAsB,MAAwC;AACrE,KAAI,CAAC,MAAM,QAAQ,KAAK,QAAQ,CAAE,QAAO;CACzC,IAAI,OAAO;AACX,MAAK,MAAM,KAAK,KAAK,QACnB,KAAI,OAAO,GAAG,SAAS,SAAU,SAAQ,EAAE;AAE7C,QAAO;;AAGT,SAAS,2BAA2B,OAA0B;AAC5D,KAAI,OAAO,UAAU,SAAU,QAAO,CAAC,MAAM;AAC7C,KAAI,CAAC,MAAM,QAAQ,MAAM,CAAE,QAAO,EAAE;CAEpC,MAAMC,SAAmB,EAAE;AAC3B,MAAK,MAAM,SAAS,OAAgC;AAClD,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAO,KAAK,MAAM;AAClB;;AAGF,MADa,MAAM,SACN,OAAQ;EACrB,MAAM,UAAU,MAAM;AACtB,MAAI,OAAO,YAAY,SACrB,QAAO,KAAK,QAAQ;WACX,MAAM,QAAQ,QAAQ,EAC/B;QAAK,MAAM,QAAQ,QACjB,KAAI,OAAO,MAAM,SAAS,SAAU,QAAO,KAAK,KAAK,KAAK;;;AAIhE,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AIConfig, ContentMode } from "./config.js";
|
|
2
|
+
import { patch } from "./patching.js";
|
|
3
|
+
import { AmplitudeAI } from "./client.js";
|
|
4
|
+
|
|
5
|
+
//#region src/register.ts
|
|
6
|
+
/**
|
|
7
|
+
* Preload module for zero-code LLM instrumentation.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node --import @amplitude/ai/register app.js
|
|
11
|
+
*
|
|
12
|
+
* Or via the CLI wrapper:
|
|
13
|
+
* AMPLITUDE_AI_API_KEY=xxx AMPLITUDE_AI_AUTO_PATCH=true amplitude-ai-instrument node app.js
|
|
14
|
+
*
|
|
15
|
+
* Environment variables:
|
|
16
|
+
* - AMPLITUDE_AI_API_KEY (required): Amplitude API key
|
|
17
|
+
* - AMPLITUDE_AI_AUTO_PATCH: Must be "true" to enable auto-patching
|
|
18
|
+
* - AMPLITUDE_AI_CONTENT_MODE: "full" (default), "metadata_only", or "customer_enriched"
|
|
19
|
+
* - AMPLITUDE_AI_DEBUG: "true" for debug output to stderr
|
|
20
|
+
*/
|
|
21
|
+
const apiKey = process.env.AMPLITUDE_AI_API_KEY ?? "";
|
|
22
|
+
const autoPatch = (process.env.AMPLITUDE_AI_AUTO_PATCH ?? "").toLowerCase() === "true";
|
|
23
|
+
if (!apiKey) {
|
|
24
|
+
if (autoPatch) process.stderr.write("amplitude-ai: AMPLITUDE_AI_API_KEY not set, skipping auto-patch.\n");
|
|
25
|
+
} else if (autoPatch) try {
|
|
26
|
+
const debug = (process.env.AMPLITUDE_AI_DEBUG ?? "").toLowerCase() === "true";
|
|
27
|
+
const contentModeStr = (process.env.AMPLITUDE_AI_CONTENT_MODE ?? "full").toLowerCase();
|
|
28
|
+
let contentMode = ContentMode.FULL;
|
|
29
|
+
if (contentModeStr === "metadata_only") contentMode = ContentMode.METADATA_ONLY;
|
|
30
|
+
else if (contentModeStr === "customer_enriched") contentMode = ContentMode.CUSTOMER_ENRICHED;
|
|
31
|
+
patch({ amplitudeAI: new AmplitudeAI({
|
|
32
|
+
apiKey,
|
|
33
|
+
config: new AIConfig({
|
|
34
|
+
debug,
|
|
35
|
+
contentMode
|
|
36
|
+
})
|
|
37
|
+
}) });
|
|
38
|
+
const note = contentModeStr === "metadata_only" || contentModeStr === "customer_enriched" ? ` (content_mode=${contentModeStr})` : "";
|
|
39
|
+
process.stderr.write(`amplitude-ai: auto-patched providers${note}\n`);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
process.stderr.write(`amplitude-ai: bootstrap error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { };
|
|
46
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","names":[],"sources":["../src/register.ts"],"sourcesContent":["/**\n * Preload module for zero-code LLM instrumentation.\n *\n * Usage:\n * node --import @amplitude/ai/register app.js\n *\n * Or via the CLI wrapper:\n * AMPLITUDE_AI_API_KEY=xxx AMPLITUDE_AI_AUTO_PATCH=true amplitude-ai-instrument node app.js\n *\n * Environment variables:\n * - AMPLITUDE_AI_API_KEY (required): Amplitude API key\n * - AMPLITUDE_AI_AUTO_PATCH: Must be \"true\" to enable auto-patching\n * - AMPLITUDE_AI_CONTENT_MODE: \"full\" (default), \"metadata_only\", or \"customer_enriched\"\n * - AMPLITUDE_AI_DEBUG: \"true\" for debug output to stderr\n */\n\nimport { AmplitudeAI } from './client.js';\nimport { AIConfig, ContentMode } from './config.js';\nimport { patch } from './patching.js';\n\nconst apiKey = process.env.AMPLITUDE_AI_API_KEY ?? '';\nconst autoPatch =\n (process.env.AMPLITUDE_AI_AUTO_PATCH ?? '').toLowerCase() === 'true';\n\nif (!apiKey) {\n if (autoPatch) {\n process.stderr.write(\n 'amplitude-ai: AMPLITUDE_AI_API_KEY not set, skipping auto-patch.\\n',\n );\n }\n} else if (autoPatch) {\n try {\n const debug =\n (process.env.AMPLITUDE_AI_DEBUG ?? '').toLowerCase() === 'true';\n const contentModeStr = (\n process.env.AMPLITUDE_AI_CONTENT_MODE ?? 'full'\n ).toLowerCase();\n\n let contentMode = ContentMode.FULL;\n if (contentModeStr === 'metadata_only')\n contentMode = ContentMode.METADATA_ONLY;\n else if (contentModeStr === 'customer_enriched')\n contentMode = ContentMode.CUSTOMER_ENRICHED;\n\n const config = new AIConfig({ debug, contentMode });\n const ai = new AmplitudeAI({ apiKey, config });\n\n patch({ amplitudeAI: ai });\n\n const privacyMode =\n contentModeStr === 'metadata_only' ||\n contentModeStr === 'customer_enriched';\n const note = privacyMode ? ` (content_mode=${contentModeStr})` : '';\n process.stderr.write(`amplitude-ai: auto-patched providers${note}\\n`);\n } catch (err) {\n process.stderr.write(\n `amplitude-ai: bootstrap error: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,SAAS,QAAQ,IAAI,wBAAwB;AACnD,MAAM,aACH,QAAQ,IAAI,2BAA2B,IAAI,aAAa,KAAK;AAEhE,IAAI,CAAC,QACH;KAAI,UACF,SAAQ,OAAO,MACb,qEACD;WAEM,UACT,KAAI;CACF,MAAM,SACH,QAAQ,IAAI,sBAAsB,IAAI,aAAa,KAAK;CAC3D,MAAM,kBACJ,QAAQ,IAAI,6BAA6B,QACzC,aAAa;CAEf,IAAI,cAAc,YAAY;AAC9B,KAAI,mBAAmB,gBACrB,eAAc,YAAY;UACnB,mBAAmB,oBAC1B,eAAc,YAAY;AAK5B,OAAM,EAAE,aAFG,IAAI,YAAY;EAAE;EAAQ,QADtB,IAAI,SAAS;GAAE;GAAO;GAAa,CAAC;EACN,CAAC,EAErB,CAAC;CAK1B,MAAM,OAFJ,mBAAmB,mBACnB,mBAAmB,sBACM,kBAAkB,eAAe,KAAK;AACjE,SAAQ,OAAO,MAAM,uCAAuC,KAAK,IAAI;SAC9D,KAAK;AACZ,SAAQ,OAAO,MACb,kCAAkC,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC,IACpF"}
|