langwatch 0.11.0 → 0.12.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 (53) hide show
  1. package/dist/{add-XV5SUAXF.mjs → add-2UHFYNUA.mjs} +4 -4
  2. package/dist/{add-UB5U3K3M.js → add-LUETMKBD.js} +7 -7
  3. package/dist/{add-UB5U3K3M.js.map → add-LUETMKBD.js.map} +1 -1
  4. package/dist/{chunk-D4H6PR6H.js → chunk-6SSCBYJM.js} +9 -9
  5. package/dist/{chunk-D4H6PR6H.js.map → chunk-6SSCBYJM.js.map} +1 -1
  6. package/dist/{chunk-JQYW7RY7.js → chunk-BQRUUTN3.js} +14 -14
  7. package/dist/{chunk-JQYW7RY7.js.map → chunk-BQRUUTN3.js.map} +1 -1
  8. package/dist/{chunk-N7PJJMU2.js → chunk-C4XUWCQR.js} +2 -2
  9. package/dist/{chunk-N7PJJMU2.js.map → chunk-C4XUWCQR.js.map} +1 -1
  10. package/dist/{chunk-WZ7FYUHN.mjs → chunk-OTID7S7K.mjs} +2 -2
  11. package/dist/{chunk-LKE6DMUP.mjs → chunk-TB5KB737.mjs} +2 -2
  12. package/dist/{chunk-LKE6DMUP.mjs.map → chunk-TB5KB737.mjs.map} +1 -1
  13. package/dist/{chunk-556ZFJMK.mjs → chunk-WCNDT5SD.mjs} +2 -2
  14. package/dist/cli/index.js +6 -6
  15. package/dist/cli/index.mjs +6 -6
  16. package/dist/{implementation-CPxv2BdW.d.ts → implementation-Bnc8Aymq.d.ts} +1 -1
  17. package/dist/{implementation-CVrmD0bz.d.mts → implementation-Ck58nRkT.d.mts} +1 -1
  18. package/dist/index.d.mts +129 -5
  19. package/dist/index.d.ts +129 -5
  20. package/dist/index.js +286 -12
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +278 -4
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{list-DUNP46AD.js → list-7U3M64GY.js} +7 -7
  25. package/dist/{list-DUNP46AD.js.map → list-7U3M64GY.js.map} +1 -1
  26. package/dist/{list-T4QS6CT2.mjs → list-WV5LA6LD.mjs} +4 -4
  27. package/dist/{login-3H27NIOD.js → login-B7DKMN7P.js} +3 -3
  28. package/dist/{login-3H27NIOD.js.map → login-B7DKMN7P.js.map} +1 -1
  29. package/dist/{login-T2ET7TKH.mjs → login-QKRT6PXA.mjs} +2 -2
  30. package/dist/observability-sdk/index.d.mts +3 -3
  31. package/dist/observability-sdk/index.d.ts +3 -3
  32. package/dist/observability-sdk/index.js +3 -3
  33. package/dist/observability-sdk/index.mjs +2 -2
  34. package/dist/observability-sdk/instrumentation/langchain/index.d.mts +1 -1
  35. package/dist/observability-sdk/instrumentation/langchain/index.d.ts +1 -1
  36. package/dist/observability-sdk/setup/node/index.js +10 -10
  37. package/dist/observability-sdk/setup/node/index.mjs +2 -2
  38. package/dist/{remove-F5RM4775.mjs → remove-2OGMXSTR.mjs} +4 -4
  39. package/dist/{remove-V4JL5Z4U.js → remove-A4DKCN7A.js} +6 -6
  40. package/dist/{remove-V4JL5Z4U.js.map → remove-A4DKCN7A.js.map} +1 -1
  41. package/dist/{sync-VGWOLOLJ.mjs → sync-TNVCKWTC.mjs} +4 -4
  42. package/dist/{sync-DIOKWE6R.js → sync-WRZXIBZS.js} +6 -6
  43. package/dist/{sync-DIOKWE6R.js.map → sync-WRZXIBZS.js.map} +1 -1
  44. package/dist/{types-Kts5RGLY.d.mts → types-5h2Im4pl.d.mts} +162 -0
  45. package/dist/{types-usU5mTCX.d.ts → types-fo-Ij9pl.d.ts} +162 -0
  46. package/package.json +1 -1
  47. /package/dist/{add-XV5SUAXF.mjs.map → add-2UHFYNUA.mjs.map} +0 -0
  48. /package/dist/{chunk-WZ7FYUHN.mjs.map → chunk-OTID7S7K.mjs.map} +0 -0
  49. /package/dist/{chunk-556ZFJMK.mjs.map → chunk-WCNDT5SD.mjs.map} +0 -0
  50. /package/dist/{list-T4QS6CT2.mjs.map → list-WV5LA6LD.mjs.map} +0 -0
  51. /package/dist/{login-T2ET7TKH.mjs.map → login-QKRT6PXA.mjs.map} +0 -0
  52. /package/dist/{remove-F5RM4775.mjs.map → remove-2OGMXSTR.mjs.map} +0 -0
  53. /package/dist/{sync-VGWOLOLJ.mjs.map → sync-TNVCKWTC.mjs.map} +0 -0
@@ -13,8 +13,8 @@ var _chunkONXIZKC6js = require('../chunk-ONXIZKC6.js');
13
13
 
14
14
 
15
15
 
16
- var _chunkJQYW7RY7js = require('../chunk-JQYW7RY7.js');
17
- require('../chunk-N7PJJMU2.js');
16
+ var _chunkBQRUUTN3js = require('../chunk-BQRUUTN3.js');
17
+ require('../chunk-C4XUWCQR.js');
18
18
 
19
19
 
20
20
 
@@ -38,5 +38,5 @@ require('../chunk-OHM7JUMR.js');
38
38
 
39
39
 
40
40
 
41
- exports.DataCapturePresets = _chunkASTAIRXGjs.DataCapturePresets; exports.FilterableBatchSpanProcessor = _chunkASTAIRXGjs.FilterableBatchSpanProcessor; exports.LangWatchExporter = _chunkJQYW7RY7js.LangWatchTraceExporter; exports.LangWatchLogsExporter = _chunkJQYW7RY7js.LangWatchLogsExporter; exports.LangWatchTraceExporter = _chunkJQYW7RY7js.LangWatchTraceExporter; exports.attributes = _chunk5MQQRSVMjs.attributes_exports; exports.createLangWatchSpan = _chunkONXIZKC6js.createLangWatchSpan; exports.getDataCaptureMode = _chunk5MQQRSVMjs.getDataCaptureMode; exports.getLangWatchLogger = _chunkJQYW7RY7js.getLangWatchLogger; exports.getLangWatchLoggerFromProvider = _chunkJQYW7RY7js.getLangWatchLoggerFromProvider; exports.getLangWatchTracer = _chunkONXIZKC6js.getLangWatchTracer; exports.getLangWatchTracerFromProvider = _chunkONXIZKC6js.getLangWatchTracerFromProvider; exports.shouldCaptureInput = _chunk5MQQRSVMjs.shouldCaptureInput; exports.shouldCaptureOutput = _chunk5MQQRSVMjs.shouldCaptureOutput; exports.spanTypes = _chunkONXIZKC6js.spanTypes;
41
+ exports.DataCapturePresets = _chunkASTAIRXGjs.DataCapturePresets; exports.FilterableBatchSpanProcessor = _chunkASTAIRXGjs.FilterableBatchSpanProcessor; exports.LangWatchExporter = _chunkBQRUUTN3js.LangWatchTraceExporter; exports.LangWatchLogsExporter = _chunkBQRUUTN3js.LangWatchLogsExporter; exports.LangWatchTraceExporter = _chunkBQRUUTN3js.LangWatchTraceExporter; exports.attributes = _chunk5MQQRSVMjs.attributes_exports; exports.createLangWatchSpan = _chunkONXIZKC6js.createLangWatchSpan; exports.getDataCaptureMode = _chunk5MQQRSVMjs.getDataCaptureMode; exports.getLangWatchLogger = _chunkBQRUUTN3js.getLangWatchLogger; exports.getLangWatchLoggerFromProvider = _chunkBQRUUTN3js.getLangWatchLoggerFromProvider; exports.getLangWatchTracer = _chunkONXIZKC6js.getLangWatchTracer; exports.getLangWatchTracerFromProvider = _chunkONXIZKC6js.getLangWatchTracerFromProvider; exports.shouldCaptureInput = _chunk5MQQRSVMjs.shouldCaptureInput; exports.shouldCaptureOutput = _chunk5MQQRSVMjs.shouldCaptureOutput; exports.spanTypes = _chunkONXIZKC6js.spanTypes;
42
42
  //# sourceMappingURL=index.js.map
