@sprucelabs/spruce-cli
Version:
Command line interface for building Spruce skills.
76 lines • 2.9 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const schema_1 = require("@sprucelabs/schema");
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
const SpruceError_1 = __importDefault(require("../../../errors/SpruceError"));
const AbstractAction_1 = __importDefault(require("../../AbstractAction"));
const optionsSchema = (0, schema_1.buildSchema)({
id: 'registerAgentOptions',
description: 'Turn Sprucebot into an agent of your own design. Heck, even give him a new name! You can create a Platform Agent or a Skill Agent. Skill Agent coming soon...',
fields: {
type: {
label: 'Agent Type',
type: 'select',
hint: 'You can only create a System Agent if you have permission to do so...',
options: {
choices: [
{
value: 'system',
label: 'System Agent',
},
{
value: 'skill',
label: 'Skill Agent (coming soon)',
},
],
},
},
name: {
type: 'text',
label: 'Agent Name',
isRequired: true,
},
},
});
class RegisterAction extends AbstractAction_1.default {
optionsSchema = optionsSchema;
invocationMessage = 'Registering your AI Agent... 🤖';
async execute(options) {
const { name } = this.validateAndNormalizeOptions(options);
const writer = this.Writer('agent');
const promptPath = writer.resolveSystemPromptPath(this.cwd);
if (spruce_skill_utils_1.diskUtil.doesFileExist(promptPath)) {
return {
errors: [
new SpruceError_1.default({
code: 'AGENT_ALREADY_REGISTERED',
promptPath,
}),
],
};
}
const plugin = await writer.writePlugin(this.cwd);
const prompt = await writer.writeSystemPrompt(this.cwd, {
name,
});
return {
headline: `AI Agent ${name} Registered Successfully!`,
summaryLines: [
`Registered ${name} AI Agent!`,
`Agent name: ${name}`,
],
hints: [
'Next steps:',
' - Customize your agent prompt in agents/SYSTEM_PROMPT.md',
' - Boot your skill',
' - Message the agent (try responding to the pin code email/text)',
],
files: [...plugin, ...prompt],
};
}
}
exports.default = RegisterAction;
//# sourceMappingURL=RegisterAction.js.map