langwatch 0.5.1 → 0.7.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 (122) hide show
  1. package/README.md +19 -0
  2. package/dist/{add-4WXEWG5H.js → add-5QV3TEWC.js} +28 -32
  3. package/dist/add-5QV3TEWC.js.map +1 -0
  4. package/dist/{add-D2WVVKIP.mjs → add-HWFRMAQX.mjs} +14 -18
  5. package/dist/add-HWFRMAQX.mjs.map +1 -0
  6. package/dist/{chunk-CAZONSXV.js → chunk-36XAYVMC.js} +186 -76
  7. package/dist/chunk-36XAYVMC.js.map +1 -0
  8. package/dist/{chunk-QCYYSMCU.js → chunk-5HAVK64Q.js} +2 -2
  9. package/dist/chunk-5HAVK64Q.js.map +1 -0
  10. package/dist/{chunk-ZIULPOMQ.mjs → chunk-7MG7DGPP.mjs} +4 -4
  11. package/dist/{chunk-YKFTFYKK.mjs → chunk-7VHZNB2S.mjs} +2 -2
  12. package/dist/chunk-7VHZNB2S.mjs.map +1 -0
  13. package/dist/{chunk-DLJO7AK5.mjs → chunk-AD7QRYIJ.mjs} +2 -2
  14. package/dist/{chunk-DISMHYXC.js → chunk-CKIZDPIJ.js} +24 -22
  15. package/dist/chunk-CKIZDPIJ.js.map +1 -0
  16. package/dist/{chunk-SVXNUWZI.js → chunk-D7UAKYVI.js} +345 -154
  17. package/dist/chunk-D7UAKYVI.js.map +1 -0
  18. package/dist/{chunk-7OZKH5K2.js → chunk-DZH6SY3Z.js} +10 -10
  19. package/dist/{chunk-7OZKH5K2.js.map → chunk-DZH6SY3Z.js.map} +1 -1
  20. package/dist/{chunk-H5PON53W.mjs → chunk-EPGKOTSN.mjs} +334 -143
  21. package/dist/chunk-EPGKOTSN.mjs.map +1 -0
  22. package/dist/{chunk-N2V6J3U2.mjs → chunk-FEL5FLHA.mjs} +2 -2
  23. package/dist/{chunk-YNQ44U6D.mjs → chunk-I2SOBPAF.mjs} +23 -21
  24. package/dist/chunk-I2SOBPAF.mjs.map +1 -0
  25. package/dist/{chunk-P4SQTYGN.js → chunk-J55AV2YW.js} +32 -32
  26. package/dist/{chunk-P4SQTYGN.js.map → chunk-J55AV2YW.js.map} +1 -1
  27. package/dist/{chunk-OXBO24RB.js → chunk-OHM7JUMR.js} +15 -2
  28. package/dist/chunk-OHM7JUMR.js.map +1 -0
  29. package/dist/chunk-PYVDTUA6.mjs +352 -0
  30. package/dist/chunk-PYVDTUA6.mjs.map +1 -0
  31. package/dist/{chunk-YH5TIVK2.js → chunk-SNDTNU3T.js} +2 -2
  32. package/dist/{chunk-YH5TIVK2.js.map → chunk-SNDTNU3T.js.map} +1 -1
  33. package/dist/{chunk-QZGTM76F.mjs → chunk-UNMZPS55.mjs} +7 -3
  34. package/dist/chunk-UNMZPS55.mjs.map +1 -0
  35. package/dist/{chunk-CU3443HD.mjs → chunk-URTD2WOC.mjs} +14 -1
  36. package/dist/{chunk-ECOC36EA.js → chunk-VMZUN4EF.js} +16 -12
  37. package/dist/chunk-VMZUN4EF.js.map +1 -0
  38. package/dist/cli/index.js +8 -8
  39. package/dist/cli/index.mjs +8 -8
  40. package/dist/{create-OQEMO4MU.mjs → create-LXQB4EFB.mjs} +4 -5
  41. package/dist/{create-OQEMO4MU.mjs.map → create-LXQB4EFB.mjs.map} +1 -1
  42. package/dist/{create-4LG4N2A4.js → create-S5RDGF3H.js} +9 -10
  43. package/dist/create-S5RDGF3H.js.map +1 -0
  44. package/dist/{implementation-BIlL6-SW.d.ts → implementation-DsHp9FYU.d.ts} +1 -1
  45. package/dist/{implementation-fAgqv8OM.d.mts → implementation-nE9dgTwc.d.mts} +1 -1
  46. package/dist/{index-DTEZr0Jn.d.mts → index-D7rKIGrO.d.mts} +12 -12
  47. package/dist/{index-DTEZr0Jn.d.ts → index-D7rKIGrO.d.ts} +12 -12
  48. package/dist/index.d.mts +256 -11
  49. package/dist/index.d.ts +256 -11
  50. package/dist/index.js +135 -12
  51. package/dist/index.js.map +1 -1
  52. package/dist/index.mjs +133 -10
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/{init-MQXXHCNT.mjs → init-T4YDPHBA.mjs} +4 -5
  55. package/dist/{init-MQXXHCNT.mjs.map → init-T4YDPHBA.mjs.map} +1 -1
  56. package/dist/init-UADBKUJU.js +15 -0
  57. package/dist/init-UADBKUJU.js.map +1 -0
  58. package/dist/{list-PFWV7IU6.mjs → list-BQXECLEM.mjs} +13 -14
  59. package/dist/list-BQXECLEM.mjs.map +1 -0
  60. package/dist/{list-GIAXAAH5.js → list-HSCIBC4Z.js} +14 -15
  61. package/dist/list-HSCIBC4Z.js.map +1 -0
  62. package/dist/{login-BYLXS23I.mjs → login-3IM3PYSJ.mjs} +3 -3
  63. package/dist/{login-3STX2FAO.js → login-EUDCIJRM.js} +4 -4
  64. package/dist/{login-3STX2FAO.js.map → login-EUDCIJRM.js.map} +1 -1
  65. package/dist/observability-sdk/index.d.mts +4 -3
  66. package/dist/observability-sdk/index.d.ts +4 -3
  67. package/dist/observability-sdk/index.js +7 -7
  68. package/dist/observability-sdk/index.mjs +6 -6
  69. package/dist/observability-sdk/instrumentation/langchain/index.d.mts +2 -1
  70. package/dist/observability-sdk/instrumentation/langchain/index.d.ts +2 -1
  71. package/dist/observability-sdk/instrumentation/langchain/index.js +19 -19
  72. package/dist/observability-sdk/instrumentation/langchain/index.mjs +3 -3
  73. package/dist/observability-sdk/setup/node/index.d.mts +1 -1
  74. package/dist/observability-sdk/setup/node/index.d.ts +1 -1
  75. package/dist/observability-sdk/setup/node/index.js +15 -15
  76. package/dist/observability-sdk/setup/node/index.mjs +4 -4
  77. package/dist/{remove-FTF3EBYV.mjs → remove-IVFQAHNT.mjs} +9 -10
  78. package/dist/{remove-FTF3EBYV.mjs.map → remove-IVFQAHNT.mjs.map} +1 -1
  79. package/dist/{remove-U3PILQDV.js → remove-VDQ4M6JF.js} +17 -18
  80. package/dist/remove-VDQ4M6JF.js.map +1 -0
  81. package/dist/{sync-FOW7DHAH.mjs → sync-2MVHHWCX.mjs} +16 -20
  82. package/dist/sync-2MVHHWCX.mjs.map +1 -0
  83. package/dist/{sync-T3T22GVZ.js → sync-KUMBMGJS.js} +31 -35
  84. package/dist/sync-KUMBMGJS.js.map +1 -0
  85. package/dist/{types-DyUmlaDx.d.ts → types-B9772cUR.d.ts} +98 -29
  86. package/dist/{types-jrEEZt9d.d.mts → types-DbPAi4US.d.mts} +98 -29
  87. package/package.json +16 -11
  88. package/dist/add-4WXEWG5H.js.map +0 -1
  89. package/dist/add-D2WVVKIP.mjs.map +0 -1
  90. package/dist/chunk-CAZONSXV.js.map +0 -1
  91. package/dist/chunk-CKVDNVFL.mjs +0 -242
  92. package/dist/chunk-CKVDNVFL.mjs.map +0 -1
  93. package/dist/chunk-DISMHYXC.js.map +0 -1
  94. package/dist/chunk-DSIQSULK.js +0 -152
  95. package/dist/chunk-DSIQSULK.js.map +0 -1
  96. package/dist/chunk-ECOC36EA.js.map +0 -1
  97. package/dist/chunk-H5PON53W.mjs.map +0 -1
  98. package/dist/chunk-OXBO24RB.js.map +0 -1
  99. package/dist/chunk-QCYYSMCU.js.map +0 -1
  100. package/dist/chunk-QZGTM76F.mjs.map +0 -1
  101. package/dist/chunk-R6FBJN7K.js +0 -115
  102. package/dist/chunk-R6FBJN7K.js.map +0 -1
  103. package/dist/chunk-SVXNUWZI.js.map +0 -1
  104. package/dist/chunk-V5M3HUBV.mjs +0 -115
  105. package/dist/chunk-V5M3HUBV.mjs.map +0 -1
  106. package/dist/chunk-YEGQXDTE.mjs +0 -152
  107. package/dist/chunk-YEGQXDTE.mjs.map +0 -1
  108. package/dist/chunk-YKFTFYKK.mjs.map +0 -1
  109. package/dist/chunk-YNQ44U6D.mjs.map +0 -1
  110. package/dist/create-4LG4N2A4.js.map +0 -1
  111. package/dist/init-EKNL2SQE.js +0 -16
  112. package/dist/init-EKNL2SQE.js.map +0 -1
  113. package/dist/list-GIAXAAH5.js.map +0 -1
  114. package/dist/list-PFWV7IU6.mjs.map +0 -1
  115. package/dist/remove-U3PILQDV.js.map +0 -1
  116. package/dist/sync-FOW7DHAH.mjs.map +0 -1
  117. package/dist/sync-T3T22GVZ.js.map +0 -1
  118. /package/dist/{chunk-ZIULPOMQ.mjs.map → chunk-7MG7DGPP.mjs.map} +0 -0
  119. /package/dist/{chunk-DLJO7AK5.mjs.map → chunk-AD7QRYIJ.mjs.map} +0 -0
  120. /package/dist/{chunk-N2V6J3U2.mjs.map → chunk-FEL5FLHA.mjs.map} +0 -0
  121. /package/dist/{chunk-CU3443HD.mjs.map → chunk-URTD2WOC.mjs.map} +0 -0
  122. /package/dist/{login-BYLXS23I.mjs.map → login-3IM3PYSJ.mjs.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { SpanOptions, Span, AttributeValue, Tracer, Context } from '@opentelemetry/api';
2
+ import { z } from 'zod';
2
3
  import { S as SemConvAttributes } from './types-DRiQaKFG.mjs';
3
4
 
4
5
  type ChatRole = "system" | "user" | "assistant" | "function" | "tool" | "unknown";
@@ -2700,37 +2701,102 @@ interface operations {
2700
2701
  };
2701
2702
  }
