langwatch 0.3.1 → 0.4.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 (203) hide show
  1. package/README.md +5 -2
  2. package/dist/{add-LBBS4I3H.js → add-35QACTIV.js} +34 -28
  3. package/dist/add-35QACTIV.js.map +1 -0
  4. package/dist/{add-RD3ZKFAT.mjs → add-TRJAXM4D.mjs} +22 -16
  5. package/dist/add-TRJAXM4D.mjs.map +1 -0
  6. package/dist/chunk-4ZSSHX6F.js +636 -0
  7. package/dist/chunk-4ZSSHX6F.js.map +1 -0
  8. package/dist/chunk-5EVBOHJY.js +155 -0
  9. package/dist/chunk-5EVBOHJY.js.map +1 -0
  10. package/dist/{chunk-YN4436PK.mjs → chunk-CU3443HD.mjs} +14 -9
  11. package/dist/{chunk-2JU376G7.js → chunk-D2CSG4SJ.js} +4 -4
  12. package/dist/chunk-D2CSG4SJ.js.map +1 -0
  13. package/dist/chunk-DISMHYXC.js +184 -0
  14. package/dist/chunk-DISMHYXC.js.map +1 -0
  15. package/dist/{chunk-E7UE2MPD.mjs → chunk-ECUXLXFT.mjs} +2 -2
  16. package/dist/chunk-EJWJXTPU.mjs +626 -0
  17. package/dist/chunk-EJWJXTPU.mjs.map +1 -0
  18. package/dist/chunk-GQMDZ4GY.mjs +155 -0
  19. package/dist/chunk-GQMDZ4GY.mjs.map +1 -0
  20. package/dist/{chunk-3GKPQB4R.mjs → chunk-HUI45ULC.mjs} +4 -4
  21. package/dist/chunk-HUI45ULC.mjs.map +1 -0
  22. package/dist/{chunk-HJU67C7H.js → chunk-K64Y6YUG.js} +10 -10
  23. package/dist/{chunk-HJU67C7H.js.map → chunk-K64Y6YUG.js.map} +1 -1
  24. package/dist/chunk-LP76VXI3.mjs +636 -0
  25. package/dist/chunk-LP76VXI3.mjs.map +1 -0
  26. package/dist/chunk-M4VUHTT2.js +626 -0
  27. package/dist/chunk-M4VUHTT2.js.map +1 -0
  28. package/dist/{chunk-PR3JDWC3.mjs → chunk-N2V6J3U2.mjs} +28 -3
  29. package/dist/chunk-N2V6J3U2.mjs.map +1 -0
  30. package/dist/chunk-OUCVXP4G.js +258 -0
  31. package/dist/chunk-OUCVXP4G.js.map +1 -0
  32. package/dist/{chunk-FJLK5CFL.js → chunk-OXBO24RB.js} +13 -8
  33. package/dist/chunk-OXBO24RB.js.map +1 -0
  34. package/dist/chunk-PGWR3OQY.mjs +258 -0
  35. package/dist/chunk-PGWR3OQY.mjs.map +1 -0
  36. package/dist/{chunk-SMXXAVMB.js → chunk-SGNJDRCT.js} +2 -2
  37. package/dist/chunk-SGNJDRCT.js.map +1 -0
  38. package/dist/{chunk-W5ZEP3CI.mjs → chunk-SYMZPWZE.mjs} +2 -2
  39. package/dist/chunk-SYMZPWZE.mjs.map +1 -0
  40. package/dist/{chunk-KGDAENGD.js → chunk-YH5TIVK2.js} +28 -3
  41. package/dist/chunk-YH5TIVK2.js.map +1 -0
  42. package/dist/chunk-YNQ44U6D.mjs +184 -0
  43. package/dist/chunk-YNQ44U6D.mjs.map +1 -0
  44. package/dist/cli/index.js +8 -8
  45. package/dist/cli/index.mjs +8 -8
  46. package/dist/{create-G5MTGOOH.js → create-7K2CC4KQ.js} +11 -11
  47. package/dist/{create-G5MTGOOH.js.map → create-7K2CC4KQ.js.map} +1 -1
  48. package/dist/{create-QUZYBMQB.mjs → create-MK7NEGCM.mjs} +8 -8
  49. package/dist/implementation-C4lvooSg.d.mts +576 -0
  50. package/dist/implementation-CzemP9jY.d.ts +576 -0
  51. package/dist/index-DTEZr0Jn.d.mts +34 -0
  52. package/dist/index-DTEZr0Jn.d.ts +34 -0
  53. package/dist/index.d.mts +122 -41
  54. package/dist/index.d.ts +122 -41
  55. package/dist/index.js +16 -12
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.mjs +27 -23
  58. package/dist/index.mjs.map +1 -1
  59. package/dist/init-GDKJICSS.js +16 -0
  60. package/dist/{init-XU2JFY6N.js.map → init-GDKJICSS.js.map} +1 -1
  61. package/dist/{init-H67RW22E.mjs → init-RINSTP4L.mjs} +5 -5
  62. package/dist/{list-7NPSX2E4.mjs → list-7L23G5DY.mjs} +28 -16
  63. package/dist/list-7L23G5DY.mjs.map +1 -0
  64. package/dist/{list-ZXFLAF52.js → list-OLLQ7XKZ.js} +29 -17
  65. package/dist/list-OLLQ7XKZ.js.map +1 -0
  66. package/dist/{login-EK4WVOI2.mjs → login-RCNKL5AM.mjs} +6 -5
  67. package/dist/login-RCNKL5AM.mjs.map +1 -0
  68. package/dist/{login-76NQIHKR.js → login-XF3BQQPV.js} +7 -6
  69. package/dist/login-XF3BQQPV.js.map +1 -0
  70. package/dist/observability-sdk/index.d.mts +134 -0
  71. package/dist/observability-sdk/index.d.ts +134 -0
  72. package/dist/observability-sdk/index.js +41 -0
  73. package/dist/observability-sdk/index.js.map +1 -0
  74. package/dist/observability-sdk/index.mjs +41 -0
  75. package/dist/observability-sdk/instrumentation/langchain/index.d.mts +69 -0
  76. package/dist/observability-sdk/instrumentation/langchain/index.d.ts +69 -0
  77. package/dist/observability-sdk/instrumentation/langchain/index.js +518 -0
  78. package/dist/observability-sdk/instrumentation/langchain/index.js.map +1 -0
  79. package/dist/observability-sdk/instrumentation/langchain/index.mjs +518 -0
  80. package/dist/observability-sdk/instrumentation/langchain/index.mjs.map +1 -0
  81. package/dist/observability-sdk/setup/node/index.d.mts +368 -0
  82. package/dist/observability-sdk/setup/node/index.d.ts +368 -0
  83. package/dist/observability-sdk/setup/node/index.js +276 -0
  84. package/dist/observability-sdk/setup/node/index.js.map +1 -0
  85. package/dist/observability-sdk/setup/node/index.mjs +276 -0
  86. package/dist/observability-sdk/setup/node/index.mjs.map +1 -0
  87. package/dist/{remove-SDJYEPAY.mjs → remove-3VLQNVHN.mjs} +11 -8
  88. package/dist/remove-3VLQNVHN.mjs.map +1 -0
  89. package/dist/{remove-XBNGIVMR.js → remove-L6JVJBWY.js} +18 -15
  90. package/dist/remove-L6JVJBWY.js.map +1 -0
  91. package/dist/{sync-ST2IWXSB.mjs → sync-DPMTUTVL.mjs} +39 -33
  92. package/dist/sync-DPMTUTVL.mjs.map +1 -0
  93. package/dist/{sync-EISKGPTL.js → sync-PSU3F5Z4.js} +52 -46
  94. package/dist/sync-PSU3F5Z4.js.map +1 -0
  95. package/dist/{prompt-D-jpMrLS.d.mts → types-1q5wIYP5.d.mts} +628 -14
  96. package/dist/{prompt-D-jpMrLS.d.ts → types-C9k5gGhU.d.ts} +628 -14
  97. package/dist/types-DRiQaKFG.d.mts +254 -0
  98. package/dist/types-DRiQaKFG.d.ts +254 -0
  99. package/dist/types-Dmazk5Bk.d.mts +44 -0
  100. package/dist/types-Dmazk5Bk.d.ts +44 -0
  101. package/package.json +40 -40
  102. package/dist/add-LBBS4I3H.js.map +0 -1
  103. package/dist/add-RD3ZKFAT.mjs.map +0 -1
  104. package/dist/chunk-2JU376G7.js.map +0 -1
  105. package/dist/chunk-2ODBGSBI.js +0 -4
  106. package/dist/chunk-2ODBGSBI.js.map +0 -1
  107. package/dist/chunk-3GKPQB4R.mjs.map +0 -1
  108. package/dist/chunk-52GXX3MA.js +0 -426
  109. package/dist/chunk-52GXX3MA.js.map +0 -1
  110. package/dist/chunk-5NC5ILKA.js +0 -94
  111. package/dist/chunk-5NC5ILKA.js.map +0 -1
  112. package/dist/chunk-6I4EA43Y.js +0 -39
  113. package/dist/chunk-6I4EA43Y.js.map +0 -1
  114. package/dist/chunk-DTEKFQ4U.js +0 -159
  115. package/dist/chunk-DTEKFQ4U.js.map +0 -1
  116. package/dist/chunk-F63YKTXA.mjs +0 -47
  117. package/dist/chunk-F63YKTXA.mjs.map +0 -1
  118. package/dist/chunk-FJLK5CFL.js.map +0 -1
  119. package/dist/chunk-GJSEBQXF.mjs +0 -392
  120. package/dist/chunk-GJSEBQXF.mjs.map +0 -1
  121. package/dist/chunk-J7ICRUU4.mjs +0 -426
  122. package/dist/chunk-J7ICRUU4.mjs.map +0 -1
  123. package/dist/chunk-KGDAENGD.js.map +0 -1
  124. package/dist/chunk-LD74LVRU.js +0 -47
  125. package/dist/chunk-LD74LVRU.js.map +0 -1
  126. package/dist/chunk-PCQVQ7SB.js +0 -45
  127. package/dist/chunk-PCQVQ7SB.js.map +0 -1
  128. package/dist/chunk-PR3JDWC3.mjs.map +0 -1
  129. package/dist/chunk-PWZBLTHR.js +0 -118
  130. package/dist/chunk-PWZBLTHR.js.map +0 -1
  131. package/dist/chunk-QEWDG5QE.mjs +0 -45
  132. package/dist/chunk-QEWDG5QE.mjs.map +0 -1
  133. package/dist/chunk-SMXXAVMB.js.map +0 -1
  134. package/dist/chunk-STV4ZVNA.mjs +0 -118
  135. package/dist/chunk-STV4ZVNA.mjs.map +0 -1
  136. package/dist/chunk-T5AZMMVS.mjs +0 -94
  137. package/dist/chunk-T5AZMMVS.mjs.map +0 -1
  138. package/dist/chunk-UU33HCCZ.mjs +0 -159
  139. package/dist/chunk-UU33HCCZ.mjs.map +0 -1
  140. package/dist/chunk-VGHLQXKB.js +0 -392
  141. package/dist/chunk-VGHLQXKB.js.map +0 -1
  142. package/dist/chunk-W5ZEP3CI.mjs.map +0 -1
  143. package/dist/chunk-Y666BJA5.mjs +0 -4
  144. package/dist/chunk-YFUZF7JM.mjs +0 -39
  145. package/dist/chunk-YFUZF7JM.mjs.map +0 -1
  146. package/dist/chunk-YN4436PK.mjs.map +0 -1
  147. package/dist/client-B2HqIKg6.d.ts +0 -51
  148. package/dist/client-XyCqclCi.d.mts +0 -51
  149. package/dist/client-browser.d.mts +0 -8
  150. package/dist/client-browser.d.ts +0 -8
  151. package/dist/client-browser.js +0 -85
  152. package/dist/client-browser.js.map +0 -1
  153. package/dist/client-browser.mjs +0 -85
  154. package/dist/client-browser.mjs.map +0 -1
  155. package/dist/client-node.d.mts +0 -8
  156. package/dist/client-node.d.ts +0 -8
  157. package/dist/client-node.js +0 -92
  158. package/dist/client-node.js.map +0 -1
  159. package/dist/client-node.mjs +0 -92
  160. package/dist/client-node.mjs.map +0 -1
  161. package/dist/evaluation/index.d.mts +0 -897
  162. package/dist/evaluation/index.d.ts +0 -897
  163. package/dist/evaluation/index.js +0 -14
  164. package/dist/evaluation/index.js.map +0 -1
  165. package/dist/evaluation/index.mjs +0 -14
  166. package/dist/filterable-batch-span-processor-zO5kcjBY.d.mts +0 -64
  167. package/dist/filterable-batch-span-processor-zO5kcjBY.d.ts +0 -64
  168. package/dist/init-XU2JFY6N.js +0 -16
  169. package/dist/list-7NPSX2E4.mjs.map +0 -1
  170. package/dist/list-ZXFLAF52.js.map +0 -1
  171. package/dist/login-76NQIHKR.js.map +0 -1
  172. package/dist/login-EK4WVOI2.mjs.map +0 -1
  173. package/dist/observability/index.d.mts +0 -260
  174. package/dist/observability/index.d.ts +0 -260
  175. package/dist/observability/index.js +0 -21
  176. package/dist/observability/index.js.map +0 -1
  177. package/dist/observability/index.mjs +0 -21
  178. package/dist/observability/index.mjs.map +0 -1
  179. package/dist/observability/instrumentation/langchain/index.d.mts +0 -40
  180. package/dist/observability/instrumentation/langchain/index.d.ts +0 -40
  181. package/dist/observability/instrumentation/langchain/index.js +0 -668
  182. package/dist/observability/instrumentation/langchain/index.js.map +0 -1
  183. package/dist/observability/instrumentation/langchain/index.mjs +0 -668
  184. package/dist/observability/instrumentation/langchain/index.mjs.map +0 -1
  185. package/dist/prompt/index.d.mts +0 -10
  186. package/dist/prompt/index.d.ts +0 -10
  187. package/dist/prompt/index.js +0 -22
  188. package/dist/prompt/index.js.map +0 -1
  189. package/dist/prompt/index.mjs +0 -22
  190. package/dist/prompt/index.mjs.map +0 -1
  191. package/dist/record-evaluation-CmxMXa-3.d.mts +0 -25
  192. package/dist/record-evaluation-CmxMXa-3.d.ts +0 -25
  193. package/dist/remove-SDJYEPAY.mjs.map +0 -1
  194. package/dist/remove-XBNGIVMR.js.map +0 -1
  195. package/dist/sync-EISKGPTL.js.map +0 -1
  196. package/dist/sync-ST2IWXSB.mjs.map +0 -1
  197. package/dist/trace-CqaKo0kZ.d.ts +0 -622
  198. package/dist/trace-DtVc5GhF.d.mts +0 -622
  199. /package/dist/{chunk-Y666BJA5.mjs.map → chunk-CU3443HD.mjs.map} +0 -0
  200. /package/dist/{chunk-E7UE2MPD.mjs.map → chunk-ECUXLXFT.mjs.map} +0 -0
  201. /package/dist/{create-QUZYBMQB.mjs.map → create-MK7NEGCM.mjs.map} +0 -0
  202. /package/dist/{init-H67RW22E.mjs.map → init-RINSTP4L.mjs.map} +0 -0
  203. /package/dist/{evaluation → observability-sdk}/index.mjs.map +0 -0
