UNPKG

@botpress/adk-cli

Version:

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

100 lines (97 loc) 3.36 kB
// @bun import { assertValidProject } from "./chunk-wmec2w0t.js"; import { ensureJsonOnlyFormat } from "./chunk-7sfagm12.js"; import { telemetry_default } from "./chunk-kwmsaz7n.js"; import { findAgentRootOrFail } from "./chunk-kk3h6qaj.js"; import { createCliLogger } from "./chunk-gzwt1qdr.js"; import { AgentProject, BpBuildCommand, generateAssetsRuntime, generateAssetsTypes, generateBotProject } from "./chunk-p0hjqn4r.js"; import { __require } from "./chunk-dhs2bg35.js"; // src/commands/adk-build.ts import path from "path"; async function adkBuild(options = {}) { ensureJsonOnlyFormat(options.format); const { silent = false, adkCommand = "adk-build" } = options; const logger = createCliLogger({ format: options.format, silent }); logger.info("\uD83D\uDD28 Building ADK agent for production...", "blue"); const { checkNodeVersion } = await import("./chunk-c07hkzqm.js"); checkNodeVersion(true); const agentRoot = await findAgentRootOrFail(process.cwd()); const project = await AgentProject.load(agentRoot, { adkCommand }); await assertValidProject(project); logger.info(`\uD83D\uDCE6 Loaded project: ${project.config?.name || "Unknown"}`, "green"); logger.info("\uD83D\uDCDD Generating assets types...", "cyan"); try { await generateAssetsTypes(project.path); await generateAssetsRuntime(project.path, project.agentInfo?.botId); logger.info("\u2705 Assets types generated", "green"); } catch (err) { logger.warn("\u26A0\uFE0F No assets directory found, skipping asset type generation"); logger.debug(`Asset type generation failed: ${err instanceof Error ? err.message : String(err)}`); } if (options.beforeGenerate) { await options.beforeGenerate(); } logger.info("\uD83D\uDD28 Generating Botpress bot project...", "cyan"); const botPath = path.join(project.path, ".adk", "bot"); await generateBotProject({ projectPath: project.path, outputPath: botPath, adkCommand }); logger.info("\u2705 Bot project generated", "green"); logger.info("\uD83C\uDFD7\uFE0F Building agent...", "cyan"); const buildCommand = new BpBuildCommand({ botPath }); await buildCommand.run(); await buildCommand.output(); const primitiveTypes = [ { type: "action", items: project.actions || [] }, { type: "workflow", items: project.workflows || [] }, { type: "conversation", items: project.conversations || [] }, { type: "trigger", items: project.triggers || [] }, { type: "table", items: project.tables || [] } ]; for (const { type, items } of primitiveTypes) { for (const item of items) { telemetry_default.track("primitive_created", { type, name: item.name || "" }); } } const { getAdkVersion } = await import("./chunk-zz6ydgkm.js"); telemetry_default.track("build", { adkVersion: getAdkVersion() }); logger.info(` \u2705 Build completed successfully!`, "green").result({ success: true, project: project.config?.name || "Unknown", outputDir: path.join(botPath, ".botpress", "dist") }); logger.info(`\uD83D\uDCE6 Output directory: ${path.join(botPath, ".botpress", "dist")}`); logger.info(` Next steps:`); logger.info(" - Run `adk deploy` to deploy your agent"); logger.info(" - Or run `cd .adk/bot && bp deploy` to deploy manually"); } export { adkBuild };