@temporalio/langsmith 1.20.0 → 1.20.2
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/lib/plugin.d.ts +1 -0
- package/lib/plugin.js +11 -13
- package/lib/plugin.js.map +1 -1
- package/package.json +8 -8
- package/src/plugin.ts +11 -14
package/lib/plugin.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export declare class LangSmithPlugin extends SimplePlugin {
|
|
|
72
72
|
private readonly client;
|
|
73
73
|
private readonly emitter;
|
|
74
74
|
private readonly workflowConfig;
|
|
75
|
+
private readonly workflowInterceptorModule;
|
|
75
76
|
constructor(options?: LangSmithPluginOptions);
|
|
76
77
|
configureClient(options: ClientOptions): ClientOptions;
|
|
77
78
|
configureWorker(options: WorkerOptions): WorkerOptions;
|
package/lib/plugin.js
CHANGED
|
@@ -26,10 +26,6 @@ const plugin_1 = require("@temporalio/plugin");
|
|
|
26
26
|
const activity_interceptor_1 = require("./activity-interceptor");
|
|
27
27
|
const client_interceptor_1 = require("./client-interceptor");
|
|
28
28
|
const sinks_1 = require("./sinks");
|
|
29
|
-
/**
|
|
30
|
-
* The module specifier for the workflow-side interceptors.
|
|
31
|
-
*/
|
|
32
|
-
const WORKFLOW_INTERCEPTOR_MODULE = '@temporalio/langsmith/workflow-interceptors';
|
|
33
29
|
// Bare identifier (not dotted) so DefinePlugin substitutes textually.
|
|
34
30
|
const CONFIG_GLOBAL = '__TEMPORAL_LANGSMITH_CONFIG__';
|
|
35
31
|
// Bare builtin name added to `ignoreModules`; see {@link aliasAsyncHooks}.
|
|
@@ -52,6 +48,8 @@ class LangSmithPlugin extends plugin_1.SimplePlugin {
|
|
|
52
48
|
client;
|
|
53
49
|
emitter;
|
|
54
50
|
workflowConfig;
|
|
51
|
+
// Absolute path so the workflow bundler resolves it under strict pnpm.
|
|
52
|
+
workflowInterceptorModule = require.resolve('./workflow-interceptors');
|
|
55
53
|
constructor(options = {}) {
|
|
56
54
|
// super() reads options.name immediately
|
|
57
55
|
super({ name: 'langchain.LangSmithPlugin' });
|
|
@@ -89,8 +87,8 @@ class LangSmithPlugin extends plugin_1.SimplePlugin {
|
|
|
89
87
|
const activityInbound = [...(interceptors.activityInbound ?? [])];
|
|
90
88
|
activityInbound.push((0, activity_interceptor_1.createActivityInboundInterceptor)(this.emitter));
|
|
91
89
|
const workflowModules = [...(interceptors.workflowModules ?? [])];
|
|
92
|
-
if (!workflowModules.includes(
|
|
93
|
-
workflowModules.push(
|
|
90
|
+
if (!workflowModules.includes(this.workflowInterceptorModule)) {
|
|
91
|
+
workflowModules.push(this.workflowInterceptorModule);
|
|
94
92
|
}
|
|
95
93
|
const nexusInbound = (0, activity_interceptor_1.createNexusInboundInterceptor)(this.emitter);
|
|
96
94
|
const nexusInterceptors = [...(interceptors.nexus ?? [])];
|
|
@@ -106,8 +104,8 @@ class LangSmithPlugin extends plugin_1.SimplePlugin {
|
|
|
106
104
|
configureBundler(options) {
|
|
107
105
|
const base = super.configureBundler(options);
|
|
108
106
|
const workflowInterceptorModules = [...(base.workflowInterceptorModules ?? [])];
|
|
109
|
-
if (!workflowInterceptorModules.includes(
|
|
110
|
-
workflowInterceptorModules.push(
|
|
107
|
+
if (!workflowInterceptorModules.includes(this.workflowInterceptorModule)) {
|
|
108
|
+
workflowInterceptorModules.push(this.workflowInterceptorModule);
|
|
111
109
|
}
|
|
112
110
|
// Dismiss the SDK bundler's disallowed-builtin guard for `async_hooks` (see aliasAsyncHooks).
|
|
113
111
|
const ignoreModules = [...(base.ignoreModules ?? [])];
|
|
@@ -120,7 +118,7 @@ class LangSmithPlugin extends plugin_1.SimplePlugin {
|
|
|
120
118
|
// Double-encode so the injected token is a string literal in the bundle.
|
|
121
119
|
const definitions = { [CONFIG_GLOBAL]: JSON.stringify(JSON.stringify(this.workflowConfig)) };
|
|
122
120
|
const withDefine = injectDefinePlugin(merged, definitions);
|
|
123
|
-
return aliasLangSmithNodeUtils(aliasAsyncHooks(withDefine));
|
|
121
|
+
return aliasLangSmithNodeUtils(aliasAsyncHooks(withDefine, this.workflowInterceptorModule));
|
|
124
122
|
};
|
|
125
123
|
return { ...base, workflowInterceptorModules, ignoreModules, webpackConfigHook };
|
|
126
124
|
}
|
|
@@ -153,16 +151,16 @@ exports.LangSmithPlugin = LangSmithPlugin;
|
|
|
153
151
|
* resolution, so `resolve.alias` cannot do this; `NormalModuleReplacementPlugin`
|
|
154
152
|
* rewrites the request in `beforeResolve` instead. Must be paired with the
|
|
155
153
|
* `ignoreModules` whitelist (see {@link LangSmithPlugin.configureBundler}). The
|
|
156
|
-
* rewrite target is the
|
|
157
|
-
* instance regardless of issuer.
|
|
154
|
+
* rewrite target is the resolved absolute module path so webpack dedupes to one
|
|
155
|
+
* isolate instance regardless of issuer.
|
|
158
156
|
*/
|
|
159
|
-
function aliasAsyncHooks(config) {
|
|
157
|
+
function aliasAsyncHooks(config, workflowInterceptorModule) {
|
|
160
158
|
const plugins = [...(config.plugins ?? [])];
|
|
161
159
|
try {
|
|
162
160
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
163
161
|
const webpack = require('webpack');
|
|
164
162
|
plugins.push(new webpack.NormalModuleReplacementPlugin(/^node:async_hooks$/, (resource) => {
|
|
165
|
-
resource.request =
|
|
163
|
+
resource.request = workflowInterceptorModule;
|
|
166
164
|
}));
|
|
167
165
|
}
|
|
168
166
|
catch (err) {
|
package/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,yCAAmC;AAGnC,+CAAkD;AAGlD,iEAAyG;AACzG,6DAA+D;AAC/D,mCAA+C;AAO/C
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,yCAAmC;A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
|
2
2
|
"name": "@temporalio/langsmith",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "Temporal LangSmith observability integration package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@temporalio/activity": "1.20.
|
|
48
|
-
"@temporalio/client": "1.20.
|
|
49
|
-
"@temporalio/
|
|
50
|
-
"@temporalio/
|
|
51
|
-
"@temporalio/
|
|
52
|
-
"@temporalio/
|
|
47
|
+
"@temporalio/activity": "1.20.2",
|
|
48
|
+
"@temporalio/client": "1.20.2",
|
|
49
|
+
"@temporalio/common": "1.20.2",
|
|
50
|
+
"@temporalio/worker": "1.20.2",
|
|
51
|
+
"@temporalio/workflow": "1.20.2",
|
|
52
|
+
"@temporalio/plugin": "1.20.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"langsmith": "^0.7.9"
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"ava": "^5.3.1",
|
|
59
59
|
"langsmith": "^0.7.9",
|
|
60
60
|
"nexus-rpc": "^0.0.2",
|
|
61
|
-
"@temporalio/testing": "1.20.
|
|
61
|
+
"@temporalio/testing": "1.20.2"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">= 20.0.0"
|
package/src/plugin.ts
CHANGED
|
@@ -34,11 +34,6 @@ import type { WorkflowLangSmithConfig } from './workflow-interceptors';
|
|
|
34
34
|
// Derived: @temporalio/worker doesn't export WebpackConfiguration from its root.
|
|
35
35
|
type WebpackConfiguration = Parameters<NonNullable<BundleOptions['webpackConfigHook']>>[0];
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
* The module specifier for the workflow-side interceptors.
|
|
39
|
-
*/
|
|
40
|
-
const WORKFLOW_INTERCEPTOR_MODULE = '@temporalio/langsmith/workflow-interceptors';
|
|
41
|
-
|
|
42
37
|
// Bare identifier (not dotted) so DefinePlugin substitutes textually.
|
|
43
38
|
const CONFIG_GLOBAL = '__TEMPORAL_LANGSMITH_CONFIG__';
|
|
44
39
|
|
|
@@ -96,6 +91,8 @@ export class LangSmithPlugin extends SimplePlugin {
|
|
|
96
91
|
private readonly client: Client;
|
|
97
92
|
private readonly emitter: EmitterConfig;
|
|
98
93
|
private readonly workflowConfig: WorkflowLangSmithConfig;
|
|
94
|
+
// Absolute path so the workflow bundler resolves it under strict pnpm.
|
|
95
|
+
private readonly workflowInterceptorModule = require.resolve('./workflow-interceptors');
|
|
99
96
|
|
|
100
97
|
constructor(options: LangSmithPluginOptions = {}) {
|
|
101
98
|
// super() reads options.name immediately
|
|
@@ -140,8 +137,8 @@ export class LangSmithPlugin extends SimplePlugin {
|
|
|
140
137
|
activityInbound.push(createActivityInboundInterceptor(this.emitter));
|
|
141
138
|
|
|
142
139
|
const workflowModules = [...(interceptors.workflowModules ?? [])];
|
|
143
|
-
if (!workflowModules.includes(
|
|
144
|
-
workflowModules.push(
|
|
140
|
+
if (!workflowModules.includes(this.workflowInterceptorModule)) {
|
|
141
|
+
workflowModules.push(this.workflowInterceptorModule);
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
const nexusInbound = createNexusInboundInterceptor(this.emitter);
|
|
@@ -161,8 +158,8 @@ export class LangSmithPlugin extends SimplePlugin {
|
|
|
161
158
|
override configureBundler(options: BundleOptions): BundleOptions {
|
|
162
159
|
const base = super.configureBundler(options);
|
|
163
160
|
const workflowInterceptorModules = [...(base.workflowInterceptorModules ?? [])];
|
|
164
|
-
if (!workflowInterceptorModules.includes(
|
|
165
|
-
workflowInterceptorModules.push(
|
|
161
|
+
if (!workflowInterceptorModules.includes(this.workflowInterceptorModule)) {
|
|
162
|
+
workflowInterceptorModules.push(this.workflowInterceptorModule);
|
|
166
163
|
}
|
|
167
164
|
// Dismiss the SDK bundler's disallowed-builtin guard for `async_hooks` (see aliasAsyncHooks).
|
|
168
165
|
const ignoreModules = [...(base.ignoreModules ?? [])];
|
|
@@ -175,7 +172,7 @@ export class LangSmithPlugin extends SimplePlugin {
|
|
|
175
172
|
// Double-encode so the injected token is a string literal in the bundle.
|
|
176
173
|
const definitions = { [CONFIG_GLOBAL]: JSON.stringify(JSON.stringify(this.workflowConfig)) };
|
|
177
174
|
const withDefine = injectDefinePlugin(merged, definitions);
|
|
178
|
-
return aliasLangSmithNodeUtils(aliasAsyncHooks(withDefine));
|
|
175
|
+
return aliasLangSmithNodeUtils(aliasAsyncHooks(withDefine, this.workflowInterceptorModule));
|
|
179
176
|
};
|
|
180
177
|
return { ...base, workflowInterceptorModules, ignoreModules, webpackConfigHook };
|
|
181
178
|
}
|
|
@@ -208,10 +205,10 @@ export class LangSmithPlugin extends SimplePlugin {
|
|
|
208
205
|
* resolution, so `resolve.alias` cannot do this; `NormalModuleReplacementPlugin`
|
|
209
206
|
* rewrites the request in `beforeResolve` instead. Must be paired with the
|
|
210
207
|
* `ignoreModules` whitelist (see {@link LangSmithPlugin.configureBundler}). The
|
|
211
|
-
* rewrite target is the
|
|
212
|
-
* instance regardless of issuer.
|
|
208
|
+
* rewrite target is the resolved absolute module path so webpack dedupes to one
|
|
209
|
+
* isolate instance regardless of issuer.
|
|
213
210
|
*/
|
|
214
|
-
function aliasAsyncHooks(config: WebpackConfiguration): WebpackConfiguration {
|
|
211
|
+
function aliasAsyncHooks(config: WebpackConfiguration, workflowInterceptorModule: string): WebpackConfiguration {
|
|
215
212
|
const plugins = [...(config.plugins ?? [])];
|
|
216
213
|
try {
|
|
217
214
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
@@ -220,7 +217,7 @@ function aliasAsyncHooks(config: WebpackConfiguration): WebpackConfiguration {
|
|
|
220
217
|
};
|
|
221
218
|
plugins.push(
|
|
222
219
|
new webpack.NormalModuleReplacementPlugin(/^node:async_hooks$/, (resource) => {
|
|
223
|
-
resource.request =
|
|
220
|
+
resource.request = workflowInterceptorModule;
|
|
224
221
|
}) as (typeof plugins)[number]
|
|
225
222
|
);
|
|
226
223
|
} catch (err) {
|