@@ -13,8 +13,8 @@ import {
13
13
  LangWatchTraceExporter,
14
14
  getLangWatchLogger,
15
15
  getLangWatchLoggerFromProvider
16
- } from "../chunk-556ZFJMK.mjs";
17
- import "../chunk-LKE6DMUP.mjs";
16
+ } from "../chunk-WCNDT5SD.mjs";
17
+ import "../chunk-TB5KB737.mjs";
18
18
  import {
19
19
  attributes_exports,
20
20
  getDataCaptureMode,
@@ -1,6 +1,6 @@
1
1
  import * as _opentelemetry_api from '@opentelemetry/api';
2
2
  import { Attributes } from '@opentelemetry/api';
3
- import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-Kts5RGLY.mjs';
3
+ import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-5h2Im4pl.mjs';
4
4
  import { AgentAction, AgentFinish } from '@langchain/core/agents';
5
5
  import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
6
6
  import { DocumentInterface } from '@langchain/core/documents';
@@ -1,6 +1,6 @@
1
1
  import * as _opentelemetry_api from '@opentelemetry/api';
2
2
  import { Attributes } from '@opentelemetry/api';
3
- import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-usU5mTCX.js';
3
+ import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-fo-Ij9pl.js';
4
4
  import { AgentAction, AgentFinish } from '@langchain/core/agents';
5
5
  import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
6
6
  import { DocumentInterface } from '@langchain/core/documents';
@@ -2,14 +2,14 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkJQYW7RY7js = require('../../../chunk-JQYW7RY7.js');
5
+ var _chunkBQRUUTN3js = require('../../../chunk-BQRUUTN3.js');
6
6
 
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- var _chunkN7PJJMU2js = require('../../../chunk-N7PJJMU2.js');
12
+ var _chunkC4XUWCQRjs = require('../../../chunk-C4XUWCQR.js');
13
13
 
14
14
 
15
15
 
@@ -30,12 +30,12 @@ var _resources = require('@opentelemetry/resources');
30
30
  var _incubating = require('@opentelemetry/semantic-conventions/incubating'); var semconv = _interopRequireWildcard(_incubating);
31
31
  function createMergedResource(attributes, serviceName, givenResource) {
32
32
  const langwatchResource = _resources.resourceFromAttributes.call(void 0, {
33
- [semconv.ATTR_TELEMETRY_SDK_NAME]: _chunkN7PJJMU2js.LANGWATCH_SDK_NAME_OBSERVABILITY,
34
- [semconv.ATTR_TELEMETRY_SDK_LANGUAGE]: _chunkN7PJJMU2js.LANGWATCH_SDK_LANGUAGE,
35
- [semconv.ATTR_TELEMETRY_SDK_VERSION]: _chunkN7PJJMU2js.LANGWATCH_SDK_VERSION
33
+ [semconv.ATTR_TELEMETRY_SDK_NAME]: _chunkC4XUWCQRjs.LANGWATCH_SDK_NAME_OBSERVABILITY,
34
+ [semconv.ATTR_TELEMETRY_SDK_LANGUAGE]: _chunkC4XUWCQRjs.LANGWATCH_SDK_LANGUAGE,
35
+ [semconv.ATTR_TELEMETRY_SDK_VERSION]: _chunkC4XUWCQRjs.LANGWATCH_SDK_VERSION
36
36
  });
37
37
  const userResource = _resources.resourceFromAttributes.call(void 0, _chunkOHM7JUMRjs.__spreadValues.call(void 0, {
38
- [semconv.ATTR_SERVICE_NAME]: serviceName != null ? serviceName : _chunkN7PJJMU2js.DEFAULT_SERVICE_NAME
38
+ [semconv.ATTR_SERVICE_NAME]: serviceName != null ? serviceName : _chunkC4XUWCQRjs.DEFAULT_SERVICE_NAME
39
39
  }, attributes != null ? attributes : {}));
40
40
  return (givenResource != null ? givenResource : _resources.defaultResource.call(void 0, )).merge(langwatchResource).merge(userResource);
41
41
  }
@@ -91,7 +91,7 @@ var getLangWatchConfig = (options) => {
91
91
  return {
92
92
  disabled: isDisabled,
93
93
  apiKey: isDisabled ? void 0 : (_a = config.apiKey) != null ? _a : process.env.LANGWATCH_API_KEY,
94
- endpoint: isDisabled ? void 0 : (_c = (_b = config.endpoint) != null ? _b : process.env.LANGWATCH_ENDPOINT) != null ? _c : _chunkN7PJJMU2js.DEFAULT_ENDPOINT,
94
+ endpoint: isDisabled ? void 0 : (_c = (_b = config.endpoint) != null ? _b : process.env.LANGWATCH_ENDPOINT) != null ? _c : _chunkC4XUWCQRjs.DEFAULT_ENDPOINT,
95
95
  processorType: (_d = config.processorType) != null ? _d : "simple"
96
96
  };
97
97
  };
@@ -198,11 +198,11 @@ function createAndStartNodeSdk(options, logger, resource) {
198
198
  logger.debug("Console recording of logs enabled; adding console log record processor");
199
199
  }
200
200
  if (!langwatch.disabled) {
201
- const traceExporter = new (0, _chunkJQYW7RY7js.LangWatchTraceExporter)({
201
+ const traceExporter = new (0, _chunkBQRUUTN3js.LangWatchTraceExporter)({
202
202
  apiKey: langwatch.apiKey,
203
203
  endpoint: langwatch.endpoint
204
204
  });
205
- const logExporter = new (0, _chunkJQYW7RY7js.LangWatchLogsExporter)({
205
+ const logExporter = new (0, _chunkBQRUUTN3js.LangWatchLogsExporter)({
206
206
  apiKey: langwatch.apiKey,
207
207
  endpoint: langwatch.endpoint
208
208
  });
@@ -272,7 +272,7 @@ function createAndStartNodeSdk(options, logger, resource) {
272
272
  });
273
273
  }
274
274
  if (loggerProvider) {
275
- _chunkJQYW7RY7js.setLangWatchLoggerProvider.call(void 0, loggerProvider);
275
+ _chunkBQRUUTN3js.setLangWatchLoggerProvider.call(void 0, loggerProvider);
276
276
  logger.debug("Set LangWatch logger provider");
277
277
  }
278
278
  if (!((_e = options.advanced) == null ? void 0 : _e.disableAutoShutdown)) {
@@ -2,14 +2,14 @@ import {
2
2
  LangWatchLogsExporter,
3
3
  LangWatchTraceExporter,
4
4
  setLangWatchLoggerProvider
5
- } from "../../../chunk-556ZFJMK.mjs";
5
+ } from "../../../chunk-WCNDT5SD.mjs";
6
6
  import {
7
7
  DEFAULT_ENDPOINT,
8
8
  DEFAULT_SERVICE_NAME,
9
9
  LANGWATCH_SDK_LANGUAGE,
10
10
  LANGWATCH_SDK_NAME_OBSERVABILITY,
11
11
  LANGWATCH_SDK_VERSION
12
- } from "../../../chunk-LKE6DMUP.mjs";
12
+ } from "../../../chunk-TB5KB737.mjs";
13
13
  import {
14
14
  ConsoleLogger,
15
15
  initializeObservabilitySdkConfig
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  PromptsError
3
- } from "./chunk-WZ7FYUHN.mjs";
3
+ } from "./chunk-OTID7S7K.mjs";
4
4
  import "./chunk-ZEPKV5YO.mjs";
5
5
  import "./chunk-IIUI2XYW.mjs";
6
- import "./chunk-556ZFJMK.mjs";
7
- import "./chunk-LKE6DMUP.mjs";
6
+ import "./chunk-WCNDT5SD.mjs";
7
+ import "./chunk-TB5KB737.mjs";
8
8
  import "./chunk-RSIPLYVA.mjs";
9
9
  import {
10
10
  FileManager
@@ -106,4 +106,4 @@ var removeCommand = async (name) => {
106
106
  export {
107
107
  removeCommand
108
108
  };
109
- //# sourceMappingURL=remove-F5RM4775.mjs.map
109
+ //# sourceMappingURL=remove-2OGMXSTR.mjs.map
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkD4H6PR6Hjs = require('./chunk-D4H6PR6H.js');
3
+ var _chunk6SSCBYJMjs = require('./chunk-6SSCBYJM.js');
4
4
  require('./chunk-ASTAIRXG.js');
5
5
  require('./chunk-ONXIZKC6.js');
6
- require('./chunk-JQYW7RY7.js');
7
- require('./chunk-N7PJJMU2.js');
6
+ require('./chunk-BQRUUTN3.js');
7
+ require('./chunk-C4XUWCQR.js');
8
8
  require('./chunk-5MQQRSVM.js');
9
9
 
10
10
 
@@ -87,7 +87,7 @@ var removeCommand = async (name) => {
87
87
  }
88
88
  } catch (error) {
89
89
  spinner.fail();
90
- if (error instanceof _chunkD4H6PR6Hjs.PromptsError) {
90
+ if (error instanceof _chunk6SSCBYJMjs.PromptsError) {
91
91
  console.error(_chalk2.default.red(`Error: ${error.message}`));
92
92
  } else {
93
93
  console.error(_chalk2.default.red(`Error removing prompt: ${error instanceof Error ? error.message : "Unknown error"}`));
@@ -95,7 +95,7 @@ var removeCommand = async (name) => {
95
95
  process.exit(1);
96
96
  }
97
97
  } catch (error) {
98
- if (error instanceof _chunkD4H6PR6Hjs.PromptsError) {
98
+ if (error instanceof _chunk6SSCBYJMjs.PromptsError) {
99
99
  console.error(_chalk2.default.red(`Error: ${error.message}`));
100
100
  } else {
101
101
  console.error(_chalk2.default.red(`Unexpected error: ${error instanceof Error ? error.message : "Unknown error"}`));
@@ -106,4 +106,4 @@ var removeCommand = async (name) => {
106
106
 
107
107
 
108
108
  exports.removeCommand = removeCommand;
109
- //# sourceMappingURL=remove-V4JL5Z4U.js.map
109
+ //# sourceMappingURL=remove-A4DKCN7A.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-V4JL5Z4U.js","../src/cli/commands/remove.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACdA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAClB,oEAAgB;AAIT,IAAM,cAAA,EAAgB,MAAA,CAAO,IAAA,EAAA,GAAgC;AAClE,EAAA,IAAI;AAEF,IAAA,GAAA,CAAI,CAAC,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,EAAA,IAAM,EAAA,EAAI;AAC/B,MAAA,OAAA,CAAQ,KAAA,CAAM,eAAA,CAAM,GAAA,CAAI,oCAAoC,CAAC,CAAA;AAC7D,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAAA,IAChB;AAGA,IAAA,MAAM,OAAA,EAAS,4BAAA,CAAY,iBAAA,CAAkB,CAAA;AAC7C,IAAA,MAAM,KAAA,EAAO,4BAAA,CAAY,eAAA,CAAgB,CAAA;AAGzC,IAAA,GAAA,CAAI,CAAC,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AACzB,MAAA,OAAA,CAAQ,KAAA,CAAM,eAAA,CAAM,GAAA,CAAI,CAAA,eAAA,EAAkB,IAAI,CAAA,2BAAA,CAA6B,CAAC,CAAA;AAC5E,MAAA,OAAA,CAAQ,GAAA,CAAI,eAAA,CAAM,IAAA,CAAK,CAAA,mBAAA,EAAsB,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,IAAI,EAAA,GAAK,MAAM,CAAA,CAAA;AAC/E,MAAA;AAChB,IAAA;AAEsC,IAAA;AAEhB,IAAA;AAEuC,IAAA;AAEzD,IAAA;AAEiB,MAAA;AACb,QAAA;AAEkE,QAAA;AACpB,UAAA;AACY,QAAA;AAChB,UAAA;AACvC,QAAA;AAEuE,UAAA;AAC9E,QAAA;AAGkC,QAAA;AACL,UAAA;AACoC,UAAA;AAC/C,UAAA;AAC2D,UAAA;AACtE,QAAA;AACW,UAAA;AACqD,UAAA;AACvE,QAAA;AAEyB,QAAA;AAC3B,MAAA;AAGmC,MAAA;AACN,MAAA;AACiC,QAAA;AACvB,QAAA;AACL,UAAA;AAGuB,UAAA;AACM,UAAA;AAE1C,UAAA;AACqE,UAAA;AAChF,YAAA;AACuC,cAAA;AACf,cAAA;AACD,gBAAA;AACa,gBAAA;AAC/B,cAAA;AACL,gBAAA;AACF,cAAA;AACM,YAAA;AACN,cAAA;AACF,YAAA;AACF,UAAA;AACF,QAAA;AACF,MAAA;AAG0B,MAAA;AACF,MAAA;AAGY,MAAA;AACJ,MAAA;AAEZ,MAAA;AACF,QAAA;AAC0D,QAAA;AAC5E,MAAA;AAEc,IAAA;AACD,MAAA;AACsB,MAAA;AACiB,QAAA;AAC7C,MAAA;AACsF,QAAA;AAC7F,MAAA;AACc,MAAA;AAChB,IAAA;AAEc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACiF,MAAA;AACxF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADdoG;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-V4JL5Z4U.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptsError } from \"@/client-sdk/services/prompts\";\n\nexport const removeCommand = async (name: string): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Load existing config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n // Check if prompt exists in dependencies\n if (!config.prompts[name]) {\n console.error(chalk.red(`Error: Prompt \"${name}\" not found in dependencies`));\n console.log(chalk.gray(`Available prompts: ${Object.keys(config.prompts).join(', ') || 'none'}`));\n process.exit(1);\n }\n\n const dependency = config.prompts[name];\n const isLocalPrompt = (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) ||\n (typeof dependency === \"object\" && dependency.file);\n\n const spinner = ora(`Removing ${chalk.cyan(name)}...`).start();\n\n try {\n // Handle local prompts\n if (isLocalPrompt) {\n let localFilePath: string;\n\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n localFilePath = path.resolve(dependency.slice(5)); // Remove \"file:\" prefix\n } else if (typeof dependency === \"object\" && dependency.file) {\n localFilePath = path.resolve(dependency.file);\n } else {\n // Fallback: assume it's in the prompts directory\n localFilePath = path.join(FileManager.getPromptsDir(), `${name}.prompt.yaml`);\n }\n\n // Delete the local file if it exists\n if (fs.existsSync(localFilePath)) {\n fs.unlinkSync(localFilePath);\n const relativePath = path.relative(process.cwd(), localFilePath);\n spinner.succeed();\n console.log(chalk.green(`✓ Removed local file ${chalk.gray(relativePath)}`));\n } else {\n spinner.succeed();\n console.log(chalk.yellow(`⚠ Local file not found (already deleted?)`));\n }\n\n console.log(chalk.yellow(`⚠ Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));\n }\n\n // Remove materialized file if it exists\n const lockEntry = lock.prompts[name];\n if (lockEntry?.materialized) {\n const materializedPath = path.resolve(lockEntry.materialized);\n if (fs.existsSync(materializedPath)) {\n fs.unlinkSync(materializedPath);\n\n // Clean up empty directories\n const materializedDir = path.dirname(materializedPath);\n const rootMaterializedDir = FileManager.getMaterializedDir();\n\n let currentDir = materializedDir;\n while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {\n try {\n const entries = fs.readdirSync(currentDir);\n if (entries.length === 0) {\n fs.rmdirSync(currentDir);\n currentDir = path.dirname(currentDir);\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n }\n }\n\n // Remove from config and lock\n delete config.prompts[name];\n delete lock.prompts[name];\n\n // Save updated files\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n if (!isLocalPrompt) {\n spinner.succeed();\n console.log(chalk.green(`✓ Removed ${chalk.cyan(name)} from dependencies`));\n }\n\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Error removing prompt: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Unexpected error: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n};\n"]}
1
+ {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-A4DKCN7A.js","../src/cli/commands/remove.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACdA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAClB,oEAAgB;AAIT,IAAM,cAAA,EAAgB,MAAA,CAAO,IAAA,EAAA,GAAgC;AAClE,EAAA,IAAI;AAEF,IAAA,GAAA,CAAI,CAAC,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,EAAA,IAAM,EAAA,EAAI;AAC/B,MAAA,OAAA,CAAQ,KAAA,CAAM,eAAA,CAAM,GAAA,CAAI,oCAAoC,CAAC,CAAA;AAC7D,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAC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D,MAAA;AACsB,MAAA;AACiB,QAAA;AAC7C,MAAA;AACsF,QAAA;AAC7F,MAAA;AACc,MAAA;AAChB,IAAA;AAEc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACiF,MAAA;AACxF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADdoG;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-A4DKCN7A.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptsError } from \"@/client-sdk/services/prompts\";\n\nexport const removeCommand = async (name: string): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Load existing config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n // Check if prompt exists in dependencies\n if (!config.prompts[name]) {\n console.error(chalk.red(`Error: Prompt \"${name}\" not found in dependencies`));\n console.log(chalk.gray(`Available prompts: ${Object.keys(config.prompts).join(', ') || 'none'}`));\n process.exit(1);\n }\n\n const dependency = config.prompts[name];\n const isLocalPrompt = (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) ||\n (typeof dependency === \"object\" && dependency.file);\n\n const spinner = ora(`Removing ${chalk.cyan(name)}...`).start();\n\n try {\n // Handle local prompts\n if (isLocalPrompt) {\n let localFilePath: string;\n\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n localFilePath = path.resolve(dependency.slice(5)); // Remove \"file:\" prefix\n } else if (typeof dependency === \"object\" && dependency.file) {\n localFilePath = path.resolve(dependency.file);\n } else {\n // Fallback: assume it's in the prompts directory\n localFilePath = path.join(FileManager.getPromptsDir(), `${name}.prompt.yaml`);\n }\n\n // Delete the local file if it exists\n if (fs.existsSync(localFilePath)) {\n fs.unlinkSync(localFilePath);\n const relativePath = path.relative(process.cwd(), localFilePath);\n spinner.succeed();\n console.log(chalk.green(`✓ Removed local file ${chalk.gray(relativePath)}`));\n } else {\n spinner.succeed();\n console.log(chalk.yellow(`⚠ Local file not found (already deleted?)`));\n }\n\n console.log(chalk.yellow(`⚠ Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));\n }\n\n // Remove materialized file if it exists\n const lockEntry = lock.prompts[name];\n if (lockEntry?.materialized) {\n const materializedPath = path.resolve(lockEntry.materialized);\n if (fs.existsSync(materializedPath)) {\n fs.unlinkSync(materializedPath);\n\n // Clean up empty directories\n const materializedDir = path.dirname(materializedPath);\n const rootMaterializedDir = FileManager.getMaterializedDir();\n\n let currentDir = materializedDir;\n while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {\n try {\n const entries = fs.readdirSync(currentDir);\n if (entries.length === 0) {\n fs.rmdirSync(currentDir);\n currentDir = path.dirname(currentDir);\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n }\n }\n\n // Remove from config and lock\n delete config.prompts[name];\n delete lock.prompts[name];\n\n // Save updated files\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n if (!isLocalPrompt) {\n spinner.succeed();\n console.log(chalk.green(`✓ Removed ${chalk.cyan(name)} from dependencies`));\n }\n\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Error removing prompt: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Unexpected error: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n};\n"]}
@@ -4,11 +4,11 @@ import {
4
4
  import {
5
5
  PromptsApiService,
6
6
  PromptsError
7
- } from "./chunk-WZ7FYUHN.mjs";
7
+ } from "./chunk-OTID7S7K.mjs";
8
8
  import "./chunk-ZEPKV5YO.mjs";
9
9
  import "./chunk-IIUI2XYW.mjs";
10
- import "./chunk-556ZFJMK.mjs";
11
- import "./chunk-LKE6DMUP.mjs";
10
+ import "./chunk-WCNDT5SD.mjs";
11
+ import "./chunk-TB5KB737.mjs";
12
12
  import "./chunk-RSIPLYVA.mjs";
13
13
  import {
14
14
  ensureProjectInitialized
@@ -410,4 +410,4 @@ Tip: Add these to prompts.json to include them in sync operations.`
410
410
  export {
411
411
  syncCommand
412
412
  };
413
- //# sourceMappingURL=sync-VGWOLOLJ.mjs.map
413
+ //# sourceMappingURL=sync-TNVCKWTC.mjs.map
@@ -4,11 +4,11 @@ var _chunkF6E4XQQUjs = require('./chunk-F6E4XQQU.js');
4
4
 
5
5
 
6
6
 
7
- var _chunkD4H6PR6Hjs = require('./chunk-D4H6PR6H.js');
7
+ var _chunk6SSCBYJMjs = require('./chunk-6SSCBYJM.js');
8
8
  require('./chunk-ASTAIRXG.js');
9
9
  require('./chunk-ONXIZKC6.js');
10
- require('./chunk-JQYW7RY7.js');
11
- require('./chunk-N7PJJMU2.js');
10
+ require('./chunk-BQRUUTN3.js');
11
+ require('./chunk-C4XUWCQR.js');
12
12
  require('./chunk-5MQQRSVM.js');
13
13
 
14
14
 
@@ -74,7 +74,7 @@ var syncCommand = async () => {
74
74
  const startTime = Date.now();
75
75
  try {
76
76
  _chunkF6E4XQQUjs.checkApiKey.call(void 0, );
77
- const promptsApiService = new (0, _chunkD4H6PR6Hjs.PromptsApiService)();
77
+ const promptsApiService = new (0, _chunk6SSCBYJMjs.PromptsApiService)();
78
78
  await _chunkBYG3QS2Xjs.ensureProjectInitialized.call(void 0, false);
79
79
  const config = _chunkWAAQLJ67js.FileManager.loadPromptsConfig();
80
80
  const lock = _chunkWAAQLJ67js.FileManager.loadPromptsLock();
@@ -395,7 +395,7 @@ Tip: Add these to prompts.json to include them in sync operations.`
395
395
  process.exit(1);
396
396
  }
397
397
  } catch (error) {
398
- if (error instanceof _chunkD4H6PR6Hjs.PromptsError) {
398
+ if (error instanceof _chunk6SSCBYJMjs.PromptsError) {
399
399
  console.error(_chalk2.default.red(`Error: ${error.message}`));
400
400
  } else {
401
401
  console.error(
@@ -410,4 +410,4 @@ Tip: Add these to prompts.json to include them in sync operations.`
410
410
 
411
411
 
412
412
  exports.syncCommand = syncCommand;
413
- //# sourceMappingURL=sync-DIOKWE6R.js.map
413
+ //# sourceMappingURL=sync-WRZXIBZS.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-DIOKWE6R.js","../src/cli/commands/sync.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACA;ACzBA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAClB,oEAAgB;AAChB,8EAAsB;AAYtB,wFAAqB;AAGrB,IAAM,eAAA,EAAiB,MAAA,CACrB,UAAA,EACA,YAAA,EAAA,GAM0C;AAC1C,EAAA,OAAA,CAAQ,GAAA;AAAA,IACN,eAAA,CAAM,MAAA,CAAO,CAAA;AAAA,qCAAA,EAAqC,eAAA,CAAM,IAAA,CAAK,UAAU,CAAC,CAAA,CAAA;AAC1E,EAAA;AACQ,EAAA;AACA,IAAA;AACuC,MAAA;AAC7C,IAAA;AACF,EAAA;AAEyC,EAAA;AACG,IAAA;AACC,IAAA;AACJ,MAAA;AACtC,IAAA;AACH,EAAA;AAEsC,EAAA;AACkB,EAAA;AACA,EAAA;AACV,EAAA;AAEV,EAAA;AACnB,IAAA;AACC,IAAA;AACjB,EAAA;AAE+B,EAAA;AACiC,IAAA;AACpD,MAAA;AACyB,MAAA;A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;AAG8B,IAAA;AACiB,MAAA;AACM,QAAA;AACnD,MAAA;AACF,IAAA;AAG2D,IAAA;AAE1B,IAAA;AAEqB,IAAA;AACR,MAAA;AACvC,IAAA;AACY,MAAA;AACW,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AACnB,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AAEI,MAAA;AACrD,IAAA;AAE8B,IAAA;AACd,MAAA;AAChB,IAAA;AACc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACG,MAAA;AACA,QAAA;AAE6B,UAAA;AAEnC,QAAA;AACF,MAAA;AACF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;AD9G8D;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-DIOKWE6R.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport * as yaml from \"js-yaml\";\nimport { PromptConverter } from \"@/cli/utils/promptConverter\";\nimport {\n type ConfigData,\n PromptsApiService,\n PromptsError,\n type SyncAction,\n} from \"@/client-sdk/services/prompts\";\nimport type { SyncResult } from \"../types\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { ensureProjectInitialized } from \"../utils/init\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport readline from \"node:readline\";\n\n// Handle conflict resolution - show diff and ask user to choose\nconst handleConflict = async (\n promptName: string,\n conflictInfo: {\n localVersion: number;\n remoteVersion: number;\n differences: string[];\n remoteConfigData: any;\n }\n): Promise<\"local\" | \"remote\" | \"abort\"> => {\n console.log(\n chalk.yellow(`\\n⚠ Conflict detected for prompt: ${chalk.cyan(promptName)}`)\n );\n console.log(\n chalk.gray(\n `Local version: ${conflictInfo.localVersion}, Remote version: ${conflictInfo.remoteVersion}`\n )\n );\n\n if (conflictInfo.differences.length > 0) {\n console.log(chalk.yellow(\"\\nDifferences:\"));\n conflictInfo.differences.forEach((diff) => {\n console.log(chalk.gray(` • ${diff}`));\n });\n }\n\n console.log(chalk.yellow(\"\\nOptions:\"));\n console.log(\" [l] Use local version (overwrite remote)\");\n console.log(\" [r] Use remote version (overwrite local)\");\n console.log(\" [a] Abort sync for this prompt\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(\"Choose resolution (l/r/a): \", (answer: string) => {\n rl.close();\n const choice = answer.toLowerCase();\n if (choice === \"l\" || choice === \"local\") {\n resolve(\"local\");\n } else if (choice === \"r\" || choice === \"remote\") {\n resolve(\"remote\");\n } else {\n resolve(\"abort\");\n }\n });\n });\n};\n\nexport const syncCommand = async (): Promise<void> => {\n console.log(\"🔄 Starting sync...\");\n\n const startTime = Date.now();\n\n try {\n // Check API key before doing anything else\n checkApiKey();\n\n // Get prompts API service\n const promptsApiService = new PromptsApiService();\n\n // Ensure project is initialized (prompts.json, lock file, directories)\n await ensureProjectInitialized(false); // Don't prompt for .gitignore in sync\n\n // Load prompts config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n const result: SyncResult = {\n fetched: [],\n pushed: [],\n unchanged: [],\n cleaned: [],\n errors: [],\n };\n\n // Process remote prompts (fetch and materialize)\n const remoteDeps = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n // Skip local file dependencies (both object format and string format)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n }\n );\n\n if (remoteDeps.length > 0) {\n const fetchSpinner = ora(\n `Checking ${remoteDeps.length} remote prompts...`\n ).start();\n\n for (const [name, dependency] of remoteDeps) {\n try {\n const versionSpec =\n typeof dependency === \"string\"\n ? dependency\n : dependency.version ?? \"latest\";\n\n // Check if we already have this prompt with the same version\n const lockEntry = lock.prompts[name];\n\n // Fetch the prompt from the API to check current version\n const prompt = await promptsApiService.get(name, { version: versionSpec });\n\n if (prompt) {\n // Check if we need to update (new version or not materialized)\n const needsUpdate =\n lockEntry?.version !== prompt.version ||\n !lockEntry.materialized ||\n !fs.existsSync(path.resolve(lockEntry.materialized));\n\n if (needsUpdate) {\n // Convert to MaterializedPrompt format using the converter\n const materializedPrompt =\n PromptConverter.fromApiToMaterialized(prompt);\n\n const savedPath = FileManager.saveMaterializedPrompt(\n name,\n materializedPrompt\n );\n const relativePath = path.relative(process.cwd(), savedPath);\n result.fetched.push({\n name,\n version: prompt.version,\n versionSpec,\n });\n\n // Update lock file entry\n FileManager.updateLockEntry(\n lock,\n name,\n materializedPrompt,\n savedPath\n );\n\n fetchSpinner.text = `Fetched ${chalk.cyan(\n `${name}@${versionSpec}`\n )} ${chalk.gray(`(version ${prompt.version})`)} → ${chalk.gray(\n relativePath\n )}`;\n } else {\n // No change needed, track as unchanged\n result.unchanged.push(name);\n }\n } else {\n result.errors.push({ name, error: \"Prompt not found\" });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name, error: errorMessage });\n }\n }\n\n fetchSpinner.stop();\n }\n\n // Process local prompts (push to API) - only those explicitly declared in prompts.json\n const localFileRefs = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n return typeof dependency === \"string\" && dependency.startsWith(\"file:\");\n }\n );\n\n if (localFileRefs.length > 0) {\n const pushSpinner = ora(\n `Pushing ${localFileRefs.length} local prompts...`\n ).start();\n\n // Use the existing lock file instead of reloading it\n // const lock = FileManager.loadPromptsLock(); // Don't reload - use existing lock\n\n for (const [promptName, dependency] of localFileRefs) {\n try {\n const filePath = (dependency as string).slice(5); // Remove \"file:\" prefix\n\n // Load local prompt config\n const localConfig = FileManager.loadLocalPrompt(filePath);\n\n // Get current version from lock file\n const currentVersion = lock.prompts[promptName]?.version;\n\n // Convert local config to API configData format\n const configData: ConfigData = {\n model: localConfig.model,\n prompt: PromptConverter.extractSystemPrompt(localConfig.messages),\n messages: PromptConverter.filterNonSystemMessages(\n localConfig.messages\n ) as Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>,\n temperature: localConfig.modelParameters?.temperature,\n max_tokens: localConfig.modelParameters?.max_tokens,\n inputs: [{ identifier: \"input\", type: \"str\" }],\n outputs: [{ identifier: \"output\", type: \"str\" }],\n };\n\n // Use new sync API with conflict detection\n const syncResult = await promptsApiService.sync({\n name: promptName,\n configData,\n localVersion: currentVersion,\n commitMessage: `Synced from local file: ${path.basename(filePath)}`,\n });\n\n const relativePath = path.relative(process.cwd(), filePath);\n\n let conflictResolution: \"local\" | \"remote\" | \"abort\" | null = null;\n if (syncResult.action === \"conflict\") {\n // Handle conflict - prompt user for resolution\n pushSpinner.stop();\n conflictResolution = await handleConflict(\n promptName,\n syncResult.conflictInfo!\n );\n if (conflictResolution === \"abort\") {\n result.errors.push({\n name: promptName,\n error: \"Sync aborted due to conflict\",\n });\n continue;\n }\n\n // If user chose remote, we should pull the remote version to local file\n if (conflictResolution === \"remote\" && syncResult.conflictInfo) {\n // Update local file with remote content\n const remoteConfig = {\n model: syncResult.conflictInfo.remoteConfigData.model,\n modelParameters: {\n temperature:\n syncResult.conflictInfo.remoteConfigData.temperature,\n max_tokens:\n syncResult.conflictInfo.remoteConfigData.max_tokens,\n },\n messages: [\n {\n role: \"system\" as const,\n content: syncResult.conflictInfo.remoteConfigData.prompt,\n },\n ...(syncResult.conflictInfo.remoteConfigData.messages ?? []),\n ],\n };\n\n const yamlContent = yaml.dump(remoteConfig, {\n lineWidth: -1,\n noRefs: true,\n sortKeys: false,\n });\n\n fs.writeFileSync(filePath, yamlContent);\n }\n\n // If user chose to proceed, we continue with the sync\n pushSpinner.start();\n }\n\n // Update lock file with new version info\n if (syncResult.prompt) {\n lock.prompts[promptName] = {\n version: syncResult.prompt.version,\n versionId: syncResult.prompt.versionId,\n materialized: filePath,\n };\n } else if (syncResult.action === \"conflict\") {\n const remoteVersion = syncResult.conflictInfo?.remoteVersion ?? 0;\n if (conflictResolution === \"remote\") {\n // User chose remote - use remote version\n lock.prompts[promptName] = {\n version: remoteVersion,\n versionId: \"remote_version\", // We don't have the actual versionId from conflict info\n materialized: filePath,\n };\n } else {\n // User chose local - force push\n const formattedConfig = PromptConverter.fromLocalToApiFormat(localConfig);\n const updatedPrompt = await promptsApiService.update(promptName, {\n ...formattedConfig,\n commitMessage: `Updated via CLI: synced from local file`\n });\n lock.prompts[promptName] = {\n version: updatedPrompt.version,\n versionId: updatedPrompt.versionId,\n materialized: filePath,\n };\n }\n }\n\n // Determine the action text based on sync result and conflict resolution\n let actionText: string;\n if (syncResult.action === \"conflict\") {\n if (conflictResolution === \"remote\") {\n actionText = \"Pulled\"; // User chose to use remote version\n result.fetched.push({\n name: promptName,\n version: syncResult.conflictInfo?.remoteVersion ?? 0,\n versionSpec: \"latest\", // Default for conflict resolution\n });\n } else {\n actionText = \"Pushed\"; // User chose to use local version (or forced push)\n result.pushed.push({\n name: promptName,\n version: (syncResult.conflictInfo?.remoteVersion ?? 0) + 1, // New version after push\n });\n }\n } else if (syncResult.action === \"up_to_date\") {\n // For up-to-date prompts, add to unchanged instead of pushed\n actionText = \"Up-to-date\";\n result.unchanged.push(promptName);\n } else {\n const actionMap: Record<SyncAction, string> = {\n created: \"Created\",\n updated: \"Updated\",\n conflict: \"Conflict resolved\",\n up_to_date: \"Up to date\",\n };\n actionText = actionMap[syncResult.action as SyncAction] || \"Pushed\";\n result.pushed.push({\n name: promptName,\n version: syncResult.prompt?.version ?? 0,\n });\n }\n\n pushSpinner.text = `${actionText} ${chalk.cyan(\n promptName\n )} ${chalk.gray(\n `(version ${\n syncResult.prompt?.version ??\n syncResult.conflictInfo?.remoteVersion ??\n \"unknown\"\n })`\n )} ${conflictResolution === \"remote\" ? \"to\" : \"from\"} ${chalk.gray(\n relativePath\n )}`;\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name: promptName, error: errorMessage });\n }\n }\n\n // Save lock file with all updates\n FileManager.savePromptsLock(lock);\n\n pushSpinner.stop();\n }\n\n // Check for orphan local prompt files and show helpful warnings\n const discoveredLocalFiles = FileManager.getLocalPromptFiles();\n const orphanFiles = discoveredLocalFiles.filter((filePath) => {\n const promptName = FileManager.promptNameFromPath(filePath);\n return !config.prompts[promptName]; // Not declared in prompts.json\n });\n\n if (orphanFiles.length > 0) {\n console.log(\n chalk.yellow(\n `\\n⚠ Found ${orphanFiles.length} orphan prompt file${\n orphanFiles.length > 1 ? \"s\" : \"\"\n }:`\n )\n );\n\n for (const filePath of orphanFiles) {\n const promptName = FileManager.promptNameFromPath(filePath);\n const relativePath = path.relative(process.cwd(), filePath);\n\n console.log(chalk.yellow(` ${relativePath}`));\n console.log(\n chalk.gray(\n ` Add to prompts.json: \"${promptName}\": \"file:${relativePath}\"`\n )\n );\n }\n\n console.log(\n chalk.gray(\n `\\nTip: Add these to prompts.json to include them in sync operations.`\n )\n );\n }\n\n // Cleanup orphaned materialized files\n const currentDependencies = new Set(\n Object.keys(config.prompts).filter((name) => {\n const dependency = config.prompts[name];\n // Only include remote dependencies (not local file: dependencies)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n })\n );\n\n const cleanedFiles =\n FileManager.cleanupOrphanedMaterializedFiles(currentDependencies);\n if (cleanedFiles.length > 0) {\n result.cleaned = cleanedFiles;\n FileManager.removeFromLock(lock, cleanedFiles);\n }\n\n // Save the updated lock file\n FileManager.savePromptsLock(lock);\n\n // Print individual results if there were actions\n if (result.fetched.length > 0) {\n for (const { name, version, versionSpec } of result.fetched) {\n // Get the actual saved path from lock file for display consistency\n const lockEntry = lock.prompts[name];\n const displayPath = lockEntry?.materialized\n ? `./${lockEntry.materialized}`\n : `./prompts/.materialized/${name}.prompt.yaml`;\n\n console.log(\n chalk.green(\n `✓ Pulled ${chalk.cyan(`${name}@${versionSpec}`)} ${chalk.gray(\n `(version ${version})`\n )} → ${chalk.gray(displayPath)}`\n )\n );\n }\n }\n\n if (result.pushed.length > 0) {\n for (const { name, version } of result.pushed) {\n const localPath = `./prompts/${name}.prompt.yaml`;\n console.log(\n chalk.green(\n `✓ Pushed ${chalk.cyan(name)} ${chalk.gray(\n `(version ${version})`\n )} from ${chalk.gray(localPath)}`\n )\n );\n }\n }\n\n // Print cleaned up files\n if (result.cleaned.length > 0) {\n for (const name of result.cleaned) {\n console.log(\n chalk.yellow(\n `✓ Cleaned ${chalk.cyan(name)} (no longer in dependencies)`\n )\n );\n }\n }\n\n // Print errors\n if (result.errors.length > 0) {\n for (const { name, error } of result.errors) {\n console.log(chalk.red(`✗ Failed ${chalk.cyan(name)}: ${error}`));\n }\n }\n\n // Print summary\n const duration = ((Date.now() - startTime) / 1000).toFixed(1);\n const totalActions =\n result.fetched.length + result.pushed.length + result.cleaned.length;\n\n if (totalActions === 0 && result.errors.length === 0) {\n console.log(chalk.gray(`Synced in ${duration}s, no changes`));\n } else {\n const summary = [];\n if (result.fetched.length > 0)\n summary.push(`${result.fetched.length} fetched`);\n if (result.pushed.length > 0)\n summary.push(`${result.pushed.length} pushed`);\n if (result.cleaned.length > 0)\n summary.push(`${result.cleaned.length} cleaned`);\n if (result.errors.length > 0)\n summary.push(`${result.errors.length} errors`);\n\n console.log(chalk.gray(`Synced ${summary.join(\", \")} in ${duration}s`));\n }\n\n if (result.errors.length > 0) {\n process.exit(1);\n }\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Unexpected error: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`\n )\n );\n }\n process.exit(1);\n }\n};\n"]}
1
+ {"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-WRZXIBZS.js","../src/cli/commands/sync.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC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,YAAA;AACzC,UAAA;AACF,QAAA;AACF,MAAA;AAEQ,MAAA;AACA,QAAA;AACJ,UAAA;AAAA,kEAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAGgC,IAAA;AACe,MAAA;AACL,QAAA;AAEW,QAAA;AACxC,UAAA;AACT,QAAA;AACiD,QAAA;AACxC,UAAA;AACT,QAAA;AACO,QAAA;AACR,MAAA;AACH,IAAA;AAGc,IAAA;AACe,IAAA;AACV,MAAA;AAC4B,MAAA;AAC/C,IAAA;AAGgC,IAAA;AAGD,IAAA;AACuB,MAAA;AAEf,QAAA;AACf,QAAA;AAIZ,QAAA;AACA,UAAA;AACyC,YAAA;AACxB,cAAA;AACS,YAAA;AAChC,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAE8B,IAAA;AACmB,MAAA;AACV,QAAA;AAC3B,QAAA;AACA,UAAA;AACkC,YAAA;AACjB,cAAA;AACU,YAAA;AACjC,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAG+B,IAAA;AACM,MAAA;AACzB,QAAA;AACA,UAAA;AACyB,YAAA;AAC/B,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAG8B,IAAA;AACiB,MAAA;AACM,QAAA;AACnD,MAAA;AACF,IAAA;AAG2D,IAAA;AAE1B,IAAA;AAEqB,IAAA;AACR,MAAA;AACvC,IAAA;AACY,MAAA;AACW,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AACnB,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AAEI,MAAA;AACrD,IAAA;AAE8B,IAAA;AACd,MAAA;AAChB,IAAA;AACc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACG,MAAA;AACA,QAAA;AAE6B,UAAA;AAEnC,QAAA;AACF,MAAA;AACF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;AD9G8D;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-WRZXIBZS.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport * as yaml from \"js-yaml\";\nimport { PromptConverter } from \"@/cli/utils/promptConverter\";\nimport {\n type ConfigData,\n PromptsApiService,\n PromptsError,\n type SyncAction,\n} from \"@/client-sdk/services/prompts\";\nimport type { SyncResult } from \"../types\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { ensureProjectInitialized } from \"../utils/init\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport readline from \"node:readline\";\n\n// Handle conflict resolution - show diff and ask user to choose\nconst handleConflict = async (\n promptName: string,\n conflictInfo: {\n localVersion: number;\n remoteVersion: number;\n differences: string[];\n remoteConfigData: any;\n }\n): Promise<\"local\" | \"remote\" | \"abort\"> => {\n console.log(\n chalk.yellow(`\\n⚠ Conflict detected for prompt: ${chalk.cyan(promptName)}`)\n );\n console.log(\n chalk.gray(\n `Local version: ${conflictInfo.localVersion}, Remote version: ${conflictInfo.remoteVersion}`\n )\n );\n\n if (conflictInfo.differences.length > 0) {\n console.log(chalk.yellow(\"\\nDifferences:\"));\n conflictInfo.differences.forEach((diff) => {\n console.log(chalk.gray(` • ${diff}`));\n });\n }\n\n console.log(chalk.yellow(\"\\nOptions:\"));\n console.log(\" [l] Use local version (overwrite remote)\");\n console.log(\" [r] Use remote version (overwrite local)\");\n console.log(\" [a] Abort sync for this prompt\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(\"Choose resolution (l/r/a): \", (answer: string) => {\n rl.close();\n const choice = answer.toLowerCase();\n if (choice === \"l\" || choice === \"local\") {\n resolve(\"local\");\n } else if (choice === \"r\" || choice === \"remote\") {\n resolve(\"remote\");\n } else {\n resolve(\"abort\");\n }\n });\n });\n};\n\nexport const syncCommand = async (): Promise<void> => {\n console.log(\"🔄 Starting sync...\");\n\n const startTime = Date.now();\n\n try {\n // Check API key before doing anything else\n checkApiKey();\n\n // Get prompts API service\n const promptsApiService = new PromptsApiService();\n\n // Ensure project is initialized (prompts.json, lock file, directories)\n await ensureProjectInitialized(false); // Don't prompt for .gitignore in sync\n\n // Load prompts config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n const result: SyncResult = {\n fetched: [],\n pushed: [],\n unchanged: [],\n cleaned: [],\n errors: [],\n };\n\n // Process remote prompts (fetch and materialize)\n const remoteDeps = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n // Skip local file dependencies (both object format and string format)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n }\n );\n\n if (remoteDeps.length > 0) {\n const fetchSpinner = ora(\n `Checking ${remoteDeps.length} remote prompts...`\n ).start();\n\n for (const [name, dependency] of remoteDeps) {\n try {\n const versionSpec =\n typeof dependency === \"string\"\n ? dependency\n : dependency.version ?? \"latest\";\n\n // Check if we already have this prompt with the same version\n const lockEntry = lock.prompts[name];\n\n // Fetch the prompt from the API to check current version\n const prompt = await promptsApiService.get(name, { version: versionSpec });\n\n if (prompt) {\n // Check if we need to update (new version or not materialized)\n const needsUpdate =\n lockEntry?.version !== prompt.version ||\n !lockEntry.materialized ||\n !fs.existsSync(path.resolve(lockEntry.materialized));\n\n if (needsUpdate) {\n // Convert to MaterializedPrompt format using the converter\n const materializedPrompt =\n PromptConverter.fromApiToMaterialized(prompt);\n\n const savedPath = FileManager.saveMaterializedPrompt(\n name,\n materializedPrompt\n );\n const relativePath = path.relative(process.cwd(), savedPath);\n result.fetched.push({\n name,\n version: prompt.version,\n versionSpec,\n });\n\n // Update lock file entry\n FileManager.updateLockEntry(\n lock,\n name,\n materializedPrompt,\n savedPath\n );\n\n fetchSpinner.text = `Fetched ${chalk.cyan(\n `${name}@${versionSpec}`\n )} ${chalk.gray(`(version ${prompt.version})`)} → ${chalk.gray(\n relativePath\n )}`;\n } else {\n // No change needed, track as unchanged\n result.unchanged.push(name);\n }\n } else {\n result.errors.push({ name, error: \"Prompt not found\" });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name, error: errorMessage });\n }\n }\n\n fetchSpinner.stop();\n }\n\n // Process local prompts (push to API) - only those explicitly declared in prompts.json\n const localFileRefs = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n return typeof dependency === \"string\" && dependency.startsWith(\"file:\");\n }\n );\n\n if (localFileRefs.length > 0) {\n const pushSpinner = ora(\n `Pushing ${localFileRefs.length} local prompts...`\n ).start();\n\n // Use the existing lock file instead of reloading it\n // const lock = FileManager.loadPromptsLock(); // Don't reload - use existing lock\n\n for (const [promptName, dependency] of localFileRefs) {\n try {\n const filePath = (dependency as string).slice(5); // Remove \"file:\" prefix\n\n // Load local prompt config\n const localConfig = FileManager.loadLocalPrompt(filePath);\n\n // Get current version from lock file\n const currentVersion = lock.prompts[promptName]?.version;\n\n // Convert local config to API configData format\n const configData: ConfigData = {\n model: localConfig.model,\n prompt: PromptConverter.extractSystemPrompt(localConfig.messages),\n messages: PromptConverter.filterNonSystemMessages(\n localConfig.messages\n ) as Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>,\n temperature: localConfig.modelParameters?.temperature,\n max_tokens: localConfig.modelParameters?.max_tokens,\n inputs: [{ identifier: \"input\", type: \"str\" }],\n outputs: [{ identifier: \"output\", type: \"str\" }],\n };\n\n // Use new sync API with conflict detection\n const syncResult = await promptsApiService.sync({\n name: promptName,\n configData,\n localVersion: currentVersion,\n commitMessage: `Synced from local file: ${path.basename(filePath)}`,\n });\n\n const relativePath = path.relative(process.cwd(), filePath);\n\n let conflictResolution: \"local\" | \"remote\" | \"abort\" | null = null;\n if (syncResult.action === \"conflict\") {\n // Handle conflict - prompt user for resolution\n pushSpinner.stop();\n conflictResolution = await handleConflict(\n promptName,\n syncResult.conflictInfo!\n );\n if (conflictResolution === \"abort\") {\n result.errors.push({\n name: promptName,\n error: \"Sync aborted due to conflict\",\n });\n continue;\n }\n\n // If user chose remote, we should pull the remote version to local file\n if (conflictResolution === \"remote\" && syncResult.conflictInfo) {\n // Update local file with remote content\n const remoteConfig = {\n model: syncResult.conflictInfo.remoteConfigData.model,\n modelParameters: {\n temperature:\n syncResult.conflictInfo.remoteConfigData.temperature,\n max_tokens:\n syncResult.conflictInfo.remoteConfigData.max_tokens,\n },\n messages: [\n {\n role: \"system\" as const,\n content: syncResult.conflictInfo.remoteConfigData.prompt,\n },\n ...(syncResult.conflictInfo.remoteConfigData.messages ?? []),\n ],\n };\n\n const yamlContent = yaml.dump(remoteConfig, {\n lineWidth: -1,\n noRefs: true,\n sortKeys: false,\n });\n\n fs.writeFileSync(filePath, yamlContent);\n }\n\n // If user chose to proceed, we continue with the sync\n pushSpinner.start();\n }\n\n // Update lock file with new version info\n if (syncResult.prompt) {\n lock.prompts[promptName] = {\n version: syncResult.prompt.version,\n versionId: syncResult.prompt.versionId,\n materialized: filePath,\n };\n } else if (syncResult.action === \"conflict\") {\n const remoteVersion = syncResult.conflictInfo?.remoteVersion ?? 0;\n if (conflictResolution === \"remote\") {\n // User chose remote - use remote version\n lock.prompts[promptName] = {\n version: remoteVersion,\n versionId: \"remote_version\", // We don't have the actual versionId from conflict info\n materialized: filePath,\n };\n } else {\n // User chose local - force push\n const formattedConfig = PromptConverter.fromLocalToApiFormat(localConfig);\n const updatedPrompt = await promptsApiService.update(promptName, {\n ...formattedConfig,\n commitMessage: `Updated via CLI: synced from local file`\n });\n lock.prompts[promptName] = {\n version: updatedPrompt.version,\n versionId: updatedPrompt.versionId,\n materialized: filePath,\n };\n }\n }\n\n // Determine the action text based on sync result and conflict resolution\n let actionText: string;\n if (syncResult.action === \"conflict\") {\n if (conflictResolution === \"remote\") {\n actionText = \"Pulled\"; // User chose to use remote version\n result.fetched.push({\n name: promptName,\n version: syncResult.conflictInfo?.remoteVersion ?? 0,\n versionSpec: \"latest\", // Default for conflict resolution\n });\n } else {\n actionText = \"Pushed\"; // User chose to use local version (or forced push)\n result.pushed.push({\n name: promptName,\n version: (syncResult.conflictInfo?.remoteVersion ?? 0) + 1, // New version after push\n });\n }\n } else if (syncResult.action === \"up_to_date\") {\n // For up-to-date prompts, add to unchanged instead of pushed\n actionText = \"Up-to-date\";\n result.unchanged.push(promptName);\n } else {\n const actionMap: Record<SyncAction, string> = {\n created: \"Created\",\n updated: \"Updated\",\n conflict: \"Conflict resolved\",\n up_to_date: \"Up to date\",\n };\n actionText = actionMap[syncResult.action as SyncAction] || \"Pushed\";\n result.pushed.push({\n name: promptName,\n version: syncResult.prompt?.version ?? 0,\n });\n }\n\n pushSpinner.text = `${actionText} ${chalk.cyan(\n promptName\n )} ${chalk.gray(\n `(version ${\n syncResult.prompt?.version ??\n syncResult.conflictInfo?.remoteVersion ??\n \"unknown\"\n })`\n )} ${conflictResolution === \"remote\" ? \"to\" : \"from\"} ${chalk.gray(\n relativePath\n )}`;\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name: promptName, error: errorMessage });\n }\n }\n\n // Save lock file with all updates\n FileManager.savePromptsLock(lock);\n\n pushSpinner.stop();\n }\n\n // Check for orphan local prompt files and show helpful warnings\n const discoveredLocalFiles = FileManager.getLocalPromptFiles();\n const orphanFiles = discoveredLocalFiles.filter((filePath) => {\n const promptName = FileManager.promptNameFromPath(filePath);\n return !config.prompts[promptName]; // Not declared in prompts.json\n });\n\n if (orphanFiles.length > 0) {\n console.log(\n chalk.yellow(\n `\\n⚠ Found ${orphanFiles.length} orphan prompt file${\n orphanFiles.length > 1 ? \"s\" : \"\"\n }:`\n )\n );\n\n for (const filePath of orphanFiles) {\n const promptName = FileManager.promptNameFromPath(filePath);\n const relativePath = path.relative(process.cwd(), filePath);\n\n console.log(chalk.yellow(` ${relativePath}`));\n console.log(\n chalk.gray(\n ` Add to prompts.json: \"${promptName}\": \"file:${relativePath}\"`\n )\n );\n }\n\n console.log(\n chalk.gray(\n `\\nTip: Add these to prompts.json to include them in sync operations.`\n )\n );\n }\n\n // Cleanup orphaned materialized files\n const currentDependencies = new Set(\n Object.keys(config.prompts).filter((name) => {\n const dependency = config.prompts[name];\n // Only include remote dependencies (not local file: dependencies)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n })\n );\n\n const cleanedFiles =\n FileManager.cleanupOrphanedMaterializedFiles(currentDependencies);\n if (cleanedFiles.length > 0) {\n result.cleaned = cleanedFiles;\n FileManager.removeFromLock(lock, cleanedFiles);\n }\n\n // Save the updated lock file\n FileManager.savePromptsLock(lock);\n\n // Print individual results if there were actions\n if (result.fetched.length > 0) {\n for (const { name, version, versionSpec } of result.fetched) {\n // Get the actual saved path from lock file for display consistency\n const lockEntry = lock.prompts[name];\n const displayPath = lockEntry?.materialized\n ? `./${lockEntry.materialized}`\n : `./prompts/.materialized/${name}.prompt.yaml`;\n\n console.log(\n chalk.green(\n `✓ Pulled ${chalk.cyan(`${name}@${versionSpec}`)} ${chalk.gray(\n `(version ${version})`\n )} → ${chalk.gray(displayPath)}`\n )\n );\n }\n }\n\n if (result.pushed.length > 0) {\n for (const { name, version } of result.pushed) {\n const localPath = `./prompts/${name}.prompt.yaml`;\n console.log(\n chalk.green(\n `✓ Pushed ${chalk.cyan(name)} ${chalk.gray(\n `(version ${version})`\n )} from ${chalk.gray(localPath)}`\n )\n );\n }\n }\n\n // Print cleaned up files\n if (result.cleaned.length > 0) {\n for (const name of result.cleaned) {\n console.log(\n chalk.yellow(\n `✓ Cleaned ${chalk.cyan(name)} (no longer in dependencies)`\n )\n );\n }\n }\n\n // Print errors\n if (result.errors.length > 0) {\n for (const { name, error } of result.errors) {\n console.log(chalk.red(`✗ Failed ${chalk.cyan(name)}: ${error}`));\n }\n }\n\n // Print summary\n const duration = ((Date.now() - startTime) / 1000).toFixed(1);\n const totalActions =\n result.fetched.length + result.pushed.length + result.cleaned.length;\n\n if (totalActions === 0 && result.errors.length === 0) {\n console.log(chalk.gray(`Synced in ${duration}s, no changes`));\n } else {\n const summary = [];\n if (result.fetched.length > 0)\n summary.push(`${result.fetched.length} fetched`);\n if (result.pushed.length > 0)\n summary.push(`${result.pushed.length} pushed`);\n if (result.cleaned.length > 0)\n summary.push(`${result.cleaned.length} cleaned`);\n if (result.errors.length > 0)\n summary.push(`${result.errors.length} errors`);\n\n console.log(chalk.gray(`Synced ${summary.join(\", \")} in ${duration}s`));\n }\n\n if (result.errors.length > 0) {\n process.exit(1);\n }\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Unexpected error: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`\n )\n );\n }\n process.exit(1);\n }\n};\n"]}
@@ -852,6 +852,40 @@ interface paths {
852
852
  patch?: never;
853
853
  trace?: never;
854
854
  };
855
+ "/api/evaluations/v3/{slug}/run": {
856
+ parameters: {
857
+ query?: never;
858
+ header?: never;
859
+ path?: never;
860
+ cookie?: never;
861
+ };
862
+ get?: never;
863
+ put?: never;
864
+ /** @description Start execution of a saved Evaluations V3 experiment by slug. Returns immediately with a runId for polling, or streams SSE events if Accept: text/event-stream header is provided. */
865
+ post: operations["postEvaluationsV3Run"];
866
+ delete?: never;
867
+ options?: never;
868
+ head?: never;
869
+ patch?: never;
870
+ trace?: never;
871
+ };
872
+ "/api/evaluations/v3/runs/{runId}": {
873
+ parameters: {
874
+ query?: never;
875
+ header?: never;
876
+ path?: never;
877
+ cookie?: never;
878
+ };
879
+ /** @description Get the current status of an evaluation run for polling. Returns progress while running, and summary when completed. */
880
+ get: operations["getEvaluationsV3RunStatus"];
881
+ put?: never;
882
+ post?: never;
883
+ delete?: never;
884
+ options?: never;
885
+ head?: never;
886
+ patch?: never;
887
+ trace?: never;
888
+ };
855
889
  }
856
890
  interface components {
857
891
  schemas: {
@@ -2817,6 +2851,134 @@ interface operations {
2817
2851
  };
2818
2852
  };
2819
2853
  };
2854
+ postEvaluationsV3Run: {
2855
+ parameters: {
2856
+ query?: never;
2857
+ header?: never;
2858
+ path: {
2859
+ /** @description The slug of the evaluation to run */
2860
+ slug: string;
2861
+ };
2862
+ cookie?: never;
2863
+ };
2864
+ requestBody?: never;
2865
+ responses: {
2866
+ /** @description Run started successfully */
2867
+ 200: {
2868
+ headers: {
2869
+ [name: string]: unknown;
2870
+ };
2871
+ content: {
2872
+ "application/json": {
2873
+ /** @description Unique identifier for this run */
2874
+ runId: string;
2875
+ /**
2876
+ * @description Initial status of the run
2877
+ * @enum {string}
2878
+ */
2879
+ status: "running";
2880
+ /** @description Total number of cells to execute */
2881
+ total: number;
2882
+ /** @description URL to view the run in LangWatch */
2883
+ runUrl?: string;
2884
+ };
2885
+ "text/event-stream": string;
2886
+ };
2887
+ };
2888
+ /** @description Unauthorized - Missing or invalid API key */
2889
+ 401: {
2890
+ headers: {
2891
+ [name: string]: unknown;
2892
+ };
2893
+ content: {
2894
+ "application/json": {
2895
+ error: string;
2896
+ };
2897
+ };
2898
+ };
2899
+ /** @description Evaluation not found */
2900
+ 404: {
2901
+ headers: {
2902
+ [name: string]: unknown;
2903
+ };
2904
+ content: {
2905
+ "application/json": {
2906
+ error: string;
2907
+ };
2908
+ };
2909
+ };
2910
+ };
2911
+ };
2912
+ getEvaluationsV3RunStatus: {
2913
+ parameters: {
2914
+ query?: never;
2915
+ header?: never;
2916
+ path: {
2917
+ /** @description The run ID returned from POST /api/evaluations/v3/{slug}/run */
2918
+ runId: string;
2919
+ };
2920
+ cookie?: never;
2921
+ };
2922
+ requestBody?: never;
2923
+ responses: {
2924
+ /** @description Run status */
2925
+ 200: {
2926
+ headers: {
2927
+ [name: string]: unknown;
2928
+ };
2929
+ content: {
2930
+ "application/json": {
2931
+ runId: string;
2932
+ /** @enum {string} */
2933
+ status: "pending" | "running" | "completed" | "failed" | "stopped";
2934
+ /** @description Number of cells completed */
2935
+ progress: number;
2936
+ /** @description Total number of cells */
2937
+ total: number;
2938
+ /** @description Unix timestamp when run started */
2939
+ startedAt?: number;
2940
+ /** @description Unix timestamp when run finished (only present when completed/failed/stopped) */
2941
+ finishedAt?: number;
2942
+ /** @description Execution summary (only present when completed) */
2943
+ summary?: {
2944
+ runId?: string;
2945
+ totalCells?: number;
2946
+ completedCells?: number;
2947
+ failedCells?: number;
2948
+ /** @description Total execution time in milliseconds */
2949
+ duration?: number;
2950
+ /** @description URL to view the run in LangWatch */
2951
+ runUrl?: string;
2952
+ };
2953
+ /** @description Error message (only present when failed) */
2954
+ error?: string;
2955
+ };
2956
+ };
2957
+ };
2958
+ /** @description Unauthorized - Missing or invalid API key */
2959
+ 401: {
2960
+ headers: {
2961
+ [name: string]: unknown;
2962
+ };
2963
+ content: {
2964
+ "application/json": {
2965
+ error: string;
2966
+ };
2967
+ };
2968
+ };
2969
+ /** @description Run not found */
2970
+ 404: {
2971
+ headers: {
2972
+ [name: string]: unknown;
2973
+ };
2974
+ content: {
2975
+ "application/json": {
2976
+ error: string;
2977
+ };
2978
+ };
2979
+ };
2980
+ };
2981
+ };
2820
2982
  }
2821
2983
 
2822
2984
  /**