langwatch 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +19 -0
  2. package/dist/{add-4WXEWG5H.js → add-CGTO6GC2.js} +28 -32
  3. package/dist/add-CGTO6GC2.js.map +1 -0
  4. package/dist/{add-D2WVVKIP.mjs → add-XCI65PVN.mjs} +14 -18
  5. package/dist/add-XCI65PVN.mjs.map +1 -0
  6. package/dist/{chunk-P4SQTYGN.js → chunk-2GYC6KEA.js} +32 -32
  7. package/dist/{chunk-P4SQTYGN.js.map → chunk-2GYC6KEA.js.map} +1 -1
  8. package/dist/{chunk-CAZONSXV.js → chunk-36XAYVMC.js} +186 -76
  9. package/dist/chunk-36XAYVMC.js.map +1 -0
  10. package/dist/{chunk-ZIULPOMQ.mjs → chunk-3P4ROGZJ.mjs} +4 -4
  11. package/dist/{chunk-DLJO7AK5.mjs → chunk-AD7QRYIJ.mjs} +2 -2
  12. package/dist/{chunk-DISMHYXC.js → chunk-CKIZDPIJ.js} +24 -22
  13. package/dist/chunk-CKIZDPIJ.js.map +1 -0
  14. package/dist/{chunk-7OZKH5K2.js → chunk-DZH6SY3Z.js} +10 -10
  15. package/dist/{chunk-7OZKH5K2.js.map → chunk-DZH6SY3Z.js.map} +1 -1
  16. package/dist/{chunk-N2V6J3U2.mjs → chunk-FEL5FLHA.mjs} +2 -2
  17. package/dist/{chunk-H5PON53W.mjs → chunk-GAFUPYJ3.mjs} +334 -143
  18. package/dist/chunk-GAFUPYJ3.mjs.map +1 -0
  19. package/dist/{chunk-SVXNUWZI.js → chunk-HVW45GST.js} +345 -154
  20. package/dist/chunk-HVW45GST.js.map +1 -0
  21. package/dist/{chunk-YNQ44U6D.mjs → chunk-I2SOBPAF.mjs} +23 -21
  22. package/dist/chunk-I2SOBPAF.mjs.map +1 -0
  23. package/dist/{chunk-ECOC36EA.js → chunk-J7B7BNDN.js} +11 -11
  24. package/dist/{chunk-ECOC36EA.js.map → chunk-J7B7BNDN.js.map} +1 -1
  25. package/dist/{chunk-QZGTM76F.mjs → chunk-JPWKINZP.mjs} +2 -2
  26. package/dist/{chunk-OXBO24RB.js → chunk-OHM7JUMR.js} +15 -2
  27. package/dist/chunk-OHM7JUMR.js.map +1 -0
  28. package/dist/chunk-PYVDTUA6.mjs +352 -0
  29. package/dist/chunk-PYVDTUA6.mjs.map +1 -0
  30. package/dist/{chunk-YH5TIVK2.js → chunk-SNDTNU3T.js} +2 -2
  31. package/dist/{chunk-YH5TIVK2.js.map → chunk-SNDTNU3T.js.map} +1 -1
  32. package/dist/{chunk-CU3443HD.mjs → chunk-URTD2WOC.mjs} +14 -1
  33. package/dist/{chunk-YKFTFYKK.mjs → chunk-WOBPYIKO.mjs} +2 -2
  34. package/dist/chunk-WOBPYIKO.mjs.map +1 -0
  35. package/dist/{chunk-QCYYSMCU.js → chunk-Z3NTWVVA.js} +2 -2
  36. package/dist/chunk-Z3NTWVVA.js.map +1 -0
  37. package/dist/cli/index.js +8 -8
  38. package/dist/cli/index.mjs +8 -8
  39. package/dist/{create-OQEMO4MU.mjs → create-LXQB4EFB.mjs} +4 -5
  40. package/dist/{create-OQEMO4MU.mjs.map → create-LXQB4EFB.mjs.map} +1 -1
  41. package/dist/{create-4LG4N2A4.js → create-S5RDGF3H.js} +9 -10
  42. package/dist/create-S5RDGF3H.js.map +1 -0
  43. package/dist/{implementation-BIlL6-SW.d.ts → implementation-DsHp9FYU.d.ts} +1 -1
  44. package/dist/{implementation-fAgqv8OM.d.mts → implementation-nE9dgTwc.d.mts} +1 -1
  45. package/dist/{index-DTEZr0Jn.d.mts → index-D7rKIGrO.d.mts} +12 -12
  46. package/dist/{index-DTEZr0Jn.d.ts → index-D7rKIGrO.d.ts} +12 -12
  47. package/dist/index.d.mts +256 -11
  48. package/dist/index.d.ts +256 -11
  49. package/dist/index.js +135 -12
  50. package/dist/index.js.map +1 -1
  51. package/dist/index.mjs +133 -10
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/{init-MQXXHCNT.mjs → init-T4YDPHBA.mjs} +4 -5
  54. package/dist/{init-MQXXHCNT.mjs.map → init-T4YDPHBA.mjs.map} +1 -1
  55. package/dist/init-UADBKUJU.js +15 -0
  56. package/dist/init-UADBKUJU.js.map +1 -0
  57. package/dist/{list-GIAXAAH5.js → list-GRKVAGJS.js} +14 -15
  58. package/dist/list-GRKVAGJS.js.map +1 -0
  59. package/dist/{list-PFWV7IU6.mjs → list-XHXVFN24.mjs} +13 -14
  60. package/dist/list-XHXVFN24.mjs.map +1 -0
  61. package/dist/{login-3STX2FAO.js → login-4GWM5I6F.js} +4 -4
  62. package/dist/{login-3STX2FAO.js.map → login-4GWM5I6F.js.map} +1 -1
  63. package/dist/{login-BYLXS23I.mjs → login-EKE7SFN3.mjs} +3 -3
  64. package/dist/observability-sdk/index.d.mts +4 -3
  65. package/dist/observability-sdk/index.d.ts +4 -3
  66. package/dist/observability-sdk/index.js +7 -7
  67. package/dist/observability-sdk/index.mjs +6 -6
  68. package/dist/observability-sdk/instrumentation/langchain/index.d.mts +2 -1
  69. package/dist/observability-sdk/instrumentation/langchain/index.d.ts +2 -1
  70. package/dist/observability-sdk/instrumentation/langchain/index.js +19 -19
  71. package/dist/observability-sdk/instrumentation/langchain/index.mjs +3 -3
  72. package/dist/observability-sdk/setup/node/index.d.mts +1 -1
  73. package/dist/observability-sdk/setup/node/index.d.ts +1 -1
  74. package/dist/observability-sdk/setup/node/index.js +15 -15
  75. package/dist/observability-sdk/setup/node/index.mjs +4 -4
  76. package/dist/{remove-U3PILQDV.js → remove-7EXB2Z6R.js} +17 -18
  77. package/dist/remove-7EXB2Z6R.js.map +1 -0
  78. package/dist/{remove-FTF3EBYV.mjs → remove-W44FQ5MF.mjs} +9 -10
  79. package/dist/{remove-FTF3EBYV.mjs.map → remove-W44FQ5MF.mjs.map} +1 -1
  80. package/dist/{sync-T3T22GVZ.js → sync-V7WRMNJV.js} +31 -35
  81. package/dist/sync-V7WRMNJV.js.map +1 -0
  82. package/dist/{sync-FOW7DHAH.mjs → sync-XGFABFAW.mjs} +16 -20
  83. package/dist/sync-XGFABFAW.mjs.map +1 -0
  84. package/dist/{types-DyUmlaDx.d.ts → types-B9772cUR.d.ts} +98 -29
  85. package/dist/{types-jrEEZt9d.d.mts → types-DbPAi4US.d.mts} +98 -29
  86. package/package.json +4 -3
  87. package/dist/add-4WXEWG5H.js.map +0 -1
  88. package/dist/add-D2WVVKIP.mjs.map +0 -1
  89. package/dist/chunk-CAZONSXV.js.map +0 -1
  90. package/dist/chunk-CKVDNVFL.mjs +0 -242
  91. package/dist/chunk-CKVDNVFL.mjs.map +0 -1
  92. package/dist/chunk-DISMHYXC.js.map +0 -1
  93. package/dist/chunk-DSIQSULK.js +0 -152
  94. package/dist/chunk-DSIQSULK.js.map +0 -1
  95. package/dist/chunk-H5PON53W.mjs.map +0 -1
  96. package/dist/chunk-OXBO24RB.js.map +0 -1
  97. package/dist/chunk-QCYYSMCU.js.map +0 -1
  98. package/dist/chunk-R6FBJN7K.js +0 -115
  99. package/dist/chunk-R6FBJN7K.js.map +0 -1
  100. package/dist/chunk-SVXNUWZI.js.map +0 -1
  101. package/dist/chunk-V5M3HUBV.mjs +0 -115
  102. package/dist/chunk-V5M3HUBV.mjs.map +0 -1
  103. package/dist/chunk-YEGQXDTE.mjs +0 -152
  104. package/dist/chunk-YEGQXDTE.mjs.map +0 -1
  105. package/dist/chunk-YKFTFYKK.mjs.map +0 -1
  106. package/dist/chunk-YNQ44U6D.mjs.map +0 -1
  107. package/dist/create-4LG4N2A4.js.map +0 -1
  108. package/dist/init-EKNL2SQE.js +0 -16
  109. package/dist/init-EKNL2SQE.js.map +0 -1
  110. package/dist/list-GIAXAAH5.js.map +0 -1
  111. package/dist/list-PFWV7IU6.mjs.map +0 -1
  112. package/dist/remove-U3PILQDV.js.map +0 -1
  113. package/dist/sync-FOW7DHAH.mjs.map +0 -1
  114. package/dist/sync-T3T22GVZ.js.map +0 -1
  115. /package/dist/{chunk-ZIULPOMQ.mjs.map → chunk-3P4ROGZJ.mjs.map} +0 -0
  116. /package/dist/{chunk-DLJO7AK5.mjs.map → chunk-AD7QRYIJ.mjs.map} +0 -0
  117. /package/dist/{chunk-N2V6J3U2.mjs.map → chunk-FEL5FLHA.mjs.map} +0 -0
  118. /package/dist/{chunk-QZGTM76F.mjs.map → chunk-JPWKINZP.mjs.map} +0 -0
  119. /package/dist/{chunk-CU3443HD.mjs.map → chunk-URTD2WOC.mjs.map} +0 -0
  120. /package/dist/{login-BYLXS23I.mjs.map → login-EKE7SFN3.mjs.map} +0 -0
