UNPKG

@botpress/adk-cli

Version:

Command-line interface for the Botpress Agent Development Kit (ADK)

160 lines (158 loc) 5.72 kB
// @bun import { findAgentRoot, findAgentRootOrFail } from "./chunk-kk3h6qaj.js"; import { createCliLogger } from "./chunk-gzwt1qdr.js"; import"./chunk-nxy2ya5r.js"; import"./chunk-wzj4dc7n.js"; import { AgentProject, ProjectState } from "./chunk-p0hjqn4r.js"; import"./chunk-np5wcwfv.js"; import"./chunk-dq2xpa24.js"; import"./chunk-6w0knnta.js"; import"./chunk-40x04ckt.js"; import"./chunk-t76d8fxx.js"; import"./chunk-nh2akp42.js"; import"./chunk-0fdvzjbh.js"; import"./chunk-2a5b6azq.js"; import"./chunk-vay209b5.js"; import"./chunk-3xrpxgq4.js"; import"./chunk-rfm3jr1m.js"; import"./chunk-w346ejn9.js"; import"./chunk-knvm2anf.js"; import"./chunk-65h5trb5.js"; import"./chunk-s2akeqpw.js"; import"./chunk-6771vrjp.js"; import"./chunk-g8mm42v1.js"; import"./chunk-50hzjdck.js"; import"./chunk-nn2jb0x0.js"; import"./chunk-v8xvth6j.js"; import"./chunk-kkk13rcb.js"; import"./chunk-ytpp1kam.js"; import"./chunk-na956zz3.js"; import"./chunk-f4bw8q7c.js"; import"./chunk-0v8vgrns.js"; import"./chunk-54qt5g7m.js"; import"./chunk-dhs2bg35.js"; // src/commands/adk-info.ts var logger = createCliLogger(); async function adkInfo(directory, options = {}) { const startPath = directory || process.cwd(); const projectPath = await findAgentRoot(startPath) || startPath; try { const agentRoot = await findAgentRootOrFail(process.cwd()); const project = await AgentProject.load(agentRoot, { noCache: options.noCache }); const info = project.info; logger.info("\uD83E\uDD16 Botpress ADK Agent", "blue"); logger.info("\u2500".repeat(40), "gray"); logger.info(`Name: ${info.config.name || "(unnamed)"}`, "cyan"); logger.info(`Description: ${info.config.description || "(no description)"}`, "cyan"); logger.info(`Path: ${info.path}`, "cyan"); if (projectPath !== startPath) { logger.info(`Working Directory: ${startPath}`, "cyan"); } const stateColor = info.state === ProjectState.Ready ? "green" : info.state === ProjectState.Error ? "red" : "yellow"; logger.info(`State: ${info.state}`, stateColor); if (info.dependencies?.integrations) { const integrations = Object.keys(info.dependencies.integrations); logger.info(`Integrations: ${integrations.length > 0 ? integrations.join(", ") : "(none)"}`, "cyan"); try { const integrationsDetail = await project.getIntegrations(); const hasChannels = integrationsDetail.some((i) => i.hasChannels); if (!hasChannels && integrations.length > 0) { logger.warn("\u26A0 Warning: No integrations with channels found"); logger.info(" Add an integration with channels to enable conversations", "gray"); } } catch (err) { logger.debug(`Failed to fetch integration details: ${err instanceof Error ? err.message : String(err)}`); } } if (info.errorCount > 0 || info.warningCount > 0) { logger.newline(); logger.warn("\u26A0 Validation Issues:"); if (info.errors && info.errors.length > 0) { logger.error("Errors:"); info.errors.forEach((err) => { logger.error(` \u2022 ${err.message}`); if (err.hint) { logger.info(` ${err.hint}`, "gray"); } }); } if (info.warnings && info.warnings.length > 0) { logger.warn("Warnings:"); info.warnings.forEach((warn) => { logger.warn(` \u2022 ${warn.message}`); if (warn.hint) { logger.info(` ${warn.hint}`, "gray"); } }); } } if (info.lastBuildTime) { logger.info(`Last Build: ${new Date(info.lastBuildTime).toLocaleString()}`, "cyan"); } logger.newline(); logger.info("Run 'adk --help' to see available commands", "gray"); } catch (error) { const foundAgentConfig = await findAgentRoot(startPath) !== null; logger.error(String(error)); logger.newline(); logger.error("\u2717 Error: Not in a valid ADK agent directory."); logger.newline(); if (foundAgentConfig && error instanceof Error && error.message.includes("validation failed")) { try { const project = new AgentProject(projectPath); const validation = await project.validate(); if (validation.errors.length > 0 || validation.warnings.length > 0) { logger.warn("This directory appears to be an agent project but has validation errors:"); logger.newline(); if (validation.errors.length > 0) { logger.error("Errors:"); validation.errors.forEach((err) => { logger.error(` \u2022 ${err.message}`); if (err.hint) { logger.info(` ${err.hint}`, "gray"); } }); logger.newline(); } if (validation.warnings.length > 0) { logger.warn("Warnings:"); validation.warnings.forEach((warn) => { logger.warn(` \u2022 ${warn.message}`); if (warn.hint) { logger.info(` ${warn.hint}`, "gray"); } }); logger.newline(); } } } catch { logger.warn("This directory appears to be an agent project but has validation errors."); logger.newline(); } } else { logger.info("The ADK command should be run inside an agent directory.", "gray"); logger.info("To create a new agent, run:", "gray"); logger.newline(); logger.info(" adk init my-agent"); } logger.newline(); logger.info("For more information, run:", "gray"); logger.newline(); logger.info(" adk --help"); logger.newline(); process.exit(1); } } export { adkInfo };