langwatch 1.14.0 → 1.16.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 (34) hide show
  1. package/dist/agent/index.js +1 -1
  2. package/dist/agent/index.js.map +1 -1
  3. package/dist/agent/index.mjs +1 -1
  4. package/dist/agent/index.mjs.map +1 -1
  5. package/dist/{chunk-MGASIVXD.js → chunk-6SSJPQAW.js} +2 -2
  6. package/dist/chunk-6SSJPQAW.js.map +1 -0
  7. package/dist/{chunk-7FIG44IG.js → chunk-FUDF46YW.js} +12 -12
  8. package/dist/{chunk-7FIG44IG.js.map → chunk-FUDF46YW.js.map} +1 -1
  9. package/dist/{chunk-QKIDVFHZ.mjs → chunk-NZP72HTX.mjs} +2 -2
  10. package/dist/chunk-NZP72HTX.mjs.map +1 -0
  11. package/dist/{chunk-MCM4C66E.mjs → chunk-XC6AXWVR.mjs} +2 -2
  12. package/dist/cli/bundle.js +328 -294
  13. package/dist/{implementation-BXX0qdV7.d.mts → implementation-BvHTdJLg.d.mts} +1 -1
  14. package/dist/{implementation-Cv7sBdwj.d.ts → implementation-Dlxw5hlM.d.ts} +1 -1
  15. package/dist/index.d.mts +141 -28
  16. package/dist/index.d.ts +141 -28
  17. package/dist/index.js +229 -43
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +198 -12
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/observability-sdk/index.d.mts +3 -3
  22. package/dist/observability-sdk/index.d.ts +3 -3
  23. package/dist/observability-sdk/index.js +2 -2
  24. package/dist/observability-sdk/index.mjs +1 -1
  25. package/dist/observability-sdk/instrumentation/langchain/index.d.mts +1 -1
  26. package/dist/observability-sdk/instrumentation/langchain/index.d.ts +1 -1
  27. package/dist/observability-sdk/setup/node/index.js +3 -3
  28. package/dist/observability-sdk/setup/node/index.mjs +2 -2
  29. package/dist/{types-BejNp4Dw.d.ts → types-CzElA_6o.d.ts} +1439 -247
  30. package/dist/{types-DXNIJdZx.d.mts → types-Dd2d9hCy.d.mts} +1439 -247
  31. package/package.json +1 -3
  32. package/dist/chunk-MGASIVXD.js.map +0 -1
  33. package/dist/chunk-QKIDVFHZ.mjs.map +0 -1
  34. /package/dist/{chunk-MCM4C66E.mjs.map → chunk-XC6AXWVR.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  ensureSetup,
11
11
  resolveEndpoint
12
- } from "./chunk-MCM4C66E.mjs";
12
+ } from "./chunk-XC6AXWVR.mjs";
13
13
  import {
14
14
  LANGWATCH_SDK_LANGUAGE,
15
15
  LANGWATCH_SDK_NAME_CLIENT,
@@ -20,7 +20,7 @@ import {
20
20
  buildAuthHeaders,
21
21
  getLangWatchLogger,
22
22
  version
23
- } from "./chunk-QKIDVFHZ.mjs";
23
+ } from "./chunk-NZP72HTX.mjs";
24
24
  import {
25
25
  ConsoleLogger,
26
26
  NoOpLogger,
@@ -5496,6 +5496,149 @@ function withTrimmedNote(body) {
5496
5496
  return rest;
5497
5497
  }
5498
5498
 
5499
+ // src/client-sdk/services/instant-evals/instant-evals-api.service.ts
5500
+ var InstantEvalsApiError = class extends Error {
5501
+ constructor(message, operation, originalError, status) {
5502
+ super(message);
5503
+ this.operation = operation;
5504
+ this.originalError = originalError;
5505
+ this.status = status;
5506
+ this.name = "InstantEvalsApiError";
5507
+ }
5508
+ };
5509
+ var InstantEvalsApiService = class {
5510
+ constructor(config) {
5511
+ var _a;
5512
+ this.apiClient = (_a = config == null ? void 0 : config.langwatchApiClient) != null ? _a : createLangWatchApiClient();
5513
+ }
5514
+ handleApiError(operation, error, response) {
5515
+ var _a;
5516
+ const status = (_a = response == null ? void 0 : response.status) != null ? _a : extractStatusFromResponse(error);
5517
+ const message = formatApiErrorForOperation({
5518
+ operation,
5519
+ error,
5520
+ options: { status }
5521
+ });
5522
+ throwIfHandledError({ operation, error, response, message });
5523
+ throw new InstantEvalsApiError(message, operation, error, status);
5524
+ }
5525
+ /**
5526
+ * The body of a successful answer. A failed response can arrive with no body
5527
+ * at all (a proxy answering 502 while the platform restarts), which leaves
5528
+ * `error` empty, so the response status decides and not the error alone.
5529
+ */
5530
+ unwrap({
5531
+ operation,
5532
+ data,
5533
+ error,
5534
+ response
5535
+ }) {
5536
+ const failed = response !== void 0 && !response.ok;
5537
+ if (error || failed || data === void 0) {
5538
+ this.handleApiError(operation, error != null ? error : void 0, response);
5539
+ }
5540
+ return data;
5541
+ }
5542
+ /** Starts a run. The judging happens on the queue. */
5543
+ async create(body) {
5544
+ const { data, error, response } = await this.apiClient.POST(
5545
+ "/api/v1/instant-evals",
5546
+ { body }
5547
+ );
5548
+ return this.unwrap({
5549
+ operation: "start an instant eval run",
5550
+ data,
5551
+ error,
5552
+ response
5553
+ });
5554
+ }
5555
+ /** Prices a run without starting it. Nothing is judged and nothing is charged. */
5556
+ async estimate(body) {
5557
+ const { data, error, response } = await this.apiClient.POST(
5558
+ "/api/v1/instant-evals/estimate",
5559
+ { body }
5560
+ );
5561
+ return this.unwrap({
5562
+ operation: "estimate an instant eval run",
5563
+ data,
5564
+ error,
5565
+ response
5566
+ });
5567
+ }
5568
+ /** The project's runs, newest first. */
5569
+ async list(options) {
5570
+ const query = __spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.limit) === void 0 ? {} : { limit: options.limit }), (options == null ? void 0 : options.before) === void 0 ? {} : { before: options.before }), (options == null ? void 0 : options.beforeId) === void 0 ? {} : { beforeId: options.beforeId });
5571
+ const { data, error, response } = await this.apiClient.GET(
5572
+ "/api/v1/instant-evals",
5573
+ { params: { query } }
5574
+ );
5575
+ return this.unwrap({
5576
+ operation: "list instant eval runs",
5577
+ data,
5578
+ error,
5579
+ response
5580
+ }).runs;
5581
+ }
5582
+ async get(id) {
5583
+ const { data, error, response } = await this.apiClient.GET(
5584
+ "/api/v1/instant-evals/{id}",
5585
+ { params: { path: { id } } }
5586
+ );
5587
+ return this.unwrap({
5588
+ operation: `get instant eval run "${id}"`,
5589
+ data,
5590
+ error,
5591
+ response
5592
+ });
5593
+ }
5594
+ /** Asks a run to stop. It stops before its next page. */
5595
+ async cancel(id) {
5596
+ const { data, error, response } = await this.apiClient.POST(
5597
+ "/api/v1/instant-evals/{id}/cancel",
5598
+ { params: { path: { id } } }
5599
+ );
5600
+ return this.unwrap({
5601
+ operation: `cancel instant eval run "${id}"`,
5602
+ data,
5603
+ error,
5604
+ response
5605
+ });
5606
+ }
5607
+ /**
5608
+ * One page of a run's judgements.
5609
+ *
5610
+ * Pass the `nextCursor` a page answers with to read the page after it. The
5611
+ * last page carries none.
5612
+ */
5613
+ async results(id, options) {
5614
+ const query = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.questionId) === void 0 ? {} : { questionId: options.questionId }), (options == null ? void 0 : options.isMatched) === void 0 ? {} : { matched: options.isMatched ? "true" : "false" }), (options == null ? void 0 : options.status) === void 0 ? {} : { status: options.status }), (options == null ? void 0 : options.limit) === void 0 ? {} : { limit: options.limit }), (options == null ? void 0 : options.cursor) === void 0 ? {} : { cursor: options.cursor });
5615
+ const { data, error, response } = await this.apiClient.GET(
5616
+ "/api/v1/instant-evals/{id}/results",
5617
+ { params: { path: { id }, query } }
5618
+ );
5619
+ return this.unwrap({
5620
+ operation: `read instant eval run "${id}" results`,
5621
+ data,
5622
+ error,
5623
+ response
5624
+ });
5625
+ }
5626
+ /** A few of the run's rows, with the judged text beside the verdict. */
5627
+ async sample(id, options) {
5628
+ const query = (options == null ? void 0 : options.n) === void 0 ? {} : { n: options.n };
5629
+ const { data, error, response } = await this.apiClient.GET(
5630
+ "/api/v1/instant-evals/{id}/sample",
5631
+ { params: { path: { id }, query } }
5632
+ );
5633
+ return this.unwrap({
5634
+ operation: `sample instant eval run "${id}"`,
5635
+ data,
5636
+ error,
5637
+ response
5638
+ });
5639
+ }
5640
+ };
5641
+
5499
5642
  // src/client-sdk/services/test-suites/test-suites-api.service.ts
