UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

94 lines 4.02 kB
"use strict"; 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; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const test_utils_1 = require("@sprucelabs/test-utils"); const AbstractSkillTest_1 = __importDefault(require("../../../tests/AbstractSkillTest")); class RegisteringAnAgentAtBootTest extends AbstractSkillTest_1.default { static skillCacheKey = 'events'; static agentName = (0, test_utils_1.generateId)(); static agents; static skills; static async beforeEach() { await super.beforeEach(); this.agents = this.Store('agent'); this.skills = this.Store('skill'); } static async canCreateRegisteringAnAgentAtBoot() { const results = await this.register(); const expectedPlugin = this.resolvePath('src', '.spruce', 'features', 'agent.plugin.ts'); const expectedPrompt = this.resolvePath('agents/SYSTEM_PROMPT.md'); test_utils_1.assert.isEqualDeep(results.files, [ { path: expectedPlugin, name: 'agent.plugin.ts', action: 'generated', description: 'Supports your skill with registering ai agents.', }, { path: expectedPrompt, name: 'SYSTEM_PROMPT.md', action: 'generated', description: `The prompt file that defines how your AI Platform Agent behaves.`, }, ]); } static async bootingRegistersTheAgent() { await this.loginAndRegisterSkill(); await this.boot(); const agent = await this.getPlatformAgent(); test_utils_1.assert.isTruthy(agent, 'Did not register an agent at boot.'); test_utils_1.assert.isEqual(agent.name, this.agentName, 'Did not set name correctly.'); } static async returnsAnErrorIfAlreadyRegistered() { const results = await this.register(); test_utils_1.assert.isFalsy(results.files, 'Should not have created files.'); test_utils_1.assert.isTruthy(results.errors, 'Should have errors.'); } static async register() { return await this.Action('agent', 'register', { shouldAutoHandleDependencies: true, }).execute({ type: 'system', name: this.agentName, }); } static async loginAndRegisterSkill() { await this.people.loginAsDemoPerson(); await this.skills.register({ name: 'Agent skill', }); } static async boot() { await this.Action('skill', 'boot').execute({ local: true, onData: (data) => { this.log(`Boot Log: ${data}`); }, onError: (data) => { this.log(`Boot Error: ${data}`); }, }); } static async getPlatformAgent() { return await this.agents.getPlatformAgent(); } } exports.default = RegisteringAnAgentAtBootTest; __decorate([ (0, test_utils_1.test)() ], RegisteringAnAgentAtBootTest, "canCreateRegisteringAnAgentAtBoot", null); __decorate([ (0, test_utils_1.test)() ], RegisteringAnAgentAtBootTest, "bootingRegistersTheAgent", null); __decorate([ (0, test_utils_1.test)() ], RegisteringAnAgentAtBootTest, "returnsAnErrorIfAlreadyRegistered", null); //# sourceMappingURL=RegisteringAnAgentAtBoot.test.js.map