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

55 lines (53 loc) 2.74 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.authMiddleware = void 0; const terminal_kit_1 = require("terminal-kit"); const conf_1 = require("../utils/conf"); const logger_1 = __importDefault(require("../utils/logger")); const api_1 = require("../helpers/api"); const logger = new logger_1.default(); function authMiddleware() { return __awaiter(this, void 0, void 0, function* () { let config = (0, conf_1.readConfig)(); if (config && !config.api_key && !config.agents.length) { yield showFirstTimeMessage(); config = (0, conf_1.readConfig)(); } if (config && !config.api_key) { terminal_kit_1.terminal.bold.red('Please run the command `@2501 set api_key {YOUR_API_KEY}` to configure the API key before running any other command.\nIf you do not have an API key, you can get one by signing up at https://accounts.2501.ai/pay\n'); process.exit(1); } yield (0, api_1.initAxios)(); }); } exports.authMiddleware = authMiddleware; function showFirstTimeMessage() { return __awaiter(this, void 0, void 0, function* () { logger.log(`Welcome to @2501 CLI! It looks like this is your first time using the CLI. Before we begin, you need to configure your API key. (You can get your API key by signing up at https://accounts.2501.ai)`); const res = yield logger.prompt(`Once you have registered, please enter your API key here: `, 'string'); if (res) { (0, conf_1.writeConfig)({ api_key: res, workspace_disabled: false, agents: [], join_discord_shown: false, disable_spinner: true, }); logger.log(`The CLI will now create a workspace and synchronize your files with the 2501 platform before creating your first agent.`); } }); }