weflayr 0.24.0 → 0.26.1

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.
Files changed (235) hide show
  1. package/README.md +2 -2
  2. package/dist/package.json +51 -0
  3. package/dist/{api → src/api}/generated/facade.gen.d.ts +86 -12
  4. package/dist/{api → src/api}/generated/facade.gen.js +4 -2
  5. package/dist/src/api/generated/index.d.ts +2 -0
  6. package/dist/{api → src/api}/generated/index.js +3 -1
  7. package/dist/{api → src/api}/generated/sdk.gen.d.ts +11 -3
  8. package/dist/{api → src/api}/generated/sdk.gen.js +34 -4
  9. package/{src/api/generated/types.gen.ts → dist/src/api/generated/types.gen.d.ts} +436 -153
  10. package/dist/{api → src/api}/makeEndpoint.js +1 -3
  11. package/dist/src/auto-instrument.d.ts +42 -0
  12. package/dist/src/auto-instrument.js +156 -0
  13. package/dist/src/index.d.ts +9 -0
  14. package/dist/src/index.js +49 -0
  15. package/dist/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.d.ts +20 -0
  16. package/dist/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.js +114 -0
  17. package/dist/src/instrumentation/anthropic/get_cache_config_telemetry.d.ts +28 -0
  18. package/dist/src/instrumentation/anthropic/get_cache_config_telemetry.js +92 -0
  19. package/dist/src/instrumentation/anthropic/get_streaming_accumulation_telemetry.d.ts +25 -0
  20. package/dist/src/instrumentation/anthropic/get_streaming_accumulation_telemetry.js +141 -0
  21. package/dist/src/instrumentation/anthropic/get_structured_output_schema_telemetry.d.ts +9 -0
  22. package/dist/src/instrumentation/anthropic/get_structured_output_schema_telemetry.js +17 -0
  23. package/dist/src/instrumentation/anthropic/get_tool_definitions_telemetry.d.ts +15 -0
  24. package/dist/src/instrumentation/anthropic/get_tool_definitions_telemetry.js +50 -0
  25. package/dist/src/instrumentation/anthropic/set_telemetry_attributes.d.ts +15 -0
  26. package/dist/src/instrumentation/anthropic/set_telemetry_attributes.js +39 -0
  27. package/dist/src/instrumentation/bedrock/get_cache_config_telemetry.d.ts +22 -0
  28. package/dist/src/instrumentation/bedrock/get_cache_config_telemetry.js +97 -0
  29. package/dist/src/instrumentation/bedrock/get_cache_telemetry.d.ts +22 -0
  30. package/dist/src/instrumentation/bedrock/get_cache_telemetry.js +102 -0
  31. package/dist/src/instrumentation/bedrock/get_input_message_content_telemetry.d.ts +15 -0
  32. package/dist/src/instrumentation/bedrock/get_input_message_content_telemetry.js +91 -0
  33. package/dist/src/instrumentation/bedrock/get_model_id_telemetry.d.ts +21 -0
  34. package/dist/src/instrumentation/bedrock/get_model_id_telemetry.js +54 -0
  35. package/dist/src/instrumentation/bedrock/get_reasoning_output_telemetry.d.ts +19 -0
  36. package/dist/src/instrumentation/bedrock/get_reasoning_output_telemetry.js +81 -0
  37. package/dist/src/instrumentation/bedrock/get_streaming_output_message_telemetry.d.ts +27 -0
  38. package/dist/src/instrumentation/bedrock/get_streaming_output_message_telemetry.js +126 -0
  39. package/dist/src/instrumentation/bedrock/get_tool_call_output_telemetry.d.ts +17 -0
  40. package/dist/src/instrumentation/bedrock/get_tool_call_output_telemetry.js +85 -0
  41. package/dist/src/instrumentation/bedrock/get_tool_definitions_telemetry.d.ts +15 -0
  42. package/dist/src/instrumentation/bedrock/get_tool_definitions_telemetry.js +68 -0
  43. package/dist/src/instrumentation/bedrock/set_telemetry_attributes.d.ts +18 -0
  44. package/dist/src/instrumentation/bedrock/set_telemetry_attributes.js +47 -0
  45. package/dist/src/instrumentation/cohere/get_chat_telemetry.d.ts +23 -0
  46. package/dist/src/instrumentation/cohere/get_chat_telemetry.js +77 -0
  47. package/dist/src/instrumentation/cohere/get_embeddings_telemetry.d.ts +18 -0
  48. package/dist/src/instrumentation/cohere/get_embeddings_telemetry.js +88 -0
  49. package/dist/src/instrumentation/cohere/get_structured_output_schema_telemetry.d.ts +12 -0
  50. package/dist/src/instrumentation/cohere/get_structured_output_schema_telemetry.js +18 -0
  51. package/dist/src/instrumentation/cohere/get_tool_call_output_telemetry.d.ts +31 -0
  52. package/dist/src/instrumentation/cohere/get_tool_call_output_telemetry.js +106 -0
  53. package/dist/src/instrumentation/cohere/get_tool_definitions_telemetry.d.ts +27 -0
  54. package/dist/src/instrumentation/cohere/get_tool_definitions_telemetry.js +75 -0
  55. package/dist/src/instrumentation/cohere/set_telemetry_attributes.d.ts +17 -0
  56. package/dist/src/instrumentation/cohere/set_telemetry_attributes.js +44 -0
  57. package/dist/src/instrumentation/elevenlabs/full_instrumentation.d.ts +28 -0
  58. package/dist/src/instrumentation/elevenlabs/full_instrumentation.js +209 -0
  59. package/dist/src/instrumentation/google/get_audio_telemetry.d.ts +9 -0
  60. package/dist/src/instrumentation/google/get_audio_telemetry.js +28 -0
  61. package/dist/src/instrumentation/google/get_cache_operations_telemetry.d.ts +23 -0
  62. package/dist/src/instrumentation/google/get_cache_operations_telemetry.js +154 -0
  63. package/dist/src/instrumentation/google/get_cache_telemetry.d.ts +16 -0
  64. package/{src → dist/src}/instrumentation/google/get_cache_telemetry.js +18 -19
  65. package/dist/src/instrumentation/google/get_embeddings_telemetry.d.ts +12 -0
  66. package/dist/src/instrumentation/google/get_embeddings_telemetry.js +85 -0
  67. package/dist/src/instrumentation/google/get_provider_name.d.ts +11 -0
  68. package/{src → dist/src}/instrumentation/google/get_provider_name.js +11 -12
  69. package/{src/instrumentation/google/get_reasoning_telemetry.js → dist/src/instrumentation/google/get_reasoning_telemetry.d.ts} +1 -11
  70. package/dist/src/instrumentation/google/get_reasoning_telemetry.js +21 -0
  71. package/dist/src/instrumentation/google/get_structured_output_schema_telemetry.d.ts +12 -0
  72. package/dist/src/instrumentation/google/get_structured_output_schema_telemetry.js +19 -0
  73. package/dist/src/instrumentation/google/set_telemetry_attributes.d.ts +18 -0
  74. package/dist/src/instrumentation/google/set_telemetry_attributes.js +98 -0
  75. package/dist/src/instrumentation/openai/get_audio_telemetry.d.ts +25 -0
  76. package/dist/src/instrumentation/openai/get_audio_telemetry.js +123 -0
  77. package/dist/src/instrumentation/openai/get_bedrock_mantle_telemetry.d.ts +35 -0
  78. package/dist/src/instrumentation/openai/get_bedrock_mantle_telemetry.js +148 -0
  79. package/dist/src/instrumentation/openai/get_cache_and_reasoning_telemetry.d.ts +27 -0
  80. package/dist/src/instrumentation/openai/get_cache_and_reasoning_telemetry.js +72 -0
  81. package/dist/src/instrumentation/openai/get_cache_config_telemetry.d.ts +28 -0
  82. package/dist/src/instrumentation/openai/get_cache_config_telemetry.js +91 -0
  83. package/dist/src/instrumentation/openai/get_embeddings_telemetry.d.ts +18 -0
  84. package/dist/src/instrumentation/openai/get_embeddings_telemetry.js +86 -0
  85. package/dist/src/instrumentation/openai/get_streaming_usage.d.ts +21 -0
  86. package/dist/src/instrumentation/openai/get_streaming_usage.js +74 -0
  87. package/dist/src/instrumentation/openai/get_structured_output_schema_telemetry.d.ts +12 -0
  88. package/dist/src/instrumentation/openai/get_structured_output_schema_telemetry.js +20 -0
  89. package/dist/src/instrumentation/openai/set_telemetry_attributes.d.ts +17 -0
  90. package/dist/src/instrumentation/openai/set_telemetry_attributes.js +47 -0
  91. package/dist/src/instrumentation/shared/get_structured_output_schema_telemetry.d.ts +35 -0
  92. package/dist/src/instrumentation/shared/get_structured_output_schema_telemetry.js +76 -0
  93. package/dist/src/instrumentation/vercel/full_instrumentation.d.ts +3 -0
  94. package/dist/src/instrumentation/vercel/full_instrumentation.js +54 -0
  95. package/dist/src/instrumentation/vercel/get_cache_creation_telemetry.d.ts +22 -0
  96. package/dist/src/instrumentation/vercel/get_cache_creation_telemetry.js +66 -0
  97. package/dist/src/instrumentation/vercel/get_structured_output_schema_telemetry.d.ts +24 -0
  98. package/dist/src/instrumentation/vercel/get_structured_output_schema_telemetry.js +84 -0
  99. package/dist/src/logger.d.ts +1 -0
  100. package/dist/src/logger.js +6 -0
  101. package/dist/src/otel/exporter.d.ts +19 -0
  102. package/dist/src/otel/exporter.js +94 -0
  103. package/dist/src/otel/propagation.d.ts +46 -0
  104. package/dist/src/otel/propagation.js +110 -0
  105. package/dist/src/otel/span-filter.d.ts +3 -0
  106. package/dist/src/otel/span-filter.js +61 -0
  107. package/dist/src/otel/span-processor.d.ts +55 -0
  108. package/dist/src/otel/span-processor.js +169 -0
  109. package/dist/src/otel/vercel-ai-sdk-span-filter.d.ts +12 -0
  110. package/dist/src/otel/vercel-ai-sdk-span-filter.js +88 -0
  111. package/dist/src/setup.d.ts +50 -0
  112. package/dist/src/setup.js +155 -0
  113. package/package.json +12 -5
  114. package/.prettierignore +0 -2
  115. package/.prettierrc.json +0 -7
  116. package/LICENSE-MIT +0 -21
  117. package/NOTICE +0 -12
  118. package/dist/api/generated/index.d.ts +0 -2
  119. package/dist/api/generated/types.gen.d.ts +0 -1005
  120. package/eslint.config.mjs +0 -36
  121. package/index.d.ts +0 -170
  122. package/openapi-ts.config.mjs +0 -9
  123. package/scripts/generate_facade.mjs +0 -86
  124. package/src/api/caseConversion.ts +0 -58
  125. package/src/api/generated/client/client.gen.ts +0 -277
  126. package/src/api/generated/client/index.ts +0 -27
  127. package/src/api/generated/client/types.gen.ts +0 -218
  128. package/src/api/generated/client/utils.gen.ts +0 -316
  129. package/src/api/generated/client.gen.ts +0 -16
  130. package/src/api/generated/core/auth.gen.ts +0 -48
  131. package/src/api/generated/core/bodySerializer.gen.ts +0 -82
  132. package/src/api/generated/core/params.gen.ts +0 -178
  133. package/src/api/generated/core/pathSerializer.gen.ts +0 -171
  134. package/src/api/generated/core/queryKeySerializer.gen.ts +0 -117
  135. package/src/api/generated/core/serverSentEvents.gen.ts +0 -242
  136. package/src/api/generated/core/types.gen.ts +0 -110
  137. package/src/api/generated/core/utils.gen.ts +0 -140
  138. package/src/api/generated/facade.gen.ts +0 -104
  139. package/src/api/generated/index.ts +0 -4
  140. package/src/api/generated/sdk.gen.ts +0 -175
  141. package/src/api/index.ts +0 -45
  142. package/src/api/makeEndpoint.ts +0 -54
  143. package/src/auto-instrument.js +0 -172
  144. package/src/index.js +0 -19
  145. package/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.js +0 -118
  146. package/src/instrumentation/anthropic/get_cache_config_telemetry.js +0 -90
  147. package/src/instrumentation/anthropic/get_streaming_stop_reason_telemetry.js +0 -121
  148. package/src/instrumentation/anthropic/get_tool_definitions_telemetry.js +0 -55
  149. package/src/instrumentation/anthropic/set_telemetry_attributes.js +0 -39
  150. package/src/instrumentation/bedrock/get_cache_config_telemetry.js +0 -106
  151. package/src/instrumentation/bedrock/get_cache_telemetry.js +0 -109
  152. package/src/instrumentation/bedrock/get_input_message_content_telemetry.js +0 -94
  153. package/src/instrumentation/bedrock/get_streaming_output_message_telemetry.js +0 -87
  154. package/src/instrumentation/bedrock/set_telemetry_attributes.js +0 -40
  155. package/src/instrumentation/cohere/get_chat_telemetry.js +0 -88
  156. package/src/instrumentation/cohere/get_embeddings_telemetry.js +0 -107
  157. package/src/instrumentation/cohere/set_telemetry_attributes.js +0 -32
  158. package/src/instrumentation/elevenlabs/full_instrumentation.js +0 -236
  159. package/src/instrumentation/google/get_audio_telemetry.js +0 -30
  160. package/src/instrumentation/google/get_cache_operations_telemetry.js +0 -171
  161. package/src/instrumentation/google/get_embeddings_telemetry.js +0 -99
  162. package/src/instrumentation/google/set_telemetry_attributes.js +0 -104
  163. package/src/instrumentation/openai/get_audio_telemetry.js +0 -149
  164. package/src/instrumentation/openai/get_cache_and_reasoning_telemetry.js +0 -71
  165. package/src/instrumentation/openai/get_cache_config_telemetry.js +0 -63
  166. package/src/instrumentation/openai/get_embeddings_telemetry.js +0 -107
  167. package/src/instrumentation/openai/get_streaming_usage.js +0 -81
  168. package/src/instrumentation/openai/set_telemetry_attributes.js +0 -41
  169. package/src/instrumentation/vercel/full_instrumentation.js +0 -52
  170. package/src/instrumentation/vercel/get_cache_creation_telemetry.js +0 -70
  171. package/src/logger.js +0 -8
  172. package/src/otel/exporter.js +0 -108
  173. package/src/otel/propagation.js +0 -146
  174. package/src/otel/span-filter.js +0 -69
  175. package/src/otel/span-processor.js +0 -170
  176. package/src/otel/vercel-ai-sdk-span-filter.js +0 -79
  177. package/src/setup.js +0 -167
  178. package/tests/api/index.test.js +0 -437
  179. package/tests/index.test.js +0 -884
  180. package/tests/instrumentation/anthropic/get_cache_and_reasoning_telemetry.test.js +0 -181
  181. package/tests/instrumentation/anthropic/get_cache_config_telemetry.test.js +0 -92
  182. package/tests/instrumentation/anthropic/get_streaming_stop_reason_telemetry.test.js +0 -117
  183. package/tests/instrumentation/anthropic/get_tool_definitions_telemetry.test.js +0 -97
  184. package/tests/instrumentation/bedrock/get_cache_config_telemetry.test.js +0 -107
  185. package/tests/instrumentation/bedrock/get_cache_telemetry.test.js +0 -118
  186. package/tests/instrumentation/bedrock/get_input_message_content_telemetry.test.js +0 -89
  187. package/tests/instrumentation/bedrock/get_streaming_output_message_telemetry.test.js +0 -87
  188. package/tests/instrumentation/cohere/get_chat_telemetry.test.js +0 -148
  189. package/tests/instrumentation/cohere/get_embeddings_telemetry.test.js +0 -132
  190. package/tests/instrumentation/elevenlabs/full_instrumentation.test.js +0 -258
  191. package/tests/instrumentation/google/get_cache_operations_telemetry.test.js +0 -130
  192. package/tests/instrumentation/google/get_embeddings_telemetry.test.js +0 -128
  193. package/tests/instrumentation/google/get_reasoning_telemetry.test.js +0 -41
  194. package/tests/instrumentation/google/set_telemetry_attributes.test.js +0 -219
  195. package/tests/instrumentation/openai/get_audio_telemetry.test.js +0 -170
  196. package/tests/instrumentation/openai/get_cache_and_reasoning_telemetry.test.js +0 -83
  197. package/tests/instrumentation/openai/get_cache_config_telemetry.test.js +0 -83
  198. package/tests/instrumentation/openai/get_embeddings_telemetry.test.js +0 -145
  199. package/tests/instrumentation/openai/get_streaming_usage.test.js +0 -105
  200. package/tests/instrumentation/vercel/full_instrumentation.test.js +0 -16
  201. package/tests/instrumentation/vercel/get_cache_creation_telemetry.test.js +0 -96
  202. package/tests/otel/vercel-ai-sdk-span-filter.test.js +0 -159
  203. package/tsconfig.json +0 -18
  204. /package/dist/{api → src/api}/caseConversion.d.ts +0 -0
  205. /package/dist/{api → src/api}/caseConversion.js +0 -0
  206. /package/dist/{api → src/api}/generated/client/client.gen.d.ts +0 -0
  207. /package/dist/{api → src/api}/generated/client/client.gen.js +0 -0
  208. /package/dist/{api → src/api}/generated/client/index.d.ts +0 -0
  209. /package/dist/{api → src/api}/generated/client/index.js +0 -0
  210. /package/dist/{api → src/api}/generated/client/types.gen.d.ts +0 -0
  211. /package/dist/{api → src/api}/generated/client/types.gen.js +0 -0
  212. /package/dist/{api → src/api}/generated/client/utils.gen.d.ts +0 -0
  213. /package/dist/{api → src/api}/generated/client/utils.gen.js +0 -0
  214. /package/dist/{api → src/api}/generated/client.gen.d.ts +0 -0
  215. /package/dist/{api → src/api}/generated/client.gen.js +0 -0
  216. /package/dist/{api → src/api}/generated/core/auth.gen.d.ts +0 -0
  217. /package/dist/{api → src/api}/generated/core/auth.gen.js +0 -0
  218. /package/dist/{api → src/api}/generated/core/bodySerializer.gen.d.ts +0 -0
  219. /package/dist/{api → src/api}/generated/core/bodySerializer.gen.js +0 -0
  220. /package/dist/{api → src/api}/generated/core/params.gen.d.ts +0 -0
  221. /package/dist/{api → src/api}/generated/core/params.gen.js +0 -0
  222. /package/dist/{api → src/api}/generated/core/pathSerializer.gen.d.ts +0 -0
  223. /package/dist/{api → src/api}/generated/core/pathSerializer.gen.js +0 -0
  224. /package/dist/{api → src/api}/generated/core/queryKeySerializer.gen.d.ts +0 -0
  225. /package/dist/{api → src/api}/generated/core/queryKeySerializer.gen.js +0 -0
  226. /package/dist/{api → src/api}/generated/core/serverSentEvents.gen.d.ts +0 -0
  227. /package/dist/{api → src/api}/generated/core/serverSentEvents.gen.js +0 -0
  228. /package/dist/{api → src/api}/generated/core/types.gen.d.ts +0 -0
  229. /package/dist/{api → src/api}/generated/core/types.gen.js +0 -0
  230. /package/dist/{api → src/api}/generated/core/utils.gen.d.ts +0 -0
  231. /package/dist/{api → src/api}/generated/core/utils.gen.js +0 -0
  232. /package/dist/{api → src/api}/generated/types.gen.js +0 -0
  233. /package/dist/{api → src/api}/index.d.ts +0 -0
  234. /package/dist/{api → src/api}/index.js +0 -0
  235. /package/dist/{api → src/api}/makeEndpoint.d.ts +0 -0
