Skip to content
49 changes: 47 additions & 2 deletions extensions/cli/src/commands/remote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,32 @@ describe("remote command", () => {
expect(mockFetch).toHaveBeenCalledWith(
new URL("agents", mockEnv.env.apiBase),
expect.objectContaining({
body: expect.stringContaining(`"agent":"${testConfig}"`),
body: expect.stringContaining(`"config":"${testConfig}"`),
}),
);
});

it("should include agent in request body when agent option is provided", async () => {
const testAgent = "test-agent";

await remote("test prompt", { agent: testAgent });

expect(mockFetch).toHaveBeenCalledWith(
new URL("agents", mockEnv.env.apiBase),
expect.objectContaining({
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer test-token",
},
body: expect.stringContaining(`"agent":"${testAgent}"`),
}),
);

expect(mockFetch).toHaveBeenCalledWith(
new URL("agents", mockEnv.env.apiBase),
expect.objectContaining({
body: expect.stringContaining(`"agent":"${testAgent}"`),
}),
);
});
Expand All @@ -375,11 +400,31 @@ describe("remote command", () => {
name: expect.stringMatching(/^devbox-\d+$/),
prompt: "test prompt",
idempotencyKey: testIdempotencyKey,
agent: testConfig,
config: testConfig,
});
});

it("should handle proper request body structure with agent field", async () => {
const testAgent = "my-agent";
const testIdempotencyKey = "test-with-config";

await remote("test prompt", {
agent: testAgent,
idempotencyKey: testIdempotencyKey,
});

const fetchCall = mockFetch.mock.calls[0];
const requestBody = JSON.parse(fetchCall[1].body);

expect(requestBody).toEqual({
repoUrl: "https://github.com/user/test-repo.git",
name: expect.stringMatching(/^devbox-\d+$/),
prompt: "test prompt",
idempotencyKey: testIdempotencyKey,
agent: testAgent,
});
});

it("should not include config in request body when config option is not provided", async () => {
await remote("test prompt", {});

Expand Down
3 changes: 2 additions & 1 deletion extensions/cli/src/commands/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type RemoteCommandOptions = {
branch?: string;
repo?: string;
config?: string;
agent?: string;
};

type TunnelResponse = {
Expand Down Expand Up @@ -169,7 +170,7 @@ function buildAgentRequestBody(
repoUrl: options.repo ?? getRepoUrl(),
name: `devbox-${Date.now()}`,
prompt,
agent: options.config,
agent: options.agent,
config: options.config,
};

Expand Down
Loading
Loading