langsmith 0.7.6 → 0.7.7

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 CHANGED
@@ -18,6 +18,6 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
19
19
  Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
20
20
  // Update using pnpm bump-version
21
- exports.__version__ = "0.7.6";
21
+ exports.__version__ = "0.7.7";
22
22
  // Metadata key to hide a traced run from LangSmith's Messages View.
23
23
  exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/index.d.ts CHANGED
@@ -5,5 +5,5 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
6
  export { uuid7, uuid7FromTime } from "./uuid.js";
7
7
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
- export declare const __version__ = "0.7.6";
8
+ export declare const __version__ = "0.7.7";
9
9
  export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
package/dist/index.js CHANGED
@@ -5,6 +5,6 @@ export { getDefaultProjectName } from "./utils/project.js";
5
5
  export { uuid7, uuid7FromTime } from "./uuid.js";
6
6
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
7
7
  // Update using pnpm bump-version
8
- export const __version__ = "0.7.6";
8
+ export const __version__ = "0.7.7";
9
9
  // Metadata key to hide a traced run from LangSmith's Messages View.
10
10
  export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
@@ -107,11 +107,25 @@ class CommandHandle {
107
107
  writable: true,
108
108
  value: void 0
109
109
  });
110
+ Object.defineProperty(this, "_onStdout", {
111
+ enumerable: true,
112
+ configurable: true,
113
+ writable: true,
114
+ value: void 0
115
+ });
116
+ Object.defineProperty(this, "_onStderr", {
117
+ enumerable: true,
118
+ configurable: true,
119
+ writable: true,
120
+ value: void 0
121
+ });
110
122
  this._stream = messageStream;
111
123
  this._control = control;
112
124
  this._sandbox = sandbox;
113
125
  this._lastStdoutOffset = options?.stdoutOffset ?? 0;
114
126
  this._lastStderrOffset = options?.stderrOffset ?? 0;
127
+ this._onStdout = options?.onStdout;
128
+ this._onStderr = options?.onStderr;
115
129
  // New executions (no commandId): _ensureStarted reads "started".
116
130
  // Reconnections (commandId set): skip since reconnect streams
117
131
  // don't send a "started" message.
@@ -221,10 +235,12 @@ class CommandHandle {
221
235
  if (chunk.stream === "stdout") {
222
236
  this._lastStdoutOffset =
223
237
  chunk.offset + new TextEncoder().encode(chunk.data).length;
238
+ this._onStdout?.(chunk.data);
224
239
  }
225
240
  else {
226
241
  this._lastStderrOffset =
227
242
  chunk.offset + new TextEncoder().encode(chunk.data).length;
243
+ this._onStderr?.(chunk.data);
228
244
  }
229
245
  yield chunk;
230
246
  }
