@temporalio/langsmith 1.24.0 → 2.0.0-rc.1
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/LICENSE +6 -6
- package/README.md +79 -6
- package/lib/activity-interceptor.js +38 -47
- package/lib/activity-interceptor.js.map +1 -1
- package/lib/client-interceptor.d.ts +4 -4
- package/lib/client-interceptor.js +28 -47
- package/lib/client-interceptor.js.map +1 -1
- package/lib/plugin.d.ts +7 -6
- package/lib/plugin.js +85 -9
- package/lib/plugin.js.map +1 -1
- package/lib/propagation.js +1 -1
- package/lib/routing.d.ts +14 -0
- package/lib/routing.js +101 -0
- package/lib/routing.js.map +1 -0
- package/lib/run-tree.d.ts +48 -13
- package/lib/run-tree.js +106 -166
- package/lib/run-tree.js.map +1 -1
- package/lib/sinks.d.ts +19 -4
- package/lib/sinks.js +33 -50
- package/lib/sinks.js.map +1 -1
- package/lib/worker-run-tree.d.ts +6 -0
- package/lib/worker-run-tree.js +43 -0
- package/lib/worker-run-tree.js.map +1 -0
- package/lib/workflow-interceptors.js +104 -151
- package/lib/workflow-interceptors.js.map +1 -1
- package/lib/workflow-run-tree.d.ts +7 -0
- package/lib/workflow-run-tree.js +112 -0
- package/lib/workflow-run-tree.js.map +1 -0
- package/package.json +37 -18
- package/src/activity-interceptor.ts +47 -51
- package/src/client-interceptor.ts +37 -59
- package/src/plugin.ts +99 -14
- package/src/propagation.ts +1 -1
- package/src/routing.ts +110 -0
- package/src/run-tree.ts +139 -185
- package/src/sinks.ts +46 -52
- package/src/worker-run-tree.ts +47 -0
- package/src/workflow-interceptors.ts +131 -217
- package/src/workflow-run-tree.ts +127 -0
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.interceptors = interceptors;
|
|
15
|
+
const run_trees_1 = require("langsmith/run_trees");
|
|
15
16
|
const traceable_1 = require("langsmith/singletons/traceable");
|
|
16
17
|
const workflow_1 = require("@temporalio/workflow");
|
|
17
18
|
const propagation_1 = require("./propagation");
|
|
18
19
|
const run_tree_1 = require("./run-tree");
|
|
20
|
+
const routing_1 = require("./routing");
|
|
21
|
+
const workflow_run_tree_1 = require("./workflow-run-tree");
|
|
19
22
|
function readConfig() {
|
|
20
23
|
try {
|
|
21
24
|
if (typeof __TEMPORAL_LANGSMITH_CONFIG__ === 'string') {
|
|
@@ -29,53 +32,61 @@ function readConfig() {
|
|
|
29
32
|
}
|
|
30
33
|
traceable_1.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new globalThis.AsyncLocalStorage());
|
|
31
34
|
const sharedStore = traceable_1.AsyncLocalStorageProviderSingleton.getInstance();
|
|
32
|
-
/** Reconstruct the propagated parent run from a Payload-keyed header map. */
|
|
33
|
-
function reconstructParent(headers) {
|
|
34
|
-
return (0, run_tree_1.runTreeFromContext)((0, propagation_1.readContextHeader)(headers));
|
|
35
|
-
}
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* Reconstruct the propagated parent run from a Payload-keyed header map. A header naming no destination takes
|
|
37
|
+
* `config.destination`, as LangSmith would take its env defaults outside the isolate. This plugin never propagates a
|
|
38
|
+
* run with no destination (see {@link runHeaders}), so such a header comes from an older release; if the Worker has
|
|
39
|
+
* no destination either, LangSmith fills in `"default"` for it here.
|
|
40
40
|
*/
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
function reconstructParent(headers, config, readOnly) {
|
|
42
|
+
const context = (0, propagation_1.readContextHeader)(headers);
|
|
43
|
+
return (0, workflow_run_tree_1.workflowRunTreeContext)(config, () => (0, run_tree_1.runTreeFromContext)(context, config.destination), readOnly);
|
|
44
|
+
}
|
|
45
|
+
/** The `RunTree.end` arguments for a Workflow run whose handler threw `err`; continue-as-new isn't an error. */
|
|
46
|
+
function workflowThrownEnd(err) {
|
|
47
|
+
if ((0, workflow_1.isCancellation)(err))
|
|
48
|
+
return [(0, run_tree_1.statusOutputs)('cancelled'), undefined];
|
|
49
|
+
return err instanceof workflow_1.ContinueAsNew ? [(0, run_tree_1.statusOutputs)('continued_as_new'), undefined] : (0, run_tree_1.thrownEnd)(err);
|
|
50
|
+
}
|
|
51
|
+
/** Keep the incoming parent ambient when a Temporal run has no destination. */
|
|
52
|
+
function bodyAmbient(run, parent) {
|
|
53
|
+
return (0, run_tree_1.isUntraced)(run) ? parent ?? run : run;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* Emit a short-lived marker run as a child of `parent`. With no destination in `config` the marker has none either,
|
|
57
|
+
* but it's built and awaited all the same: the isolate's awaits, and so the order of its commands, must not depend
|
|
58
|
+
* on the Worker's env, or a history recorded under one env fails to replay under another.
|
|
59
59
|
*/
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
async function emitMarker(config, parent, name) {
|
|
61
|
+
const marker = parent.createChild({
|
|
62
|
+
name,
|
|
63
|
+
run_type: run_tree_1.RUN_TYPE.CHAIN,
|
|
64
|
+
tags: config.tags,
|
|
65
|
+
extra: { metadata: { ...config.metadata } },
|
|
66
|
+
});
|
|
67
|
+
if (config.destination === undefined)
|
|
68
|
+
(0, run_tree_1.suppressRun)(marker);
|
|
69
|
+
if (!marker.tracingEnabled)
|
|
70
|
+
return;
|
|
71
|
+
await marker.postRun();
|
|
72
|
+
await marker.end((0, run_tree_1.statusOutputs)('ok'));
|
|
73
|
+
await marker.patchRun();
|
|
68
74
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
function buildWorkflowRunTree(config, name, parent) {
|
|
76
|
+
const { workflowId, runId } = (0, workflow_1.workflowInfo)();
|
|
77
|
+
const run = new run_trees_1.RunTree({
|
|
78
|
+
name,
|
|
79
|
+
run_type: run_tree_1.RUN_TYPE.CHAIN,
|
|
80
|
+
parent_run: parent,
|
|
81
|
+
parent_run_id: parent?.id,
|
|
82
|
+
...(0, routing_1.destination)(parent, config.destination),
|
|
83
|
+
replicas: parent?.replicas ?? config.replicas,
|
|
75
84
|
tags: config.tags,
|
|
76
|
-
extra: { metadata:
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
extra: { metadata: { ...config.metadata, temporalWorkflowID: workflowId, temporalRunID: runId } },
|
|
86
|
+
});
|
|
87
|
+
if (config.destination === undefined)
|
|
88
|
+
(0, run_tree_1.suppressRun)(run);
|
|
89
|
+
return run;
|
|
79
90
|
}
|
|
80
91
|
class LangSmithWorkflowInbound {
|
|
81
92
|
config;
|
|
@@ -83,101 +94,59 @@ class LangSmithWorkflowInbound {
|
|
|
83
94
|
this.config = config;
|
|
84
95
|
}
|
|
85
96
|
async execute(input, next) {
|
|
86
|
-
|
|
87
|
-
return this.runInbound((0, run_tree_1.runWorkflowRunName)((0, workflow_1.workflowInfo)().workflowType), run_tree_1.RUN_TYPE.CHAIN, parent, { args: input.args }, () => next(input));
|
|
97
|
+
return this.runInbound((0, run_tree_1.runWorkflowRunName)((0, workflow_1.workflowInfo)().workflowType), input.headers, () => next(input));
|
|
88
98
|
}
|
|
89
99
|
async handleSignal(input, next) {
|
|
90
|
-
|
|
91
|
-
await this.runInbound((0, run_tree_1.handleSignalRunName)(input.signalName), run_tree_1.RUN_TYPE.CHAIN, parent, { args: input.args }, () => next(input));
|
|
100
|
+
await this.runInbound((0, run_tree_1.handleSignalRunName)(input.signalName), input.headers, () => next(input));
|
|
92
101
|
}
|
|
93
102
|
async handleQuery(input, next) {
|
|
94
103
|
if ((0, propagation_1.isInternalQuery)(input.queryName)) {
|
|
95
104
|
return next(input);
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
return this.runInbound((0, run_tree_1.handleQueryRunName)(input.queryName), run_tree_1.RUN_TYPE.CHAIN, parent, { args: input.args }, () => next(input),
|
|
99
|
-
// Read-only: mint run ids from the nondeterministic unsafe random source so the
|
|
100
|
-
// handler never draws from the Workflow main PRNG (which a clean replay would not advance).
|
|
101
|
-
(0, workflow_1.workflowInfo)().unsafe.random.uuid4);
|
|
106
|
+
return this.runInbound((0, run_tree_1.handleQueryRunName)(input.queryName), input.headers, () => next(input), true);
|
|
102
107
|
}
|
|
103
108
|
async handleUpdate(input, next) {
|
|
104
|
-
|
|
105
|
-
return this.runInbound((0, run_tree_1.handleUpdateRunName)(input.name), run_tree_1.RUN_TYPE.CHAIN, parent, { args: input.args }, () => next(input));
|
|
109
|
+
return this.runInbound((0, run_tree_1.handleUpdateRunName)(input.name), input.headers, () => next(input));
|
|
106
110
|
}
|
|
107
111
|
validateUpdate(input, next) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// a `traceable` in the validator body nests under it.
|
|
130
|
-
void run.postRun();
|
|
131
|
-
try {
|
|
132
|
-
sharedStore.run(run, () => next(input));
|
|
133
|
-
void run.end({});
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
void run.end(undefined, (0, run_tree_1.describeError)(err));
|
|
137
|
-
void run.patchRun();
|
|
138
|
-
throw err;
|
|
139
|
-
}
|
|
140
|
-
void run.patchRun();
|
|
112
|
+
const parent = reconstructParent(input.headers, this.config, true);
|
|
113
|
+
(0, workflow_run_tree_1.workflowRunTreeContext)(this.config, () => {
|
|
114
|
+
if (!this.config.addTemporalRuns) {
|
|
115
|
+
sharedStore.run(parent, () => next(input));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const run = buildWorkflowRunTree(this.config, (0, run_tree_1.validateUpdateRunName)(input.name), parent);
|
|
119
|
+
void run.postRun();
|
|
120
|
+
let end = [(0, run_tree_1.statusOutputs)('ok'), undefined];
|
|
121
|
+
try {
|
|
122
|
+
sharedStore.run(bodyAmbient(run, parent), () => next(input));
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
end = workflowThrownEnd(err);
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
void run.end(...end);
|
|
130
|
+
void run.patchRun();
|
|
131
|
+
}
|
|
132
|
+
}, true);
|
|
141
133
|
}
|
|
142
134
|
/**
|
|
143
|
-
* Open the inbound run, install it as the active run for the whole `next`
|
|
135
|
+
* Open the inbound run, install it (see {@link bodyAmbient}) as the active run for the whole `next`
|
|
144
136
|
* async scope, and close it. The real ALS scopes the run to this branch, so a
|
|
145
137
|
* handler running concurrently with the workflow body never leaks its run into
|
|
146
138
|
* the body's context.
|
|
147
139
|
*/
|
|
148
|
-
async runInbound(name,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// `undefined` so a workflow-body `traceable` takes LangSmith's
|
|
154
|
-
// `createChild` branch (deterministic id) rather than the no-parent branch
|
|
155
|
-
// that mints a uuid via `crypto`, which the isolate lacks.
|
|
156
|
-
const ambient = asReplaySafeParent(parent, generateNewUuid4) ?? placeholderRoot(generateNewUuid4);
|
|
157
|
-
return sharedStore.run(ambient, next);
|
|
158
|
-
}
|
|
159
|
-
const run = buildReplaySafeRunTree(this.config, {
|
|
160
|
-
name,
|
|
161
|
-
runType,
|
|
162
|
-
parent: asReplaySafeParent(parent, generateNewUuid4),
|
|
163
|
-
inputs,
|
|
164
|
-
generateNewUuid4,
|
|
165
|
-
});
|
|
166
|
-
void run.postRun();
|
|
167
|
-
const body = async () => {
|
|
168
|
-
try {
|
|
169
|
-
const result = await next();
|
|
170
|
-
await run.end((0, run_tree_1.asOutputs)(result));
|
|
171
|
-
await run.patchRun();
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
catch (err) {
|
|
175
|
-
await run.end(undefined, (0, run_tree_1.describeError)(err));
|
|
176
|
-
await run.patchRun();
|
|
177
|
-
throw err;
|
|
140
|
+
async runInbound(name, headers, next, readOnly = false) {
|
|
141
|
+
const parent = reconstructParent(headers, this.config, readOnly);
|
|
142
|
+
return (0, workflow_run_tree_1.workflowRunTreeContext)(this.config, () => {
|
|
143
|
+
if (!this.config.addTemporalRuns) {
|
|
144
|
+
return sharedStore.run(parent, next);
|
|
178
145
|
}
|
|
179
|
-
|
|
180
|
-
|
|
146
|
+
const run = buildWorkflowRunTree(this.config, name, parent);
|
|
147
|
+
void run.postRun();
|
|
148
|
+
return sharedStore.run(bodyAmbient(run, parent), () => (0, run_tree_1.wrapWithRun)(run, next, workflowThrownEnd));
|
|
149
|
+
}, readOnly);
|
|
181
150
|
}
|
|
182
151
|
}
|
|
183
152
|
class LangSmithWorkflowOutbound {
|
|
@@ -186,56 +155,39 @@ class LangSmithWorkflowOutbound {
|
|
|
186
155
|
this.config = config;
|
|
187
156
|
}
|
|
188
157
|
async scheduleActivity(input, next) {
|
|
189
|
-
return this.
|
|
158
|
+
return this.withHeaders((0, run_tree_1.startActivityRunName)(input.activityType), input, next);
|
|
190
159
|
}
|
|
191
160
|
async scheduleLocalActivity(input, next) {
|
|
192
|
-
return this.
|
|
161
|
+
return this.withHeaders((0, run_tree_1.startActivityRunName)(input.activityType), input, next);
|
|
193
162
|
}
|
|
194
163
|
async startChildWorkflowExecution(input, next) {
|
|
195
|
-
return this.
|
|
164
|
+
return this.withHeaders((0, run_tree_1.startChildWorkflowRunName)(input.workflowType), input, next);
|
|
196
165
|
}
|
|
197
166
|
continueAsNew(input, next) {
|
|
198
|
-
|
|
199
|
-
// runs would dangle under a nonexistent parent. Let it install its own.
|
|
200
|
-
const ambient = sharedStore.getStore();
|
|
201
|
-
const context = ambient instanceof run_tree_1._RootReplaySafeRunTreeFactory ? undefined : (0, run_tree_1.runHeaders)(ambient);
|
|
202
|
-
const headers = (0, propagation_1.withContextHeader)(input.headers, context);
|
|
203
|
-
return next({ ...input, headers });
|
|
167
|
+
return next({ ...input, headers: (0, propagation_1.withContextHeader)(input.headers, (0, run_tree_1.runHeaders)(sharedStore.getStore())) });
|
|
204
168
|
}
|
|
205
169
|
async signalWorkflow(input, next) {
|
|
206
|
-
const
|
|
207
|
-
const name = isChild
|
|
170
|
+
const name = input.target.type === 'child'
|
|
208
171
|
? (0, run_tree_1.signalChildWorkflowRunName)(input.signalName)
|
|
209
172
|
: (0, run_tree_1.signalExternalWorkflowRunName)(input.signalName);
|
|
210
|
-
return this.
|
|
173
|
+
return this.withHeaders(name, input, next);
|
|
211
174
|
}
|
|
212
175
|
async startNexusOperation(input, next) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
const ctx = (0, run_tree_1.runHeaders)(ambient);
|
|
218
|
-
const headers = ctx ? { ...input.headers, [propagation_1.HEADER_KEY]: (0, propagation_1.encodeContextString)(ctx) } : input.headers;
|
|
219
|
-
return next({ ...input, headers });
|
|
176
|
+
return this.traceOutbound((0, run_tree_1.startNexusOperationRunName)(input.service, input.operation), (context) => {
|
|
177
|
+
const headers = context ? { ...input.headers, [propagation_1.HEADER_KEY]: (0, propagation_1.encodeContextString)(context) } : input.headers;
|
|
178
|
+
return next({ ...input, headers });
|
|
179
|
+
});
|
|
220
180
|
}
|
|
221
|
-
/**
|
|
222
|
-
async
|
|
181
|
+
/** Emit the marker, then pass `call` the caller's context, so the remote run is the marker's sibling. */
|
|
182
|
+
async traceOutbound(name, call) {
|
|
223
183
|
const ambient = sharedStore.getStore();
|
|
224
|
-
if (this.config.addTemporalRuns && ambient
|
|
225
|
-
await emitMarker(ambient, name
|
|
184
|
+
if (this.config.addTemporalRuns && ambient !== undefined) {
|
|
185
|
+
await emitMarker(this.config, ambient, name);
|
|
226
186
|
}
|
|
227
|
-
|
|
228
|
-
return next(headers);
|
|
187
|
+
return call((0, run_tree_1.runHeaders)(ambient));
|
|
229
188
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const ambient = sharedStore.getStore();
|
|
233
|
-
let propagate = ambient;
|
|
234
|
-
if (this.config.addTemporalRuns && ambient instanceof run_tree_1.ReplaySafeRunTree) {
|
|
235
|
-
propagate = await emitMarker(ambient, name, { args: input.args ?? [] });
|
|
236
|
-
}
|
|
237
|
-
const headers = (0, propagation_1.withContextHeader)(input.headers, (0, run_tree_1.runHeaders)(propagate));
|
|
238
|
-
return next(headers);
|
|
189
|
+
withHeaders(name, input, next) {
|
|
190
|
+
return this.traceOutbound(name, (context) => next({ ...input, headers: (0, propagation_1.withContextHeader)(input.headers, context) }));
|
|
239
191
|
}
|
|
240
192
|
}
|
|
241
193
|
/**
|
|
@@ -246,6 +198,7 @@ class LangSmithWorkflowOutbound {
|
|
|
246
198
|
*/
|
|
247
199
|
function interceptors() {
|
|
248
200
|
const config = readConfig();
|
|
201
|
+
(0, workflow_run_tree_1.installRunTreeOverrides)();
|
|
249
202
|
return {
|
|
250
203
|
inbound: [new LangSmithWorkflowInbound(config)],
|
|
251
204
|
outbound: [new LangSmithWorkflowOutbound(config)],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-interceptors.js","sourceRoot":"","sources":["../src/workflow-interceptors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;
|
|
1
|
+
{"version":3,"file":"workflow-interceptors.js","sourceRoot":"","sources":["../src/workflow-interceptors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA0UH,oCAOC;AA/UD,mDAA8C;AAC9C,8DAAoF;AASpF,mDAc8B;AAC9B,+CAOuB;AACvB,yCAq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,OAAO,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACzD,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,IAAA,qBAAU,EAAC,OAAO,CAAC,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CACjB,IAAY,EACZ,KAAQ,EACR,IAA8B;QAE9B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAC1C,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAA,+BAAiB,EAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CACvE,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACH,SAAgB,YAAY;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,IAAA,2CAAuB,GAAE,CAAC;IAC1B,OAAO;QACL,OAAO,EAAE,CAAC,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;QAC/C,QAAQ,EAAE,CAAC,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Native LangSmith lifecycle overrides, scoped to this plugin's workflow handlers. */
|
|
2
|
+
import { type RunTreeOverrides } from './run-tree';
|
|
3
|
+
import type { WorkflowLangSmithConfig } from './workflow-interceptors';
|
|
4
|
+
export declare function workflowRunTreeContext<T>(config: WorkflowLangSmithConfig, fn: () => T, readOnly?: boolean): T;
|
|
5
|
+
/** Preserve native root/child selection, ordering, and replica inheritance. */
|
|
6
|
+
export declare const WORKFLOW_RUN_TREE_OVERRIDES: RunTreeOverrides;
|
|
7
|
+
export declare function installRunTreeOverrides(): void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Native LangSmith lifecycle overrides, scoped to this plugin's workflow handlers. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.WORKFLOW_RUN_TREE_OVERRIDES = void 0;
|
|
5
|
+
exports.workflowRunTreeContext = workflowRunTreeContext;
|
|
6
|
+
exports.installRunTreeOverrides = installRunTreeOverrides;
|
|
7
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const workflow_1 = require("@temporalio/workflow");
|
|
10
|
+
const run_tree_1 = require("./run-tree");
|
|
11
|
+
const sinks_1 = require("./sinks");
|
|
12
|
+
const LANGSMITH_RUN_TREE_STREAM = 'package-langsmith-tracing';
|
|
13
|
+
// The bundle rewrites `node:async_hooks` to the AsyncLocalStorage the SDK injects into the sandbox.
|
|
14
|
+
const context = new node_async_hooks_1.AsyncLocalStorage();
|
|
15
|
+
function workflowRunTreeContext(config, fn, readOnly = false) {
|
|
16
|
+
return context.run({ config, readOnly }, fn);
|
|
17
|
+
}
|
|
18
|
+
function runId(readOnly) {
|
|
19
|
+
const bytes = new Uint8Array(16);
|
|
20
|
+
if (readOnly) {
|
|
21
|
+
const { unsafe } = (0, workflow_1.workflowInfo)();
|
|
22
|
+
return (0, uuid_1.v7)({ msecs: unsafe.now(), random: unsafe.random.fillRandom(bytes) });
|
|
23
|
+
}
|
|
24
|
+
return (0, uuid_1.v7)({ msecs: Date.now(), random: (0, workflow_1.getRandomStream)(LANGSMITH_RUN_TREE_STREAM).fill(bytes) });
|
|
25
|
+
}
|
|
26
|
+
function workerOrServerTime() {
|
|
27
|
+
const { unsafe } = (0, workflow_1.workflowInfo)();
|
|
28
|
+
return unsafe.isReplayingHistoryEvents ? Date.now() : unsafe.now();
|
|
29
|
+
}
|
|
30
|
+
// Every write inside a workflow is routed through a sink instead of this client.
|
|
31
|
+
const NOOP_CLIENT = {
|
|
32
|
+
createRun: async () => { },
|
|
33
|
+
updateRun: async () => { },
|
|
34
|
+
};
|
|
35
|
+
// LangSmith calls getDefaultConfig and _resolveAddressing from its constructor. Patching them also covers
|
|
36
|
+
// RunTree aliases imported before installation, including its own createChild.
|
|
37
|
+
/** Preserve native root/child selection, ordering, and replica inheritance. */
|
|
38
|
+
exports.WORKFLOW_RUN_TREE_OVERRIDES = {
|
|
39
|
+
statics: {
|
|
40
|
+
getDefaultConfig: (original) => function (...args) {
|
|
41
|
+
const defaults = original.apply(this, args);
|
|
42
|
+
const active = context.getStore();
|
|
43
|
+
if (!active)
|
|
44
|
+
return defaults;
|
|
45
|
+
return {
|
|
46
|
+
...defaults,
|
|
47
|
+
id: runId(active.readOnly),
|
|
48
|
+
start_time: workerOrServerTime(),
|
|
49
|
+
replicas: active.config.replicas,
|
|
50
|
+
// Keep traceable's awaits independent of the worker's destination env.
|
|
51
|
+
tracingEnabled: true,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
getSharedClient: (original) => function (...args) {
|
|
55
|
+
return context.getStore() ? NOOP_CLIENT : original.apply(this, args);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
methods: {
|
|
59
|
+
_resolveAddressing: (original) => function (config, ...args) {
|
|
60
|
+
const active = context.getStore();
|
|
61
|
+
if (!active)
|
|
62
|
+
return original.call(this, config, ...args);
|
|
63
|
+
const selected = config.project_name || config.address ? config : { ...config, ...active.config.destination };
|
|
64
|
+
original.call(this, selected, ...args);
|
|
65
|
+
if (!selected.project_name && !selected.address)
|
|
66
|
+
(0, run_tree_1.suppressRun)(this);
|
|
67
|
+
// A run with no parent and no propagated trace starts a new trace, which LangSmith's env gates.
|
|
68
|
+
if (!config.parent_run && !config.trace_id && active.config.tracingEnabled === false)
|
|
69
|
+
(0, run_tree_1.suppressRun)(this);
|
|
70
|
+
// A child of an untraced run stays untraced, whether built by createChild or `new RunTree({ parent_run })`.
|
|
71
|
+
if (config.parent_run && (0, run_tree_1.isUntraced)(config.parent_run))
|
|
72
|
+
(0, run_tree_1.suppressRun)(this);
|
|
73
|
+
},
|
|
74
|
+
end: (original) => async function (outputs, error, endTime, ...args) {
|
|
75
|
+
if (context.getStore() && endTime === undefined)
|
|
76
|
+
endTime = workerOrServerTime();
|
|
77
|
+
return original.call(this, outputs, error, endTime, ...args);
|
|
78
|
+
},
|
|
79
|
+
postRun: (original) => async function (excludeChildRuns = true, ...args) {
|
|
80
|
+
if (!context.getStore())
|
|
81
|
+
return original.call(this, excludeChildRuns, ...args);
|
|
82
|
+
// Native traceable can defer asynchronous input processing until postRun.
|
|
83
|
+
if (this._awaitInputsOnPost) {
|
|
84
|
+
this.inputs = await this.inputs;
|
|
85
|
+
}
|
|
86
|
+
if (!(0, workflow_1.workflowInfo)().unsafe.isReplayingHistoryEvents && !(0, run_tree_1.isUntraced)(this)) {
|
|
87
|
+
(0, workflow_1.proxySinks)()[sinks_1.LANGSMITH_SINK_NAME].createRun((0, run_tree_1.serializeRun)(this));
|
|
88
|
+
}
|
|
89
|
+
if (!excludeChildRuns) {
|
|
90
|
+
for (const child of this.child_runs)
|
|
91
|
+
await child.postRun(false);
|
|
92
|
+
}
|
|
93
|
+
this.child_runs = [];
|
|
94
|
+
},
|
|
95
|
+
patchRun: (original) => async function (options, ...args) {
|
|
96
|
+
if (!context.getStore())
|
|
97
|
+
return original.call(this, options, ...args);
|
|
98
|
+
if (!(0, workflow_1.workflowInfo)().unsafe.isReplayingHistoryEvents && !(0, run_tree_1.isUntraced)(this)) {
|
|
99
|
+
(0, workflow_1.proxySinks)()[sinks_1.LANGSMITH_SINK_NAME].updateRun((0, run_tree_1.serializeRun)(this), options);
|
|
100
|
+
}
|
|
101
|
+
this.child_runs = [];
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
let installed = false;
|
|
106
|
+
function installRunTreeOverrides() {
|
|
107
|
+
if (installed)
|
|
108
|
+
return;
|
|
109
|
+
(0, run_tree_1.patchRunTree)(exports.WORKFLOW_RUN_TREE_OVERRIDES);
|
|
110
|
+
installed = true;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=workflow-run-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-run-tree.js","sourceRoot":"","sources":["../src/workflow-run-tree.ts"],"names":[],"mappings":";AAAA,uFAAuF;;;AAsBvF,wDAMC;AA8FD,0DAIC;AA5HD,uDAAqD;AAIrD,+BAAoC;AACpC,mDAAiF;AACjF,yCAAwG;AACxG,mCAAmE;AAGnE,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAO9D,oGAAoG;AACpG,MAAM,OAAO,GAAG,IAAI,oCAAiB,EAA0B,CAAC;AAEhE,SAAgB,sBAAsB,CACpC,MAA+B,EAC/B,EAAW,EACX,QAAQ,GAAG,KAAK;IAEhB,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,KAAK,CAAC,QAAiB;IAC9B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAEjC,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,uBAAY,GAAE,CAAC;QAClC,OAAO,IAAA,SAAM,EAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,IAAA,SAAM,EAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAA,0BAAe,EAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACvG,CAAC;AAED,SAAS,kBAAkB;IACzB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,uBAA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F,CAAC;YACD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACvB,CAAC;KACJ;CACF,CAAC;AAEF,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,SAAgB,uBAAuB;IACrC,IAAI,SAAS;QAAE,OAAO;IACtB,IAAA,uBAAY,EAAC,mCAA2B,CAAC,CAAC;IAC1C,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/langsmith",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"description": "Temporal LangSmith observability integration package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"ava": {
|
|
15
15
|
"files": [
|
|
16
|
+
"./lib/__tests__/**/*.test.js",
|
|
16
17
|
"./lib/__tests__/test-*.js"
|
|
17
18
|
],
|
|
18
19
|
"timeout": "120s",
|
|
@@ -44,34 +45,49 @@
|
|
|
44
45
|
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
45
46
|
"license": "MIT",
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@temporalio/activity": "1.24.0",
|
|
48
|
-
"@temporalio/client": "1.24.0",
|
|
49
|
-
"@temporalio/common": "1.24.0",
|
|
50
|
-
"@temporalio/plugin": "1.24.0",
|
|
51
|
-
"@temporalio/worker": "1.24.0",
|
|
52
|
-
"@temporalio/workflow": "1.24.0"
|
|
48
|
+
"@temporalio/activity": "^1.24.0",
|
|
49
|
+
"@temporalio/client": "^1.24.0",
|
|
50
|
+
"@temporalio/common": "^1.24.0",
|
|
51
|
+
"@temporalio/plugin": "^1.24.0",
|
|
52
|
+
"@temporalio/worker": "^1.24.0",
|
|
53
|
+
"@temporalio/workflow": "^1.24.0",
|
|
54
|
+
"uuid": "^11.1.0"
|
|
53
55
|
},
|
|
54
56
|
"peerDependencies": {
|
|
55
|
-
"langsmith": "
|
|
57
|
+
"langsmith": ">=0.10.13 <0.11.0",
|
|
58
|
+
"long": "^5.3.2",
|
|
59
|
+
"protobufjs": "^8.7.1"
|
|
56
60
|
},
|
|
57
61
|
"devDependencies": {
|
|
58
|
-
"@temporalio/testing": "1.24.0",
|
|
62
|
+
"@temporalio/testing": "^1.24.0",
|
|
59
63
|
"ava": "^5.3.1",
|
|
60
|
-
"langsmith": "
|
|
61
|
-
"
|
|
64
|
+
"langsmith": ">=0.10.13 <0.11.0",
|
|
65
|
+
"long": "^5.3.2",
|
|
66
|
+
"nexus-rpc": "^0.0.3",
|
|
67
|
+
"protobufjs": "^8.7.1",
|
|
68
|
+
"@tsconfig/node20": "^20.1.4",
|
|
69
|
+
"@types/node": "^20.19.39",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"tsx": "^4.20.6",
|
|
72
|
+
"eslint": "^9.26.0",
|
|
73
|
+
"@eslint/js": "^9.26.0",
|
|
74
|
+
"typescript-eslint": "^8.10.0",
|
|
75
|
+
"eslint-plugin-import": "^2.31.0",
|
|
76
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
77
|
+
"eslint-config-prettier": "^9.1.0"
|
|
62
78
|
},
|
|
63
79
|
"engines": {
|
|
64
|
-
"node": ">=
|
|
80
|
+
"node": ">=22.12.0"
|
|
65
81
|
},
|
|
66
82
|
"bugs": {
|
|
67
|
-
"url": "https://github.com/temporalio/
|
|
83
|
+
"url": "https://github.com/temporalio/ai-integrations/issues"
|
|
68
84
|
},
|
|
69
85
|
"repository": {
|
|
70
86
|
"type": "git",
|
|
71
|
-
"url": "git+https://github.com/temporalio/
|
|
72
|
-
"directory": "
|
|
87
|
+
"url": "git+https://github.com/temporalio/ai-integrations.git",
|
|
88
|
+
"directory": "typescript/langsmith"
|
|
73
89
|
},
|
|
74
|
-
"homepage": "https://github.com/temporalio/
|
|
90
|
+
"homepage": "https://github.com/temporalio/ai-integrations/tree/main/typescript/langsmith",
|
|
75
91
|
"publishConfig": {
|
|
76
92
|
"access": "public"
|
|
77
93
|
},
|
|
@@ -79,10 +95,13 @@
|
|
|
79
95
|
"src",
|
|
80
96
|
"lib",
|
|
81
97
|
"!src/__tests__",
|
|
82
|
-
"!lib/__tests__"
|
|
98
|
+
"!lib/__tests__",
|
|
99
|
+
"LICENSE"
|
|
83
100
|
],
|
|
84
101
|
"scripts": {
|
|
85
102
|
"build": "tsc --build",
|
|
86
|
-
"
|
|
103
|
+
"lint": "pnpm run build && eslint --config ../_shared/eslint.config.mjs src",
|
|
104
|
+
"test": "ava",
|
|
105
|
+
"pack": "pnpm pack --pack-destination dist"
|
|
87
106
|
}
|
|
88
107
|
}
|