5500
5643
  var TestSuitesApiError = class extends Error {
5501
5644
  constructor(message, operation, originalError, status) {
@@ -6027,7 +6170,7 @@ var QueryApiService = class {
6027
6170
  throw new QueryApiError(message, operation, error, status);
6028
6171
  }
6029
6172
  /**
6030
- * Runs one read-only LangWatchQL `SELECT` over the analytics datasets and
6173
+ * Runs one read-only LangWatchQL `SELECT` over the analytics views and
6031
6174
  * returns typed columns, rows, execution statistics, truncation state and
6032
6175
  * diagnostics, scoped to the caller's project.
6033
6176
  */
@@ -6040,7 +6183,7 @@ var QueryApiService = class {
6040
6183
  return data;
6041
6184
  }
6042
6185
  /**
6043
- * Lists the LangWatchQL analytics datasets this key may query, with each
6186
+ * Lists the LangWatchQL analytics views this key may query, with each
6044
6187
  * column's type, description, the permissions that unlock it, and whether
6045
6188
  * this caller holds them — plus each dataset's grain, join keys,
6046
6189
  * partition-pruning time column, freshness and a runnable example query.
@@ -6053,6 +6196,20 @@ var QueryApiService = class {
6053
6196
  if (error) this.handleApiError("discover query schema", error, response);
6054
6197
  return data;
6055
6198
  }
6199
+ /**
6200
+ * Describes both query languages in one payload: the LangWatchQL schema,
6201
+ * limits and endpoints, the trace filter's syntax and fields, worked examples
6202
+ * validated in both, and which language answers which kind of
6203
+ * question.
6204
+ */
6205
+ async reference() {
6206
+ const { data, error, response } = await this.apiClient.GET(
6207
+ "/api/v1/query/reference",
6208
+ {}
6209
+ );
6210
+ if (error) this.handleApiError("read query reference", error, response);
6211
+ return data;
6212
+ }
6056
6213
  };
6057
6214
 
6058
6215
  // src/client-sdk/services/triggers/triggers-api.service.ts
@@ -6581,11 +6738,6 @@ var VirtualKeysApiService = class {
6581
6738
  );
6582
6739
  return virtual_key;
6583
6740
  }
