langsmith 0.5.22 → 0.5.24
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/client.cjs +365 -19
- package/dist/client.d.ts +116 -1
- package/dist/client.js +369 -23
- package/dist/evaluation/_runner.cjs +4 -7
- package/dist/evaluation/_runner.js +2 -5
- package/dist/evaluation/evaluate_comparative.cjs +10 -10
- package/dist/evaluation/evaluate_comparative.js +1 -1
- package/dist/evaluation/evaluator.cjs +2 -2
- package/dist/evaluation/evaluator.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/run_trees.cjs +8 -7
- package/dist/run_trees.d.ts +7 -0
- package/dist/run_trees.js +7 -6
- package/dist/schemas.d.ts +54 -0
- package/dist/singletons/otel.cjs +3 -2
- package/dist/singletons/otel.js +4 -3
- package/dist/traceable.cjs +1 -2
- package/dist/traceable.js +1 -2
- package/dist/utils/_uuid.cjs +2 -2
- package/dist/utils/_uuid.js +1 -1
- package/dist/utils/env.cjs +33 -0
- package/dist/utils/env.d.ts +9 -0
- package/dist/utils/env.js +32 -0
- package/dist/utils/error.cjs +7 -0
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +6 -0
- package/dist/utils/fast-safe-stringify/index.cjs +203 -0
- package/dist/utils/fast-safe-stringify/index.d.ts +46 -0
- package/dist/utils/fast-safe-stringify/index.js +202 -0
- package/dist/utils/jestlike/index.cjs +5 -5
- package/dist/utils/jestlike/index.js +1 -1
- package/dist/utils/jestlike/vendor/evaluatedBy.cjs +3 -3
- package/dist/utils/jestlike/vendor/evaluatedBy.js +1 -1
- package/dist/utils/prompts.cjs +7 -2
- package/dist/utils/prompts.d.ts +6 -1
- package/dist/utils/prompts.js +6 -1
- package/dist/utils/serialize_worker.cjs +389 -0
- package/dist/utils/serialize_worker.d.ts +67 -0
- package/dist/utils/serialize_worker.js +383 -0
- package/dist/utils/uuid/src/index.cjs +24 -0
- package/dist/utils/uuid/src/index.d.ts +10 -0
- package/dist/utils/uuid/src/index.js +9 -0
- package/dist/utils/uuid/src/max.cjs +3 -0
- package/dist/utils/uuid/src/max.d.ts +2 -0
- package/dist/utils/uuid/src/max.js +1 -0
- package/dist/utils/uuid/src/nil.cjs +3 -0
- package/dist/utils/uuid/src/nil.d.ts +2 -0
- package/dist/utils/uuid/src/nil.js +1 -0
- package/dist/utils/uuid/src/parse.cjs +23 -0
- package/dist/utils/uuid/src/parse.d.ts +3 -0
- package/dist/utils/uuid/src/parse.js +18 -0
- package/dist/utils/uuid/src/regex.cjs +3 -0
- package/dist/utils/uuid/src/regex.d.ts +2 -0
- package/dist/utils/uuid/src/regex.js +1 -0
- package/dist/utils/uuid/src/rng.cjs +10 -0
- package/dist/utils/uuid/src/rng.d.ts +1 -0
- package/dist/utils/uuid/src/rng.js +7 -0
- package/dist/utils/uuid/src/sha1.cjs +75 -0
- package/dist/utils/uuid/src/sha1.d.ts +2 -0
- package/dist/utils/uuid/src/sha1.js +73 -0
- package/dist/utils/uuid/src/stringify.cjs +55 -0
- package/dist/utils/uuid/src/stringify.d.ts +3 -0
- package/dist/utils/uuid/src/stringify.js +49 -0
- package/dist/utils/uuid/src/types.cjs +2 -0
- package/dist/utils/uuid/src/types.d.ts +22 -0
- package/dist/utils/uuid/src/types.js +1 -0
- package/dist/utils/uuid/src/v35.cjs +52 -0
- package/dist/utils/uuid/src/v35.d.ts +7 -0
- package/dist/utils/uuid/src/v35.js +44 -0
- package/dist/utils/uuid/src/v4.cjs +40 -0
- package/dist/utils/uuid/src/v4.d.ts +4 -0
- package/dist/utils/uuid/src/v4.js +35 -0
- package/dist/utils/uuid/src/v5.cjs +50 -0
- package/dist/utils/uuid/src/v5.d.ts +9 -0
- package/dist/utils/uuid/src/v5.js +9 -0
- package/dist/utils/uuid/src/v7.cjs +88 -0
- package/dist/utils/uuid/src/v7.d.ts +9 -0
- package/dist/utils/uuid/src/v7.js +82 -0
- package/dist/utils/uuid/src/validate.cjs +10 -0
- package/dist/utils/uuid/src/validate.d.ts +2 -0
- package/dist/utils/uuid/src/validate.js +5 -0
- package/dist/utils/uuid/src/version.cjs +13 -0
- package/dist/utils/uuid/src/version.d.ts +2 -0
- package/dist/utils/uuid/src/version.js +8 -0
- package/dist/utils/worker_threads.browser.cjs +16 -0
- package/dist/utils/worker_threads.browser.d.ts +14 -0
- package/dist/utils/worker_threads.browser.js +13 -0
- package/dist/utils/worker_threads.cjs +16 -0
- package/dist/utils/worker_threads.d.ts +13 -0
- package/dist/utils/worker_threads.js +13 -0
- package/dist/uuid.cjs +2 -2
- package/dist/uuid.js +1 -1
- package/package.json +7 -5
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DynamicRunEvaluator = void 0;
|
|
4
4
|
exports.runEvaluator = runEvaluator;
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("../utils/uuid/src/index.cjs");
|
|
6
6
|
const traceable_js_1 = require("../traceable.cjs");
|
|
7
7
|
/**
|
|
8
8
|
* Wraps an evaluator function + implements the RunEvaluator interface.
|
|
@@ -67,7 +67,7 @@ class DynamicRunEvaluator {
|
|
|
67
67
|
* @returns A promise that extracts to the evaluation result.
|
|
68
68
|
*/
|
|
69
69
|
async evaluateRun(run, example, options) {
|
|
70
|
-
let sourceRunId = (0,
|
|
70
|
+
let sourceRunId = (0, index_js_1.v7)();
|
|
71
71
|
const metadata = {
|
|
72
72
|
targetRunId: run.id,
|
|
73
73
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
|
|
|
18
18
|
Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
|
|
19
19
|
Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
|
|
20
20
|
// Update using pnpm bump-version
|
|
21
|
-
exports.__version__ = "0.5.
|
|
21
|
+
exports.__version__ = "0.5.24";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
6
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
7
7
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
|
-
export declare const __version__ = "0.5.
|
|
8
|
+
export declare const __version__ = "0.5.24";
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { getDefaultProjectName } from "./utils/project.js";
|
|
|
5
5
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
6
6
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
7
7
|
// Update using pnpm bump-version
|
|
8
|
-
export const __version__ = "0.5.
|
|
8
|
+
export const __version__ = "0.5.24";
|
package/dist/run_trees.cjs
CHANGED
|
@@ -14,7 +14,7 @@ const project_js_1 = require("./utils/project.cjs");
|
|
|
14
14
|
const env_js_3 = require("./utils/env.cjs");
|
|
15
15
|
const warn_js_1 = require("./utils/warn.cjs");
|
|
16
16
|
const _uuid_js_1 = require("./utils/_uuid.cjs");
|
|
17
|
-
const
|
|
17
|
+
const index_js_1 = require("./utils/uuid/src/index.cjs");
|
|
18
18
|
const TIMESTAMP_LENGTH = 36;
|
|
19
19
|
// DNS namespace for UUID v5 (same as Python's uuid.NAMESPACE_DNS)
|
|
20
20
|
const UUID_NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
@@ -26,7 +26,7 @@ function getReplicaKey(replica) {
|
|
|
26
26
|
const keyData = sortedKeys
|
|
27
27
|
.map((key) => `${key}:${replica[key] ?? ""}`)
|
|
28
28
|
.join("|");
|
|
29
|
-
return (0,
|
|
29
|
+
return (0, index_js_1.v5)(keyData, UUID_NAMESPACE_DNS);
|
|
30
30
|
}
|
|
31
31
|
function stripNonAlphanumeric(input) {
|
|
32
32
|
return input.replace(/[-:.]/g, "");
|
|
@@ -691,8 +691,7 @@ class RunTree {
|
|
|
691
691
|
try {
|
|
692
692
|
const runtimeEnv = (0, env_js_2.getRuntimeEnvironment)();
|
|
693
693
|
if (this.replicas && this.replicas.length > 0) {
|
|
694
|
-
for (const { projectName, apiKey, apiUrl, workspaceId, reroot } of this
|
|
695
|
-
.replicas) {
|
|
694
|
+
for (const { projectName, apiKey, apiUrl, workspaceId, reroot, client: replicaClient, } of this.replicas) {
|
|
696
695
|
const runCreate = this._remapForProject({
|
|
697
696
|
projectName: projectName ?? this.project_name,
|
|
698
697
|
runtimeEnv,
|
|
@@ -703,7 +702,8 @@ class RunTree {
|
|
|
703
702
|
apiKey,
|
|
704
703
|
workspaceId,
|
|
705
704
|
});
|
|
706
|
-
|
|
705
|
+
const targetClient = replicaClient ?? this.client;
|
|
706
|
+
await targetClient.createRun(runCreate, {
|
|
707
707
|
apiKey,
|
|
708
708
|
apiUrl,
|
|
709
709
|
workspaceId,
|
|
@@ -728,7 +728,7 @@ class RunTree {
|
|
|
728
728
|
}
|
|
729
729
|
async patchRun(options) {
|
|
730
730
|
if (this.replicas && this.replicas.length > 0) {
|
|
731
|
-
for (const { projectName, apiKey, apiUrl, workspaceId, updates, reroot, } of this.replicas) {
|
|
731
|
+
for (const { projectName, apiKey, apiUrl, workspaceId, updates, reroot, client: replicaClient, } of this.replicas) {
|
|
732
732
|
const runData = this._remapForProject({
|
|
733
733
|
projectName: projectName ?? this.project_name,
|
|
734
734
|
runtimeEnv: undefined,
|
|
@@ -764,7 +764,8 @@ class RunTree {
|
|
|
764
764
|
if (!options?.excludeInputs) {
|
|
765
765
|
updatePayload.inputs = runData.inputs;
|
|
766
766
|
}
|
|
767
|
-
|
|
767
|
+
const targetClient = replicaClient ?? this.client;
|
|
768
|
+
await targetClient.updateRun(runData.id, updatePayload, {
|
|
768
769
|
apiKey,
|
|
769
770
|
apiUrl,
|
|
770
771
|
workspaceId,
|
package/dist/run_trees.d.ts
CHANGED
|
@@ -63,6 +63,13 @@ type WriteReplica = {
|
|
|
63
63
|
updates?: KVMap | undefined;
|
|
64
64
|
fromEnv?: boolean;
|
|
65
65
|
reroot?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Optional dedicated Client for this replica.
|
|
68
|
+
* When set, the replica's runs are dispatched through this client
|
|
69
|
+
* (and its tracing mode) instead of the RunTree's default client.
|
|
70
|
+
* Not serialized in distributed-tracing baggage headers.
|
|
71
|
+
*/
|
|
72
|
+
client?: Client;
|
|
66
73
|
};
|
|
67
74
|
type Replica = ProjectReplica | WriteReplica;
|
|
68
75
|
export declare class RunTree implements BaseRun {
|
package/dist/run_trees.js
CHANGED
|
@@ -8,7 +8,7 @@ import { getDefaultProjectName } from "./utils/project.js";
|
|
|
8
8
|
import { getLangSmithEnvironmentVariable } from "./utils/env.js";
|
|
9
9
|
import { warnOnce } from "./utils/warn.js";
|
|
10
10
|
import { uuid7FromTime, nonCryptographicUuid7Deterministic, } from "./utils/_uuid.js";
|
|
11
|
-
import { v5 as uuidv5 } from "uuid";
|
|
11
|
+
import { v5 as uuidv5 } from "./utils/uuid/src/index.js";
|
|
12
12
|
const TIMESTAMP_LENGTH = 36;
|
|
13
13
|
// DNS namespace for UUID v5 (same as Python's uuid.NAMESPACE_DNS)
|
|
14
14
|
const UUID_NAMESPACE_DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
@@ -685,8 +685,7 @@ export class RunTree {
|
|
|
685
685
|
try {
|
|
686
686
|
const runtimeEnv = getRuntimeEnvironment();
|
|
687
687
|
if (this.replicas && this.replicas.length > 0) {
|
|
688
|
-
for (const { projectName, apiKey, apiUrl, workspaceId, reroot } of this
|
|
689
|
-
.replicas) {
|
|
688
|
+
for (const { projectName, apiKey, apiUrl, workspaceId, reroot, client: replicaClient, } of this.replicas) {
|
|
690
689
|
const runCreate = this._remapForProject({
|
|
691
690
|
projectName: projectName ?? this.project_name,
|
|
692
691
|
runtimeEnv,
|
|
@@ -697,7 +696,8 @@ export class RunTree {
|
|
|
697
696
|
apiKey,
|
|
698
697
|
workspaceId,
|
|
699
698
|
});
|
|
700
|
-
|
|
699
|
+
const targetClient = replicaClient ?? this.client;
|
|
700
|
+
await targetClient.createRun(runCreate, {
|
|
701
701
|
apiKey,
|
|
702
702
|
apiUrl,
|
|
703
703
|
workspaceId,
|
|
@@ -722,7 +722,7 @@ export class RunTree {
|
|
|
722
722
|
}
|
|
723
723
|
async patchRun(options) {
|
|
724
724
|
if (this.replicas && this.replicas.length > 0) {
|
|
725
|
-
for (const { projectName, apiKey, apiUrl, workspaceId, updates, reroot, } of this.replicas) {
|
|
725
|
+
for (const { projectName, apiKey, apiUrl, workspaceId, updates, reroot, client: replicaClient, } of this.replicas) {
|
|
726
726
|
const runData = this._remapForProject({
|
|
727
727
|
projectName: projectName ?? this.project_name,
|
|
728
728
|
runtimeEnv: undefined,
|
|
@@ -758,7 +758,8 @@ export class RunTree {
|
|
|
758
758
|
if (!options?.excludeInputs) {
|
|
759
759
|
updatePayload.inputs = runData.inputs;
|
|
760
760
|
}
|
|
761
|
-
|
|
761
|
+
const targetClient = replicaClient ?? this.client;
|
|
762
|
+
await targetClient.updateRun(runData.id, updatePayload, {
|
|
762
763
|
apiKey,
|
|
763
764
|
apiUrl,
|
|
764
765
|
workspaceId,
|
package/dist/schemas.d.ts
CHANGED
|
@@ -435,6 +435,60 @@ export type PromptSortField = "num_downloads" | "num_views" | "updated_at" | "nu
|
|
|
435
435
|
export interface LikePromptResponse {
|
|
436
436
|
likes: number;
|
|
437
437
|
}
|
|
438
|
+
export interface FileEntry {
|
|
439
|
+
type: "file";
|
|
440
|
+
content: string;
|
|
441
|
+
}
|
|
442
|
+
export interface AgentEntry {
|
|
443
|
+
type: "agent";
|
|
444
|
+
repo_handle: string;
|
|
445
|
+
commit_id?: string;
|
|
446
|
+
owner?: string;
|
|
447
|
+
commit_hash?: string;
|
|
448
|
+
}
|
|
449
|
+
export interface SkillEntry {
|
|
450
|
+
type: "skill";
|
|
451
|
+
repo_handle: string;
|
|
452
|
+
commit_id?: string;
|
|
453
|
+
owner?: string;
|
|
454
|
+
commit_hash?: string;
|
|
455
|
+
}
|
|
456
|
+
export type Entry = FileEntry | AgentEntry | SkillEntry;
|
|
457
|
+
/** The type of a non-prompt hub repo. */
|
|
458
|
+
export type HubRepoType = "agent" | "skill";
|
|
459
|
+
/**
|
|
460
|
+
* An agent pulled from hub.
|
|
461
|
+
*/
|
|
462
|
+
export interface AgentContext {
|
|
463
|
+
/** The commit ID. */
|
|
464
|
+
commit_id: string;
|
|
465
|
+
/** The commit hash. */
|
|
466
|
+
commit_hash: string;
|
|
467
|
+
/** The files in the agent. */
|
|
468
|
+
files: Record<string, Entry>;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* A skill pulled from hub.
|
|
472
|
+
*/
|
|
473
|
+
export interface SkillContext {
|
|
474
|
+
/** The commit ID. */
|
|
475
|
+
commit_id: string;
|
|
476
|
+
/** The commit hash. */
|
|
477
|
+
commit_hash: string;
|
|
478
|
+
/** The files in the skill. */
|
|
479
|
+
files: Record<string, Entry>;
|
|
480
|
+
}
|
|
481
|
+
/** Response body for `POST /directories/commits`. */
|
|
482
|
+
export interface DirectoryCommitResponse {
|
|
483
|
+
commit: {
|
|
484
|
+
/** The commit ID. */
|
|
485
|
+
id: string;
|
|
486
|
+
/** The commit hash. */
|
|
487
|
+
commit_hash: string;
|
|
488
|
+
/** When the commit was created. */
|
|
489
|
+
created_at: string;
|
|
490
|
+
};
|
|
491
|
+
}
|
|
438
492
|
export interface LangSmithSettings {
|
|
439
493
|
id: string;
|
|
440
494
|
display_name: string;
|
package/dist/singletons/otel.cjs
CHANGED
|
@@ -18,8 +18,9 @@ class MockTracer {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
startActiveSpan(_name, ...args) {
|
|
21
|
-
if (!this.hasWarned && (0, env_js_1.
|
|
22
|
-
console.warn("
|
|
21
|
+
if (!this.hasWarned && (0, env_js_1.resolveTracingMode)() === "otel") {
|
|
22
|
+
console.warn("OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or " +
|
|
23
|
+
"LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. " +
|
|
23
24
|
'Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.');
|
|
24
25
|
this.hasWarned = true;
|
|
25
26
|
}
|
package/dist/singletons/otel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Should not import any OTEL packages to avoid pulling in optional deps.
|
|
2
|
-
import {
|
|
2
|
+
import { resolveTracingMode } from "../utils/env.js";
|
|
3
3
|
class MockTracer {
|
|
4
4
|
constructor() {
|
|
5
5
|
Object.defineProperty(this, "hasWarned", {
|
|
@@ -10,8 +10,9 @@ class MockTracer {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
startActiveSpan(_name, ...args) {
|
|
13
|
-
if (!this.hasWarned &&
|
|
14
|
-
console.warn("
|
|
13
|
+
if (!this.hasWarned && resolveTracingMode() === "otel") {
|
|
14
|
+
console.warn("OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or " +
|
|
15
|
+
"LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. " +
|
|
15
16
|
'Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.');
|
|
16
17
|
this.hasWarned = true;
|
|
17
18
|
}
|
package/dist/traceable.cjs
CHANGED
|
@@ -8,7 +8,6 @@ const env_js_1 = require("./env.cjs");
|
|
|
8
8
|
const traceable_js_1 = require("./singletons/traceable.cjs");
|
|
9
9
|
const constants_js_1 = require("./singletons/constants.cjs");
|
|
10
10
|
const asserts_js_1 = require("./utils/asserts.cjs");
|
|
11
|
-
const env_js_2 = require("./utils/env.cjs");
|
|
12
11
|
const index_js_1 = require("./index.cjs");
|
|
13
12
|
const otel_js_1 = require("./singletons/otel.cjs");
|
|
14
13
|
const utils_js_1 = require("./experimental/otel/utils.cjs");
|
|
@@ -20,7 +19,7 @@ traceable_js_1.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new n
|
|
|
20
19
|
function maybeCreateOtelContext(runTree, projectName, tracer
|
|
21
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
21
|
) {
|
|
23
|
-
if (!runTree ||
|
|
22
|
+
if (!runTree || runTree.client.tracingMode !== "otel") {
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
const otel_trace = (0, otel_js_1.getOTELTrace)();
|
package/dist/traceable.js
CHANGED
|
@@ -4,7 +4,6 @@ import { isTracingEnabled } from "./env.js";
|
|
|
4
4
|
import { ROOT, AsyncLocalStorageProviderSingleton, getCurrentRunTree, } from "./singletons/traceable.js";
|
|
5
5
|
import { _LC_CHILD_RUN_END_PROMISES_KEY, _LC_CONTEXT_VARIABLES_KEY, } from "./singletons/constants.js";
|
|
6
6
|
import { isKVMap, isReadableStream, isAsyncIterable, isIteratorLike, isThenable, isGenerator, isPromiseMethod, } from "./utils/asserts.js";
|
|
7
|
-
import { getOtelEnabled } from "./utils/env.js";
|
|
8
7
|
import { __version__ } from "./index.js";
|
|
9
8
|
import { getOTELTrace, getOTELContext } from "./singletons/otel.js";
|
|
10
9
|
import { getUuidFromOtelSpanId } from "./experimental/otel/utils.js";
|
|
@@ -16,7 +15,7 @@ AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorag
|
|
|
16
15
|
function maybeCreateOtelContext(runTree, projectName, tracer
|
|
17
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
17
|
) {
|
|
19
|
-
if (!runTree ||
|
|
18
|
+
if (!runTree || runTree.client.tracingMode !== "otel") {
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
22
21
|
const otel_trace = getOTELTrace();
|
package/dist/utils/_uuid.cjs
CHANGED
|
@@ -7,7 +7,7 @@ exports.warnIfNotUuidV7 = warnIfNotUuidV7;
|
|
|
7
7
|
exports.nonCryptographicUuid7Deterministic = nonCryptographicUuid7Deterministic;
|
|
8
8
|
// Relaxed UUID validation regex (allows any valid UUID format including nil UUIDs)
|
|
9
9
|
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10
|
-
const
|
|
10
|
+
const index_js_1 = require("./uuid/src/index.cjs");
|
|
11
11
|
const warn_js_1 = require("./warn.cjs");
|
|
12
12
|
const xxhash_js_1 = require("./xxhash/xxhash.cjs");
|
|
13
13
|
let UUID7_WARNING_EMITTED = false;
|
|
@@ -34,7 +34,7 @@ function uuid7FromTime(timestamp) {
|
|
|
34
34
|
// may not set the internal timestamp used for stringification.
|
|
35
35
|
// Providing a seq ensures the implementation updates its internal state
|
|
36
36
|
// and encodes the provided milliseconds into the UUID bytes.
|
|
37
|
-
return (0,
|
|
37
|
+
return (0, index_js_1.v7)({ msecs, seq: 0 });
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Get the version of a UUID string.
|
package/dist/utils/_uuid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Relaxed UUID validation regex (allows any valid UUID format including nil UUIDs)
|
|
2
2
|
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3
|
-
import { v7 as uuidv7 } from "uuid";
|
|
3
|
+
import { v7 as uuidv7 } from "./uuid/src/index.js";
|
|
4
4
|
import { warnOnce } from "./warn.js";
|
|
5
5
|
import { XXH3_128, xxh128ToBytes } from "./xxhash/xxhash.js";
|
|
6
6
|
let UUID7_WARNING_EMITTED = false;
|
package/dist/utils/env.cjs
CHANGED
|
@@ -9,6 +9,7 @@ exports.getLangSmithEnvironmentVariable = getLangSmithEnvironmentVariable;
|
|
|
9
9
|
exports.setEnvironmentVariable = setEnvironmentVariable;
|
|
10
10
|
exports.getShas = getShas;
|
|
11
11
|
exports.getOtelEnabled = getOtelEnabled;
|
|
12
|
+
exports.resolveTracingMode = resolveTracingMode;
|
|
12
13
|
// Inlined from https://github.com/flexdinesh/browser-or-node
|
|
13
14
|
const index_js_1 = require("../index.cjs");
|
|
14
15
|
let globalEnv;
|
|
@@ -218,3 +219,35 @@ function getOtelEnabled() {
|
|
|
218
219
|
return (getEnvironmentVariable("OTEL_ENABLED") === "true" ||
|
|
219
220
|
getLangSmithEnvironmentVariable("OTEL_ENABLED") === "true");
|
|
220
221
|
}
|
|
222
|
+
const _VALID_TRACING_MODES = new Set(["langsmith", "otel"]);
|
|
223
|
+
/**
|
|
224
|
+
* Resolve the effective tracing mode from an explicit config value and
|
|
225
|
+
* environment variables.
|
|
226
|
+
*
|
|
227
|
+
* Priority: explicit argument > `LANGSMITH_TRACING_MODE` env var >
|
|
228
|
+
* legacy `OTEL_ENABLED` / `LANGSMITH_OTEL_ENABLED` env vars > `"langsmith"`.
|
|
229
|
+
*/
|
|
230
|
+
function resolveTracingMode(configValue) {
|
|
231
|
+
if (configValue !== undefined) {
|
|
232
|
+
return configValue;
|
|
233
|
+
}
|
|
234
|
+
const envMode = getLangSmithEnvironmentVariable("TRACING_MODE");
|
|
235
|
+
if (envMode !== undefined && envMode !== "") {
|
|
236
|
+
const lower = envMode.toLowerCase();
|
|
237
|
+
if (!_VALID_TRACING_MODES.has(lower)) {
|
|
238
|
+
throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(envMode)}. ` +
|
|
239
|
+
`Must be one of: ${[..._VALID_TRACING_MODES].sort().join(", ")}`);
|
|
240
|
+
}
|
|
241
|
+
if (getOtelEnabled()) {
|
|
242
|
+
console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / " +
|
|
243
|
+
"LANGSMITH_OTEL_ENABLED env vars are set. " +
|
|
244
|
+
"LANGSMITH_TRACING_MODE takes precedence.");
|
|
245
|
+
}
|
|
246
|
+
return lower;
|
|
247
|
+
}
|
|
248
|
+
// Fall back to legacy env var
|
|
249
|
+
if (getOtelEnabled()) {
|
|
250
|
+
return "otel";
|
|
251
|
+
}
|
|
252
|
+
return "langsmith";
|
|
253
|
+
}
|
package/dist/utils/env.d.ts
CHANGED
|
@@ -48,4 +48,13 @@ interface ICommitSHAs {
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function getShas(): ICommitSHAs;
|
|
50
50
|
export declare function getOtelEnabled(): boolean;
|
|
51
|
+
export type TracingMode = "langsmith" | "otel";
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the effective tracing mode from an explicit config value and
|
|
54
|
+
* environment variables.
|
|
55
|
+
*
|
|
56
|
+
* Priority: explicit argument > `LANGSMITH_TRACING_MODE` env var >
|
|
57
|
+
* legacy `OTEL_ENABLED` / `LANGSMITH_OTEL_ENABLED` env vars > `"langsmith"`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveTracingMode(configValue?: TracingMode): TracingMode;
|
|
51
60
|
export {};
|
package/dist/utils/env.js
CHANGED
|
@@ -201,3 +201,35 @@ export function getOtelEnabled() {
|
|
|
201
201
|
return (getEnvironmentVariable("OTEL_ENABLED") === "true" ||
|
|
202
202
|
getLangSmithEnvironmentVariable("OTEL_ENABLED") === "true");
|
|
203
203
|
}
|
|
204
|
+
const _VALID_TRACING_MODES = new Set(["langsmith", "otel"]);
|
|
205
|
+
/**
|
|
206
|
+
* Resolve the effective tracing mode from an explicit config value and
|
|
207
|
+
* environment variables.
|
|
208
|
+
*
|
|
209
|
+
* Priority: explicit argument > `LANGSMITH_TRACING_MODE` env var >
|
|
210
|
+
* legacy `OTEL_ENABLED` / `LANGSMITH_OTEL_ENABLED` env vars > `"langsmith"`.
|
|
211
|
+
*/
|
|
212
|
+
export function resolveTracingMode(configValue) {
|
|
213
|
+
if (configValue !== undefined) {
|
|
214
|
+
return configValue;
|
|
215
|
+
}
|
|
216
|
+
const envMode = getLangSmithEnvironmentVariable("TRACING_MODE");
|
|
217
|
+
if (envMode !== undefined && envMode !== "") {
|
|
218
|
+
const lower = envMode.toLowerCase();
|
|
219
|
+
if (!_VALID_TRACING_MODES.has(lower)) {
|
|
220
|
+
throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(envMode)}. ` +
|
|
221
|
+
`Must be one of: ${[..._VALID_TRACING_MODES].sort().join(", ")}`);
|
|
222
|
+
}
|
|
223
|
+
if (getOtelEnabled()) {
|
|
224
|
+
console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / " +
|
|
225
|
+
"LANGSMITH_OTEL_ENABLED env vars are set. " +
|
|
226
|
+
"LANGSMITH_TRACING_MODE takes precedence.");
|
|
227
|
+
}
|
|
228
|
+
return lower;
|
|
229
|
+
}
|
|
230
|
+
// Fall back to legacy env var
|
|
231
|
+
if (getOtelEnabled()) {
|
|
232
|
+
return "otel";
|
|
233
|
+
}
|
|
234
|
+
return "langsmith";
|
|
235
|
+
}
|
package/dist/utils/error.cjs
CHANGED
|
@@ -4,6 +4,7 @@ exports.ConflictingEndpointsError = exports.LangSmithNotFoundError = exports.Lan
|
|
|
4
4
|
exports.getInvalidPromptIdentifierMsg = getInvalidPromptIdentifierMsg;
|
|
5
5
|
exports.printErrorStackTrace = printErrorStackTrace;
|
|
6
6
|
exports.isLangSmithNotFoundError = isLangSmithNotFoundError;
|
|
7
|
+
exports.isLangSmithConflictError = isLangSmithConflictError;
|
|
7
8
|
exports.raiseForStatus = raiseForStatus;
|
|
8
9
|
exports.isConflictingEndpointsError = isConflictingEndpointsError;
|
|
9
10
|
/**
|
|
@@ -115,6 +116,12 @@ function isLangSmithNotFoundError(error) {
|
|
|
115
116
|
"name" in error &&
|
|
116
117
|
error?.name === "LangSmithNotFoundError");
|
|
117
118
|
}
|
|
119
|
+
function isLangSmithConflictError(error) {
|
|
120
|
+
return (error != null &&
|
|
121
|
+
typeof error === "object" &&
|
|
122
|
+
"name" in error &&
|
|
123
|
+
error?.name === "LangSmithConflictError");
|
|
124
|
+
}
|
|
118
125
|
/**
|
|
119
126
|
* Throws an appropriate error based on the response status and body.
|
|
120
127
|
*
|
package/dist/utils/error.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export declare class LangSmithNotFoundError extends Error {
|
|
|
55
55
|
constructor(message: string);
|
|
56
56
|
}
|
|
57
57
|
export declare function isLangSmithNotFoundError(error: unknown): error is LangSmithNotFoundError;
|
|
58
|
+
export declare function isLangSmithConflictError(error: unknown): error is LangSmithConflictError;
|
|
58
59
|
/**
|
|
59
60
|
* Throws an appropriate error based on the response status and body.
|
|
60
61
|
*
|
package/dist/utils/error.js
CHANGED
|
@@ -105,6 +105,12 @@ export function isLangSmithNotFoundError(error) {
|
|
|
105
105
|
"name" in error &&
|
|
106
106
|
error?.name === "LangSmithNotFoundError");
|
|
107
107
|
}
|
|
108
|
+
export function isLangSmithConflictError(error) {
|
|
109
|
+
return (error != null &&
|
|
110
|
+
typeof error === "object" &&
|
|
111
|
+
"name" in error &&
|
|
112
|
+
error?.name === "LangSmithConflictError");
|
|
113
|
+
}
|
|
108
114
|
/**
|
|
109
115
|
* Throws an appropriate error based on the response status and body.
|
|
110
116
|
*
|