@lmnr-ai/lmnr 0.8.53 → 0.8.55
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/README.md +12 -0
- package/dist/cli.cjs +6 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +1 -3
- package/dist/cli.d.mts +1 -3
- package/dist/cli.mjs +6 -9
- package/dist/cli.mjs.map +1 -1
- package/dist/{consts-9rSS0oeR.cjs → consts-X-pnRGD0.cjs} +2 -3
- package/dist/{consts-9rSS0oeR.cjs.map → consts-X-pnRGD0.cjs.map} +1 -1
- package/dist/{consts-CTTu3jhI.mjs → consts-r67THnT9.mjs} +2 -3
- package/dist/{consts-CTTu3jhI.mjs.map → consts-r67THnT9.mjs.map} +1 -1
- package/dist/{evaluations-BwB2JsRa.d.mts → evaluations-Bz4AjiEN.d.mts} +302 -1264
- package/dist/{evaluations-BXDpgOzM.d.cts → evaluations-CAossFsy.d.cts} +302 -1264
- package/dist/{file-utils-CyBBBeeW.cjs → file-utils-DvRb07ah.cjs} +7 -15
- package/dist/{file-utils-CyBBBeeW.cjs.map → file-utils-DvRb07ah.cjs.map} +1 -1
- package/dist/{file-utils-CwqjWMsF.mjs → file-utils-qSiXXrPa.mjs} +6 -14
- package/dist/{file-utils-CwqjWMsF.mjs.map → file-utils-qSiXXrPa.mjs.map} +1 -1
- package/dist/index.cjs +3893 -2308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1664 -512
- package/dist/index.d.mts +1664 -512
- package/dist/index.mjs +3905 -2322
- package/dist/index.mjs.map +1 -1
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.cjs +117 -185
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.cjs.map +1 -1
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.d.cts +1 -453
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.d.mts +1 -453
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.mjs +117 -185
- package/dist/opentelemetry-lib/instrumentation/temporal/workflow-interceptors.mjs.map +1 -1
- package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-C-fzZZTt.cjs} +2 -3
- package/dist/{rolldown-runtime-B4iAMlE-.mjs → rolldown-runtime-DYf_mQCB.mjs} +2 -3
- package/dist/{utils-DavLzQA8.mjs → utils-B7IKRw5F.mjs} +190 -55
- package/dist/utils-B7IKRw5F.mjs.map +1 -0
- package/dist/{utils-DcdjJ-4n.cjs → utils-C3QuhVGE.cjs} +245 -68
- package/dist/utils-C3QuhVGE.cjs.map +1 -0
- package/package.json +9 -8
- package/dist/utils-DavLzQA8.mjs.map +0 -1
- package/dist/utils-DcdjJ-4n.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C-fzZZTt.cjs");
|
|
2
2
|
let dotenv = require("dotenv");
|
|
3
3
|
let path = require("path");
|
|
4
4
|
let path$1 = require_rolldown_runtime.__toESM(path, 1);
|
|
@@ -10,7 +10,7 @@ let pino_pretty = require("pino-pretty");
|
|
|
10
10
|
let uuid = require("uuid");
|
|
11
11
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
12
12
|
let url = require("url");
|
|
13
|
-
|
|
13
|
+
// ../types/dist/index.mjs
|
|
14
14
|
/** Directory the debug-session file lives in, relative to the working dir. */
|
|
15
15
|
const DEBUG_SESSION_DIR = ".lmnr";
|
|
16
16
|
/** Filename of the debug-session file inside {@link DEBUG_SESSION_DIR}. */
|
|
@@ -29,9 +29,11 @@ let TracingLevel = /* @__PURE__ */ function(TracingLevel) {
|
|
|
29
29
|
return TracingLevel;
|
|
30
30
|
}({});
|
|
31
31
|
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/** Whether `obj` has `key` as an own property (never an inherited one, like
|
|
33
|
+
* `"constructor" in {}`). `Object.hasOwn` is ES2022. */
|
|
34
|
+
const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
35
|
+
// ../client/dist/index.mjs
|
|
36
|
+
var version$1 = "0.8.55";
|
|
35
37
|
function getLangVersion() {
|
|
36
38
|
if (typeof process !== "undefined" && process.versions && process.versions.node) return `node-${process.versions.node}`;
|
|
37
39
|
if (typeof navigator !== "undefined" && navigator.userAgent) return `browser-${navigator.userAgent}`;
|
|
@@ -59,6 +61,20 @@ var BaseResource = class {
|
|
|
59
61
|
const errorMsg = await response.text();
|
|
60
62
|
throw new Error(`${response.status} ${errorMsg}`);
|
|
61
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* For routes that answer errors as `{error: "<message>"}` with user-facing
|
|
66
|
+
* text: raise that message instead of the raw JSON body, falling back to the
|
|
67
|
+
* body when it isn't that shape (a proxy error page, a plain-text 413).
|
|
68
|
+
*/
|
|
69
|
+
async handleErrorMessage(response) {
|
|
70
|
+
const body = await response.text();
|
|
71
|
+
let message = body;
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(body);
|
|
74
|
+
if (typeof parsed?.error === "string" && parsed.error.length > 0) message = parsed.error;
|
|
75
|
+
} catch {}
|
|
76
|
+
throw new Error(`${response.status} ${message}`);
|
|
77
|
+
}
|
|
62
78
|
};
|
|
63
79
|
var BrowserEventsResource = class extends BaseResource {
|
|
64
80
|
constructor(baseHttpUrl, auth) {
|
|
@@ -312,7 +328,8 @@ var DatasetsResource = class extends BaseResource {
|
|
|
312
328
|
datapoints: batch.map((point) => ({
|
|
313
329
|
data: point.data,
|
|
314
330
|
target: point.target ?? {},
|
|
315
|
-
metadata: point.metadata ?? {}
|
|
331
|
+
metadata: point.metadata ?? {},
|
|
332
|
+
taskId: point.taskId
|
|
316
333
|
})),
|
|
317
334
|
createDataset
|
|
318
335
|
})
|
|
@@ -426,16 +443,18 @@ var EvalsResource = class extends BaseResource {
|
|
|
426
443
|
* @param {T} [options.target] - The target/expected output for evaluators
|
|
427
444
|
* @param {Record<string, any>} [options.metadata] - Optional metadata
|
|
428
445
|
* @param {number} [options.index] - Optional index of the datapoint
|
|
446
|
+
* @param {string} [options.taskId] - Optional Task id shared by every Trial of the Task
|
|
429
447
|
* @param {string} [options.traceId] - Optional trace ID
|
|
430
448
|
* @returns {Promise<StringUUID>} The datapoint ID
|
|
431
449
|
*/
|
|
432
|
-
async createDatapoint({ evalId, data, target, metadata, index, traceId }) {
|
|
450
|
+
async createDatapoint({ evalId, data, target, metadata, index, taskId, traceId }) {
|
|
433
451
|
const datapointId = newUUID$1();
|
|
434
452
|
const partialDatapoint = {
|
|
435
453
|
id: datapointId,
|
|
436
454
|
data,
|
|
437
455
|
target,
|
|
438
456
|
index: index ?? 0,
|
|
457
|
+
taskId,
|
|
439
458
|
traceId: traceId ?? newUUID$1(),
|
|
440
459
|
executorSpanId: newUUID$1(),
|
|
441
460
|
metadata
|
|
@@ -608,6 +627,89 @@ var EvaluatorsResource = class extends BaseResource {
|
|
|
608
627
|
}
|
|
609
628
|
};
|
|
610
629
|
/**
|
|
630
|
+
* Hosted evals: Harbor evals with trials in Laminar-managed sandboxes.
|
|
631
|
+
*
|
|
632
|
+
* - Images: `missingLayers` / `uploadLayer` / `createImage` push an image built
|
|
633
|
+
* locally (layers named by their `diff_id`); trials start from it.
|
|
634
|
+
* - Remote runs: `upload` the `.tar.gz` of the evals folder, then `startRun`
|
|
635
|
+
* to orchestrate it in a Laminar sandbox. Results land in the project as
|
|
636
|
+
* regular evaluations; v0 returns no run status.
|
|
637
|
+
*/
|
|
638
|
+
var HostedEvalsResource = class extends BaseResource {
|
|
639
|
+
constructor(baseHttpUrl, auth) {
|
|
640
|
+
super(baseHttpUrl, auth);
|
|
641
|
+
}
|
|
642
|
+
/** The image layers (by `diff_id`) the project hasn't uploaded yet. */
|
|
643
|
+
async missingLayers(diffIds) {
|
|
644
|
+
const response = await fetch(this.url("/images/layers/missing"), {
|
|
645
|
+
method: "POST",
|
|
646
|
+
headers: this.headers(),
|
|
647
|
+
body: JSON.stringify({ diffIds })
|
|
648
|
+
});
|
|
649
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
650
|
+
return (await response.json()).missing;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Upload one image layer, gzip-compressed. `diffId` is the digest of its
|
|
654
|
+
* uncompressed tar, as listed in the image config's `rootfs.diff_ids`.
|
|
655
|
+
*/
|
|
656
|
+
async uploadLayer(diffId, gzipped) {
|
|
657
|
+
const response = await fetch(this.url(`/images/layers/${diffId}`), {
|
|
658
|
+
method: "PUT",
|
|
659
|
+
headers: {
|
|
660
|
+
...this.headers(),
|
|
661
|
+
"Content-Type": "application/gzip"
|
|
662
|
+
},
|
|
663
|
+
body: gzipped,
|
|
664
|
+
duplex: "half"
|
|
665
|
+
});
|
|
666
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
667
|
+
return await response.json();
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Push the image described by `config` (its config JSON, byte for byte) once
|
|
671
|
+
* its layers are uploaded. Returns the manifest digest trials start from.
|
|
672
|
+
*/
|
|
673
|
+
async createImage(config) {
|
|
674
|
+
const response = await fetch(this.url("/images"), {
|
|
675
|
+
method: "POST",
|
|
676
|
+
headers: this.headers(),
|
|
677
|
+
body: JSON.stringify({ config })
|
|
678
|
+
});
|
|
679
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
680
|
+
return await response.json();
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Upload a `.tar.gz` of the `evals/` folder's contents (suites at the archive
|
|
684
|
+
* root). Sent as the raw request body; the server caps it at 1 GiB.
|
|
685
|
+
*/
|
|
686
|
+
async upload(archive) {
|
|
687
|
+
const response = await fetch(this.url("/uploads"), {
|
|
688
|
+
method: "POST",
|
|
689
|
+
headers: {
|
|
690
|
+
...this.headers(),
|
|
691
|
+
"Content-Type": "application/gzip"
|
|
692
|
+
},
|
|
693
|
+
body: archive
|
|
694
|
+
});
|
|
695
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
696
|
+
return await response.json();
|
|
697
|
+
}
|
|
698
|
+
/** Start a remote run. Returns once its orchestrator sandbox has started. */
|
|
699
|
+
async startRun(options) {
|
|
700
|
+
const response = await fetch(this.url("/runs"), {
|
|
701
|
+
method: "POST",
|
|
702
|
+
headers: this.headers(),
|
|
703
|
+
body: JSON.stringify(options)
|
|
704
|
+
});
|
|
705
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
706
|
+
return await response.json();
|
|
707
|
+
}
|
|
708
|
+
url(path) {
|
|
709
|
+
return `${this.baseHttpUrl}${this.apiPrefix}/hosted-evals${path}`;
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
611
713
|
* Workspace LLM profile CRUD over the CLI user-token surface
|
|
612
714
|
* (`/v1/cli/llm-profiles`). Validation is entirely server-side; error messages
|
|
613
715
|
* come back user-ready. Self-hosted only: on Laminar Cloud every route 404s
|
|
@@ -617,27 +719,13 @@ var LlmProfilesResource = class extends BaseResource {
|
|
|
617
719
|
constructor(baseHttpUrl, auth) {
|
|
618
720
|
super(baseHttpUrl, auth);
|
|
619
721
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
* user-facing text, so unwrap the envelope before raising rather than
|
|
623
|
-
* showing the raw JSON body.
|
|
624
|
-
*/
|
|
625
|
-
async raiseLlmProfileError(response) {
|
|
626
|
-
const body = await response.text();
|
|
627
|
-
let message = body;
|
|
628
|
-
try {
|
|
629
|
-
const parsed = JSON.parse(body);
|
|
630
|
-
if (typeof parsed?.error === "string" && parsed.error.length > 0) message = parsed.error;
|
|
631
|
-
} catch {}
|
|
632
|
-
throw new Error(`${response.status} ${message}`);
|
|
633
|
-
}
|
|
634
|
-
async request(method, path$2, body) {
|
|
635
|
-
const response = await fetch(`${this.baseHttpUrl}${this.apiPrefix}/llm-profiles${path$2}`, {
|
|
722
|
+
async request(method, path, body) {
|
|
723
|
+
const response = await fetch(`${this.baseHttpUrl}${this.apiPrefix}/llm-profiles${path}`, {
|
|
636
724
|
method,
|
|
637
725
|
headers: this.headers(),
|
|
638
726
|
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
639
727
|
});
|
|
640
|
-
if (!response.ok) await this.
|
|
728
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
641
729
|
return response;
|
|
642
730
|
}
|
|
643
731
|
/**
|
|
@@ -853,34 +941,22 @@ var RolloutSessionsResource = class extends BaseResource {
|
|
|
853
941
|
if (!response.ok) await this.handleError(response);
|
|
854
942
|
}
|
|
855
943
|
};
|
|
856
|
-
/**
|
|
944
|
+
/**
|
|
945
|
+
* Signals CRUD over the CLI user-token surface (`/v1/cli/signals`). Errors come
|
|
946
|
+
* back as `{error}` with user-facing text (e.g. "A signal named X already
|
|
947
|
+
* exists in this project"), raised verbatim by `handleErrorMessage`.
|
|
948
|
+
*/
|
|
857
949
|
var SignalsResource = class extends BaseResource {
|
|
858
950
|
constructor(baseHttpUrl, auth) {
|
|
859
951
|
super(baseHttpUrl, auth);
|
|
860
952
|
}
|
|
861
|
-
/**
|
|
862
|
-
* Every signal route answers errors as `{ error: "<message>" }`, and those
|
|
863
|
-
* messages are written to be shown to the user verbatim (e.g. "A signal named
|
|
864
|
-
* X already exists in this project"). The shared `handleError` would surface
|
|
865
|
-
* the raw JSON body, so unwrap the envelope here and fall back to it when the
|
|
866
|
-
* body isn't the expected shape.
|
|
867
|
-
*/
|
|
868
|
-
async raiseSignalError(response) {
|
|
869
|
-
const body = await response.text();
|
|
870
|
-
let message = body;
|
|
871
|
-
try {
|
|
872
|
-
const parsed = JSON.parse(body);
|
|
873
|
-
if (typeof parsed?.error === "string" && parsed.error.length > 0) message = parsed.error;
|
|
874
|
-
} catch {}
|
|
875
|
-
throw new Error(`${response.status} ${message}`);
|
|
876
|
-
}
|
|
877
953
|
async list(name) {
|
|
878
954
|
const query = name ? `?${new URLSearchParams({ name }).toString()}` : "";
|
|
879
955
|
const response = await fetch(`${this.baseHttpUrl}${this.apiPrefix}/signals${query}`, {
|
|
880
956
|
method: "GET",
|
|
881
957
|
headers: this.headers()
|
|
882
958
|
});
|
|
883
|
-
if (!response.ok) await this.
|
|
959
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
884
960
|
const body = await response.json();
|
|
885
961
|
return Array.isArray(body?.signals) ? body.signals : [];
|
|
886
962
|
}
|
|
@@ -889,7 +965,7 @@ var SignalsResource = class extends BaseResource {
|
|
|
889
965
|
method: "GET",
|
|
890
966
|
headers: this.headers()
|
|
891
967
|
});
|
|
892
|
-
if (!response.ok) await this.
|
|
968
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
893
969
|
return response.json();
|
|
894
970
|
}
|
|
895
971
|
/**
|
|
@@ -903,7 +979,7 @@ var SignalsResource = class extends BaseResource {
|
|
|
903
979
|
method: "GET",
|
|
904
980
|
headers: this.headers()
|
|
905
981
|
});
|
|
906
|
-
if (!response.ok) await this.
|
|
982
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
907
983
|
const body = await response.json();
|
|
908
984
|
return Array.isArray(body?.versions) ? body.versions : [];
|
|
909
985
|
}
|
|
@@ -913,7 +989,7 @@ var SignalsResource = class extends BaseResource {
|
|
|
913
989
|
headers: this.headers(),
|
|
914
990
|
body: JSON.stringify(options)
|
|
915
991
|
});
|
|
916
|
-
if (!response.ok) await this.
|
|
992
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
917
993
|
return response.json();
|
|
918
994
|
}
|
|
919
995
|
/**
|
|
@@ -927,7 +1003,7 @@ var SignalsResource = class extends BaseResource {
|
|
|
927
1003
|
headers: this.headers(),
|
|
928
1004
|
body: JSON.stringify(options)
|
|
929
1005
|
});
|
|
930
|
-
if (!response.ok) await this.
|
|
1006
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
931
1007
|
return response.json();
|
|
932
1008
|
}
|
|
933
1009
|
/** Deletes the signal, its triggers, its alerts, and its ClickHouse events. */
|
|
@@ -936,7 +1012,7 @@ var SignalsResource = class extends BaseResource {
|
|
|
936
1012
|
method: "DELETE",
|
|
937
1013
|
headers: this.headers()
|
|
938
1014
|
});
|
|
939
|
-
if (!response.ok) await this.
|
|
1015
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
940
1016
|
return response.json();
|
|
941
1017
|
}
|
|
942
1018
|
/**
|
|
@@ -950,7 +1026,7 @@ var SignalsResource = class extends BaseResource {
|
|
|
950
1026
|
headers: this.headers(),
|
|
951
1027
|
body: JSON.stringify({ traceIds })
|
|
952
1028
|
});
|
|
953
|
-
if (!response.ok) await this.
|
|
1029
|
+
if (!response.ok) await this.handleErrorMessage(response);
|
|
954
1030
|
return response.json();
|
|
955
1031
|
}
|
|
956
1032
|
};
|
|
@@ -1131,6 +1207,7 @@ var LaminarClient = class LaminarClient {
|
|
|
1131
1207
|
this._datasets = new DatasetsResource(this.baseUrl, this.auth);
|
|
1132
1208
|
this._evals = new EvalsResource(this.baseUrl, this.auth);
|
|
1133
1209
|
this._evaluators = new EvaluatorsResource(this.baseUrl, this.auth);
|
|
1210
|
+
this._hostedEvals = new HostedEvalsResource(this.baseUrl, this.auth);
|
|
1134
1211
|
this._llmProfiles = new LlmProfilesResource(this.baseUrl, this.auth);
|
|
1135
1212
|
this._rolloutSessions = new RolloutSessionsResource(this.baseUrl, this.auth);
|
|
1136
1213
|
this._signals = new SignalsResource(this.baseUrl, this.auth);
|
|
@@ -1202,6 +1279,9 @@ var LaminarClient = class LaminarClient {
|
|
|
1202
1279
|
get evaluators() {
|
|
1203
1280
|
return this._evaluators;
|
|
1204
1281
|
}
|
|
1282
|
+
get hostedEvals() {
|
|
1283
|
+
return this._hostedEvals;
|
|
1284
|
+
}
|
|
1205
1285
|
get llmProfiles() {
|
|
1206
1286
|
return this._llmProfiles;
|
|
1207
1287
|
}
|
|
@@ -1221,11 +1301,9 @@ var LaminarClient = class LaminarClient {
|
|
|
1221
1301
|
return this._traces;
|
|
1222
1302
|
}
|
|
1223
1303
|
};
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
//#endregion
|
|
1228
|
-
//#region src/opentelemetry-lib/tracing/attributes.ts
|
|
1304
|
+
// package.json
|
|
1305
|
+
var version = "0.8.55";
|
|
1306
|
+
// src/opentelemetry-lib/tracing/attributes.ts
|
|
1229
1307
|
const SPAN_INPUT = "lmnr.span.input";
|
|
1230
1308
|
const SPAN_OUTPUT = "lmnr.span.output";
|
|
1231
1309
|
const SPAN_TYPE = "lmnr.span.type";
|
|
@@ -1241,6 +1319,9 @@ const SPAN_INSTRUMENTATION_SCOPE_NAME = "lmnr.span.instrumentation_scope.name";
|
|
|
1241
1319
|
const SPAN_INSTRUMENTATION_SCOPE_VERSION = "lmnr.span.instrumentation_scope.version";
|
|
1242
1320
|
const TRACE_HAS_BROWSER_SESSION = "lmnr.internal.has_browser_session";
|
|
1243
1321
|
const HUMAN_EVALUATOR_OPTIONS = "lmnr.span.human_evaluator_options";
|
|
1322
|
+
const GEN_AI_INPUT_MESSAGES = "gen_ai.input.messages";
|
|
1323
|
+
const GEN_AI_OUTPUT_MESSAGES = "gen_ai.output.messages";
|
|
1324
|
+
const GEN_AI_TOOL_DEFINITIONS = "gen_ai.tool.definitions";
|
|
1244
1325
|
const ASSOCIATION_PROPERTIES = "lmnr.association.properties";
|
|
1245
1326
|
const SESSION_ID = "lmnr.association.properties.session_id";
|
|
1246
1327
|
const USER_ID = "lmnr.association.properties.user_id";
|
|
@@ -1257,8 +1338,7 @@ const LaminarAttributes = {
|
|
|
1257
1338
|
OUTPUT_COST: "gen_ai.usage.output_cost",
|
|
1258
1339
|
TOTAL_COST: "gen_ai.usage.cost"
|
|
1259
1340
|
};
|
|
1260
|
-
|
|
1261
|
-
//#region src/utils.ts
|
|
1341
|
+
// src/utils.ts
|
|
1262
1342
|
function initializeLogger(options) {
|
|
1263
1343
|
const colorize = options?.colorize ?? true;
|
|
1264
1344
|
const level = options?.level ?? process.env.LMNR_LOG_LEVEL?.toLowerCase()?.trim() ?? "info";
|
|
@@ -1304,8 +1384,8 @@ const otelTraceIdToUUID = (traceId) => {
|
|
|
1304
1384
|
}
|
|
1305
1385
|
return id.replace(/^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})$/, "$1-$2-$3-$4-$5");
|
|
1306
1386
|
};
|
|
1307
|
-
const uuidToOtelTraceId = (uuid
|
|
1308
|
-
const uuidToOtelSpanId = (uuid
|
|
1387
|
+
const uuidToOtelTraceId = (uuid) => uuid.replace(/-/g, "");
|
|
1388
|
+
const uuidToOtelSpanId = (uuid) => uuid.replace(/-/g, "").slice(16);
|
|
1309
1389
|
/**
|
|
1310
1390
|
* This is a simple implementation of a semaphore to replicate
|
|
1311
1391
|
* the behavior of the `asyncio.Semaphore` in Python.
|
|
@@ -1432,6 +1512,62 @@ const getDirname = () => {
|
|
|
1432
1512
|
if (typeof require("url").pathToFileURL(__filename).href !== "undefined") return path.dirname((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
1433
1513
|
return process.cwd();
|
|
1434
1514
|
};
|
|
1515
|
+
const CIRCULAR_REFERENCE = "[Circular reference]";
|
|
1516
|
+
/**
|
|
1517
|
+
* `JSON.stringify` for span attributes. It never throws:
|
|
1518
|
+
* - `null`, `undefined` and values JSON can't represent (a function, a symbol)
|
|
1519
|
+
* give `undefined`, so the attribute is skipped. So does a value whose
|
|
1520
|
+
* serialization throws (a throwing getter or `toJSON`).
|
|
1521
|
+
* - bigints become strings, and a `Map` becomes its `[key, value]` entries.
|
|
1522
|
+
* - an object that is its own ancestor becomes `"[Circular reference]"`. The
|
|
1523
|
+
* same object reached twice through different paths is serialized both
|
|
1524
|
+
* times: SDK payloads share objects (LangChain messages share tool-call args
|
|
1525
|
+
* between `tool_calls` and provider content blocks), and a "seen anywhere"
|
|
1526
|
+
* set would replace the second copy.
|
|
1527
|
+
*
|
|
1528
|
+
* Strings are serialized too (quoted). Callers that record strings as they are
|
|
1529
|
+
* check for them first.
|
|
1530
|
+
*/
|
|
1531
|
+
const toJson = (value) => {
|
|
1532
|
+
if (value === void 0 || value === null) return void 0;
|
|
1533
|
+
const holders = [];
|
|
1534
|
+
const sources = [];
|
|
1535
|
+
try {
|
|
1536
|
+
return JSON.stringify(value, function(_key, item) {
|
|
1537
|
+
if (typeof item === "bigint") return item.toString();
|
|
1538
|
+
if (item === null || typeof item !== "object") return item;
|
|
1539
|
+
while (holders.length > 0 && holders[holders.length - 1] !== this) {
|
|
1540
|
+
holders.pop();
|
|
1541
|
+
sources.pop();
|
|
1542
|
+
}
|
|
1543
|
+
if (sources.includes(item)) return CIRCULAR_REFERENCE;
|
|
1544
|
+
const replacement = item instanceof Map ? Array.from(item.entries()) : item;
|
|
1545
|
+
holders.push(replacement);
|
|
1546
|
+
sources.push(item);
|
|
1547
|
+
return replacement;
|
|
1548
|
+
});
|
|
1549
|
+
} catch (error) {
|
|
1550
|
+
logger.debug(`Failed to serialize value to JSON: ${errorMessage(error)}`);
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
/**
|
|
1555
|
+
* `toJson`, except that a string is returned as it is, for payloads where a
|
|
1556
|
+
* string already is the serialized form.
|
|
1557
|
+
*/
|
|
1558
|
+
const toJsonOrString = (value) => typeof value === "string" ? value : toJson(value);
|
|
1559
|
+
/**
|
|
1560
|
+
* `JSON.parse` that hands back the input when it is not a string or not valid
|
|
1561
|
+
* JSON.
|
|
1562
|
+
*/
|
|
1563
|
+
const parseJson = (value) => {
|
|
1564
|
+
if (typeof value !== "string") return value;
|
|
1565
|
+
try {
|
|
1566
|
+
return JSON.parse(value);
|
|
1567
|
+
} catch {
|
|
1568
|
+
return value;
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1435
1571
|
const MAX_MANUAL_SPAN_PAYLOAD_SIZE = 10485760;
|
|
1436
1572
|
const TRUNCATION_SUFFIX = "...[Laminar: truncated]";
|
|
1437
1573
|
/**
|
|
@@ -1549,17 +1685,16 @@ const loadEnv = (options) => {
|
|
|
1549
1685
|
* @returns The frontend URL
|
|
1550
1686
|
*/
|
|
1551
1687
|
const getFrontendUrl = (baseUrl, frontendPort) => {
|
|
1552
|
-
let url
|
|
1553
|
-
if (url
|
|
1554
|
-
url
|
|
1555
|
-
if (/localhost|127\.0\.0\.1/.test(url
|
|
1556
|
-
const port = frontendPort ?? url
|
|
1557
|
-
if (/:(\d{1,5})$/.test(url
|
|
1558
|
-
else url
|
|
1559
|
-
}
|
|
1560
|
-
return url
|
|
1688
|
+
let url = baseUrl ?? "https://api.lmnr.ai";
|
|
1689
|
+
if (url === "https://api.lmnr.ai") url = "https://www.laminar.sh";
|
|
1690
|
+
url = url.replace(/\/$/, "");
|
|
1691
|
+
if (/localhost|127\.0\.0\.1/.test(url)) {
|
|
1692
|
+
const port = frontendPort ?? url.match(/:\d{1,5}$/g)?.[0]?.slice(1) ?? 5667;
|
|
1693
|
+
if (/:(\d{1,5})$/.test(url)) url = url.replace(/:\d{1,5}$/g, `:${port}`);
|
|
1694
|
+
else url = `${url}:${port}`;
|
|
1695
|
+
}
|
|
1696
|
+
return url;
|
|
1561
1697
|
};
|
|
1562
|
-
//#endregion
|
|
1563
1698
|
Object.defineProperty(exports, "ASSOCIATION_PROPERTIES", {
|
|
1564
1699
|
enumerable: true,
|
|
1565
1700
|
get: function() {
|
|
@@ -1584,6 +1719,24 @@ Object.defineProperty(exports, "DEBUG_SESSION_FILE", {
|
|
|
1584
1719
|
return DEBUG_SESSION_FILE;
|
|
1585
1720
|
}
|
|
1586
1721
|
});
|
|
1722
|
+
Object.defineProperty(exports, "GEN_AI_INPUT_MESSAGES", {
|
|
1723
|
+
enumerable: true,
|
|
1724
|
+
get: function() {
|
|
1725
|
+
return GEN_AI_INPUT_MESSAGES;
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
Object.defineProperty(exports, "GEN_AI_OUTPUT_MESSAGES", {
|
|
1729
|
+
enumerable: true,
|
|
1730
|
+
get: function() {
|
|
1731
|
+
return GEN_AI_OUTPUT_MESSAGES;
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1734
|
+
Object.defineProperty(exports, "GEN_AI_TOOL_DEFINITIONS", {
|
|
1735
|
+
enumerable: true,
|
|
1736
|
+
get: function() {
|
|
1737
|
+
return GEN_AI_TOOL_DEFINITIONS;
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1587
1740
|
Object.defineProperty(exports, "HUMAN_EVALUATOR_OPTIONS", {
|
|
1588
1741
|
enumerable: true,
|
|
1589
1742
|
get: function() {
|
|
@@ -1752,6 +1905,12 @@ Object.defineProperty(exports, "getOtelEnvVar", {
|
|
|
1752
1905
|
return getOtelEnvVar;
|
|
1753
1906
|
}
|
|
1754
1907
|
});
|
|
1908
|
+
Object.defineProperty(exports, "hasOwn", {
|
|
1909
|
+
enumerable: true,
|
|
1910
|
+
get: function() {
|
|
1911
|
+
return hasOwn;
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1755
1914
|
Object.defineProperty(exports, "initializeLogger", {
|
|
1756
1915
|
enumerable: true,
|
|
1757
1916
|
get: function() {
|
|
@@ -1800,12 +1959,30 @@ Object.defineProperty(exports, "otelTraceIdToUUID", {
|
|
|
1800
1959
|
return otelTraceIdToUUID;
|
|
1801
1960
|
}
|
|
1802
1961
|
});
|
|
1962
|
+
Object.defineProperty(exports, "parseJson", {
|
|
1963
|
+
enumerable: true,
|
|
1964
|
+
get: function() {
|
|
1965
|
+
return parseJson;
|
|
1966
|
+
}
|
|
1967
|
+
});
|
|
1803
1968
|
Object.defineProperty(exports, "parseOtelHeaders", {
|
|
1804
1969
|
enumerable: true,
|
|
1805
1970
|
get: function() {
|
|
1806
1971
|
return parseOtelHeaders;
|
|
1807
1972
|
}
|
|
1808
1973
|
});
|
|
1974
|
+
Object.defineProperty(exports, "toJson", {
|
|
1975
|
+
enumerable: true,
|
|
1976
|
+
get: function() {
|
|
1977
|
+
return toJson;
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1980
|
+
Object.defineProperty(exports, "toJsonOrString", {
|
|
1981
|
+
enumerable: true,
|
|
1982
|
+
get: function() {
|
|
1983
|
+
return toJsonOrString;
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1809
1986
|
Object.defineProperty(exports, "truncateSpanPayload", {
|
|
1810
1987
|
enumerable: true,
|
|
1811
1988
|
get: function() {
|
|
@@ -1831,4 +2008,4 @@ Object.defineProperty(exports, "version", {
|
|
|
1831
2008
|
}
|
|
1832
2009
|
});
|
|
1833
2010
|
|
|
1834
|
-
//# sourceMappingURL=utils-
|
|
2011
|
+
//# sourceMappingURL=utils-C3QuhVGE.cjs.map
|