@@ -0,0 +1,352 @@
1
+ import {
2
+ localPromptConfigSchema
3
+ } from "./chunk-BTBSMJTY.mjs";
4
+
5
+ // src/cli/utils/promptConverter.ts
6
+ var PromptConverter = class {
7
+ /**
8
+ * Converts a Prompt instance from the API service to the MaterializedPrompt format
9
+ * used for saving to the .materialized directory.
10
+ */
11
+ static fromApiToMaterialized(prompt) {
12
+ return {
13
+ id: prompt.id,
14
+ name: prompt.name,
15
+ version: prompt.version,
16
+ versionId: prompt.versionId,
17
+ model: prompt.model,
18
+ messages: prompt.messages,
19
+ prompt: prompt.prompt,
20
+ temperature: prompt.temperature,
21
+ maxTokens: prompt.maxTokens,
22
+ inputs: prompt.inputs,
23
+ outputs: prompt.outputs,
24
+ updatedAt: prompt.updatedAt
25
+ };
26
+ }
27
+ /**
28
+ * Converts a MaterializedPrompt to the YAML content structure
29
+ * for saving to .prompt.yaml files.
30
+ */
31
+ static fromMaterializedToYaml(prompt) {
32
+ const result = {
33
+ model: prompt.model,
34
+ messages: prompt.messages
35
+ };
36
+ if (prompt.temperature !== void 0 || prompt.maxTokens !== void 0) {
37
+ result.modelParameters = {};
38
+ if (prompt.temperature !== void 0) {
39
+ result.modelParameters.temperature = prompt.temperature;
40
+ }
41
+ if (prompt.maxTokens !== void 0) {
42
+ result.modelParameters.maxTokens = prompt.maxTokens;
43
+ }
44
+ }
45
+ return result;
46
+ }
47
+ /**
48
+ * Converts a LocalPromptConfig (loaded from YAML) to the format
49
+ * expected by the API service for upserting.
50
+ */
51
+ static fromLocalToApiFormat(config) {
52
+ return {
53
+ model: config.model,
54
+ modelParameters: config.modelParameters,
55
+ messages: config.messages
56
+ };
57
+ }
58
+ /**
59
+ * Extracts the system prompt from messages array.
60
+ * Used when converting to API format that separates system prompt from messages.
61
+ */
62
+ static extractSystemPrompt(messages) {
63
+ var _a, _b;
64
+ return (_b = (_a = messages.find((m) => m.role === "system")) == null ? void 0 : _a.content) != null ? _b : "";
65
+ }
66
+ /**
67
+ * Filters out system messages from the messages array.
68
+ * Used when converting to API format that handles system prompt separately.
69
+ */
70
+ static filterNonSystemMessages(messages) {
71
+ return messages.filter((m) => m.role !== "system");
72
+ }
73
+ /**
74
+ * Converts version specification strings to actual version constraints.
75
+ * Handles npm-style version specs like "latest", "5", "^5", etc.
76
+ */
77
+ static parseVersionSpec(versionSpec) {
78
+ if (versionSpec === "latest") {
79
+ return { type: "latest", value: "latest" };
80
+ }
81
+ if (/^\d+$/.test(versionSpec)) {
82
+ return { type: "exact", value: versionSpec };
83
+ }
84
+ return { type: "tag", value: versionSpec };
85
+ }
86
+ /**
87
+ * Validates that a YAML config can be safely converted to API format.
88
+ * Returns validation errors if any, or null if valid.
89
+ */
90
+ static validateForApiConversion(config) {
91
+ var _a;
92
+ const errors = [];
93
+ if (!((_a = config.model) == null ? void 0 : _a.trim())) {
94
+ errors.push("Model is required and cannot be empty");
95
+ }
96
+ if (!config.messages || config.messages.length === 0) {
97
+ errors.push("At least one message is required");
98
+ }
99
+ if (config.messages) {
100
+ config.messages.forEach((message, index) => {
101
+ var _a2;
102
+ if (!["system", "user", "assistant"].includes(message.role)) {
103
+ errors.push(
104
+ `Message ${index}: role must be 'system', 'user', or 'assistant'`
105
+ );
106
+ }
107
+ if (!((_a2 = message.content) == null ? void 0 : _a2.trim())) {
108
+ errors.push(`Message ${index}: content cannot be empty`);
109
+ }
110
+ });
111
+ }
112
+ return errors;
113
+ }
114
+ };
115
+
116
+ // src/cli/utils/fileManager.ts
117
+ import * as fs from "fs";
118
+ import * as path from "path";
119
+ import * as yaml from "js-yaml";
120
+ import chalk from "chalk";
121
+ var _FileManager = class _FileManager {
122
+ static getPromptsConfigPath() {
123
+ return path.join(process.cwd(), this.PROMPTS_CONFIG_FILE);
124
+ }
125
+ static getPromptsLockPath() {
126
+ return path.join(process.cwd(), this.PROMPTS_LOCK_FILE);
127
+ }
128
+ static getPromptsDir() {
129
+ return path.join(process.cwd(), this.PROMPTS_DIR);
130
+ }
131
+ static getMaterializedDir() {
132
+ return path.join(this.getPromptsDir(), this.MATERIALIZED_DIR);
133
+ }
134
+ static ensureDirectories() {
135
+ const promptsDir = this.getPromptsDir();
136
+ const materializedDir = this.getMaterializedDir();
137
+ if (!fs.existsSync(promptsDir)) {
138
+ fs.mkdirSync(promptsDir, { recursive: true });
139
+ }
140
+ if (!fs.existsSync(materializedDir)) {
141
+ fs.mkdirSync(materializedDir, { recursive: true });
142
+ }
143
+ }
144
+ static loadPromptsConfig() {
145
+ const configPath = this.getPromptsConfigPath();
146
+ if (!fs.existsSync(configPath)) {
147
+ return { prompts: {} };
148
+ }
149
+ try {
150
+ const content = fs.readFileSync(configPath, "utf-8");
151
+ return JSON.parse(content);
152
+ } catch (error) {
153
+ throw new Error(`Failed to parse prompts.json: ${error instanceof Error ? error.message : "Unknown error"}`);
154
+ }
155
+ }
156
+ static savePromptsConfig(config) {
157
+ const configPath = this.getPromptsConfigPath();
158
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
159
+ }
160
+ static initializePromptsConfig() {
161
+ const configPath = this.getPromptsConfigPath();
162
+ const existed = fs.existsSync(configPath);
163
+ if (!existed) {
164
+ const emptyConfig = { prompts: {} };
165
+ this.savePromptsConfig(emptyConfig);
166
+ return { created: true, path: configPath };
167
+ }
168
+ return { created: false, path: configPath };
169
+ }
170
+ static savePromptsLock(lock) {
171
+ const lockPath = this.getPromptsLockPath();
172
+ fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2) + "\n");
173
+ }
174
+ static initializePromptsLock() {
175
+ const lockPath = this.getPromptsLockPath();
176
+ const existed = fs.existsSync(lockPath);
177
+ if (!existed) {
178
+ const emptyLock = {
179
+ lockfileVersion: 1,
180
+ prompts: {}
181
+ };
182
+ this.savePromptsLock(emptyLock);
183
+ return { created: true, path: lockPath };
184
+ }
185
+ return { created: false, path: lockPath };
186
+ }
187
+ static saveMaterializedPrompt(name, prompt) {
188
+ const materializedDir = this.getMaterializedDir();
189
+ const parts = name.split("/");
190
+ const fileName = `${parts[parts.length - 1]}.prompt.yaml`;
191
+ if (parts.length > 1) {
192
+ const subDir = path.join(materializedDir, ...parts.slice(0, -1));
193
+ if (!fs.existsSync(subDir)) {
194
+ fs.mkdirSync(subDir, { recursive: true });
195
+ }
196
+ }
197
+ const filePath = path.join(materializedDir, ...parts.slice(0, -1), fileName);
198
+ const yamlContent = PromptConverter.fromMaterializedToYaml(prompt);
199
+ const yamlString = yaml.dump(yamlContent, {
200
+ lineWidth: -1,
201
+ noRefs: true,
202
+ sortKeys: false
203
+ });
204
+ fs.writeFileSync(filePath, yamlString);
205
+ return filePath;
206
+ }
207
+ static promptNameFromPath(filePath) {
208
+ const promptsDir = this.getPromptsDir();
209
+ const relativePath = path.relative(promptsDir, filePath);
210
+ return relativePath.replace(/\.prompt\.yaml$/, "");
211
+ }
212
+ static cleanupOrphanedMaterializedFiles(currentDependencies) {
213
+ const materializedDir = this.getMaterializedDir();
214
+ if (!fs.existsSync(materializedDir)) {
215
+ return [];
216
+ }
217
+ const cleaned = [];
218
+ const cleanupDir = (dir, relativePath = "") => {
219
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
220
+ for (const entry of entries) {
221
+ const fullPath = path.join(dir, entry.name);
222
+ const relativeFilePath = path.join(relativePath, entry.name);
223
+ if (entry.isDirectory()) {
224
+ cleanupDir(fullPath, relativeFilePath);
225
+ try {
226
+ const dirEntries = fs.readdirSync(fullPath);
227
+ if (dirEntries.length === 0) {
228
+ fs.rmdirSync(fullPath);
229
+ }
230
+ } catch (e) {
231
+ }
232
+ } else if (entry.isFile() && entry.name.endsWith(".prompt.yaml")) {
233
+ const promptName = relativeFilePath.replace(/\.prompt\.yaml$/, "");
234
+ if (!currentDependencies.has(promptName)) {
235
+ fs.unlinkSync(fullPath);
236
+ cleaned.push(promptName);
237
+ }
238
+ }
239
+ }
240
+ };
241
+ cleanupDir(materializedDir);
242
+ return cleaned;
243
+ }
244
+ static updateLockEntry(lock, name, prompt, materializedPath) {
245
+ const relativePath = path.relative(process.cwd(), materializedPath);
246
+ lock.prompts[name] = {
247
+ version: prompt.version,
248
+ versionId: prompt.versionId,
249
+ materialized: relativePath
250
+ };
251
+ }
252
+ static removeFromLock(lock, names) {
253
+ for (const name of names) {
254
+ delete lock.prompts[name];
255
+ }
256
+ }
257
+ static addToGitignore(entry) {
258
+ const gitignorePath = path.join(process.cwd(), ".gitignore");
259
+ if (!fs.existsSync(gitignorePath)) {
260
+ fs.writeFileSync(gitignorePath, `${entry}
261
+ `);
262
+ return { added: true, existed: false };
263
+ }
264
+ const content = fs.readFileSync(gitignorePath, "utf-8");
265
+ const lines = content.split("\n").map((line) => line.trim());
266
+ if (lines.includes(entry)) {
267
+ return { added: false, existed: true };
268
+ }
269
+ const newContent = content.endsWith("\n") ? `${content}${entry}
270
+ ` : `${content}
271
+ ${entry}
272
+ `;
273
+ fs.writeFileSync(gitignorePath, newContent);
274
+ return { added: true, existed: false };
275
+ }
276
+ };
277
+ _FileManager.PROMPTS_CONFIG_FILE = "prompts.json";
278
+ _FileManager.PROMPTS_LOCK_FILE = "prompts-lock.json";
279
+ _FileManager.PROMPTS_DIR = "prompts";
280
+ _FileManager.MATERIALIZED_DIR = ".materialized";
281
+ _FileManager.loadPromptsLock = () => {
282
+ const lockPath = _FileManager.getPromptsLockPath();
283
+ if (!fs.existsSync(lockPath)) {
284
+ return {
285
+ lockfileVersion: 1,
286
+ prompts: {}
287
+ };
288
+ }
289
+ try {
290
+ const content = fs.readFileSync(lockPath, "utf-8");
291
+ return JSON.parse(content);
292
+ } catch (error) {
293
+ throw new Error(`Failed to parse prompts-lock.json: ${error instanceof Error ? error.message : "Unknown error"}`);
294
+ }
295
+ };
296
+ _FileManager.loadLocalPrompt = (filePath) => {
297
+ const fullPath = path.resolve(filePath);
298
+ if (!fs.existsSync(fullPath)) {
299
+ throw new Error(`Local prompt file not found: ${filePath}`);
300
+ }
301
+ try {
302
+ const content = fs.readFileSync(fullPath, "utf-8");
303
+ const rawData = yaml.load(content);
304
+ const result = localPromptConfigSchema.safeParse(rawData);
305
+ if (!result.success) {
306
+ const prettyError = result.error.issues.map((issue) => `\u2716 ${issue.message}${issue.path.length > 0 ? `
307
+ \u2192 at ${issue.path.join(".")}` : ""}`).join("\n");
308
+ throw new Error(
309
+ `Invalid prompt configuration in ${chalk.yellow(filePath)}:
310
+ ${prettyError}`
311
+ );
312
+ }
313
+ return result.data;
314
+ } catch (error) {
315
+ if (error instanceof Error && error.message.includes("Invalid prompt configuration")) {
316
+ throw error;
317
+ }
318
+ throw new Error(`Failed to parse local prompt file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
319
+ }
320
+ };
321
+ _FileManager.getLocalPromptFiles = () => {
322
+ const promptsDir = _FileManager.getPromptsDir();
323
+ const materializedDir = _FileManager.getMaterializedDir();
324
+ if (!fs.existsSync(promptsDir)) {
325
+ return [];
326
+ }
327
+ const files = [];
328
+ const walkDir = (dir, relativePath = "") => {
329
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
330
+ for (const entry of entries) {
331
+ const fullPath = path.join(dir, entry.name);
332
+ const relativeFilePath = path.join(relativePath, entry.name);
333
+ if (entry.isDirectory()) {
334
+ if (fullPath === materializedDir) {
335
+ continue;
336
+ }
337
+ walkDir(fullPath, relativeFilePath);
338
+ } else if (entry.isFile() && entry.name.endsWith(".prompt.yaml")) {
339
+ files.push(path.join(promptsDir, relativeFilePath));
340
+ }
341
+ }
342
+ };
343
+ walkDir(promptsDir);
344
+ return files;
345
+ };
346
+ var FileManager = _FileManager;
347
+
348
+ export {
349
+ PromptConverter,
350
+ FileManager
351
+ };
352
+ //# sourceMappingURL=chunk-PYVDTUA6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/utils/promptConverter.ts","../src/cli/utils/fileManager.ts"],"sourcesContent":["import type { LocalPromptConfig, MaterializedPrompt } from \"../types\";\nimport { type PromptResponse } from \"@/client-sdk/services/prompts/types\";\n\n/**\n * Converter utility for transforming between YAML prompt format and API service format.\n *\n * The YAML format follows the GitHub .prompt.yaml file format standard,\n * while the API format is our internal prompt service schema tied to the database.\n *\n * This separation allows us to maintain and evolve both formats independently\n * while keeping the conversion logic centralized and well-tested.\n */\nexport class PromptConverter {\n /**\n * Converts a Prompt instance from the API service to the MaterializedPrompt format\n * used for saving to the .materialized directory.\n */\n static fromApiToMaterialized(prompt: PromptResponse): MaterializedPrompt {\n return {\n id: prompt.id,\n name: prompt.name,\n version: prompt.version,\n versionId: prompt.versionId,\n model: prompt.model,\n messages: prompt.messages,\n prompt: prompt.prompt,\n temperature: prompt.temperature,\n maxTokens: prompt.maxTokens,\n inputs: prompt.inputs,\n outputs: prompt.outputs,\n updatedAt: prompt.updatedAt,\n };\n }\n\n /**\n * Converts a MaterializedPrompt to the YAML content structure\n * for saving to .prompt.yaml files.\n */\n static fromMaterializedToYaml(prompt: MaterializedPrompt): {\n model: string;\n modelParameters?: {\n temperature?: number;\n maxTokens?: number;\n };\n messages: Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>;\n } {\n const result: any = {\n model: prompt.model,\n messages: prompt.messages,\n };\n\n // Add modelParameters if temperature or maxTokens exist\n if (prompt.temperature !== undefined || prompt.maxTokens !== undefined) {\n result.modelParameters = {};\n if (prompt.temperature !== undefined) {\n result.modelParameters.temperature = prompt.temperature;\n }\n if (prompt.maxTokens !== undefined) {\n result.modelParameters.maxTokens = prompt.maxTokens;\n }\n }\n\n return result;\n }\n\n /**\n * Converts a LocalPromptConfig (loaded from YAML) to the format\n * expected by the API service for upserting.\n */\n static fromLocalToApiFormat(config: LocalPromptConfig): {\n model: string;\n modelParameters?: {\n temperature?: number;\n max_tokens?: number;\n };\n messages: Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>;\n } {\n return {\n model: config.model,\n modelParameters: config.modelParameters,\n messages: config.messages,\n };\n }\n\n /**\n * Extracts the system prompt from messages array.\n * Used when converting to API format that separates system prompt from messages.\n */\n static extractSystemPrompt(\n messages: Array<{ role: string; content: string }>,\n ): string {\n return messages.find((m) => m.role === \"system\")?.content ?? \"\";\n }\n\n /**\n * Filters out system messages from the messages array.\n * Used when converting to API format that handles system prompt separately.\n */\n static filterNonSystemMessages(\n messages: Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>,\n ): Array<{ role: \"user\" | \"assistant\"; content: string }> {\n return messages.filter((m) => m.role !== \"system\") as Array<{\n role: \"user\" | \"assistant\";\n content: string;\n }>;\n }\n\n /**\n * Converts version specification strings to actual version constraints.\n * Handles npm-style version specs like \"latest\", \"5\", \"^5\", etc.\n */\n static parseVersionSpec(versionSpec: string): {\n type: \"latest\" | \"exact\" | \"tag\";\n value: string;\n } {\n if (versionSpec === \"latest\") {\n return { type: \"latest\", value: \"latest\" };\n }\n\n // For now, treat everything else as tags until we implement proper semver\n if (/^\\d+$/.test(versionSpec)) {\n return { type: \"exact\", value: versionSpec };\n }\n\n // Handle prefixes like ^, ~, etc. as tags for now\n return { type: \"tag\", value: versionSpec };\n }\n\n /**\n * Validates that a YAML config can be safely converted to API format.\n * Returns validation errors if any, or null if valid.\n */\n static validateForApiConversion(config: LocalPromptConfig): string[] {\n const errors: string[] = [];\n\n if (!config.model?.trim()) {\n errors.push(\"Model is required and cannot be empty\");\n }\n\n if (!config.messages || config.messages.length === 0) {\n errors.push(\"At least one message is required\");\n }\n\n if (config.messages) {\n config.messages.forEach((message, index) => {\n if (![\"system\", \"user\", \"assistant\"].includes(message.role)) {\n errors.push(\n `Message ${index}: role must be 'system', 'user', or 'assistant'`,\n );\n }\n if (!message.content?.trim()) {\n errors.push(`Message ${index}: content cannot be empty`);\n }\n });\n }\n\n return errors;\n }\n}\n","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":";;;;;AAYO,IAAM,kBAAN,MAAsB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK3B,OAAO,sBAAsB,QAA4C;AACvE,WAAO;AAAA,MACL,IAAI,OAAO;AAAA,MACX,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,WAAW,OAAO;AAAA,MAClB,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,MACf,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,MAClB,QAAQ,OAAO;AAAA,MACf,SAAS,OAAO;AAAA,MAChB,WAAW,OAAO;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,uBAAuB,QAU5B;AACA,UAAM,SAAc;AAAA,MAClB,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,IACnB;AAGA,QAAI,OAAO,gBAAgB,UAAa,OAAO,cAAc,QAAW;AACtE,aAAO,kBAAkB,CAAC;AAC1B,UAAI,OAAO,gBAAgB,QAAW;AACpC,eAAO,gBAAgB,cAAc,OAAO;AAAA,MAC9C;AACA,UAAI,OAAO,cAAc,QAAW;AAClC,eAAO,gBAAgB,YAAY,OAAO;AAAA,MAC5C;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,qBAAqB,QAU1B;AACA,WAAO;AAAA,MACL,OAAO,OAAO;AAAA,MACd,iBAAiB,OAAO;AAAA,MACxB,UAAU,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,oBACL,UACQ;AAhGZ;AAiGI,YAAO,oBA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Aa,eAAY,KAAK,EAAE,eAAe,KAAK,CAAC;AAE3D,eAAW,SAAS,SAAS;AAC3B,YAAM,WAAgB,UAAK,KAAK,MAAM,IAAI;AAC1C,YAAM,mBAAwB,UAAK,cAAc,MAAM,IAAI;AAE3D,UAAI,MAAM,YAAY,GAAG;AAEvB,YAAI,aAAa,iBAAiB;AAChC;AAAA,QACF;AACA,gBAAQ,UAAU,gBAAgB;AAAA,MACpC,WAAW,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,cAAc,GAAG;AAChE,cAAM,KAAU,UAAK,YAAY,gBAAgB,CAAC;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAEA,UAAQ,UAAU;AAClB,SAAO;AACT;AAxMK,IAAM,cAAN;","names":["_a"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDISMHYXCjs = require('./chunk-DISMHYXC.js');
3
+ var _chunkCKIZDPIJjs = require('./chunk-CKIZDPIJ.js');
4
4
 
5
5
  // src/observability-sdk/processors/filterable-batch-span-processor.ts
6
6
 
@@ -72,4 +72,4 @@ var DataCapturePresets = {
72
72
 
73
73
 
74
74
  exports.FilterableBatchSpanProcessor = FilterableBatchSpanProcessor; exports.DataCapturePresets = DataCapturePresets;
75
- //# sourceMappingURL=chunk-YH5TIVK2.js.map
75
+ //# sourceMappingURL=chunk-SNDTNU3T.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-YH5TIVK2.js","../src/observability-sdk/processors/filterable-batch-span-processor.ts","../src/observability-sdk/features/data-capture/presets.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACKA;AACE;AAAA,6DAGK;AAsCA,IAAM,6BAAA,EAAN,MAAA,QAA2C,iCAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnE,WAAA,CAAY,QAAA,EAAwB,OAAA,EAAs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;AAAA,EAIhC,WAAA,EAAa,KAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAA,EAAc,MAAA;AAAA;AAAA;AAAA;AAAA,EAKd,UAAA,EAAY,OAAA;AAAA;AAAA;AAAA;AAAA,EAKZ,WAAA,EAAa;AACf,CAAA;AF4CA;AACA;AACE;AACA;AACF,qHAAC","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-YH5TIVK2.js","sourcesContent":[null,"/**\n * Filterable Batch Span Exporter for OpenTelemetry\n *\n * This module provides a BatchSpanProcessor subclass that allows filtering of spans before export\n * based on configurable rules. Spans matching any exclude rule are dropped and not exported.\n *\n * @module filterable-batch-span-exporter\n */\n\nimport {\n BatchSpanProcessor,\n type ReadableSpan,\n type SpanExporter,\n} from '@opentelemetry/sdk-trace-base';\n\n/**\n * A rule for excluding spans from export based on their name or instrumentation scope name.\n *\n * @property fieldName - The span field to match against ('span_name' or 'instrumentation_scope_name').\n * @property matchValue - The value to match against the field.\n * @property matchOperation - The operation to use for matching ('includes', 'exact_match', 'starts_with', 'ends_with').\n *\n * @example\n * const rule: SpanProcessingExcludeRule = {\n * fieldName: 'span_name',\n * matchValue: 'heartbeat',\n * matchOperation: 'exact_match',\n * };\n */\nexport interface SpanProcessingExcludeRule {\n fieldName: \"span_name\" | \"instrumentation_scope_name\";\n matchValue: string;\n matchOperation: \"includes\" | \"exact_match\" | \"starts_with\" | \"ends_with\";\n}\n\n/**\n * A BatchSpanProcessor that filters out spans matching any of the provided exclude rules before export.\n *\n * This is useful for dropping noisy or irrelevant spans (e.g., health checks, heartbeats) from being exported to your tracing backend.\n *\n * @example\n * import { FilterableBatchSpanProcessor } from './filterable-batch-span-exporter';\n * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\n *\n * const exporter = new OTLPTraceExporter({ url: '...' });\n * const filters = [\n * { fieldName: 'span_name', matchValue: 'heartbeat', matchOperation: 'exact_match' },\n * { fieldName: 'instrumentation_scope_name', matchValue: 'internal', matchOperation: 'starts_with' },\n * ];\n * provider.addSpanProcessor(new FilterableBatchSpanProcessor(exporter, filters));\n */\nexport class FilterableBatchSpanProcessor extends BatchSpanProcessor {\n private readonly _filters: SpanProcessingExcludeRule[];\n\n /**\n * Create a new FilterableBatchSpanProcessor.\n *\n * @param exporter - The underlying SpanExporter to use for exporting spans.\n * @param filters - An array of rules for excluding spans from export.\n */\n constructor(exporter: SpanExporter, filters: SpanProcessingExcludeRule[]) {\n super(exporter);\n this._filters = filters;\n }\n\n /**\n * Called when a span ends. If the span matches any exclude rule, it is dropped and not exported.\n *\n * @param span - The ReadableSpan that has ended.\n */\n override onEnd(span: ReadableSpan): void {\n for (const filter of this._filters) {\n let sourceValue: string;\n\n if (filter.fieldName === \"span_name\") {\n sourceValue = span.name;\n } else if (filter.fieldName === \"instrumentation_scope_name\") {\n sourceValue = span.instrumentationScope.name;\n } else {\n continue;\n }\n\n const matchValue = filter.matchValue;\n const matchOperation = filter.matchOperation;\n\n switch (true) {\n case matchOperation === \"exact_match\" && sourceValue === matchValue:\n case matchOperation === \"includes\" && sourceValue.includes(matchValue):\n case matchOperation === \"starts_with\" && sourceValue.startsWith(matchValue):\n case matchOperation === \"ends_with\" && sourceValue.endsWith(matchValue):\n return;\n\n default: break;\n }\n }\n\n super.onEnd(span);\n }\n}\n","import { type DataCaptureMode } from \"./types\";\n\n/**\n * Predefined data capture configurations for common use cases.\n */\nexport const DataCapturePresets = {\n /**\n * Capture both input and output - useful for development and debugging.\n */\n CAPTURE_ALL: \"all\" as DataCaptureMode,\n\n /**\n * Capture nothing - useful for high-security environments.\n */\n CAPTURE_NONE: \"none\" as DataCaptureMode,\n\n /**\n * Capture only inputs - useful when you want to see what's being sent.\n */\n INPUT_ONLY: \"input\" as DataCaptureMode,\n\n /**\n * Capture only outputs - useful when you want to see responses.\n */\n OUTPUT_ONLY: \"output\" as DataCaptureMode,\n} as const;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-SNDTNU3T.js","../src/observability-sdk/processors/filterable-batch-span-processor.ts","../src/observability-sdk/features/data-capture/presets.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACKA;AACE;AAAA,6DAGK;AAsCA,IAAM,6BAAA,EAAN,MAAA,QAA2C,iCAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnE,WAAA,CAAY,QAAA,EAAwB,OAAA,EAAsC;AACxE,IAAA,KAAA,CAAM,QAAQ,CAAA;AACd,IAAA,IAAA,CAAK,SAAA,EAAW,OAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOS,KAAA,CAAM,IAAA,EAA0B;AACvC,IAAA,IAAA,CAAA,MAAW,OAAA,GAAU,IAAA,CAAK,QAAA,EAAU;AAClC,MAAA,IAAI,WAAA;AAEJ,MAAA,GAAA,CAAI,MAAA,CAAO,UAAA,IAAc,WAAA,EAAa;AACpC,QAAA,YAAA,EAAc,IAAA,CAAK,IAAA;AAAA,MACrB,EAAA,KAAA,GAAA,CAAW,MAAA,CAAO,UAAA,IAAc,4BAAA,EAA8B;AAC5D,QAAA,YAAA,EAAc,IAAA,CAAK,oBAAA,CAAqB,IAAA;AAAA,MAC1C,EAAA,KAAO;AACL,QAAA,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,WAAA,EAAa,MAAA,CAAO,UAAA;AAC1B,MAAA,MAAM,eAAA,EAAiB,MAAA,CAAO,cAAA;AAE9B,MAAA,OAAA,CAAQ,IAAA,EAAM;AAAA,QACZ,KAAA,CAAK,eAAA,IAAmB,cAAA,GAAiB,YAAA,IAAgB,UAAA,CAAA;AAAA,QACzD,KAAA,CAAK,eAAA,IAAmB,WAAA,GAAc,WAAA,CAAY,QAAA,CAAS,UAAU,CAAA,CAAA;AAAA,QACrE,KAAA,CAAK,eAAA,IAAmB,cAAA,GAAiB,WAAA,CAAY,UAAA,CAAW,UAAU,CAAA,CAAA;AAAA,QAC1E,KAAA,CAAK,eAAA,IAAmB,YAAA,GAAe,WAAA,CAAY,QAAA,CAAS,UAAU,CAAA,CAAA;AACpE,UAAA,MAAA;AAAA,QAEF,OAAA;AAAS,UAAA,KAAA;AAAA,MACX;AAAA,IACF;AAEA,IAAA,KAAA,CAAM,KAAA,CAAM,IAAI,CAAA;AAAA,EAClB;AACF,CAAA;ADjDA;AACA;AE7CO,IAAM,mBAAA,EAAqB;AAAA;AAAA;AAAA;AAAA,EAIhC,WAAA,EAAa,KAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAA,EAAc,MAAA;AAAA;AAAA;AAAA;AAAA,EAKd,UAAA,EAAY,OAAA;AAAA;AAAA;AAAA;AAAA,EAKZ,WAAA,EAAa;AACf,CAAA;AF4CA;AACA;AACE;AACA;AACF,qHAAC","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-SNDTNU3T.js","sourcesContent":[null,"/**\n * Filterable Batch Span Exporter for OpenTelemetry\n *\n * This module provides a BatchSpanProcessor subclass that allows filtering of spans before export\n * based on configurable rules. Spans matching any exclude rule are dropped and not exported.\n *\n * @module filterable-batch-span-exporter\n */\n\nimport {\n BatchSpanProcessor,\n type ReadableSpan,\n type SpanExporter,\n} from '@opentelemetry/sdk-trace-base';\n\n/**\n * A rule for excluding spans from export based on their name or instrumentation scope name.\n *\n * @property fieldName - The span field to match against ('span_name' or 'instrumentation_scope_name').\n * @property matchValue - The value to match against the field.\n * @property matchOperation - The operation to use for matching ('includes', 'exact_match', 'starts_with', 'ends_with').\n *\n * @example\n * const rule: SpanProcessingExcludeRule = {\n * fieldName: 'span_name',\n * matchValue: 'heartbeat',\n * matchOperation: 'exact_match',\n * };\n */\nexport interface SpanProcessingExcludeRule {\n fieldName: \"span_name\" | \"instrumentation_scope_name\";\n matchValue: string;\n matchOperation: \"includes\" | \"exact_match\" | \"starts_with\" | \"ends_with\";\n}\n\n/**\n * A BatchSpanProcessor that filters out spans matching any of the provided exclude rules before export.\n *\n * This is useful for dropping noisy or irrelevant spans (e.g., health checks, heartbeats) from being exported to your tracing backend.\n *\n * @example\n * import { FilterableBatchSpanProcessor } from './filterable-batch-span-exporter';\n * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\n *\n * const exporter = new OTLPTraceExporter({ url: '...' });\n * const filters = [\n * { fieldName: 'span_name', matchValue: 'heartbeat', matchOperation: 'exact_match' },\n * { fieldName: 'instrumentation_scope_name', matchValue: 'internal', matchOperation: 'starts_with' },\n * ];\n * provider.addSpanProcessor(new FilterableBatchSpanProcessor(exporter, filters));\n */\nexport class FilterableBatchSpanProcessor extends BatchSpanProcessor {\n private readonly _filters: SpanProcessingExcludeRule[];\n\n /**\n * Create a new FilterableBatchSpanProcessor.\n *\n * @param exporter - The underlying SpanExporter to use for exporting spans.\n * @param filters - An array of rules for excluding spans from export.\n */\n constructor(exporter: SpanExporter, filters: SpanProcessingExcludeRule[]) {\n super(exporter);\n this._filters = filters;\n }\n\n /**\n * Called when a span ends. If the span matches any exclude rule, it is dropped and not exported.\n *\n * @param span - The ReadableSpan that has ended.\n */\n override onEnd(span: ReadableSpan): void {\n for (const filter of this._filters) {\n let sourceValue: string;\n\n if (filter.fieldName === \"span_name\") {\n sourceValue = span.name;\n } else if (filter.fieldName === \"instrumentation_scope_name\") {\n sourceValue = span.instrumentationScope.name;\n } else {\n continue;\n }\n\n const matchValue = filter.matchValue;\n const matchOperation = filter.matchOperation;\n\n switch (true) {\n case matchOperation === \"exact_match\" && sourceValue === matchValue:\n case matchOperation === \"includes\" && sourceValue.includes(matchValue):\n case matchOperation === \"starts_with\" && sourceValue.startsWith(matchValue):\n case matchOperation === \"ends_with\" && sourceValue.endsWith(matchValue):\n return;\n\n default: break;\n }\n }\n\n super.onEnd(span);\n }\n}\n","import { type DataCaptureMode } from \"./types\";\n\n/**\n * Predefined data capture configurations for common use cases.\n */\nexport const DataCapturePresets = {\n /**\n * Capture both input and output - useful for development and debugging.\n */\n CAPTURE_ALL: \"all\" as DataCaptureMode,\n\n /**\n * Capture nothing - useful for high-security environments.\n */\n CAPTURE_NONE: \"none\" as DataCaptureMode,\n\n /**\n * Capture only inputs - useful when you want to see what's being sent.\n */\n INPUT_ONLY: \"input\" as DataCaptureMode,\n\n /**\n * Capture only outputs - useful when you want to see responses.\n */\n OUTPUT_ONLY: \"output\" as DataCaptureMode,\n} as const;\n"]}
@@ -20,6 +20,18 @@ var __spreadValues = (a, b) => {
20
20
  return a;
21
21
  };
22
22
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
23
35
  var __export = (target, all) => {
24
36
  for (var name in all)
25
37
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -33,10 +45,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
33
45
  export {
34
46
  __spreadValues,
35
47
  __spreadProps,
48
+ __objRest,
36
49
  __export,
37
50
  __privateGet,
38
51
  __privateAdd,
39
52
  __privateSet,
40
53
  __privateMethod
41
54
  };
42
- //# sourceMappingURL=chunk-CU3443HD.mjs.map
55
+ //# sourceMappingURL=chunk-URTD2WOC.mjs.map
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.5.1";
2
+ var version = "0.6.0";
3
3
 
4
4
  // src/internal/runtime.ts
5
5
  var _runtime;
@@ -60,4 +60,4 @@ export {
60
60
  TRACES_PATH,
61
61
  LOGS_PATH
62
62
  };
63
- //# sourceMappingURL=chunk-YKFTFYKK.mjs.map
63
+ //# sourceMappingURL=chunk-WOBPYIKO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/internal/runtime.ts","../src/internal/constants.ts"],"sourcesContent":["{\n \"name\": \"langwatch\",\n \"version\": \"0.6.0\",\n \"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\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"author\": \"LangWatch\",\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=20\",\n \"pnpm\": \">=8\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"bin\": {\n \"langwatch\": \"./dist/cli/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./observability\": {\n \"types\": \"./dist/observability-sdk/index.d.ts\",\n \"require\": \"./dist/observability-sdk/index.js\",\n \"import\": \"./dist/observability-sdk/index.mjs\"\n },\n \"./observability/node\": {\n \"types\": \"./dist/observability-sdk/setup/node/index.d.ts\",\n \"require\": \"./dist/observability-sdk/setup/node/index.js\",\n \"import\": \"./dist/observability-sdk/setup/node/index.mjs\"\n },\n \"./observability/instrumentation/langchain\": {\n \"types\": \"./dist/observability-sdk/instrumentation/langchain/index.d.ts\",\n \"require\": \"./dist/observability-sdk/instrumentation/langchain/index.js\",\n \"import\": \"./dist/observability-sdk/instrumentation/langchain/index.mjs\"\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/langwatch/langwatch.git\",\n \"directory\": \"typescript-sdk\"\n },\n \"scripts\": {\n \"prepare\": \"pnpm run generate:server-types && pnpm run generate:openapi-types\",\n \"cli\": \"node dist/cli/index.js\",\n \"lint\": \"eslint .\",\n \"test\": \"vitest\",\n \"test:e2e\": \"vitest run -c ./vitest.e2e.config.mts\",\n \"prebuild\": \"pnpm i && pnpm run prepare\",\n \"build\": \"tsc --noEmit && tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublish\": \"pnpm run build\",\n \"generate:openapi-types\": \"npx openapi-typescript ../langwatch/src/app/api/openapiLangWatch.json -o ./src/internal/generated/openapi/api-client.ts\",\n \"generate:server-types\": \"./copy-types.sh\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.32.0\",\n \"@opentelemetry/sdk-node\": \">=0.203.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-web\": \">=2.0.1\",\n \"@types/debug\": \"^4.1.12\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.1.0\",\n \"@typescript/native-preview\": \"7.0.0-dev.20250804.1\",\n \"@vercel/otel\": \"^1.13.0\",\n \"@vitest/coverage-v8\": \"3.2.4\",\n \"esbuild\": \"^0.25.8\",\n \"eslint\": \"^9.32.0\",\n \"fets\": \"^0.8.5\",\n \"fishery\": \"^2.3.1\",\n \"msw\": \"^2.10.4\",\n \"nock\": \"^14.0.8\",\n \"openapi-msw\": \"^1.2.0\",\n \"ts-to-zod\": \"3.15.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.9.2\",\n \"typescript-eslint\": \"^8.38.0\",\n \"vitest\": \"^3.2.4\",\n \"vitest-mock-extended\": \"^3.1.0\",\n \"yaml\": \"^2.8.1\"\n },\n \"dependencies\": {\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"0.203.0\",\n \"@opentelemetry/core\": \"^2.0.1\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"0.203.0\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"0.203.0\",\n \"@opentelemetry/instrumentation\": \"0.203.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-logs\": \"0.203.0\",\n \"@opentelemetry/sdk-metrics\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-base\": \"^2.0.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.36.0\",\n \"@types/prompts\": \"^2.4.9\",\n \"chalk\": \"^4.1.2\",\n \"commander\": \"^12.0.0\",\n \"dotenv\": \"^16.6.1\",\n \"js-yaml\": \"^4.1.0\",\n \"liquidjs\": \"^10.21.1\",\n \"open\": \"^10.2.0\",\n \"openapi-fetch\": \"^0.14.0\",\n \"ora\": \"^5.4.1\",\n \"prompts\": \"^2.4.2\",\n \"xksuid\": \"^0.0.4\",\n \"zod\": \"^4.0.14\"\n },\n \"peerDependencies\": {\n \"@ai-sdk/openai\": \">=2.0.0 <3.0.0\",\n \"@langchain/core\": \">=0.3.0 <1.0.0\",\n \"@langchain/langgraph\": \">=0.4.0 <1.0.0\",\n \"@langchain/openai\": \">=0.6.0 <1.0.0\",\n \"@opentelemetry/context-async-hooks\": \">=1.19.0 <3.0.0\",\n \"@opentelemetry/context-zone\": \">=1.19.0 <3.0.0\",\n \"@opentelemetry/sdk-node\": \">=0.200.0 <1.0.0\",\n \"@opentelemetry/sdk-trace-web\": \">=1.19.0 <3.0.0\",\n \"langchain\": \">=0.3.0 <1.0.0\"\n }\n}\n","export type JsRuntime = \"node\" | \"deno\" | \"bun\" | \"web\" | \"unknown\";\n\nlet _runtime: JsRuntime | undefined;\n\n/**\n * Gets the cached JavaScript runtime environment.\n * @returns The detected runtime environment\n */\nexport const getRuntime = (): JsRuntime => {\n _runtime ??= detectRuntime();\n return _runtime;\n};\n\n/**\n * Resets the cached runtime. Only used for testing.\n * @internal\n */\nexport const resetRuntimeCache = (): void => {\n _runtime = undefined;\n};\n\n/**\n * Detects the JavaScript runtime environment.\n * @param globals - (Test only) Optionally override the global object for environment simulation. Only used if NODE_ENV === 'test'.\n */\nexport function detectRuntime(globals?: any): JsRuntime {\n let g = globalThis;\n if (globals) {\n if (process.env.NODE_ENV === \"test\") {\n g = globals;\n } else {\n console.warn(\"[LangWatch Observability] overriding detectRuntime is only supported when running in NODE_ENV=test\");\n }\n }\n\n try {\n if (\n \"Deno\" in g &&\n typeof g.Deno === \"object\" &&\n g.Deno &&\n 'version' in g.Deno &&\n typeof g.Deno.version === \"object\"\n ) {\n return \"deno\";\n }\n if (\n \"Bun\" in g &&\n typeof g.Bun === \"object\" &&\n g.Bun &&\n 'version' in g.Bun &&\n typeof g.Bun.version === \"string\"\n ) {\n return \"bun\";\n }\n if (\n \"process\" in g &&\n typeof g.process === \"object\" &&\n g.process &&\n typeof g.process.versions === \"object\" &&\n typeof g.process.versions.node === \"string\"\n ) {\n return \"node\";\n }\n if (\n typeof g.window?.document !== \"undefined\" &&\n g === g.window\n ) {\n return \"web\";\n }\n return \"unknown\";\n } catch (error) {\n console.warn(\"[LangWatch Observability] Failed to detect runtime\", error);\n return \"unknown\";\n }\n}\n","import { version } from \"../../package.json\";\nimport { getRuntime } from \"./runtime\";\n\nexport const LANGWATCH_SDK_RUNTIME = getRuntime;\n\nexport const LANGWATCH_SDK_NAME_OBSERVABILITY = \"langwatch-observability-sdk\";\nexport const LANGWATCH_SDK_NAME_CLIENT = \"langwatch-client-sdk\";\nexport const LANGWATCH_SDK_LANGUAGE = \"typescript\";\nexport const LANGWATCH_SDK_VERSION = version;\n\nexport const DEFAULT_ENDPOINT = \"https://app.langwatch.ai/\";\nexport const DEFAULT_SERVICE_NAME = \"unknown-service.langwatch\";\n\nexport const TRACES_PATH = \"/api/otel/v1/traces\";\nexport const LOGS_PATH = \"/api/otel/v1/logs\";\nexport const METRICS_PATH = \"/api/otel/v1/metrics\";\n"],"mappings":";AAEI,cAAW;;;ACAf,IAAI;AAMG,IAAM,aAAa,MAAiB;AACzC,2CAAa,cAAc;AAC3B,SAAO;AACT;AAcO,SAAS,cAAc,SAA0B;AAzBxD;AA0BE,MAAI,IAAI;AACR,MAAI,SAAS;AACX,QAAI,QAAQ,IAAI,aAAa,QAAQ;AACnC,UAAI;AAAA,IACN,OAAO;AACL,cAAQ,KAAK,oGAAoG;AAAA,IACnH;AAAA,EACF;AAEA,MAAI;AACF,QACE,UAAU,KACV,OAAO,EAAE,SAAS,YAClB,EAAE,QACF,aAAa,EAAE,QACf,OAAO,EAAE,KAAK,YAAY,UAC1B;AACA,aAAO;AAAA,IACT;AACA,QACE,SAAS,KACT,OAAO,EAAE,QAAQ,YACjB,EAAE,OACF,aAAa,EAAE,OACf,OAAO,EAAE,IAAI,YAAY,UACzB;AACA,aAAO;AAAA,IACT;AACA,QACE,aAAa,KACb,OAAO,EAAE,YAAY,YACrB,EAAE,WACF,OAAO,EAAE,QAAQ,aAAa,YAC9B,OAAO,EAAE,QAAQ,SAAS,SAAS,UACnC;AACA,aAAO;AAAA,IACT;AACA,QACE,SAAO,OAAE,WAAF,mBAAU,cAAa,eAC9B,MAAM,EAAE,QACR;AACA,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,KAAK,sDAAsD,KAAK;AACxE,WAAO;AAAA,EACT;AACF;;;ACvEO,IAAM,wBAAwB;AAE9B,IAAM,mCAAmC;AACzC,IAAM,4BAA4B;AAClC,IAAM,yBAAyB;AAC/B,IAAM,wBAAwB;AAE9B,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAE7B,IAAM,cAAc;AACpB,IAAM,YAAY;","names":[]}
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// package.json
2
- var version = "0.5.1";
2
+ var version = "0.6.0";
3
3
 
4
4
  // src/internal/runtime.ts
5
5
  var _runtime;
@@ -60,4 +60,4 @@ var LOGS_PATH = "/api/otel/v1/logs";
60
60
 
61
61
 
62
62
  exports.version = version; exports.LANGWATCH_SDK_RUNTIME = LANGWATCH_SDK_RUNTIME; exports.LANGWATCH_SDK_NAME_OBSERVABILITY = LANGWATCH_SDK_NAME_OBSERVABILITY; exports.LANGWATCH_SDK_NAME_CLIENT = LANGWATCH_SDK_NAME_CLIENT; exports.LANGWATCH_SDK_LANGUAGE = LANGWATCH_SDK_LANGUAGE; exports.LANGWATCH_SDK_VERSION = LANGWATCH_SDK_VERSION; exports.DEFAULT_ENDPOINT = DEFAULT_ENDPOINT; exports.DEFAULT_SERVICE_NAME = DEFAULT_SERVICE_NAME; exports.TRACES_PATH = TRACES_PATH; exports.LOGS_PATH = LOGS_PATH;
63
- //# sourceMappingURL=chunk-QCYYSMCU.js.map
63
+ //# sourceMappingURL=chunk-Z3NTWVVA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-Z3NTWVVA.js","../package.json","../src/internal/runtime.ts","../src/internal/constants.ts"],"names":[],"mappings":"AAAA;ACEI,IAAA,QAAA,EAAW,OAAA;ADAf;AACA;AEDA,IAAI,QAAA;AAMG,IAAM,WAAA,EAAa,CAAA,EAAA,GAAiB;AACzC,EAAA,SAAA,GAAA,KAAA,EAAA,SAAA,EAAA,SAAA,EAAa,aAAA,CAAc,CAAA;AAC3B,EAAA,OAAO,QAAA;AACT,CAAA;AAcO,SAAS,aAAA,CAAc,OAAA,EAA0B;AAzBxD,EAAA,IAAA,EAAA;AA0BE,EAAA,IAAI,EAAA,EAAI,UAAA;AACR,EAAA,GAAA,CAAI,OAAA,EAAS;AACX,IAAA,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,SAAA,IAAa,MAAA,EAAQ;AACnC,MAAA,EAAA,EAAI,OAAA;AAAA,IACN,EAAA,KAAO;AACL,MAAA,OAAA,CAAQ,IAAA,CAAK,oGAAoG,CAAA;AAAA,IACnH;AAAA,EACF;AAEA,EAAA,IAAI;AACF,IAAA,GAAA,CACE,OAAA,GAAU,EAAA,GACV,OAAO,CAAA,CAAE,KAAA,IAAS,SAAA,GAClB,CAAA,CAAE,KAAA,GACF,UAAA,GAAa,CAAA,CAAE,KAAA,GACf,OAAO,CAAA,CAAE,IAAA,CAAK,QAAA,IAAY,QAAA,EAC1B;AACA,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,GAAA,CACE,MAAA,GAAS,E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F,ifAAC","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/chunk-Z3NTWVVA.js","sourcesContent":[null,"{\n \"name\": \"langwatch\",\n \"version\": \"0.6.0\",\n \"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\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"author\": \"LangWatch\",\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=20\",\n \"pnpm\": \">=8\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"bin\": {\n \"langwatch\": \"./dist/cli/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./observability\": {\n \"types\": \"./dist/observability-sdk/index.d.ts\",\n \"require\": \"./dist/observability-sdk/index.js\",\n \"import\": \"./dist/observability-sdk/index.mjs\"\n },\n \"./observability/node\": {\n \"types\": \"./dist/observability-sdk/setup/node/index.d.ts\",\n \"require\": \"./dist/observability-sdk/setup/node/index.js\",\n \"import\": \"./dist/observability-sdk/setup/node/index.mjs\"\n },\n \"./observability/instrumentation/langchain\": {\n \"types\": \"./dist/observability-sdk/instrumentation/langchain/index.d.ts\",\n \"require\": \"./dist/observability-sdk/instrumentation/langchain/index.js\",\n \"import\": \"./dist/observability-sdk/instrumentation/langchain/index.mjs\"\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/langwatch/langwatch.git\",\n \"directory\": \"typescript-sdk\"\n },\n \"scripts\": {\n \"prepare\": \"pnpm run generate:server-types && pnpm run generate:openapi-types\",\n \"cli\": \"node dist/cli/index.js\",\n \"lint\": \"eslint .\",\n \"test\": \"vitest\",\n \"test:e2e\": \"vitest run -c ./vitest.e2e.config.mts\",\n \"prebuild\": \"pnpm i && pnpm run prepare\",\n \"build\": \"tsc --noEmit && tsup\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublish\": \"pnpm run build\",\n \"generate:openapi-types\": \"npx openapi-typescript ../langwatch/src/app/api/openapiLangWatch.json -o ./src/internal/generated/openapi/api-client.ts\",\n \"generate:server-types\": \"./copy-types.sh\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.32.0\",\n \"@opentelemetry/sdk-node\": \">=0.203.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-web\": \">=2.0.1\",\n \"@types/debug\": \"^4.1.12\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.1.0\",\n \"@typescript/native-preview\": \"7.0.0-dev.20250804.1\",\n \"@vercel/otel\": \"^1.13.0\",\n \"@vitest/coverage-v8\": \"3.2.4\",\n \"esbuild\": \"^0.25.8\",\n \"eslint\": \"^9.32.0\",\n \"fets\": \"^0.8.5\",\n \"fishery\": \"^2.3.1\",\n \"msw\": \"^2.10.4\",\n \"nock\": \"^14.0.8\",\n \"openapi-msw\": \"^1.2.0\",\n \"ts-to-zod\": \"3.15.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.9.2\",\n \"typescript-eslint\": \"^8.38.0\",\n \"vitest\": \"^3.2.4\",\n \"vitest-mock-extended\": \"^3.1.0\",\n \"yaml\": \"^2.8.1\"\n },\n \"dependencies\": {\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"0.203.0\",\n \"@opentelemetry/core\": \"^2.0.1\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"0.203.0\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"0.203.0\",\n \"@opentelemetry/instrumentation\": \"0.203.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-logs\": \"0.203.0\",\n \"@opentelemetry/sdk-metrics\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-base\": \"^2.0.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.36.0\",\n \"@types/prompts\": \"^2.4.9\",\n \"chalk\": \"^4.1.2\",\n \"commander\": \"^12.0.0\",\n \"dotenv\": \"^16.6.1\",\n \"js-yaml\": \"^4.1.0\",\n \"liquidjs\": \"^10.21.1\",\n \"open\": \"^10.2.0\",\n \"openapi-fetch\": \"^0.14.0\",\n \"ora\": \"^5.4.1\",\n \"prompts\": \"^2.4.2\",\n \"xksuid\": \"^0.0.4\",\n \"zod\": \"^4.0.14\"\n },\n \"peerDependencies\": {\n \"@ai-sdk/openai\": \">=2.0.0 <3.0.0\",\n \"@langchain/core\": \">=0.3.0 <1.0.0\",\n \"@langchain/langgraph\": \">=0.4.0 <1.0.0\",\n \"@langchain/openai\": \">=0.6.0 <1.0.0\",\n \"@opentelemetry/context-async-hooks\": \">=1.19.0 <3.0.0\",\n \"@opentelemetry/context-zone\": \">=1.19.0 <3.0.0\",\n \"@opentelemetry/sdk-node\": \">=0.200.0 <1.0.0\",\n \"@opentelemetry/sdk-trace-web\": \">=1.19.0 <3.0.0\",\n \"langchain\": \">=0.3.0 <1.0.0\"\n }\n}\n","export type JsRuntime = \"node\" | \"deno\" | \"bun\" | \"web\" | \"unknown\";\n\nlet _runtime: JsRuntime | undefined;\n\n/**\n * Gets the cached JavaScript runtime environment.\n * @returns The detected runtime environment\n */\nexport const getRuntime = (): JsRuntime => {\n _runtime ??= detectRuntime();\n return _runtime;\n};\n\n/**\n * Resets the cached runtime. Only used for testing.\n * @internal\n */\nexport const resetRuntimeCache = (): void => {\n _runtime = undefined;\n};\n\n/**\n * Detects the JavaScript runtime environment.\n * @param globals - (Test only) Optionally override the global object for environment simulation. Only used if NODE_ENV === 'test'.\n */\nexport function detectRuntime(globals?: any): JsRuntime {\n let g = globalThis;\n if (globals) {\n if (process.env.NODE_ENV === \"test\") {\n g = globals;\n } else {\n console.warn(\"[LangWatch Observability] overriding detectRuntime is only supported when running in NODE_ENV=test\");\n }\n }\n\n try {\n if (\n \"Deno\" in g &&\n typeof g.Deno === \"object\" &&\n g.Deno &&\n 'version' in g.Deno &&\n typeof g.Deno.version === \"object\"\n ) {\n return \"deno\";\n }\n if (\n \"Bun\" in g &&\n typeof g.Bun === \"object\" &&\n g.Bun &&\n 'version' in g.Bun &&\n typeof g.Bun.version === \"string\"\n ) {\n return \"bun\";\n }\n if (\n \"process\" in g &&\n typeof g.process === \"object\" &&\n g.process &&\n typeof g.process.versions === \"object\" &&\n typeof g.process.versions.node === \"string\"\n ) {\n return \"node\";\n }\n if (\n typeof g.window?.document !== \"undefined\" &&\n g === g.window\n ) {\n return \"web\";\n }\n return \"unknown\";\n } catch (error) {\n console.warn(\"[LangWatch Observability] Failed to detect runtime\", error);\n return \"unknown\";\n }\n}\n","import { version } from \"../../package.json\";\nimport { getRuntime } from \"./runtime\";\n\nexport const LANGWATCH_SDK_RUNTIME = getRuntime;\n\nexport const LANGWATCH_SDK_NAME_OBSERVABILITY = \"langwatch-observability-sdk\";\nexport const LANGWATCH_SDK_NAME_CLIENT = \"langwatch-client-sdk\";\nexport const LANGWATCH_SDK_LANGUAGE = \"typescript\";\nexport const LANGWATCH_SDK_VERSION = version;\n\nexport const DEFAULT_ENDPOINT = \"https://app.langwatch.ai/\";\nexport const DEFAULT_SERVICE_NAME = \"unknown-service.langwatch\";\n\nexport const TRACES_PATH = \"/api/otel/v1/traces\";\nexport const LOGS_PATH = \"/api/otel/v1/logs\";\nexport const METRICS_PATH = \"/api/otel/v1/metrics\";\n"]}
package/dist/cli/index.js CHANGED
@@ -2,38 +2,38 @@
2
2
  "use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
3
3
 
4
4
  var _chunkAZHZ4NB4js = require('../chunk-AZHZ4NB4.js');
5
- require('../chunk-OXBO24RB.js');
5
+ require('../chunk-OHM7JUMR.js');
6
6
 
7
7
  // src/cli/index.ts
8
8
  var _dotenv = require('dotenv');
9
9
  var _commander = require('commander');
10
10
  _dotenv.config.call(void 0, );
11
11
  var addCommand = async (name, options) => {
12
- const { addCommand: addCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../add-4WXEWG5H.js")));
12
+ const { addCommand: addCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../add-CGTO6GC2.js")));
13
13
  return addCommandImpl(name, options);
14
14
  };
15
15
  var removeCommand = async (name) => {
16
- const { removeCommand: removeCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../remove-U3PILQDV.js")));
16
+ const { removeCommand: removeCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../remove-7EXB2Z6R.js")));
17
17
  return removeCommandImpl(name);
18
18
  };
19
19
  var initCommand = async () => {
20
- const { initCommand: initCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../init-EKNL2SQE.js")));
20
+ const { initCommand: initCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../init-UADBKUJU.js")));
21
21
  return initCommandImpl();
22
22
  };
23
23
  var loginCommand = async () => {
24
- const { loginCommand: loginCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../login-3STX2FAO.js")));
24
+ const { loginCommand: loginCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../login-4GWM5I6F.js")));
25
25
  return loginCommandImpl();
26
26
  };
27
27
  var listCommand = async () => {
28
- const { listCommand: listCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../list-GIAXAAH5.js")));
28
+ const { listCommand: listCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../list-GRKVAGJS.js")));
29
29
  return listCommandImpl();
30
30
  };
31
31
  var syncCommand = async () => {
32
- const { syncCommand: syncCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../sync-T3T22GVZ.js")));
32
+ const { syncCommand: syncCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../sync-V7WRMNJV.js")));
33
33
  return syncCommandImpl();
34
34
  };
35
35
  var createCommand = async (name, options) => {
36
- const { createCommand: createCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../create-4LG4N2A4.js")));
36
+ const { createCommand: createCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../create-S5RDGF3H.js")));
37
37
  return createCommandImpl(name, options);
38
38
  };
39
39
  var program = new (0, _commander.Command)();