package/eslint.config.mjs DELETED
@@ -1,36 +0,0 @@
1
- export default [
2
- {
3
- languageOptions: {
4
- ecmaVersion: 2023,
5
- sourceType: "commonjs",
6
- globals: {
7
- // Node.js
8
- require: "readonly",
9
- module: "readonly",
10
- exports: "writable",
11
- __dirname: "readonly",
12
- __filename: "readonly",
13
- process: "readonly",
14
- Buffer: "readonly",
15
- console: "readonly",
16
- setTimeout: "readonly",
17
- clearTimeout: "readonly",
18
- setInterval: "readonly",
19
- clearInterval: "readonly",
20
- // Web platform (available in modern Node)
21
- fetch: "readonly",
22
- URL: "readonly",
23
- ReadableStream: "readonly",
24
- TransformStream: "readonly",
25
- TextEncoder: "readonly",
26
- TextDecoder: "readonly",
27
- },
28
- },
29
- rules: {
30
- "no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
31
- "no-undef": "error",
32
- "prefer-const": "warn",
33
- eqeqeq: ["error", "smart"],
34
- },
35
- },
36
- ];
package/index.d.ts DELETED
@@ -1,170 +0,0 @@
1
- /** Arbitrary key-value tags applied to OTel spans. */
2
- export type Tags = Record<string, string | number | boolean>;
3
-
4
- /**
5
- * Span attributes the mask callback can read or scrub. The OpenTelemetry GenAI
6
- * semantic-convention keys get autocomplete; the index signature catches user
7
- * tags and provider-specific attributes (e.g. Vercel AI's `ai.*`).
8
- */
9
- export interface OtelSpanAttributes {
10
- 'gen_ai.system'?: string;
11
- 'gen_ai.operation.name'?: string;
12
- 'gen_ai.request.model'?: string;
13
- 'gen_ai.request.temperature'?: number;
14
- 'gen_ai.request.max_tokens'?: number;
15
- 'gen_ai.response.model'?: string;
16
- 'gen_ai.response.id'?: string;
17
- 'gen_ai.response.finish_reasons'?: string[];
18
- 'gen_ai.usage.input_tokens'?: number;
19
- 'gen_ai.usage.output_tokens'?: number;
20
- /** Only populated when `captureMessageContent=true`. */
21
- 'gen_ai.prompt'?: string;
22
- /** Only populated when `captureMessageContent=true`. */
23
- 'gen_ai.completion'?: string;
24
- 'gen_ai.tool.name'?: string;
25
- 'gen_ai.tool.call.id'?: string;
26
- 'gen_ai.tool.call.arguments'?: string;
27
- 'error.type'?: string;
28
- [key: string]: unknown;
29
- }
30
-
31
- /** LLM provider SDKs the `autoInstrument` registry knows how to wire up. */
32
- export const AiSdk: {
33
- readonly OPENAI: 'openai';
34
- readonly ANTHROPIC: 'anthropic';
35
- readonly BEDROCK: 'bedrock';
36
- readonly COHERE: 'cohere';
37
- readonly GOOGLE_GENAI: 'google-genai';
38
- readonly ELEVENLABS: 'elevenlabs';
39
- readonly VERCEL_AI_GATEWAY: 'vercel_ai_gateway';
40
- };
41
- export type AiSdk = (typeof AiSdk)[keyof typeof AiSdk];
42
-
43
- /**
44
- * Allowed values for `propagateMetadata({ providerNameOverride })`: the actual
45
- * AI providers a call can be attributed to. Unlike AiSdk this names providers,
46
- * not SDKs — google-genai is an SDK whose calls are labelled gemini or vertex,
47
- * and mistral is reached via the OpenAI SDK on the wire but reported as itself.
48
- */
49
- export const AIProviderName: {
50
- readonly OPENAI: 'openai';
51
- readonly AZURE_OPENAI: 'azure';
52
- readonly ANTHROPIC: 'anthropic';
53
- readonly BEDROCK: 'bedrock';
54
- readonly COHERE: 'cohere';
55
- readonly ELEVENLABS: 'elevenlabs';
56
- readonly MISTRAL: 'mistral';
57
- readonly VERCEL_AI_GATEWAY: 'vercel_ai_gateway';
58
- readonly GEMINI: 'gemini';
59
- readonly VERTEX: 'vertex';
60
- };
61
- export type AIProviderName = (typeof AIProviderName)[keyof typeof AIProviderName];
62
-
63
- export interface SetupOptions {
64
- /** Weflayr API key. The server resolves your project_uuid from this token. */
65
- apiKey: string;
66
- /** Override the intake base URL. Defaults to WEFLAYR_BASE_URL or https://api.weflayr.com. */
67
- baseUrl?: string;
68
- /** Tags applied to every emitted span. */
69
- defaultTags?: Tags;
70
- /**
71
- * `'batch'` (default) groups spans for throughput. `'immediate'` flushes every
72
- * span synchronously — recommended for short-lived runtimes (Lambda, edge).
73
- */
74
- exportMode?: 'batch' | 'immediate';
75
- /**
76
- * When `false`, sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=false
77
- * so instrumentations strip `gen_ai.prompt` / `gen_ai.completion` from spans
78
- * before they're emitted. Defaults to `true`.
79
- */
80
- captureMessageContent?: boolean;
81
- /**
82
- * Last-line-of-defense scrubber. Receives the span attribute bag just before
83
- * export; return the (optionally mutated) bag.
84
- */
85
- mask?: (attrs: OtelSpanAttributes) => OtelSpanAttributes;
86
- }
87
-
88
- /** Initializes the OpenTelemetry tracer + exporter. Call once at app start. */
89
- export function setup(options: SetupOptions): void;
90
-
91
- /**
92
- * Loads and registers OpenTelemetry instrumentation packages for the given provider SDKs.
93
- * Throws a clear "install package X" error if the matching package isn't installed.
94
- *
95
- * @example
96
- * await weflayr.autoInstrument({ aiSdks: weflayr.AiSdk.OPENAI, apiKey: '...' });
97
- * await weflayr.autoInstrument({ aiSdks: [weflayr.AiSdk.OPENAI, weflayr.AiSdk.ANTHROPIC] });
98
- */
99
- export function autoInstrument(
100
- options: { aiSdks: AiSdk | AiSdk[] } & Partial<SetupOptions>
101
- ): Promise<void>;
102
-
103
- export interface PropagateMetadataOptions {
104
- /** Product-side feature triggering the LLM call (e.g. `"onboarding-summary"`). */
105
- featureName: string;
106
- /** Name of the end-user / tenant customer the call is made for. */
107
- customerName?: string;
108
- /** @deprecated Use `customerName` instead. */
109
- customerId?: string;
110
- /**
111
- * Override for the provider seen on the wire. Set this only if it differs
112
- * from the SDK auto-detected by OpenTelemetry — e.g. calls routed through
113
- * `vercel_ai_gateway` that proxies to OpenAI/Anthropic but should be
114
- * reported as the gateway.
115
- */
116
- providerNameOverride?: AIProviderName;
117
- /** @deprecated Use `providerNameOverride` instead. */
118
- providerName?: AIProviderName;
119
- /**
120
- * Arbitrary scalar key/value pairs to attach. Values must be `string`,
121
- * `number`, or `boolean` so they survive the ClickHouse `Map(String,
122
- * String)` column they land in. Avoid `featureName` / `customerName` keys
123
- * here — they have dedicated fields.
124
- */
125
- extraTags?: Record<string, string | number | boolean>;
126
- }
127
-
128
- /**
129
- * Attach Weflayr metadata to every LLM span created inside `fn`.
130
- *
131
- * Every invocation mints a fresh `uuid` that is stamped on every span inside
132
- * the scope, so all calls made under one `propagateMetadata` block can be
133
- * correlated downstream.
134
- *
135
- * @example
136
- * await weflayr.propagateMetadata(
137
- * { featureName: 'onboarding', customerName: 'Acme Corp', extraTags: { variant: 'control' } },
138
- * async () => { await openai.chat.completions.create({ ... }); },
139
- * );
140
- */
141
- export function propagateMetadata<T>(
142
- options: PropagateMetadataOptions,
143
- fn: () => Promise<T> | T
144
- ): Promise<T> | T;
145
-
146
- /**
147
- * Decorator form. Apply to a class method to propagate metadata around every call.
148
- * Each invocation of the wrapped function mints its own `uuid`.
149
- *
150
- * @example
151
- * class ChatService {
152
- * @weflayr.propagateMetadata({ featureName: 'chat', customerName: 'Acme Corp' })
153
- * async reply(userId: string) { ... }
154
- * }
155
- */
156
- export function propagateMetadata(
157
- options: PropagateMetadataOptions
158
- ): <T>(target: T, key?: string, descriptor?: PropertyDescriptor) => T;
159
-
160
- /** Flush any pending spans. Await before a short-lived runtime exits. */
161
- export function flush(): Promise<void>;
162
-
163
- /**
164
- * Endpoint functions for the Weflayr public API (revenue, key metrics, customer
165
- * tags), generated from the platform's OpenAPI spec.
166
- */
167
- export * as api from './dist/api';
168
-
169
- /** A client for the public API, authenticated with a project API key. */
170
- export { client, type ApiClientOptions } from './dist/api';
@@ -1,9 +0,0 @@
1
- import { defineConfig } from '@hey-api/openapi-ts';
2
-
3
- // Regenerated by `make generate-sdk-api-clients`; src/api/generated/ is wiped
4
- // on every run, the handwritten facade lives in src/api/index.ts.
5
- export default defineConfig({
6
- input: '../observability_dashboard/app_api/openapi.json',
7
- output: 'src/api/generated',
8
- plugins: ['@hey-api/client-fetch'],
9
- });
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- // Generates src/api/generated/facade.gen.ts: one camelCase-facing wrapper
5
- // per public-API endpoint exported from src/api/generated/sdk.gen.ts.
6
- //
7
- // Run via `npm run generate-api`, right after `openapi-ts` regenerates
8
- // src/api/generated/ (which wipes the directory first, so this always
9
- // starts from a clean slate). Do not edit facade.gen.ts by hand - it is
10
- // overwritten on every run.
11
- //
12
- // @hey-api/openapi-ts names an operation's request/response types after its
13
- // PascalCase operation name (e.g. operation `getRevenue` gets types
14
- // `GetRevenueData`, `GetRevenueResponse`, `GetRevenueError`), so the
15
- // only thing this script needs from the generated source is the list of
16
- // operation names - the type names, and the per-endpoint camelCase/snake_case
17
- // conversion, follow mechanically from there.
18
-
19
- import { readFileSync, writeFileSync } from 'node:fs';
20
- import path from 'node:path';
21
- import { fileURLToPath } from 'node:url';
22
-
23
- const GENERATED_DIR = path.join(
24
- path.dirname(fileURLToPath(import.meta.url)),
25
- '..',
26
- 'src',
27
- 'api',
28
- 'generated'
29
- );
30
- const SDK_PATH = path.join(GENERATED_DIR, 'sdk.gen.ts');
31
- const TYPES_PATH = path.join(GENERATED_DIR, 'types.gen.ts');
32
- const OUTPUT_PATH = path.join(GENERATED_DIR, 'facade.gen.ts');
33
-
34
- const HEADER = `// Generated by services/sdk_node_js/scripts/generate_facade.mjs from
35
- // sdk.gen.ts. Do not edit by hand.
36
-
37
- import { makeEndpoint } from '../makeEndpoint.js';
38
- import type { CamelCaseDeep } from '../caseConversion.js';
39
- import * as generated from './sdk.gen.js';
40
- import type * as generatedTypes from './types.gen.js';
41
- `;
42
-
43
- function pascalCase(operationName) {
44
- return operationName[0].toUpperCase() + operationName.slice(1);
45
- }
46
-
47
- function collectOperationNames(sdkSource) {
48
- return [...sdkSource.matchAll(/^export const (\w+) = </gm)].map((match) => match[1]);
49
- }
50
-
51
- function collectExportedTypeNames(typesSource) {
52
- return new Set([...typesSource.matchAll(/^export type (\w+)/gm)].map((match) => match[1]));
53
- }
54
-
55
- function main() {
56
- const sdkSource = readFileSync(SDK_PATH, 'utf8');
57
- const typesSource = readFileSync(TYPES_PATH, 'utf8');
58
- const operationNames = collectOperationNames(sdkSource);
59
- const exportedTypeNames = collectExportedTypeNames(typesSource);
60
-
61
- const lines = [HEADER];
62
- for (const operationName of operationNames) {
63
- const pascal = pascalCase(operationName);
64
- for (const suffix of ['Data', 'Response', 'Error']) {
65
- const typeName = `${pascal}${suffix}`;
66
- if (!exportedTypeNames.has(typeName)) {
67
- throw new Error(
68
- `generate_facade.mjs: expected type '${typeName}' for operation '${operationName}' ` +
69
- "not found in types.gen.ts - has @hey-api/openapi-ts's naming convention changed?"
70
- );
71
- }
72
- }
73
- lines.push(
74
- `export const ${operationName} = makeEndpoint<\n` +
75
- ` CamelCaseDeep<Omit<generatedTypes.${pascal}Data, 'url'>>,\n` +
76
- ` CamelCaseDeep<generatedTypes.${pascal}Response>,\n` +
77
- ` CamelCaseDeep<generatedTypes.${pascal}Error>\n` +
78
- `>(generated.${operationName});`
79
- );
80
- }
81
-
82
- writeFileSync(OUTPUT_PATH, lines.join('\n\n') + '\n');
83
- console.log(`Generated ${OUTPUT_PATH} (${operationNames.length} endpoints)`);
84
- }
85
-
86
- main();
@@ -1,58 +0,0 @@
1
- /**
2
- * Converts between the wire's snake_case JSON keys (also the Python SDK's
3
- * native casing) and the camelCase keys this SDK exposes to JS callers.
4
- *
5
- * `tags` (see CustomerTags / CustomerTagsOutput) is a free-form map of
6
- * user-chosen tag names, not a fixed schema - its own field name is renamed
7
- * like any other, but the keys inside it are left untouched in both
8
- * directions, otherwise a tag literally named e.g. "utm_source" would be
9
- * silently mangled into "utmSource" on the way out.
10
- */
11
-
12
- const OPAQUE_KEYS = new Set(['tags']);
13
-
14
- export type CamelCase<S extends string> = S extends `${infer Head}_${infer Tail}`
15
- ? `${Head}${Capitalize<CamelCase<Tail>>}`
16
- : S;
17
-
18
- export type CamelCaseDeep<T> = T extends readonly (infer Item)[]
19
- ? CamelCaseDeep<Item>[]
20
- : T extends object
21
- ? { [Key in keyof T as CamelCase<Key & string>]: CamelCaseDeep<T[Key]> }
22
- : T;
23
-
24
- function isPlainObject(value: unknown): value is Record<string, unknown> {
25
- return typeof value === 'object' && value !== null && !Array.isArray(value);
26
- }
27
-
28
- function snakeToCamel(key: string): string {
29
- return key.replace(/_[a-z0-9]/g, (match) => match[1].toUpperCase());
30
- }
31
-
32
- function camelToSnake(key: string): string {
33
- return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
34
- }
35
-
36
- function convertKeysDeep(value: unknown, convertKey: (key: string) => string): unknown {
37
- if (Array.isArray(value)) {
38
- return value.map((item) => convertKeysDeep(item, convertKey));
39
- }
40
- if (!isPlainObject(value)) {
41
- return value;
42
- }
43
- const converted: Record<string, unknown> = {};
44
- for (const [key, entryValue] of Object.entries(value)) {
45
- converted[convertKey(key)] = OPAQUE_KEYS.has(key)
46
- ? entryValue
47
- : convertKeysDeep(entryValue, convertKey);
48
- }
49
- return converted;
50
- }
51
-
52
- export function toCamelCaseDeep<T>(value: T): CamelCaseDeep<T> {
53
- return convertKeysDeep(value, snakeToCamel) as CamelCaseDeep<T>;
54
- }
55
-
56
- export function toSnakeCaseDeep(value: unknown): unknown {
57
- return convertKeysDeep(value, camelToSnake);
58
- }
@@ -1,277 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import { createSseClient } from '../core/serverSentEvents.gen.js';
4
- import type { HttpMethod } from '../core/types.gen.js';
5
- import { getValidRequestBody } from '../core/utils.gen.js';
6
- import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen.js';
7
- import {
8
- buildUrl,
9
- createConfig,
10
- createInterceptors,
11
- getParseAs,
12
- mergeConfigs,
13
- mergeHeaders,
14
- setAuthParams,
15
- } from './utils.gen.js';
16
-
17
- type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
18
- body?: any;
19
- headers: ReturnType<typeof mergeHeaders>;
20
- };
21
-
22
- export const createClient = (config: Config = {}): Client => {
23
- let _config = mergeConfigs(createConfig(), config);
24
-
25
- const getConfig = (): Config => ({ ..._config });
26
-
27
- const setConfig = (config: Config): Config => {
28
- _config = mergeConfigs(_config, config);
29
- return getConfig();
30
- };
31
-
32
- const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
33
-
34
- const beforeRequest = async <
35
- TData = unknown,
36
- TResponseStyle extends 'data' | 'fields' = 'fields',
37
- ThrowOnError extends boolean = boolean,
38
- Url extends string = string,
39
- >(
40
- options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
41
- ) => {
42
- const opts = {
43
- ..._config,
44
- ...options,
45
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
46
- headers: mergeHeaders(_config.headers, options.headers),
47
- serializedBody: undefined as string | undefined,
48
- };
49
-
50
- if (opts.security) {
51
- await setAuthParams(opts);
52
- }
53
-
54
- if (opts.requestValidator) {
55
- await opts.requestValidator(opts);
56
- }
57
-
58
- if (opts.body !== undefined && opts.bodySerializer) {
59
- opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
60
- }
61
-
62
- // remove Content-Type header if body is empty to avoid sending invalid requests
63
- if (opts.body === undefined || opts.serializedBody === '') {
64
- opts.headers.delete('Content-Type');
65
- }
66
-
67
- const resolvedOpts = opts as typeof opts &
68
- ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
69
- const url = buildUrl(resolvedOpts);
70
-
71
- return { opts: resolvedOpts, url };
72
- };
73
-
74
- const request: Client['request'] = async (options) => {
75
- const throwOnError = options.throwOnError ?? _config.throwOnError;
76
- const responseStyle = options.responseStyle ?? _config.responseStyle;
77
-
78
- let request: Request | undefined;
79
- let response: Response | undefined;
80
-
81
- try {
82
- const { opts, url } = await beforeRequest(options);
83
- const requestInit: ReqInit = {
84
- redirect: 'follow',
85
- ...opts,
86
- body: getValidRequestBody(opts),
87
- };
88
-
89
- request = new Request(url, requestInit);
90
-
91
- for (const fn of interceptors.request.fns) {
92
- if (fn) {
93
- request = await fn(request, opts);
94
- }
95
- }
96
-
97
- // fetch must be assigned here, otherwise it would throw the error:
98
- // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
99
- const _fetch = opts.fetch!;
100
-
101
- response = await _fetch(request);
102
-
103
- for (const fn of interceptors.response.fns) {
104
- if (fn) {
105
- response = await fn(response, request, opts);
106
- }
107
- }
108
-
109
- const result = {
110
- request,
111
- response,
112
- };
113
-
114
- if (response.ok) {
115
- const parseAs =
116
- (opts.parseAs === 'auto'
117
- ? getParseAs(response.headers.get('Content-Type'))
118
- : opts.parseAs) ?? 'json';
119
-
120
- if (response.status === 204 || response.headers.get('Content-Length') === '0') {
121
- let emptyData: any;
122
- switch (parseAs) {
123
- case 'arrayBuffer':
124
- case 'blob':
125
- case 'text':
126
- emptyData = await response[parseAs]();
127
- break;
128
- case 'formData':
129
- emptyData = new FormData();
130
- break;
131
- case 'stream':
132
- emptyData = response.body;
133
- break;
134
- case 'json':
135
- default:
136
- emptyData = {};
137
- break;
138
- }
139
- return opts.responseStyle === 'data'
140
- ? emptyData
141
- : {
142
- data: emptyData,
143
- ...result,
144
- };
145
- }
146
-
147
- let data: any;
148
- switch (parseAs) {
149
- case 'arrayBuffer':
150
- case 'blob':
151
- case 'formData':
152
- case 'text':
153
- data = await response[parseAs]();
154
- break;
155
- case 'json': {
156
- // Some servers return 200 with no Content-Length and empty body.
157
- // response.json() would throw; read as text and parse if non-empty.
158
- const text = await response.text();
159
- data = text ? JSON.parse(text) : {};
160
- break;
161
- }
162
- case 'stream':
163
- return opts.responseStyle === 'data'
164
- ? response.body
165
- : {
166
- data: response.body,
167
- ...result,
168
- };
169
- }
170
-
171
- if (parseAs === 'json') {
172
- if (opts.responseValidator) {
173
- await opts.responseValidator(data);
174
- }
175
-
176
- if (opts.responseTransformer) {
177
- data = await opts.responseTransformer(data);
178
- }
179
- }
180
-
181
- return opts.responseStyle === 'data'
182
- ? data
183
- : {
184
- data,
185
- ...result,
186
- };
187
- }
188
-
189
- const textError = await response.text();
190
- let jsonError: unknown;
191
-
192
- try {
193
- jsonError = JSON.parse(textError);
194
- } catch {
195
- // noop
196
- }
197
-
198
- throw jsonError ?? textError;
199
- } catch (error) {
200
- let finalError = error;
201
-
202
- for (const fn of interceptors.error.fns) {
203
- if (fn) {
204
- finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
205
- }
206
- }
207
-
208
- finalError = finalError || {};
209
-
210
- if (throwOnError) {
211
- throw finalError;
212
- }
213
-
214
- // TODO: we probably want to return error and improve types
215
- return responseStyle === 'data'
216
- ? undefined
217
- : {
218
- error: finalError,
219
- request,
220
- response,
221
- };
222
- }
223
- };
224
-
225
- const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
226
- request({ ...options, method });
227
-
228
- const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
229
- const { opts, url } = await beforeRequest(options);
230
- return createSseClient({
231
- ...opts,
232
- body: opts.body as BodyInit | null | undefined,
233
- method,
234
- onRequest: async (url, init) => {
235
- let request = new Request(url, init);
236
- for (const fn of interceptors.request.fns) {
237
- if (fn) {
238
- request = await fn(request, opts);
239
- }
240
- }
241
- return request;
242
- },
243
- serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
244
- url,
245
- });
246
- };
247
-
248
- const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
249
-
250
- return {
251
- buildUrl: _buildUrl,
252
- connect: makeMethodFn('CONNECT'),
253
- delete: makeMethodFn('DELETE'),
254
- get: makeMethodFn('GET'),
255
- getConfig,
256
- head: makeMethodFn('HEAD'),
257
- interceptors,
258
- options: makeMethodFn('OPTIONS'),
259
- patch: makeMethodFn('PATCH'),
260
- post: makeMethodFn('POST'),
261
- put: makeMethodFn('PUT'),
262
- request,
263
- setConfig,
264
- sse: {
265
- connect: makeSseFn('CONNECT'),
266
- delete: makeSseFn('DELETE'),
267
- get: makeSseFn('GET'),
268
- head: makeSseFn('HEAD'),
269
- options: makeSseFn('OPTIONS'),
270
- patch: makeSseFn('PATCH'),
271
- post: makeSseFn('POST'),
272
- put: makeSseFn('PUT'),
273
- trace: makeSseFn('TRACE'),
274
- },
275
- trace: makeMethodFn('TRACE'),
276
- } as Client;
277
- };
@@ -1,27 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- export type { Auth } from '../core/auth.gen.js';
4
- export type { QuerySerializerOptions } from '../core/bodySerializer.gen.js';
5
- export {
6
- formDataBodySerializer,
7
- jsonBodySerializer,
8
- urlSearchParamsBodySerializer,
9
- } from '../core/bodySerializer.gen.js';
10
- export { buildClientParams } from '../core/params.gen.js';
11
- export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen.js';
12
- export type { ServerSentEventsResult } from '../core/serverSentEvents.gen.js';
13
- export type { ClientMeta } from '../core/types.gen.js';
14
- export { createClient } from './client.gen.js';
15
- export type {
16
- Client,
17
- ClientOptions,
18
- Config,
19
- CreateClientConfig,
20
- Options,
21
- RequestOptions,
22
- RequestResult,
23
- ResolvedRequestOptions,
24
- ResponseStyle,
25
- TDataShape,
26
- } from './types.gen.js';
27
- export { createConfig, mergeHeaders } from './utils.gen.js';