2702
2703
 
2703
- type PromptResponse = NonNullable<paths["/api/prompts/{id}"]["get"]["responses"]["200"]["content"]["application/json"]>;
2704
+ /**
2705
+ * Zod schema for core prompt data - the essential fields needed for functionality
2706
+ */
2707
+ declare const corePromptDataSchema: z.ZodObject<{
2708
+ model: z.ZodString;
2709
+ messages: z.ZodArray<z.ZodObject<{
2710
+ role: z.ZodEnum<{
2711
+ system: "system";
2712
+ user: "user";
2713
+ assistant: "assistant";
2714
+ }>;
2715
+ content: z.ZodString;
2716
+ }, z.core.$strip>>;
2717
+ prompt: z.ZodOptional<z.ZodString>;
2718
+ temperature: z.ZodOptional<z.ZodNumber>;
2719
+ maxTokens: z.ZodOptional<z.ZodNumber>;
2720
+ responseFormat: z.ZodOptional<z.ZodObject<{
2721
+ type: z.ZodLiteral<"json_schema">;
2722
+ json_schema: z.ZodNullable<z.ZodObject<{
2723
+ name: z.ZodString;
2724
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2725
+ }, z.core.$strip>>;
2726
+ }, z.core.$strip>>;
2727
+ }, z.core.$strip>;
2728
+ /**
2729
+ * Combined schema for complete prompt data
2730
+ */
2731
+ declare const promptDataSchema: z.ZodObject<{
2732
+ id: z.ZodOptional<z.ZodString>;
2733
+ handle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2734
+ version: z.ZodOptional<z.ZodNumber>;
2735
+ versionId: z.ZodOptional<z.ZodString>;
2736
+ scope: z.ZodOptional<z.ZodEnum<{
2737
+ ORGANIZATION: "ORGANIZATION";
2738
+ PROJECT: "PROJECT";
2739
+ }>>;
2740
+ model: z.ZodString;
2741
+ messages: z.ZodArray<z.ZodObject<{
2742
+ role: z.ZodEnum<{
2743
+ system: "system";
2744
+ user: "user";
2745
+ assistant: "assistant";
2746
+ }>;
2747
+ content: z.ZodString;
2748
+ }, z.core.$strip>>;
2749
+ prompt: z.ZodOptional<z.ZodString>;
2750
+ temperature: z.ZodOptional<z.ZodNumber>;
2751
+ maxTokens: z.ZodOptional<z.ZodNumber>;
2752
+ responseFormat: z.ZodOptional<z.ZodObject<{
2753
+ type: z.ZodLiteral<"json_schema">;
2754
+ json_schema: z.ZodNullable<z.ZodObject<{
2755
+ name: z.ZodString;
2756
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2757
+ }, z.core.$strip>>;
2758
+ }, z.core.$strip>>;
2759
+ }, z.core.$strip>;
2760
+
2761
+ /**
2762
+ * Type for template variables - supporting common data types
2763
+ */
2704
2764
  type TemplateVariables = Record<string, string | number | boolean | object | null>;
2765
+ /**
2766
+ * Core data needed for prompt functionality
2767
+ */
2768
+ type CorePromptData = z.infer<typeof corePromptDataSchema>;
2769
+ /**
2770
+ * Combined type for creating prompts
2771
+ */
2772
+ type PromptData = z.infer<typeof promptDataSchema>;
2773
+ type CreatePromptBody = NonNullable<paths["/api/prompts"]["post"]["requestBody"]>["content"]["application/json"];
2774
+ type UpdatePromptBody = NonNullable<paths["/api/prompts/{id}"]["put"]["requestBody"]>["content"]["application/json"];
2775
+ type PromptResponse = NonNullable<paths["/api/prompts/{id}"]["get"]["responses"]["200"]["content"]["application/json"]>;
2776
+ type PromptScope = paths["/api/prompts"]["post"]["responses"]["200"]["content"]["application/json"]["scope"];
2777
+
2705
2778
  /**
2706
2779
  * The Prompt class provides a standardized interface for working with prompt objects
2707
- * within the SDK, ensuring consistent structure and behavior regardless of the underlying
2708
- * client implementation. This abstraction enables the SDK to maintain control over prompt
2709
- * handling, enforce type safety, and facilitate future enhancements without exposing
2710
- * internal details or requiring changes from client code.
2780
+ * within the SDK, focusing on core functionality needed for template compilation and execution.
2781
+ * Keeps only essential fields while maintaining compatibility with tracing and observability.
2711
2782
  */