@@ -45,6 +45,8 @@ export declare class CommandHandle {
45
45
  private _lastStdoutOffset;
46
46
  private _lastStderrOffset;
47
47
  private _started;
48
+ private _onStdout?;
49
+ private _onStderr?;
48
50
  /**
49
51
  * Read the 'started' message to populate commandId and pid.
50
52
  *
@@ -104,11 +104,25 @@ export class CommandHandle {
104
104
  writable: true,
105
105
  value: void 0
106
106
  });
107
+ Object.defineProperty(this, "_onStdout", {
108
+ enumerable: true,
109
+ configurable: true,
110
+ writable: true,
111
+ value: void 0
112
+ });
113
+ Object.defineProperty(this, "_onStderr", {
114
+ enumerable: true,
115
+ configurable: true,
116
+ writable: true,
117
+ value: void 0
118
+ });
107
119
  this._stream = messageStream;
108
120
  this._control = control;
109
121
  this._sandbox = sandbox;
110
122
  this._lastStdoutOffset = options?.stdoutOffset ?? 0;
111
123
  this._lastStderrOffset = options?.stderrOffset ?? 0;
124
+ this._onStdout = options?.onStdout;
125
+ this._onStderr = options?.onStderr;
112
126
  // New executions (no commandId): _ensureStarted reads "started".
113
127
  // Reconnections (commandId set): skip since reconnect streams
114
128
  // don't send a "started" message.
@@ -218,10 +232,12 @@ export class CommandHandle {
218
232
  if (chunk.stream === "stdout") {
219
233
  this._lastStdoutOffset =
220
234
  chunk.offset + new TextEncoder().encode(chunk.data).length;
235
+ this._onStdout?.(chunk.data);
221
236
  }
222
237
  else {
223
238
  this._lastStderrOffset =
224
239
  chunk.offset + new TextEncoder().encode(chunk.data).length;
240
+ this._onStderr?.(chunk.data);
225
241
  }
226
242
  yield chunk;
227
243
  }
@@ -225,7 +225,7 @@ class Sandbox {
225
225
  * @internal
226
226
  */
227
227
  async _runWs(command, options = {}) {
228
- const { timeout = 60, env, cwd, shell = "/bin/bash", onStdout, onStderr, idleTimeout, killOnDisconnect, ttlSeconds, pty, } = options;
228
+ const { timeout = 60, env, cwd, shell = "/bin/bash", onStdout, onStderr, commandId, idleTimeout, killOnDisconnect, ttlSeconds, pty, } = options;
229
229
  const dataplaneUrl = this.requireDataplaneUrl();
230
230
  const clientHeaders = this._client.getDefaultHeaders();
231
231
  const [stream, control] = await (0, ws_execute_js_1.runWsStream)(dataplaneUrl, this._client.getApiKey(), command, {
@@ -233,8 +233,7 @@ class Sandbox {
233
233
  env,
234
234
  cwd,
235
235
  shell,
236
- onStdout,
237
- onStderr,
236
+ commandId,
238
237
  idleTimeout,
239
238
  killOnDisconnect,
240
239
  ttlSeconds,
@@ -243,7 +242,10 @@ class Sandbox {
243
242
  ? { headers: clientHeaders }
244
243
  : {}),
245
244
  });
246
- const handle = new command_handle_js_1.CommandHandle(stream, control, this);
245
+ const handle = new command_handle_js_1.CommandHandle(stream, control, this, {
246
+ onStdout,
247
+ onStderr,
248
+ });
247
249
  await handle._ensureStarted();
248
250
  return handle;
249
251
  }
@@ -222,7 +222,7 @@ export class Sandbox {
222
222
  * @internal
223
223
  */
224
224
  async _runWs(command, options = {}) {
225
- const { timeout = 60, env, cwd, shell = "/bin/bash", onStdout, onStderr, idleTimeout, killOnDisconnect, ttlSeconds, pty, } = options;
225
+ const { timeout = 60, env, cwd, shell = "/bin/bash", onStdout, onStderr, commandId, idleTimeout, killOnDisconnect, ttlSeconds, pty, } = options;
226
226
  const dataplaneUrl = this.requireDataplaneUrl();
227
227
  const clientHeaders = this._client.getDefaultHeaders();
228
228
  const [stream, control] = await runWsStream(dataplaneUrl, this._client.getApiKey(), command, {
@@ -230,8 +230,7 @@ export class Sandbox {
230
230
  env,
231
231
  cwd,
232
232
  shell,
233
- onStdout,
234
- onStderr,
233
+ commandId,
235
234
  idleTimeout,
236
235
  killOnDisconnect,
237
236
  ttlSeconds,
@@ -240,7 +239,10 @@ export class Sandbox {
240
239
  ? { headers: clientHeaders }
241
240
  : {}),
242
241
  });
243
- const handle = new CommandHandle(stream, control, this);
242
+ const handle = new CommandHandle(stream, control, this, {
243
+ onStdout,
244
+ onStderr,
245
+ });
244
246
  await handle._ensureStarted();
245
247
  return handle;
246
248
  }
@@ -202,6 +202,12 @@ export interface RunOptions {
202
202
  * When false, returns a CommandHandle for streaming output.
203
203
  */
204
204
  wait?: boolean;
205
+ /**
206
+ * Client-assigned command ID. Executing with an existing command ID
207
+ * re-attaches to that command (get-or-create) instead of starting a
208
+ * new one. Only used by the WebSocket path.
209
+ */
210
+ commandId?: string;
205
211
  /**
206
212
  * Callback invoked with each stdout chunk during streaming execution.
207
213
  * When provided, WebSocket streaming is used.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "files": [
@@ -128,8 +128,8 @@
128
128
  "watch:single": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --watch --config jest.config.cjs --testTimeout 100000",
129
129
  "test:vitest": "vitest run --config vitest.config.ts",
130
130
  "test:eval:vitest": "vitest run --config ls.vitest.config.ts",
131
- "lint": "oxlint src/",
132
- "lint:fix": "oxlint --fix src/",
131
+ "lint": "oxlint src/ --ignore-pattern 'src/_openapi_client/**'",
132
+ "lint:fix": "oxlint --fix src/ --ignore-pattern 'src/_openapi_client/**'",
133
133
  "format": "oxfmt --write 'src/**/*.{ts,tsx,mts}'",
134
134
  "format:check": "oxfmt --check 'src/**/*.{ts,tsx,mts}'",
135
135
  "check:types": "tsc --noEmit",