langsmith 0.5.9 → 0.5.11
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/client.cjs +34 -11
- package/dist/client.js +34 -11
- package/dist/experimental/anthropic/index.cjs +1 -15
- package/dist/experimental/anthropic/index.js +1 -15
- package/dist/experimental/sandbox/client.cjs +7 -0
- package/dist/experimental/sandbox/client.js +7 -0
- package/dist/experimental/sandbox/command_handle.cjs +325 -0
- package/dist/experimental/sandbox/command_handle.d.ts +98 -0
- package/dist/experimental/sandbox/command_handle.js +321 -0
- package/dist/experimental/sandbox/errors.cjs +30 -1
- package/dist/experimental/sandbox/errors.d.ts +15 -0
- package/dist/experimental/sandbox/errors.js +27 -0
- package/dist/experimental/sandbox/index.cjs +5 -1
- package/dist/experimental/sandbox/index.d.ts +3 -2
- package/dist/experimental/sandbox/index.js +3 -2
- package/dist/experimental/sandbox/sandbox.cjs +91 -28
- package/dist/experimental/sandbox/sandbox.d.ts +43 -19
- package/dist/experimental/sandbox/sandbox.js +91 -28
- package/dist/experimental/sandbox/types.d.ts +93 -0
- package/dist/experimental/sandbox/ws_execute.cjs +350 -0
- package/dist/experimental/sandbox/ws_execute.d.ts +70 -0
- package/dist/experimental/sandbox/ws_execute.js +341 -0
- package/dist/experimental/vercel/index.cjs +5 -23
- package/dist/experimental/vercel/index.js +5 -23
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommandHandle - async handle to a running command with streaming output
|
|
3
|
+
* and auto-reconnect.
|
|
4
|
+
*
|
|
5
|
+
* Port of Python's AsyncCommandHandle to TypeScript.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExecutionResult, OutputChunk } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Async handle to a running command with streaming output and auto-reconnect.
|
|
10
|
+
*
|
|
11
|
+
* Async iterable, yielding OutputChunk objects (stdout and stderr interleaved
|
|
12
|
+
* in arrival order). Access .result after iteration to get the full
|
|
13
|
+
* ExecutionResult.
|
|
14
|
+
*
|
|
15
|
+
* Auto-reconnect behavior:
|
|
16
|
+
* - Server hot-reload (1001 Going Away): reconnect immediately
|
|
17
|
+
* - Network error / unexpected close: reconnect with exponential backoff
|
|
18
|
+
* - User called kill(): do NOT reconnect (propagate error)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const handle = await sandbox.run("make build", { timeout: 600, wait: false });
|
|
23
|
+
*
|
|
24
|
+
* for await (const chunk of handle) { // auto-reconnects on transient errors
|
|
25
|
+
* process.stdout.write(chunk.data);
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* const result = await handle.result;
|
|
29
|
+
* console.log(`Exit code: ${result.exit_code}`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class CommandHandle {
|
|
33
|
+
static MAX_AUTO_RECONNECTS: number;
|
|
34
|
+
static BACKOFF_BASE: number;
|
|
35
|
+
static BACKOFF_MAX: number;
|
|
36
|
+
private _stream;
|
|
37
|
+
private _control;
|
|
38
|
+
private _sandbox;
|
|
39
|
+
private _commandId;
|
|
40
|
+
private _pid;
|
|
41
|
+
private _result;
|
|
42
|
+
private _stdoutParts;
|
|
43
|
+
private _stderrParts;
|
|
44
|
+
private _exhausted;
|
|
45
|
+
private _lastStdoutOffset;
|
|
46
|
+
private _lastStderrOffset;
|
|
47
|
+
private _started;
|
|
48
|
+
/**
|
|
49
|
+
* Read the 'started' message to populate commandId and pid.
|
|
50
|
+
*
|
|
51
|
+
* Must be called (and awaited) before iterating for new executions.
|
|
52
|
+
*/
|
|
53
|
+
_ensureStarted(): Promise<void>;
|
|
54
|
+
/** The server-assigned command ID. Available after _ensureStarted(). */
|
|
55
|
+
get commandId(): string | null;
|
|
56
|
+
/** The process ID on the sandbox. Available after _ensureStarted(). */
|
|
57
|
+
get pid(): number | null;
|
|
58
|
+
/**
|
|
59
|
+
* The final execution result. Drains the stream if not already exhausted.
|
|
60
|
+
*/
|
|
61
|
+
get result(): Promise<ExecutionResult>;
|
|
62
|
+
private _getResult;
|
|
63
|
+
/**
|
|
64
|
+
* Iterate over output chunks from the current stream (no reconnect).
|
|
65
|
+
*/
|
|
66
|
+
private _iterStream;
|
|
67
|
+
/**
|
|
68
|
+
* Async iterate over output chunks with auto-reconnect on transient errors.
|
|
69
|
+
*
|
|
70
|
+
* Reconnect strategy:
|
|
71
|
+
* - 1001 Going Away (hot-reload): immediate reconnect, no delay
|
|
72
|
+
* - Other SandboxConnectionError: exponential backoff (0.5s, 1s, 2s...)
|
|
73
|
+
* - After kill(): no reconnect, error propagates
|
|
74
|
+
*/
|
|
75
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<OutputChunk>;
|
|
76
|
+
/**
|
|
77
|
+
* Send a kill signal to the running command (SIGKILL).
|
|
78
|
+
*
|
|
79
|
+
* The server kills the entire process group. The stream will
|
|
80
|
+
* subsequently yield an exit message with a non-zero exit code.
|
|
81
|
+
*/
|
|
82
|
+
kill(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Write data to the command's stdin.
|
|
85
|
+
*/
|
|
86
|
+
sendInput(data: string): void;
|
|
87
|
+
/** Last known stdout byte offset (for manual reconnection). */
|
|
88
|
+
get lastStdoutOffset(): number;
|
|
89
|
+
/** Last known stderr byte offset (for manual reconnection). */
|
|
90
|
+
get lastStderrOffset(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Reconnect to this command from the last known offsets.
|
|
93
|
+
*
|
|
94
|
+
* Returns a new CommandHandle that resumes output from where this one
|
|
95
|
+
* left off.
|
|
96
|
+
*/
|
|
97
|
+
reconnect(): Promise<CommandHandle>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommandHandle - async handle to a running command with streaming output
|
|
3
|
+
* and auto-reconnect.
|
|
4
|
+
*
|
|
5
|
+
* Port of Python's AsyncCommandHandle to TypeScript.
|
|
6
|
+
*/
|
|
7
|
+
import { LangSmithSandboxConnectionError, LangSmithSandboxOperationError, } from "./errors.js";
|
|
8
|
+
/**
|
|
9
|
+
* Async handle to a running command with streaming output and auto-reconnect.
|
|
10
|
+
*
|
|
11
|
+
* Async iterable, yielding OutputChunk objects (stdout and stderr interleaved
|
|
12
|
+
* in arrival order). Access .result after iteration to get the full
|
|
13
|
+
* ExecutionResult.
|
|
14
|
+
*
|
|
15
|
+
* Auto-reconnect behavior:
|
|
16
|
+
* - Server hot-reload (1001 Going Away): reconnect immediately
|
|
17
|
+
* - Network error / unexpected close: reconnect with exponential backoff
|
|
18
|
+
* - User called kill(): do NOT reconnect (propagate error)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const handle = await sandbox.run("make build", { timeout: 600, wait: false });
|
|
23
|
+
*
|
|
24
|
+
* for await (const chunk of handle) { // auto-reconnects on transient errors
|
|
25
|
+
* process.stdout.write(chunk.data);
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* const result = await handle.result;
|
|
29
|
+
* console.log(`Exit code: ${result.exit_code}`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class CommandHandle {
|
|
33
|
+
/** @internal */
|
|
34
|
+
constructor(messageStream, control, sandbox, options) {
|
|
35
|
+
Object.defineProperty(this, "_stream", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: void 0
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "_control", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(this, "_sandbox", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(this, "_commandId", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: null
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(this, "_pid", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: null
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(this, "_result", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: null
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, "_stdoutParts", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: []
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(this, "_stderrParts", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: []
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(this, "_exhausted", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true,
|
|
86
|
+
writable: true,
|
|
87
|
+
value: false
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(this, "_lastStdoutOffset", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(this, "_lastStderrOffset", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
value: void 0
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(this, "_started", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
configurable: true,
|
|
104
|
+
writable: true,
|
|
105
|
+
value: void 0
|
|
106
|
+
});
|
|
107
|
+
this._stream = messageStream;
|
|
108
|
+
this._control = control;
|
|
109
|
+
this._sandbox = sandbox;
|
|
110
|
+
this._lastStdoutOffset = options?.stdoutOffset ?? 0;
|
|
111
|
+
this._lastStderrOffset = options?.stderrOffset ?? 0;
|
|
112
|
+
// New executions (no commandId): _ensureStarted reads "started".
|
|
113
|
+
// Reconnections (commandId set): skip since reconnect streams
|
|
114
|
+
// don't send a "started" message.
|
|
115
|
+
if (options?.commandId) {
|
|
116
|
+
this._commandId = options.commandId;
|
|
117
|
+
this._started = true;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this._started = false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Read the 'started' message to populate commandId and pid.
|
|
125
|
+
*
|
|
126
|
+
* Must be called (and awaited) before iterating for new executions.
|
|
127
|
+
*/
|
|
128
|
+
async _ensureStarted() {
|
|
129
|
+
if (this._started)
|
|
130
|
+
return;
|
|
131
|
+
const firstResult = await this._stream.next();
|
|
132
|
+
if (firstResult.done) {
|
|
133
|
+
throw new LangSmithSandboxOperationError("Command stream ended before 'started' message", "command");
|
|
134
|
+
}
|
|
135
|
+
const firstMsg = firstResult.value;
|
|
136
|
+
if (firstMsg.type !== "started") {
|
|
137
|
+
throw new LangSmithSandboxOperationError(`Expected 'started' message, got '${firstMsg.type}'`, "command");
|
|
138
|
+
}
|
|
139
|
+
this._commandId = firstMsg.command_id ?? null;
|
|
140
|
+
this._pid = firstMsg.pid ?? null;
|
|
141
|
+
this._started = true;
|
|
142
|
+
}
|
|
143
|
+
/** The server-assigned command ID. Available after _ensureStarted(). */
|
|
144
|
+
get commandId() {
|
|
145
|
+
return this._commandId;
|
|
146
|
+
}
|
|
147
|
+
/** The process ID on the sandbox. Available after _ensureStarted(). */
|
|
148
|
+
get pid() {
|
|
149
|
+
return this._pid;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The final execution result. Drains the stream if not already exhausted.
|
|
153
|
+
*/
|
|
154
|
+
get result() {
|
|
155
|
+
return this._getResult();
|
|
156
|
+
}
|
|
157
|
+
async _getResult() {
|
|
158
|
+
if (this._result === null) {
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
160
|
+
for await (const _ of this) {
|
|
161
|
+
// drain
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (this._result === null) {
|
|
165
|
+
throw new LangSmithSandboxOperationError("Command stream ended without exit message", "command");
|
|
166
|
+
}
|
|
167
|
+
return this._result;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Iterate over output chunks from the current stream (no reconnect).
|
|
171
|
+
*/
|
|
172
|
+
async *_iterStream() {
|
|
173
|
+
await this._ensureStarted();
|
|
174
|
+
if (this._exhausted)
|
|
175
|
+
return;
|
|
176
|
+
for await (const msg of this._stream) {
|
|
177
|
+
const msgType = msg.type;
|
|
178
|
+
if (msgType === "stdout" || msgType === "stderr") {
|
|
179
|
+
const chunk = {
|
|
180
|
+
stream: msgType,
|
|
181
|
+
data: msg.data,
|
|
182
|
+
offset: msg.offset ?? 0,
|
|
183
|
+
};
|
|
184
|
+
if (msgType === "stdout") {
|
|
185
|
+
this._stdoutParts.push(msg.data);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this._stderrParts.push(msg.data);
|
|
189
|
+
}
|
|
190
|
+
yield chunk;
|
|
191
|
+
}
|
|
192
|
+
else if (msgType === "exit") {
|
|
193
|
+
this._result = {
|
|
194
|
+
stdout: this._stdoutParts.join(""),
|
|
195
|
+
stderr: this._stderrParts.join(""),
|
|
196
|
+
exit_code: msg.exit_code ?? -1,
|
|
197
|
+
};
|
|
198
|
+
this._exhausted = true;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
this._exhausted = true;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Async iterate over output chunks with auto-reconnect on transient errors.
|
|
206
|
+
*
|
|
207
|
+
* Reconnect strategy:
|
|
208
|
+
* - 1001 Going Away (hot-reload): immediate reconnect, no delay
|
|
209
|
+
* - Other SandboxConnectionError: exponential backoff (0.5s, 1s, 2s...)
|
|
210
|
+
* - After kill(): no reconnect, error propagates
|
|
211
|
+
*/
|
|
212
|
+
async *[Symbol.asyncIterator]() {
|
|
213
|
+
let reconnectAttempts = 0;
|
|
214
|
+
while (true) {
|
|
215
|
+
try {
|
|
216
|
+
for await (const chunk of this._iterStream()) {
|
|
217
|
+
reconnectAttempts = 0; // Reset on successful data
|
|
218
|
+
if (chunk.stream === "stdout") {
|
|
219
|
+
this._lastStdoutOffset =
|
|
220
|
+
chunk.offset + new TextEncoder().encode(chunk.data).length;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this._lastStderrOffset =
|
|
224
|
+
chunk.offset + new TextEncoder().encode(chunk.data).length;
|
|
225
|
+
}
|
|
226
|
+
yield chunk;
|
|
227
|
+
}
|
|
228
|
+
return; // Stream ended normally (exit message received)
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
const eName = e != null && typeof e === "object" ? e.name : "";
|
|
232
|
+
if (eName !== "LangSmithSandboxConnectionError" &&
|
|
233
|
+
eName !== "LangSmithSandboxServerReloadError") {
|
|
234
|
+
throw e;
|
|
235
|
+
}
|
|
236
|
+
if (this._control && this._control.killed) {
|
|
237
|
+
throw e;
|
|
238
|
+
}
|
|
239
|
+
reconnectAttempts++;
|
|
240
|
+
if (reconnectAttempts > CommandHandle.MAX_AUTO_RECONNECTS) {
|
|
241
|
+
throw new LangSmithSandboxConnectionError(`Lost connection ${reconnectAttempts} times in succession, giving up`);
|
|
242
|
+
}
|
|
243
|
+
const isHotReload = eName === "LangSmithSandboxServerReloadError";
|
|
244
|
+
if (!isHotReload) {
|
|
245
|
+
const delay = Math.min(CommandHandle.BACKOFF_BASE * 2 ** (reconnectAttempts - 1), CommandHandle.BACKOFF_MAX);
|
|
246
|
+
await new Promise((r) => setTimeout(r, delay * 1000));
|
|
247
|
+
}
|
|
248
|
+
if (this._commandId === null) {
|
|
249
|
+
throw e;
|
|
250
|
+
}
|
|
251
|
+
const newHandle = await this._sandbox.reconnect(this._commandId, {
|
|
252
|
+
stdoutOffset: this._lastStdoutOffset,
|
|
253
|
+
stderrOffset: this._lastStderrOffset,
|
|
254
|
+
});
|
|
255
|
+
this._stream = newHandle._stream;
|
|
256
|
+
this._control = newHandle._control;
|
|
257
|
+
this._exhausted = false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Send a kill signal to the running command (SIGKILL).
|
|
263
|
+
*
|
|
264
|
+
* The server kills the entire process group. The stream will
|
|
265
|
+
* subsequently yield an exit message with a non-zero exit code.
|
|
266
|
+
*/
|
|
267
|
+
kill() {
|
|
268
|
+
if (this._control) {
|
|
269
|
+
this._control.sendKill();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Write data to the command's stdin.
|
|
274
|
+
*/
|
|
275
|
+
sendInput(data) {
|
|
276
|
+
if (this._control) {
|
|
277
|
+
this._control.sendInput(data);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/** Last known stdout byte offset (for manual reconnection). */
|
|
281
|
+
get lastStdoutOffset() {
|
|
282
|
+
return this._lastStdoutOffset;
|
|
283
|
+
}
|
|
284
|
+
/** Last known stderr byte offset (for manual reconnection). */
|
|
285
|
+
get lastStderrOffset() {
|
|
286
|
+
return this._lastStderrOffset;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Reconnect to this command from the last known offsets.
|
|
290
|
+
*
|
|
291
|
+
* Returns a new CommandHandle that resumes output from where this one
|
|
292
|
+
* left off.
|
|
293
|
+
*/
|
|
294
|
+
async reconnect() {
|
|
295
|
+
if (this._commandId === null) {
|
|
296
|
+
throw new LangSmithSandboxOperationError("Cannot reconnect: command ID not available", "reconnect");
|
|
297
|
+
}
|
|
298
|
+
return this._sandbox.reconnect(this._commandId, {
|
|
299
|
+
stdoutOffset: this._lastStdoutOffset,
|
|
300
|
+
stderrOffset: this._lastStderrOffset,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
Object.defineProperty(CommandHandle, "MAX_AUTO_RECONNECTS", {
|
|
305
|
+
enumerable: true,
|
|
306
|
+
configurable: true,
|
|
307
|
+
writable: true,
|
|
308
|
+
value: 5
|
|
309
|
+
});
|
|
310
|
+
Object.defineProperty(CommandHandle, "BACKOFF_BASE", {
|
|
311
|
+
enumerable: true,
|
|
312
|
+
configurable: true,
|
|
313
|
+
writable: true,
|
|
314
|
+
value: 0.5
|
|
315
|
+
}); // seconds
|
|
316
|
+
Object.defineProperty(CommandHandle, "BACKOFF_MAX", {
|
|
317
|
+
enumerable: true,
|
|
318
|
+
configurable: true,
|
|
319
|
+
writable: true,
|
|
320
|
+
value: 8.0
|
|
321
|
+
}); // seconds
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* properties for specific handling when needed.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = void 0;
|
|
10
|
+
exports.LangSmithSandboxServerReloadError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = void 0;
|
|
11
11
|
/**
|
|
12
12
|
* Base exception for sandbox client errors.
|
|
13
13
|
*/
|
|
@@ -340,3 +340,32 @@ class LangSmithSandboxOperationError extends LangSmithSandboxError {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
exports.LangSmithSandboxOperationError = LangSmithSandboxOperationError;
|
|
343
|
+
/**
|
|
344
|
+
* Raised when a command exceeds its timeout.
|
|
345
|
+
*/
|
|
346
|
+
class LangSmithCommandTimeoutError extends LangSmithSandboxOperationError {
|
|
347
|
+
constructor(message, timeout) {
|
|
348
|
+
super(message, "command", "CommandTimeout");
|
|
349
|
+
Object.defineProperty(this, "timeout", {
|
|
350
|
+
enumerable: true,
|
|
351
|
+
configurable: true,
|
|
352
|
+
writable: true,
|
|
353
|
+
value: void 0
|
|
354
|
+
});
|
|
355
|
+
this.name = "LangSmithCommandTimeoutError";
|
|
356
|
+
this.timeout = timeout;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
exports.LangSmithCommandTimeoutError = LangSmithCommandTimeoutError;
|
|
360
|
+
/**
|
|
361
|
+
* Raised when the sandbox server is reloading (close code 1001).
|
|
362
|
+
*
|
|
363
|
+
* Subclass of connection error that signals immediate reconnect (no backoff).
|
|
364
|
+
*/
|
|
365
|
+
class LangSmithSandboxServerReloadError extends LangSmithSandboxConnectionError {
|
|
366
|
+
constructor(message) {
|
|
367
|
+
super(message);
|
|
368
|
+
this.name = "LangSmithSandboxServerReloadError";
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
exports.LangSmithSandboxServerReloadError = LangSmithSandboxServerReloadError;
|
|
@@ -147,3 +147,18 @@ export declare class LangSmithSandboxOperationError extends LangSmithSandboxErro
|
|
|
147
147
|
constructor(message: string, operation?: string, errorType?: string);
|
|
148
148
|
toString(): string;
|
|
149
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Raised when a command exceeds its timeout.
|
|
152
|
+
*/
|
|
153
|
+
export declare class LangSmithCommandTimeoutError extends LangSmithSandboxOperationError {
|
|
154
|
+
timeout?: number;
|
|
155
|
+
constructor(message: string, timeout?: number);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Raised when the sandbox server is reloading (close code 1001).
|
|
159
|
+
*
|
|
160
|
+
* Subclass of connection error that signals immediate reconnect (no backoff).
|
|
161
|
+
*/
|
|
162
|
+
export declare class LangSmithSandboxServerReloadError extends LangSmithSandboxConnectionError {
|
|
163
|
+
constructor(message: string);
|
|
164
|
+
}
|
|
@@ -321,3 +321,30 @@ export class LangSmithSandboxOperationError extends LangSmithSandboxError {
|
|
|
321
321
|
return super.toString();
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Raised when a command exceeds its timeout.
|
|
326
|
+
*/
|
|
327
|
+
export class LangSmithCommandTimeoutError extends LangSmithSandboxOperationError {
|
|
328
|
+
constructor(message, timeout) {
|
|
329
|
+
super(message, "command", "CommandTimeout");
|
|
330
|
+
Object.defineProperty(this, "timeout", {
|
|
331
|
+
enumerable: true,
|
|
332
|
+
configurable: true,
|
|
333
|
+
writable: true,
|
|
334
|
+
value: void 0
|
|
335
|
+
});
|
|
336
|
+
this.name = "LangSmithCommandTimeoutError";
|
|
337
|
+
this.timeout = timeout;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Raised when the sandbox server is reloading (close code 1001).
|
|
342
|
+
*
|
|
343
|
+
* Subclass of connection error that signals immediate reconnect (no backoff).
|
|
344
|
+
*/
|
|
345
|
+
export class LangSmithSandboxServerReloadError extends LangSmithSandboxConnectionError {
|
|
346
|
+
constructor(message) {
|
|
347
|
+
super(message);
|
|
348
|
+
this.name = "LangSmithSandboxServerReloadError";
|
|
349
|
+
}
|
|
350
|
+
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @packageDocumentation
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.Sandbox = exports.SandboxClient = void 0;
|
|
27
|
+
exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.CommandHandle = exports.Sandbox = exports.SandboxClient = void 0;
|
|
28
28
|
// Emit warning on import (alpha feature)
|
|
29
29
|
console.warn("langsmith/experimental/sandbox is in alpha. " +
|
|
30
30
|
"This feature is experimental, and breaking changes are expected.");
|
|
@@ -33,6 +33,8 @@ var client_js_1 = require("./client.cjs");
|
|
|
33
33
|
Object.defineProperty(exports, "SandboxClient", { enumerable: true, get: function () { return client_js_1.SandboxClient; } });
|
|
34
34
|
var sandbox_js_1 = require("./sandbox.cjs");
|
|
35
35
|
Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return sandbox_js_1.Sandbox; } });
|
|
36
|
+
var command_handle_js_1 = require("./command_handle.cjs");
|
|
37
|
+
Object.defineProperty(exports, "CommandHandle", { enumerable: true, get: function () { return command_handle_js_1.CommandHandle; } });
|
|
36
38
|
// Errors
|
|
37
39
|
var errors_js_1 = require("./errors.cjs");
|
|
38
40
|
// Base and connection errors
|
|
@@ -40,6 +42,7 @@ Object.defineProperty(exports, "LangSmithSandboxError", { enumerable: true, get:
|
|
|
40
42
|
Object.defineProperty(exports, "LangSmithSandboxAPIError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxAPIError; } });
|
|
41
43
|
Object.defineProperty(exports, "LangSmithSandboxAuthenticationError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxAuthenticationError; } });
|
|
42
44
|
Object.defineProperty(exports, "LangSmithSandboxConnectionError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxConnectionError; } });
|
|
45
|
+
Object.defineProperty(exports, "LangSmithSandboxServerReloadError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxServerReloadError; } });
|
|
43
46
|
// Resource errors (type-based with resourceType attribute)
|
|
44
47
|
Object.defineProperty(exports, "LangSmithResourceNotFoundError", { enumerable: true, get: function () { return errors_js_1.LangSmithResourceNotFoundError; } });
|
|
45
48
|
Object.defineProperty(exports, "LangSmithResourceTimeoutError", { enumerable: true, get: function () { return errors_js_1.LangSmithResourceTimeoutError; } });
|
|
@@ -55,4 +58,5 @@ Object.defineProperty(exports, "LangSmithResourceCreationError", { enumerable: t
|
|
|
55
58
|
Object.defineProperty(exports, "LangSmithSandboxCreationError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxCreationError; } });
|
|
56
59
|
Object.defineProperty(exports, "LangSmithSandboxNotReadyError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxNotReadyError; } });
|
|
57
60
|
Object.defineProperty(exports, "LangSmithSandboxOperationError", { enumerable: true, get: function () { return errors_js_1.LangSmithSandboxOperationError; } });
|
|
61
|
+
Object.defineProperty(exports, "LangSmithCommandTimeoutError", { enumerable: true, get: function () { return errors_js_1.LangSmithCommandTimeoutError; } });
|
|
58
62
|
Object.defineProperty(exports, "LangSmithDataplaneNotConfiguredError", { enumerable: true, get: function () { return errors_js_1.LangSmithDataplaneNotConfiguredError; } });
|
|
@@ -24,5 +24,6 @@
|
|
|
24
24
|
*/
|
|
25
25
|
export { SandboxClient } from "./client.js";
|
|
26
26
|
export { Sandbox } from "./sandbox.js";
|
|
27
|
-
export
|
|
28
|
-
export {
|
|
27
|
+
export { CommandHandle } from "./command_handle.js";
|
|
28
|
+
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceSpec, ResourceStatus, VolumeMountSpec, Volume, SandboxTemplate, Pool, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, WaitForSandboxOptions, CreateVolumeOptions, CreateTemplateOptions, UpdateTemplateOptions, CreatePoolOptions, UpdateVolumeOptions, UpdatePoolOptions, } from "./types.js";
|
|
29
|
+
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
|
@@ -28,10 +28,11 @@ console.warn("langsmith/experimental/sandbox is in alpha. " +
|
|
|
28
28
|
// Main classes
|
|
29
29
|
export { SandboxClient } from "./client.js";
|
|
30
30
|
export { Sandbox } from "./sandbox.js";
|
|
31
|
+
export { CommandHandle } from "./command_handle.js";
|
|
31
32
|
// Errors
|
|
32
33
|
export {
|
|
33
34
|
// Base and connection errors
|
|
34
|
-
LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError,
|
|
35
|
+
LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxServerReloadError,
|
|
35
36
|
// Resource errors (type-based with resourceType attribute)
|
|
36
37
|
LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError,
|
|
37
38
|
// Validation and quota errors
|
|
@@ -39,4 +40,4 @@ LangSmithValidationError, LangSmithQuotaExceededError,
|
|
|
39
40
|
// Resource creation errors
|
|
40
41
|
LangSmithResourceCreationError,
|
|
41
42
|
// Sandbox-specific errors
|
|
42
|
-
LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
|
43
|
+
LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|