@temporalio/langsmith 1.23.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 CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License
1
+ MIT License
2
2
 
3
- Copyright (c) 2021-2025 Temporal Technologies Inc. All rights reserved.
3
+ Copyright (c) 2026 temporal.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # @temporalio/langsmith — LangSmith tracing for Temporal
2
2
 
3
+ Release stage: Generally Available.
4
+
3
5
  This plugin makes [LangSmith](https://docs.smith.langchain.com/) observability
4
6
  work inside Temporal Workflows and Activities **without changing your existing
5
7
  instrumentation**. Code you already trace with LangSmith's native `traceable`
6
8
  keeps working when you move it into a Workflow or Activity body — you only add
7
9
  the plugin to your `Client` and `Worker`.
8
10
 
9
- This plugin is built on Temporal's Plugin API, which is experimental; its APIs
10
- may change in a future release.
11
-
12
11
  It handles the parts that are otherwise hard:
13
12
 
14
13
  - **Replay safety.** Workflows replay history; a naive tracer re-emits every run
@@ -40,7 +39,8 @@ export LANGSMITH_API_KEY="<your key>"
40
39
 
41
40
  The plugin reads the same flags LangSmith itself uses (`LANGSMITH_TRACING` /
42
41
  `LANGSMITH_TRACING_V2` and their `LANGCHAIN_` aliases); with none set to `true`,
43
- tracing stays off and the plugin is a no-op.
42
+ the plugin starts no new traces. As in LangSmith, a trace that arrives in
43
+ Temporal headers from a traced caller continues either way.
44
44
 
45
45
  ## Hello world
46
46
 
@@ -150,15 +150,75 @@ user_pipeline
150
150
  | ----------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
151
151
  | `client` | `new Client()` | The LangSmith client runs are emitted to. Lives only in the worker/client process — it is never serialized or sent across a Temporal boundary. |
152
152
  | `addTemporalRuns` | `false` | Emit first-class runs for Temporal operations (`StartWorkflow:`, `RunActivity:`, `HandleSignal:`, …) in addition to your `traceable` runs. |
153
- | `projectName` | LangSmith default | Target LangSmith project for emitted runs. |
153
+ | `projectName` | LangSmith default | Default LangSmith project for new root traces. An inherited destination takes precedence. |
154
+ | `address` | — | Agent/environment destination, mutually exclusive with `projectName`. Requires LangSmith's workspace-enabled beta feature. |
154
155
  | `tags` | — | Tags attached to every run the plugin emits. |
155
- | `metadata` | — | Metadata merged into every run the plugin emits. Credential-looking keys are scrubbed before emission. |
156
+ | `metadata` | — | Metadata merged into every run the plugin emits. It is sent unchanged and travels in Temporal headers, so keep secrets out of it. |
156
157
 
157
158
  The LangSmith API key is never accepted as a plugin option and never crosses a
158
159
  Temporal boundary. Supply a pre-constructed `Client` (which reads
159
160
  `LANGSMITH_API_KEY` from the process environment) or let the plugin build a
160
161
  default client from the environment.
161
162
 
163
+ ## Agent and environment destinations
164
+
165
+ With LangSmith 0.10.13 or later, send traces to an agent's environment:
166
+
167
+ ```typescript
168
+ import { AgentAddress } from 'langsmith';
169
+ import { LangSmithPlugin } from '@temporalio/langsmith';
170
+
171
+ const plugin = new LangSmithPlugin({
172
+ address: new AgentAddress('support', 'staging'),
173
+ });
174
+ ```
175
+
176
+ Register the plugin on the Client and Worker as in the quick start. `address`
177
+ and `projectName` are mutually exclusive. Agent addressing is a LangSmith beta
178
+ feature that must be enabled for the workspace.
179
+
180
+ When upgrading from LangSmith 0.10.8, replace `address.agent(...)` with
181
+ `new AgentAddress(...)`. Addresses are objects in application code; tracing
182
+ headers retain their LRN string format, including headers in existing histories.
183
+ This is a breaking change for Workflows that pass address strings as recorded
184
+ inputs to LangSmith calls. Let those executions finish on the previous plugin
185
+ and LangSmith versions, or keep them on their previous Worker Deployment Version
186
+ when deploying the upgrade.
187
+
188
+ Native `traceable(fn, { address: ... })` and runtime traceable configuration
189
+ also select destinations for new root traces in Workflows, Activities, and
190
+ Nexus handlers. Child runs
191
+ inherit their parent's destination, following LangSmith's native rules. Plugin
192
+ defaults apply when a new root names no destination.
193
+ Destinations follow the trace through Activities, child Workflows, and Nexus,
194
+ including with `addTemporalRuns: false`.
195
+
196
+ ## Write replicas
197
+
198
+ LangSmith write replicas configured on `traceable` or through
199
+ `LANGSMITH_RUNS_ENDPOINTS` follow the trace across Temporal boundaries:
200
+
201
+ ```typescript
202
+ const pipeline = traceable(runWorkflow, {
203
+ replicas: [
204
+ { projectName: 'primary', primary: true },
205
+ { projectName: 'audit' },
206
+ { address: new AgentAddress('support', 'production') },
207
+ ],
208
+ });
209
+ ```
210
+
211
+ A primary replica retains the original run IDs. Secondary replicas use
212
+ LangSmith's deterministic destination-specific IDs, with corresponding parent
213
+ links and completion updates. Replaying Workflow history publishes no extra
214
+ copies.
215
+
216
+ Only destination identifiers, routing flags, and sanitized replica updates
217
+ cross Temporal boundaries. Each client/worker configures its own credentials;
218
+ matching project destinations in its local `LANGSMITH_RUNS_ENDPOINTS` supply
219
+ their own connection settings. API keys, ingestion URLs, and client objects
220
+ stay outside persisted trace headers.
221
+
162
222
  ## Where `traceable` works
163
223
 
164
224
  `traceable` from `langsmith/traceable` works **unchanged** in every position
@@ -176,6 +236,13 @@ the worker injects onto the workflow-sandbox global, so context propagates
176
236
  across `await` boundaries and `Promise.all(...)` fan-out exactly as it does
177
237
  outside the isolate — the same deterministic run tree replays identically.
178
238
 
239
+ Native `RunTree` instances work in Workflow code too:
240
+
241
+ - Run IDs are the same on replay.
242
+ - End times come from the Worker's clock. Start times do too, unless the run
243
+ was rebuilt by a replay before it ended; then they come from Workflow time.
244
+ - A run's end is never sent twice.
245
+
179
246
  ## Process-wide effects to be aware of
180
247
 
181
248
  - **Workflow context provider.** Loading the plugin's workflow interceptor
@@ -184,6 +251,12 @@ outside the isolate — the same deterministic run tree replays identically.
184
251
  backed by the SDK-provided `AsyncLocalStorage`. This is what lets unchanged
185
252
  `traceable` calls find their parent inside a Workflow. It is scoped to the
186
253
  workflow bundle and does not affect your client/worker process context.
254
+ - **Worker routing defaults.** The plugin wraps LangSmith's destination and
255
+ shared-client hooks. Defaults apply only within parentless Activity and
256
+ Nexus handlers when `addTemporalRuns: false`; each call carries its own
257
+ destination, client, and replicas in async context. No placeholder run is
258
+ installed. Explicit run configuration and native child inheritance take
259
+ precedence.
187
260
 
188
261
  ## Composing with other plugins
189
262
 
@@ -14,6 +14,8 @@ const run_trees_1 = require("langsmith/run_trees");
14
14
  const traceable_1 = require("langsmith/traceable");
15
15
  const propagation_1 = require("./propagation");
16
16
  const run_tree_1 = require("./run-tree");
17
+ const routing_1 = require("./routing");
18
+ const worker_run_tree_1 = require("./worker-run-tree");
17
19
  /**
18
20
  * Reconstruct the propagated parent run from a LangSmith trace context, wired to
19
21
  * the plugin-configured client so descendant runs emit to the right place. The
@@ -31,30 +33,35 @@ function reconstructParentRun(config, ctx) {
31
33
  id: parsed.id,
32
34
  trace_id: parsed.trace_id,
33
35
  dotted_order: parsed.dotted_order,
36
+ start_time: parsed.start_time,
34
37
  parent_run_id: parsed.parent_run_id,
35
- project_name: config.projectName ?? parsed.project_name,
38
+ ...(0, routing_1.destination)(parsed, { project_name: config.projectName, address: config.address }),
39
+ replicas: (0, routing_1.bindReplicaCredentials)(parsed.replicas, config.replicas),
40
+ distributedParentId: parsed.distributedParentId,
36
41
  client: config.client,
37
42
  // Force-enable so nested body `traceable` runs emit; tracing gate is `isTracingEnabled()`.
38
43
  tracingEnabled: true,
39
44
  });
40
45
  }
41
46
  /**
42
- * Run `fn` with `op` installed as the active LangSmith run, emitting the run
43
- * around the call. Shared by activity and Nexus handlers.
47
+ * Run a handler under `parent`. With `addTemporalRuns`, wrap it in the operation run from `build`, emitted unless
48
+ * LangSmith turned tracing off for it (an env it can't address). Shared by activity and Nexus handlers.
44
49
  */
45
- async function traceOperation(op, fn) {
46
- await op.postRun();
47
- try {
48
- const result = await (0, traceable_1.withRunTree)(op, fn);
49
- await op.end((0, run_tree_1.asOutputs)(result));
50
- await op.patchRun();
51
- return result;
50
+ async function traceHandler(config, parent, build, fn) {
51
+ // A propagated parent keeps tracing on, as LangSmith does; the env only gates traces that start here.
52
+ if (!parent && !(0, langsmith_1.isTracingEnabled)()) {
53
+ return fn();
52
54
  }
53
- catch (err) {
54
- await op.end(undefined, (0, run_tree_1.describeError)(err));
55
- await op.patchRun();
56
- throw err;
55
+ if (!config.addTemporalRuns) {
56
+ // Without a parent, native roots fall back to the plugin's routing defaults.
57
+ return parent ? (0, traceable_1.withRunTree)(parent, fn) : (0, worker_run_tree_1.withRunTreeDefaults)(config, fn);
57
58
  }
59
+ const run = build();
60
+ if (!run.tracingEnabled) {
61
+ return (0, traceable_1.withRunTree)(run, fn);
62
+ }
63
+ await run.postRun();
64
+ return (0, run_tree_1.wrapWithRun)(run, () => (0, traceable_1.withRunTree)(run, fn));
58
65
  }
59
66
  /**
60
67
  * Build the activity-inbound interceptor factory. The worker calls the factory
@@ -64,30 +71,24 @@ async function traceOperation(op, fn) {
64
71
  function createActivityInboundInterceptor(config) {
65
72
  return (ctx) => ({
66
73
  async execute(input, next) {
67
- if (!(0, langsmith_1.isTracingEnabled)()) {
68
- return next(input);
69
- }
70
74
  const parent = reconstructParentRun(config, (0, propagation_1.readContextHeader)(input.headers));
71
- if (!config.addTemporalRuns) {
72
- // Propagation only: nest the user's body `traceable` runs under the
73
- // reconstructed parent without emitting a Temporal-operation run.
74
- // No propagated parent: run the body with no ambient run by design (nothing to attach to).
75
- return parent ? (0, traceable_1.withRunTree)(parent, () => next(input)) : next(input);
76
- }
77
- const activityType = ctx.info.activityType;
78
- const run = (0, run_tree_1.buildRunTree)(config, {
79
- name: (0, run_tree_1.runActivityRunName)(activityType),
80
- runType: run_tree_1.RUN_TYPE.TOOL,
81
- parent,
82
- inputs: { args: input.args },
83
- });
84
- return traceOperation(run, () => next(input));
75
+ const build = () => {
76
+ const { activityType, activityId, workflowExecution } = ctx.info;
77
+ return (0, run_tree_1.buildRunTree)(config, {
78
+ name: (0, run_tree_1.runActivityRunName)(activityType),
79
+ runType: run_tree_1.RUN_TYPE.TOOL,
80
+ parent,
81
+ metadata: {
82
+ temporalWorkflowID: workflowExecution?.workflowId ?? '',
83
+ temporalRunID: workflowExecution?.runId ?? '',
84
+ temporalActivityID: activityId,
85
+ },
86
+ });
87
+ };
88
+ return traceHandler(config, parent, build, () => next(input));
85
89
  },
86
90
  });
87
91
  }
88
- function nexusContext(headers) {
89
- return (0, propagation_1.decodeContextString)(headers[propagation_1.HEADER_KEY]);
90
- }
91
92
  /**
92
93
  * Build the Nexus-handler interceptor. `startOperation` opens a
93
94
  * `RunStartNexusOperationHandler:` run (so workflows the handler starts nest
@@ -95,19 +96,9 @@ function nexusContext(headers) {
95
96
  */
96
97
  function createNexusInboundInterceptor(config) {
97
98
  const handle = async (input, next, nameOf) => {
98
- if (!(0, langsmith_1.isTracingEnabled)()) {
99
- return next(input);
100
- }
101
- const parent = reconstructParentRun(config, nexusContext(input.ctx.headers));
102
- if (!config.addTemporalRuns) {
103
- return parent ? (0, traceable_1.withRunTree)(parent, () => next(input)) : next(input);
104
- }
105
- const run = (0, run_tree_1.buildRunTree)(config, {
106
- name: nameOf(input.ctx.service, input.ctx.operation),
107
- runType: run_tree_1.RUN_TYPE.CHAIN,
108
- parent,
109
- });
110
- return traceOperation(run, () => next(input));
99
+ const parent = reconstructParentRun(config, (0, propagation_1.decodeContextString)(input.ctx.headers[propagation_1.HEADER_KEY]));
100
+ const build = () => (0, run_tree_1.buildRunTree)(config, { name: nameOf(input.ctx.service, input.ctx.operation), runType: run_tree_1.RUN_TYPE.TOOL, parent });
101
+ return traceHandler(config, parent, build, () => next(input));
111
102
  };
112
103
  return {
113
104
  startOperation(input, next) {
@@ -1 +1 @@
1
- {"version":3,"file":"activity-interceptor.js","sourceRoot":"","sources":["../src/activity-interceptor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAqEH,4EAuBC;AAWD,sEA6BC;AAlID,yCAA6C;AAC7C,mDAA8C;AAC9C,mDAAkD;AAIlD,+CAA+G;AAC/G,yCASoB;AAGpB;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,MAAqB,EAAE,GAAsC;IACzF,MAAM,MAAM,GAAG,IAAA,6BAAkB,EAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,mBAAO,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,QAAQ;QAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,mBAAQ,CAAC,KAAK;QAC3C,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,YAAY,EAAE,MAA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EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,mBAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACjH,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO;QACL,cAAc,CAAC,KAAK,EAAE,IAAI;YACxB,OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,sCAA2B,CAAC,CAAC;QAC1D,CAAC;QACD,eAAe,CAAC,KAAK,EAAE,IAAI;YACzB,OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,uCAA4B,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Client-side LangSmith interceptor. Execution ops (`start`) emit a peer marker
3
- * and propagate the **ambient** context (the remote run is a sibling); messaging
4
- * ops (`signal`, `query`, `update`, …) emit the marker and propagate the
5
- * **marker** context (the remote handler nests under it).
2
+ * Client-side LangSmith interceptor. Each call runs inside a marker run that ends when the call returns. Execution ops
3
+ * (`start`, `signalWithStart`, `startUpdateWithStart`) propagate the **ambient** context (the remote run is a
4
+ * sibling); messaging ops (`signal`, `query`, `startUpdate`) propagate the **marker** context (the remote handler
5
+ * nests under it).
6
6
  *
7
7
  * @module
8
8
  */
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * Client-side LangSmith interceptor. Execution ops (`start`) emit a peer marker
4
- * and propagate the **ambient** context (the remote run is a sibling); messaging
5
- * ops (`signal`, `query`, `update`, …) emit the marker and propagate the
6
- * **marker** context (the remote handler nests under it).
3
+ * Client-side LangSmith interceptor. Each call runs inside a marker run that ends when the call returns. Execution ops
4
+ * (`start`, `signalWithStart`, `startUpdateWithStart`) propagate the **ambient** context (the remote run is a
5
+ * sibling); messaging ops (`signal`, `query`, `startUpdate`) propagate the **marker** context (the remote handler
6
+ * nests under it).
7
7
  *
8
8
  * @module
9
9
  */
@@ -14,68 +14,49 @@ const traceable_1 = require("langsmith/traceable");
14
14
  const propagation_1 = require("./propagation");
15
15
  const run_tree_1 = require("./run-tree");
16
16
  function createClientInterceptor(config) {
17
- const peerStart = async (input, next, name, args) => {
17
+ /** Run `call` inside a marker run, passing it the context to propagate: the marker's, or the ambient one when `peer`. */
18
+ const traced = async (name, peer, call) => {
18
19
  if (!(0, langsmith_1.isTracingEnabled)()) {
19
- return next(input);
20
+ return call(undefined);
20
21
  }
21
22
  const ambient = (0, traceable_1.getCurrentRunTree)(true);
22
- if (config.addTemporalRuns) {
23
- await (0, run_tree_1.emitMarkerRun)((0, run_tree_1.buildRunTree)(config, { name, runType: run_tree_1.RUN_TYPE.CHAIN, parent: ambient, inputs: { args } }));
23
+ if (!config.addTemporalRuns) {
24
+ return call((0, run_tree_1.runHeaders)(ambient));
24
25
  }
25
- const headers = (0, propagation_1.withContextHeader)(input.headers, (0, run_tree_1.runHeaders)(ambient));
26
- return next({ ...input, headers });
27
- };
28
- const parentMarker = async (input, next, name, args) => {
29
- if (!(0, langsmith_1.isTracingEnabled)()) {
30
- return next(input);
31
- }
32
- const ambient = (0, traceable_1.getCurrentRunTree)(true);
33
- let propagate = ambient;
34
- if (config.addTemporalRuns) {
35
- const marker = (0, run_tree_1.buildRunTree)(config, { name, runType: run_tree_1.RUN_TYPE.CHAIN, parent: ambient, inputs: { args } });
36
- await (0, run_tree_1.emitMarkerRun)(marker);
37
- propagate = marker;
26
+ const marker = (0, run_tree_1.buildRunTree)(config, { name, runType: run_tree_1.RUN_TYPE.CHAIN, parent: ambient });
27
+ const context = (0, run_tree_1.runHeaders)(peer ? ambient : marker);
28
+ if (!marker.tracingEnabled) {
29
+ return call(context);
38
30
  }
39
- const headers = (0, propagation_1.withContextHeader)(input.headers, (0, run_tree_1.runHeaders)(propagate));
40
- return next({ ...input, headers });
31
+ await marker.postRun();
32
+ return (0, run_tree_1.wrapWithRun)(marker, () => call(context));
41
33
  };
34
+ const withHeaders = (input, next, name, peer) => traced(name, peer, (context) => next({ ...input, headers: (0, propagation_1.withContextHeader)(input.headers, context) }));
42
35
  return {
43
36
  start(input, next) {
44
- return peerStart(input, next, (0, run_tree_1.startWorkflowRunName)(input.workflowType), input.options.args);
37
+ return withHeaders(input, next, (0, run_tree_1.startWorkflowRunName)(input.workflowType), true);
45
38
  },
46
39
  startWithDetails(input, next) {
47
- return peerStart(input, next, (0, run_tree_1.startWorkflowRunName)(input.workflowType), input.options.args);
40
+ return withHeaders(input, next, (0, run_tree_1.startWorkflowRunName)(input.workflowType), true);
48
41
  },
49
42
  signal(input, next) {
50
- return parentMarker(input, next, (0, run_tree_1.signalWorkflowRunName)(input.signalName), input.args);
43
+ return withHeaders(input, next, (0, run_tree_1.signalWorkflowRunName)(input.signalName), false);
51
44
  },
52
45
  signalWithStart(input, next) {
53
- return parentMarker(input, next, (0, run_tree_1.signalWithStartRunName)(input.workflowType), input.signalArgs);
46
+ return withHeaders(input, next, (0, run_tree_1.signalWithStartRunName)(input.workflowType), true);
54
47
  },
55
48
  query(input, next) {
56
- return parentMarker(input, next, (0, run_tree_1.queryWorkflowRunName)(input.queryType), input.args);
49
+ return withHeaders(input, next, (0, run_tree_1.queryWorkflowRunName)(input.queryType), false);
57
50
  },
58
51
  startUpdate(input, next) {
59
- return parentMarker(input, next, (0, run_tree_1.startWorkflowUpdateRunName)(input.updateName), input.args);
52
+ return withHeaders(input, next, (0, run_tree_1.startWorkflowUpdateRunName)(input.updateName), false);
60
53
  },
61
- async startUpdateWithStart(input, next) {
62
- if (!(0, langsmith_1.isTracingEnabled)()) {
63
- return next(input);
64
- }
65
- const ambient = (0, traceable_1.getCurrentRunTree)(true);
66
- let propagate = ambient;
67
- if (config.addTemporalRuns) {
68
- const marker = (0, run_tree_1.buildRunTree)(config, {
69
- name: (0, run_tree_1.startUpdateWithStartRunName)(input.updateName),
70
- runType: run_tree_1.RUN_TYPE.CHAIN,
71
- parent: ambient,
72
- inputs: { args: input.updateArgs },
73
- });
74
- await (0, run_tree_1.emitMarkerRun)(marker);
75
- propagate = marker;
76
- }
77
- const workflowStartHeaders = (0, propagation_1.withContextHeader)(input.workflowStartHeaders, (0, run_tree_1.runHeaders)(propagate));
78
- return next({ ...input, workflowStartHeaders });
54
+ startUpdateWithStart(input, next) {
55
+ return traced((0, run_tree_1.startUpdateWithStartRunName)(input.workflowType), true, (context) => next({
56
+ ...input,
57
+ workflowStartHeaders: (0, propagation_1.withContextHeader)(input.workflowStartHeaders, context),
58
+ updateHeaders: (0, propagation_1.withContextHeader)(input.updateHeaders, context),
59
+ }));
79
60
  },
80
61
  };
81
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client-interceptor.js","sourceRoot":"","sources":["../src/client-interceptor.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAwBH,0DA6EC;AAnGD,yCAA6C;AAE7C,mDAAwD;AAGxD,+CAAkD;AAClD,yCAWoB;AAKpB,SAAgB,uBAAuB,CAAC,MAAqB;IAC3D,MAAM,SAAS,GAAG,KAAK,EACrB,KAAQ,EACR,IAAkB,EAClB,IAAY,EACZ,IAAe,EACH,EAAE;QACd,IAAI,CAAC,IAAA,4BAAgB,GAAE,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QACD,MAAM,OAAO,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3B,MAAM,IAAA,wBAAa,EAAC,IAAA,uBAAY,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,C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D,eAAe,CAAC,KAAK,EAAE,IAAI;YACzB,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,iCAAsB,EAAC,KAAK,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;QACpF,CAAC;QACD,KAAK,CAAC,KAAK,EAAE,IAAI;YACf,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,+BAAoB,EAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;QAChF,CAAC;QACD,WAAW,CAAC,KAAK,EAAE,IAAI;YACrB,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAA,qCAA0B,EAAC,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC;QACvF,CAAC;QACD,oBAAoB,CAAC,KAAK,EAAE,IAAI;YAC9B,OAAO,MAAM,CAAC,IAAA,sCAA2B,EAAC,KAAK,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAC/E,IAAI,CAAC;gBACH,GAAG,KAAK;gBACR,oBAAoB,EAAE,IAAA,+BAAiB,EAAC,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC;gBAC5E,aAAa,EAAE,IAAA,+BAAiB,EAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC;aAC/D,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
package/lib/plugin.d.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * @module
20
20
  */
21
- import { Client } from 'langsmith';
21
+ import { Client, type AgentAddress } from 'langsmith';
22
22
  import { SimplePlugin } from '@temporalio/plugin';
23
23
  import type { ClientOptions } from '@temporalio/client';
24
24
  import type { BundleOptions, ReplayWorkerOptions, Worker, WorkerOptions } from '@temporalio/worker';
@@ -29,8 +29,6 @@ import type { BundleOptions, ReplayWorkerOptions, Worker, WorkerOptions } from '
29
29
  * never cross a Temporal boundary — supply a pre-constructed {@link Client}
30
30
  * (which reads `LANGSMITH_API_KEY` from the worker/client process env) or let
31
31
  * the plugin construct a default client from the environment.
32
- *
33
- * @experimental Plugins is an experimental feature; APIs may change without notice.
34
32
  */
35
33
  export interface LangSmithPluginOptions {
36
34
  /**
@@ -39,8 +37,10 @@ export interface LangSmithPluginOptions {
39
37
  * environment. Lives only in the worker/client process — never serialized.
40
38
  */
41
39
  client?: Client;
42
- /** Target LangSmith project for every emitted run. */
40
+ /** Default LangSmith project for new root traces. An inherited destination takes precedence. */
43
41
  projectName?: string;
42
+ /** Agent/environment destination, mutually exclusive with projectName. LangSmith beta. */
43
+ address?: AgentAddress;
44
44
  /**
45
45
  * When `true`, emit first-class runs for Temporal operations themselves
46
46
  * (`StartWorkflow:`, `RunActivity:`, `HandleSignal:`, …) in addition to the
@@ -65,13 +65,14 @@ export interface LangSmithPluginOptions {
65
65
  * const plugin = new LangSmithPlugin({ addTemporalRuns: true });
66
66
  * const worker = await Worker.create({ workflowsPath, taskQueue: 'tq', plugins: [plugin] });
67
67
  * ```
68
- *
69
- * @experimental Plugins is an experimental feature; APIs may change without notice.
70
68
  */
71
69
  export declare class LangSmithPlugin extends SimplePlugin {
70
+ /** The package version, reported in worker heartbeats. */
71
+ readonly version: string;
72
72
  private readonly client;
73
73
  private readonly emitter;
74
74
  private readonly workflowConfig;
75
+ private readonly drains;
75
76
  private readonly workflowInterceptorModule;
76
77
  private readonly asyncHooksShimModule;
77
78
  constructor(options?: LangSmithPluginOptions);