@@ -1,392 +0,0 @@
1
- import {
2
- PromptConverter
3
- } from "./chunk-W5ZEP3CI.mjs";
4
- import {
5
- getApiKey,
6
- getEndpoint
7
- } from "./chunk-QEWDG5QE.mjs";
8
- import {
9
- __spreadProps,
10
- __spreadValues
11
- } from "./chunk-YN4436PK.mjs";
12
-
13
- // src/prompt/prompt.ts
14
- import { Liquid } from "liquidjs";
15
- var PromptCompilationError = class extends Error {
16
- constructor(message, template, originalError) {
17
- super(message);
18
- this.template = template;
19
- this.originalError = originalError;
20
- this.name = "PromptCompilationError";
21
- }
22
- };
23
- var liquid = new Liquid({
24
- strictFilters: true
25
- });
26
- var Prompt = class {
27
- constructor(promptData) {
28
- this.id = promptData.id;
29
- this.handle = promptData.handle;
30
- this.scope = promptData.scope;
31
- this.name = promptData.name;
32
- this.updatedAt = promptData.updatedAt;
33
- this.version = promptData.version;
34
- this.versionId = promptData.versionId;
35
- this.versionCreatedAt = promptData.versionCreatedAt;
36
- this.model = promptData.model;
37
- this.prompt = promptData.prompt;
38
- this.messages = promptData.messages;
39
- this.response_format = promptData.response_format;
40
- }
41
- /**
42
- * Get the raw prompt data from the API
43
- */
44
- get raw() {
45
- return this;
46
- }
47
- /**
48
- * Compile the prompt template with provided variables (lenient - missing variables become empty)
49
- * @param variables - Object containing variable values for template compilation
50
- * @returns CompiledPrompt instance with compiled content
51
- */
52
- _compile(variables, strict) {
53
- try {
54
- const compiledPrompt = this.prompt ? liquid.parseAndRenderSync(this.prompt, variables, {
55
- strictVariables: strict
56
- }) : "";
57
- const compiledMessages = (this.messages || []).map((message) => __spreadProps(__spreadValues({}, message), {
58
- content: message.content ? liquid.parseAndRenderSync(message.content, variables, {
59
- strictVariables: strict
60
- }) : message.content
61
- }));
62
- const compiledData = __spreadProps(__spreadValues({}, this), {
63
- prompt: compiledPrompt,
64
- messages: compiledMessages
65
- });
66
- return new CompiledPrompt(compiledData, this);
67
- } catch (error) {
68
- const templateStr = this.prompt || JSON.stringify(this.messages);
69
- throw new PromptCompilationError(
70
- `Failed to compile prompt template: ${error instanceof Error ? error.message : "Unknown error"}`,
71
- templateStr,
72
- error
73
- );
74
- }
75
- }
76
- compile(variables = {}) {
77
- return this._compile(variables, false);
78
- }
79
- /**
80
- * Compile with validation - throws error if required variables are missing
81
- * @param variables - Template variables
82
- * @returns CompiledPrompt instance with compiled content
83
- */
84
- compileStrict(variables) {
85
- return this._compile(variables, true);
86
- }
87
- };
88
- var CompiledPrompt = class extends Prompt {
89
- constructor(compiledData, original) {
90
- super(compiledData);
91
- this.original = original;
92
- }
93
- };
94
-
95
- // src/internal/api/client.ts
96
- import openApiCreateClient from "openapi-fetch";
97
- import { z } from "zod";
98
- var configSchema = z.object({
99
- apiKey: z.string().min(1, "API key is required"),
100
- endpoint: z.string().url("Endpoint must be a valid URL")
101
- });
102
- function createLangWatchApiClient(apiKey, endpoint) {
103
- const config = configSchema.parse({
104
- apiKey: apiKey != null ? apiKey : getApiKey(),
105
- endpoint: endpoint != null ? endpoint : getEndpoint()
106
- });
107
- return openApiCreateClient({
108
- baseUrl: config.endpoint,
109
- headers: {
110
- "X-Auth-Token": config.apiKey,
111
- "Content-Type": "application/json"
112
- }
113
- });
114
- }
115
-
116
- // src/prompt/service.ts
117
- var PromptsError = class extends Error {
118
- constructor(message, operation, originalError) {
119
- super(message);
120
- this.operation = operation;
121
- this.originalError = originalError;
122
- this.name = "PromptsError";
123
- }
124
- };
125
- var _PromptService = class _PromptService {
126
- constructor(opts) {
127
- var _a;
128
- this.client = (_a = opts == null ? void 0 : opts.client) != null ? _a : createLangWatchApiClient();
129
- }
130
- /**
131
- * Gets the singleton instance of PromptService.
132
- * Creates the instance lazily on first access.
133
- */
134
- static getInstance() {
135
- if (!_PromptService.instance) {
136
- _PromptService.instance = new _PromptService();
137
- }
138
- return _PromptService.instance;
139
- }
140
- /**
141
- * Resets the singleton instance. Primarily used for testing.
142
- */
143
- static resetInstance() {
144
- _PromptService.instance = null;
145
- }
146
- /**
147
- * Handles API errors by throwing a PromptsError with operation context.
148
- * @param operation Description of the operation being performed.
149
- * @param error The error object returned from the API client.
150
- * @throws {PromptsError}
151
- */
152
- handleApiError(operation, error) {
153
- var _a, _b;
154
- const errorMessage = typeof error === "string" ? error : (_b = (_a = error == null ? void 0 : error.error) != null ? _a : error == null ? void 0 : error.message) != null ? _b : "Unknown error occurred";
155
- throw new PromptsError(
156
- `Failed to ${operation}: ${errorMessage}`,
157
- operation,
158
- error
159
- );
160
- }
161
- /**
162
- * Fetches all prompts from the API.
163
- * @returns Array of Prompt instances.
164
- * @throws {PromptsError} If the API call fails.
165
- */
166
- async getAll() {
167
- const { data, error } = await this.client.GET("/api/prompts");
168
- if (error) this.handleApiError("fetch all prompts", error);
169
- return data.map((promptData) => new Prompt(promptData));
170
- }
171
- /**
172
- * Fetches a single prompt by its ID.
173
- * @param id The prompt's unique identifier.
174
- * @returns The Prompt instance or null if not found.
175
- * @throws {PromptsError} If the API call fails.
176
- */
177
- async get(id) {
178
- const { data, error } = await this.client.GET("/api/prompts/{id}", {
179
- params: { path: { id } }
180
- });
181
- if (error) {
182
- if (error.toString().includes("404")) {
183
- return null;
184
- }
185
- this.handleApiError(`fetch prompt with ID "${id}"`, error);
186
- }
187
- return new Prompt(data);
188
- }
189
- /**
190
- * Validates if a prompt exists.
191
- * @param id The prompt's unique identifier.
192
- * @returns True if prompt exists, false otherwise.
193
- * @throws {PromptsError} If the API call fails (not 404).
194
- */
195
- async exists(id) {
196
- try {
197
- const prompt = await this.get(id);
198
- return prompt !== null;
199
- } catch (error) {
200
- throw error;
201
- }
202
- }
203
- /**
204
- * Creates a new prompt.
205
- * @param params The prompt creation payload, matching the OpenAPI schema.
206
- * @returns The created Prompt instance.
207
- * @throws {PromptsError} If the API call fails.
208
- */
209
- async create(params) {
210
- const { data, error } = await this.client.POST("/api/prompts", {
211
- body: params
212
- });
213
- if (error) this.handleApiError("create prompt", error);
214
- return new Prompt(data);
215
- }
216
- /**
217
- * Updates an existing prompt.
218
- * @param id The prompt's unique identifier.
219
- * @param params The update payload, matching the OpenAPI schema.
220
- * @returns The updated Prompt instance.
221
- * @throws {PromptsError} If the API call fails.
222
- * @remarks
223
- * The API does not return the updated prompt directly, so this method fetches it after updating.
224
- */
225
- async update(id, params) {
226
- const { error } = await this.client.PUT("/api/prompts/{id}", {
227
- params: { path: { id } },
228
- body: params
229
- });
230
- if (error) this.handleApiError(`update prompt with ID "${id}"`, error);
231
- const updatedPrompt = await this.get(id);
232
- if (!updatedPrompt) {
233
- throw new PromptsError(
234
- "Prompt not found after update",
235
- "update prompt",
236
- null
237
- );
238
- }
239
- return updatedPrompt;
240
- }
241
- /**
242
- * Deletes a prompt by its ID.
243
- * @param id The prompt's unique identifier.
244
- * @throws {PromptsError} If the API call fails.
245
- */
246
- async delete(id) {
247
- const { error } = await this.client.DELETE("/api/prompts/{id}", {
248
- params: { path: { id } }
249
- });
250
- if (error) this.handleApiError(`delete prompt with ID "${id}"`, error);
251
- }
252
- /**
253
- * Fetches all versions for a given prompt.
254
- * @param id The prompt's unique identifier.
255
- * @throws {PromptsError} If the API call fails.
256
- */
257
- async getVersions(id) {
258
- var _a;
259
- const { data, error } = await this.client.GET(
260
- "/api/prompts/{id}/versions",
261
- {
262
- params: { path: { id } }
263
- }
264
- );
265
- if (error)
266
- this.handleApiError(`fetch versions for prompt with ID "${id}"`, error);
267
- const prompts = {};
268
- const dataTypeCorrected = data;
269
- for (const version of dataTypeCorrected) {
270
- prompts[version.id] = new Prompt({
271
- id: version.configId,
272
- handle: version.handle,
273
- scope: version.scope,
274
- messages: version.configData.messages,
275
- model: version.configData.model,
276
- prompt: version.configData.prompt,
277
- response_format: null,
278
- name: `Prompt ${version.configId}@${version.id}`,
279
- updatedAt: version.createdAt,
280
- version: (_a = version.configData.version) != null ? _a : 0,
281
- versionCreatedAt: version.createdAt,
282
- versionId: version.id
283
- });
284
- }
285
- return prompts;
286
- }
287
- /**
288
- * Creates a new version for a given prompt.
289
- * @param id The prompt's unique identifier.
290
- * @param params The version creation payload, matching the OpenAPI schema.
291
- * @returns The updated Prompt instance.
292
- * @throws {PromptsError} If the API call fails.
293
- * @remarks
294
- * The API does not return the updated prompt directly, so this method fetches it after creation.
295
- */
296
- async createVersion(id, params) {
297
- const { error } = await this.client.POST("/api/prompts/{id}/versions", {
298
- params: { path: { id } },
299
- body: params
300
- });
301
- if (error)
302
- this.handleApiError(`create version for prompt with ID "${id}"`, error);
303
- const updatedPrompt = await this.get(id);
304
- if (!updatedPrompt) {
305
- throw new PromptsError(
306
- "Prompt not found after version creation",
307
- "create version",
308
- null
309
- );
310
- }
311
- return updatedPrompt;
312
- }
313
- /**
314
- * Upserts a prompt with local configuration - creates if doesn't exist, updates version if exists.
315
- * @param name The prompt's name/identifier.
316
- * @param config Local prompt configuration.
317
- * @returns Object with created flag and the prompt instance.
318
- * @throws {PromptsError} If the API call fails.
319
- */
320
- async upsert(name, config) {
321
- var _a, _b;
322
- let prompt = await this.get(name);
323
- let created = false;
324
- if (!prompt) {
325
- prompt = await this.create({ name });
326
- created = true;
327
- }
328
- const versionData = {
329
- configData: {
330
- version: 1,
331
- model: config.model,
332
- prompt: PromptConverter.extractSystemPrompt(config.messages),
333
- messages: PromptConverter.filterNonSystemMessages(config.messages),
334
- temperature: (_a = config.modelParameters) == null ? void 0 : _a.temperature,
335
- max_tokens: (_b = config.modelParameters) == null ? void 0 : _b.max_tokens,
336
- inputs: [{ identifier: "input", type: "str" }],
337
- outputs: [{ identifier: "output", type: "str" }]
338
- },
339
- commitMessage: `Updated via CLI sync`,
340
- projectId: "placeholder",
341
- // Will be overridden by the API
342
- configId: prompt.id,
343
- schemaVersion: "1.0",
344
- version: 1
345
- // Will be auto-incremented by the API
346
- };
347
- const updatedPrompt = await this.createVersion(prompt.id, versionData);
348
- return {
349
- created,
350
- prompt: updatedPrompt
351
- };
352
- }
353
- /**
354
- * Sync a prompt with local content, handling conflicts and version management
355
- */
356
- async sync(params) {
357
- var _a, _b;
358
- try {
359
- const response = await this.client.POST("/api/prompts/{id}/sync", {
360
- params: { path: { id: params.name } },
361
- body: {
362
- configData: params.configData,
363
- localVersion: params.localVersion,
364
- commitMessage: params.commitMessage
365
- }
366
- });
367
- if (response.error) {
368
- const errorMessage = (_b = (_a = response.error) == null ? void 0 : _a.error) != null ? _b : JSON.stringify(response.error);
369
- throw new Error(`Failed to sync prompt: ${errorMessage}`);
370
- }
371
- return {
372
- action: response.data.action,
373
- prompt: response.data.prompt,
374
- conflictInfo: response.data.conflictInfo
375
- };
376
- } catch (error) {
377
- const message = error instanceof Error ? error.message : "Unknown error occurred";
378
- throw new PromptsError(message, "sync", error);
379
- }
380
- }
381
- };
382
- _PromptService.instance = null;
383
- var PromptService = _PromptService;
384
-
385
- export {
386
- PromptCompilationError,
387
- Prompt,
388
- CompiledPrompt,
389
- PromptsError,
390
- PromptService
391
- };
392
- //# sourceMappingURL=chunk-GJSEBQXF.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/prompt/prompt.ts","../src/internal/api/client.ts","../src/prompt/service.ts"],"sourcesContent":["import { Liquid } from \"liquidjs\";\nimport type { paths } from \"../internal/generated/openapi/api-client\";\n\n// Extract the prompt response type from OpenAPI schema\nexport type PromptResponse = NonNullable<\n paths[\"/api/prompts/{id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"]\n>;\n\n// Type for template variables - supporting common data types\nexport type TemplateVariables = Record<\n string,\n string | number | boolean | object | null\n>;\n\n/**\n * Error class for template compilation issues\n */\nexport class PromptCompilationError extends Error {\n constructor(\n message: string,\n public readonly template: string,\n public readonly originalError?: any,\n ) {\n super(message);\n this.name = \"PromptCompilationError\";\n }\n}\n\n// Global Liquid instance - shared across all prompts for efficiency\nconst liquid = new Liquid({\n strictFilters: true,\n});\n\nexport class Prompt implements PromptResponse {\n public readonly id!: string;\n public readonly handle!: string | null;\n public readonly scope!: \"ORGANIZATION\" | \"PROJECT\";\n public readonly name!: string;\n public readonly updatedAt!: string;\n public readonly version!: number;\n public readonly versionId!: string;\n public readonly versionCreatedAt!: string;\n public readonly model!: string;\n public readonly prompt!: string;\n public readonly messages!: PromptResponse[\"messages\"];\n public readonly response_format!: PromptResponse[\"response_format\"];\n\n constructor(promptData: PromptResponse) {\n this.id = promptData.id;\n this.handle = promptData.handle;\n this.scope = promptData.scope;\n this.name = promptData.name;\n this.updatedAt = promptData.updatedAt;\n this.version = promptData.version;\n this.versionId = promptData.versionId;\n this.versionCreatedAt = promptData.versionCreatedAt;\n this.model = promptData.model;\n this.prompt = promptData.prompt;\n this.messages = promptData.messages;\n this.response_format = promptData.response_format;\n }\n\n /**\n * Get the raw prompt data from the API\n */\n get raw(): PromptResponse {\n return this;\n }\n\n /**\n * Compile the prompt template with provided variables (lenient - missing variables become empty)\n * @param variables - Object containing variable values for template compilation\n * @returns CompiledPrompt instance with compiled content\n */\n private _compile(\n variables: TemplateVariables,\n strict: boolean,\n ): CompiledPrompt {\n try {\n // Compile main prompt\n const compiledPrompt = this.prompt\n ? liquid.parseAndRenderSync(this.prompt, variables, {\n strictVariables: strict,\n })\n : \"\";\n\n // Compile messages\n const compiledMessages = (this.messages || []).map((message) => ({\n ...message,\n content: message.content\n ? liquid.parseAndRenderSync(message.content, variables, {\n strictVariables: strict,\n })\n : message.content,\n }));\n\n // Create new prompt data with compiled content\n const compiledData: PromptResponse = {\n ...this,\n prompt: compiledPrompt,\n messages: compiledMessages,\n };\n\n return new CompiledPrompt(compiledData, this);\n } catch (error) {\n const templateStr = this.prompt || JSON.stringify(this.messages);\n throw new PromptCompilationError(\n `Failed to compile prompt template: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n templateStr,\n error,\n );\n }\n }\n\n compile(variables: TemplateVariables = {}): CompiledPrompt {\n return this._compile(variables, false);\n }\n\n /**\n * Compile with validation - throws error if required variables are missing\n * @param variables - Template variables\n * @returns CompiledPrompt instance with compiled content\n */\n compileStrict(variables: TemplateVariables): CompiledPrompt {\n return this._compile(variables, true);\n }\n}\n\n/**\n * Represents a compiled prompt that extends Prompt with reference to the original template\n */\nexport class CompiledPrompt extends Prompt {\n constructor(\n compiledData: PromptResponse,\n public readonly original: Prompt,\n ) {\n super(compiledData);\n }\n}\n","import openApiCreateClient from \"openapi-fetch\";\nimport type { paths } from \"../generated/openapi/api-client\";\nimport { z } from \"zod\";\nimport { getApiKey, getEndpoint } from \"../../client\";\n\n// Define the client type explicitly to avoid naming issues\nexport type LangwatchApiClient = ReturnType<typeof openApiCreateClient<paths>>;\n\nconst configSchema = z.object({\n apiKey: z.string().min(1, \"API key is required\"),\n endpoint: z.string().url(\"Endpoint must be a valid URL\"),\n});\n\nexport function createLangWatchApiClient(apiKey?: string | undefined, endpoint?: string | undefined ): LangwatchApiClient {\n // This will error if the config is invalid\n const config = configSchema.parse({\n apiKey: apiKey ?? getApiKey(),\n endpoint: endpoint ?? getEndpoint(),\n });\n\n return openApiCreateClient<paths>({\n baseUrl: config.endpoint,\n headers: {\n \"X-Auth-Token\": config.apiKey,\n \"Content-Type\": \"application/json\",\n },\n });\n}\n\n\n","import {\n createLangWatchApiClient,\n type LangwatchApiClient,\n} from \"../internal/api/client\";\nimport type { paths } from \"../internal/generated/openapi/api-client\";\nimport { Prompt, type PromptResponse } from \"./prompt\";\nimport { PromptConverter } from \"./converter\";\n\n// Extract types directly from OpenAPI schema for strong type safety.\ntype CreatePromptBody = NonNullable<\n paths[\"/api/prompts\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype UpdatePromptBody = NonNullable<\n paths[\"/api/prompts/{id}\"][\"put\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CreateVersionBody = NonNullable<\n paths[\"/api/prompts/{id}/versions\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype SyncBody = NonNullable<\n paths[\"/api/prompts/{id}/sync\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/**\n * Custom error class for Prompts API operations.\n * Provides context about the failed operation and the original error.\n */\nexport class PromptsError extends Error {\n constructor(\n message: string,\n public readonly operation: string,\n public readonly originalError?: any,\n ) {\n super(message);\n this.name = \"PromptsError\";\n }\n}\n\nexport type SyncAction = \"created\" | \"updated\" | \"conflict\" | \"up_to_date\";\n\nexport type ConfigData = NonNullable<\n paths[\"/api/prompts/{id}/sync\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"][\"configData\"];\n\nexport interface SyncResult {\n action: SyncAction;\n prompt?: PromptResponse;\n conflictInfo?: {\n localVersion: number;\n remoteVersion: number;\n differences: string[];\n remoteConfigData: ConfigData;\n };\n}\n\ninterface PromptServiceOptions {\n client?: LangwatchApiClient;\n}\n\n/**\n * Service for managing prompt resources via the Langwatch API.\n *\n * Responsibilities:\n * - CRUD operations for prompts\n * - Creating prompt versions\n * - Error handling with contextual information\n *\n * All methods return Prompt instances, which encapsulate prompt data and template logic.\n */\nexport class PromptService {\n private client: LangwatchApiClient;\n private static instance: PromptService | null = null;\n\n constructor(opts?: PromptServiceOptions) {\n this.client = opts?.client ?? createLangWatchApiClient();\n }\n\n /**\n * Gets the singleton instance of PromptService.\n * Creates the instance lazily on first access.\n */\n public static getInstance(): PromptService {\n if (!PromptService.instance) {\n PromptService.instance = new PromptService();\n }\n return PromptService.instance;\n }\n\n /**\n * Resets the singleton instance. Primarily used for testing.\n */\n public static resetInstance(): void {\n PromptService.instance = null;\n }\n\n /**\n * Handles API errors by throwing a PromptsError with operation context.\n * @param operation Description of the operation being performed.\n * @param error The error object returned from the API client.\n * @throws {PromptsError}\n */\n private handleApiError(operation: string, error: any): never {\n const errorMessage =\n typeof error === \"string\"\n ? error\n : error?.error ?? error?.message ?? \"Unknown error occurred\";\n throw new PromptsError(\n `Failed to ${operation}: ${errorMessage}`,\n operation,\n error,\n );\n }\n\n /**\n * Fetches all prompts from the API.\n * @returns Array of Prompt instances.\n * @throws {PromptsError} If the API call fails.\n */\n async getAll(): Promise<Prompt[]> {\n const { data, error } = await this.client.GET(\"/api/prompts\");\n if (error) this.handleApiError(\"fetch all prompts\", error);\n return data.map((promptData) => new Prompt(promptData));\n }\n\n /**\n * Fetches a single prompt by its ID.\n * @param id The prompt's unique identifier.\n * @returns The Prompt instance or null if not found.\n * @throws {PromptsError} If the API call fails.\n */\n async get(id: string): Promise<Prompt | null> {\n const { data, error } = await this.client.GET(\"/api/prompts/{id}\", {\n params: { path: { id } },\n });\n if (error) {\n if (error.toString().includes(\"404\")) {\n return null;\n }\n this.handleApiError(`fetch prompt with ID \"${id}\"`, error);\n }\n return new Prompt(data);\n }\n\n /**\n * Validates if a prompt exists.\n * @param id The prompt's unique identifier.\n * @returns True if prompt exists, false otherwise.\n * @throws {PromptsError} If the API call fails (not 404).\n */\n async exists(id: string): Promise<boolean> {\n try {\n const prompt = await this.get(id);\n return prompt !== null;\n } catch (error) {\n throw error; // Re-throw non-404 errors\n }\n }\n\n /**\n * Creates a new prompt.\n * @param params The prompt creation payload, matching the OpenAPI schema.\n * @returns The created Prompt instance.\n * @throws {PromptsError} If the API call fails.\n */\n async create(params: CreatePromptBody): Promise<Prompt> {\n const { data, error } = await this.client.POST(\"/api/prompts\", {\n body: params,\n });\n if (error) this.handleApiError(\"create prompt\", error);\n return new Prompt(data);\n }\n\n /**\n * Updates an existing prompt.\n * @param id The prompt's unique identifier.\n * @param params The update payload, matching the OpenAPI schema.\n * @returns The updated Prompt instance.\n * @throws {PromptsError} If the API call fails.\n * @remarks\n * The API does not return the updated prompt directly, so this method fetches it after updating.\n */\n async update(id: string, params: UpdatePromptBody): Promise<Prompt> {\n const { error } = await this.client.PUT(\"/api/prompts/{id}\", {\n params: { path: { id } },\n body: params,\n });\n if (error) this.handleApiError(`update prompt with ID \"${id}\"`, error);\n // TODO: This is a workaround to get the updated prompt. It would be better to return the updated prompt directly.\n const updatedPrompt = await this.get(id);\n if (!updatedPrompt) {\n throw new PromptsError(\n \"Prompt not found after update\",\n \"update prompt\",\n null,\n );\n }\n return updatedPrompt;\n }\n\n /**\n * Deletes a prompt by its ID.\n * @param id The prompt's unique identifier.\n * @throws {PromptsError} If the API call fails.\n */\n async delete(id: string): Promise<void> {\n const { error } = await this.client.DELETE(\"/api/prompts/{id}\", {\n params: { path: { id } },\n });\n if (error) this.handleApiError(`delete prompt with ID \"${id}\"`, error);\n }\n\n /**\n * Fetches all versions for a given prompt.\n * @param id The prompt's unique identifier.\n * @throws {PromptsError} If the API call fails.\n */\n async getVersions(id: string): Promise<Record<string, Prompt>> {\n const { data, error } = await this.client.GET(\n \"/api/prompts/{id}/versions\",\n {\n params: { path: { id } },\n },\n );\n if (error)\n this.handleApiError(`fetch versions for prompt with ID \"${id}\"`, error);\n\n const prompts: Record<string, Prompt> = {};\n const dataTypeCorrected = data as unknown as NonNullable<\n paths[\"/api/prompts/{id}/versions\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"]\n >[];\n\n for (const version of dataTypeCorrected) {\n prompts[version.id] = new Prompt({\n id: version.configId,\n handle: version.handle,\n scope: version.scope,\n messages: version.configData.messages,\n model: version.configData.model,\n prompt: version.configData.prompt,\n response_format: null,\n name: `Prompt ${version.configId}@${version.id}`,\n updatedAt: version.createdAt,\n version: version.configData.version ?? 0,\n versionCreatedAt: version.createdAt,\n versionId: version.id,\n });\n }\n\n return prompts;\n }\n\n /**\n * Creates a new version for a given prompt.\n * @param id The prompt's unique identifier.\n * @param params The version creation payload, matching the OpenAPI schema.\n * @returns The updated Prompt instance.\n * @throws {PromptsError} If the API call fails.\n * @remarks\n * The API does not return the updated prompt directly, so this method fetches it after creation.\n */\n async createVersion(id: string, params: CreateVersionBody): Promise<Prompt> {\n const { error } = await this.client.POST(\"/api/prompts/{id}/versions\", {\n params: { path: { id } },\n body: params,\n });\n if (error)\n this.handleApiError(`create version for prompt with ID \"${id}\"`, error);\n // TODO: This is a workaround to get the updated prompt. It would be better to return the updated prompt directly.\n const updatedPrompt = await this.get(id);\n if (!updatedPrompt) {\n throw new PromptsError(\n \"Prompt not found after version creation\",\n \"create version\",\n null,\n );\n }\n return updatedPrompt;\n }\n\n /**\n * Upserts a prompt with local configuration - creates if doesn't exist, updates version if exists.\n * @param name The prompt's name/identifier.\n * @param config Local prompt configuration.\n * @returns Object with created flag and the prompt instance.\n * @throws {PromptsError} If the API call fails.\n */\n async upsert(\n name: string,\n config: {\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 ): Promise<{ created: boolean; prompt: Prompt }> {\n let prompt = await this.get(name);\n let created = false;\n\n if (!prompt) {\n prompt = await this.create({ name });\n created = true;\n }\n\n // Create a new version with the updated config using the converter\n const versionData = {\n configData: {\n version: 1,\n model: config.model,\n prompt: PromptConverter.extractSystemPrompt(config.messages),\n messages: PromptConverter.filterNonSystemMessages(config.messages),\n temperature: config.modelParameters?.temperature,\n max_tokens: config.modelParameters?.max_tokens,\n inputs: [{ identifier: \"input\", type: \"str\" as const }],\n outputs: [{ identifier: \"output\", type: \"str\" as const }],\n },\n commitMessage: `Updated via CLI sync`,\n projectId: \"placeholder\", // Will be overridden by the API\n configId: prompt.id,\n schemaVersion: \"1.0\" as const,\n version: 1, // Will be auto-incremented by the API\n } as any; // Type assertion to bypass strict typing for now\n\n const updatedPrompt = await this.createVersion(prompt.id, versionData);\n\n return {\n created,\n prompt: updatedPrompt,\n };\n }\n\n /**\n * Sync a prompt with local content, handling conflicts and version management\n */\n async sync(params: {\n name: string;\n configData: ConfigData;\n localVersion?: number;\n commitMessage?: string;\n }): Promise<SyncResult> {\n try {\n const response = await this.client.POST(\"/api/prompts/{id}/sync\", {\n params: { path: { id: params.name } },\n body: {\n configData: params.configData,\n localVersion: params.localVersion,\n commitMessage: params.commitMessage,\n },\n });\n\n if (response.error) {\n const errorMessage =\n response.error?.error ?? JSON.stringify(response.error);\n throw new Error(`Failed to sync prompt: ${errorMessage}`);\n }\n\n return {\n action: response.data.action as SyncAction,\n prompt: response.data.prompt as PromptResponse,\n conflictInfo: response.data.conflictInfo,\n };\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n throw new PromptsError(message, \"sync\", error);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,cAAc;AAiBhB,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAChD,YACE,SACgB,UACA,eAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAGA,IAAM,SAAS,IAAI,OAAO;AAAA,EACxB,eAAe;AACjB,CAAC;AAEM,IAAM,SAAN,MAAuC;AAAA,EAc5C,YAAY,YAA4B;AACtC,SAAK,KAAK,WAAW;AACrB,SAAK,SAAS,WAAW;AACzB,SAAK,QAAQ,WAAW;AACxB,SAAK,OAAO,WAAW;AACvB,SAAK,YAAY,WAAW;AAC5B,SAAK,UAAU,WAAW;AAC1B,SAAK,YAAY,WAAW;AAC5B,SAAK,mBAAmB,WAAW;AACnC,SAAK,QAAQ,WAAW;AACxB,SAAK,SAAS,WAAW;AACzB,SAAK,WAAW,WAAW;AAC3B,SAAK,kBAAkB,WAAW;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,MAAsB;AACxB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOQ,SACN,WACA,QACgB;AAChB,QAAI;AAEF,YAAM,iBAAiB,KAAK,SACxB,OAAO,mBAAmB,KAAK,QAAQ,WAAW;AAAA,QACh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