UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

110 lines • 5.22 kB
// agora-doctor command v1 — keep identical across libs // Revision 1.1 (see the canonical README for the changelog). // Every @adonis-agora lib ships this command (commands/agora_doctor.ts); whichever copy Ace loads // last wins, and they all behave the same. Each repo's CI checks its sha256 against the pinned // canonical one. Never edit a lib's copy: change the canonical copy, then re-copy it into every lib. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { BaseCommand, flags } from '@adonisjs/core/ace'; import { AgoraDoctorUsageError, discoverDoctorChecks, readDoctorChecks, renderAgoraDoctor, runAgoraDoctor, } from '../src/doctor/agora_doctor.js'; /** * `node ace agora:doctor`: one health check for every installed `@adonis-agora` lib. Exit code `0` * when nothing is an error (`--strict`: nor a warning), `1` otherwise, `2` when the doctor itself * cannot run. */ export default class AgoraDoctor extends BaseCommand { static commandName = 'agora:doctor'; static description = 'Check the configuration of every installed @adonis-agora lib'; // The app is booted by `run()` itself, so `--no-boot` can skip it. static options = { startApp: false }; /** A `<lib>:doctor` alias sets this to pre-filter its lib. */ presetLib = undefined; async run() { const err = (line) => process.stderr.write(`${line}\n`); try { let checks; if (this.boot === false) { checks = await discoverDoctorChecks(this.app); } else { if (!this.app.isReady) { try { await this.app.boot(); await this.app.start(() => { }); } catch (error) { const reason = error instanceof Error ? error.message : String(error); throw new AgoraDoctorUsageError(`the app did not boot (${reason}). Fix the boot error, or run with --no-boot.`); } } checks = await readDoctorChecks(this.app.container); } const libs = (this.lib ?? this.presetLib) ?.split(',') .map((name) => name.trim()) .filter(Boolean); const { report, exitCode } = await runAgoraDoctor(this.app, checks, { ...(libs ? { libs } : {}), ...(this.only ? { only: this.only } : {}), deep: this.deep === true, noBoot: this.boot === false, strict: this.strict === true, }); if (this.json) { process.stdout.write(`${JSON.stringify(report)}\n`); } else { const fancy = process.stdout.isTTY === true && !process.env.NO_COLOR; const c = this.colors; process.stdout.write(renderAgoraDoctor(report, { verbose: this.verbose === true, fancy, paint: { green: (t) => c.green(t), yellow: (t) => c.yellow(t), red: (t) => c.red(t), dim: (t) => c.dim(t), bold: (t) => c.bold(t), }, })); } this.exitCode = exitCode; } catch (error) { if (!(error instanceof AgoraDoctorUsageError)) throw error; err(`agora:doctor: ${error.message}`); this.exitCode = 2; } } } __decorate([ flags.boolean({ description: 'Print one JSON object to stdout' }) ], AgoraDoctor.prototype, "json", void 0); __decorate([ flags.string({ description: 'Only these libs, comma separated (durable,payments)' }) ], AgoraDoctor.prototype, "lib", void 0); __decorate([ flags.boolean({ description: 'Also run checks that touch the database, Redis or the network' }) ], AgoraDoctor.prototype, "deep", void 0); __decorate([ flags.string({ description: 'Run one check by id' }) ], AgoraDoctor.prototype, "only", void 0); __decorate([ flags.boolean({ description: 'Fail (exit 1) on warnings too' }) ], AgoraDoctor.prototype, "strict", void 0); __decorate([ flags.boolean({ description: 'Show skipped checks and every message' }) ], AgoraDoctor.prototype, "verbose", void 0); __decorate([ flags.boolean({ description: 'Boot the app first; --no-boot checks the config only (when boot itself fails)', default: true, showNegatedVariantInHelp: true, }) ], AgoraDoctor.prototype, "boot", void 0); //# sourceMappingURL=agora_doctor.js.map