6584
- /**
6585
- * Mint a key. The response carries the secret ONCE; nothing ever serves it
6586
- * again, so a create that times out is recovered with `idempotencyKey`
6587
- * rather than by listing.
6588
- */
6589
6741
  async create(input, options) {
6590
6742
  return this.request(
6591
6743
  "create virtual key",
@@ -6881,6 +7033,15 @@ var GatewayBudgetsApiService = class {
6881
7033
  };
6882
7034
 
6883
7035
  // src/client-sdk/services/spend-events/spend-events-api.service.ts
7036
+ function spendUsageFromWire(usage) {
7037
+ var _a, _b, _c;
7038
+ const wire = usage;
7039
+ return __spreadProps(__spreadValues({}, usage), {
7040
+ input_image_tokens: (_a = wire.input_image_tokens) != null ? _a : 0,
7041
+ output_image_tokens: (_b = wire.output_image_tokens) != null ? _b : 0,
7042
+ image_count: (_c = wire.image_count) != null ? _c : 0
7043
+ });
7044
+ }
6884
7045
  var FILTER_PARAMS = [
6885
7046
  ["projectId", "project_id"],
6886
7047
  ["teamId", "team_id"],
@@ -6981,10 +7142,17 @@ var SpendEventsApiService = class {
6981
7142
  if (options.limit !== void 0) params.set("limit", String(options.limit));
6982
7143
  appendSpendFilters({ params, filters: options });
6983
7144
  const qs = params.toString() !== "" ? `?${params.toString()}` : "";
6984
- return await this.request(
7145
+ const page = await this.request(
6985
7146
  "list spend events",
6986
7147
  `/api/gateway/v1/spend-events${qs}`
6987
7148
  );
7149
+ return __spreadProps(__spreadValues({}, page), {
7150
+ data: page.data.map((event) => __spreadProps(__spreadValues({}, event), {
7151
+ data: __spreadProps(__spreadValues({}, event.data), {
7152
+ usage: event.data.usage === null ? null : spendUsageFromWire(event.data.usage)
7153
+ })
7154
+ }))
7155
+ });
6988
7156
  }
6989
7157
  /**
6990
7158
  * Every spend event in the window, one row at a time, fetching each page
@@ -7050,10 +7218,15 @@ var SpendEventsApiService = class {
7050
7218
  appendSpendFilters({ params, filters: options });
7051
7219
  if (options.cursor) params.set("cursor", options.cursor);
7052
7220
  if (options.limit !== void 0) params.set("limit", String(options.limit));
7053
- return await this.request(
7221
+ const page = await this.request(
7054
7222
  "read spend summaries",
7055
7223
  `/api/gateway/v1/spend-summaries?${params.toString()}`
7056
7224
  );
7225
+ return __spreadProps(__spreadValues({}, page), {
7226
+ data: page.data.map((row) => __spreadProps(__spreadValues({}, row), {
7227
+ usage: spendUsageFromWire(row.usage)
7228
+ }))
7229
+ });
7057
7230
  }
7058
7231
  /**
7059
7232
  * Every rollup row for the window, one at a time, fetching each page only
@@ -7130,7 +7303,7 @@ var SpendEventsApiService = class {
7130
7303
  "read end-user spend",
7131
7304
  `/api/gateway/v1/end-users/${encodeURIComponent(endUserId)}/spend${qs}`
7132
7305
  );
7133
- return res.data;
7306
+ return __spreadProps(__spreadValues({}, res.data), { usage: spendUsageFromWire(res.data.usage) });
7134
7307
  }
7135
7308
  };
7136
7309
 
@@ -7634,6 +7807,18 @@ var ProjectsApiService = class {
7634
7807
  `/api/projects/${encodeURIComponent(id)}`
7635
7808
  );
7636
7809
  }
7810
+ /**
7811
+ * The project's ingest key. The platform hands it out only to a credential
7812
+ * with `project:update` on the project, so a 403 here is the answer "this
7813
+ * login may not", not a transport failure.
7814
+ */
7815
+ async getApiKey(id) {
7816
+ const answer = await this.request(
7817
+ `get api key of project "${id}"`,
7818
+ `/api/projects/${encodeURIComponent(id)}/api-key`
7819
+ );
7820
+ return answer.apiKey;
7821
+ }
7637
7822
  async create(input) {
7638
7823
  return this.request(
7639
7824
  "create project",
@@ -7772,6 +7957,7 @@ var LangWatch = class {
7772
7957
  this.scenarios = new ScenariosApiService(this.config);
7773
7958
  this.suites = new SuitesApiService(this.config);
7774
7959
  this.runPlans = new RunPlansApiService(this.config);
7960
+ this.instantEvals = new InstantEvalsApiService(this.config);
7775
7961
  this.testSuites = new TestSuitesApiService(this.config);
7776
7962
  this.workflows = new WorkflowsApiService(this.config);
7777
7963
  this.agents = new AgentsApiService(this.config);