langsmith 0.5.13 → 0.5.15
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/experimental/anthropic/context.cjs +23 -15
- package/dist/experimental/anthropic/context.js +23 -15
- package/dist/experimental/anthropic/messages.cjs +1 -1
- package/dist/experimental/anthropic/messages.js +1 -1
- package/dist/experimental/sandbox/client.cjs +35 -13
- package/dist/experimental/sandbox/client.d.ts +12 -3
- package/dist/experimental/sandbox/client.js +36 -14
- package/dist/experimental/sandbox/helpers.cjs +22 -0
- package/dist/experimental/sandbox/helpers.d.ts +8 -0
- package/dist/experimental/sandbox/helpers.js +21 -0
- package/dist/experimental/sandbox/index.d.ts +1 -1
- package/dist/experimental/sandbox/sandbox.cjs +24 -0
- package/dist/experimental/sandbox/sandbox.d.ts +6 -0
- package/dist/experimental/sandbox/sandbox.js +24 -0
- package/dist/experimental/sandbox/types.d.ts +32 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/wrappers/gemini.cjs +1 -1
- package/dist/wrappers/gemini.js +1 -1
- package/package.json +5 -5
|
@@ -57,7 +57,7 @@ class StreamManager {
|
|
|
57
57
|
return;
|
|
58
58
|
if (message.type === "result") {
|
|
59
59
|
if (message.modelUsage) {
|
|
60
|
-
(0, usage_js_1.correctUsageFromResults)(message.modelUsage, Object.values(this.assistant));
|
|
60
|
+
(0, usage_js_1.correctUsageFromResults)(message.modelUsage, Object.values(this.assistant).filter((runTree) => runTree != null));
|
|
61
61
|
}
|
|
62
62
|
const usage = message.modelUsage
|
|
63
63
|
? (0, usage_js_1.aggregateUsageFromModelUsage)(message.modelUsage)
|
|
@@ -100,6 +100,8 @@ class StreamManager {
|
|
|
100
100
|
},
|
|
101
101
|
outputs: { output: { messages: [] } },
|
|
102
102
|
});
|
|
103
|
+
if (this.assistant[messageId] == null)
|
|
104
|
+
return;
|
|
103
105
|
this.assistant[messageId].outputs = (() => {
|
|
104
106
|
const prevMessages = this.assistant[messageId].outputs?.output.messages ?? [];
|
|
105
107
|
const newMessages = (0, messages_js_1.convertFromAnthropicMessage)([message]);
|
|
@@ -125,22 +127,24 @@ class StreamManager {
|
|
|
125
127
|
? block.input.description.split(" ")[0]
|
|
126
128
|
: null) ||
|
|
127
129
|
"unknown-agent";
|
|
128
|
-
this.tools[block.id] ??=
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
this.tools[block.id] ??=
|
|
131
|
+
this.createChild("root", {
|
|
132
|
+
name,
|
|
133
|
+
run_type: "chain",
|
|
134
|
+
inputs: block.input,
|
|
135
|
+
start_time: eventTime,
|
|
136
|
+
}) ?? this.tools[block.id];
|
|
134
137
|
this.namespaces[block.id] ??= this.tools[block.id];
|
|
135
138
|
}
|
|
136
139
|
else {
|
|
137
140
|
const name = block.name || "unknown-tool";
|
|
138
|
-
this.tools[block.id] ??=
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
this.tools[block.id] ??=
|
|
142
|
+
this.createChild(namespace, {
|
|
143
|
+
name,
|
|
144
|
+
run_type: "tool",
|
|
145
|
+
inputs: block.input ? { input: block.input } : {},
|
|
146
|
+
start_time: eventTime,
|
|
147
|
+
}) ?? this.tools[block.id];
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
}
|
|
@@ -174,14 +178,16 @@ class StreamManager {
|
|
|
174
178
|
const toolError = "is_error" in block && block.is_error === true
|
|
175
179
|
? getToolError(result)
|
|
176
180
|
: undefined;
|
|
177
|
-
void this.tools[block.tool_use_id]
|
|
181
|
+
void this.tools[block.tool_use_id]?.end(toolOutput, toolError);
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
}
|
|
181
185
|
this.history[namespace].push(message);
|
|
182
186
|
}
|
|
183
187
|
createChild(namespace, args) {
|
|
184
|
-
const runTree = this.namespaces[namespace]
|
|
188
|
+
const runTree = this.namespaces[namespace]?.createChild(args);
|
|
189
|
+
if (runTree == null)
|
|
190
|
+
return undefined;
|
|
185
191
|
this.postRunQueue.push(runTree.postRun());
|
|
186
192
|
this.runTrees.push(runTree);
|
|
187
193
|
return runTree;
|
|
@@ -189,6 +195,8 @@ class StreamManager {
|
|
|
189
195
|
async finish() {
|
|
190
196
|
// Clean up incomplete tools and subagent calls
|
|
191
197
|
for (const tool of Object.values(this.tools)) {
|
|
198
|
+
if (tool == null)
|
|
199
|
+
continue;
|
|
192
200
|
if (tool.outputs == null && tool.error == null) {
|
|
193
201
|
void tool.end(undefined, "Run not completed (conversation ended)");
|
|
194
202
|
}
|
|
@@ -54,7 +54,7 @@ export class StreamManager {
|
|
|
54
54
|
return;
|
|
55
55
|
if (message.type === "result") {
|
|
56
56
|
if (message.modelUsage) {
|
|
57
|
-
correctUsageFromResults(message.modelUsage, Object.values(this.assistant));
|
|
57
|
+
correctUsageFromResults(message.modelUsage, Object.values(this.assistant).filter((runTree) => runTree != null));
|
|
58
58
|
}
|
|
59
59
|
const usage = message.modelUsage
|
|
60
60
|
? aggregateUsageFromModelUsage(message.modelUsage)
|
|
@@ -97,6 +97,8 @@ export class StreamManager {
|
|
|
97
97
|
},
|
|
98
98
|
outputs: { output: { messages: [] } },
|
|
99
99
|
});
|
|
100
|
+
if (this.assistant[messageId] == null)
|
|
101
|
+
return;
|
|
100
102
|
this.assistant[messageId].outputs = (() => {
|
|
101
103
|
const prevMessages = this.assistant[messageId].outputs?.output.messages ?? [];
|
|
102
104
|
const newMessages = convertFromAnthropicMessage([message]);
|
|
@@ -122,22 +124,24 @@ export class StreamManager {
|
|
|
122
124
|
? block.input.description.split(" ")[0]
|
|
123
125
|
: null) ||
|
|
124
126
|
"unknown-agent";
|
|
125
|
-
this.tools[block.id] ??=
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
this.tools[block.id] ??=
|
|
128
|
+
this.createChild("root", {
|
|
129
|
+
name,
|
|
130
|
+
run_type: "chain",
|
|
131
|
+
inputs: block.input,
|
|
132
|
+
start_time: eventTime,
|
|
133
|
+
}) ?? this.tools[block.id];
|
|
131
134
|
this.namespaces[block.id] ??= this.tools[block.id];
|
|
132
135
|
}
|
|
133
136
|
else {
|
|
134
137
|
const name = block.name || "unknown-tool";
|
|
135
|
-
this.tools[block.id] ??=
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
this.tools[block.id] ??=
|
|
139
|
+
this.createChild(namespace, {
|
|
140
|
+
name,
|
|
141
|
+
run_type: "tool",
|
|
142
|
+
inputs: block.input ? { input: block.input } : {},
|
|
143
|
+
start_time: eventTime,
|
|
144
|
+
}) ?? this.tools[block.id];
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
}
|
|
@@ -171,14 +175,16 @@ export class StreamManager {
|
|
|
171
175
|
const toolError = "is_error" in block && block.is_error === true
|
|
172
176
|
? getToolError(result)
|
|
173
177
|
: undefined;
|
|
174
|
-
void this.tools[block.tool_use_id]
|
|
178
|
+
void this.tools[block.tool_use_id]?.end(toolOutput, toolError);
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
this.history[namespace].push(message);
|
|
179
183
|
}
|
|
180
184
|
createChild(namespace, args) {
|
|
181
|
-
const runTree = this.namespaces[namespace]
|
|
185
|
+
const runTree = this.namespaces[namespace]?.createChild(args);
|
|
186
|
+
if (runTree == null)
|
|
187
|
+
return undefined;
|
|
182
188
|
this.postRunQueue.push(runTree.postRun());
|
|
183
189
|
this.runTrees.push(runTree);
|
|
184
190
|
return runTree;
|
|
@@ -186,6 +192,8 @@ export class StreamManager {
|
|
|
186
192
|
async finish() {
|
|
187
193
|
// Clean up incomplete tools and subagent calls
|
|
188
194
|
for (const tool of Object.values(this.tools)) {
|
|
195
|
+
if (tool == null)
|
|
196
|
+
continue;
|
|
189
197
|
if (tool.outputs == null && tool.error == null) {
|
|
190
198
|
void tool.end(undefined, "Run not completed (conversation ended)");
|
|
191
199
|
}
|
|
@@ -89,7 +89,7 @@ function isToolResultBlock(block) {
|
|
|
89
89
|
* @internal
|
|
90
90
|
*/
|
|
91
91
|
function isTaskTool(tool) {
|
|
92
|
-
return tool.type === "tool_use" && tool.name === "Task";
|
|
92
|
+
return (tool.type === "tool_use" && (tool.name === "Task" || tool.name === "Agent"));
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Type-assertion to check for tool blocks
|
|
@@ -83,7 +83,7 @@ function isToolResultBlock(block) {
|
|
|
83
83
|
* @internal
|
|
84
84
|
*/
|
|
85
85
|
export function isTaskTool(tool) {
|
|
86
|
-
return tool.type === "tool_use" && tool.name === "Task";
|
|
86
|
+
return (tool.type === "tool_use" && (tool.name === "Task" || tool.name === "Agent"));
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Type-assertion to check for tool blocks
|
|
@@ -524,6 +524,7 @@ class SandboxClient {
|
|
|
524
524
|
* @returns Created Sandbox.
|
|
525
525
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
526
526
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
527
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
527
528
|
*
|
|
528
529
|
* @example
|
|
529
530
|
* ```typescript
|
|
@@ -537,7 +538,9 @@ class SandboxClient {
|
|
|
537
538
|
* ```
|
|
538
539
|
*/
|
|
539
540
|
async createSandbox(templateName, options = {}) {
|
|
540
|
-
const { name, timeout = 30, waitForReady = true } = options;
|
|
541
|
+
const { name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, } = options;
|
|
542
|
+
(0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
|
|
543
|
+
(0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
|
|
541
544
|
const url = `${this._baseUrl}/boxes`;
|
|
542
545
|
const payload = {
|
|
543
546
|
template_name: templateName,
|
|
@@ -549,6 +552,12 @@ class SandboxClient {
|
|
|
549
552
|
if (name) {
|
|
550
553
|
payload.name = name;
|
|
551
554
|
}
|
|
555
|
+
if (ttlSeconds !== undefined) {
|
|
556
|
+
payload.ttl_seconds = ttlSeconds;
|
|
557
|
+
}
|
|
558
|
+
if (idleTtlSeconds !== undefined) {
|
|
559
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
560
|
+
}
|
|
552
561
|
const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
|
|
553
562
|
const response = await this._fetch(url, {
|
|
554
563
|
method: "POST",
|
|
@@ -600,18 +609,29 @@ class SandboxClient {
|
|
|
600
609
|
const data = await response.json();
|
|
601
610
|
return (data.sandboxes ?? []).map((s) => new sandbox_js_1.Sandbox(s, this));
|
|
602
611
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
612
|
+
async updateSandbox(name, newNameOrOptions) {
|
|
613
|
+
const options = typeof newNameOrOptions === "string"
|
|
614
|
+
? { newName: newNameOrOptions }
|
|
615
|
+
: newNameOrOptions;
|
|
616
|
+
const { newName, ttlSeconds, idleTtlSeconds } = options;
|
|
617
|
+
(0, helpers_js_1.validateTtl)(ttlSeconds, "ttlSeconds");
|
|
618
|
+
(0, helpers_js_1.validateTtl)(idleTtlSeconds, "idleTtlSeconds");
|
|
619
|
+
if (newName === undefined &&
|
|
620
|
+
ttlSeconds === undefined &&
|
|
621
|
+
idleTtlSeconds === undefined) {
|
|
622
|
+
return this.getSandbox(name);
|
|
623
|
+
}
|
|
613
624
|
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
|
|
614
|
-
const payload = {
|
|
625
|
+
const payload = {};
|
|
626
|
+
if (newName !== undefined) {
|
|
627
|
+
payload.name = newName;
|
|
628
|
+
}
|
|
629
|
+
if (ttlSeconds !== undefined) {
|
|
630
|
+
payload.ttl_seconds = ttlSeconds;
|
|
631
|
+
}
|
|
632
|
+
if (idleTtlSeconds !== undefined) {
|
|
633
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
634
|
+
}
|
|
615
635
|
const response = await this._fetch(url, {
|
|
616
636
|
method: "PATCH",
|
|
617
637
|
headers: { "Content-Type": "application/json" },
|
|
@@ -622,7 +642,9 @@ class SandboxClient {
|
|
|
622
642
|
throw new errors_js_1.LangSmithResourceNotFoundError(`Sandbox '${name}' not found`, "sandbox");
|
|
623
643
|
}
|
|
624
644
|
if (response.status === 409) {
|
|
625
|
-
throw new errors_js_1.LangSmithResourceNameConflictError(
|
|
645
|
+
throw new errors_js_1.LangSmithResourceNameConflictError(newName !== undefined
|
|
646
|
+
? `Sandbox name '${newName}' already in use`
|
|
647
|
+
: "Sandbox update conflict (name may already be in use)", "sandbox");
|
|
626
648
|
}
|
|
627
649
|
await (0, helpers_js_1.handleClientHttpError)(response);
|
|
628
650
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main SandboxClient class for interacting with the sandbox server API.
|
|
3
3
|
*/
|
|
4
|
-
import type { CreatePoolOptions, CreateSandboxOptions, CreateTemplateOptions, CreateVolumeOptions, Pool, ResourceStatus, SandboxClientConfig, SandboxTemplate, UpdatePoolOptions, UpdateTemplateOptions, UpdateVolumeOptions, Volume, WaitForSandboxOptions } from "./types.js";
|
|
4
|
+
import type { CreatePoolOptions, CreateSandboxOptions, CreateTemplateOptions, CreateVolumeOptions, Pool, ResourceStatus, SandboxClientConfig, SandboxTemplate, UpdatePoolOptions, UpdateSandboxOptions, UpdateTemplateOptions, UpdateVolumeOptions, Volume, WaitForSandboxOptions } from "./types.js";
|
|
5
5
|
import { Sandbox } from "./sandbox.js";
|
|
6
6
|
/**
|
|
7
7
|
* Client for interacting with the Sandbox Server API.
|
|
@@ -191,6 +191,7 @@ export declare class SandboxClient {
|
|
|
191
191
|
* @returns Created Sandbox.
|
|
192
192
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
193
193
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
194
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
194
195
|
*
|
|
195
196
|
* @example
|
|
196
197
|
* ```typescript
|
|
@@ -225,11 +226,19 @@ export declare class SandboxClient {
|
|
|
225
226
|
*
|
|
226
227
|
* @param name - Current sandbox name.
|
|
227
228
|
* @param newName - New display name.
|
|
228
|
-
|
|
229
|
+
*/
|
|
230
|
+
updateSandbox(name: string, newName: string): Promise<Sandbox>;
|
|
231
|
+
/**
|
|
232
|
+
* Update a sandbox's name and/or TTL settings.
|
|
233
|
+
*
|
|
234
|
+
* @param name - Current sandbox name.
|
|
235
|
+
* @param options - Fields to update. Omit a field to leave it unchanged.
|
|
236
|
+
* @returns Updated Sandbox. If no fields are provided, returns the current sandbox.
|
|
229
237
|
* @throws LangSmithResourceNotFoundError if sandbox not found.
|
|
230
238
|
* @throws LangSmithResourceNameConflictError if newName is already in use.
|
|
239
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
231
240
|
*/
|
|
232
|
-
updateSandbox(name: string,
|
|
241
|
+
updateSandbox(name: string, options: UpdateSandboxOptions): Promise<Sandbox>;
|
|
233
242
|
/**
|
|
234
243
|
* Delete a Sandbox.
|
|
235
244
|
*
|
|
@@ -6,7 +6,7 @@ import { _getFetchImplementation } from "../../singletons/fetch.js";
|
|
|
6
6
|
import { AsyncCaller } from "../../utils/async_caller.js";
|
|
7
7
|
import { Sandbox } from "./sandbox.js";
|
|
8
8
|
import { LangSmithResourceCreationError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, } from "./errors.js";
|
|
9
|
-
import { handleClientHttpError, handleConflictError, handlePoolError, handleResourceInUseError, handleSandboxCreationError, handleVolumeCreationError, } from "./helpers.js";
|
|
9
|
+
import { handleClientHttpError, handleConflictError, handlePoolError, handleResourceInUseError, handleSandboxCreationError, handleVolumeCreationError, validateTtl, } from "./helpers.js";
|
|
10
10
|
/**
|
|
11
11
|
* Get the default sandbox API endpoint from environment.
|
|
12
12
|
*
|
|
@@ -521,6 +521,7 @@ export class SandboxClient {
|
|
|
521
521
|
* @returns Created Sandbox.
|
|
522
522
|
* @throws ResourceTimeoutError if timeout waiting for sandbox to be ready.
|
|
523
523
|
* @throws SandboxCreationError if sandbox creation fails.
|
|
524
|
+
* @throws LangSmithValidationError if TTL values are invalid.
|
|
524
525
|
*
|
|
525
526
|
* @example
|
|
526
527
|
* ```typescript
|
|
@@ -534,7 +535,9 @@ export class SandboxClient {
|
|
|
534
535
|
* ```
|
|
535
536
|
*/
|
|
536
537
|
async createSandbox(templateName, options = {}) {
|
|
537
|
-
const { name, timeout = 30, waitForReady = true } = options;
|
|
538
|
+
const { name, timeout = 30, waitForReady = true, ttlSeconds, idleTtlSeconds, } = options;
|
|
539
|
+
validateTtl(ttlSeconds, "ttlSeconds");
|
|
540
|
+
validateTtl(idleTtlSeconds, "idleTtlSeconds");
|
|
538
541
|
const url = `${this._baseUrl}/boxes`;
|
|
539
542
|
const payload = {
|
|
540
543
|
template_name: templateName,
|
|
@@ -546,6 +549,12 @@ export class SandboxClient {
|
|
|
546
549
|
if (name) {
|
|
547
550
|
payload.name = name;
|
|
548
551
|
}
|
|
552
|
+
if (ttlSeconds !== undefined) {
|
|
553
|
+
payload.ttl_seconds = ttlSeconds;
|
|
554
|
+
}
|
|
555
|
+
if (idleTtlSeconds !== undefined) {
|
|
556
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
557
|
+
}
|
|
549
558
|
const httpTimeout = waitForReady ? (timeout + 30) * 1000 : 30 * 1000;
|
|
550
559
|
const response = await this._fetch(url, {
|
|
551
560
|
method: "POST",
|
|
@@ -597,18 +606,29 @@ export class SandboxClient {
|
|
|
597
606
|
const data = await response.json();
|
|
598
607
|
return (data.sandboxes ?? []).map((s) => new Sandbox(s, this));
|
|
599
608
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
609
|
+
async updateSandbox(name, newNameOrOptions) {
|
|
610
|
+
const options = typeof newNameOrOptions === "string"
|
|
611
|
+
? { newName: newNameOrOptions }
|
|
612
|
+
: newNameOrOptions;
|
|
613
|
+
const { newName, ttlSeconds, idleTtlSeconds } = options;
|
|
614
|
+
validateTtl(ttlSeconds, "ttlSeconds");
|
|
615
|
+
validateTtl(idleTtlSeconds, "idleTtlSeconds");
|
|
616
|
+
if (newName === undefined &&
|
|
617
|
+
ttlSeconds === undefined &&
|
|
618
|
+
idleTtlSeconds === undefined) {
|
|
619
|
+
return this.getSandbox(name);
|
|
620
|
+
}
|
|
610
621
|
const url = `${this._baseUrl}/boxes/${encodeURIComponent(name)}`;
|
|
611
|
-
const payload = {
|
|
622
|
+
const payload = {};
|
|
623
|
+
if (newName !== undefined) {
|
|
624
|
+
payload.name = newName;
|
|
625
|
+
}
|
|
626
|
+
if (ttlSeconds !== undefined) {
|
|
627
|
+
payload.ttl_seconds = ttlSeconds;
|
|
628
|
+
}
|
|
629
|
+
if (idleTtlSeconds !== undefined) {
|
|
630
|
+
payload.idle_ttl_seconds = idleTtlSeconds;
|
|
631
|
+
}
|
|
612
632
|
const response = await this._fetch(url, {
|
|
613
633
|
method: "PATCH",
|
|
614
634
|
headers: { "Content-Type": "application/json" },
|
|
@@ -619,7 +639,9 @@ export class SandboxClient {
|
|
|
619
639
|
throw new LangSmithResourceNotFoundError(`Sandbox '${name}' not found`, "sandbox");
|
|
620
640
|
}
|
|
621
641
|
if (response.status === 409) {
|
|
622
|
-
throw new LangSmithResourceNameConflictError(
|
|
642
|
+
throw new LangSmithResourceNameConflictError(newName !== undefined
|
|
643
|
+
? `Sandbox name '${newName}' already in use`
|
|
644
|
+
: "Sandbox update conflict (name may already be in use)", "sandbox");
|
|
623
645
|
}
|
|
624
646
|
await handleClientHttpError(response);
|
|
625
647
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* exceptions. They contain no I/O operations.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.validateTtl = validateTtl;
|
|
9
10
|
exports.parseErrorResponse = parseErrorResponse;
|
|
10
11
|
exports.parseValidationError = parseValidationError;
|
|
11
12
|
exports.extractQuotaType = extractQuotaType;
|
|
@@ -17,6 +18,27 @@ exports.handleSandboxHttpError = handleSandboxHttpError;
|
|
|
17
18
|
exports.handleConflictError = handleConflictError;
|
|
18
19
|
exports.handleResourceInUseError = handleResourceInUseError;
|
|
19
20
|
const errors_js_1 = require("./errors.cjs");
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Input validation
|
|
23
|
+
// =============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Validate TTL values for sandbox create/update (minute resolution).
|
|
26
|
+
*
|
|
27
|
+
* @param value - TTL in seconds (`undefined` means unset; `0` disables).
|
|
28
|
+
* @param name - Parameter name for error messages.
|
|
29
|
+
* @throws LangSmithValidationError if negative or not a multiple of 60 (when non-zero).
|
|
30
|
+
*/
|
|
31
|
+
function validateTtl(value, name) {
|
|
32
|
+
if (value === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (value < 0) {
|
|
36
|
+
throw new errors_js_1.LangSmithValidationError(`${name} must be >= 0, got ${value}`, name);
|
|
37
|
+
}
|
|
38
|
+
if (value !== 0 && value % 60 !== 0) {
|
|
39
|
+
throw new errors_js_1.LangSmithValidationError(`${name} must be a multiple of 60 seconds, got ${value}`, name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
20
42
|
/**
|
|
21
43
|
* Parse standardized error response.
|
|
22
44
|
*
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* These functions are used to parse error responses and raise appropriate
|
|
5
5
|
* exceptions. They contain no I/O operations.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Validate TTL values for sandbox create/update (minute resolution).
|
|
9
|
+
*
|
|
10
|
+
* @param value - TTL in seconds (`undefined` means unset; `0` disables).
|
|
11
|
+
* @param name - Parameter name for error messages.
|
|
12
|
+
* @throws LangSmithValidationError if negative or not a multiple of 60 (when non-zero).
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateTtl(value: number | undefined, name: string): void;
|
|
7
15
|
interface ParsedError {
|
|
8
16
|
errorType?: string;
|
|
9
17
|
message: string;
|
|
@@ -5,6 +5,27 @@
|
|
|
5
5
|
* exceptions. They contain no I/O operations.
|
|
6
6
|
*/
|
|
7
7
|
import { LangSmithQuotaExceededError, LangSmithResourceAlreadyExistsError, LangSmithResourceInUseError, LangSmithResourceNameConflictError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxError, LangSmithSandboxConnectionError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithValidationError, } from "./errors.js";
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Input validation
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Validate TTL values for sandbox create/update (minute resolution).
|
|
13
|
+
*
|
|
14
|
+
* @param value - TTL in seconds (`undefined` means unset; `0` disables).
|
|
15
|
+
* @param name - Parameter name for error messages.
|
|
16
|
+
* @throws LangSmithValidationError if negative or not a multiple of 60 (when non-zero).
|
|
17
|
+
*/
|
|
18
|
+
export function validateTtl(value, name) {
|
|
19
|
+
if (value === undefined) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (value < 0) {
|
|
23
|
+
throw new LangSmithValidationError(`${name} must be >= 0, got ${value}`, name);
|
|
24
|
+
}
|
|
25
|
+
if (value !== 0 && value % 60 !== 0) {
|
|
26
|
+
throw new LangSmithValidationError(`${name} must be a multiple of 60 seconds, got ${value}`, name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
8
29
|
/**
|
|
9
30
|
* Parse standardized error response.
|
|
10
31
|
*
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
export { SandboxClient } from "./client.js";
|
|
26
26
|
export { Sandbox } from "./sandbox.js";
|
|
27
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";
|
|
28
|
+
export type { ExecutionResult, OutputChunk, WsMessage, WsRunOptions, ResourceSpec, ResourceStatus, VolumeMountSpec, Volume, SandboxTemplate, Pool, SandboxData, SandboxClientConfig, RunOptions, CreateSandboxOptions, UpdateSandboxOptions, WaitForSandboxOptions, CreateVolumeOptions, CreateTemplateOptions, UpdateTemplateOptions, CreatePoolOptions, UpdateVolumeOptions, UpdatePoolOptions, } from "./types.js";
|
|
29
29
|
export { LangSmithSandboxError, LangSmithSandboxAPIError, LangSmithSandboxAuthenticationError, LangSmithSandboxConnectionError, LangSmithSandboxServerReloadError, LangSmithResourceNotFoundError, LangSmithResourceTimeoutError, LangSmithResourceInUseError, LangSmithResourceAlreadyExistsError, LangSmithResourceNameConflictError, LangSmithValidationError, LangSmithQuotaExceededError, LangSmithResourceCreationError, LangSmithSandboxCreationError, LangSmithSandboxNotReadyError, LangSmithSandboxOperationError, LangSmithCommandTimeoutError, LangSmithDataplaneNotConfiguredError, } from "./errors.js";
|
|
@@ -85,6 +85,27 @@ class Sandbox {
|
|
|
85
85
|
writable: true,
|
|
86
86
|
value: void 0
|
|
87
87
|
});
|
|
88
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
89
|
+
Object.defineProperty(this, "ttl_seconds", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
95
|
+
/** Idle timeout TTL in seconds (`0` means disabled). */
|
|
96
|
+
Object.defineProperty(this, "idle_ttl_seconds", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
configurable: true,
|
|
99
|
+
writable: true,
|
|
100
|
+
value: void 0
|
|
101
|
+
});
|
|
102
|
+
/** Computed expiration timestamp when a TTL is active. */
|
|
103
|
+
Object.defineProperty(this, "expires_at", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: void 0
|
|
108
|
+
});
|
|
88
109
|
Object.defineProperty(this, "_client", {
|
|
89
110
|
enumerable: true,
|
|
90
111
|
configurable: true,
|
|
@@ -99,6 +120,9 @@ class Sandbox {
|
|
|
99
120
|
this.id = data.id;
|
|
100
121
|
this.created_at = data.created_at;
|
|
101
122
|
this.updated_at = data.updated_at;
|
|
123
|
+
this.ttl_seconds = data.ttl_seconds;
|
|
124
|
+
this.idle_ttl_seconds = data.idle_ttl_seconds;
|
|
125
|
+
this.expires_at = data.expires_at;
|
|
102
126
|
this._client = client;
|
|
103
127
|
}
|
|
104
128
|
/**
|
|
@@ -38,6 +38,12 @@ export declare class Sandbox {
|
|
|
38
38
|
readonly created_at?: string;
|
|
39
39
|
/** Timestamp when the sandbox was last updated. */
|
|
40
40
|
readonly updated_at?: string;
|
|
41
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
42
|
+
readonly ttl_seconds?: number;
|
|
43
|
+
/** Idle timeout TTL in seconds (`0` means disabled). */
|
|
44
|
+
readonly idle_ttl_seconds?: number;
|
|
45
|
+
/** Computed expiration timestamp when a TTL is active. */
|
|
46
|
+
readonly expires_at?: string;
|
|
41
47
|
private _client;
|
|
42
48
|
/**
|
|
43
49
|
* Validate and return the dataplane URL.
|
|
@@ -82,6 +82,27 @@ export class Sandbox {
|
|
|
82
82
|
writable: true,
|
|
83
83
|
value: void 0
|
|
84
84
|
});
|
|
85
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled). */
|
|
86
|
+
Object.defineProperty(this, "ttl_seconds", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: void 0
|
|
91
|
+
});
|
|
92
|
+
/** Idle timeout TTL in seconds (`0` means disabled). */
|
|
93
|
+
Object.defineProperty(this, "idle_ttl_seconds", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
97
|
+
value: void 0
|
|
98
|
+
});
|
|
99
|
+
/** Computed expiration timestamp when a TTL is active. */
|
|
100
|
+
Object.defineProperty(this, "expires_at", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: void 0
|
|
105
|
+
});
|
|
85
106
|
Object.defineProperty(this, "_client", {
|
|
86
107
|
enumerable: true,
|
|
87
108
|
configurable: true,
|
|
@@ -96,6 +117,9 @@ export class Sandbox {
|
|
|
96
117
|
this.id = data.id;
|
|
97
118
|
this.created_at = data.created_at;
|
|
98
119
|
this.updated_at = data.updated_at;
|
|
120
|
+
this.ttl_seconds = data.ttl_seconds;
|
|
121
|
+
this.idle_ttl_seconds = data.idle_ttl_seconds;
|
|
122
|
+
this.expires_at = data.expires_at;
|
|
99
123
|
this._client = client;
|
|
100
124
|
}
|
|
101
125
|
/**
|
|
@@ -85,6 +85,12 @@ export interface SandboxData {
|
|
|
85
85
|
status_message?: string;
|
|
86
86
|
created_at?: string;
|
|
87
87
|
updated_at?: string;
|
|
88
|
+
/** Maximum lifetime TTL in seconds (`0` means disabled, omitted/`undefined` means not set). */
|
|
89
|
+
ttl_seconds?: number;
|
|
90
|
+
/** Idle timeout TTL in seconds (`0` means disabled, omitted/`undefined` means not set). */
|
|
91
|
+
idle_ttl_seconds?: number;
|
|
92
|
+
/** Computed expiration timestamp when a TTL is active, else omitted/`undefined`. */
|
|
93
|
+
expires_at?: string;
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
96
|
* Configuration options for the SandboxClient.
|
|
@@ -248,6 +254,32 @@ export interface CreateSandboxOptions {
|
|
|
248
254
|
* Default: true.
|
|
249
255
|
*/
|
|
250
256
|
waitForReady?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Maximum lifetime in seconds from creation. The sandbox is deleted after
|
|
259
|
+
* this duration. Must be a multiple of 60, or `0`/`undefined` to disable or omit.
|
|
260
|
+
*/
|
|
261
|
+
ttlSeconds?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Idle timeout in seconds. The sandbox is deleted after this much inactivity.
|
|
264
|
+
* Must be a multiple of 60, or `0`/`undefined` to disable or omit.
|
|
265
|
+
*/
|
|
266
|
+
idleTtlSeconds?: number;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Options for updating a sandbox (name and/or TTL).
|
|
270
|
+
*/
|
|
271
|
+
export interface UpdateSandboxOptions {
|
|
272
|
+
/** New display name. */
|
|
273
|
+
newName?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Maximum lifetime in seconds from creation. Must be a multiple of 60.
|
|
276
|
+
* Pass `0` to disable absolute TTL.
|
|
277
|
+
*/
|
|
278
|
+
ttlSeconds?: number;
|
|
279
|
+
/**
|
|
280
|
+
* Idle timeout in seconds. Must be a multiple of 60. Pass `0` to disable.
|
|
281
|
+
*/
|
|
282
|
+
idleTtlSeconds?: number;
|
|
251
283
|
}
|
|
252
284
|
/**
|
|
253
285
|
* Options for waiting for a sandbox to become ready.
|
package/dist/index.cjs
CHANGED
|
@@ -18,4 +18,4 @@ 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 yarn bump-version
|
|
21
|
-
exports.__version__ = "0.5.
|
|
21
|
+
exports.__version__ = "0.5.15";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ 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.5.
|
|
8
|
+
export declare const __version__ = "0.5.15";
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ 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 yarn bump-version
|
|
8
|
-
export const __version__ = "0.5.
|
|
8
|
+
export const __version__ = "0.5.15";
|
package/dist/wrappers/gemini.cjs
CHANGED
|
@@ -166,7 +166,7 @@ const chatAggregator = (input) => {
|
|
|
166
166
|
return result;
|
|
167
167
|
};
|
|
168
168
|
function processGeminiInputs(inputs) {
|
|
169
|
-
const { contents,
|
|
169
|
+
const { contents, ...rest } = inputs;
|
|
170
170
|
if (!contents)
|
|
171
171
|
return inputs;
|
|
172
172
|
if (typeof contents === "string") {
|
package/dist/wrappers/gemini.js
CHANGED
|
@@ -163,7 +163,7 @@ const chatAggregator = (input) => {
|
|
|
163
163
|
return result;
|
|
164
164
|
};
|
|
165
165
|
function processGeminiInputs(inputs) {
|
|
166
|
-
const { contents,
|
|
166
|
+
const { contents, ...rest } = inputs;
|
|
167
167
|
if (!contents)
|
|
168
168
|
return inputs;
|
|
169
169
|
if (typeof contents === "string") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
5
|
"packageManager": "yarn@1.22.19",
|
|
6
6
|
"files": [
|
|
@@ -156,8 +156,8 @@
|
|
|
156
156
|
"@ai-sdk/anthropic": "^3.0.0",
|
|
157
157
|
"@ai-sdk/openai": "^3.0.0",
|
|
158
158
|
"@ai-sdk/provider": "^3.0.0",
|
|
159
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
160
|
-
"@anthropic-ai/sdk": "^0.
|
|
159
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.83",
|
|
160
|
+
"@anthropic-ai/sdk": "^0.80.0",
|
|
161
161
|
"@babel/preset-env": "^7.22.4",
|
|
162
162
|
"@faker-js/faker": "^8.4.1",
|
|
163
163
|
"@google/genai": "^1.29.0",
|
|
@@ -167,8 +167,8 @@
|
|
|
167
167
|
"@langchain/langgraph": "^0.3.6",
|
|
168
168
|
"@langchain/openai": "^0.5.16",
|
|
169
169
|
"@opentelemetry/api": "^1.9.0",
|
|
170
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
171
|
-
"@opentelemetry/sdk-node": "^0.
|
|
170
|
+
"@opentelemetry/auto-instrumentations-node": "^0.71.0",
|
|
171
|
+
"@opentelemetry/sdk-node": "^0.214.0",
|
|
172
172
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
173
173
|
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
174
174
|
"@tsconfig/recommended": "^1.0.2",
|