@sentry/server-utils 10.63.0 → 10.65.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/build/cjs/graphql/graphql-dc-subscriber.js +125 -0
- package/build/cjs/graphql/graphql-dc-subscriber.js.map +1 -0
- package/build/cjs/graphql/index.js +23 -0
- package/build/cjs/graphql/index.js.map +1 -0
- package/build/cjs/graphql/utils.js +86 -0
- package/build/cjs/graphql/utils.js.map +1 -0
- package/build/cjs/index.js +12 -9
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/amqplib.js +420 -0
- package/build/cjs/integrations/tracing-channel/amqplib.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/anthropic.js +101 -0
- package/build/cjs/integrations/tracing-channel/anthropic.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/express/index.js +24 -0
- package/build/cjs/integrations/tracing-channel/express/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/express/instrumentation.js +173 -0
- package/build/cjs/integrations/tracing-channel/express/instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/express/route.js +76 -0
- package/build/cjs/integrations/tracing-channel/express/route.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js +1 -1
- package/build/cjs/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/google-genai.js +96 -0
- package/build/cjs/integrations/tracing-channel/google-genai.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/constants.js +26 -0
- package/build/cjs/integrations/tracing-channel/graphql/constants.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/index.js +66 -0
- package/build/cjs/integrations/tracing-channel/graphql/index.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/resolvers.js +168 -0
- package/build/cjs/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/graphql/spans.js +102 -0
- package/build/cjs/integrations/tracing-channel/graphql/spans.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi-types.js +30 -0
- package/build/cjs/integrations/tracing-channel/hapi-types.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi-utils.js +177 -0
- package/build/cjs/integrations/tracing-channel/hapi-utils.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/hapi.js +52 -0
- package/build/cjs/integrations/tracing-channel/hapi.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/ioredis.js +96 -0
- package/build/cjs/integrations/tracing-channel/ioredis.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/mysql.js +2 -1
- package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/openai.js +83 -0
- package/build/cjs/integrations/tracing-channel/openai.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/postgres-js.js +191 -0
- package/build/cjs/integrations/tracing-channel/postgres-js.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/postgres.js +170 -0
- package/build/cjs/integrations/tracing-channel/postgres.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/redis.js +227 -0
- package/build/cjs/integrations/tracing-channel/redis.js.map +1 -0
- package/build/cjs/integrations/tracing-channel/vercel-ai.js +25 -0
- package/build/cjs/integrations/tracing-channel/vercel-ai.js.map +1 -0
- package/build/cjs/mongoose/index.js +23 -0
- package/build/cjs/mongoose/index.js.map +1 -0
- package/build/cjs/mongoose/mongoose-dc-subscriber.js +97 -0
- package/build/cjs/mongoose/mongoose-dc-subscriber.js.map +1 -0
- package/build/cjs/mysql2/index.js +23 -0
- package/build/cjs/mysql2/index.js.map +1 -0
- package/build/cjs/mysql2/mysql2-dc-subscriber.js +68 -0
- package/build/cjs/mysql2/mysql2-dc-subscriber.js.map +1 -0
- package/build/cjs/orchestrion/bundler/vite.js +3 -3
- package/build/cjs/orchestrion/bundler/vite.js.map +1 -1
- package/build/cjs/orchestrion/channels.js +29 -2
- package/build/cjs/orchestrion/channels.js.map +1 -1
- package/build/cjs/orchestrion/config/amqplib.js +81 -0
- package/build/cjs/orchestrion/config/amqplib.js.map +1 -0
- package/build/cjs/orchestrion/config/anthropic-ai.js +43 -0
- package/build/cjs/orchestrion/config/anthropic-ai.js.map +1 -0
- package/build/cjs/orchestrion/config/express.js +76 -0
- package/build/cjs/orchestrion/config/express.js.map +1 -0
- package/build/cjs/orchestrion/config/google-genai.js +38 -0
- package/build/cjs/orchestrion/config/google-genai.js.map +1 -0
- package/build/cjs/orchestrion/config/graphql.js +28 -0
- package/build/cjs/orchestrion/config/graphql.js.map +1 -0
- package/build/cjs/orchestrion/config/hapi.js +26 -0
- package/build/cjs/orchestrion/config/hapi.js.map +1 -0
- package/build/cjs/orchestrion/config/index.js +48 -0
- package/build/cjs/orchestrion/config/index.js.map +1 -0
- package/build/cjs/orchestrion/config/ioredis.js +35 -0
- package/build/cjs/orchestrion/config/ioredis.js.map +1 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js +17 -0
- package/build/cjs/orchestrion/config/lru-memoizer.js.map +1 -0
- package/build/cjs/orchestrion/config/mysql.js +16 -0
- package/build/cjs/orchestrion/config/mysql.js.map +1 -0
- package/build/cjs/orchestrion/config/openai.js +40 -0
- package/build/cjs/orchestrion/config/openai.js.map +1 -0
- package/build/cjs/orchestrion/config/pg.js +51 -0
- package/build/cjs/orchestrion/config/pg.js.map +1 -0
- package/build/cjs/orchestrion/config/postgres.js +50 -0
- package/build/cjs/orchestrion/config/postgres.js.map +1 -0
- package/build/cjs/orchestrion/config/redis.js +76 -0
- package/build/cjs/orchestrion/config/redis.js.map +1 -0
- package/build/cjs/orchestrion/config/vercel-ai.js +48 -0
- package/build/cjs/orchestrion/config/vercel-ai.js.map +1 -0
- package/build/cjs/orchestrion/detect.js +6 -1
- package/build/cjs/orchestrion/detect.js.map +1 -1
- package/build/cjs/orchestrion/index.js +44 -5
- package/build/cjs/orchestrion/index.js.map +1 -1
- package/build/cjs/orchestrion/runtime/register.js +10 -7
- package/build/cjs/orchestrion/runtime/register.js.map +1 -1
- package/build/cjs/redis/index.js +23 -0
- package/build/cjs/redis/index.js.map +1 -0
- package/build/cjs/redis/redis-dc-subscriber.js +23 -35
- package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
- package/build/cjs/redis/redis-statement-serializer.js +34 -0
- package/build/cjs/redis/redis-statement-serializer.js.map +1 -0
- package/build/cjs/tracing-channel.js +8 -7
- package/build/cjs/tracing-channel.js.map +1 -1
- package/build/cjs/vercel-ai/util.js +123 -0
- package/build/cjs/vercel-ai/util.js.map +1 -0
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +147 -76
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js +386 -0
- package/build/cjs/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
- package/build/esm/graphql/graphql-dc-subscriber.js +118 -0
- package/build/esm/graphql/graphql-dc-subscriber.js.map +1 -0
- package/build/esm/graphql/index.js +21 -0
- package/build/esm/graphql/index.js.map +1 -0
- package/build/esm/graphql/utils.js +81 -0
- package/build/esm/graphql/utils.js.map +1 -0
- package/build/esm/index.js +5 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/tracing-channel/amqplib.js +418 -0
- package/build/esm/integrations/tracing-channel/amqplib.js.map +1 -0
- package/build/esm/integrations/tracing-channel/anthropic.js +99 -0
- package/build/esm/integrations/tracing-channel/anthropic.js.map +1 -0
- package/build/esm/integrations/tracing-channel/express/index.js +22 -0
- package/build/esm/integrations/tracing-channel/express/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/express/instrumentation.js +171 -0
- package/build/esm/integrations/tracing-channel/express/instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing-channel/express/route.js +68 -0
- package/build/esm/integrations/tracing-channel/express/route.js.map +1 -0
- package/build/esm/integrations/tracing-channel/fastify/instrumentation.js +2 -2
- package/build/esm/integrations/tracing-channel/fastify/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing-channel/google-genai.js +94 -0
- package/build/esm/integrations/tracing-channel/google-genai.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/constants.js +14 -0
- package/build/esm/integrations/tracing-channel/graphql/constants.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/index.js +63 -0
- package/build/esm/integrations/tracing-channel/graphql/index.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/resolvers.js +164 -0
- package/build/esm/integrations/tracing-channel/graphql/resolvers.js.map +1 -0
- package/build/esm/integrations/tracing-channel/graphql/spans.js +96 -0
- package/build/esm/integrations/tracing-channel/graphql/spans.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi-types.js +25 -0
- package/build/esm/integrations/tracing-channel/hapi-types.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi-utils.js +172 -0
- package/build/esm/integrations/tracing-channel/hapi-utils.js.map +1 -0
- package/build/esm/integrations/tracing-channel/hapi.js +50 -0
- package/build/esm/integrations/tracing-channel/hapi.js.map +1 -0
- package/build/esm/integrations/tracing-channel/ioredis.js +94 -0
- package/build/esm/integrations/tracing-channel/ioredis.js.map +1 -0
- package/build/esm/integrations/tracing-channel/mysql.js +3 -2
- package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/esm/integrations/tracing-channel/openai.js +81 -0
- package/build/esm/integrations/tracing-channel/openai.js.map +1 -0
- package/build/esm/integrations/tracing-channel/postgres-js.js +189 -0
- package/build/esm/integrations/tracing-channel/postgres-js.js.map +1 -0
- package/build/esm/integrations/tracing-channel/postgres.js +168 -0
- package/build/esm/integrations/tracing-channel/postgres.js.map +1 -0
- package/build/esm/integrations/tracing-channel/redis.js +225 -0
- package/build/esm/integrations/tracing-channel/redis.js.map +1 -0
- package/build/esm/integrations/tracing-channel/vercel-ai.js +23 -0
- package/build/esm/integrations/tracing-channel/vercel-ai.js.map +1 -0
- package/build/esm/mongoose/index.js +21 -0
- package/build/esm/mongoose/index.js.map +1 -0
- package/build/esm/mongoose/mongoose-dc-subscriber.js +89 -0
- package/build/esm/mongoose/mongoose-dc-subscriber.js.map +1 -0
- package/build/esm/mysql2/index.js +21 -0
- package/build/esm/mysql2/index.js.map +1 -0
- package/build/esm/mysql2/mysql2-dc-subscriber.js +62 -0
- package/build/esm/mysql2/mysql2-dc-subscriber.js.map +1 -0
- package/build/esm/orchestrion/bundler/vite.js +1 -1
- package/build/esm/orchestrion/channels.js +29 -2
- package/build/esm/orchestrion/channels.js.map +1 -1
- package/build/esm/orchestrion/config/amqplib.js +78 -0
- package/build/esm/orchestrion/config/amqplib.js.map +1 -0
- package/build/esm/orchestrion/config/anthropic-ai.js +40 -0
- package/build/esm/orchestrion/config/anthropic-ai.js.map +1 -0
- package/build/esm/orchestrion/config/express.js +73 -0
- package/build/esm/orchestrion/config/express.js.map +1 -0
- package/build/esm/orchestrion/config/google-genai.js +35 -0
- package/build/esm/orchestrion/config/google-genai.js.map +1 -0
- package/build/esm/orchestrion/config/graphql.js +25 -0
- package/build/esm/orchestrion/config/graphql.js.map +1 -0
- package/build/esm/orchestrion/config/hapi.js +23 -0
- package/build/esm/orchestrion/config/hapi.js.map +1 -0
- package/build/esm/orchestrion/config/index.js +44 -0
- package/build/esm/orchestrion/config/index.js.map +1 -0
- package/build/esm/orchestrion/config/ioredis.js +32 -0
- package/build/esm/orchestrion/config/ioredis.js.map +1 -0
- package/build/esm/orchestrion/config/lru-memoizer.js +14 -0
- package/build/esm/orchestrion/config/lru-memoizer.js.map +1 -0
- package/build/esm/orchestrion/config/mysql.js +13 -0
- package/build/esm/orchestrion/config/mysql.js.map +1 -0
- package/build/esm/orchestrion/config/openai.js +37 -0
- package/build/esm/orchestrion/config/openai.js.map +1 -0
- package/build/esm/orchestrion/config/pg.js +48 -0
- package/build/esm/orchestrion/config/pg.js.map +1 -0
- package/build/esm/orchestrion/config/postgres.js +47 -0
- package/build/esm/orchestrion/config/postgres.js.map +1 -0
- package/build/esm/orchestrion/config/redis.js +73 -0
- package/build/esm/orchestrion/config/redis.js.map +1 -0
- package/build/esm/orchestrion/config/vercel-ai.js +45 -0
- package/build/esm/orchestrion/config/vercel-ai.js.map +1 -0
- package/build/esm/orchestrion/detect.js +6 -2
- package/build/esm/orchestrion/detect.js.map +1 -1
- package/build/esm/orchestrion/index.js +33 -3
- package/build/esm/orchestrion/index.js.map +1 -1
- package/build/esm/orchestrion/runtime/register.js +8 -4
- package/build/esm/orchestrion/runtime/register.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/redis/index.js +21 -0
- package/build/esm/redis/index.js.map +1 -0
- package/build/esm/redis/redis-dc-subscriber.js +24 -36
- package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
- package/build/esm/redis/redis-statement-serializer.js +32 -0
- package/build/esm/redis/redis-statement-serializer.js.map +1 -0
- package/build/esm/tracing-channel.js +9 -8
- package/build/esm/tracing-channel.js.map +1 -1
- package/build/esm/vercel-ai/util.js +116 -0
- package/build/esm/vercel-ai/util.js.map +1 -0
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +122 -54
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js +384 -0
- package/build/esm/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -0
- package/build/types/graphql/graphql-dc-subscriber.d.ts +94 -0
- package/build/types/graphql/graphql-dc-subscriber.d.ts.map +1 -0
- package/build/types/graphql/index.d.ts +12 -0
- package/build/types/graphql/index.d.ts.map +1 -0
- package/build/types/graphql/utils.d.ts +40 -0
- package/build/types/graphql/utils.d.ts.map +1 -0
- package/build/types/index.d.ts +6 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/amqplib.d.ts +11 -0
- package/build/types/integrations/tracing-channel/amqplib.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/anthropic.d.ts +10 -0
- package/build/types/integrations/tracing-channel/anthropic.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/index.d.ts +18 -0
- package/build/types/integrations/tracing-channel/express/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
- package/build/types/integrations/tracing-channel/express/instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/route.d.ts +28 -0
- package/build/types/integrations/tracing-channel/express/route.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/express/types.d.ts +64 -0
- package/build/types/integrations/tracing-channel/express/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/fastify/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/google-genai.d.ts +12 -0
- package/build/types/integrations/tracing-channel/google-genai.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/constants.d.ts +12 -0
- package/build/types/integrations/tracing-channel/graphql/constants.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
- package/build/types/integrations/tracing-channel/graphql/graphql-types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/index.d.ts +28 -0
- package/build/types/integrations/tracing-channel/graphql/index.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
- package/build/types/integrations/tracing-channel/graphql/resolvers.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/spans.d.ts +17 -0
- package/build/types/integrations/tracing-channel/graphql/spans.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/graphql/types.d.ts +25 -0
- package/build/types/integrations/tracing-channel/graphql/types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi-types.d.ts +53 -0
- package/build/types/integrations/tracing-channel/hapi-types.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi-utils.d.ts +25 -0
- package/build/types/integrations/tracing-channel/hapi-utils.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/hapi.d.ts +9 -0
- package/build/types/integrations/tracing-channel/hapi.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts +17 -0
- package/build/types/integrations/tracing-channel/ioredis.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -1
- package/build/types/integrations/tracing-channel/openai.d.ts +10 -0
- package/build/types/integrations/tracing-channel/openai.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/postgres-js.d.ts +26 -0
- package/build/types/integrations/tracing-channel/postgres-js.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/postgres.d.ts +15 -0
- package/build/types/integrations/tracing-channel/postgres.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/redis.d.ts +16 -0
- package/build/types/integrations/tracing-channel/redis.d.ts.map +1 -0
- package/build/types/integrations/tracing-channel/vercel-ai.d.ts +13 -0
- package/build/types/integrations/tracing-channel/vercel-ai.d.ts.map +1 -0
- package/build/types/mongoose/index.d.ts +11 -0
- package/build/types/mongoose/index.d.ts.map +1 -0
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts +63 -0
- package/build/types/mongoose/mongoose-dc-subscriber.d.ts.map +1 -0
- package/build/types/mysql2/index.d.ts +11 -0
- package/build/types/mysql2/index.d.ts.map +1 -0
- package/build/types/mysql2/mysql2-dc-subscriber.d.ts +59 -0
- package/build/types/mysql2/mysql2-dc-subscriber.d.ts.map +1 -0
- package/build/types/orchestrion/channels.d.ts +55 -1
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/amqplib.d.ts +66 -0
- package/build/types/orchestrion/config/amqplib.d.ts.map +1 -0
- package/build/types/orchestrion/config/anthropic-ai.d.ts +31 -0
- package/build/types/orchestrion/config/anthropic-ai.d.ts.map +1 -0
- package/build/types/orchestrion/config/express.d.ts +32 -0
- package/build/types/orchestrion/config/express.d.ts.map +1 -0
- package/build/types/orchestrion/config/google-genai.d.ts +30 -0
- package/build/types/orchestrion/config/google-genai.d.ts.map +1 -0
- package/build/types/orchestrion/config/graphql.d.ts +29 -0
- package/build/types/orchestrion/config/graphql.d.ts.map +1 -0
- package/build/types/orchestrion/config/hapi.d.ts +17 -0
- package/build/types/orchestrion/config/hapi.d.ts.map +1 -0
- package/build/types/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
- package/build/types/orchestrion/config/index.d.ts.map +1 -0
- package/build/types/orchestrion/config/ioredis.d.ts +7 -0
- package/build/types/orchestrion/config/ioredis.d.ts.map +1 -0
- package/build/types/orchestrion/config/lru-memoizer.d.ts +16 -0
- package/build/types/orchestrion/config/lru-memoizer.d.ts.map +1 -0
- package/build/types/orchestrion/config/mysql.d.ts +16 -0
- package/build/types/orchestrion/config/mysql.d.ts.map +1 -0
- package/build/types/orchestrion/config/openai.d.ts +20 -0
- package/build/types/orchestrion/config/openai.d.ts.map +1 -0
- package/build/types/orchestrion/config/pg.d.ts +33 -0
- package/build/types/orchestrion/config/pg.d.ts.map +1 -0
- package/build/types/orchestrion/config/postgres.d.ts +9 -0
- package/build/types/orchestrion/config/postgres.d.ts.map +1 -0
- package/build/types/orchestrion/config/redis.d.ts +37 -0
- package/build/types/orchestrion/config/redis.d.ts.map +1 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts +12 -0
- package/build/types/orchestrion/config/vercel-ai.d.ts.map +1 -0
- package/build/types/orchestrion/detect.d.ts +10 -0
- package/build/types/orchestrion/detect.d.ts.map +1 -1
- package/build/types/orchestrion/index.d.ts +80 -3
- package/build/types/orchestrion/index.d.ts.map +1 -1
- package/build/types/orchestrion/runtime/register.d.ts.map +1 -1
- package/build/types/redis/index.d.ts +18 -0
- package/build/types/redis/index.d.ts.map +1 -0
- package/build/types/redis/redis-dc-subscriber.d.ts +0 -5
- package/build/types/redis/redis-dc-subscriber.d.ts.map +1 -1
- package/build/types/redis/redis-statement-serializer.d.ts +6 -0
- package/build/types/redis/redis-statement-serializer.d.ts.map +1 -0
- package/build/types/tracing-channel.d.ts +5 -0
- package/build/types/tracing-channel.d.ts.map +1 -1
- package/build/types/vercel-ai/util.d.ts +32 -0
- package/build/types/vercel-ai/util.d.ts.map +1 -0
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
- package/build/types/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -0
- package/build/types-ts3.8/graphql/graphql-dc-subscriber.d.ts +94 -0
- package/build/types-ts3.8/graphql/index.d.ts +12 -0
- package/build/types-ts3.8/graphql/utils.d.ts +40 -0
- package/build/types-ts3.8/index.d.ts +6 -2
- package/build/types-ts3.8/integrations/tracing-channel/amqplib.d.ts +11 -0
- package/build/types-ts3.8/integrations/tracing-channel/anthropic.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/index.d.ts +18 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/instrumentation.d.ts +4 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/route.d.ts +28 -0
- package/build/types-ts3.8/integrations/tracing-channel/express/types.d.ts +64 -0
- package/build/types-ts3.8/integrations/tracing-channel/google-genai.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/constants.d.ts +12 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/graphql-types.d.ts +135 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/index.d.ts +30 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/resolvers.d.ts +13 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/spans.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing-channel/graphql/types.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi-types.d.ts +65 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi-utils.d.ts +25 -0
- package/build/types-ts3.8/integrations/tracing-channel/hapi.d.ts +9 -0
- package/build/types-ts3.8/integrations/tracing-channel/ioredis.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing-channel/openai.d.ts +10 -0
- package/build/types-ts3.8/integrations/tracing-channel/postgres-js.d.ts +26 -0
- package/build/types-ts3.8/integrations/tracing-channel/postgres.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing-channel/redis.d.ts +16 -0
- package/build/types-ts3.8/integrations/tracing-channel/vercel-ai.d.ts +13 -0
- package/build/types-ts3.8/mongoose/index.d.ts +11 -0
- package/build/types-ts3.8/mongoose/mongoose-dc-subscriber.d.ts +63 -0
- package/build/types-ts3.8/mysql2/index.d.ts +11 -0
- package/build/types-ts3.8/mysql2/mysql2-dc-subscriber.d.ts +59 -0
- package/build/types-ts3.8/orchestrion/channels.d.ts +55 -1
- package/build/types-ts3.8/orchestrion/config/amqplib.d.ts +66 -0
- package/build/types-ts3.8/orchestrion/config/anthropic-ai.d.ts +31 -0
- package/build/types-ts3.8/orchestrion/config/express.d.ts +32 -0
- package/build/types-ts3.8/orchestrion/config/google-genai.d.ts +30 -0
- package/build/types-ts3.8/orchestrion/config/graphql.d.ts +29 -0
- package/build/types-ts3.8/orchestrion/config/hapi.d.ts +17 -0
- package/build/types-ts3.8/orchestrion/{config.d.ts → config/index.d.ts} +1 -12
- package/build/types-ts3.8/orchestrion/config/ioredis.d.ts +7 -0
- package/build/types-ts3.8/orchestrion/config/lru-memoizer.d.ts +16 -0
- package/build/types-ts3.8/orchestrion/config/mysql.d.ts +16 -0
- package/build/types-ts3.8/orchestrion/config/openai.d.ts +20 -0
- package/build/types-ts3.8/orchestrion/config/pg.d.ts +33 -0
- package/build/types-ts3.8/orchestrion/config/postgres.d.ts +9 -0
- package/build/types-ts3.8/orchestrion/config/redis.d.ts +37 -0
- package/build/types-ts3.8/orchestrion/config/vercel-ai.d.ts +12 -0
- package/build/types-ts3.8/orchestrion/detect.d.ts +10 -0
- package/build/types-ts3.8/orchestrion/index.d.ts +82 -3
- package/build/types-ts3.8/redis/index.d.ts +18 -0
- package/build/types-ts3.8/redis/redis-dc-subscriber.d.ts +0 -5
- package/build/types-ts3.8/redis/redis-statement-serializer.d.ts +6 -0
- package/build/types-ts3.8/tracing-channel.d.ts +5 -0
- package/build/types-ts3.8/vercel-ai/util.d.ts +32 -0
- package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +15 -5
- package/build/types-ts3.8/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts +12 -0
- package/package.json +9 -9
- package/build/cjs/orchestrion/config.js +0 -44
- package/build/cjs/orchestrion/config.js.map +0 -1
- package/build/esm/orchestrion/config.js +0 -40
- package/build/esm/orchestrion/config.js.map +0 -1
- package/build/types/orchestrion/config.d.ts.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
|
|
5
|
+
function asString(value) {
|
|
6
|
+
return typeof value === "string" ? value : void 0;
|
|
7
|
+
}
|
|
8
|
+
function asNumber(value) {
|
|
9
|
+
return typeof value === "number" && !isNaN(value) ? value : void 0;
|
|
10
|
+
}
|
|
11
|
+
function sum(a, b) {
|
|
12
|
+
return a === void 0 && b === void 0 ? void 0 : (a ?? 0) + (b ?? 0);
|
|
13
|
+
}
|
|
14
|
+
function safeStringify(value) {
|
|
15
|
+
if (typeof value === "string") {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
} catch {
|
|
21
|
+
return "[unserializable]";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function isReadableStream(value) {
|
|
25
|
+
return core.isObjectLike(value) && typeof value.pipeThrough === "function" && typeof value.getReader === "function";
|
|
26
|
+
}
|
|
27
|
+
function tapModelCallStream(stream, onFinal, onError) {
|
|
28
|
+
const reader = stream.getReader();
|
|
29
|
+
const state = { toolCalls: [] };
|
|
30
|
+
let text = "";
|
|
31
|
+
let settled = false;
|
|
32
|
+
const finalize = () => {
|
|
33
|
+
if (settled) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
settled = true;
|
|
37
|
+
if (text) {
|
|
38
|
+
state.text = text;
|
|
39
|
+
}
|
|
40
|
+
onFinal(state);
|
|
41
|
+
};
|
|
42
|
+
const fail = (error) => {
|
|
43
|
+
if (settled) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
settled = true;
|
|
47
|
+
onError(error);
|
|
48
|
+
};
|
|
49
|
+
return new ReadableStream({
|
|
50
|
+
async pull(controller) {
|
|
51
|
+
try {
|
|
52
|
+
const { done, value } = await reader.read();
|
|
53
|
+
if (done) {
|
|
54
|
+
finalize();
|
|
55
|
+
controller.close();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
text += accumulateChunk(state, value) ?? "";
|
|
59
|
+
controller.enqueue(value);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
fail(error);
|
|
62
|
+
controller.error(error);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
cancel(reason) {
|
|
66
|
+
finalize();
|
|
67
|
+
return reader.cancel(reason);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function accumulateChunk(state, chunk) {
|
|
72
|
+
if (!core.isObjectLike(chunk)) {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
const {
|
|
76
|
+
type,
|
|
77
|
+
delta,
|
|
78
|
+
textDelta,
|
|
79
|
+
id,
|
|
80
|
+
modelId,
|
|
81
|
+
toolCallId,
|
|
82
|
+
toolName,
|
|
83
|
+
input,
|
|
84
|
+
args,
|
|
85
|
+
finishReason,
|
|
86
|
+
usage,
|
|
87
|
+
providerMetadata
|
|
88
|
+
} = chunk;
|
|
89
|
+
switch (type) {
|
|
90
|
+
case "text-delta": {
|
|
91
|
+
const textChunk = delta ?? textDelta;
|
|
92
|
+
return typeof textChunk === "string" ? textChunk : void 0;
|
|
93
|
+
}
|
|
94
|
+
case "tool-call":
|
|
95
|
+
state.toolCalls.push({ toolCallId, toolName, input: input ?? args });
|
|
96
|
+
return void 0;
|
|
97
|
+
case "response-metadata":
|
|
98
|
+
if (typeof id === "string") {
|
|
99
|
+
state.responseId = id;
|
|
100
|
+
}
|
|
101
|
+
if (typeof modelId === "string") {
|
|
102
|
+
state.responseModel = modelId;
|
|
103
|
+
}
|
|
104
|
+
return void 0;
|
|
105
|
+
case "finish":
|
|
106
|
+
state.finishReason = finishReason;
|
|
107
|
+
state.usage = usage;
|
|
108
|
+
if (providerMetadata !== void 0) {
|
|
109
|
+
state.providerMetadata = providerMetadata;
|
|
110
|
+
}
|
|
111
|
+
return void 0;
|
|
112
|
+
default:
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.asNumber = asNumber;
|
|
118
|
+
exports.asString = asString;
|
|
119
|
+
exports.isReadableStream = isReadableStream;
|
|
120
|
+
exports.safeStringify = safeStringify;
|
|
121
|
+
exports.sum = sum;
|
|
122
|
+
exports.tapModelCallStream = tapModelCallStream;
|
|
123
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../src/vercel-ai/util.ts"],"sourcesContent":["/** Shared, state-free helpers for the Vercel AI (`ai`) channel subscribers, plus the streamed model-call tap. */\n\nimport { isObjectLike } from '@sentry/core';\n\n/** Narrow to a string, or `undefined` for anything else. */\nexport function asString(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\n/** Narrow to a finite number, or `undefined` for anything else (including `NaN`). */\nexport function asNumber(value: unknown): number | undefined {\n return typeof value === 'number' && !isNaN(value) ? value : undefined;\n}\n\n/** Add two optional numbers, treating a missing operand as `0` but returning `undefined` when both are absent. */\nexport function sum(a: number | undefined, b: number | undefined): number | undefined {\n return a === undefined && b === undefined ? undefined : (a ?? 0) + (b ?? 0);\n}\n\n/** Stringify a value, passing strings through and falling back to a placeholder on circular/unserializable input. */\nexport function safeStringify(value: unknown): string {\n if (typeof value === 'string') {\n return value;\n }\n try {\n return JSON.stringify(value);\n } catch {\n return '[unserializable]';\n }\n}\n\n/*\n * Streaming support for the `ai:telemetry` tracing channel.\n *\n * For a streamed model call (`doStream`) the SDK resolves the `languageModelCall` channel promise as\n * soon as it hands back the *unconsumed* stream — so `result.stream` is a `ReadableStream` and the\n * final usage / finish reason / output only arrive later, as the stream is drained (they ride the\n * stream's own `finish`/`text-delta`/`tool-call` chunks, never the channel context). The SDK\n * deliberately leaves `result` undefined on the `streamText`/`step` contexts and exposes the stream\n * only on the model call, expecting consumers to tap it themselves.\n * @see https://github.com/vercel/ai/pull/15660 (discussion: \"tee off and aggregate ourselves\")\n *\n * We replace `result.stream` with a passthrough that forwards every chunk untouched (so the SDK's own\n * consumption is unaffected) while accumulating the data we need, then hand the aggregate back once the\n * stream settles so the model-call span can be enriched and ended out-of-band.\n */\n\n/** The subset of a streamed provider chunk we read. Unknown chunk types are forwarded and ignored. */\ninterface StreamChunk {\n type?: unknown;\n delta?: unknown;\n // v4 text-delta chunks carry the text on `textDelta`; v5+ uses `delta`.\n textDelta?: unknown;\n id?: unknown;\n modelId?: unknown;\n toolCallId?: unknown;\n toolName?: unknown;\n input?: unknown;\n args?: unknown;\n finishReason?: unknown;\n usage?: unknown;\n providerMetadata?: unknown;\n error?: unknown;\n}\n\n/** The aggregate handed back once a streamed model call finishes, in the shape `enrichSpanOnEnd` expects. */\nexport interface StreamedModelCallResult {\n text?: string;\n toolCalls: Array<Record<string, unknown>>;\n usage?: unknown;\n finishReason?: unknown;\n responseId?: string;\n responseModel?: string;\n providerMetadata?: unknown;\n}\n\n/** A minimal structural check — the streamed model call exposes a web `ReadableStream` on `result.stream`. */\nexport function isReadableStream(value: unknown): value is ReadableStream<unknown> {\n return (\n isObjectLike(value) &&\n typeof (value as { pipeThrough?: unknown }).pipeThrough === 'function' &&\n typeof (value as { getReader?: unknown }).getReader === 'function'\n );\n}\n\n/**\n * Wrap a streamed model call's `ReadableStream` so its chunks are observed as the SDK consumes them,\n * without altering what the SDK sees. Returns a replacement stream to swap onto `result.stream`.\n *\n * `onFinal` runs exactly once when the stream drains cleanly; `onError` runs exactly once if it errors\n * or is cancelled. Reading one source chunk per `pull` preserves the SDK's backpressure. The\n * `try/catch` around every read guarantees the owning span is always ended — a leaked open span on a\n * mid-stream failure would be worse than a slightly-less-enriched one.\n */\nexport function tapModelCallStream(\n stream: ReadableStream<unknown>,\n onFinal: (result: StreamedModelCallResult) => void,\n onError: (error: unknown) => void,\n): ReadableStream<unknown> {\n const reader = stream.getReader();\n const state: StreamedModelCallResult = { toolCalls: [] };\n let text = '';\n let settled = false;\n\n const finalize = (): void => {\n if (settled) {\n return;\n }\n settled = true;\n if (text) {\n state.text = text;\n }\n onFinal(state);\n };\n\n const fail = (error: unknown): void => {\n if (settled) {\n return;\n }\n settled = true;\n onError(error);\n };\n\n return new ReadableStream<unknown>({\n async pull(controller) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n finalize();\n controller.close();\n\n return;\n }\n text += accumulateChunk(state, value) ?? '';\n controller.enqueue(value);\n } catch (error) {\n fail(error);\n controller.error(error);\n }\n },\n cancel(reason) {\n // Consumer stopped reading early (e.g. a `break` out of `for await`); close out the span with\n // whatever we have rather than leave it open. A non-error reason is a deliberate stop, not a failure.\n finalize();\n\n return reader.cancel(reason);\n },\n });\n}\n\n/**\n * Fold a single streamed chunk into the running aggregate. Returns any text delta so the caller can\n * accumulate it (kept out of `state` until the end to avoid re-joining on every chunk).\n */\nfunction accumulateChunk(state: StreamedModelCallResult, chunk: unknown): string | undefined {\n if (!isObjectLike(chunk)) {\n return undefined;\n }\n const {\n type,\n delta,\n textDelta,\n id,\n modelId,\n toolCallId,\n toolName,\n input,\n args,\n finishReason,\n usage,\n providerMetadata,\n } = chunk as StreamChunk;\n\n switch (type) {\n case 'text-delta': {\n const textChunk = delta ?? textDelta;\n return typeof textChunk === 'string' ? textChunk : undefined;\n }\n case 'tool-call':\n state.toolCalls.push({ toolCallId, toolName, input: input ?? args });\n\n return undefined;\n case 'response-metadata':\n if (typeof id === 'string') {\n state.responseId = id;\n }\n if (typeof modelId === 'string') {\n state.responseModel = modelId;\n }\n\n return undefined;\n case 'finish':\n state.finishReason = finishReason;\n state.usage = usage;\n if (providerMetadata !== undefined) {\n state.providerMetadata = providerMetadata;\n }\n\n return undefined;\n default:\n return undefined;\n }\n}\n"],"names":["isObjectLike"],"mappings":"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"}
|
|
@@ -4,6 +4,7 @@ const attributes = require('@sentry/conventions/attributes');
|
|
|
4
4
|
const op = require('@sentry/conventions/op');
|
|
5
5
|
const core = require('@sentry/core');
|
|
6
6
|
const tracingChannel = require('../tracing-channel.js');
|
|
7
|
+
const util = require('./util.js');
|
|
7
8
|
|
|
8
9
|
const AI_SDK_TELEMETRY_TRACING_CHANNEL = "ai:telemetry";
|
|
9
10
|
const ORIGIN = "auto.vercelai.channel";
|
|
@@ -17,24 +18,36 @@ const VERCEL_AI_MODEL_PROVIDER_ATTRIBUTE = "vercel.ai.model.provider";
|
|
|
17
18
|
const VERCEL_AI_SETTINGS_MAX_RETRIES_ATTRIBUTE = "vercel.ai.settings.maxRetries";
|
|
18
19
|
const operationIdByCallId = /* @__PURE__ */ new Map();
|
|
19
20
|
const toolDescriptionsByCallId = /* @__PURE__ */ new Map();
|
|
20
|
-
const
|
|
21
|
+
const invokeAgentSpanByCallId = /* @__PURE__ */ new Map();
|
|
22
|
+
const ROOT_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
23
|
+
"generateText",
|
|
24
|
+
"streamText",
|
|
25
|
+
"generateObject",
|
|
26
|
+
"embed",
|
|
27
|
+
"embedMany",
|
|
28
|
+
"rerank"
|
|
29
|
+
]);
|
|
21
30
|
function clearOperationId(data) {
|
|
22
31
|
if (!ROOT_OPERATION_TYPES.has(data.type)) {
|
|
23
32
|
return;
|
|
24
33
|
}
|
|
25
|
-
const callId = asString(data.event.callId);
|
|
34
|
+
const callId = util.asString(data.event.callId);
|
|
26
35
|
if (callId) {
|
|
27
|
-
|
|
28
|
-
toolDescriptionsByCallId.delete(callId);
|
|
36
|
+
clearOperationCallId(callId);
|
|
29
37
|
}
|
|
30
38
|
}
|
|
39
|
+
function clearOperationCallId(callId) {
|
|
40
|
+
operationIdByCallId.delete(callId);
|
|
41
|
+
toolDescriptionsByCallId.delete(callId);
|
|
42
|
+
invokeAgentSpanByCallId.delete(callId);
|
|
43
|
+
}
|
|
31
44
|
function recordToolDescriptions(callId, tools) {
|
|
32
45
|
if (!callId || !Array.isArray(tools)) {
|
|
33
46
|
return;
|
|
34
47
|
}
|
|
35
48
|
let descriptions = toolDescriptionsByCallId.get(callId);
|
|
36
49
|
for (const tool of tools) {
|
|
37
|
-
if (
|
|
50
|
+
if (core.isObjectLike(tool) && typeof tool.name === "string" && typeof tool.description === "string") {
|
|
38
51
|
descriptions = descriptions ?? /* @__PURE__ */ new Map();
|
|
39
52
|
if (!descriptions.has(tool.name)) {
|
|
40
53
|
descriptions.set(tool.name, tool.description);
|
|
@@ -51,21 +64,16 @@ function resolveToolDescription(callId, toolName, tools) {
|
|
|
51
64
|
return fromMap;
|
|
52
65
|
}
|
|
53
66
|
if (Array.isArray(tools)) {
|
|
54
|
-
const match = tools.find((tool) =>
|
|
55
|
-
return
|
|
67
|
+
const match = tools.find((tool) => core.isObjectLike(tool) && tool.name === toolName);
|
|
68
|
+
return core.isObjectLike(match) ? util.asString(match.description) : void 0;
|
|
56
69
|
}
|
|
57
|
-
if (
|
|
70
|
+
if (core.isObjectLike(tools)) {
|
|
58
71
|
const tool = tools[toolName];
|
|
59
|
-
return
|
|
72
|
+
return core.isObjectLike(tool) ? util.asString(tool.description) : void 0;
|
|
60
73
|
}
|
|
61
74
|
return void 0;
|
|
62
75
|
}
|
|
63
|
-
let subscribed = false;
|
|
64
76
|
function subscribeVercelAiTracingChannel(tracingChannel$1, options = {}) {
|
|
65
|
-
if (subscribed) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
subscribed = true;
|
|
69
77
|
tracingChannel.bindTracingChannelToSpan(
|
|
70
78
|
tracingChannel$1(AI_SDK_TELEMETRY_TRACING_CHANNEL),
|
|
71
79
|
(data) => createSpanFromMessage(data, options),
|
|
@@ -75,20 +83,94 @@ function subscribeVercelAiTracingChannel(tracingChannel$1, options = {}) {
|
|
|
75
83
|
beforeSpanEnd: (span, data) => {
|
|
76
84
|
enrichSpanOnEnd(span, data, options);
|
|
77
85
|
clearOperationId(data);
|
|
78
|
-
}
|
|
86
|
+
},
|
|
87
|
+
// A streamed model call resolves before its stream is drained, so we tap the stream, keep the
|
|
88
|
+
// span open, and end it (via `end`) once the final usage/finish/output chunks arrive.
|
|
89
|
+
deferSpanEnd: ({ data, end }) => deferStreamedModelCallEnd(data, options, end)
|
|
79
90
|
}
|
|
80
91
|
);
|
|
81
92
|
}
|
|
93
|
+
function deferStreamedModelCallEnd(data, options, end) {
|
|
94
|
+
if (data.type !== "languageModelCall" || !core.isObjectLike(data.result)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const result = data.result;
|
|
98
|
+
const stream = result.stream;
|
|
99
|
+
if (!util.isReadableStream(stream)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const callId = util.asString(data.event.callId);
|
|
103
|
+
const { recordOutputs } = getRecordingOptions(data.event, options);
|
|
104
|
+
result.stream = util.tapModelCallStream(
|
|
105
|
+
stream,
|
|
106
|
+
(final) => {
|
|
107
|
+
data.result = { ...result, ...streamedResultToChannelResult(final) };
|
|
108
|
+
end();
|
|
109
|
+
enrichInvokeAgentFromStream(callId, final, recordOutputs);
|
|
110
|
+
},
|
|
111
|
+
(error) => end(error)
|
|
112
|
+
);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
function streamedResultToChannelResult(final) {
|
|
116
|
+
const content = [];
|
|
117
|
+
if (final.text) {
|
|
118
|
+
content.push({ type: "text", text: final.text });
|
|
119
|
+
}
|
|
120
|
+
for (const toolCall of final.toolCalls) {
|
|
121
|
+
content.push({ type: "tool-call", ...toolCall });
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
content,
|
|
125
|
+
...final.usage !== void 0 ? { usage: final.usage } : {},
|
|
126
|
+
...final.finishReason !== void 0 ? { finishReason: final.finishReason } : {},
|
|
127
|
+
...final.providerMetadata !== void 0 ? { providerMetadata: final.providerMetadata } : {},
|
|
128
|
+
...final.responseId || final.responseModel ? {
|
|
129
|
+
response: {
|
|
130
|
+
...final.responseId ? { id: final.responseId } : {},
|
|
131
|
+
...final.responseModel ? { modelId: final.responseModel } : {}
|
|
132
|
+
}
|
|
133
|
+
} : {}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function enrichInvokeAgentFromStream(callId, final, recordOutputs) {
|
|
137
|
+
const span = callId ? invokeAgentSpanByCallId.get(callId) : void 0;
|
|
138
|
+
if (!span) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const usage = core.isObjectLike(final.usage) ? final.usage : void 0;
|
|
142
|
+
if (usage) {
|
|
143
|
+
const input = tokenCount(usage.inputTokens) ?? tokenCount(usage.promptTokens) ?? tokenCount(usage.tokens);
|
|
144
|
+
const output = tokenCount(usage.outputTokens) ?? tokenCount(usage.completionTokens);
|
|
145
|
+
addTokensToSpan(span, attributes.GEN_AI_USAGE_INPUT_TOKENS, input);
|
|
146
|
+
addTokensToSpan(span, attributes.GEN_AI_USAGE_OUTPUT_TOKENS, output);
|
|
147
|
+
addTokensToSpan(span, attributes.GEN_AI_USAGE_TOTAL_TOKENS, tokenCount(usage.totalTokens) ?? util.sum(input, output));
|
|
148
|
+
}
|
|
149
|
+
if (recordOutputs) {
|
|
150
|
+
const parts = partsFromTextAndToolCalls(final.text, final.toolCalls);
|
|
151
|
+
const outputMessages = buildOutputMessages(parts, getFinishReason({ finishReason: final.finishReason }));
|
|
152
|
+
if (outputMessages) {
|
|
153
|
+
span.setAttribute(attributes.GEN_AI_OUTPUT_MESSAGES, outputMessages);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function addTokensToSpan(span, attribute, value) {
|
|
158
|
+
if (value === void 0) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const current = core.spanToJSON(span).data[attribute];
|
|
162
|
+
span.setAttribute(attribute, (typeof current === "number" ? current : 0) + value);
|
|
163
|
+
}
|
|
82
164
|
function createSpanFromMessage(data, channelOptions) {
|
|
83
165
|
const { type, event } = data;
|
|
84
166
|
if (type === "step" || !event || typeof event !== "object") {
|
|
85
167
|
return void 0;
|
|
86
168
|
}
|
|
87
169
|
const { recordInputs, enableTruncation } = getRecordingOptions(event, channelOptions);
|
|
88
|
-
const provider = asString(event.provider);
|
|
89
|
-
const modelId = asString(event.modelId);
|
|
90
|
-
const callId = asString(event.callId);
|
|
91
|
-
const maxRetries = asNumber(event.maxRetries);
|
|
170
|
+
const provider = util.asString(event.provider);
|
|
171
|
+
const modelId = util.asString(event.modelId);
|
|
172
|
+
const callId = util.asString(event.callId);
|
|
173
|
+
const maxRetries = util.asNumber(event.maxRetries);
|
|
92
174
|
if (recordInputs) {
|
|
93
175
|
recordToolDescriptions(callId, event.tools);
|
|
94
176
|
}
|
|
@@ -101,16 +183,20 @@ function createSpanFromMessage(data, channelOptions) {
|
|
|
101
183
|
switch (type) {
|
|
102
184
|
case "generateText":
|
|
103
185
|
case "streamText":
|
|
186
|
+
case "generateObject":
|
|
104
187
|
return buildInvokeAgentSpan(event, baseAttributes, recordInputs, enableTruncation, callId, type === "streamText");
|
|
105
188
|
case "languageModelCall":
|
|
106
189
|
return buildModelCallSpan(event, baseAttributes, recordInputs, enableTruncation, callId, modelId);
|
|
107
190
|
case "executeTool":
|
|
108
191
|
return buildToolSpan(event, recordInputs);
|
|
109
192
|
case "embed":
|
|
193
|
+
case "embedMany": {
|
|
194
|
+
const input = type === "embedMany" ? event.values : event.value;
|
|
110
195
|
return startGenAiSpan(GEN_AI_EMBEDDINGS_OPERATION, modelId, {
|
|
111
196
|
...baseAttributes,
|
|
112
|
-
...recordInputs &&
|
|
197
|
+
...recordInputs && input !== void 0 ? { [attributes.GEN_AI_EMBEDDINGS_INPUT]: util.safeStringify(input) } : {}
|
|
113
198
|
});
|
|
199
|
+
}
|
|
114
200
|
case "rerank":
|
|
115
201
|
return startGenAiSpan(GEN_AI_RERANK_OPERATION, modelId, baseAttributes);
|
|
116
202
|
default:
|
|
@@ -125,18 +211,22 @@ function startGenAiSpan(operation, suffix, attributes$1) {
|
|
|
125
211
|
});
|
|
126
212
|
}
|
|
127
213
|
function buildInvokeAgentSpan(event, baseAttributes, recordInputs, enableTruncation, callId, isStream) {
|
|
128
|
-
const functionId = asString(event.functionId);
|
|
129
|
-
const operationId = asString(event.operationId) ?? (isStream ? "ai.streamText" : "ai.generateText");
|
|
214
|
+
const functionId = util.asString(event.functionId);
|
|
215
|
+
const operationId = util.asString(event.operationId) ?? (isStream ? "ai.streamText" : "ai.generateText");
|
|
130
216
|
if (callId) {
|
|
131
217
|
operationIdByCallId.set(callId, { operationId, isStream });
|
|
132
218
|
}
|
|
133
|
-
|
|
219
|
+
const span = startGenAiSpan(op.GEN_AI_INVOKE_AGENT_SPAN_OP, functionId, {
|
|
134
220
|
...baseAttributes,
|
|
135
221
|
[VERCEL_AI_OPERATION_ID_ATTRIBUTE]: operationId,
|
|
136
222
|
[attributes.GEN_AI_RESPONSE_STREAMING]: isStream,
|
|
137
223
|
...functionId ? { [attributes.GEN_AI_FUNCTION_ID]: functionId } : {},
|
|
138
224
|
...recordInputs ? buildInputMessageAttributes(event, enableTruncation) : {}
|
|
139
225
|
});
|
|
226
|
+
if (isStream && callId) {
|
|
227
|
+
invokeAgentSpanByCallId.set(callId, span);
|
|
228
|
+
}
|
|
229
|
+
return span;
|
|
140
230
|
}
|
|
141
231
|
function buildModelCallSpan(event, baseAttributes, recordInputs, enableTruncation, callId, modelId) {
|
|
142
232
|
const parent = callId ? operationIdByCallId.get(callId) : void 0;
|
|
@@ -145,45 +235,45 @@ function buildModelCallSpan(event, baseAttributes, recordInputs, enableTruncatio
|
|
|
145
235
|
...baseAttributes,
|
|
146
236
|
[VERCEL_AI_OPERATION_ID_ATTRIBUTE]: operationId,
|
|
147
237
|
...recordInputs ? buildInputMessageAttributes(event, enableTruncation) : {},
|
|
148
|
-
...recordInputs && Array.isArray(event.tools) ? { [attributes.GEN_AI_REQUEST_AVAILABLE_TOOLS]: safeStringify(event.tools) } : {}
|
|
238
|
+
...recordInputs && Array.isArray(event.tools) ? { [attributes.GEN_AI_REQUEST_AVAILABLE_TOOLS]: util.safeStringify(event.tools) } : {}
|
|
149
239
|
});
|
|
150
240
|
}
|
|
151
241
|
function buildToolSpan(event, recordInputs) {
|
|
152
|
-
const toolCall =
|
|
153
|
-
const toolName = asString(toolCall.toolName);
|
|
154
|
-
const toolCallId = asString(event.toolCallId) ?? asString(toolCall.toolCallId);
|
|
242
|
+
const toolCall = core.isObjectLike(event.toolCall) ? event.toolCall : {};
|
|
243
|
+
const toolName = util.asString(toolCall.toolName);
|
|
244
|
+
const toolCallId = util.asString(event.toolCallId) ?? util.asString(toolCall.toolCallId);
|
|
155
245
|
const toolInput = toolCall.input ?? toolCall.args;
|
|
156
|
-
const description = recordInputs && toolName ? resolveToolDescription(asString(event.callId), toolName, event.tools) : void 0;
|
|
246
|
+
const description = recordInputs && toolName ? resolveToolDescription(util.asString(event.callId), toolName, event.tools) : void 0;
|
|
157
247
|
return startGenAiSpan(op.GEN_AI_EXECUTE_TOOL_SPAN_OP, toolName, {
|
|
158
248
|
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
159
249
|
[attributes.GEN_AI_TOOL_TYPE]: "function",
|
|
160
250
|
...toolName ? { [attributes.GEN_AI_TOOL_NAME]: toolName } : {},
|
|
161
251
|
...toolCallId ? { [GEN_AI_TOOL_CALL_ID_ATTRIBUTE]: toolCallId } : {},
|
|
162
252
|
...description ? { [GEN_AI_TOOL_DESCRIPTION_ATTRIBUTE]: description } : {},
|
|
163
|
-
...recordInputs && toolInput !== void 0 ? { [attributes.GEN_AI_TOOL_INPUT]: safeStringify(toolInput) } : {}
|
|
253
|
+
...recordInputs && toolInput !== void 0 ? { [attributes.GEN_AI_TOOL_INPUT]: util.safeStringify(toolInput) } : {}
|
|
164
254
|
});
|
|
165
255
|
}
|
|
166
256
|
function enrichSpanOnEnd(span, data, channelOptions) {
|
|
167
257
|
const { type, result } = data;
|
|
168
|
-
if (!
|
|
258
|
+
if (!core.isObjectLike(result)) {
|
|
169
259
|
return;
|
|
170
260
|
}
|
|
171
261
|
const { recordOutputs } = getRecordingOptions(data.event, channelOptions);
|
|
172
262
|
if (type === "executeTool") {
|
|
173
263
|
if (recordOutputs) {
|
|
174
|
-
span.setAttribute(attributes.GEN_AI_TOOL_OUTPUT, safeStringify(result.output ?? result));
|
|
264
|
+
span.setAttribute(attributes.GEN_AI_TOOL_OUTPUT, util.safeStringify(result.output ?? result));
|
|
175
265
|
}
|
|
176
|
-
const output =
|
|
266
|
+
const output = core.isObjectLike(result.output) ? result.output : void 0;
|
|
177
267
|
if (output?.type === "tool-error") {
|
|
178
268
|
captureToolError(span, data, output.error);
|
|
179
269
|
}
|
|
180
270
|
return;
|
|
181
271
|
}
|
|
182
|
-
const usage =
|
|
272
|
+
const usage = core.isObjectLike(result.usage) ? result.usage : void 0;
|
|
183
273
|
if (usage) {
|
|
184
|
-
const inputTokens = tokenCount(usage.inputTokens) ?? tokenCount(usage.tokens);
|
|
185
|
-
const outputTokens = tokenCount(usage.outputTokens);
|
|
186
|
-
const totalTokens = tokenCount(usage.totalTokens) ?? sum(inputTokens, outputTokens);
|
|
274
|
+
const inputTokens = tokenCount(usage.inputTokens) ?? tokenCount(usage.promptTokens) ?? tokenCount(usage.tokens);
|
|
275
|
+
const outputTokens = tokenCount(usage.outputTokens) ?? tokenCount(usage.completionTokens);
|
|
276
|
+
const totalTokens = tokenCount(usage.totalTokens) ?? util.sum(inputTokens, outputTokens);
|
|
187
277
|
if (inputTokens !== void 0) {
|
|
188
278
|
span.setAttribute(attributes.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
|
|
189
279
|
}
|
|
@@ -196,14 +286,14 @@ function enrichSpanOnEnd(span, data, channelOptions) {
|
|
|
196
286
|
}
|
|
197
287
|
const finishReason = getFinishReason(result);
|
|
198
288
|
if (finishReason && type === "languageModelCall") {
|
|
199
|
-
span.setAttribute(attributes.GEN_AI_RESPONSE_FINISH_REASONS, safeStringify([finishReason]));
|
|
289
|
+
span.setAttribute(attributes.GEN_AI_RESPONSE_FINISH_REASONS, util.safeStringify([finishReason]));
|
|
200
290
|
}
|
|
201
|
-
const response =
|
|
202
|
-
const responseId = asString(response?.id) ?? asString(result.responseId);
|
|
291
|
+
const response = core.isObjectLike(result.response) ? result.response : void 0;
|
|
292
|
+
const responseId = util.asString(response?.id) ?? util.asString(result.responseId);
|
|
203
293
|
if (responseId) {
|
|
204
294
|
span.setAttribute(attributes.GEN_AI_RESPONSE_ID, responseId);
|
|
205
295
|
}
|
|
206
|
-
const responseModel = asString(response?.modelId) ?? asString(data.event.modelId);
|
|
296
|
+
const responseModel = util.asString(response?.modelId) ?? util.asString(data.event.modelId);
|
|
207
297
|
if (responseModel) {
|
|
208
298
|
span.setAttribute(attributes.GEN_AI_RESPONSE_MODEL, responseModel);
|
|
209
299
|
}
|
|
@@ -229,30 +319,30 @@ function getFinishReason(result) {
|
|
|
229
319
|
if (typeof finishReason === "string") {
|
|
230
320
|
return finishReason;
|
|
231
321
|
}
|
|
232
|
-
return
|
|
322
|
+
return core.isObjectLike(finishReason) ? util.asString(finishReason.unified) : void 0;
|
|
233
323
|
}
|
|
234
324
|
function tokenCount(value) {
|
|
235
|
-
return asNumber(value) ?? (
|
|
325
|
+
return util.asNumber(value) ?? (core.isObjectLike(value) ? util.asNumber(value.total) : void 0);
|
|
236
326
|
}
|
|
237
327
|
function buildOutputMessages(parts, finishReason) {
|
|
238
328
|
if (!parts.length) {
|
|
239
329
|
return void 0;
|
|
240
330
|
}
|
|
241
|
-
return safeStringify([{ role: "assistant", parts, finish_reason: normalizeFinishReason(finishReason) }]);
|
|
331
|
+
return util.safeStringify([{ role: "assistant", parts, finish_reason: normalizeFinishReason(finishReason) }]);
|
|
242
332
|
}
|
|
243
333
|
function toolCallPart(toolCall) {
|
|
244
334
|
const args = toolCall.input ?? toolCall.args;
|
|
245
335
|
return {
|
|
246
336
|
type: "tool_call",
|
|
247
|
-
id: asString(toolCall.toolCallId),
|
|
248
|
-
name: asString(toolCall.toolName),
|
|
249
|
-
arguments: typeof args === "string" ? args : safeStringify(args ?? {})
|
|
337
|
+
id: util.asString(toolCall.toolCallId),
|
|
338
|
+
name: util.asString(toolCall.toolName),
|
|
339
|
+
arguments: typeof args === "string" ? args : util.safeStringify(args ?? {})
|
|
250
340
|
};
|
|
251
341
|
}
|
|
252
342
|
function partsFromContent(content) {
|
|
253
343
|
const parts = [];
|
|
254
344
|
for (const item of content) {
|
|
255
|
-
if (!
|
|
345
|
+
if (!core.isObjectLike(item)) {
|
|
256
346
|
continue;
|
|
257
347
|
}
|
|
258
348
|
if (item.type === "text" && typeof item.text === "string") {
|
|
@@ -270,7 +360,7 @@ function partsFromTextAndToolCalls(text, toolCalls) {
|
|
|
270
360
|
}
|
|
271
361
|
if (Array.isArray(toolCalls)) {
|
|
272
362
|
for (const toolCall of toolCalls) {
|
|
273
|
-
if (
|
|
363
|
+
if (core.isObjectLike(toolCall)) {
|
|
274
364
|
parts.push(toolCallPart(toolCall));
|
|
275
365
|
}
|
|
276
366
|
}
|
|
@@ -282,9 +372,9 @@ function captureToolError(span, data, error) {
|
|
|
282
372
|
code: core.SPAN_STATUS_ERROR,
|
|
283
373
|
message: error instanceof Error ? error.message : "tool_error"
|
|
284
374
|
});
|
|
285
|
-
const toolCall =
|
|
286
|
-
const toolName = asString(toolCall.toolName);
|
|
287
|
-
const toolCallId = asString(data.event.toolCallId) ?? asString(toolCall.toolCallId);
|
|
375
|
+
const toolCall = core.isObjectLike(data.event.toolCall) ? data.event.toolCall : {};
|
|
376
|
+
const toolName = util.asString(toolCall.toolName);
|
|
377
|
+
const toolCallId = util.asString(data.event.toolCallId) ?? util.asString(toolCall.toolCallId);
|
|
288
378
|
core.withScope((scope) => {
|
|
289
379
|
scope.setContext("trace", core.spanToTraceContext(span));
|
|
290
380
|
if (toolName) {
|
|
@@ -321,42 +411,23 @@ function resolveRecording(integrationOption, perCallOption, globalDefault) {
|
|
|
321
411
|
}
|
|
322
412
|
function buildInputMessageAttributes(event, enableTruncation) {
|
|
323
413
|
const attributes$1 = {};
|
|
324
|
-
const instructions = asString(event.instructions);
|
|
414
|
+
const instructions = util.asString(event.instructions);
|
|
325
415
|
if (instructions) {
|
|
326
|
-
attributes$1[core.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE] = safeStringify([{ type: "text", content: instructions }]);
|
|
416
|
+
attributes$1[core.GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE] = util.safeStringify([{ type: "text", content: instructions }]);
|
|
327
417
|
}
|
|
328
418
|
const messages = event.messages ?? event.prompt;
|
|
329
419
|
if (messages !== void 0) {
|
|
330
|
-
attributes$1[attributes.GEN_AI_INPUT_MESSAGES] = enableTruncation ? core.getTruncatedJsonString(messages) : safeStringify(messages);
|
|
420
|
+
attributes$1[attributes.GEN_AI_INPUT_MESSAGES] = enableTruncation ? core.getTruncatedJsonString(messages) : util.safeStringify(messages);
|
|
331
421
|
attributes$1[core.GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE] = Array.isArray(messages) ? messages.length : 1;
|
|
332
422
|
}
|
|
333
423
|
return attributes$1;
|
|
334
424
|
}
|
|
335
|
-
function asString(value) {
|
|
336
|
-
return typeof value === "string" ? value : void 0;
|
|
337
|
-
}
|
|
338
|
-
function asNumber(value) {
|
|
339
|
-
return typeof value === "number" && !isNaN(value) ? value : void 0;
|
|
340
|
-
}
|
|
341
|
-
function sum(a, b) {
|
|
342
|
-
return a === void 0 && b === void 0 ? void 0 : (a ?? 0) + (b ?? 0);
|
|
343
|
-
}
|
|
344
|
-
function isRecord(value) {
|
|
345
|
-
return typeof value === "object" && value !== null;
|
|
346
|
-
}
|
|
347
|
-
function safeStringify(value) {
|
|
348
|
-
if (typeof value === "string") {
|
|
349
|
-
return value;
|
|
350
|
-
}
|
|
351
|
-
try {
|
|
352
|
-
return JSON.stringify(value);
|
|
353
|
-
} catch {
|
|
354
|
-
return "[unserializable]";
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
425
|
|
|
426
|
+
exports.captureToolError = captureToolError;
|
|
427
|
+
exports.clearOperationCallId = clearOperationCallId;
|
|
358
428
|
exports.clearOperationId = clearOperationId;
|
|
359
429
|
exports.createSpanFromMessage = createSpanFromMessage;
|
|
360
430
|
exports.enrichSpanOnEnd = enrichSpanOnEnd;
|
|
431
|
+
exports.streamedResultToChannelResult = streamedResultToChannelResult;
|
|
361
432
|
exports.subscribeVercelAiTracingChannel = subscribeVercelAiTracingChannel;
|
|
362
433
|
//# sourceMappingURL=vercel-ai-dc-subscriber.js.map
|