UNPKG

@kya-os/cli

Version:

CLI for KYA-OS MCP-I setup and management

65 lines • 3.18 kB
import chalk from "chalk"; import ora from "ora"; import { MCPIdentity } from "@kya-os/mcp-i"; import { EnvManager } from "../utils/env-manager.js"; import { showSuccess, showError, showInfo } from "../utils/prompts.js"; export async function claim() { console.log(chalk.cyan("\nšŸŽÆ Agent Management URLs\n")); // Check for existing identity const envManager = new EnvManager(); const processVars = envManager.getFromProcess(); if (!processVars.MCP_IDENTITY_AGENT_DID) { showError('No MCP-I identity found. Run "npx kya-os init" first.'); return; } const spinner = ora("Retrieving management URLs...").start(); try { // Initialize identity const identity = await MCPIdentity.init(); // Request edit access const { editUrl, claimUrl } = await identity.requestEditAccess(); spinner.succeed("URLs retrieved successfully!"); console.log(`\n${chalk.bold("šŸ“ Agent Information:")}`); console.log(` DID: ${chalk.gray(processVars.MCP_IDENTITY_AGENT_DID)}`); if (processVars.MCP_IDENTITY_AGENT_SLUG) { console.log(` Profile: ${chalk.cyan(`https://knowthat.ai/agents/${processVars.MCP_IDENTITY_AGENT_SLUG}`)}`); } if (claimUrl) { console.log(`\n${chalk.bold("šŸŽÆ Claim Your Agent:")}`); console.log(` ${chalk.cyan(claimUrl)}`); console.log(`\n ${chalk.gray("Use this link to:")}`); console.log(` ${chalk.gray("• Set up your account")}`); console.log(` ${chalk.gray("• Edit agent details")}`); console.log(` ${chalk.gray("• Add logos and descriptions")}`); console.log(` ${chalk.gray("• Manage directory listings")}`); console.log(` ${chalk.gray("• View analytics")}`); showInfo("This is a one-time claim link. Once claimed, use the edit URL."); } console.log(`\n${chalk.bold("āœļø Edit Your Agent:")}`); console.log(` ${chalk.cyan(editUrl)}`); console.log(` ${chalk.gray("(Requires authentication after claiming)")}`); // Check if agent is draft if (processVars.MCP_IDENTITY_AGENT_DID?.includes("localhost")) { showInfo("This is a development/draft agent. It won't appear in public directories."); } showSuccess("Management URLs ready!"); } catch (error) { spinner.fail("Failed to retrieve URLs"); if (error.message?.includes("429")) { showError("Rate limit exceeded. Please try again in a few minutes."); } else if (error.message?.includes("Network")) { showError("Network error. Check your internet connection."); } else { showError(error.message || "Failed to get management URLs"); // Provide fallback URL if (processVars.MCP_IDENTITY_AGENT_SLUG) { console.log(`\n${chalk.gray("You can try visiting directly:")}`); console.log(`${chalk.cyan(`https://knowthat.ai/agents/${processVars.MCP_IDENTITY_AGENT_SLUG}`)}`); } } } } //# sourceMappingURL=claim.js.map