@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
71 lines • 3.41 kB
JavaScript
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 { flags } from '@adonisjs/core/ace';
import { AgentCommand } from '../src/cli/agent_command.js';
import { PoppyConnections } from '../src/poppy-connections/service.js';
/**
* `agent:crypto:reseal [--dry-run] [--json]` — re-seal what the agent keeps encrypted at rest (the
* poppy connections) with the active key of `crypto` in `config/poppy_connections.ts`: values in
* the pre-1.0 format and values sealed with a retired key. Exit `1` when a value could not be opened.
*/
export class AgentCryptoReseal extends AgentCommand {
static commandName = 'agent:crypto:reseal';
static description = 'Re-seal encrypted-at-rest values with the active key';
async execute() {
if (!this.app.container.hasBinding(PoppyConnections)) {
const empty = { walkable: true, dryRun: this.dryRun === true, columns: [] };
return this.output(empty, () => this.logger.info('Nothing sealed: poppy-connections is not configured.'));
}
const connections = await this.app.container.make(PoppyConnections);
const report = await connections.reseal({
dryRun: this.dryRun === true,
all: this.all === true,
});
if (!report.walkable) {
return this.refuse('The poppy-connections store cannot list its sealed values (a custom store needs `listSealed` and `replaceSealed`).');
}
this.output(report, (value) => {
this.table([
'Column',
'Scanned',
'Active',
'Retired',
'Legacy',
'Unreadable',
value.dryRun ? 'Would reseal' : 'Resealed',
'Failed',
'Skipped',
], value.columns.map((c) => [
c.column,
c.scanned,
c.active,
c.retired,
c.legacy,
c.unreadable,
c.resealed,
c.failed,
c.skipped,
]));
if (value.dryRun)
this.logger.info('Dry run: nothing was written.');
});
const failed = report.columns.reduce((total, c) => total + c.failed, 0);
if (failed > 0) {
this.logger.error(`${failed} value(s) could not be opened: a key is missing from \`crypto.keys\`, or the value is damaged.`);
this.exitCode = 1;
}
}
}
__decorate([
flags.boolean({ description: 'Count and test-open what would be re-sealed; write nothing' })
], AgentCryptoReseal.prototype, "dryRun", void 0);
__decorate([
flags.boolean({
description: 'Re-seal every value, not only retired/legacy ones (after rotating the keys of config/encryption.ts)',
})
], AgentCryptoReseal.prototype, "all", void 0);
//# sourceMappingURL=agent_crypto.js.map