2712
- declare class Prompt implements PromptResponse {
2713
- readonly raw: PromptResponse;
2714
- readonly id: PromptResponse["id"];
2715
- readonly handle: PromptResponse["handle"];
2716
- readonly name: PromptResponse["name"];
2717
- readonly scope: PromptResponse["scope"];
2718
- readonly projectId: PromptResponse["projectId"];
2719
- readonly organizationId: PromptResponse["organizationId"];
2720
- readonly authorId: PromptResponse["authorId"];
2721
- readonly createdAt: PromptResponse["createdAt"];
2722
- readonly updatedAt: PromptResponse["updatedAt"];
2723
- readonly version: PromptResponse["version"];
2724
- readonly versionId: PromptResponse["versionId"];
2725
- readonly model: PromptResponse["model"];
2726
- readonly temperature: PromptResponse["temperature"];
2727
- readonly maxTokens: PromptResponse["maxTokens"];
2728
- readonly responseFormat: PromptResponse["responseFormat"];
2729
- readonly prompt: PromptResponse["prompt"];
2730
- readonly messages: PromptResponse["messages"];
2731
- readonly inputs: PromptResponse["inputs"];
2732
- readonly outputs: PromptResponse["outputs"];
2733
- constructor(raw: PromptResponse);
2783
+ declare class Prompt {
2784
+ readonly model: string;
2785
+ readonly messages: Array<{
2786
+ role: "user" | "assistant" | "system";
2787
+ content: string;
2788
+ }>;
2789
+ readonly prompt?: string;
2790
+ readonly temperature?: number;
2791
+ readonly maxTokens?: number;
2792
+ readonly responseFormat?: CorePromptData["responseFormat"];
2793
+ readonly id?: string;
2794
+ readonly handle?: string | null;
2795
+ readonly version?: number;
2796
+ readonly versionId?: string;
2797
+ readonly scope?: PromptScope;
2798
+ constructor(data: PromptData);
2799
+ private extractSystemPrompt;
2734
2800
  /**
2735
2801
  * Compile the prompt template with provided variables (lenient - missing variables become empty)
2736
2802
  * @param variables - Object containing variable values for template compilation
@@ -2745,9 +2811,12 @@ declare class Prompt implements PromptResponse {
2745
2811
  */
2746
2812
  compileStrict(variables: TemplateVariables): CompiledPrompt;
2747
2813
  }
2814
+ /**
2815
+ * Represents a compiled prompt that extends Prompt with reference to the original template
2816
+ */
2748
2817
  declare class CompiledPrompt extends Prompt {
2749
2818
  readonly original: Prompt;
2750
- constructor(compiledData: PromptResponse, original: Prompt);
2819
+ constructor(compiledData: PromptData, original: Prompt);
2751
2820
  }
2752
2821
 
2753
2822
  /**
@@ -3263,4 +3332,4 @@ interface LangWatchTracer extends Tracer {
3263
3332
  withActiveSpan<F extends (span: LangWatchSpan) => unknown>(name: string, options: LangWatchSpanOptions, context: Context, fn: F): ReturnType<F>;
3264
3333
  }
3265
3334
 
3266
- export { type ChatMessage as C, type InputOutputType as I, type JsonSerializable as J, type LangWatchSpan as L, type PromptResponse as P, type SpanType as S, type LangWatchTracer as a, type LangWatchSpanMetrics as b, type LangWatchSpanRAGContext as c, type LangWatchSpanOptions as d, type SimpleChatMessage as e, INPUT_OUTPUT_TYPES as f, Prompt as g, type paths as p, spanTypes as s };
3335
+ export { type ChatMessage as C, type InputOutputType as I, type JsonSerializable as J, type LangWatchSpan as L, type PromptResponse as P, type SpanType as S, type UpdatePromptBody as U, type LangWatchTracer as a, type LangWatchSpanMetrics as b, type LangWatchSpanRAGContext as c, type LangWatchSpanOptions as d, type SimpleChatMessage as e, INPUT_OUTPUT_TYPES as f, type CreatePromptBody as g, type PromptData as h, Prompt as i, type paths as p, spanTypes as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langwatch",
3
- "version": "0.5.1",
3
+ "version": "0.7.1",
4
4
  "description": "LangWatch TypeScript/JavaScript SDK. Interact with the full LangWatch API and use the LangWatch OpenTelemetry SDK to instrument your application. For more information, see https://docs.langwatch.ai/integration/typescript/guide",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -48,7 +48,10 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@eslint/js": "^9.32.0",
51
- "@opentelemetry/sdk-node": ">=0.203.0",
51
+ "@langchain/core": ">=0.3.68 <0.4.0",
52
+ "@langchain/langgraph": ">=0.4.0 <1.0.0",
53
+ "@langchain/openai": ">=0.6.0 <1.0.0",
54
+ "@opentelemetry/sdk-node": "0.205.0",
52
55
  "@opentelemetry/sdk-trace-node": "^2.0.1",
53
56
  "@opentelemetry/sdk-trace-web": ">=2.0.1",
54
57
  "@types/debug": "^4.1.12",
@@ -61,25 +64,27 @@
61
64
  "eslint": "^9.32.0",
62
65
  "fets": "^0.8.5",
63
66
  "fishery": "^2.3.1",
67
+ "langchain": ">=0.3.0 <1.0.0",
64
68
  "msw": "^2.10.4",
65
69
  "nock": "^14.0.8",
66
70
  "openapi-msw": "^1.2.0",
67
- "ts-to-zod": "3.15.0",
71
+ "ts-to-zod": "4.0.1",
68
72
  "tsup": "^8.5.0",
69
73
  "typescript": "^5.9.2",
70
74
  "typescript-eslint": "^8.38.0",
71
75
  "vitest": "^3.2.4",
76
+ "vitest-mock-extended": "^3.1.0",
72
77
  "yaml": "^2.8.1"
73
78
  },
74
79
  "dependencies": {
75
80
  "@opentelemetry/api": "^1.9.0",
76
- "@opentelemetry/api-logs": "0.203.0",
81
+ "@opentelemetry/api-logs": "0.205.0",
77
82
  "@opentelemetry/core": "^2.0.1",
78
- "@opentelemetry/exporter-logs-otlp-http": "0.203.0",
79
- "@opentelemetry/exporter-trace-otlp-http": "0.203.0",
80
- "@opentelemetry/instrumentation": "0.203.0",
83
+ "@opentelemetry/exporter-logs-otlp-http": "0.205.0",
84
+ "@opentelemetry/exporter-trace-otlp-http": "0.205.0",
85
+ "@opentelemetry/instrumentation": "0.205.0",
81
86
  "@opentelemetry/resources": "^2.0.1",
82
- "@opentelemetry/sdk-logs": "0.203.0",
87
+ "@opentelemetry/sdk-logs": "0.205.0",
83
88
  "@opentelemetry/sdk-metrics": "^2.0.1",
84
89
  "@opentelemetry/sdk-trace-base": "^2.0.1",
85
90
  "@opentelemetry/semantic-conventions": "^1.36.0",
@@ -101,7 +106,7 @@
101
106
  "@langchain/core": ">=0.3.0 <1.0.0",
102
107
  "@langchain/langgraph": ">=0.4.0 <1.0.0",
103
108
  "@langchain/openai": ">=0.6.0 <1.0.0",
104
- "@opentelemetry/context-async-hooks": ">=1.19.0 <3.0.0",
109
+ "@opentelemetry/context-async-hooks": "^2.1.0",
105
110
  "@opentelemetry/context-zone": ">=1.19.0 <3.0.0",
106
111
  "@opentelemetry/sdk-node": ">=0.200.0 <1.0.0",
107
112
  "@opentelemetry/sdk-trace-web": ">=1.19.0 <3.0.0",
@@ -113,8 +118,8 @@
113
118
  "test": "vitest",
114
119
  "test:e2e": "vitest run -c ./vitest.e2e.config.mts",
115
120
  "prebuild": "pnpm i && pnpm run prepare",
116
- "build": "tsgo --noEmit && tsup",
117
- "typecheck": "tsgo --noEmit",
121
+ "build": "tsc --noEmit && tsup",
122
+ "typecheck": "tsc --noEmit",
118
123
  "prepublish": "pnpm run build",
119
124
  "generate:openapi-types": "npx openapi-typescript ../langwatch/src/app/api/openapiLangWatch.json -o ./src/internal/generated/openapi/api-client.ts",
120
125
  "generate:server-types": "./copy-types.sh"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/add-4WXEWG5H.js","../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,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AA;AAGI,MAAA;AACnC,MAAA;AAC5B,QAAA;AACA,QAAA;AACF,MAAA;AAC2D,MAAA;AAGd,MAAA;AACJ,MAAA;AAElB,MAAA;AACqC,MAAA;AAGxB,MAAA;AACJ,MAAA;AAEhB,MAAA;AAKZ,MAAA;AACI,MAAA;AACA,QAAA;AACkD,UAAA;AAC1B,YAAA;AACE,UAAA;AAChC,QAAA;AACF,MAAA;AACc,IAAA;AACD,MAAA;AACsB,MAAA;AACiB,QAAA;AAC7C,MAAA;AACG,QAAA;AACA,UAAA;AAE6B,YAAA;AAEnC,UAAA;AACF,QAAA;AACF,MAAA;AACc,MAAA;AAChB,IAAA;AACc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACG,MAAA;AACA,QAAA;AAEuC,UAAA;AAE7C,QAAA;AACF,MAAA;AACF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADhC0E;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/add-4WXEWG5H.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptsError } from \"@/client-sdk/services/prompts\";\nimport { PromptConverter } from \"../utils/promptConverter\";\nimport { ensureProjectInitialized } from \"../utils/init\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport { LangWatch } from \"@/client-sdk\";\n\ninterface AddOptions {\n version?: string;\n localFile?: string;\n}\n\nconst addLocalFile = async (\n name: string,\n localFilePath: string,\n): Promise<void> => {\n // Validate that the file exists and has the right extension\n if (!fs.existsSync(localFilePath)) {\n console.error(chalk.red(`Error: Local file not found: ${localFilePath}`));\n process.exit(1);\n }\n\n if (!localFilePath.endsWith(\".prompt.yaml\")) {\n console.error(\n chalk.red(`Error: Local file must have .prompt.yaml extension`),\n );\n process.exit(1);\n }\n\n // Load and validate the YAML file\n try {\n FileManager.loadLocalPrompt(localFilePath);\n\n // Ensure project is initialized\n await ensureProjectInitialized();\n\n // Add to prompts.json as a file: dependency\n const promptsConfig = FileManager.loadPromptsConfig();\n promptsConfig.prompts[name] = `file:${localFilePath}`;\n FileManager.savePromptsConfig(promptsConfig);\n\n // Update lock file\n const lock = FileManager.loadPromptsLock();\n lock.prompts[name] = {\n version: 0, // Local files start at version 0\n versionId: \"local\",\n materialized: localFilePath, // Store the original file path\n };\n FileManager.savePromptsLock(lock);\n\n console.log(\n chalk.green(\n `✓ Added local prompt: ${chalk.cyan(name)} → ${chalk.gray(\n localFilePath,\n )}`,\n ),\n );\n } catch (error) {\n console.error(chalk.red(\"Error loading local prompt file:\"));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error)),\n );\n process.exit(1);\n }\n};\n\nexport const addCommand = async (\n name: string,\n options: AddOptions,\n): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Handle local file addition\n if (options.localFile) {\n await addLocalFile(name, options.localFile);\n return;\n }\n\n // Check API key before doing anything else\n checkApiKey();\n\n const langwatch = new LangWatch();\n const version = options.version ?? \"latest\";\n\n // Fetch and materialize the prompt (like sync does for individual prompts)\n const spinner = ora(\n `Adding ${chalk.cyan(`${name}@${version}`)}...`,\n ).start();\n\n try {\n // Fetch the prompt from the API\n const prompt = await langwatch.prompts.get(name);\n\n if (!prompt) {\n spinner.fail();\n console.error(chalk.red(`Error: Prompt \"${name}\" not found`));\n process.exit(1);\n }\n\n // Stop spinner before any user input prompts\n spinner.stop();\n\n // Ensure project is initialized (prompts.json, lock file, directories)\n await ensureProjectInitialized();\n\n // Restart spinner for the actual work\n spinner.start(`Adding ${chalk.cyan(`${name}@${version}`)}...`);\n\n // Convert to MaterializedPrompt format and save\n const materializedPrompt = PromptConverter.fromApiToMaterialized(prompt);\n const savedPath = FileManager.saveMaterializedPrompt(\n name,\n materializedPrompt,\n );\n const relativePath = path.relative(process.cwd(), savedPath);\n\n // Load existing config and lock, add the new dependency\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n config.prompts[name] = version;\n FileManager.updateLockEntry(lock, name, materializedPrompt, savedPath);\n\n // Save the updated config and lock\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n spinner.succeed();\n\n // Show what was done (add ./ prefix for consistency)\n const displayPath = relativePath.startsWith(\"./\")\n ? relativePath\n : `./${relativePath}`;\n console.log(\n chalk.green(\n `✓ Pulled ${chalk.cyan(`${name}@${version}`)} ${chalk.gray(\n `(version ${prompt.version})`,\n )} → ${chalk.gray(displayPath)}`,\n ),\n );\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Error adding prompt: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n }\n process.exit(1);\n }\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Unexpected error: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n }\n process.exit(1);\n }\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/commands/add.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptsError } from \"@/client-sdk/services/prompts\";\nimport { PromptConverter } from \"../utils/promptConverter\";\nimport { ensureProjectInitialized } from \"../utils/init\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport { LangWatch } from \"@/client-sdk\";\n\ninterface AddOptions {\n version?: string;\n localFile?: string;\n}\n\nconst addLocalFile = async (\n name: string,\n localFilePath: string,\n): Promise<void> => {\n // Validate that the file exists and has the right extension\n if (!fs.existsSync(localFilePath)) {\n console.error(chalk.red(`Error: Local file not found: ${localFilePath}`));\n process.exit(1);\n }\n\n if (!localFilePath.endsWith(\".prompt.yaml\")) {\n console.error(\n chalk.red(`Error: Local file must have .prompt.yaml extension`),\n );\n process.exit(1);\n }\n\n // Load and validate the YAML file\n try {\n FileManager.loadLocalPrompt(localFilePath);\n\n // Ensure project is initialized\n await ensureProjectInitialized();\n\n // Add to prompts.json as a file: dependency\n const promptsConfig = FileManager.loadPromptsConfig();\n promptsConfig.prompts[name] = `file:${localFilePath}`;\n FileManager.savePromptsConfig(promptsConfig);\n\n // Update lock file\n const lock = FileManager.loadPromptsLock();\n lock.prompts[name] = {\n version: 0, // Local files start at version 0\n versionId: \"local\",\n materialized: localFilePath, // Store the original file path\n };\n FileManager.savePromptsLock(lock);\n\n console.log(\n chalk.green(\n `✓ Added local prompt: ${chalk.cyan(name)} → ${chalk.gray(\n localFilePath,\n )}`,\n ),\n );\n } catch (error) {\n console.error(chalk.red(\"Error loading local prompt file:\"));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error)),\n );\n process.exit(1);\n }\n};\n\nexport const addCommand = async (\n name: string,\n options: AddOptions,\n): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Handle local file addition\n if (options.localFile) {\n await addLocalFile(name, options.localFile);\n return;\n }\n\n // Check API key before doing anything else\n checkApiKey();\n\n const langwatch = new LangWatch();\n const version = options.version ?? \"latest\";\n\n // Fetch and materialize the prompt (like sync does for individual prompts)\n const spinner = ora(\n `Adding ${chalk.cyan(`${name}@${version}`)}...`,\n ).start();\n\n try {\n // Fetch the prompt from the API\n const prompt = await langwatch.prompts.get(name);\n\n if (!prompt) {\n spinner.fail();\n console.error(chalk.red(`Error: Prompt \"${name}\" not found`));\n process.exit(1);\n }\n\n // Stop spinner before any user input prompts\n spinner.stop();\n\n // Ensure project is initialized (prompts.json, lock file, directories)\n await ensureProjectInitialized();\n\n // Restart spinner for the actual work\n spinner.start(`Adding ${chalk.cyan(`${name}@${version}`)}...`);\n\n // Convert to MaterializedPrompt format and save\n const materializedPrompt = PromptConverter.fromApiToMaterialized(prompt);\n const savedPath = FileManager.saveMaterializedPrompt(\n name,\n materializedPrompt,\n );\n const relativePath = path.relative(process.cwd(), savedPath);\n\n // Load existing config and lock, add the new dependency\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n config.prompts[name] = version;\n FileManager.updateLockEntry(lock, name, materializedPrompt, savedPath);\n\n // Save the updated config and lock\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n spinner.succeed();\n\n // Show what was done (add ./ prefix for consistency)\n const displayPath = relativePath.startsWith(\"./\")\n ? relativePath\n : `./${relativePath}`;\n console.log(\n chalk.green(\n `✓ Pulled ${chalk.cyan(`${name}@${version}`)} ${chalk.gray(\n `(version ${prompt.version})`,\n )} → ${chalk.gray(displayPath)}`,\n ),\n );\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Error adding prompt: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n }\n process.exit(1);\n }\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Unexpected error: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n }\n process.exit(1);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,OAAO,WAAW;AAClB,OAAO,SAAS;AAahB,IAAM,eAAe,OACnB,MACA,kBACkB;AAElB,MAAI,CAAI,cAAW,aAAa,GAAG;AACjC,YAAQ,MAAM,MAAM,IAAI,gCAAgC,aAAa,EAAE,CAAC;AACxE,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,CAAC,cAAc,SAAS,cAAc,GAA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F;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,SAAS,OAAO;AACd,QAAI,iBAAiB,cAAc;AACjC,cAAQ,MAAM,MAAM,IAAI,UAAU,MAAM,OAAO,EAAE,CAAC;AAAA,IACpD,OAAO;AACL,cAAQ;AAAA,QACN,MAAM;AAAA,UACJ,qBACE,iBAAiB,QAAQ,MAAM,UAAU,eAC3C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-CAZONSXV.js","../src/cli/utils/fileManager.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACPA,+DAAoB;AACpB,uEAAsB;AACtB,8EAAsB;AACtB,4EAAkB;AAKX,IAAM,YAAA,EAAN,MAAkB;AAAA,EAMvB,OAAO,oBAAA,CAAA,EAA+B;AACpC,IAAA,OAAY,IAAA,CAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,mBAAmB,CAAA;AAAA,EAC1D;AAAA,EAEA,OAAO,kBAAA,CAAA,EAA6B;AAClC,IAAA,OAAY,IAAA,CAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,iBAAiB,CAAA;AAAA,EACxD;AAAA,EAEA,OAAO,aAAA,CAAA,EAAwB;AAC7B,IAAA,OAAY,IAAA,CAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,WAAW,CAAA;AAAA,EAClD;AAAA,EAEA,OAAO,kBAAA,CAAA,EAA6B;AAClC,IAAA,OAAY,IAAA,CAAA,IAAA,CAAK,IAAA,CAAK,aAAA,CAAc,CAAA,EAAG,IAAA,CAAK,gBAAgB,CAAA;AAAA,EA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AEkB,IAAA;AACX,IAAA;AACT,EAAA;AAEoD,EAAA;AACZ,IAAA;AACiB,IAAA;AACN,IAAA;AACnD,EAAA;AAEoF,EAAA;AAClC,IAAA;AAEX,IAAA;AAC3B,MAAA;AACV,IAAA;AAE2B,IAAA;AAEkC,IAAA;AACA,MAAA;AAE9B,MAAA;AACe,QAAA;AACiB,QAAA;AAElC,QAAA;AACc,UAAA;AAGjC,UAAA;AACwC,YAAA;AACb,YAAA;AACN,cAAA;AACvB,YAAA;AACM,UAAA;AAER,UAAA;AACgE,QAAA;AAEC,UAAA;AAEvB,UAAA;AAClB,YAAA;AACC,YAAA;AACzB,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAE0B,IAAA;AACnB,IAAA;AACT,EAAA;AAEoH,EAAA;AAChD,IAAA;AAE7C,IAAA;AACH,MAAA;AACE,MAAA;AACJ,MAAA;AAChB,IAAA;AACF,EAAA;AAEgE,EAAA;AACpC,IAAA;AACA,MAAA;AAC1B,IAAA;AACF,EAAA;AAE2E,EAAA;AACd,IAAA;AAGxB,IAAA;AAEO,MAAA;AAAI;AACP,MAAA;AACvC,IAAA;AAGsD,IAAA;AACG,IAAA;AAG9B,IAAA;AACY,MAAA;AACvC,IAAA;AAG8D,IAAA;AAAiB;AAAU;AAAA;AAC/C,IAAA;AAEL,IAAA;AACvC,EAAA;AACF;AApSgD;AACF;AACN;AACK;ADiOmE;AACA;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-CAZONSXV.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as yaml from \"js-yaml\";\nimport chalk from \"chalk\";\nimport type { PromptsConfig, LocalPromptConfig, MaterializedPrompt, PromptsLock } from \"../types\";\nimport { localPromptConfigSchema } from \"../types\";\nimport { PromptConverter } from \"@/cli/utils/promptConverter\";\n\nexport class FileManager {\n private static readonly PROMPTS_CONFIG_FILE = \"prompts.json\";\n private static readonly PROMPTS_LOCK_FILE = \"prompts-lock.json\";\n private static readonly PROMPTS_DIR = \"prompts\";\n private static readonly MATERIALIZED_DIR = \".materialized\";\n\n static getPromptsConfigPath(): string {\n return path.join(process.cwd(), this.PROMPTS_CONFIG_FILE);\n }\n\n static getPromptsLockPath(): string {\n return path.join(process.cwd(), this.PROMPTS_LOCK_FILE);\n }\n\n static getPromptsDir(): string {\n return path.join(process.cwd(), this.PROMPTS_DIR);\n }\n\n static getMaterializedDir(): string {\n return path.join(this.getPromptsDir(), this.MATERIALIZED_DIR);\n }\n\n static ensureDirectories(): void {\n const promptsDir = this.getPromptsDir();\n const materializedDir = this.getMaterializedDir();\n\n if (!fs.existsSync(promptsDir)) {\n fs.mkdirSync(promptsDir, { recursive: true });\n }\n\n if (!fs.existsSync(materializedDir)) {\n fs.mkdirSync(materializedDir, { recursive: true });\n }\n }\n\n static loadPromptsConfig(): PromptsConfig {\n const configPath = this.getPromptsConfigPath();\n\n if (!fs.existsSync(configPath)) {\n return { prompts: {} };\n }\n\n try {\n const content = fs.readFileSync(configPath, \"utf-8\");\n return JSON.parse(content) as PromptsConfig;\n } catch (error) {\n throw new Error(`Failed to parse prompts.json: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n }\n }\n\n static savePromptsConfig(config: PromptsConfig): void {\n const configPath = this.getPromptsConfigPath();\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n\n static initializePromptsConfig(): { created: boolean; path: string } {\n const configPath = this.getPromptsConfigPath();\n const existed = fs.existsSync(configPath);\n\n if (!existed) {\n const emptyConfig: PromptsConfig = { prompts: {} };\n this.savePromptsConfig(emptyConfig);\n return { created: true, path: configPath };\n }\n\n return { created: false, path: configPath };\n }\n\n static loadPromptsLock(): PromptsLock {\n const lockPath = this.getPromptsLockPath();\n\n if (!fs.existsSync(lockPath)) {\n return {\n lockfileVersion: 1,\n prompts: {}\n };\n }\n\n try {\n const content = fs.readFileSync(lockPath, \"utf-8\");\n return JSON.parse(content) as PromptsLock;\n } catch (error) {\n throw new Error(`Failed to parse prompts-lock.json: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n }\n }\n\n static savePromptsLock(lock: PromptsLock): void {\n const lockPath = this.getPromptsLockPath();\n fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2) + \"\\n\");\n }\n\n static initializePromptsLock(): { created: boolean; path: string } {\n const lockPath = this.getPromptsLockPath();\n const existed = fs.existsSync(lockPath);\n\n if (!existed) {\n const emptyLock: PromptsLock = {\n lockfileVersion: 1,\n prompts: {}\n };\n this.savePromptsLock(emptyLock);\n return { created: true, path: lockPath };\n }\n\n return { created: false, path: lockPath };\n }\n\n static loadLocalPrompt(filePath: string): LocalPromptConfig {\n const fullPath = path.resolve(filePath);\n\n if (!fs.existsSync(fullPath)) {\n throw new Error(`Local prompt file not found: ${filePath}`);\n }\n\n try {\n const content = fs.readFileSync(fullPath, \"utf-8\");\n const rawData = yaml.load(content);\n\n // Validate with zod and provide nice error messages\n const result = localPromptConfigSchema.safeParse(rawData);\n\n if (!result.success) {\n // Format zod errors nicely (manually since z.prettifyError might not be available)\n const prettyError = result.error.issues\n .map(issue => `✖ ${issue.message}${issue.path.length > 0 ? `\\n → at ${issue.path.join('.')}` : ''}`)\n .join('\\n');\n\n throw new Error(\n `Invalid prompt configuration in ${chalk.yellow(filePath)}:\\n${prettyError}`\n );\n }\n\n return result.data;\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid prompt configuration\")) {\n throw error; // Re-throw zod validation errors as-is\n }\n throw new Error(`Failed to parse local prompt file ${filePath}: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n }\n }\n\n static saveMaterializedPrompt(name: string, prompt: MaterializedPrompt): string {\n const materializedDir = this.getMaterializedDir();\n const parts = name.split(\"/\");\n const fileName = `${parts[parts.length - 1]}.prompt.yaml`;\n\n // Create nested directories if needed\n if (parts.length > 1) {\n const subDir = path.join(materializedDir, ...parts.slice(0, -1));\n if (!fs.existsSync(subDir)) {\n fs.mkdirSync(subDir, { recursive: true });\n }\n }\n\n const filePath = path.join(materializedDir, ...parts.slice(0, -1), fileName);\n\n // Convert to YAML format using the converter\n const yamlContent = PromptConverter.fromMaterializedToYaml(prompt);\n\n const yamlString = yaml.dump(yamlContent, {\n lineWidth: -1,\n noRefs: true,\n sortKeys: false\n });\n\n fs.writeFileSync(filePath, yamlString);\n return filePath;\n }\n\n static getLocalPromptFiles(): string[] {\n const promptsDir = this.getPromptsDir();\n const materializedDir = this.getMaterializedDir();\n\n if (!fs.existsSync(promptsDir)) {\n return [];\n }\n\n const files: string[] = [];\n\n const walkDir = (dir: string, relativePath = \"\"): void => {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n const relativeFilePath = path.join(relativePath, entry.name);\n\n if (entry.isDirectory()) {\n // Skip the .materialized directory\n if (fullPath === materializedDir) {\n continue;\n }\n walkDir(fullPath, relativeFilePath);\n } else if (entry.isFile() && entry.name.endsWith(\".prompt.yaml\")) {\n files.push(path.join(promptsDir, relativeFilePath));\n }\n }\n };\n\n walkDir(promptsDir);\n return files;\n }\n\n static promptNameFromPath(filePath: string): string {\n const promptsDir = this.getPromptsDir();\n const relativePath = path.relative(promptsDir, filePath);\n return relativePath.replace(/\\.prompt\\.yaml$/, \"\");\n }\n\n static cleanupOrphanedMaterializedFiles(currentDependencies: Set<string>): string[] {\n const materializedDir = this.getMaterializedDir();\n\n if (!fs.existsSync(materializedDir)) {\n return [];\n }\n\n const cleaned: string[] = [];\n\n const cleanupDir = (dir: string, relativePath = \"\"): void => {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n const relativeFilePath = path.join(relativePath, entry.name);\n\n if (entry.isDirectory()) {\n cleanupDir(fullPath, relativeFilePath);\n\n // Remove empty directories\n try {\n const dirEntries = fs.readdirSync(fullPath);\n if (dirEntries.length === 0) {\n fs.rmdirSync(fullPath);\n }\n } catch {\n // Directory not empty or other error, ignore\n }\n } else if (entry.isFile() && entry.name.endsWith(\".prompt.yaml\")) {\n // Extract prompt name from materialized file path\n const promptName = relativeFilePath.replace(/\\.prompt\\.yaml$/, \"\");\n\n if (!currentDependencies.has(promptName)) {\n fs.unlinkSync(fullPath);\n cleaned.push(promptName);\n }\n }\n }\n };\n\n cleanupDir(materializedDir);\n return cleaned;\n }\n\n static updateLockEntry(lock: PromptsLock, name: string, prompt: MaterializedPrompt, materializedPath: string): void {\n const relativePath = path.relative(process.cwd(), materializedPath);\n\n lock.prompts[name] = {\n version: prompt.version,\n versionId: prompt.versionId,\n materialized: relativePath,\n };\n }\n\n static removeFromLock(lock: PromptsLock, names: string[]): void {\n for (const name of names) {\n delete lock.prompts[name];\n }\n }\n\n static addToGitignore(entry: string): { added: boolean; existed: boolean } {\n const gitignorePath = path.join(process.cwd(), \".gitignore\");\n\n // Check if .gitignore exists\n if (!fs.existsSync(gitignorePath)) {\n // Create new .gitignore with the entry\n fs.writeFileSync(gitignorePath, `${entry}\\n`);\n return { added: true, existed: false };\n }\n\n // Read existing .gitignore\n const content = fs.readFileSync(gitignorePath, \"utf-8\");\n const lines = content.split(\"\\n\").map(line => line.trim());\n\n // Check if entry already exists\n if (lines.includes(entry)) {\n return { added: false, existed: true };\n }\n\n // Add entry to .gitignore\n const newContent = content.endsWith(\"\\n\") ? `${content}${entry}\\n` : `${content}\\n${entry}\\n`;\n fs.writeFileSync(gitignorePath, newContent);\n\n return { added: true, existed: false };\n }\n}\n"]}
@@ -1,242 +0,0 @@
1
- import {
2
- PromptConverter
3
- } from "./chunk-V5M3HUBV.mjs";
4
- import {
5
- localPromptConfigSchema
6
- } from "./chunk-BTBSMJTY.mjs";
7
-
8
- // src/cli/utils/fileManager.ts
9
- import * as fs from "fs";
10
- import * as path from "path";
11
- import * as yaml from "js-yaml";
12
- import chalk from "chalk";
13
- var FileManager = class {
14
- static getPromptsConfigPath() {
15
- return path.join(process.cwd(), this.PROMPTS_CONFIG_FILE);
16
- }
17
- static getPromptsLockPath() {
18
- return path.join(process.cwd(), this.PROMPTS_LOCK_FILE);
19
- }
20
- static getPromptsDir() {
21
- return path.join(process.cwd(), this.PROMPTS_DIR);
22
- }
23
- static getMaterializedDir() {
24
- return path.join(this.getPromptsDir(), this.MATERIALIZED_DIR);
25
- }
26
- static ensureDirectories() {
27
- const promptsDir = this.getPromptsDir();
28
- const materializedDir = this.getMaterializedDir();
29
- if (!fs.existsSync(promptsDir)) {
30
- fs.mkdirSync(promptsDir, { recursive: true });
31
- }
32
- if (!fs.existsSync(materializedDir)) {
33
- fs.mkdirSync(materializedDir, { recursive: true });
34
- }
35
- }
36
- static loadPromptsConfig() {
37
- const configPath = this.getPromptsConfigPath();
38
- if (!fs.existsSync(configPath)) {
39
- return { prompts: {} };
40
- }
41
- try {
42
- const content = fs.readFileSync(configPath, "utf-8");
43
- return JSON.parse(content);
44
- } catch (error) {
45
- throw new Error(`Failed to parse prompts.json: ${error instanceof Error ? error.message : "Unknown error"}`);
46
- }
47
- }
48
- static savePromptsConfig(config) {
49
- const configPath = this.getPromptsConfigPath();
50
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
51
- }
52
- static initializePromptsConfig() {
53
- const configPath = this.getPromptsConfigPath();
54
- const existed = fs.existsSync(configPath);
55
- if (!existed) {
56
- const emptyConfig = { prompts: {} };
57
- this.savePromptsConfig(emptyConfig);
58
- return { created: true, path: configPath };
59
- }
60
- return { created: false, path: configPath };
61
- }
62
- static loadPromptsLock() {
63
- const lockPath = this.getPromptsLockPath();
64
- if (!fs.existsSync(lockPath)) {
65
- return {
66
- lockfileVersion: 1,
67
- prompts: {}
68
- };
69
- }
70
- try {
71
- const content = fs.readFileSync(lockPath, "utf-8");
72
- return JSON.parse(content);
73
- } catch (error) {
74
- throw new Error(`Failed to parse prompts-lock.json: ${error instanceof Error ? error.message : "Unknown error"}`);
75
- }
76
- }
77
- static savePromptsLock(lock) {
78
- const lockPath = this.getPromptsLockPath();
79
- fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2) + "\n");
80
- }
81
- static initializePromptsLock() {
82
- const lockPath = this.getPromptsLockPath();
83
- const existed = fs.existsSync(lockPath);
84
- if (!existed) {
85
- const emptyLock = {
86
- lockfileVersion: 1,
87
- prompts: {}
88
- };
89
- this.savePromptsLock(emptyLock);
90
- return { created: true, path: lockPath };
91
- }
92
- return { created: false, path: lockPath };
93
- }
94
- static loadLocalPrompt(filePath) {
95
- const fullPath = path.resolve(filePath);
96
- if (!fs.existsSync(fullPath)) {
97
- throw new Error(`Local prompt file not found: ${filePath}`);
98
- }
99
- try {
100
- const content = fs.readFileSync(fullPath, "utf-8");
101
- const rawData = yaml.load(content);
102
- const result = localPromptConfigSchema.safeParse(rawData);
103
- if (!result.success) {
104
- const prettyError = result.error.issues.map((issue) => `\u2716 ${issue.message}${issue.path.length > 0 ? `
105
- \u2192 at ${issue.path.join(".")}` : ""}`).join("\n");
106
- throw new Error(
107
- `Invalid prompt configuration in ${chalk.yellow(filePath)}:
108
- ${prettyError}`
109
- );
110
- }
111
- return result.data;
112
- } catch (error) {
113
- if (error instanceof Error && error.message.includes("Invalid prompt configuration")) {
114
- throw error;
115
- }
116
- throw new Error(`Failed to parse local prompt file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
117
- }
118
- }
119
- static saveMaterializedPrompt(name, prompt) {
120
- const materializedDir = this.getMaterializedDir();
121
- const parts = name.split("/");
122
- const fileName = `${parts[parts.length - 1]}.prompt.yaml`;
123
- if (parts.length > 1) {
124
- const subDir = path.join(materializedDir, ...parts.slice(0, -1));
125
- if (!fs.existsSync(subDir)) {
126
- fs.mkdirSync(subDir, { recursive: true });
127
- }
128
- }
129
- const filePath = path.join(materializedDir, ...parts.slice(0, -1), fileName);
130
- const yamlContent = PromptConverter.fromMaterializedToYaml(prompt);
131
- const yamlString = yaml.dump(yamlContent, {
132
- lineWidth: -1,
133
- noRefs: true,
134
- sortKeys: false
135
- });
136
- fs.writeFileSync(filePath, yamlString);
137
- return filePath;
138
- }
139
- static getLocalPromptFiles() {
140
- const promptsDir = this.getPromptsDir();
141
- const materializedDir = this.getMaterializedDir();
142
- if (!fs.existsSync(promptsDir)) {
143
- return [];
144
- }
145
- const files = [];
146
- const walkDir = (dir, relativePath = "") => {
147
- const entries = fs.readdirSync(dir, { withFileTypes: true });
148
- for (const entry of entries) {
149
- const fullPath = path.join(dir, entry.name);
150
- const relativeFilePath = path.join(relativePath, entry.name);
151
- if (entry.isDirectory()) {
152
- if (fullPath === materializedDir) {
153
- continue;
154
- }
155
- walkDir(fullPath, relativeFilePath);
156
- } else if (entry.isFile() && entry.name.endsWith(".prompt.yaml")) {
157
- files.push(path.join(promptsDir, relativeFilePath));
158
- }
159
- }
160
- };
161
- walkDir(promptsDir);
162
- return files;
163
- }
164
- static promptNameFromPath(filePath) {
165
- const promptsDir = this.getPromptsDir();
166
- const relativePath = path.relative(promptsDir, filePath);
167
- return relativePath.replace(/\.prompt\.yaml$/, "");
168
- }
169
- static cleanupOrphanedMaterializedFiles(currentDependencies) {
170
- const materializedDir = this.getMaterializedDir();
171
- if (!fs.existsSync(materializedDir)) {
172
- return [];
173
- }
174
- const cleaned = [];
175
- const cleanupDir = (dir, relativePath = "") => {
176
- const entries = fs.readdirSync(dir, { withFileTypes: true });
177
- for (const entry of entries) {
178
- const fullPath = path.join(dir, entry.name);
179
- const relativeFilePath = path.join(relativePath, entry.name);
180
- if (entry.isDirectory()) {
181
- cleanupDir(fullPath, relativeFilePath);
182
- try {
183
- const dirEntries = fs.readdirSync(fullPath);
184
- if (dirEntries.length === 0) {
185
- fs.rmdirSync(fullPath);
186
- }
187
- } catch (e) {
188
- }
189
- } else if (entry.isFile() && entry.name.endsWith(".prompt.yaml")) {
190
- const promptName = relativeFilePath.replace(/\.prompt\.yaml$/, "");
191
- if (!currentDependencies.has(promptName)) {
192
- fs.unlinkSync(fullPath);
193
- cleaned.push(promptName);
194
- }
195
- }
196
- }
197
- };
198
- cleanupDir(materializedDir);
199
- return cleaned;
200
- }
201
- static updateLockEntry(lock, name, prompt, materializedPath) {
202
- const relativePath = path.relative(process.cwd(), materializedPath);
203
- lock.prompts[name] = {
204
- version: prompt.version,
205
- versionId: prompt.versionId,
206
- materialized: relativePath
207
- };
208
- }
209
- static removeFromLock(lock, names) {
210
- for (const name of names) {
211
- delete lock.prompts[name];
212
- }
213
- }
214
- static addToGitignore(entry) {
215
- const gitignorePath = path.join(process.cwd(), ".gitignore");
216
- if (!fs.existsSync(gitignorePath)) {
217
- fs.writeFileSync(gitignorePath, `${entry}
218
- `);
219
- return { added: true, existed: false };
220
- }
221
- const content = fs.readFileSync(gitignorePath, "utf-8");
222
- const lines = content.split("\n").map((line) => line.trim());
223
- if (lines.includes(entry)) {
224
- return { added: false, existed: true };
225
- }
226
- const newContent = content.endsWith("\n") ? `${content}${entry}
227
- ` : `${content}
228
- ${entry}
229
- `;
230
- fs.writeFileSync(gitignorePath, newContent);
231
- return { added: true, existed: false };
232
- }
233
- };
234
- FileManager.PROMPTS_CONFIG_FILE = "prompts.json";
235
- FileManager.PROMPTS_LOCK_FILE = "prompts-lock.json";
236
- FileManager.PROMPTS_DIR = "prompts";
237
- FileManager.MATERIALIZED_DIR = ".materialized";
238
-
239
- export {
240
- FileManager
241
- };
242
- //# sourceMappingURL=chunk-CKVDNVFL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/utils/fileManager.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as yaml from \"js-yaml\";\nimport chalk from \"chalk\";\nimport type { PromptsConfig, LocalPromptConfig, MaterializedPrompt, PromptsLock } from \"../types\";\nimport { localPromptConfigSchema } from \"../types\";\nimport { PromptConverter } from \"@/cli/utils/promptConverter\";\n\nexport class FileManager {\n private static readonly PROMPTS_CONFIG_FILE = \"prompts.json\";\n private static readonly PROMPTS_LOCK_FILE = \"prompts-lock.json\";\n private static readonly PROMPTS_DIR = \"prompts\";\n private static readonly MATERIALIZED_DIR = \".materialized\";\n\n static getPromptsConfigPath(): string {\n return path.join(process.cwd(), this.PROMPTS_CONFIG_FILE);\n }\n\n static getPromptsLockPath(): string {\n return path.join(process.cwd(), this.PROMPTS_LOCK_FILE);\n }\n\n static getPromptsDir(): string {\n return path.join(process.cwd(), this.PROMPTS_DIR);\n }\n\n static getMaterializedDir(): string {\n return path.join(this.getPromptsDir(), this.MATERIALIZED_DIR);\n }\n\n static ensureDirectories(): void {\n const promptsDir = this.getPromptsDir();\n const materializedDir = this.getMaterializedDir();\n\n if (!fs.existsSync(promptsDir)) {\n fs.mkdirSync(promptsDir, { recursive: true });\n }\n\n if (!fs.existsSync(materializedDir)) {\n fs.mkdirSync(materializedDir, { recursive: true });\n }\n }\n\n static loadPromptsConfig(): PromptsConfig {\n const configPath = this.getPromptsConfigPath();\n\n if (!fs.existsSync(configPath)) {\n return { prompts: {} };\n }\n\n try {\n const content = fs.readFileSync(configPath, \"utf-8\");\n return JSON.parse(content) as PromptsConfig;\n } catch (error) {\n throw new Error(`Failed to parse prompts.json: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n }\n }\n\n static savePromptsConfig(config: PromptsConfig): void {\n const configPath = this.getPromptsConfigPath();\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n }\n\n static initializePromptsConfig(): { created: boolean; path: string } {\n const configPath = this.getPromptsConfigPath();\n const existed = fs.existsSync(configPath);\n\n if (!existed) {\n const emptyConfig: PromptsConfig = { prompts: {} };\n this.savePromptsConfig(emptyConfig);\n return { created: true, path: configPath };\n }\n\n return { created: false, path: configPath };\n }\n\n static loadPromptsLock(): PromptsLock {\n const lockPath = this.getPromptsLockPath();\n\n if (!fs.existsSync(lockPath)) {\n return {\n lockfileVersion: 1,\n prompts: {}\n };\n }\n\n try {\n const content = fs.readFileSync(lockPath, \"utf-8\");\n return JSON.parse(content) as PromptsLock;\n } catch (error) {\n throw new Error(`Failed to parse prompts-lock.json: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n }\n }\n\n static savePromptsLock(lock: PromptsLock): void {\n const lockPath = this.getPromptsLockPath();\n fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2) + \"\\n\");\n }\n\n static initializePromptsLock(): { created: boolean; path: string } {\n const lockPath = this.getPromptsLockPath();\n const existed = fs.existsSync(lockPath);\n\n if (!existed) {\n const emptyLock: PromptsLock = {\n lockfileVersion: 1,\n prompts: {}\n };\n this.savePromptsLock(emptyLock);\n return { created: true, path: lockPath };\n }\n\n return { created: false, path: lockPath };\n }\n\n static loadLocalPrompt(filePath: string): LocalPromptConfig {\n const fullPath = path.resolve(filePath);\n\n if (!fs.existsSync(fullPath)) {\n throw new Error(`Local prompt file not found: ${filePath}`);\n }\n\n try {\n const content = fs.readFileSync(fullPath, \"utf-8\");\n const rawData = yaml.load(content);\n\n // Validate with zod and provide nice error messages\n const result = localPromptConfigSchema.safeParse(rawData);\n\n if (!result.success) {\n // Format zod errors nicely (manually since z.prettifyError might not be available)\n const prettyError = result.error.issues\n .map(issue => `✖ ${issue.message}${issue.path.length > 0 ? `\\n → at ${issue.path.join('.')}` : ''}`)\n .join('\\n');\n\n throw new Error(\n `Invalid prompt configuration in ${chalk.yellow(filePath)}:\\n${prettyError}`\n );\n }\n\n return result.data;\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid prompt configuration\")) {\n throw error; // Re-throw zod validation errors as-is\n }\n throw new Error(`Failed to parse local prompt file ${filePath}: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n }\n }\n\n static saveMaterializedPrompt(name: string, prompt: MaterializedPrompt): string {\n const materializedDir = this.getMaterializedDir();\n const parts = name.split(\"/\");\n const fileName = `${parts[parts.length - 1]}.prompt.yaml`;\n\n // Create nested directories if needed\n if (parts.length > 1) {\n const subDir = path.join(materializedDir, ...parts.slice(0, -1));\n if (!fs.existsSync(subDir)) {\n fs.mkdirSync(subDir, { recursive: true });\n }\n }\n\n const filePath = path.join(materializedDir, ...parts.slice(0, -1), fileName);\n\n // Convert to YAML format using the converter\n const yamlContent = PromptConverter.fromMaterializedToYaml(prompt);\n\n const yamlString = yaml.dump(yamlContent, {\n lineWidth: -1,\n noRefs: true,\n sortKeys: false\n });\n\n fs.writeFileSync(filePath, yamlString);\n return filePath;\n }\n\n static getLocalPromptFiles(): string[] {\n const promptsDir = this.getPromptsDir();\n const materializedDir = this.getMaterializedDir();\n\n if (!fs.existsSync(promptsDir)) {\n return [];\n }\n\n const files: string[] = [];\n\n const walkDir = (dir: string, relativePath = \"\"): void => {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n const relativeFilePath = path.join(relativePath, entry.name);\n\n if (entry.isDirectory()) {\n // Skip the .materialized directory\n if (fullPath === materializedDir) {\n continue;\n }\n walkDir(fullPath, relativeFilePath);\n } else if (entry.isFile() && entry.name.endsWith(\".prompt.yaml\")) {\n files.push(path.join(promptsDir, relativeFilePath));\n }\n }\n };\n\n walkDir(promptsDir);\n return files;\n }\n\n static promptNameFromPath(filePath: string): string {\n const promptsDir = this.getPromptsDir();\n const relativePath = path.relative(promptsDir, filePath);\n return relativePath.replace(/\\.prompt\\.yaml$/, \"\");\n }\n\n static cleanupOrphanedMaterializedFiles(currentDependencies: Set<string>): string[] {\n const materializedDir = this.getMaterializedDir();\n\n if (!fs.existsSync(materializedDir)) {\n return [];\n }\n\n const cleaned: string[] = [];\n\n const cleanupDir = (dir: string, relativePath = \"\"): void => {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n const relativeFilePath = path.join(relativePath, entry.name);\n\n if (entry.isDirectory()) {\n cleanupDir(fullPath, relativeFilePath);\n\n // Remove empty directories\n try {\n const dirEntries = fs.readdirSync(fullPath);\n if (dirEntries.length === 0) {\n fs.rmdirSync(fullPath);\n }\n } catch {\n // Directory not empty or other error, ignore\n }\n } else if (entry.isFile() && entry.name.endsWith(\".prompt.yaml\")) {\n // Extract prompt name from materialized file path\n const promptName = relativeFilePath.replace(/\\.prompt\\.yaml$/, \"\");\n\n if (!currentDependencies.has(promptName)) {\n fs.unlinkSync(fullPath);\n cleaned.push(promptName);\n }\n }\n }\n };\n\n cleanupDir(materializedDir);\n return cleaned;\n }\n\n static updateLockEntry(lock: PromptsLock, name: string, prompt: MaterializedPrompt, materializedPath: string): void {\n const relativePath = path.relative(process.cwd(), materializedPath);\n\n lock.prompts[name] = {\n version: prompt.version,\n versionId: prompt.versionId,\n materialized: relativePath,\n };\n }\n\n static removeFromLock(lock: PromptsLock, names: string[]): void {\n for (const name of names) {\n delete lock.prompts[name];\n }\n }\n\n static addToGitignore(entry: string): { added: boolean; existed: boolean } {\n const gitignorePath = path.join(process.cwd(), \".gitignore\");\n\n // Check if .gitignore exists\n if (!fs.existsSync(gitignorePath)) {\n // Create new .gitignore with the entry\n fs.writeFileSync(gitignorePath, `${entry}\\n`);\n return { added: true, existed: false };\n }\n\n // Read existing .gitignore\n const content = fs.readFileSync(gitignorePath, \"utf-8\");\n const lines = content.split(\"\\n\").map(line => line.trim());\n\n // Check if entry already exists\n if (lines.includes(entry)) {\n return { added: false, existed: true };\n }\n\n // Add entry to .gitignore\n const newContent = content.endsWith(\"\\n\") ? `${content}${entry}\\n` : `${content}\\n${entry}\\n`;\n fs.writeFileSync(gitignorePath, newContent);\n\n return { added: true, existed: false };\n }\n}\n"],"mappings":";;;;;;;;AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,OAAO,WAAW;AAKX,IAAM,cAAN,MAAkB;AAAA,EAMvB,OAAO,uBAA+B;AACpC,WAAY,UAAK,QAAQ,IAAI,GAAG,KAAK,mBAAmB;AAAA,EAC1D;AAAA,EAEA,OAAO,qBAA6B;AAClC,WAAY,UAAK,QAAQ,IAAI,GAAG,KAAK,iBAAiB;AAAA,EACxD;AAAA,EAEA,OAAO,gBAAwB;AAC7B,WAAY,UAAK,QAAQ,IAAI,GAAG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zF,IAAG,iBAAc,eAAe,UAAU;AAE1C,WAAO,EAAE,OAAO,MAAM,SAAS,MAAM;AAAA,EACvC;AACF;AArSa,YACa,sBAAsB;AADnC,YAEa,oBAAoB;AAFjC,YAGa,cAAc;AAH3B,YAIa,mBAAmB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-DISMHYXC.js","../src/logger/index.ts","../src/observability-sdk/semconv/attributes.ts","../src/observability-sdk/features/data-capture/utils.ts","../src/observability-sdk/config.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACcA,IAAM,cAAA,EAA0C;AAAA,EAC9C,KAAA,EAAO,CAAA;AAAA,EACP,IAAA,EAAM,CAAA;AAAA,EACN,IAAA,EAAM,CAAA;AAAA,EACN,KAAA,EAAO;AACT,CAAA;AASO,IAAM,WAAA,EAAN,MAAmC;AAAA,EACxC,KAAA,CAAA,EAAc;AAAA,EAAa;AAAA,EAC3B,IAAA,CAAA,EAAa;AAAA,EAAa;AAAA,EAC1B,IAAA,CAAA,EAAa;AAAA,EAAa;AAAA,EAC1B,KAAA,CAAA,EAAc;AAAA,EAAa;AAC7B,CAAA;AAWO,IAAM,cAAA,EAAN,MAAsC;AAAA,EAI3C,WAAA,CAAY,QAAA,EAAgC,EAAE,KAAA,EAAO,OAAO,CAAA,EAAG;AAC7D,IAAA,IAAA,CAAK,MAAA,EAAQ,OAAA,CAAQ,KAAA;AACrB,IAAA,IAAA,CAAK,OAAA,EAAS,OAAA,CAAQ,MAAA;AAAA,EACxB;AAAA,EAEQ,SAAA,CAAU,KAAA,EAA0B;AAC1C,IAAA,OAAO,aAAA,CAAc,KAAK,EAAA,GAAK,aAAA,CAAc,IAAA,CAAK,KAAK,CAAA;AAAA,EACzD;AAAA,EAEQ,MAAA,CAAO,OAAA,EAAyB;AACtC,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,CAAA,CAAA,EAAI,IAAA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B,EAAA;AAEO,EAAA;AACT;AAc8C;AACZ,EAAA;AACI,EAAA;AACtC;AAc+C;AACb,EAAA;AACK,EAAA;AACvC;AJ3DqD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-DISMHYXC.js","sourcesContent":[null,"// Logger utility for SDKs\n//\n// Usage:\n// - If you pass your own Logger implementation, the SDK will use it as-is (no log level filtering or prefixing applied).\n// - If you use ConsoleLogger, you can specify log level and prefix options.\n// - NoOpLogger disables all logging.\n//\n// Example:\n// const logger = new ConsoleLogger({ level: \"warn\", prefix: \"SDK\" });\n// logger.info(\"This will not show\");\n// logger.warn(\"This will show with prefix\");\n//\n// // If you pass your own logger, SDK will not filter logs:\n// const customLogger: Logger = { ... };\n// // SDK uses customLogger as-is\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst logLevelOrder: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n} as const;\n\nexport interface Logger {\n debug(message: string, ...args: unknown[]): void;\n info(message: string, ...args: unknown[]): void;\n warn(message: string, ...args: unknown[]): void;\n error(message: string, ...args: unknown[]): void;\n}\n\nexport class NoOpLogger implements Logger {\n debug(): void { /* noop */ }\n info(): void { /* noop */ }\n warn(): void { /* noop */ }\n error(): void { /* noop */ }\n}\n\ninterface ConsoleLoggerOptions {\n level: LogLevel;\n prefix?: string;\n}\n\n/**\n * ConsoleLogger applies log level filtering and optional prefixing.\n * If you pass your own Logger, the SDK will not apply log level filtering or prefixing.\n */\nexport class ConsoleLogger implements Logger {\n private level: LogLevel;\n private prefix?: string;\n\n constructor(options: ConsoleLoggerOptions = { level: \"warn\" }) {\n this.level = options.level;\n this.prefix = options.prefix;\n }\n\n private shouldLog(level: LogLevel): boolean {\n return logLevelOrder[level] >= logLevelOrder[this.level];\n }\n\n private format(message: string): string {\n return this.prefix ? `[${this.prefix}] ${message}` : message;\n }\n\n debug(message: string, ...args: unknown[]): void {\n if (this.shouldLog(\"debug\")) console.debug(this.format(message), ...args);\n }\n info(message: string, ...args: unknown[]): void {\n if (this.shouldLog(\"info\")) console.info(this.format(message), ...args);\n }\n warn(message: string, ...args: unknown[]): void {\n if (this.shouldLog(\"warn\")) console.warn(this.format(message), ...args);\n }\n error(message: string, ...args: unknown[]): void {\n if (this.shouldLog(\"error\")) console.error(this.format(message), ...args);\n }\n}\n","/*\n This file contains the semantic conventions for attributes either owned by LangWatch, or\n which are no yet part of the OpenTelemetry semantic conventions for Gen AI.\n\n Any that are not yet part of the OpenTelemetry semantic conventions for Gen AI are\n marked with an UNSTABLE_ prefix.\n*/\n\n/**\n * LangWatch input data attribute key\n * Used to store the input data for a span or event\n */\nexport const ATTR_LANGWATCH_INPUT = \"langwatch.input\";\n\n/**\n * LangWatch output data attribute key\n * Used to store the output data for a span or event\n */\nexport const ATTR_LANGWATCH_OUTPUT = \"langwatch.output\";\n\n/**\n * LangWatch span type attribute key\n * Used to identify the type of span being traced\n */\nexport const ATTR_LANGWATCH_SPAN_TYPE = \"langwatch.span.type\";\n\n/**\n * LangWatch RAG contexts attribute key\n * Used to store retrieval-augmented generation contexts\n */\nexport const ATTR_LANGWATCH_RAG_CONTEXTS = \"langwatch.contexts\";\n\n/**\n * LangWatch metrics attribute key\n * Used to store custom metrics data\n */\nexport const ATTR_LANGWATCH_METRICS = \"langwatch.metrics\";\n\n/**\n * LangWatch SDK version attribute key\n * Used to track the version of the LangWatch SDK being used\n */\nexport const ATTR_LANGWATCH_SDK_VERSION = \"langwatch.sdk.version\";\n\n/**\n * LangWatch SDK name attribute key\n * Used to identify the LangWatch SDK implementation\n */\nexport const ATTR_LANGWATCH_SDK_NAME = \"langwatch.sdk.name\";\n\n/**\n * LangWatch SDK language attribute key\n * Used to identify the programming language of the SDK\n */\nexport const ATTR_LANGWATCH_SDK_LANGUAGE = \"langwatch.sdk.language\";\n\n/**\n * LangWatch timestamps attribute key\n * Used to store timing information for events\n */\nexport const ATTR_LANGWATCH_TIMESTAMPS = \"langwatch.timestamps\";\n\n/**\n * LangWatch custom evaluation attribute key\n * Used to store custom evaluation data\n */\nexport const ATTR_LANGWATCH_EVALUATION_CUSTOM = \"langwatch.evaluation.custom\";\n\n/**\n * LangWatch parameters attribute key\n * Used to store parameter data for operations\n */\nexport const ATTR_LANGWATCH_PARAMS = \"langwatch.params\";\n\n/**\n * LangWatch customer ID attribute key\n * Used to identify the customer associated with the trace\n */\nexport const ATTR_LANGWATCH_CUSTOMER_ID = \"langwatch.customer.id\";\n\n/**\n * LangWatch thread ID attribute key\n * Used to group related operations within a conversation thread\n */\nexport const ATTR_LANGWATCH_THREAD_ID = \"langwatch.thread.id\";\n\n/**\n * LangWatch user ID attribute key\n * Used to store the user ID for a span or event\n */\nexport const ATTR_LANGWATCH_USER_ID = \"langwatch.user.id\";\n\n/**\n * LangWatch tags attribute key\n * Used to store tags for a span or event\n */\nexport const ATTR_LANGWATCH_TAGS = \"langwatch.tags\";\n\n/**\n * LangWatch streaming attribute key\n * Used to indicate if the operation involves streaming\n */\nexport const ATTR_LANGWATCH_STREAMING = \"langwatch.gen_ai.streaming\";\n\n/**\n * LangWatch prompt ID attribute key\n * Used to identify the specific prompt being used\n */\nexport const ATTR_LANGWATCH_PROMPT_ID = \"langwatch.prompt.id\";\n\n/**\n * LangWatch prompt ID attribute key\n * Used to identify the specific prompt being used\n */\nexport const ATTR_LANGWATCH_PROMPT_HANDLE = \"langwatch.prompt.handle\";\n\n/**\n * LangWatch prompt version ID attribute key\n * Used to identify the specific version of a prompt\n */\nexport const ATTR_LANGWATCH_PROMPT_VERSION_ID = \"langwatch.prompt.version.id\";\n\n/**\n * LangWatch prompt variables attribute key\n * Used to store variables used in prompt templates\n */\nexport const ATTR_LANGWATCH_PROMPT_VARIABLES = \"langwatch.prompt.variables\";\n\n/**\n * LangWatch prompt selected ID attribute key\n * Used to identify which prompt was selected from a set\n */\nexport const ATTR_LANGWATCH_PROMPT_SELECTED_ID = \"langwatch.prompt.selected.id\";\n\n/**\n * LangWatch prompt version number attribute key\n * Used to track the version number of a prompt\n */\nexport const ATTR_LANGWATCH_PROMPT_VERSION_NUMBER =\n \"langwatch.prompt.version.number\";\n\n/**\n * LangWatch LangChain tags attribute key\n * Used to store tags associated with LangChain operations\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_TAGS = \"langwatch.langchain.tags\";\n\n/**\n * LangWatch LangChain event name attribute key\n * Used to identify the specific LangChain event type\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_EVENT_NAME = \"langwatch.langchain.event_name\";\n\n/**\n * LangWatch LangChain run ID attribute key\n * Used to identify a specific LangChain run\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_RUN_ID = \"langwatch.langchain.run.id\";\n\n/**\n * LangWatch LangChain run tags attribute key\n * Used to store tags associated with a LangChain run\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_RUN_TAGS = \"langwatch.langchain.run.tags\";\n\n/**\n * LangWatch LangChain run type attribute key\n * Used to identify the type of LangChain run\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_RUN_TYPE = \"langwatch.langchain.run.type\";\n\n/**\n * LangWatch LangChain run metadata attribute key\n * Used to store metadata associated with a LangChain run\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_RUN_METADATA = \"langwatch.langchain.run.metadata\";\n\n/**\n * LangWatch LangChain run extra parameters attribute key\n * Used to store additional parameters for a LangChain run\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_RUN_EXTRA_PARAMS = \"langwatch.langchain.run.extra_params\";\n\n/**\n * LangWatch LangChain run parent ID attribute key\n * Used to identify the parent run in a hierarchical structure\n */\nexport const ATTR_LANGWATCH_LANGCHAIN_RUN_PARENT_ID =\n \"langwatch.langchain.run.parent.id\";\n","import { type DataCaptureMode } from \"./types\";\n\n/**\n * Validates a data capture mode.\n */\nexport function validateDataCaptureMode(mode: DataCaptureMode): boolean {\n return [\"none\", \"input\", \"output\", \"all\"].includes(mode);\n}\n","import { type Logger, NoOpLogger } from \"../logger/index.js\";\nimport {\n type DataCaptureMode,\n type DataCaptureContext,\n type DataCaptureOptions,\n} from \"./features/data-capture/types.js\";\nimport { validateDataCaptureMode } from \"./features/data-capture/utils.js\";\n\n/**\n * @module observability/config\n * @description\n * Provides configuration management for the LangWatch Observability SDK, including logger and data capture settings.\n *\n * @remarks\n * This module allows you to initialize, retrieve, and reset the global observability configuration. It also provides utilities for determining data capture behavior based on context and configuration.\n *\n * @see {@link ObservabilityConfig}\n * @see {@link initializeObservabilitySdkConfig}\n * @see {@link getObservabilitySdkConfig}\n * @see {@link resetObservabilitySdkConfig}\n * @see {@link getDataCaptureMode}\n * @see {@link shouldCaptureInput}\n * @see {@link shouldCaptureOutput}\n */\n/**\n * Configuration options for the LangWatch Observability SDK.\n *\n * @property logger - The logger instance to use for SDK logging.\n * @property dataCapture - Configuration for automatic data capture. Can be a string, function, or object.\n *\n * @example\n * ```ts\n * import { ObservabilityConfig, initializeObservabilitySdkConfig } from \"@langwatch/observability\";\n *\n * const config: ObservabilityConfig = {\n * logger: new ConsoleLogger(),\n * dataCapture: \"all\",\n * };\n *\n * initializeObservabilitySdkConfig(config);\n * ```\n */\nexport interface ObservabilityConfig {\n /**\n * The logger to use for the observability SDK.\n *\n * @default NoOpLogger\n */\n logger: Logger;\n\n /**\n * Configuration for automatic data capture.\n *\n * @default \"all\"\n */\n dataCapture?: DataCaptureOptions;\n}\n\n/**\n * The observability SDK config.\n */\nlet observabilitySdkConfig: ObservabilityConfig | null = null;\n\n/**\n * Initializes the global observability SDK configuration.\n *\n * @param config - The configuration object to use.\n *\n * @remarks\n * This function should be called once at application startup, before using any observability features.\n *\n * @warning\n * Calling this function will intentionally overwrite any existing configuration. This is by design to allow re-initialization in dynamic or testing environments. If you call this function multiple times, the most recent configuration will take effect.\n *\n * @example\n * ```ts\n * initializeObservabilitySdkConfig({ logger: new ConsoleLogger() });\n * ```\n */\nexport function initializeObservabilitySdkConfig(config: ObservabilityConfig) {\n observabilitySdkConfig = config;\n}\n\n/**\n * Resets the global observability SDK configuration to its initial state (`null`).\n *\n * @remarks\n * Useful for testing or re-initializing the SDK in dynamic environments.\n *\n * @example\n * ```ts\n * resetObservabilitySdkConfig();\n * ```\n */\nexport function resetObservabilitySdkConfig() {\n observabilitySdkConfig = null;\n}\n\n/**\n * Retrieves the current observability SDK configuration.\n *\n * @param options - Optional settings.\n * @param options.throwOnUninitialized - If true, throws an error if the config is not initialized. Defaults to `false` unless `NODE_ENV` is `development`.\n * @returns The current {@link ObservabilityConfig}.\n *\n * @throws {Error} If the config is uninitialized and `throwOnUninitialized` is true or in development mode.\n *\n * @example\n * ```ts\n * const config = getObservabilitySdkConfig();\n * ```\n */\nexport function getObservabilitySdkConfig(options?: {\n throwOnUninitialized?: boolean;\n}): ObservabilityConfig {\n if (!observabilitySdkConfig) {\n const message =\n \"[LangWatch Observability SDK] Please call setupObservability() before using the Observability SDK\";\n\n if (\n options?.throwOnUninitialized ||\n process.env.NODE_ENV === \"development\"\n ) {\n throw new Error(message);\n }\n\n // Use a default logger that can be configured\n return {\n logger: new NoOpLogger(),\n };\n }\n return observabilitySdkConfig;\n}\n\n/**\n * Gets the logger instance from the current observability SDK configuration.\n *\n * @returns The configured {@link Logger} instance.\n *\n * @example\n * ```ts\n * const logger = getObservabilitySdkLogger();\n * logger.info(\"Observability initialized\");\n * ```\n */\nexport function getObservabilitySdkLogger(): Logger {\n return getObservabilitySdkConfig().logger;\n}\n\n/**\n * Determines the effective data capture mode.\n *\n * @returns The resolved {@link DataCaptureMode} (\"all\", \"input\", or \"output\").\n *\n * @remarks\n * The mode is determined by the configuration, which can be a string, function, or object. Defaults to \"all\" if not specified.\n *\n * @example\n * ```ts\n * const mode = getDataCaptureMode();\n * ```\n */\nexport function getDataCaptureMode(): DataCaptureMode {\n const config = getObservabilitySdkConfig();\n\n if (!config.dataCapture) {\n return \"all\"; // Default: capture both input and output\n }\n\n // Handle different config formats\n if (typeof config.dataCapture === \"string\") {\n const validModes: DataCaptureMode[] = [\"none\", \"input\", \"output\", \"all\"];\n if (validModes.includes(config.dataCapture)) {\n return config.dataCapture;\n }\n\n\n getObservabilitySdkLogger().warn(\n `Invalid data capture mode: ${config.dataCapture}. Using default: \"all\"`,\n );\n\n return \"all\";\n }\n\n if (typeof config.dataCapture === \"object\" && config.dataCapture.mode &&validateDataCaptureMode(config.dataCapture.mode)) {\n return config.dataCapture.mode;\n }\n\n return \"all\"; // Default fallback\n}\n\n/**\n * Determines if input data should be captured.\n *\n * @returns `true` if input should be captured, otherwise `false`.\n *\n * @example\n * ```ts\n * if (shouldCaptureInput()) {\n * // Capture input\n * }\n * ```\n */\nexport function shouldCaptureInput(): boolean {\n const mode = getDataCaptureMode();\n return mode === \"input\" || mode === \"all\";\n}\n\n/**\n * Determines if output data should be captured.\n *\n * @returns `true` if output should be captured, otherwise `false`.\n *\n * @example\n * ```ts\n * if (shouldCaptureOutput()) {\n * // Capture output\n * }\n * ```\n */\nexport function shouldCaptureOutput(): boolean {\n const mode = getDataCaptureMode();\n return mode === \"output\" || mode === \"all\";\n}\n"]}