1import { describe, expect, it } from "vite-plus/test";
2import { withAgentDeviceEnvironment } from "./mcpSession.ts";
3
4describe("device CLI environment", () => {
5 it("preserves provider credentials and commands while routing devices to the owned daemon", () => {
6 const environment = withAgentDeviceEnvironment(
7 { PATH: "/provider/bin:/usr/bin", PROVIDER_KEY: "fixture" },
8 {
9 agentDeviceEnvironment: {
10 PATH: "/t3/device/bin",
11 PATH_SEPARATOR: ":",
12 AGENT_DEVICE_DAEMON_BASE_URL: "http://127.0.0.1:9000",
13 AGENT_DEVICE_DAEMON_AUTH_TOKEN: "fixture-device",
14 },
15 },
16 );
17 expect(environment).toEqual({
18 PATH: "/t3/device/bin:/provider/bin:/usr/bin",
19 PROVIDER_KEY: "fixture",
20 AGENT_DEVICE_DAEMON_BASE_URL: "http://127.0.0.1:9000",
21 AGENT_DEVICE_DAEMON_AUTH_TOKEN: "fixture-device",
22 });
23 });
24
25 it("does not grant CLI access when device access was not supplied", () => {
26 const environment = { PATH: "/usr/bin", PROVIDER_KEY: "fixture" };
27 expect(withAgentDeviceEnvironment(environment, undefined)).toBe(environment);
28 expect(withAgentDeviceEnvironment(environment, {})).toBe(environment);
29 });
30});