UNPKG

@2501-ai/cli

Version:

[![npm version](https://img.shields.io/npm/v/@2501-ai/cli.svg)](https://www.npmjs.com/package/@2501-ai/cli) [![HumanEval Score](https://img.shields.io/badge/HumanEval-96.95%25-brightgreen.svg)](https://www.2501.ai/research/full-humaneval-benchmark) [![Lic

101 lines (100 loc) 5.92 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const remoteExecutor_1 = require("../remoteExecutor"); const remoteWorkspace_1 = require("../remoteWorkspace"); const { JEST_WINRM_PASS, JEST_WINRM_USER, JEST_WINRM_HOST } = process.env; const { JEST_SSH_KEY, JEST_SSH_USER, JEST_SSH_HOST } = process.env; const hasWinRMConfig = JEST_WINRM_PASS && JEST_WINRM_USER && JEST_WINRM_HOST; const hasSSHConfig = JEST_SSH_KEY && JEST_SSH_USER && JEST_SSH_HOST; if (!hasWinRMConfig && !hasSSHConfig) { throw new Error('Missing environment variables. Provide either WinRM (JEST_WINRM_*) or SSH (JEST_SSH_*) credentials.'); } const describeWinRM = hasWinRMConfig ? describe : describe.skip; describeWinRM('RemoteWorkspace - WinRM (Windows)', () => { const testWorkspacePath = `C:\\Users\\${JEST_WINRM_USER}\\2501-test-workspace`; const remoteExecConfig = { enabled: true, target: JEST_WINRM_HOST, port: 5985, type: 'winrm', platform: 'windows', user: JEST_WINRM_USER, remote_workspace: testWorkspacePath, password: JEST_WINRM_PASS, }; beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { remoteExecutor_1.RemoteExecutor.instance.init(remoteExecConfig); yield remoteExecutor_1.RemoteExecutor.instance.validateConnection(); })); afterAll(() => __awaiter(void 0, void 0, void 0, function* () { const cleanupCmd = `if (Test-Path "${testWorkspacePath}") { Remove-Item -Path "${testWorkspacePath}" -Recurse -Force }`; yield remoteExecutor_1.RemoteExecutor.instance.executeCommand(cleanupCmd); yield remoteExecutor_1.RemoteExecutor.instance.disconnect(); })); it('ensureRemoteWorkspaceExists should not throw', () => __awaiter(void 0, void 0, void 0, function* () { yield expect((0, remoteWorkspace_1.ensureRemoteWorkspaceExists)(true, testWorkspacePath)).resolves.not.toThrow(); })); it('setupRemoteWorkspace should return expected path', () => __awaiter(void 0, void 0, void 0, function* () { const workspacePath = yield (0, remoteWorkspace_1.setupRemoteWorkspace)(remoteExecConfig, { remoteWorkspace: testWorkspacePath, }); expect(workspacePath).toBe(testWorkspacePath); })); it('setupRemoteWorkspace should return default path when not provided', () => __awaiter(void 0, void 0, void 0, function* () { const workspacePath = yield (0, remoteWorkspace_1.setupRemoteWorkspace)(remoteExecConfig, {}); expect(workspacePath).toBe('C:\\ProgramData\\2501\\'); })); it('ensureRemoteWorkspaceExists should be idempotent', () => __awaiter(void 0, void 0, void 0, function* () { yield expect((0, remoteWorkspace_1.ensureRemoteWorkspaceExists)(true, testWorkspacePath)).resolves.not.toThrow(); yield expect((0, remoteWorkspace_1.ensureRemoteWorkspaceExists)(true, testWorkspacePath)).resolves.not.toThrow(); })); }); const describeSSH = hasSSHConfig ? describe : describe.skip; describeSSH('RemoteWorkspace - SSH (Unix)', () => { const testWorkspacePath = `/home/${JEST_SSH_USER}/2501-test-workspace`; const remoteExecConfig = { enabled: true, target: JEST_SSH_HOST, port: 22, type: 'ssh', platform: 'unix', user: JEST_SSH_USER, remote_workspace: testWorkspacePath, private_key: JEST_SSH_KEY, }; beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { remoteExecutor_1.RemoteExecutor.instance.init(remoteExecConfig); yield remoteExecutor_1.RemoteExecutor.instance.validateConnection(); })); afterAll(() => __awaiter(void 0, void 0, void 0, function* () { const cleanupCmd = `rm -rf "${testWorkspacePath}"`; yield remoteExecutor_1.RemoteExecutor.instance.executeCommand(cleanupCmd, undefined, true); yield remoteExecutor_1.RemoteExecutor.instance.disconnect(); })); it('ensureRemoteWorkspaceExists should not throw', () => __awaiter(void 0, void 0, void 0, function* () { yield expect((0, remoteWorkspace_1.ensureRemoteWorkspaceExists)(false, testWorkspacePath)).resolves.not.toThrow(); })); it('setupRemoteWorkspace should return expected path', () => __awaiter(void 0, void 0, void 0, function* () { const workspacePath = yield (0, remoteWorkspace_1.setupRemoteWorkspace)(remoteExecConfig, { remoteWorkspace: testWorkspacePath, }); expect(workspacePath).toBe(testWorkspacePath); })); it('setupRemoteWorkspace should return default path when not provided', () => __awaiter(void 0, void 0, void 0, function* () { const workspacePath = yield (0, remoteWorkspace_1.setupRemoteWorkspace)(remoteExecConfig, {}); expect(workspacePath).toBe(`/home/${JEST_SSH_USER}/.2501/workspace`); })); it('ensureRemoteWorkspaceExists should be idempotent', () => __awaiter(void 0, void 0, void 0, function* () { yield expect((0, remoteWorkspace_1.ensureRemoteWorkspaceExists)(false, testWorkspacePath)).resolves.not.toThrow(); yield expect((0, remoteWorkspace_1.ensureRemoteWorkspaceExists)(false, testWorkspacePath)).resolves.not.toThrow(); })); });