UNPKG

@iqai/adk-cli

Version:

CLI tool for creating, running, and testing ADK-TS agents

102 lines 4.12 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); const adk_1 = require("@iqai/adk"); const schema_1 = require("./common/schema"); // Lightweight, dependency-free version flag handling executed before Nest bootstraps. // Supports: adk --version | adk -v | adk -V // Intentionally done here (instead of commander integration) to avoid spinning up // the Nest container for a trivial, frequently used query. try { if (process.argv.some((a) => a === "--version" || a === "-v" || a === "-V")) { const pkg = require("../package.json"); // Print just the version to stay script-friendly (e.g., `adk --version` in tooling) // Common CLIs output only the version number; adjust if branding desired. console.log(pkg.version || "unknown"); process.exit(0); } } catch { // Silently ignore and continue to normal bootstrap if something unexpected happens. } // Show branded welcome banner when running bare `adk` (no subcommand). // Executed before Nest bootstraps to keep it instantaneous. try { if (process.argv.length === 2) { const { printWelcome } = require("./cli/banner"); printWelcome(); process.exit(0); } } catch { // Fall through to normal bootstrap if banner fails. } // Decide how noisy Nest should be based on the invoked command. // We only want framework bootstrap logs when actually starting a server // (serve / run / web). Plain `adk` (help) should be clean. function selectLogger() { const env = schema_1.envSchema.parse(process.env); const debug = env.ADK_DEBUG; // Unified rule: stay silent by default to avoid polluting UX. // Opt-in via env var for framework level diagnostics. if (debug) { return ["log", "error", "warn", "debug", "verbose"]; } // Keep errors & warnings only (avoid boot noise like InstanceLoader lines). return ["error", "warn"]; } async function bootstrap() { if (!adk_1.telemetryService.initialized) { await adk_1.telemetryService.initialize({ appName: "adk-cli", appVersion: "1.0.0", enableTracing: true, enableMetrics: false, metricExportIntervalMs: 1000, debug: true, enableAutoInstrumentation: false, }); } // Dynamic imports to ensure NestJS is loaded AFTER telemetry init const { CommandFactory } = await Promise.resolve().then(() => __importStar(require("nest-commander"))); const { AppModule } = await Promise.resolve().then(() => __importStar(require("./app.module"))); await CommandFactory.run(AppModule, { logger: selectLogger(), }); } bootstrap(); //# sourceMappingURL=main.js.map