langsmith 0.8.12 → 0.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/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/run_trees.cjs +19 -2
- package/dist/run_trees.d.ts +12 -0
- package/dist/run_trees.js +19 -2
- package/dist/utils/env.cjs +18 -7
- package/dist/utils/env.js +18 -7
- package/dist/wrappers/openai_agents.cjs +2 -1
- package/dist/wrappers/openai_agents.js +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,6 @@ Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, g
|
|
|
35
35
|
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return error_js_1.RateLimitError; } });
|
|
36
36
|
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_js_1.InternalServerError; } });
|
|
37
37
|
// Update using pnpm bump-version
|
|
38
|
-
exports.__version__ = "0.
|
|
38
|
+
exports.__version__ = "0.9.0";
|
|
39
39
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
40
40
|
exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { computeRunIdForSecondaryReplica, uuid7, uuid7FromTime, } from "./uuid.j
|
|
|
7
7
|
export { isTracingEnabled } from "./utils/guard.js";
|
|
8
8
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
9
9
|
export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
|
|
10
|
-
export declare const __version__ = "0.
|
|
10
|
+
export declare const __version__ = "0.9.0";
|
|
11
11
|
export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,6 @@ export { isTracingEnabled } from "./utils/guard.js";
|
|
|
7
7
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
8
|
export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
|
|
9
9
|
// Update using pnpm bump-version
|
|
10
|
-
export const __version__ = "0.
|
|
10
|
+
export const __version__ = "0.9.0";
|
|
11
11
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
12
12
|
export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/run_trees.cjs
CHANGED
|
@@ -140,6 +140,10 @@ class Baggage {
|
|
|
140
140
|
return items.join(",");
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
+
function getExcludeInputsOnPatch() {
|
|
144
|
+
const value = (0, env_js_3.getLangSmithEnvironmentVariable)("EXCLUDE_INPUTS_ON_PATCH");
|
|
145
|
+
return value === undefined || value.toLowerCase() === "true" || value === "1";
|
|
146
|
+
}
|
|
143
147
|
class RunTree {
|
|
144
148
|
constructor(originalConfig) {
|
|
145
149
|
Object.defineProperty(this, "id", {
|
|
@@ -737,7 +741,20 @@ class RunTree {
|
|
|
737
741
|
console.error(`Error in postRun for run ${this.id}:`, error);
|
|
738
742
|
}
|
|
739
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Patch the run tree to the API.
|
|
746
|
+
*
|
|
747
|
+
* @param options.excludeInputs - Whether to exclude inputs from the patch
|
|
748
|
+
* request. Defaults to the value of `LANGSMITH_EXCLUDE_INPUTS_ON_PATCH`
|
|
749
|
+
* (or its `LANGCHAIN_` equivalent), which itself defaults to `true`.
|
|
750
|
+
* An explicit value overrides the environment variable for this call.
|
|
751
|
+
*
|
|
752
|
+
* Unless the environment variable is disabled, inputs added after the
|
|
753
|
+
* initial `postRun()` are not persisted unless this option is explicitly set
|
|
754
|
+
* to `false`.
|
|
755
|
+
*/
|
|
740
756
|
async patchRun(options) {
|
|
757
|
+
const excludeInputs = options?.excludeInputs ?? getExcludeInputsOnPatch();
|
|
741
758
|
if (this.replicas && this.replicas.length > 0) {
|
|
742
759
|
for (const { projectName, primary, apiKey, apiUrl, workspaceId, updates, reroot, client: replicaClient, } of this.replicas) {
|
|
743
760
|
const runData = this._remapForProject({
|
|
@@ -773,7 +790,7 @@ class RunTree {
|
|
|
773
790
|
// Important that inputs is not a key in the run update
|
|
774
791
|
// if excluded because it will overwrite the run create if the
|
|
775
792
|
// two operations are merged during batching
|
|
776
|
-
if (!
|
|
793
|
+
if (!excludeInputs) {
|
|
777
794
|
updatePayload.inputs = runData.inputs;
|
|
778
795
|
}
|
|
779
796
|
const targetClient = replicaClient ?? this.client;
|
|
@@ -806,7 +823,7 @@ class RunTree {
|
|
|
806
823
|
// Important that inputs is not a key in the run update
|
|
807
824
|
// if excluded because it will overwrite the run create if the
|
|
808
825
|
// two operations are merged during batching
|
|
809
|
-
if (!
|
|
826
|
+
if (!excludeInputs) {
|
|
810
827
|
runUpdate.inputs = this.inputs;
|
|
811
828
|
}
|
|
812
829
|
await this.client.updateRun(this.id, runUpdate);
|
package/dist/run_trees.d.ts
CHANGED
|
@@ -125,6 +125,18 @@ export declare class RunTree implements BaseRun {
|
|
|
125
125
|
private _setReplicaTraceRoot;
|
|
126
126
|
private _remapForProject;
|
|
127
127
|
postRun(excludeChildRuns?: boolean): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Patch the run tree to the API.
|
|
130
|
+
*
|
|
131
|
+
* @param options.excludeInputs - Whether to exclude inputs from the patch
|
|
132
|
+
* request. Defaults to the value of `LANGSMITH_EXCLUDE_INPUTS_ON_PATCH`
|
|
133
|
+
* (or its `LANGCHAIN_` equivalent), which itself defaults to `true`.
|
|
134
|
+
* An explicit value overrides the environment variable for this call.
|
|
135
|
+
*
|
|
136
|
+
* Unless the environment variable is disabled, inputs added after the
|
|
137
|
+
* initial `postRun()` are not persisted unless this option is explicitly set
|
|
138
|
+
* to `false`.
|
|
139
|
+
*/
|
|
128
140
|
patchRun(options?: {
|
|
129
141
|
excludeInputs?: boolean;
|
|
130
142
|
}): Promise<void>;
|
package/dist/run_trees.js
CHANGED
|
@@ -134,6 +134,10 @@ class Baggage {
|
|
|
134
134
|
return items.join(",");
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
+
function getExcludeInputsOnPatch() {
|
|
138
|
+
const value = getLangSmithEnvironmentVariable("EXCLUDE_INPUTS_ON_PATCH");
|
|
139
|
+
return value === undefined || value.toLowerCase() === "true" || value === "1";
|
|
140
|
+
}
|
|
137
141
|
export class RunTree {
|
|
138
142
|
constructor(originalConfig) {
|
|
139
143
|
Object.defineProperty(this, "id", {
|
|
@@ -731,7 +735,20 @@ export class RunTree {
|
|
|
731
735
|
console.error(`Error in postRun for run ${this.id}:`, error);
|
|
732
736
|
}
|
|
733
737
|
}
|
|
738
|
+
/**
|
|
739
|
+
* Patch the run tree to the API.
|
|
740
|
+
*
|
|
741
|
+
* @param options.excludeInputs - Whether to exclude inputs from the patch
|
|
742
|
+
* request. Defaults to the value of `LANGSMITH_EXCLUDE_INPUTS_ON_PATCH`
|
|
743
|
+
* (or its `LANGCHAIN_` equivalent), which itself defaults to `true`.
|
|
744
|
+
* An explicit value overrides the environment variable for this call.
|
|
745
|
+
*
|
|
746
|
+
* Unless the environment variable is disabled, inputs added after the
|
|
747
|
+
* initial `postRun()` are not persisted unless this option is explicitly set
|
|
748
|
+
* to `false`.
|
|
749
|
+
*/
|
|
734
750
|
async patchRun(options) {
|
|
751
|
+
const excludeInputs = options?.excludeInputs ?? getExcludeInputsOnPatch();
|
|
735
752
|
if (this.replicas && this.replicas.length > 0) {
|
|
736
753
|
for (const { projectName, primary, apiKey, apiUrl, workspaceId, updates, reroot, client: replicaClient, } of this.replicas) {
|
|
737
754
|
const runData = this._remapForProject({
|
|
@@ -767,7 +784,7 @@ export class RunTree {
|
|
|
767
784
|
// Important that inputs is not a key in the run update
|
|
768
785
|
// if excluded because it will overwrite the run create if the
|
|
769
786
|
// two operations are merged during batching
|
|
770
|
-
if (!
|
|
787
|
+
if (!excludeInputs) {
|
|
771
788
|
updatePayload.inputs = runData.inputs;
|
|
772
789
|
}
|
|
773
790
|
const targetClient = replicaClient ?? this.client;
|
|
@@ -800,7 +817,7 @@ export class RunTree {
|
|
|
800
817
|
// Important that inputs is not a key in the run update
|
|
801
818
|
// if excluded because it will overwrite the run create if the
|
|
802
819
|
// two operations are merged during batching
|
|
803
|
-
if (!
|
|
820
|
+
if (!excludeInputs) {
|
|
804
821
|
runUpdate.inputs = this.inputs;
|
|
805
822
|
}
|
|
806
823
|
await this.client.updateRun(this.id, runUpdate);
|
package/dist/utils/env.cjs
CHANGED
|
@@ -76,6 +76,22 @@ function getRuntimeEnvironment() {
|
|
|
76
76
|
}
|
|
77
77
|
return runtimeEnvironment;
|
|
78
78
|
}
|
|
79
|
+
// Substrings marking a variable as secret-bearing or personal; matched
|
|
80
|
+
// case-insensitively against the variable name.
|
|
81
|
+
const EXCLUDED_SUBSTRINGS = [
|
|
82
|
+
"key",
|
|
83
|
+
"secret",
|
|
84
|
+
"token",
|
|
85
|
+
"password",
|
|
86
|
+
"passwd",
|
|
87
|
+
"pwd",
|
|
88
|
+
"credential",
|
|
89
|
+
"email",
|
|
90
|
+
];
|
|
91
|
+
function isSensitiveEnvVarName(key) {
|
|
92
|
+
const lowered = key.toLowerCase();
|
|
93
|
+
return EXCLUDED_SUBSTRINGS.some((sub) => lowered.includes(sub));
|
|
94
|
+
}
|
|
79
95
|
/**
|
|
80
96
|
* Retrieves the LangSmith-specific metadata from the current runtime environment.
|
|
81
97
|
*
|
|
@@ -101,9 +117,7 @@ function getLangSmithEnvVarsMetadata() {
|
|
|
101
117
|
for (const [key, value] of Object.entries(allEnvVars)) {
|
|
102
118
|
if (typeof value === "string" &&
|
|
103
119
|
!excluded.includes(key) &&
|
|
104
|
-
!
|
|
105
|
-
!key.toLowerCase().includes("secret") &&
|
|
106
|
-
!key.toLowerCase().includes("token")) {
|
|
120
|
+
!isSensitiveEnvVarName(key)) {
|
|
107
121
|
if (key === "LANGCHAIN_REVISION_ID") {
|
|
108
122
|
envVars["revision_id"] = value;
|
|
109
123
|
}
|
|
@@ -131,10 +145,7 @@ function getLangSmithEnvironmentVariables() {
|
|
|
131
145
|
for (const [key, value] of Object.entries(process.env)) {
|
|
132
146
|
if ((key.startsWith("LANGCHAIN_") || key.startsWith("LANGSMITH_")) &&
|
|
133
147
|
value != null) {
|
|
134
|
-
if ((key
|
|
135
|
-
key.toLowerCase().includes("secret") ||
|
|
136
|
-
key.toLowerCase().includes("token")) &&
|
|
137
|
-
typeof value === "string") {
|
|
148
|
+
if (isSensitiveEnvVarName(key) && typeof value === "string") {
|
|
138
149
|
envVars[key] =
|
|
139
150
|
value.slice(0, 2) +
|
|
140
151
|
"*".repeat(value.length - 4) +
|
package/dist/utils/env.js
CHANGED
|
@@ -58,6 +58,22 @@ export function getRuntimeEnvironment() {
|
|
|
58
58
|
}
|
|
59
59
|
return runtimeEnvironment;
|
|
60
60
|
}
|
|
61
|
+
// Substrings marking a variable as secret-bearing or personal; matched
|
|
62
|
+
// case-insensitively against the variable name.
|
|
63
|
+
const EXCLUDED_SUBSTRINGS = [
|
|
64
|
+
"key",
|
|
65
|
+
"secret",
|
|
66
|
+
"token",
|
|
67
|
+
"password",
|
|
68
|
+
"passwd",
|
|
69
|
+
"pwd",
|
|
70
|
+
"credential",
|
|
71
|
+
"email",
|
|
72
|
+
];
|
|
73
|
+
function isSensitiveEnvVarName(key) {
|
|
74
|
+
const lowered = key.toLowerCase();
|
|
75
|
+
return EXCLUDED_SUBSTRINGS.some((sub) => lowered.includes(sub));
|
|
76
|
+
}
|
|
61
77
|
/**
|
|
62
78
|
* Retrieves the LangSmith-specific metadata from the current runtime environment.
|
|
63
79
|
*
|
|
@@ -83,9 +99,7 @@ export function getLangSmithEnvVarsMetadata() {
|
|
|
83
99
|
for (const [key, value] of Object.entries(allEnvVars)) {
|
|
84
100
|
if (typeof value === "string" &&
|
|
85
101
|
!excluded.includes(key) &&
|
|
86
|
-
!
|
|
87
|
-
!key.toLowerCase().includes("secret") &&
|
|
88
|
-
!key.toLowerCase().includes("token")) {
|
|
102
|
+
!isSensitiveEnvVarName(key)) {
|
|
89
103
|
if (key === "LANGCHAIN_REVISION_ID") {
|
|
90
104
|
envVars["revision_id"] = value;
|
|
91
105
|
}
|
|
@@ -113,10 +127,7 @@ export function getLangSmithEnvironmentVariables() {
|
|
|
113
127
|
for (const [key, value] of Object.entries(process.env)) {
|
|
114
128
|
if ((key.startsWith("LANGCHAIN_") || key.startsWith("LANGSMITH_")) &&
|
|
115
129
|
value != null) {
|
|
116
|
-
if ((key
|
|
117
|
-
key.toLowerCase().includes("secret") ||
|
|
118
|
-
key.toLowerCase().includes("token")) &&
|
|
119
|
-
typeof value === "string") {
|
|
130
|
+
if (isSensitiveEnvVarName(key) && typeof value === "string") {
|
|
120
131
|
envVars[key] =
|
|
121
132
|
value.slice(0, 2) +
|
|
122
133
|
"*".repeat(value.length - 4) +
|
|
@@ -717,6 +717,7 @@ class OpenAIAgentsTracingProcessor {
|
|
|
717
717
|
// available at start.
|
|
718
718
|
if (spanData.type === "generation" ||
|
|
719
719
|
spanData.type === "response" ||
|
|
720
|
+
spanData.type === "agent" ||
|
|
720
721
|
spanData.type === "function" ||
|
|
721
722
|
spanData.type === "handoff") {
|
|
722
723
|
this._unpostedSpans.add(span.spanId);
|
|
@@ -818,7 +819,7 @@ class OpenAIAgentsTracingProcessor {
|
|
|
818
819
|
await run.postRun();
|
|
819
820
|
}
|
|
820
821
|
else {
|
|
821
|
-
await run.patchRun(
|
|
822
|
+
await run.patchRun({ excludeInputs: true });
|
|
822
823
|
}
|
|
823
824
|
}
|
|
824
825
|
catch (e) {
|
|
@@ -714,6 +714,7 @@ export class OpenAIAgentsTracingProcessor {
|
|
|
714
714
|
// available at start.
|
|
715
715
|
if (spanData.type === "generation" ||
|
|
716
716
|
spanData.type === "response" ||
|
|
717
|
+
spanData.type === "agent" ||
|
|
717
718
|
spanData.type === "function" ||
|
|
718
719
|
spanData.type === "handoff") {
|
|
719
720
|
this._unpostedSpans.add(span.spanId);
|
|
@@ -815,7 +816,7 @@ export class OpenAIAgentsTracingProcessor {
|
|
|
815
816
|
await run.postRun();
|
|
816
817
|
}
|
|
817
818
|
else {
|
|
818
|
-
await run.patchRun(
|
|
819
|
+
await run.patchRun({ excludeInputs: true });
|
|
819
820
|
}
|
|
820
821
|
}
|
|
821
822
|
catch (e) {
|