UNPKG

sensai

Version:

Because even AI needs a master

57 lines (56 loc) 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _nodetest = require("node:test"); const _nodeassert = /*#__PURE__*/ _interop_require_default(require("node:assert")); const _orchestrator = /*#__PURE__*/ _interop_require_default(require("./orchestrator")); const _nodepath = require("node:path"); function _interop_require_default(obj) { return obj && obj.__esModule ? obj : { default: obj }; } (0, _nodetest.describe)("orchestrator", ()=>{ (0, _nodetest.it)("should add and get orchestrated agents", ()=>{ const { add, get } = (0, _orchestrator.default)(); const path1 = (0, _nodepath.join)(_nodepath.sep, "api", "agent1", "prompt.md"); add(path1); const path2 = (0, _nodepath.join)(_nodepath.sep, "api", "agent2", "prompt.md"); add(path2); _nodeassert.default.deepEqual(get((0, _nodepath.join)(_nodepath.sep, "api")), { agent1: path1, agent2: path2 }); }); (0, _nodetest.it)("should remove agent from the orchestrator", ()=>{ const { add, get, remove } = (0, _orchestrator.default)(); const path1 = (0, _nodepath.join)(_nodepath.sep, "api", "agent1", "prompt.md"); add(path1); const path2 = (0, _nodepath.join)(_nodepath.sep, "api", "agent2", "prompt.md"); add(path2); remove(path1); _nodeassert.default.deepEqual(get((0, _nodepath.join)(_nodepath.sep, "api")), { agent2: path2 }); }); (0, _nodetest.it)("should return empty object if no agents", ()=>{ const { get } = (0, _orchestrator.default)(); _nodeassert.default.deepEqual(get((0, _nodepath.join)(_nodepath.sep, "api")), {}); }); (0, _nodetest.it)("should support parametric segments in paths", ()=>{ const { add, get } = (0, _orchestrator.default)(); const path1 = (0, _nodepath.join)(_nodepath.sep, "api", "[agent1]", "prompt.md"); add(path1); const path2 = (0, _nodepath.join)(_nodepath.sep, "api", "[...agent2]", "prompt.md"); add(path2); // optional catch all can not live alongside catch-all or slug but that does not matter here const path3 = (0, _nodepath.join)(_nodepath.sep, "api", "[[...agent3]]", "prompt.md"); add(path3); _nodeassert.default.deepEqual(get((0, _nodepath.join)(_nodepath.sep, "api")), { agent1: path1, agent2: path2, agent3: path3 }); }); });