deepagents 1.10.0 → 1.10.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/dist/index.cjs +47 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -6
- package/dist/index.d.ts +43 -6
- package/dist/index.js +47 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6464,7 +6464,7 @@ var BaseSandbox = class {
|
|
|
6464
6464
|
* ```typescript
|
|
6465
6465
|
* import { LangSmithSandbox, createDeepAgent } from "deepagents";
|
|
6466
6466
|
*
|
|
6467
|
-
* const sandbox = await LangSmithSandbox.create({
|
|
6467
|
+
* const sandbox = await LangSmithSandbox.create({ snapshotId: "your-snapshot-id" });
|
|
6468
6468
|
*
|
|
6469
6469
|
* const agent = createDeepAgent({ model, backend: sandbox });
|
|
6470
6470
|
*
|
|
@@ -6588,6 +6588,41 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
6588
6588
|
this.#isRunning = false;
|
|
6589
6589
|
}
|
|
6590
6590
|
/**
|
|
6591
|
+
* Start a stopped sandbox and wait until it is ready.
|
|
6592
|
+
*
|
|
6593
|
+
* After calling this, `isRunning` will be `true` and the sandbox
|
|
6594
|
+
* can be used for command execution and file operations again.
|
|
6595
|
+
*
|
|
6596
|
+
* @param options - Start options (timeout, signal).
|
|
6597
|
+
*/
|
|
6598
|
+
async start(options = {}) {
|
|
6599
|
+
await this.#sandbox.start(options);
|
|
6600
|
+
this.#isRunning = true;
|
|
6601
|
+
}
|
|
6602
|
+
/**
|
|
6603
|
+
* Stop the sandbox without deleting it.
|
|
6604
|
+
*
|
|
6605
|
+
* Sandbox files are preserved and the sandbox can be restarted later
|
|
6606
|
+
* with `start()`. After calling this, `isRunning` will be `false`.
|
|
6607
|
+
*/
|
|
6608
|
+
async stop() {
|
|
6609
|
+
await this.#sandbox.stop();
|
|
6610
|
+
this.#isRunning = false;
|
|
6611
|
+
}
|
|
6612
|
+
/**
|
|
6613
|
+
* Capture a snapshot from this running sandbox.
|
|
6614
|
+
*
|
|
6615
|
+
* Snapshots can be used to create new sandboxes via
|
|
6616
|
+
* `LangSmithSandbox.create({ snapshotId })`.
|
|
6617
|
+
*
|
|
6618
|
+
* @param name - Name for the snapshot.
|
|
6619
|
+
* @param options - Capture options (checkpoint, timeout).
|
|
6620
|
+
* @returns The created Snapshot in "ready" status.
|
|
6621
|
+
*/
|
|
6622
|
+
async captureSnapshot(name, options = {}) {
|
|
6623
|
+
return this.#sandbox.captureSnapshot(name, options);
|
|
6624
|
+
}
|
|
6625
|
+
/**
|
|
6591
6626
|
* Create and return a new LangSmithSandbox in one step.
|
|
6592
6627
|
*
|
|
6593
6628
|
* This is the recommended way to create a sandbox — no need to import
|
|
@@ -6595,7 +6630,10 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
6595
6630
|
*
|
|
6596
6631
|
* @example
|
|
6597
6632
|
* ```typescript
|
|
6598
|
-
* const sandbox = await LangSmithSandbox.create({
|
|
6633
|
+
* const sandbox = await LangSmithSandbox.create({
|
|
6634
|
+
* snapshotId: "abc-123",
|
|
6635
|
+
* });
|
|
6636
|
+
*
|
|
6599
6637
|
* try {
|
|
6600
6638
|
* const agent = createDeepAgent({ model, backend: sandbox });
|
|
6601
6639
|
* await agent.invoke({ messages: [...] });
|
|
@@ -6604,10 +6642,14 @@ var LangSmithSandbox = class LangSmithSandbox extends BaseSandbox {
|
|
|
6604
6642
|
* }
|
|
6605
6643
|
* ```
|
|
6606
6644
|
*/
|
|
6607
|
-
static async create(options
|
|
6608
|
-
const { templateName
|
|
6645
|
+
static async create(options) {
|
|
6646
|
+
const { templateName, apiKey = process.env.LANGSMITH_API_KEY, defaultTimeout, snapshotId, ...createSandboxOptions } = options;
|
|
6647
|
+
if (snapshotId && templateName) throw new Error("snapshotId and templateName are mutually exclusive. Pass only one creation source.");
|
|
6648
|
+
if (!snapshotId && !templateName) throw new Error("Either snapshotId or templateName is required. snapshotId is recommended — template-based creation is deprecated.");
|
|
6649
|
+
const sandboxOptions = { ...createSandboxOptions };
|
|
6650
|
+
if (templateName) sandboxOptions.snapshotName = templateName;
|
|
6609
6651
|
return new LangSmithSandbox({
|
|
6610
|
-
sandbox: await new langsmith_experimental_sandbox.SandboxClient({ apiKey }).createSandbox(
|
|
6652
|
+
sandbox: await new langsmith_experimental_sandbox.SandboxClient({ apiKey }).createSandbox(snapshotId, sandboxOptions),
|
|
6611
6653
|
defaultTimeout
|
|
6612
6654
|
});
|
|
6613
6655
|
}
|