mirror of
https://github.com/langchain-ai/deepagentsjs.git
synced 2026-07-19 08:26:01 -04:00
fix: delegate CompositeBackend.id to default sandbox backend (#286)
* fix: delegate CompositeBackend.id to default sandbox backend
CompositeBackend failed isSandboxBackend check because it lacked the
required id property from SandboxBackendProtocol. Added a get id()
getter that delegates to the default backend's id when it is a sandbox,
or returns an empty string otherwise. This preserves the real sandbox
ID (e.g. from Daytona/Deno/Modal) for external lifecycle operations
like provider.delete({ sandboxId: sandbox.id }).
Fixes #275
* Fix delegation of CompositeBackend.id to sandbox backend
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"deepagents": patch
|
||||
---
|
||||
|
||||
fix: delegate CompositeBackend.id to default sandbox backend
|
||||
@@ -18,6 +18,7 @@ import type {
|
||||
SandboxBackendProtocol,
|
||||
GrepMatch,
|
||||
} from "./protocol.js";
|
||||
import { isSandboxBackend } from "./protocol.js";
|
||||
|
||||
/**
|
||||
* Mock sandbox backend for testing execute delegation
|
||||
@@ -608,6 +609,38 @@ describe("CompositeBackend", () => {
|
||||
"doesn't support command execution",
|
||||
);
|
||||
});
|
||||
|
||||
it("should pass isSandboxBackend check when default backend supports execution", () => {
|
||||
const mockSandbox = new MockSandboxBackend();
|
||||
const { stateAndStore } = makeConfig();
|
||||
|
||||
const composite = new CompositeBackend(mockSandbox, {
|
||||
"/store/": new StoreBackend(stateAndStore),
|
||||
});
|
||||
|
||||
expect(isSandboxBackend(composite)).toBe(true);
|
||||
});
|
||||
|
||||
it("should delegate id to default sandbox backend", () => {
|
||||
const mockSandbox = new MockSandboxBackend();
|
||||
const { stateAndStore } = makeConfig();
|
||||
|
||||
const composite = new CompositeBackend(mockSandbox, {
|
||||
"/store/": new StoreBackend(stateAndStore),
|
||||
});
|
||||
|
||||
expect(composite.id).toBe("mock-sandbox");
|
||||
});
|
||||
|
||||
it("should return empty string id when default backend is not sandbox", () => {
|
||||
const { stateAndStore } = makeConfig();
|
||||
|
||||
const composite = new CompositeBackend(new StateBackend(stateAndStore), {
|
||||
"/store/": new StoreBackend(stateAndStore),
|
||||
});
|
||||
|
||||
expect(composite.id).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("uploadFiles", () => {
|
||||
|
||||
@@ -42,6 +42,11 @@ export class CompositeBackend implements BackendProtocol {
|
||||
);
|
||||
}
|
||||
|
||||
/** Delegates to default backend's id if it is a sandbox, otherwise empty string. */
|
||||
get id(): string {
|
||||
return isSandboxBackend(this.default) ? this.default.id : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine which backend handles this key and strip prefix.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user