langwatch 1.8.0 → 1.9.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.
- package/dist/{chunk-W6NUS5XK.mjs → chunk-4XQHESU7.mjs} +2 -2
- package/dist/{chunk-W6NUS5XK.mjs.map → chunk-4XQHESU7.mjs.map} +1 -1
- package/dist/{chunk-YEKLDVGO.mjs → chunk-A52LX4C4.mjs} +2 -2
- package/dist/{chunk-KS7O6FTO.js → chunk-HUMHSRVP.js} +12 -12
- package/dist/{chunk-KS7O6FTO.js.map → chunk-HUMHSRVP.js.map} +1 -1
- package/dist/{chunk-FJ6JSLLE.js → chunk-NFFB3DWW.js} +2 -2
- package/dist/{chunk-FJ6JSLLE.js.map → chunk-NFFB3DWW.js.map} +1 -1
- package/dist/cli/bundle.js +346 -240
- package/dist/{implementation-Di0CB66C.d.ts → implementation-BvwOB77X.d.ts} +1 -1
- package/dist/{implementation-CMvLlYDH.d.mts → implementation-C1F0eCHp.d.mts} +1 -1
- package/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +171 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +140 -9
- package/dist/index.mjs.map +1 -1
- package/dist/observability-sdk/index.d.mts +3 -3
- package/dist/observability-sdk/index.d.ts +3 -3
- package/dist/observability-sdk/index.js +2 -2
- package/dist/observability-sdk/index.mjs +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +1 -1
- package/dist/observability-sdk/setup/node/index.js +3 -3
- package/dist/observability-sdk/setup/node/index.mjs +2 -2
- package/dist/{types-DQqmFCDl.d.mts → types-C3NpCWi_.d.mts} +1333 -425
- package/dist/{types-Cg_frfBV.d.ts → types-jx13nj4M.d.ts} +1333 -425
- package/package.json +1 -1
- /package/dist/{chunk-YEKLDVGO.mjs.map → chunk-A52LX4C4.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-
|
|
12
|
+
} from "./chunk-A52LX4C4.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-
|
|
23
|
+
} from "./chunk-4XQHESU7.mjs";
|
|
24
24
|
import {
|
|
25
25
|
ConsoleLogger,
|
|
26
26
|
NoOpLogger,
|
|
@@ -51,6 +51,9 @@ function currentHolder() {
|
|
|
51
51
|
function scopedApiKey() {
|
|
52
52
|
return currentHolder().apiKey;
|
|
53
53
|
}
|
|
54
|
+
function scopedProjectId() {
|
|
55
|
+
return currentHolder().projectId;
|
|
56
|
+
}
|
|
54
57
|
|
|
55
58
|
// src/cli/utils/responseFormat.ts
|
|
56
59
|
var DEFAULT_TEXT_OUTPUT = {
|
|
@@ -424,7 +427,7 @@ var asSuggestions = (value) => {
|
|
|
424
427
|
return suggestions.length > 0 ? suggestions : void 0;
|
|
425
428
|
};
|
|
426
429
|
var asErrorBody = (value) => {
|
|
427
|
-
var _a, _b,
|
|
430
|
+
var _a, _b, _c, _e, _g;
|
|
428
431
|
const record = asRecord(value);
|
|
429
432
|
if (!record) return null;
|
|
430
433
|
if (isSystemError(record)) return null;
|
|
@@ -443,9 +446,23 @@ var asErrorBody = (value) => {
|
|
|
443
446
|
docUrl: typeof serialized.docsUrl === "string" ? serialized.docsUrl : typeof serialized.docUrl === "string" ? serialized.docUrl : void 0
|
|
444
447
|
};
|
|
445
448
|
}
|
|
449
|
+
const canonical = asRecord(record.error);
|
|
450
|
+
if (canonical && !isSystemError(canonical) && (typeof canonical.code === "string" || typeof canonical.type === "string")) {
|
|
451
|
+
const code2 = typeof canonical.code === "string" ? canonical.code : canonical.type;
|
|
452
|
+
const _d = (_c = asRecord(canonical.meta)) != null ? _c : {}, { reasons: metaReasons } = _d, meta = __objRest(_d, ["reasons"]);
|
|
453
|
+
return {
|
|
454
|
+
code: code2,
|
|
455
|
+
message: typeof canonical.message === "string" && canonical.message !== code2 ? canonical.message : void 0,
|
|
456
|
+
meta,
|
|
457
|
+
traceId: typeof canonical.trace_id === "string" ? canonical.trace_id : void 0,
|
|
458
|
+
reasons: asReasons(metaReasons),
|
|
459
|
+
suggestions: (_e = asSuggestions(canonical.tips)) != null ? _e : asSuggestions(canonical.suggestions),
|
|
460
|
+
docUrl: typeof canonical.docs_url === "string" ? canonical.docs_url : void 0
|
|
461
|
+
};
|
|
462
|
+
}
|
|
446
463
|
const named = typeof record.kind === "string" ? typeof record.code === "string" ? record.code : typeof record.type === "string" ? record.type : record.kind : typeof record.error === "string" ? record.error : looksLikeErrorEnvelope(record) ? typeof record.code === "string" ? record.code : typeof record.type === "string" ? record.type : null : null;
|
|
447
464
|
if (named === null) return null;
|
|
448
|
-
const
|
|
465
|
+
const _f = record, {
|
|
449
466
|
error,
|
|
450
467
|
message,
|
|
451
468
|
kind,
|
|
@@ -464,7 +481,7 @@ var asErrorBody = (value) => {
|
|
|
464
481
|
tips: tips,
|
|
465
482
|
docsUrl,
|
|
466
483
|
fault: fault
|
|
467
|
-
} =
|
|
484
|
+
} = _f, rest = __objRest(_f, [
|
|
468
485
|
"error",
|
|
469
486
|
"message",
|
|
470
487
|
"kind",
|
|
@@ -503,7 +520,7 @@ var asErrorBody = (value) => {
|
|
|
503
520
|
traceUrl: typeof traceUrl === "string" ? traceUrl : typeof (traceRecord == null ? void 0 : traceRecord.traceUrl) === "string" ? traceRecord.traceUrl : void 0,
|
|
504
521
|
logsUrl: typeof logsUrl === "string" ? logsUrl : typeof (traceRecord == null ? void 0 : traceRecord.logsUrl) === "string" ? traceRecord.logsUrl : void 0,
|
|
505
522
|
reasons: asReasons(reasons),
|
|
506
|
-
suggestions: (
|
|
523
|
+
suggestions: (_g = asSuggestions(tips)) != null ? _g : asSuggestions(suggestions),
|
|
507
524
|
docUrl: typeof docsUrl === "string" ? docsUrl : typeof docUrl === "string" ? docUrl : void 0
|
|
508
525
|
};
|
|
509
526
|
};
|
|
@@ -657,7 +674,7 @@ var handledErrorMiddleware = {
|
|
|
657
674
|
if (handledError) throw handledError;
|
|
658
675
|
}
|
|
659
676
|
};
|
|
660
|
-
var createLangWatchApiClient = (apiKey = ((_b) => (_b = ((_a) => (_a = scopedApiKey()) != null ? _a : process.env.LANGWATCH_API_KEY)()) != null ? _b : "")(), endpoint, projectId = process.env.LANGWATCH_PROJECT_ID) => {
|
|
677
|
+
var createLangWatchApiClient = (apiKey = ((_b) => (_b = ((_a) => (_a = scopedApiKey()) != null ? _a : process.env.LANGWATCH_API_KEY)()) != null ? _b : "")(), endpoint, projectId = ((_c) => (_c = scopedProjectId()) != null ? _c : process.env.LANGWATCH_PROJECT_ID)()) => {
|
|
661
678
|
const client = openApiCreateClient({
|
|
662
679
|
baseUrl: resolveEndpoint(endpoint),
|
|
663
680
|
headers: __spreadProps(__spreadValues({}, buildAuthHeaders({ apiKey, projectId })), {
|
|
@@ -3993,6 +4010,107 @@ var ExperimentsApiService = class {
|
|
|
3993
4010
|
if (error) this.handleApiError(`start experiment run for "${slug}"`, error);
|
|
3994
4011
|
return data;
|
|
3995
4012
|
}
|
|
4013
|
+
/**
|
|
4014
|
+
* Create an experiment.
|
|
4015
|
+
*
|
|
4016
|
+
* Sending no state creates a blank workbench with one inline dataset, so a
|
|
4017
|
+
* caller that only wants somewhere to put its setup does not have to build
|
|
4018
|
+
* one first.
|
|
4019
|
+
*/
|
|
4020
|
+
async create({
|
|
4021
|
+
name,
|
|
4022
|
+
state
|
|
4023
|
+
} = {}) {
|
|
4024
|
+
const { data, error } = await this.apiClient.POST("/api/experiments", {
|
|
4025
|
+
body: __spreadValues(__spreadValues({}, name !== void 0 ? { name } : {}), state !== void 0 ? { state } : {})
|
|
4026
|
+
});
|
|
4027
|
+
if (error) this.handleApiError("create experiment", error);
|
|
4028
|
+
return data;
|
|
4029
|
+
}
|
|
4030
|
+
async getWorkbenchState({
|
|
4031
|
+
slug,
|
|
4032
|
+
fields
|
|
4033
|
+
}) {
|
|
4034
|
+
const { data, error } = await this.apiClient.GET(
|
|
4035
|
+
"/api/experiments/{slug}/workbench-state",
|
|
4036
|
+
{
|
|
4037
|
+
params: __spreadValues({
|
|
4038
|
+
path: { slug }
|
|
4039
|
+
}, fields !== void 0 ? { query: { fields } } : {})
|
|
4040
|
+
}
|
|
4041
|
+
);
|
|
4042
|
+
if (error) {
|
|
4043
|
+
this.handleApiError(`get workbench state for "${slug}"`, error);
|
|
4044
|
+
}
|
|
4045
|
+
return data;
|
|
4046
|
+
}
|
|
4047
|
+
/**
|
|
4048
|
+
* Save an experiment's setup.
|
|
4049
|
+
*
|
|
4050
|
+
* Send `expectedVersion` with the version you read and the platform refuses
|
|
4051
|
+
* the save with a 409 when someone else wrote first, instead of overwriting
|
|
4052
|
+
* their work.
|
|
4053
|
+
*/
|
|
4054
|
+
async setWorkbenchState({
|
|
4055
|
+
slug,
|
|
4056
|
+
state,
|
|
4057
|
+
expectedVersion,
|
|
4058
|
+
commitMessage
|
|
4059
|
+
}) {
|
|
4060
|
+
const { data, error } = await this.apiClient.PUT(
|
|
4061
|
+
"/api/experiments/{slug}/workbench-state",
|
|
4062
|
+
{
|
|
4063
|
+
params: { path: { slug } },
|
|
4064
|
+
body: __spreadValues(__spreadValues({
|
|
4065
|
+
state
|
|
4066
|
+
}, expectedVersion !== void 0 ? { expectedVersion } : {}), commitMessage !== void 0 ? { commitMessage } : {})
|
|
4067
|
+
}
|
|
4068
|
+
);
|
|
4069
|
+
if (error) {
|
|
4070
|
+
this.handleApiError(`save workbench state for "${slug}"`, error);
|
|
4071
|
+
}
|
|
4072
|
+
return data;
|
|
4073
|
+
}
|
|
4074
|
+
/** The experiment's saved versions, newest first. */
|
|
4075
|
+
async listVersions({
|
|
4076
|
+
slug,
|
|
4077
|
+
limit,
|
|
4078
|
+
cursor
|
|
4079
|
+
}) {
|
|
4080
|
+
const { data, error } = await this.apiClient.GET(
|
|
4081
|
+
"/api/experiments/{slug}/versions",
|
|
4082
|
+
{
|
|
4083
|
+
params: {
|
|
4084
|
+
path: { slug },
|
|
4085
|
+
query: __spreadValues(__spreadValues({}, limit !== void 0 ? { limit } : {}), cursor !== void 0 ? { cursor } : {})
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
);
|
|
4089
|
+
if (error) {
|
|
4090
|
+
this.handleApiError(`list versions for experiment "${slug}"`, error);
|
|
4091
|
+
}
|
|
4092
|
+
return data;
|
|
4093
|
+
}
|
|
4094
|
+
/**
|
|
4095
|
+
* Bring an old version back by writing it forward as a new save. History is
|
|
4096
|
+
* never rewritten: the version restored from stays in the list.
|
|
4097
|
+
*/
|
|
4098
|
+
async restoreVersion({
|
|
4099
|
+
slug,
|
|
4100
|
+
version: version2
|
|
4101
|
+
}) {
|
|
4102
|
+
const { data, error } = await this.apiClient.POST(
|
|
4103
|
+
"/api/experiments/{slug}/versions/{version}/restore",
|
|
4104
|
+
{ params: { path: { slug, version: version2 } } }
|
|
4105
|
+
);
|
|
4106
|
+
if (error) {
|
|
4107
|
+
this.handleApiError(
|
|
4108
|
+
`restore version ${version2} of experiment "${slug}"`,
|
|
4109
|
+
error
|
|
4110
|
+
);
|
|
4111
|
+
}
|
|
4112
|
+
return data;
|
|
4113
|
+
}
|
|
3996
4114
|
async getRunStatus(runId) {
|
|
3997
4115
|
const { data, error } = await this.apiClient.GET(
|
|
3998
4116
|
"/api/experiments/runs/{runId}",
|
|
@@ -6934,10 +7052,11 @@ _request = new WeakMap();
|
|
|
6934
7052
|
|
|
6935
7053
|
// src/client-sdk/services/projects/projects-api.service.ts
|
|
6936
7054
|
var ProjectsApiError = class extends Error {
|
|
6937
|
-
constructor(message, operation, originalError) {
|
|
7055
|
+
constructor(message, operation, originalError, status) {
|
|
6938
7056
|
super(message);
|
|
6939
7057
|
this.operation = operation;
|
|
6940
7058
|
this.originalError = originalError;
|
|
7059
|
+
this.status = status;
|
|
6941
7060
|
this.name = "ProjectsApiError";
|
|
6942
7061
|
}
|
|
6943
7062
|
};
|
|
@@ -6947,6 +7066,13 @@ var ProjectsApiService = class {
|
|
|
6947
7066
|
this.endpoint = resolveEndpoint(config == null ? void 0 : config.endpoint);
|
|
6948
7067
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
6949
7068
|
}
|
|
7069
|
+
/**
|
|
7070
|
+
* Bearer, never the project-pinned Basic shape the data routes use. The
|
|
7071
|
+
* listing is the question "which projects can this credential see?", so
|
|
7072
|
+
* naming one project in the header would scope the answer to that project
|
|
7073
|
+
* and defeat the call — including the `--project <slug>` lookup, which reads
|
|
7074
|
+
* the listing precisely because it does not know the id yet.
|
|
7075
|
+
*/
|
|
6950
7076
|
headers() {
|
|
6951
7077
|
return {
|
|
6952
7078
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -6976,7 +7102,12 @@ var ProjectsApiService = class {
|
|
|
6976
7102
|
status: response.status,
|
|
6977
7103
|
message
|
|
6978
7104
|
});
|
|
6979
|
-
throw new ProjectsApiError(
|
|
7105
|
+
throw new ProjectsApiError(
|
|
7106
|
+
message,
|
|
7107
|
+
operation,
|
|
7108
|
+
parsedBody,
|
|
7109
|
+
response.status
|
|
7110
|
+
);
|
|
6980
7111
|
}
|
|
6981
7112
|
return await response.json();
|
|
6982
7113
|
}
|