langsmith 0.5.19 → 0.6.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/client.cjs +460 -22
- package/dist/client.d.ts +165 -1
- package/dist/client.js +464 -26
- 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/experimental/anthropic/context.cjs +419 -49
- package/dist/experimental/anthropic/context.js +420 -50
- package/dist/experimental/anthropic/index.cjs +78 -10
- package/dist/experimental/anthropic/index.js +80 -12
- package/dist/experimental/anthropic/messages.cjs +53 -0
- package/dist/experimental/anthropic/messages.d.ts +6 -0
- package/dist/experimental/anthropic/messages.js +52 -0
- package/dist/experimental/anthropic/transcripts.cjs +144 -0
- package/dist/experimental/anthropic/transcripts.d.ts +22 -0
- package/dist/experimental/anthropic/transcripts.js +141 -0
- package/dist/experimental/anthropic/types.d.ts +1 -0
- package/dist/experimental/anthropic/usage.cjs +19 -20
- package/dist/experimental/anthropic/usage.d.ts +2 -1
- package/dist/experimental/anthropic/usage.js +18 -20
- package/dist/experimental/opencode/index.cjs +36 -0
- package/dist/experimental/opencode/index.d.ts +3 -0
- package/dist/experimental/opencode/index.js +32 -0
- package/dist/experimental/opencode/tracer.cjs +389 -0
- package/dist/experimental/opencode/tracer.d.ts +30 -0
- package/dist/experimental/opencode/tracer.js +385 -0
- package/dist/experimental/otel/setup.cjs +1 -1
- package/dist/experimental/otel/setup.js +1 -1
- package/dist/experimental/sandbox/client.cjs +308 -409
- package/dist/experimental/sandbox/client.d.ts +136 -157
- package/dist/experimental/sandbox/client.js +310 -411
- package/dist/experimental/sandbox/errors.cjs +1 -2
- package/dist/experimental/sandbox/errors.d.ts +1 -2
- package/dist/experimental/sandbox/errors.js +1 -2
- package/dist/experimental/sandbox/helpers.cjs +8 -98
- package/dist/experimental/sandbox/helpers.d.ts +0 -29
- package/dist/experimental/sandbox/helpers.js +9 -95
- package/dist/experimental/sandbox/index.cjs +6 -1
- package/dist/experimental/sandbox/index.d.ts +7 -2
- package/dist/experimental/sandbox/index.js +6 -1
- package/dist/experimental/sandbox/sandbox.cjs +71 -13
- package/dist/experimental/sandbox/sandbox.d.ts +39 -9
- package/dist/experimental/sandbox/sandbox.js +71 -13
- package/dist/experimental/sandbox/types.d.ts +147 -137
- package/dist/experimental/vercel/index.cjs +1 -1
- package/dist/experimental/vercel/index.js +1 -1
- package/dist/experimental/vercel/middleware.cjs +2 -1
- package/dist/experimental/vercel/middleware.js +2 -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 +58 -0
- package/dist/singletons/otel.cjs +3 -2
- package/dist/singletons/otel.js +4 -3
- package/dist/singletons/traceable.cjs +1 -3
- package/dist/singletons/traceable.js +1 -3
- package/dist/traceable.cjs +2 -5
- package/dist/traceable.js +2 -5
- package/dist/utils/_git.cjs +2 -2
- package/dist/utils/_git.js +2 -2
- package/dist/utils/_uuid.cjs +2 -2
- package/dist/utils/_uuid.js +1 -1
- package/dist/utils/env.cjs +35 -2
- package/dist/utils/env.d.ts +9 -0
- package/dist/utils/env.js +34 -2
- package/dist/utils/error.cjs +9 -2
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +8 -2
- 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/reporter.cjs +1 -1
- package/dist/utils/jestlike/reporter.js +1 -1
- package/dist/utils/jestlike/vendor/chain.cjs +2 -3
- package/dist/utils/jestlike/vendor/chain.js +2 -3
- 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 +388 -0
- package/dist/utils/serialize_worker.d.ts +66 -0
- package/dist/utils/serialize_worker.js +382 -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/dist/vitest/utils/esm.mjs +4 -4
- package/dist/wrappers/gemini.cjs +1 -1
- package/dist/wrappers/gemini.js +1 -1
- package/dist/wrappers/openai.cjs +2 -6
- package/dist/wrappers/openai.js +2 -6
- package/dist/wrappers/openai_agents.cjs +849 -0
- package/dist/wrappers/openai_agents.d.ts +92 -0
- package/dist/wrappers/openai_agents.js +845 -0
- package/experimental/opencode.cjs +1 -0
- package/experimental/opencode.d.cts +1 -0
- package/experimental/opencode.d.ts +1 -0
- package/experimental/opencode.js +1 -0
- package/package.json +47 -25
- package/wrappers/openai_agents.cjs +1 -0
- package/wrappers/openai_agents.d.cts +1 -0
- package/wrappers/openai_agents.d.ts +1 -0
- package/wrappers/openai_agents.js +1 -0
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
|
@@ -398,6 +398,10 @@ export interface PromptCommit {
|
|
|
398
398
|
manifest: Record<string, any>;
|
|
399
399
|
examples: Array<Record<any, any>>;
|
|
400
400
|
description?: string;
|
|
401
|
+
/** The model configuration for the prompt. */
|
|
402
|
+
hub_model_config?: Record<string, any>;
|
|
403
|
+
/** The model provider (e.g. ChatOpenAI) */
|
|
404
|
+
hub_model_provider?: string;
|
|
401
405
|
}
|
|
402
406
|
export interface Prompt {
|
|
403
407
|
repo_handle: string;
|
|
@@ -435,6 +439,60 @@ export type PromptSortField = "num_downloads" | "num_views" | "updated_at" | "nu
|
|
|
435
439
|
export interface LikePromptResponse {
|
|
436
440
|
likes: number;
|
|
437
441
|
}
|
|
442
|
+
export interface FileEntry {
|
|
443
|
+
type: "file";
|
|
444
|
+
content: string;
|
|
445
|
+
}
|
|
446
|
+
export interface AgentEntry {
|
|
447
|
+
type: "agent";
|
|
448
|
+
repo_handle: string;
|
|
449
|
+
commit_id?: string;
|
|
450
|
+
owner?: string;
|
|
451
|
+
commit_hash?: string;
|
|
452
|
+
}
|
|
453
|
+
export interface SkillEntry {
|
|
454
|
+
type: "skill";
|
|
455
|
+
repo_handle: string;
|
|
456
|
+
commit_id?: string;
|
|
457
|
+
owner?: string;
|
|
458
|
+
commit_hash?: string;
|
|
459
|
+
}
|
|
460
|
+
export type Entry = FileEntry | AgentEntry | SkillEntry;
|
|
461
|
+
/** The type of a non-prompt hub repo. */
|
|
462
|
+
export type HubRepoType = "agent" | "skill";
|
|
463
|
+
/**
|
|
464
|
+
* An agent pulled from hub.
|
|
465
|
+
*/
|
|
466
|
+
export interface AgentContext {
|
|
467
|
+
/** The commit ID. */
|
|
468
|
+
commit_id: string;
|
|
469
|
+
/** The commit hash. */
|
|
470
|
+
commit_hash: string;
|
|
471
|
+
/** The files in the agent. */
|
|
472
|
+
files: Record<string, Entry>;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* A skill pulled from hub.
|
|
476
|
+
*/
|
|
477
|
+
export interface SkillContext {
|
|
478
|
+
/** The commit ID. */
|
|
479
|
+
commit_id: string;
|
|
480
|
+
/** The commit hash. */
|
|
481
|
+
commit_hash: string;
|
|
482
|
+
/** The files in the skill. */
|
|
483
|
+
files: Record<string, Entry>;
|
|
484
|
+
}
|
|
485
|
+
/** Response body for `POST /directories/commits`. */
|
|
486
|
+
export interface DirectoryCommitResponse {
|
|
487
|
+
commit: {
|
|
488
|
+
/** The commit ID. */
|
|
489
|
+
id: string;
|
|
490
|
+
/** The commit hash. */
|
|
491
|
+
commit_hash: string;
|
|
492
|
+
/** When the commit was created. */
|
|
493
|
+
created_at: string;
|
|
494
|
+
};
|
|
495
|
+
}
|
|
438
496
|
export interface LangSmithSettings {
|
|
439
497
|
id: string;
|
|
440
498
|
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
|
}
|
|
@@ -43,8 +43,6 @@ function withRunTree(runTree, fn) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
exports.ROOT = Symbol.for("langsmith:traceable:root");
|
|
46
|
-
function isTraceableFunction(x
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
) {
|
|
46
|
+
function isTraceableFunction(x) {
|
|
49
47
|
return typeof x === "function" && "langsmith:traceable" in x;
|
|
50
48
|
}
|
|
@@ -37,8 +37,6 @@ export function withRunTree(runTree, fn) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
export const ROOT = Symbol.for("langsmith:traceable:root");
|
|
40
|
-
export function isTraceableFunction(x
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
) {
|
|
40
|
+
export function isTraceableFunction(x) {
|
|
43
41
|
return typeof x === "function" && "langsmith:traceable" in x;
|
|
44
42
|
}
|
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");
|
|
@@ -17,10 +16,8 @@ traceable_js_1.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new n
|
|
|
17
16
|
/**
|
|
18
17
|
* Create OpenTelemetry context manager from RunTree if OTEL is enabled.
|
|
19
18
|
*/
|
|
20
|
-
function maybeCreateOtelContext(runTree, projectName, tracer
|
|
21
|
-
|
|
22
|
-
) {
|
|
23
|
-
if (!runTree || !(0, env_js_2.getOtelEnabled)()) {
|
|
19
|
+
function maybeCreateOtelContext(runTree, projectName, tracer) {
|
|
20
|
+
if (!runTree || runTree.client.tracingMode !== "otel") {
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
23
|
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";
|
|
@@ -13,10 +12,8 @@ AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorag
|
|
|
13
12
|
/**
|
|
14
13
|
* Create OpenTelemetry context manager from RunTree if OTEL is enabled.
|
|
15
14
|
*/
|
|
16
|
-
function maybeCreateOtelContext(runTree, projectName, tracer
|
|
17
|
-
|
|
18
|
-
) {
|
|
19
|
-
if (!runTree || !getOtelEnabled()) {
|
|
15
|
+
function maybeCreateOtelContext(runTree, projectName, tracer) {
|
|
16
|
+
if (!runTree || runTree.client.tracingMode !== "otel") {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
19
|
const otel_trace = getOTELTrace();
|
package/dist/utils/_git.cjs
CHANGED
|
@@ -23,7 +23,7 @@ const getGitInfo = async (remote = "origin") => {
|
|
|
23
23
|
const execImport = await importChildProcess();
|
|
24
24
|
exec = execImport.exec;
|
|
25
25
|
}
|
|
26
|
-
catch (
|
|
26
|
+
catch (_e) {
|
|
27
27
|
// no-op
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
@@ -59,7 +59,7 @@ const getDefaultRevisionId = async () => {
|
|
|
59
59
|
const execImport = await importChildProcess();
|
|
60
60
|
exec = execImport.exec;
|
|
61
61
|
}
|
|
62
|
-
catch (
|
|
62
|
+
catch (_e) {
|
|
63
63
|
// no-op
|
|
64
64
|
return null;
|
|
65
65
|
}
|
package/dist/utils/_git.js
CHANGED
|
@@ -20,7 +20,7 @@ export const getGitInfo = async (remote = "origin") => {
|
|
|
20
20
|
const execImport = await importChildProcess();
|
|
21
21
|
exec = execImport.exec;
|
|
22
22
|
}
|
|
23
|
-
catch (
|
|
23
|
+
catch (_e) {
|
|
24
24
|
// no-op
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
@@ -55,7 +55,7 @@ export const getDefaultRevisionId = async () => {
|
|
|
55
55
|
const execImport = await importChildProcess();
|
|
56
56
|
exec = execImport.exec;
|
|
57
57
|
}
|
|
58
|
-
catch (
|
|
58
|
+
catch (_e) {
|
|
59
59
|
// no-op
|
|
60
60
|
return null;
|
|
61
61
|
}
|
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;
|
|
@@ -145,7 +146,7 @@ function getLangSmithEnvironmentVariables() {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
catch (
|
|
149
|
+
catch (_e) {
|
|
149
150
|
// Catch any errors that might occur while trying to access environment variables
|
|
150
151
|
}
|
|
151
152
|
return envVars;
|
|
@@ -159,7 +160,7 @@ function getEnvironmentVariable(name) {
|
|
|
159
160
|
process.env?.[name]
|
|
160
161
|
: undefined;
|
|
161
162
|
}
|
|
162
|
-
catch (
|
|
163
|
+
catch (_e) {
|
|
163
164
|
return undefined;
|
|
164
165
|
}
|
|
165
166
|
}
|
|
@@ -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
|
@@ -128,7 +128,7 @@ export function getLangSmithEnvironmentVariables() {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
catch (
|
|
131
|
+
catch (_e) {
|
|
132
132
|
// Catch any errors that might occur while trying to access environment variables
|
|
133
133
|
}
|
|
134
134
|
return envVars;
|
|
@@ -142,7 +142,7 @@ export function getEnvironmentVariable(name) {
|
|
|
142
142
|
process.env?.[name]
|
|
143
143
|
: undefined;
|
|
144
144
|
}
|
|
145
|
-
catch (
|
|
145
|
+
catch (_e) {
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -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
|
*
|
|
@@ -145,7 +152,7 @@ async function raiseForStatus(response, context, consumeOnSuccess) {
|
|
|
145
152
|
}
|
|
146
153
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
154
|
}
|
|
148
|
-
catch (
|
|
155
|
+
catch (_e) {
|
|
149
156
|
const errorWithStatus = new Error(`${response.status} ${response.statusText}`);
|
|
150
157
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
158
|
errorWithStatus.status = response?.status;
|
|
@@ -157,7 +164,7 @@ async function raiseForStatus(response, context, consumeOnSuccess) {
|
|
|
157
164
|
errorBody = await response.text();
|
|
158
165
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
166
|
}
|
|
160
|
-
catch (
|
|
167
|
+
catch (_e) {
|
|
161
168
|
errorBody = "";
|
|
162
169
|
}
|
|
163
170
|
}
|
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
|
*
|
|
@@ -135,7 +141,7 @@ export async function raiseForStatus(response, context, consumeOnSuccess) {
|
|
|
135
141
|
}
|
|
136
142
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
143
|
}
|
|
138
|
-
catch (
|
|
144
|
+
catch (_e) {
|
|
139
145
|
const errorWithStatus = new Error(`${response.status} ${response.statusText}`);
|
|
140
146
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
147
|
errorWithStatus.status = response?.status;
|
|
@@ -147,7 +153,7 @@ export async function raiseForStatus(response, context, consumeOnSuccess) {
|
|
|
147
153
|
errorBody = await response.text();
|
|
148
154
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
155
|
}
|
|
150
|
-
catch (
|
|
156
|
+
catch (_e) {
|
|
151
157
|
errorBody = "";
|
|
152
158
|
}
|
|
153
159
|
}
|