{"version":3,"file":"index.mjs","sources":["../node_modules/tslib/tslib.es6.js","../src/lib/services/context/MethodContextService.ts","../src/lib/core/di.ts","../src/lib/core/types.ts","../src/lib/services/context/ExecutionContextService.ts","../src/validation/validateNoEmptyResult.ts","../src/validation/validateNoToolCall.ts","../src/validation/validateDefault.ts","../src/classes/History.ts","../src/classes/Logger.ts","../src/config/params.ts","../src/utils/removeXmlTags.ts","../src/utils/nameToTitle.ts","../src/lib/services/base/LoggerService.ts","../src/lib/services/schema/AgentSchemaService.ts","../src/client/ClientAgent.ts","../src/lib/services/connection/AgentConnectionService.ts","../src/client/ClientHistory.ts","../src/lib/services/connection/HistoryConnectionService.ts","../src/lib/services/schema/ToolSchemaService.ts","../src/client/ClientSwarm.ts","../src/lib/services/connection/SwarmConnectionService.ts","../src/lib/services/schema/SwarmSchemaService.ts","../src/lib/services/schema/CompletionSchemaService.ts","../src/client/ClientSession.ts","../src/lib/services/connection/SessionConnectionService.ts","../src/lib/services/public/AgentPublicService.ts","../src/lib/services/public/HistoryPublicService.ts","../src/lib/services/public/SessionPublicService.ts","../src/lib/services/public/SwarmPublicService.ts","../src/lib/services/validation/AgentValidationService.ts","../src/lib/services/validation/CompletionValidationService.ts","../src/lib/services/validation/SessionValidationService.ts","../src/lib/services/validation/SwarmValidationService.ts","../src/lib/services/validation/ToolValidationService.ts","../src/lib/services/schema/EmbeddingSchemaService.ts","../src/lib/services/schema/StorageSchemaService.ts","../src/client/ClientStorage.ts","../src/lib/services/connection/StorageConnectionService.ts","../src/lib/services/public/StoragePublicService.ts","../src/lib/services/validation/StorageValidationService.ts","../src/lib/services/validation/EmbeddingValidationService.ts","../src/lib/services/schema/StateSchemaService.ts","../src/client/ClientState.ts","../src/lib/services/connection/StateConnectionService.ts","../src/lib/services/public/StatePublicService.ts","../src/lib/services/base/BusService.ts","../src/lib/core/provide.ts","../src/lib/index.ts","../src/functions/addAgent.ts","../src/functions/addCompletion.ts","../src/functions/addSwarm.ts","../src/functions/addTool.ts","../src/functions/addState.ts","../src/functions/addEmbeding.ts","../src/functions/addStorage.ts","../src/functions/commitUserMessage.ts","../src/functions/getAgentName.ts","../src/functions/makeConnection.ts","../src/functions/changeAgent.ts","../src/functions/disposeConnection.ts","../src/functions/complete.ts","../src/functions/session.ts","../src/functions/getRawHistory.ts","../src/functions/getAgentHistory.ts","../src/functions/getSessionMode.ts","../src/functions/commitToolOutput.ts","../src/functions/commitSystemMessage.ts","../src/functions/commitFlush.ts","../src/functions/execute.ts","../src/functions/emit.ts","../src/functions/commitToolOutputForce.ts","../src/functions/commitSystemMessageForce.ts","../src/functions/commitFlushForce.ts","../src/functions/commitUserMessageForce.ts","../src/functions/emitForce.ts","../src/functions/executeForce.ts","../src/functions/listenEvent.ts","../src/functions/listenEventOnce.ts","../src/functions/getLastUserMessage.ts","../src/functions/getUserHistory.ts","../src/functions/getAssistantHistory.ts","../src/functions/getLastAssistantMessage.ts","../src/functions/getLastSystemMessage.ts","../src/functions/makeAutoDispose.ts","../src/functions/event.ts","../src/functions/cancelOutput.ts","../src/functions/cancelOutputForce.ts","../src/events/listenAgentEvent.ts","../src/events/listenHistoryEvent.ts","../src/events/listenSessionEvent.ts","../src/events/listenStateEvent.ts","../src/events/listenStorageEvent.ts","../src/events/listenSwarmEvent.ts","../src/events/listenAgentEventOnce.ts","../src/events/listenHistoryEventOnce.ts","../src/events/listenSessionEventOnce.ts","../src/events/listenStateEventOnce.ts","../src/events/listenStorageEventOnce.ts","../src/events/listenSwarmEventOnce.ts","../src/classes/Storage.ts","../src/classes/State.ts","../src/utils/objectFlat.ts","../src/classes/Schema.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n    extendStatics = Object.setPrototypeOf ||\r\n        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n    return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n    if (typeof b !== \"function\" && b !== null)\r\n        throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n    extendStatics(d, b);\r\n    function __() { this.constructor = d; }\r\n    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n    __assign = Object.assign || function __assign(t) {\r\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n            s = arguments[i];\r\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n        }\r\n        return t;\r\n    }\r\n    return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n    var t = {};\r\n    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n        t[p] = s[p];\r\n    if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n                t[p[i]] = s[p[i]];\r\n        }\r\n    return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n    if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n    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;\r\n    return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n    return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n    function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n    var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n    var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n    var _, done = false;\r\n    for (var i = decorators.length - 1; i >= 0; i--) {\r\n        var context = {};\r\n        for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n        for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n        context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n        var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n        if (kind === \"accessor\") {\r\n            if (result === void 0) continue;\r\n            if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n            if (_ = accept(result.get)) descriptor.get = _;\r\n            if (_ = accept(result.set)) descriptor.set = _;\r\n            if (_ = accept(result.init)) initializers.unshift(_);\r\n        }\r\n        else if (_ = accept(result)) {\r\n            if (kind === \"field\") initializers.unshift(_);\r\n            else descriptor[key] = _;\r\n        }\r\n    }\r\n    if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n    done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n    var useValue = arguments.length > 2;\r\n    for (var i = 0; i < initializers.length; i++) {\r\n        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n    }\r\n    return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n    return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n    if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n    return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n    if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n    return new (P || (P = Promise))(function (resolve, reject) {\r\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n    });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n    return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n    function verb(n) { return function (v) { return step([n, v]); }; }\r\n    function step(op) {\r\n        if (f) throw new TypeError(\"Generator is already executing.\");\r\n        while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n            if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n            if (y = 0, t) op = [op[0] & 2, t.value];\r\n            switch (op[0]) {\r\n                case 0: case 1: t = op; break;\r\n                case 4: _.label++; return { value: op[1], done: false };\r\n                case 5: _.label++; y = op[1]; op = [0]; continue;\r\n                case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n                default:\r\n                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n                    if (t[2]) _.ops.pop();\r\n                    _.trys.pop(); continue;\r\n            }\r\n            op = body.call(thisArg, _);\r\n        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n    }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n    if (k2 === undefined) k2 = k;\r\n    var desc = Object.getOwnPropertyDescriptor(m, k);\r\n    if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n        desc = { enumerable: true, get: function() { return m[k]; } };\r\n    }\r\n    Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n    if (k2 === undefined) k2 = k;\r\n    o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n    for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n    var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n    if (m) return m.call(o);\r\n    if (o && typeof o.length === \"number\") return {\r\n        next: function () {\r\n            if (o && i >= o.length) o = void 0;\r\n            return { value: o && o[i++], done: !o };\r\n        }\r\n    };\r\n    throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n    var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n    if (!m) return o;\r\n    var i = m.call(o), r, ar = [], e;\r\n    try {\r\n        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n    }\r\n    catch (error) { e = { error: error }; }\r\n    finally {\r\n        try {\r\n            if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n        }\r\n        finally { if (e) throw e.error; }\r\n    }\r\n    return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n    for (var ar = [], i = 0; i < arguments.length; i++)\r\n        ar = ar.concat(__read(arguments[i]));\r\n    return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n    for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n            r[k] = a[j];\r\n    return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n        if (ar || !(i in from)) {\r\n            if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n            ar[i] = from[i];\r\n        }\r\n    }\r\n    return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n    return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n    if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n    var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n    return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n    function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n    function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n    function fulfill(value) { resume(\"next\", value); }\r\n    function reject(value) { resume(\"throw\", value); }\r\n    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n    var i, p;\r\n    return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n    function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n    if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n    var m = o[Symbol.asyncIterator], i;\r\n    return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n    if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n    return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n    Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n    o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n    if (mod && mod.__esModule) return mod;\r\n    var result = {};\r\n    if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n    __setModuleDefault(result, mod);\r\n    return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n    return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n    if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n    if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n    return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n    if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n    if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n    if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n    return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n    if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n    return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n    if (value !== null && value !== void 0) {\r\n        if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n        var dispose, inner;\r\n        if (async) {\r\n            if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n            dispose = value[Symbol.asyncDispose];\r\n        }\r\n        if (dispose === void 0) {\r\n            if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n            dispose = value[Symbol.dispose];\r\n            if (async) inner = dispose;\r\n        }\r\n        if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n        if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n        env.stack.push({ value: value, dispose: dispose, async: async });\r\n    }\r\n    else if (async) {\r\n        env.stack.push({ async: true });\r\n    }\r\n    return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n    var e = new Error(message);\r\n    return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n    function fail(e) {\r\n        env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n        env.hasError = true;\r\n    }\r\n    var r, s = 0;\r\n    function next() {\r\n        while (r = env.stack.pop()) {\r\n            try {\r\n                if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n                if (r.dispose) {\r\n                    var result = r.dispose.call(r.value);\r\n                    if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n                }\r\n                else s |= 1;\r\n            }\r\n            catch (e) {\r\n                fail(e);\r\n            }\r\n        }\r\n        if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n        if (env.hasError) throw env.error;\r\n    }\r\n    return next();\r\n}\r\n\r\nexport default {\r\n    __extends: __extends,\r\n    __assign: __assign,\r\n    __rest: __rest,\r\n    __decorate: __decorate,\r\n    __param: __param,\r\n    __metadata: __metadata,\r\n    __awaiter: __awaiter,\r\n    __generator: __generator,\r\n    __createBinding: __createBinding,\r\n    __exportStar: __exportStar,\r\n    __values: __values,\r\n    __read: __read,\r\n    __spread: __spread,\r\n    __spreadArrays: __spreadArrays,\r\n    __spreadArray: __spreadArray,\r\n    __await: __await,\r\n    __asyncGenerator: __asyncGenerator,\r\n    __asyncDelegator: __asyncDelegator,\r\n    __asyncValues: __asyncValues,\r\n    __makeTemplateObject: __makeTemplateObject,\r\n    __importStar: __importStar,\r\n    __importDefault: __importDefault,\r\n    __classPrivateFieldGet: __classPrivateFieldGet,\r\n    __classPrivateFieldSet: __classPrivateFieldSet,\r\n    __classPrivateFieldIn: __classPrivateFieldIn,\r\n    __addDisposableResource: __addDisposableResource,\r\n    __disposeResources: __disposeResources,\r\n};\r\n","import { scoped } from \"di-scoped\";\r\nimport { AgentName } from \"../../../interfaces/Agent.interface\";\r\nimport { SwarmName } from \"../../../interfaces/Swarm.interface\";\r\nimport { StorageName } from \"../../../interfaces/Storage.interface\";\r\nimport { StateName } from \"../../../interfaces/State.interface\";\r\n\r\n/**\r\n * Interface representing the context.\r\n */\r\nexport interface IMethodContext {\r\n  clientId: string;\r\n  methodName: string;\r\n  agentName: AgentName;\r\n  swarmName: SwarmName;\r\n  storageName: StorageName;\r\n  stateName: StateName;\r\n}\r\n\r\n/**\r\n * Service providing method call context information.\r\n */\r\nexport const MethodContextService = scoped(\r\n  class {\r\n    /**\r\n     * Creates an instance of MethodContextService.\r\n     * @param {IMethodContext} context - The context object.\r\n     */\r\n    constructor(readonly context: IMethodContext) {}\r\n  }\r\n);\r\n\r\n/**\r\n * Type representing an instance of MethodContextService.\r\n */\r\nexport type TMethodContextService = InstanceType<typeof MethodContextService>;\r\n\r\nexport default MethodContextService;\r\n","import { createActivator } from \"di-kit\";\r\n\r\nexport const { init, inject, provide } = createActivator(\"agent-swarm\");\r\n","const baseServices = {\r\n    busService: Symbol('busService'),\r\n    loggerService: Symbol('loggerService'),\r\n};\r\n\r\nconst contextServices = {\r\n    methodContextService: Symbol('methodContextService'),\r\n    executionContextService: Symbol('executionContextService'),\r\n};\r\n\r\nconst connectionServices = {\r\n    agentConnectionService: Symbol('agentConnectionService'),\r\n    historyConnectionService: Symbol('historyConnectionService'),\r\n    swarmConnectionService: Symbol('swarmConnectionService'),\r\n    sessionConnectionService: Symbol('sessionConnectionService'),\r\n    storageConnectionService: Symbol('storageConnectionService'),\r\n    stateConnectionService: Symbol('stateConnectionService'),\r\n};\r\n\r\nconst schemaServices = {\r\n    completionSchemaService: Symbol('completionSchemaService'),\r\n    agentSchemaService: Symbol('agentSchemaService'),\r\n    swarmSchemaService: Symbol('swarmSchemaService'),\r\n    toolSchemaService: Symbol('toolSchemaService'),\r\n    embeddingSchemaService: Symbol('embeddingSchemaService'),\r\n    storageSchemaService: Symbol('storageSchemaService'),\r\n    stateSchemaService: Symbol('stateSchemaService'),\r\n};\r\n\r\nconst publicServices = {\r\n    agentPublicService: Symbol('agentPublicService'),\r\n    historyPublicService: Symbol('historyPublicService'),\r\n    sessionPublicService: Symbol('sessionPublicService'),\r\n    swarmPublicService: Symbol('swarmPublicService'),\r\n    storagePublicService: Symbol('storagePublicService'),\r\n    statePublicService: Symbol('statePublicService'),\r\n};\r\n\r\nconst validationServices = {\r\n    agentValidationService: Symbol('agentValidationService'),\r\n    toolValidationService: Symbol('toolValidationService'),\r\n    sessionValidationService: Symbol('sessionValidationService'),\r\n    swarmValidationService: Symbol('swarmValidationService'),\r\n    completionValidationService: Symbol('completionValidationService'),\r\n    embeddingValidationService: Symbol('embeddingValidationService'),\r\n    storageValidationService: Symbol('storageValidationService'),\r\n};\r\n\r\nexport const TYPES = {\r\n    ...baseServices,\r\n    ...contextServices,\r\n    ...schemaServices,\r\n    ...connectionServices,\r\n    ...publicServices,\r\n    ...validationServices,\r\n}\r\n\r\nexport default TYPES;\r\n","import { scoped } from \"di-scoped\";\r\n\r\n/**\r\n * Interface representing the context.\r\n */\r\nexport interface IExecutionContext {\r\n  clientId: string;\r\n  executionId: string;\r\n}\r\n\r\n/**\r\n * Service providing execution context information.\r\n */\r\nexport const ExecutionContextService = scoped(\r\n  class {\r\n    /**\r\n     * Creates an instance of ExecutionContextService.\r\n     * @param {IExecutionContext} context - The context object.\r\n     */\r\n    constructor(readonly context: IExecutionContext) {}\r\n  }\r\n);\r\n\r\n/**\r\n * Type representing an instance of ExecutionContextService.\r\n */\r\nexport type TExecutionContextService = InstanceType<typeof ExecutionContextService>;\r\n\r\nexport default ExecutionContextService;\r\n","/**\r\n * Validates that the given output string is not empty.\r\n * \r\n * @param {string} output - The output string to validate.\r\n * @returns {Promise<string | null>} - Returns a promise that resolves to \"Empty output\" if the string is empty, otherwise null.\r\n */\r\nexport const validateNoEmptyResult = async (output: string): Promise<string | null> => {\r\n  if (!output.trim()) {\r\n    return \"Empty output\";\r\n  }\r\n  return null;\r\n};\r\n\r\nexport default validateNoEmptyResult;\r\n","import { trycatch } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport xml2js from \"xml2js\";\r\n\r\nconst toolParser = new xml2js.Parser();\r\n\r\n/**\r\n * Validates that the given output string does not contain any tool call entries or disallowed symbols.\r\n * @see https://github.com/ollama/ollama/issues/8287\r\n * \r\n * @param {string} output - The output string to validate.\r\n * @returns {Promise<string | null>} - A promise that resolves to a string indicating a tool call in the text output, or null if no tool call is found.\r\n * @throws {Error} - If an error occurs during XML parsing.\r\n */\r\nexport const validateNoToolCall: (output: string) => Promise<string | null> = trycatch(\r\n  async (output: string) => {\r\n    for (const symbol of GLOBAL_CONFIG.CC_AGENT_DISALLOWED_SYMBOLS) {\r\n      if (output.includes(symbol)) {\r\n        return \"Tool call in text output\";\r\n      }\r\n    }\r\n    const result = await toolParser.parseStringPromise(output);\r\n    for (const tag of GLOBAL_CONFIG.CC_AGENT_DISALLOWED_TAGS) {\r\n      if (result[tag]) {\r\n        return \"Tool call in text output\";\r\n      }\r\n    }\r\n    return null;\r\n  },\r\n  {\r\n    defaultValue: null,\r\n  }\r\n);\r\n\r\nexport default validateNoToolCall;\r\n","import validateNoEmptyResult from \"./validateNoEmptyResult\";\r\nimport validateNoToolCall from \"./validateNoToolCall\";\r\n\r\n/**\r\n * Validates the given output string using a series of validation functions.\r\n * \r\n * @param {string} output - The output string to validate.\r\n * @returns {Promise<string | null>} - A promise that resolves to a validation error message if any validation fails, or null if all validations pass.\r\n */\r\nexport const validateDefault = async (output: string): Promise<string | null> => {\r\n  let validation: string | null = null;\r\n  if (validation = await validateNoEmptyResult(output)) {\r\n    return validation;\r\n  }\r\n  if (validation = await validateNoToolCall(output)) {\r\n    return validation;\r\n  }\r\n  return null;\r\n};\r\n\r\nexport default validateDefault;\r\n","import { memoize, singleshot } from \"functools-kit\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport { IModelMessage } from \"../model/ModelMessage.model\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\n/**\r\n * Interface for History Adapter Callbacks\r\n */\r\nexport interface IHistoryInstanceCallbacks {\r\n\r\n  /**\r\n   * Callback for compute of dynamic system prompt\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns An array of additional system prompt messages\r\n   */\r\n  getSystemPrompt?: (\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => Promise<string[]> | string[];\r\n\r\n  /**\r\n   * Filter condition for history messages.\r\n   * @param message - The model message.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns A promise that resolves to a boolean indicating whether the message passes the filter.\r\n   */\r\n  filterCondition?: (\r\n    message: IModelMessage,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => Promise<boolean> | boolean;\r\n\r\n  /**\r\n   * Get data for the history.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns A promise that resolves to an array of model messages.\r\n   */\r\n  getData: (\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => Promise<IModelMessage[]> | IModelMessage[];\r\n\r\n  /**\r\n   * Callback for when the history changes.\r\n   * @param data - The array of model messages.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   */\r\n  onChange: (\r\n    data: IModelMessage[],\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => void;\r\n\r\n  /**\r\n   * Callback for when the history get the new message\r\n   * @param data - The array of model messages.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   */\r\n  onPush: (data: IModelMessage, clientId: string, agentName: AgentName) => void;\r\n\r\n  /**\r\n   * Callback for when the history is read. Will be called for each message\r\n   * @param message - The model message.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   */\r\n  onRead: (\r\n    message: IModelMessage,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => void;\r\n\r\n  /**\r\n   * Callback for when the read is begin\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   */\r\n  onReadBegin: (clientId: string, agentName: AgentName) => void;\r\n\r\n  /**\r\n   * Callback for when the read is end\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   */\r\n  onReadEnd: (clientId: string, agentName: AgentName) => void;\r\n\r\n  /**\r\n   * Callback for when the history is disposed.\r\n   * @param clientId - The client ID.\r\n   */\r\n  onDispose: (clientId: string) => void;\r\n\r\n  /**\r\n   * Callback for when the history is initialized.\r\n   * @param clientId - The client ID.\r\n   */\r\n  onInit: (clientId: string) => void;\r\n\r\n  /**\r\n   * Callback to obtain history ref\r\n   * @param clientId - The client ID.\r\n   */\r\n  onRef: (history: HistoryInstance) => void;\r\n}\r\n\r\n/**\r\n * Interface for History Adapter\r\n */\r\nexport interface IHistoryAdapter {\r\n  /**\r\n   * Iterate over the history messages.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns An async iterable iterator of model messages.\r\n   */\r\n  iterate(\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ): AsyncIterableIterator<IModelMessage>;\r\n\r\n  /**\r\n   * Push a new message to the history.\r\n   * @param value - The model message to push.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns A promise that resolves when the message is pushed.\r\n   */\r\n  push: (\r\n    value: IModelMessage,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => Promise<void>;\r\n\r\n  /**\r\n   * Dispose of the history for a given client and agent.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name or null.\r\n   * @returns A promise that resolves when the history is disposed.\r\n   */\r\n  dispose: (clientId: string, agentName: AgentName | null) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Interface for History Control\r\n */\r\nexport interface IHistoryControl {\r\n  /**\r\n   * Use a custom history adapter.\r\n   * @param Ctor - The constructor for the history instance.\r\n   */\r\n  useHistoryAdapter(Ctor: THistoryInstanceCtor): void;\r\n\r\n  /**\r\n   * Use history lifecycle callbacks.\r\n   * @param Callbacks - The callbacks dictionary.\r\n   */\r\n  useHistoryCallbacks: (Callbacks: Partial<IHistoryInstanceCallbacks>) => void;\r\n}\r\n\r\n/**\r\n * Interface for History Instance\r\n */\r\nexport interface IHistoryInstance {\r\n  /**\r\n   * Iterate over the history messages for a given agent.\r\n   * @param agentName - The agent name.\r\n   * @returns An async iterable iterator of model messages.\r\n   */\r\n  iterate(agentName: AgentName): AsyncIterableIterator<IModelMessage>;\r\n\r\n  /**\r\n   * Wait for the history to initialize.\r\n   * @param agentName - The agent name.\r\n   * @param init - Whether the history is initializing.\r\n   * @returns A promise that resolves when the history is initialized.\r\n   */\r\n  waitForInit(agentName: AgentName, init: boolean): Promise<void>;\r\n\r\n  /**\r\n   * Push a new message to the history for a given agent.\r\n   * @param value - The model message to push.\r\n   * @param agentName - The agent name.\r\n   * @returns A promise that resolves when the message is pushed.\r\n   */\r\n  push(value: IModelMessage, agentName: AgentName): Promise<void>;\r\n\r\n  /**\r\n   * Dispose of the history for a given agent.\r\n   * @param agentName - The agent name or null.\r\n   * @returns A promise that resolves when the history is disposed.\r\n   */\r\n  dispose(agentName: AgentName | null): Promise<void>;\r\n}\r\n\r\n/**\r\n * Type for History Instance Constructor\r\n */\r\nexport type THistoryInstanceCtor = new (\r\n  clientId: string,\r\n  ...args: unknown[]\r\n) => IHistoryInstance;\r\n\r\nconst HISTORY_INSTANCE_WAIT_FOR_INIT = Symbol(\"wait-for-init\");\r\n\r\nconst INSTANCE_METHOD_NAME_WAIT_FOR_INIT = \"HistoryInstance.waitForInit\";\r\nconst INSTANCE_METHOD_NAME_CTOR = \"HistoryInstance.CTOR\";\r\nconst INSTANCE_METHOD_NAME_ITERATE_CONDITION =\r\n  \"HistoryInstance.iterate condition\";\r\nconst INSTANCE_METHOD_NAME_ITERATE = \"HistoryInstance.iterate\";\r\nconst INSTANCE_METHOD_NAME_PUSH = \"HistoryInstance.push\";\r\nconst INSTANCE_METHOD_NAME_DISPOSE = \"HistoryInstance.dispose\";\r\n\r\nconst METHOD_NAME_USE_HISTORY_ADAPTER = \"HistoryUtils.useHistoryAdapter\";\r\nconst METHOD_NAME_USE_HISTORY_CALLBACKS = \"HistoryUtils.useHistoryCallbacks\";\r\nconst METHOD_NAME_ITERATE = \"HistoryUtils.iterate\";\r\nconst METHOD_NAME_PUSH = \"HistoryUtils.push\";\r\nconst METHOD_NAME_DISPOSE = \"HistoryUtils.dispose\";\r\n\r\n/**\r\n * Class representing a History Instance\r\n */\r\nexport class HistoryInstance implements IHistoryInstance {\r\n  private _array: IModelMessage[] = [];\r\n\r\n  /**\r\n   * Makes the singleshot for initialization\r\n   * @param agentName - The agent name.\r\n   */\r\n  private [HISTORY_INSTANCE_WAIT_FOR_INIT] = singleshot(\r\n    async (agentName: AgentName) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n        swarm.loggerService.debug(INSTANCE_METHOD_NAME_WAIT_FOR_INIT, {\r\n          clientId: this.clientId,\r\n          agentName,\r\n        });\r\n      if (this.callbacks.getData) {\r\n        this._array = await this.callbacks.getData(this.clientId, agentName);\r\n      }\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Wait for the history to initialize.\r\n   * @param agentName - The agent name.\r\n   */\r\n  public async waitForInit(agentName: AgentName): Promise<void> {\r\n    return await this[HISTORY_INSTANCE_WAIT_FOR_INIT](agentName);\r\n  }\r\n\r\n  /**\r\n   * Create a HistoryInstance.\r\n   * @param clientId - The client ID.\r\n   * @param callbacks - The callbacks for the history instance.\r\n   */\r\n  constructor(\r\n    readonly clientId: string,\r\n    readonly callbacks: Partial<IHistoryInstanceCallbacks>\r\n  ) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      swarm.loggerService.debug(INSTANCE_METHOD_NAME_CTOR, {\r\n        clientId: this.clientId,\r\n      });\r\n    if (callbacks.onInit) {\r\n      callbacks.onInit(clientId);\r\n    }\r\n    if (callbacks.onRef) {\r\n      callbacks.onRef(this);\r\n    }\r\n    if (callbacks.filterCondition) {\r\n      this.iterate = async function* (\r\n        agentName: AgentName\r\n      ): AsyncIterableIterator<IModelMessage> {\r\n        GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n          swarm.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE_CONDITION, {\r\n            clientId: this.clientId,\r\n            agentName,\r\n          });\r\n        if (this.callbacks.onRead) {\r\n          this.callbacks.onReadBegin &&\r\n            this.callbacks.onReadBegin(this.clientId, agentName);\r\n          for (const item of this._array) {\r\n            if (\r\n              await this.callbacks.filterCondition(\r\n                item,\r\n                this.clientId,\r\n                agentName\r\n              )\r\n            ) {\r\n              this.callbacks.onRead(item, this.clientId, agentName);\r\n              yield item;\r\n            }\r\n          }\r\n          if (this.callbacks.getSystemPrompt) {\r\n            for (const content of await this.callbacks.getSystemPrompt(this.clientId, agentName)) {\r\n              yield {\r\n                role: \"system\",\r\n                content,\r\n                agentName,\r\n                mode: \"tool\"\r\n              }\r\n            }\r\n          }\r\n          this.callbacks.onReadEnd &&\r\n            this.callbacks.onReadEnd(this.clientId, agentName);\r\n          return;\r\n        }\r\n        this.callbacks.onReadBegin &&\r\n          this.callbacks.onReadBegin(this.clientId, agentName);\r\n        for (const item of this._array) {\r\n          if (\r\n            await this.callbacks.filterCondition(item, this.clientId, agentName)\r\n          ) {\r\n            yield item;\r\n          }\r\n        }\r\n        if (this.callbacks.getSystemPrompt) {\r\n          for (const content of await this.callbacks.getSystemPrompt(this.clientId, agentName)) {\r\n            yield {\r\n              role: \"system\",\r\n              content,\r\n              agentName,\r\n              mode: \"tool\"\r\n            }\r\n          }\r\n        }\r\n        this.callbacks.onReadEnd &&\r\n          this.callbacks.onReadEnd(this.clientId, agentName);\r\n      };\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Iterate over the history messages for a given agent.\r\n   * @param agentName - The agent name.\r\n   * @returns An async iterable iterator of model messages.\r\n   */\r\n  public async *iterate(\r\n    agentName: AgentName\r\n  ): AsyncIterableIterator<IModelMessage> {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      swarm.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE, {\r\n        clientId: this.clientId,\r\n        agentName,\r\n      });\r\n    if (this.callbacks.onRead) {\r\n      this.callbacks.onReadBegin &&\r\n        this.callbacks.onReadBegin(this.clientId, agentName);\r\n      for (const item of this._array) {\r\n        this.callbacks.onRead(item, this.clientId, agentName);\r\n        yield item;\r\n      }\r\n      this.callbacks.onReadEnd &&\r\n        this.callbacks.onReadEnd(this.clientId, agentName);\r\n      return;\r\n    }\r\n    this.callbacks.onReadBegin &&\r\n      this.callbacks.onReadBegin(this.clientId, agentName);\r\n    for (const item of this._array) {\r\n      yield item;\r\n    }\r\n    if (this.callbacks.getSystemPrompt) {\r\n      for (const content of await this.callbacks.getSystemPrompt(this.clientId, agentName)) {\r\n        yield {\r\n          role: \"system\",\r\n          content,\r\n          agentName,\r\n          mode: \"tool\"\r\n        }\r\n      }\r\n    }\r\n    this.callbacks.onReadEnd &&\r\n      this.callbacks.onReadEnd(this.clientId, agentName);\r\n  }\r\n\r\n  /**\r\n   * Push a new message to the history for a given agent.\r\n   * @param value - The model message to push.\r\n   * @param agentName - The agent name.\r\n   * @returns A promise that resolves when the message is pushed.\r\n   */\r\n  public push(value: IModelMessage, agentName: AgentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      swarm.loggerService.debug(INSTANCE_METHOD_NAME_PUSH, {\r\n        clientId: this.clientId,\r\n        agentName,\r\n      });\r\n    this.callbacks.onPush &&\r\n      this.callbacks.onPush(value, this.clientId, agentName);\r\n    this._array.push(value);\r\n    this.callbacks.onChange &&\r\n      this.callbacks.onChange(this._array, this.clientId, agentName);\r\n    return Promise.resolve();\r\n  }\r\n\r\n  /**\r\n   * Dispose of the history for a given agent.\r\n   * @param agentName - The agent name or null.\r\n   * @returns A promise that resolves when the history is disposed.\r\n   */\r\n  public dispose(agentName: AgentName | null) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      swarm.loggerService.debug(INSTANCE_METHOD_NAME_DISPOSE, {\r\n        clientId: this.clientId,\r\n        agentName,\r\n      });\r\n    if (agentName === null) {\r\n      this.callbacks.onDispose && this.callbacks.onDispose(this.clientId);\r\n      this._array = [];\r\n    }\r\n    return Promise.resolve();\r\n  }\r\n}\r\n\r\n/**\r\n * Class representing History Utilities\r\n */\r\nclass HistoryUtils implements IHistoryAdapter, IHistoryControl {\r\n  private HistoryFactory: THistoryInstanceCtor = HistoryInstance;\r\n  private HistoryCallbacks: Partial<IHistoryInstanceCallbacks> = {};\r\n\r\n  private getHistory = memoize(\r\n    ([clientId]) => clientId,\r\n    (clientId: string) =>\r\n      new this.HistoryFactory(clientId, this.HistoryCallbacks)\r\n  );\r\n\r\n  /**\r\n   * Use a custom history adapter.\r\n   * @param Ctor - The constructor for the history instance.\r\n   */\r\n  public useHistoryAdapter = (Ctor: THistoryInstanceCtor) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_USE_HISTORY_ADAPTER);\r\n    this.HistoryFactory = Ctor;\r\n  };\r\n\r\n  /**\r\n   * Use history lifecycle callbacks.\r\n   * @param Callbacks - The callbacks dictionary.\r\n   */\r\n  public useHistoryCallbacks = (\r\n    Callbacks: Partial<IHistoryInstanceCallbacks>\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_USE_HISTORY_CALLBACKS);\r\n    Object.assign(this.HistoryCallbacks, Callbacks);\r\n  };\r\n\r\n  /**\r\n   * Iterate over the history messages.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns An async iterable iterator of model messages.\r\n   */\r\n  public async *iterate(\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ): AsyncIterableIterator<IModelMessage> {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_ITERATE, {\r\n        clientId,\r\n        agentName,\r\n      });\r\n    const isInitial = this.getHistory.has(clientId);\r\n    const history = await this.getHistory(clientId);\r\n    await history.waitForInit(agentName, isInitial);\r\n    for await (const item of history.iterate(agentName)) {\r\n      yield item;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Push a new message to the history.\r\n   * @param value - The model message to push.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name.\r\n   * @returns A promise that resolves when the message is pushed.\r\n   */\r\n  public push = async (\r\n    value: IModelMessage,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_PUSH, {\r\n        clientId,\r\n        agentName,\r\n        value,\r\n      });\r\n    const isInitial = this.getHistory.has(clientId);\r\n    const history = await this.getHistory(clientId);\r\n    await history.waitForInit(agentName, isInitial);\r\n    return await history.push(value, agentName);\r\n  };\r\n\r\n  /**\r\n   * Dispose of the history for a given client and agent.\r\n   * @param clientId - The client ID.\r\n   * @param agentName - The agent name or null.\r\n   * @returns A promise that resolves when the history is disposed.\r\n   */\r\n  public dispose = async (clientId: string, agentName: AgentName | null) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_DISPOSE, {\r\n        clientId,\r\n        agentName,\r\n      });\r\n    if (!this.getHistory.has(clientId)) {\r\n      return;\r\n    }\r\n    const history = await this.getHistory(clientId);\r\n    await history.waitForInit(agentName, false);\r\n    await history.dispose(agentName);\r\n    if (agentName === null) {\r\n      this.getHistory.clear(clientId);\r\n    }\r\n  };\r\n}\r\n\r\n/**\r\n * Exported History Adapter instance\r\n */\r\nexport const HistoryAdapter = new HistoryUtils();\r\n\r\n/**\r\n * Exported History Control instance\r\n */\r\nexport const History = HistoryAdapter as IHistoryControl;\r\n\r\nexport default HistoryAdapter;\r\n","import { ILogger } from \"../interfaces/Logger.interface\";\r\nimport swarm, { MethodContextService } from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { memoize, singleshot } from \"functools-kit\";\r\n\r\nconst LOGGER_INSTANCE_WAIT_FOR_INIT = Symbol(\"wait-for-init\");\r\n\r\n/**\r\n * @interface ILoggerInstanceCallbacks\r\n * @description Callbacks for logger instance events.\r\n */\r\nexport interface ILoggerInstanceCallbacks {\r\n  onInit(clientId: string): void;\r\n  onDispose(clientId: string): void;\r\n  onLog(clientId: string, topic: string, ...args: any[]): void;\r\n  onDebug(clientId: string, topic: string, ...args: any[]): void;\r\n  onInfo(clientId: string, topic: string, ...args: any[]): void;\r\n}\r\n\r\n/**\r\n * @interface ILoggerInstance\r\n * @extends ILogger\r\n * @description Interface for logger instances.\r\n */\r\nexport interface ILoggerInstance extends ILogger {\r\n  waitForInit(initial: boolean): Promise<void> | void;\r\n  dispose(): Promise<void> | void;\r\n}\r\n\r\n/**\r\n * @interface ILoggerAdapter\r\n * @description Interface for logger adapter.\r\n */\r\nexport interface ILoggerAdapter {\r\n  log(clientId: string, topic: string, ...args: any[]): Promise<void>;\r\n  debug(clientId: string, topic: string, ...args: any[]): Promise<void>;\r\n  info(clientId: string, topic: string, ...args: any[]): Promise<void>;\r\n  dispose(clientId: string): Promise<void>;\r\n}\r\n\r\n/**\r\n * @interface ILoggerControl\r\n * @description Interface for logger control.\r\n */\r\ninterface ILoggerControl {\r\n  useCommonAdapter(logger: ILogger): void;\r\n  useClientCallbacks(Callbacks: Partial<ILoggerInstanceCallbacks>): void;\r\n  useClientAdapter(Ctor: TLoggerInstanceCtor): void;\r\n  logClient(clientId: string, topic: string, ...args: any[]): Promise<void>;\r\n  infoClient(clientId: string, topic: string, ...args: any[]): Promise<void>;\r\n  debugClient(clientId: string, topic: string, ...args: any[]): Promise<void>;\r\n}\r\n\r\ntype TLoggerInstanceCtor = new (\r\n  clientId: string,\r\n  ...args: unknown[]\r\n) => ILoggerInstance;\r\n\r\n/**\r\n * @class LoggerInstance\r\n * @implements ILoggerInstance\r\n * @description Logger instance class.\r\n */\r\nexport class LoggerInstance implements ILoggerInstance {\r\n  constructor(\r\n    readonly clientId: string,\r\n    readonly callbacks: Partial<ILoggerInstanceCallbacks>\r\n  ) {}\r\n\r\n  private [LOGGER_INSTANCE_WAIT_FOR_INIT] = singleshot(async () => {\r\n    if (this.callbacks.onInit) {\r\n      this.callbacks.onInit(this.clientId);\r\n    }\r\n  });\r\n\r\n  /**\r\n   * @method waitForInit\r\n   * @description Waits for initialization.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public async waitForInit() {\r\n    return await this[LOGGER_INSTANCE_WAIT_FOR_INIT]();\r\n  }\r\n\r\n  /**\r\n   * @method log\r\n   * @description Logs a message.\r\n   * @param {string} topic - The topic of the log.\r\n   * @param {...any[]} args - The log arguments.\r\n   */\r\n  public log(topic: string, ...args: any[]) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE &&\r\n      console.log(`[clientId=${this.clientId}]`, topic, ...args);\r\n    if (this.callbacks.onLog) {\r\n      this.callbacks.onLog(this.clientId, topic, ...args);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @method debug\r\n   * @description Logs a debug message.\r\n   * @param {string} topic - The topic of the debug log.\r\n   * @param {...any[]} args - The debug log arguments.\r\n   */\r\n  public debug(topic: string, ...args: any[]) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE &&\r\n      console.debug(`[clientId=${this.clientId}]`, topic, ...args);\r\n    if (this.callbacks.onDebug) {\r\n      this.callbacks.onDebug(this.clientId, topic, ...args);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @method info\r\n   * @description Logs an info message.\r\n   * @param {string} topic - The topic of the info log.\r\n   * @param {...any[]} args - The info log arguments.\r\n   */\r\n  public info(topic: string, ...args: any[]) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE &&\r\n      console.info(`[clientId=${this.clientId}]`, topic, ...args);\r\n    if (this.callbacks.onInfo) {\r\n      this.callbacks.onInfo(this.clientId, topic, ...args);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @method dispose\r\n   * @description Disposes the logger instance.\r\n   */\r\n  public dispose() {\r\n    if (this.callbacks.onDispose) {\r\n      this.callbacks.onDispose(this.clientId);\r\n    }\r\n  }\r\n}\r\n\r\n/**\r\n * @class LoggerUtils\r\n * @implements ILoggerAdapter, ILoggerControl\r\n * @description Utility class for logger.\r\n */\r\nclass LoggerUtils implements ILoggerAdapter, ILoggerControl {\r\n  private LoggerFactory: TLoggerInstanceCtor = LoggerInstance;\r\n  private LoggerCallbacks: Partial<ILoggerInstanceCallbacks> = {};\r\n\r\n  private getLogger = memoize(\r\n    ([clientId]) => clientId,\r\n    (clientId: string) => new this.LoggerFactory(clientId, this.LoggerCallbacks)\r\n  );\r\n\r\n  /**\r\n   * @method useCommonAdapter\r\n   * @description Sets the common logger adapter.\r\n   * @param {ILogger} logger - The logger instance.\r\n   */\r\n  public useCommonAdapter = (logger: ILogger) => {\r\n    swarm.loggerService.setLogger(logger);\r\n  };\r\n\r\n  /**\r\n   * @method useClientCallbacks\r\n   * @description Sets the client-specific callbacks.\r\n   * @param {Partial<ILoggerInstanceCallbacks>} Callbacks - The callbacks.\r\n   */\r\n  public useClientCallbacks = (\r\n    Callbacks: Partial<ILoggerInstanceCallbacks>\r\n  ) => {\r\n    Object.assign(this.LoggerCallbacks, Callbacks);\r\n  };\r\n\r\n  /**\r\n   * @method useClientAdapter\r\n   * @description Sets the client-specific logger adapter.\r\n   * @param {TLoggerInstanceCtor} Ctor - The logger instance constructor.\r\n   */\r\n  public useClientAdapter = (Ctor: TLoggerInstanceCtor) => {\r\n    this.LoggerFactory = Ctor;\r\n  };\r\n\r\n  /**\r\n   * @method logClient\r\n   * @description Logs a message for a specific client.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} topic - The topic of the log.\r\n   * @param {...any[]} args - The log arguments.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public logClient = async (\r\n    clientId: string,\r\n    topic: string,\r\n    ...args: any[]\r\n  ) => {\r\n    if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG) {\r\n      return;\r\n    }\r\n    if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    await MethodContextService.runInContext(\r\n      async () => {\r\n        await swarm.loggerService.log(topic, ...args);\r\n      },\r\n      {\r\n        clientId,\r\n        agentName: \"\",\r\n        methodName: \"LoggerUtils.logClient\",\r\n        stateName: \"\",\r\n        storageName: \"\",\r\n        swarmName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * @method infoClient\r\n   * @description Logs an info message for a specific client.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} topic - The topic of the info log.\r\n   * @param {...any[]} args - The info log arguments.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public infoClient = async (\r\n    clientId: string,\r\n    topic: string,\r\n    ...args: any[]\r\n  ) => {\r\n    if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO) {\r\n      return;\r\n    }\r\n    if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    await MethodContextService.runInContext(\r\n      async () => {\r\n        await swarm.loggerService.info(topic, ...args);\r\n      },\r\n      {\r\n        clientId,\r\n        agentName: \"\",\r\n        methodName: \"LoggerUtils.infoClient\",\r\n        stateName: \"\",\r\n        storageName: \"\",\r\n        swarmName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * @method debugClient\r\n   * @description Logs a debug message for a specific client.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} topic - The topic of the debug log.\r\n   * @param {...any[]} args - The debug log arguments.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public debugClient = async (\r\n    clientId: string,\r\n    topic: string,\r\n    ...args: any[]\r\n  ) => {\r\n    if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG) {\r\n      return;\r\n    }\r\n    if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    await MethodContextService.runInContext(\r\n      async () => {\r\n        await swarm.loggerService.debug(topic, ...args);\r\n      },\r\n      {\r\n        clientId,\r\n        agentName: \"\",\r\n        methodName: \"LoggerUtils.debugClient\",\r\n        stateName: \"\",\r\n        storageName: \"\",\r\n        swarmName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * @method log\r\n   * @description Logs a message.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} topic - The topic of the log.\r\n   * @param {...any[]} args - The log arguments.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public log = async (clientId: string, topic: string, ...args: any[]) => {\r\n    if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG) {\r\n      return;\r\n    }\r\n    if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    const isInitial = this.getLogger.has(clientId);\r\n    const logger = this.getLogger(clientId);\r\n    await logger.waitForInit(isInitial);\r\n    await logger.log(topic, ...args);\r\n  };\r\n\r\n  /**\r\n   * @method debug\r\n   * @description Logs a debug message.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} topic - The topic of the debug log.\r\n   * @param {...any[]} args - The debug log arguments.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public debug = async (clientId: string, topic: string, ...args: any[]) => {\r\n    if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG) {\r\n      return;\r\n    }\r\n    if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    const isInitial = this.getLogger.has(clientId);\r\n    const logger = this.getLogger(clientId);\r\n    await logger.waitForInit(isInitial);\r\n    await logger.debug(topic, ...args);\r\n  };\r\n\r\n  /**\r\n   * @method info\r\n   * @description Logs an info message.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} topic - The topic of the info log.\r\n   * @param {...any[]} args - The info log arguments.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public info = async (clientId: string, topic: string, ...args: any[]) => {\r\n    if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO) {\r\n      return;\r\n    }\r\n    if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    const isInitial = this.getLogger.has(clientId);\r\n    const logger = this.getLogger(clientId);\r\n    await logger.waitForInit(isInitial);\r\n    await logger.info(topic, ...args);\r\n  };\r\n\r\n  /**\r\n   * @method dispose\r\n   * @description Disposes the logger instance.\r\n   * @param {string} clientId - The client ID.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async (clientId: string) => {\r\n    if (!this.getLogger.has(clientId)) {\r\n      return;\r\n    }\r\n    const logger = this.getLogger(clientId);\r\n    await logger.waitForInit(false);\r\n    await logger.dispose();\r\n    this.getLogger.clear(clientId);\r\n  };\r\n}\r\n\r\n/**\r\n * @constant LoggerAdapter\r\n * @description Singleton instance of LoggerUtils.\r\n */\r\nexport const LoggerAdapter = new LoggerUtils();\r\n\r\n/**\r\n * @constant Logger\r\n * @description Logger control interface.\r\n */\r\nexport const Logger = LoggerAdapter as ILoggerControl;\r\n\r\nexport default LoggerAdapter;\r\n","import { AgentName } from \"../interfaces/Agent.interface\";\r\nimport { IModelMessage } from \"../model/ModelMessage.model\";\r\nimport { SwarmName } from \"../interfaces/Swarm.interface\";\r\nimport validateDefault from \"../validation/validateDefault\";\r\nimport removeXmlTags from \"../utils/removeXmlTags\";\r\nimport { HistoryAdapter, IHistoryAdapter } from \"../classes/History\";\r\nimport nameToTitle from \"src/utils/nameToTitle\";\r\nimport LoggerAdapter, { ILoggerAdapter } from \"../classes/Logger\";\r\n\r\n/**\r\n * @description `ask for agent function` in `llama3.1:8b` to troubleshoot (need CC_OLLAMA_EMIT_TOOL_PROTOCOL to be turned off)\r\n */\r\nconst CC_TOOL_CALL_EXCEPTION_PROMPT = \"Start the conversation\";\r\n\r\n/**\r\n * @description When the model output is empty just say hello to the customer\r\n */\r\nconst CC_EMPTY_OUTPUT_PLACEHOLDERS = [\r\n  \"Sorry, I missed that. Could you say it again?\",\r\n  \"I couldn't catch that. Would you mind repeating?\",\r\n  \"I didn’t quite hear you. Can you repeat that, please?\",\r\n  \"Pardon me, I didn’t hear that clearly. Could you repeat it?\",\r\n  \"Sorry, I didn’t catch what you said. Could you say it again?\",\r\n  \"Could you repeat that? I didn’t hear it clearly.\",\r\n  \"I missed that. Can you say it one more time?\",\r\n  \"Sorry, I didn’t get that. Could you repeat it, please?\",\r\n  \"I didn’t hear you properly. Can you say that again?\",\r\n  \"Could you please repeat that? I didn’t catch it.\",\r\n];\r\n\r\nconst CC_SWARM_AGENT_CHANGED: (\r\n  clientId: string,\r\n  agentName: AgentName,\r\n  swarmName: SwarmName\r\n) => Promise<void> = async () => Promise.resolve();\r\n\r\nconst CC_SWARM_DEFAULT_AGENT: (\r\n  clientId: string,\r\n  swarmName: SwarmName,\r\n  defaultAgent: AgentName\r\n) => Promise<AgentName> = async ({}, {}, defaultAgent) => {\r\n  return defaultAgent;\r\n};\r\n\r\nconst CC_AGENT_DEFAULT_VALIDATION = validateDefault;\r\n\r\nconst CC_AGENT_DISALLOWED_TAGS = [\"tool_call\", \"toolcall\", \"tool\"];\r\n\r\nconst CC_AGENT_DISALLOWED_SYMBOLS = [\"{\", \"}\"];\r\n\r\nconst CC_AGENT_HISTORY_FILTER =\r\n  (agentName: AgentName) =>\r\n  (message: IModelMessage): boolean => {\r\n    let isOk = true;\r\n    if (message.role === \"tool\") {\r\n      isOk = isOk && message.agentName === agentName;\r\n    }\r\n    if (message.tool_calls) {\r\n      isOk = isOk && message.agentName === agentName;\r\n    }\r\n    return isOk;\r\n  };\r\n\r\nconst CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;\r\n\r\nconst CC_KEEP_MESSAGES = 5;\r\n\r\nconst CC_GET_AGENT_HISTORY_ADAPTER: (\r\n  clientId: string,\r\n  agentName: AgentName\r\n) => IHistoryAdapter = () => HistoryAdapter;\r\n\r\nconst CC_GET_CLIENT_LOGGER_ADAPTER: () => ILoggerAdapter = () => LoggerAdapter;\r\n\r\nconst CC_AGENT_OUTPUT_MAP = (\r\n  message: IModelMessage\r\n): IModelMessage | Promise<IModelMessage> => message;\r\n\r\nconst CC_AGENT_SYSTEM_PROMPT: string[] | undefined = undefined;\r\n\r\nconst CC_STORAGE_SEARCH_SIMILARITY = 0.65;\r\nconst CC_STORAGE_SEARCH_POOL = 5;\r\n\r\nconst CC_LOGGER_ENABLE_INFO = false;\r\nconst CC_LOGGER_ENABLE_DEBUG = false;\r\nconst CC_LOGGER_ENABLE_LOG = true;\r\nconst CC_LOGGER_ENABLE_CONSOLE = false;\r\n\r\nconst CC_NAME_TO_TITLE = nameToTitle;\r\n\r\nexport const GLOBAL_CONFIG = {\r\n  CC_TOOL_CALL_EXCEPTION_PROMPT,\r\n  CC_EMPTY_OUTPUT_PLACEHOLDERS,\r\n  CC_KEEP_MESSAGES,\r\n  CC_GET_AGENT_HISTORY_ADAPTER,\r\n  CC_GET_CLIENT_LOGGER_ADAPTER,\r\n  CC_SWARM_AGENT_CHANGED,\r\n  CC_SWARM_DEFAULT_AGENT,\r\n  CC_AGENT_DEFAULT_VALIDATION,\r\n  CC_AGENT_HISTORY_FILTER,\r\n  CC_AGENT_OUTPUT_TRANSFORM,\r\n  CC_AGENT_OUTPUT_MAP,\r\n  CC_AGENT_SYSTEM_PROMPT,\r\n  CC_AGENT_DISALLOWED_TAGS,\r\n  CC_AGENT_DISALLOWED_SYMBOLS,\r\n  CC_STORAGE_SEARCH_SIMILARITY,\r\n  CC_STORAGE_SEARCH_POOL,\r\n  CC_LOGGER_ENABLE_INFO,\r\n  CC_LOGGER_ENABLE_DEBUG,\r\n  CC_LOGGER_ENABLE_LOG,\r\n  CC_LOGGER_ENABLE_CONSOLE,\r\n  CC_NAME_TO_TITLE,\r\n};\r\n\r\nexport const setConfig = (config: Partial<typeof GLOBAL_CONFIG>) => {\r\n  Object.assign(GLOBAL_CONFIG, config);\r\n};\r\n","export const removeXmlTags = (input: string) => {\r\n    return input\r\n        .replace(/<[^>]+>[\\s\\S]*?<\\/[^>]+>/g, '')\r\n        .replace(/\\n\\s*\\n/g, '\\n')\r\n        .trim();\r\n};\r\n\r\n\r\nexport default removeXmlTags;\r\n","/**\r\n * Convert a name to title case.\r\n *\r\n * @param name - The name to convert to title case.\r\n * @return The name converted to title case.\r\n */\r\nexport const nameToTitle = (name: string) => {\r\n    if (!name) {\r\n        return undefined;\r\n    }\r\n    if (name.includes(\".\")) {\r\n        const tokens = name.split(\".\");\r\n        [name] = tokens.reverse();\r\n    }\r\n    const [word, ...rest] = name.split('_');\r\n    return [`${word.charAt(0).toUpperCase()}${word.slice(1)}`, ...rest].join(' ');\r\n};\r\n\r\nexport default nameToTitle;\r\n","import { inject } from \"../../../lib/core/di\";\r\nimport { ILogger } from \"../../../interfaces/Logger.interface\";\r\nimport MethodContextService, {\r\n  TMethodContextService,\r\n} from \"../context/MethodContextService\";\r\nimport TYPES from \"../../../lib/core/types\";\r\nimport ExecutionContextService, {\r\n  TExecutionContextService,\r\n} from \"../context/ExecutionContextService\";\r\nimport { singleshot } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\nconst NOOP_LOGGER: ILogger = {\r\n  /**\r\n   * Logs normal level messages.\r\n   */\r\n  log() {\r\n    void 0;\r\n  },\r\n  /**\r\n   * Logs debug level messages.\r\n   */\r\n  debug() {\r\n    void 0;\r\n  },\r\n  /**\r\n   * Logs info level messages.\r\n   */\r\n  info() {\r\n    void 0;\r\n  },\r\n};\r\n\r\n/**\r\n * LoggerService class that implements the ILogger interface.\r\n * Provides methods to log and debug messages.\r\n */\r\nexport class LoggerService implements ILogger {\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n  private readonly executionContextService = inject<TExecutionContextService>(\r\n    TYPES.executionContextService\r\n  );\r\n\r\n  private _commonLogger: ILogger = NOOP_LOGGER;\r\n\r\n  /**\r\n   * Creates the client logs adapter using factory\r\n   */\r\n  private getLoggerAdapter = singleshot(\r\n    GLOBAL_CONFIG.CC_GET_CLIENT_LOGGER_ADAPTER\r\n  );\r\n\r\n  /**\r\n   * Logs messages using the current logger.\r\n   * @param {...any} args - The messages to log.\r\n   */\r\n  public log = (topic: string, ...args: any[]) => {\r\n    const methodContext = MethodContextService.hasContext()\r\n      ? this.methodContextService.context\r\n      : null;\r\n    const executionContext = ExecutionContextService.hasContext()\r\n      ? this.executionContextService.context\r\n      : null;\r\n    const clientId = methodContext?.clientId ?? executionContext?.clientId;\r\n    const context = {\r\n      methodContext,\r\n      executionContext,\r\n    };\r\n    clientId && this.getLoggerAdapter().log(clientId, topic, ...args, context);\r\n    this._commonLogger.log(topic, ...args, context);\r\n  };\r\n\r\n  /**\r\n   * Logs debug messages using the current logger.\r\n   * @param {...any} args - The debug messages to log.\r\n   */\r\n  public debug = (topic: string, ...args: any[]) => {\r\n    const methodContext = MethodContextService.hasContext()\r\n      ? this.methodContextService.context\r\n      : null;\r\n    const executionContext = ExecutionContextService.hasContext()\r\n      ? this.executionContextService.context\r\n      : null;\r\n    const clientId = methodContext?.clientId ?? executionContext?.clientId;\r\n    const context = {\r\n      methodContext,\r\n      executionContext,\r\n    };\r\n    clientId &&\r\n      this.getLoggerAdapter().debug(clientId, topic, ...args, context);\r\n    this._commonLogger.debug(topic, ...args, context);\r\n  };\r\n\r\n  /**\r\n   * Logs info messages using the current logger.\r\n   * @param {...any} args - The info messages to log.\r\n   */\r\n  public info = (topic: string, ...args: any[]) => {\r\n    const methodContext = MethodContextService.hasContext()\r\n      ? this.methodContextService.context\r\n      : null;\r\n    const executionContext = ExecutionContextService.hasContext()\r\n      ? this.executionContextService.context\r\n      : null;\r\n    const clientId = methodContext?.clientId ?? executionContext?.clientId;\r\n    const context = {\r\n      methodContext,\r\n      executionContext,\r\n    };\r\n    clientId && this.getLoggerAdapter().info(clientId, topic, ...args, context);\r\n    this._commonLogger.info(topic, ...args, context);\r\n  };\r\n\r\n  /**\r\n   * Sets a new logger.\r\n   * @param {ILogger} logger - The new logger to set.\r\n   */\r\n  public setLogger = (logger: ILogger) => {\r\n    this._commonLogger = logger;\r\n  };\r\n}\r\n\r\nexport default LoggerService;\r\n","import { ToolRegistry } from \"functools-kit\";\r\nimport { AgentName, IAgentSchema } from \"../../../interfaces/Agent.interface\";\r\nimport { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport TYPES from \"../../core/types\";\r\n\r\n/**\r\n * Service for managing agent schemas.\r\n */\r\nexport class AgentSchemaService {\r\n  readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<Record<AgentName, IAgentSchema>>(\r\n    \"agentSchemaService\"\r\n  );\r\n\r\n  /**\r\n   * Registers a new agent schema.\r\n   * @param {AgentName} key - The name of the agent.\r\n   * @param {IAgentSchema} value - The schema of the agent.\r\n   */\r\n  public register = (key: AgentName, value: IAgentSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentSchemaService register`, { key });\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves an agent schema by name.\r\n   * @param {AgentName} key - The name of the agent.\r\n   * @returns {IAgentSchema} The schema of the agent.\r\n   */\r\n  public get = (key: AgentName): IAgentSchema => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentSchemaService get`, { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default AgentSchemaService;\r\n","import {\r\n  errorData,\r\n  getErrorMessage,\r\n  not,\r\n  queued,\r\n  randomString,\r\n  Subject,\r\n} from \"functools-kit\";\r\nimport { omit } from \"lodash-es\";\r\nimport { IModelMessage } from \"../model/ModelMessage.model\";\r\nimport { IAgent, IAgentParams } from \"../interfaces/Agent.interface\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { ExecutionMode } from \"../interfaces/Session.interface\";\r\nimport { IToolCall } from \"../model/Tool.model\";\r\nimport { IBusEvent } from \"../model/Event.model\";\r\n\r\nconst AGENT_CHANGE_SYMBOL = Symbol(\"agent-change\");\r\n\r\nconst getPlaceholder = () =>\r\n  GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[\r\n    Math.floor(\r\n      Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length\r\n    )\r\n  ];\r\n\r\n/**\r\n * Represents a client agent that interacts with the system.\r\n * @implements {IAgent}\r\n */\r\nexport class ClientAgent implements IAgent {\r\n  readonly _agentChangeSubject = new Subject<typeof AGENT_CHANGE_SYMBOL>();\r\n  readonly _toolCommitSubject = new Subject<void>();\r\n  readonly _toolErrorSubject = new Subject<void>();\r\n  readonly _outputSubject = new Subject<string>();\r\n\r\n  /**\r\n   * Creates an instance of ClientAgent.\r\n   * @param {IAgentParams} params - The parameters for the agent.\r\n   */\r\n  constructor(readonly params: IAgentParams) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} CTOR`,\r\n        {\r\n          params,\r\n        }\r\n      );\r\n    this.params.onInit && this.params.onInit(params.clientId, params.agentName);\r\n  }\r\n\r\n  /**\r\n   * Emits the output result after validation.\r\n   * @param {string} result - The result to be emitted.\r\n   * @returns {Promise<void>}\r\n   * @private\r\n   */\r\n  _emitOuput = async (\r\n    mode: ExecutionMode,\r\n    rawResult: string\r\n  ): Promise<void> => {\r\n    const result = await this.params.transform(\r\n      rawResult,\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    );\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _emitOuput`,\r\n        { mode, result, rawResult }\r\n      );\r\n    let validation: string | null = null;\r\n    if ((validation = await this.params.validate(result))) {\r\n      const rawResult = await this._resurrectModel(mode, validation);\r\n      const result = await this.params.transform(\r\n        rawResult,\r\n        this.params.clientId,\r\n        this.params.agentName\r\n      );\r\n      if ((validation = await this.params.validate(result))) {\r\n        throw new Error(\r\n          `agent-swarm-kit ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} model ressurect failed: ${validation}`\r\n        );\r\n      }\r\n      this.params.onOutput &&\r\n        this.params.onOutput(\r\n          this.params.clientId,\r\n          this.params.agentName,\r\n          result\r\n        );\r\n      await this._outputSubject.next(result);\r\n      await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n        type: \"emit-output\",\r\n        source: \"agent-bus\",\r\n        input: {\r\n          mode,\r\n          rawResult,\r\n        },\r\n        output: {\r\n          result,\r\n        },\r\n        context: {\r\n          agentName: this.params.agentName,\r\n        },\r\n        clientId: this.params.clientId,\r\n      });\r\n      return;\r\n    }\r\n    this.params.onOutput &&\r\n      this.params.onOutput(this.params.clientId, this.params.agentName, result);\r\n    await this._outputSubject.next(result);\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"emit-output\",\r\n      source: \"agent-bus\",\r\n      input: {\r\n        mode,\r\n        rawResult,\r\n      },\r\n      output: {\r\n        result,\r\n      },\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return;\r\n  };\r\n\r\n  /**\r\n   * Resurrects the model based on the given reason.\r\n   * @param {string} [reason] - The reason for resurrecting the model.\r\n   * @returns {Promise<string>}\r\n   * @private\r\n   */\r\n  _resurrectModel = async (\r\n    mode: ExecutionMode,\r\n    reason?: string\r\n  ): Promise<string> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _resurrectModel`\r\n      );\r\n    this.params.onResurrect &&\r\n      this.params.onResurrect(\r\n        this.params.clientId,\r\n        this.params.agentName,\r\n        mode,\r\n        reason\r\n      );\r\n    {\r\n      await this.params.history.push({\r\n        role: \"resque\",\r\n        mode: \"tool\",\r\n        agentName: this.params.agentName,\r\n        content: reason || \"Unknown error\",\r\n      });\r\n      await this.params.history.push({\r\n        role: \"user\",\r\n        mode: \"tool\",\r\n        agentName: this.params.agentName,\r\n        content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_PROMPT,\r\n      });\r\n    }\r\n    const rawMessage = await this.getCompletion(mode);\r\n    const message = await this.params.map(\r\n      rawMessage,\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    );\r\n    const result = await this.params.transform(\r\n      message.content,\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    );\r\n    let validation: string | null = null;\r\n    if ((validation = await this.params.validate(result))) {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n        this.params.logger.debug(\r\n          `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _resurrectModel validation error: ${validation}`\r\n        );\r\n      const content = getPlaceholder();\r\n      await this.params.history.push({\r\n        agentName: this.params.agentName,\r\n        role: \"assistant\",\r\n        mode: \"tool\",\r\n        content,\r\n      });\r\n      return content;\r\n    }\r\n    await this.params.history.push({\r\n      ...message,\r\n      agentName: this.params.agentName,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Waits for the output to be available.\r\n   * @returns {Promise<string>}\r\n   */\r\n  waitForOutput = async (): Promise<string> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} waitForOutput`\r\n      );\r\n    return await this._outputSubject.toPromise();\r\n  };\r\n\r\n  /**\r\n   * Gets the completion message from the model.\r\n   * @returns {Promise<IModelMessage>}\r\n   */\r\n  getCompletion = async (mode: ExecutionMode): Promise<IModelMessage> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} getCompletion`\r\n      );\r\n    const messages = await this.params.history.toArrayForAgent(\r\n      this.params.prompt,\r\n      this.params.system\r\n    );\r\n    const args = {\r\n      clientId: this.params.clientId,\r\n      agentName: this.params.agentName,\r\n      messages,\r\n      mode,\r\n      tools: this.params.tools?.map((t) =>\r\n        omit(t, \"toolName\", \"call\", \"validate\", \"callbacks\")\r\n      ),\r\n    };\r\n    const output = await this.params.completion.getCompletion(args);\r\n    this.params.completion.callbacks?.onComplete &&\r\n      this.params.completion.callbacks?.onComplete(args, output);\r\n    return output;\r\n  };\r\n\r\n  /**\r\n   * Commits a user message to the history without answer.\r\n   * @param {string} message - The message to commit.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitUserMessage = async (message: string): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} commitUserMessage`,\r\n        { message }\r\n      );\r\n    this.params.onUserMessage &&\r\n      this.params.onUserMessage(\r\n        this.params.clientId,\r\n        this.params.agentName,\r\n        message\r\n      );\r\n    await this.params.history.push({\r\n      role: \"user\",\r\n      agentName: this.params.agentName,\r\n      mode: \"user\",\r\n      content: message.trim(),\r\n    });\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-user-message\",\r\n      source: \"agent-bus\",\r\n      input: {\r\n        message,\r\n      },\r\n      output: {},\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Commits flush of agent history\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitFlush = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} commitFlush`\r\n      );\r\n    this.params.onFlush &&\r\n      this.params.onFlush(this.params.clientId, this.params.agentName);\r\n    await this.params.history.push({\r\n      role: \"flush\",\r\n      agentName: this.params.agentName,\r\n      mode: \"tool\",\r\n      content: \"\",\r\n    });\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-flush\",\r\n      source: \"agent-bus\",\r\n      input: {},\r\n      output: {},\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Commits change of agent to prevent the next tool execution from being called.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitAgentChange = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} commitAgentChange`\r\n      );\r\n    await this._agentChangeSubject.next(AGENT_CHANGE_SYMBOL);\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-agent-change\",\r\n      source: \"agent-bus\",\r\n      input: {},\r\n      output: {},\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Commits a system message to the history.\r\n   * @param {string} message - The system message to commit.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitSystemMessage = async (message: string): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} commitSystemMessage`,\r\n        { message }\r\n      );\r\n    this.params.onSystemMessage &&\r\n      this.params.onSystemMessage(\r\n        this.params.clientId,\r\n        this.params.agentName,\r\n        message\r\n      );\r\n    await this.params.history.push({\r\n      role: \"system\",\r\n      agentName: this.params.agentName,\r\n      mode: \"tool\",\r\n      content: message.trim(),\r\n    });\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-system-message\",\r\n      source: \"agent-bus\",\r\n      input: {\r\n        message,\r\n      },\r\n      output: {},\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Commits the tool output to the history.\r\n   * @param {string} content - The tool output content.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitToolOutput = async (toolId: string, content: string): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} commitToolOutput`,\r\n        { content, toolId }\r\n      );\r\n    this.params.onToolOutput &&\r\n      this.params.onToolOutput(\r\n        toolId,\r\n        this.params.clientId,\r\n        this.params.agentName,\r\n        content\r\n      );\r\n    await this.params.history.push({\r\n      role: \"tool\",\r\n      agentName: this.params.agentName,\r\n      mode: \"tool\",\r\n      content,\r\n      tool_call_id: toolId,\r\n    });\r\n    await this._toolCommitSubject.next();\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-tool-output\",\r\n      source: \"agent-bus\",\r\n      input: {\r\n        toolId,\r\n        content,\r\n      },\r\n      output: {},\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Executes the incoming message and processes tool calls if any.\r\n   * @param {string} incoming - The incoming message content.\r\n   * @returns {Promise<void>}\r\n   */\r\n  execute = queued(\r\n    async (incoming: string, mode: ExecutionMode): Promise<void> => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n        this.params.logger.debug(\r\n          `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} execute begin`,\r\n          { incoming, mode }\r\n        );\r\n      this.params.onExecute &&\r\n        this.params.onExecute(\r\n          this.params.clientId,\r\n          this.params.agentName,\r\n          incoming,\r\n          mode\r\n        );\r\n      await this.params.history.push({\r\n        role: \"user\",\r\n        mode,\r\n        agentName: this.params.agentName,\r\n        content: incoming.trim(),\r\n      });\r\n      const rawMessage = await this.getCompletion(mode);\r\n      const message = await this.params.map(\r\n        rawMessage,\r\n        this.params.clientId,\r\n        this.params.agentName\r\n      );\r\n      if (message.tool_calls) {\r\n        GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n          this.params.logger.debug(\r\n            `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} tool call begin`\r\n          );\r\n        const toolCalls: IToolCall[] = message.tool_calls.map((call) => ({\r\n          function: call.function,\r\n          id: call.id ?? randomString(),\r\n          type: call.type ?? \"function\",\r\n        }));\r\n        await this.params.history.push({\r\n          ...message,\r\n          agentName: this.params.agentName,\r\n        });\r\n        for (let idx = 0; idx !== toolCalls.length; idx++) {\r\n          const tool = toolCalls[idx];\r\n          const targetFn = this.params.tools?.find(\r\n            (t) => t.function.name === tool.function.name\r\n          );\r\n          if (!targetFn) {\r\n            GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n              this.params.logger.debug(\r\n                `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} functionName=${tool.function.name} tool function not found`,\r\n                this.params.tools\r\n              );\r\n            const result = await this._resurrectModel(\r\n              mode,\r\n              `No target function for ${tool.function.name}`\r\n            );\r\n            GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n              this.params.logger.debug(\r\n                `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} execute end result=${result}`\r\n              );\r\n            await this._emitOuput(mode, result);\r\n            return;\r\n          }\r\n          targetFn.callbacks?.onValidate &&\r\n            targetFn.callbacks?.onValidate(\r\n              this.params.clientId,\r\n              this.params.agentName,\r\n              tool.function.arguments\r\n            );\r\n          if (\r\n            await not(\r\n              targetFn.validate({\r\n                clientId: this.params.clientId,\r\n                agentName: this.params.agentName,\r\n                params: tool.function.arguments,\r\n                toolCalls,\r\n              })\r\n            )\r\n          ) {\r\n            GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n              this.params.logger.debug(\r\n                `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} functionName=${tool.function.name} tool validation not passed`\r\n              );\r\n            const result = await this._resurrectModel(\r\n              mode,\r\n              `Function validation failed: name=${\r\n                tool.function.name\r\n              } arguments=${JSON.stringify(tool.function.arguments)}`\r\n            );\r\n            GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n              this.params.logger.debug(\r\n                `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} execute end result=${result}`\r\n              );\r\n            await this._emitOuput(mode, result);\r\n            return;\r\n          }\r\n          targetFn.callbacks?.onBeforeCall &&\r\n            targetFn.callbacks?.onBeforeCall(\r\n              tool.id,\r\n              this.params.clientId,\r\n              this.params.agentName,\r\n              tool.function.arguments\r\n            );\r\n          /**\r\n           * @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages\r\n           */\r\n          Promise.resolve(\r\n            targetFn.call({\r\n              toolId: tool.id,\r\n              clientId: this.params.clientId,\r\n              agentName: this.params.agentName,\r\n              params: tool.function.arguments,\r\n              isLast: idx === toolCalls.length - 1,\r\n              toolCalls,\r\n            })\r\n          )\r\n            .then(() => {\r\n              targetFn.callbacks?.onAfterCall &&\r\n                targetFn.callbacks?.onAfterCall(\r\n                  tool.id,\r\n                  this.params.clientId,\r\n                  this.params.agentName,\r\n                  tool.function.arguments\r\n                );\r\n            })\r\n            .catch((error) => {\r\n              console.error(\r\n                `agent-swarm tool call error functionName=${\r\n                  tool.function.name\r\n                } error=${getErrorMessage(error)}`,\r\n                {\r\n                  clientId: this.params.clientId,\r\n                  agentName: this.params.agentName,\r\n                  tool_call_id: tool.id,\r\n                  arguments: tool.function.arguments,\r\n                  error: errorData(error),\r\n                }\r\n              );\r\n              targetFn.callbacks?.onCallError &&\r\n                targetFn.callbacks?.onCallError(\r\n                  tool.id,\r\n                  this.params.clientId,\r\n                  this.params.agentName,\r\n                  tool.function.arguments,\r\n                  error\r\n                );\r\n              this._toolErrorSubject.next();\r\n            });\r\n          GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n            this.params.logger.debug(\r\n              `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} functionName=${tool.function.name} tool call executing`\r\n            );\r\n          const status = await Promise.race([\r\n            this._agentChangeSubject.toPromise(),\r\n            this._toolCommitSubject.toPromise(),\r\n            this._toolErrorSubject.toPromise(),\r\n            this._outputSubject.toPromise(),\r\n          ]);\r\n          GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n            this.params.logger.debug(\r\n              `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} functionName=${tool.function.name} tool call end`\r\n            );\r\n          if (status === AGENT_CHANGE_SYMBOL) {\r\n            GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n              this.params.logger.debug(\r\n                `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} functionName=${tool.function.name} the next tool execution stopped due to the agent changed`\r\n              );\r\n            this.params.callbacks?.onAfterToolCalls &&\r\n              this.params.callbacks.onAfterToolCalls(\r\n                this.params.clientId,\r\n                this.params.agentName,\r\n                toolCalls\r\n              );\r\n            return;\r\n          }\r\n        }\r\n        this.params.callbacks?.onAfterToolCalls &&\r\n          this.params.callbacks.onAfterToolCalls(\r\n            this.params.clientId,\r\n            this.params.agentName,\r\n            toolCalls\r\n          );\r\n        return;\r\n      }\r\n      if (!message.tool_calls) {\r\n        GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n          this.params.logger.debug(\r\n            `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} execute no tool calls detected`\r\n          );\r\n      }\r\n      const result = await this.params.transform(\r\n        message.content,\r\n        this.params.clientId,\r\n        this.params.agentName\r\n      );\r\n      await this.params.history.push({\r\n        ...message,\r\n        agentName: this.params.agentName,\r\n      });\r\n      let validation: string | null = null;\r\n      if ((validation = await this.params.validate(result))) {\r\n        GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n          this.params.logger.debug(\r\n            `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} execute invalid tool call detected: ${validation}`,\r\n            { result }\r\n          );\r\n        const result1 = await this._resurrectModel(\r\n          mode,\r\n          `Invalid model output: ${result}`\r\n        );\r\n        await this._emitOuput(mode, result1);\r\n        return;\r\n      }\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n        this.params.logger.debug(\r\n          `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} execute end result=${result}`\r\n        );\r\n      await this._emitOuput(mode, result);\r\n    }\r\n  ) as IAgent[\"execute\"];\r\n\r\n  /**\r\n   * Should call on agent dispose\r\n   * @returns {Promise<void>}\r\n   */\r\n  dispose = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} dispose`\r\n      );\r\n    this.params.onDispose &&\r\n      this.params.onDispose(this.params.clientId, this.params.agentName);\r\n  };\r\n}\r\n\r\nexport default ClientAgent;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { TMethodContextService } from \"../context/MethodContextService\";\r\nimport { memoize } from \"functools-kit\";\r\nimport ClientAgent from \"../../../client/ClientAgent\";\r\nimport HistoryConnectionService from \"./HistoryConnectionService\";\r\nimport AgentSchemaService from \"../schema/AgentSchemaService\";\r\nimport ToolSchemaService from \"../schema/ToolSchemaService\";\r\nimport { IAgent } from \"../../../interfaces/Agent.interface\";\r\nimport CompletionSchemaService from \"../schema/CompletionSchemaService\";\r\nimport validateDefault from \"../../../validation/validateDefault\";\r\nimport SessionValidationService from \"../validation/SessionValidationService\";\r\nimport { ExecutionMode } from \"../../../interfaces/Session.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport StorageConnectionService from \"./StorageConnectionService\";\r\nimport BusService from \"../base/BusService\";\r\n\r\n/**\r\n * Service for managing agent connections.\r\n * @implements {IAgent}\r\n */\r\nexport class AgentConnectionService implements IAgent {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly busService = inject<BusService>(TYPES.busService);\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n  private readonly sessionValidationService = inject<SessionValidationService>(\r\n    TYPES.sessionValidationService\r\n  );\r\n  private readonly historyConnectionService = inject<HistoryConnectionService>(\r\n    TYPES.historyConnectionService\r\n  );\r\n  private readonly storageConnectionService = inject<StorageConnectionService>(\r\n    TYPES.storageConnectionService\r\n  );\r\n  private readonly agentSchemaService = inject<AgentSchemaService>(\r\n    TYPES.agentSchemaService\r\n  );\r\n  private readonly toolSchemaService = inject<ToolSchemaService>(\r\n    TYPES.toolSchemaService\r\n  );\r\n  private readonly completionSchemaService = inject<CompletionSchemaService>(\r\n    TYPES.completionSchemaService\r\n  );\r\n\r\n  /**\r\n   * Retrieves an agent instance.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} agentName - The agent name.\r\n   * @returns {ClientAgent} The client agent instance.\r\n   */\r\n  public getAgent = memoize(\r\n    ([clientId, agentName]) => `${clientId}-${agentName}`,\r\n    (clientId: string, agentName: string) => {\r\n      const {\r\n        prompt,\r\n        system,\r\n        tools,\r\n        transform = GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM,\r\n        map = GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP,\r\n        callbacks,\r\n        storages,\r\n        states,\r\n        completion: completionName,\r\n        validate = validateDefault,\r\n      } = this.agentSchemaService.get(agentName);\r\n      const completion = this.completionSchemaService.get(completionName);\r\n      this.sessionValidationService.addAgentUsage(clientId, agentName);\r\n      storages?.forEach((storageName) =>\r\n        this.storageConnectionService\r\n          .getStorage(clientId, storageName)\r\n          .waitForInit()\r\n      );\r\n      states?.forEach((storageName) =>\r\n        this.storageConnectionService\r\n          .getStorage(clientId, storageName)\r\n          .waitForInit()\r\n      );\r\n      return new ClientAgent({\r\n        clientId,\r\n        agentName,\r\n        validate,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        history: this.historyConnectionService.getHistory(clientId, agentName),\r\n        prompt,\r\n        system,\r\n        transform,\r\n        map,\r\n        tools: tools?.map(this.toolSchemaService.get),\r\n        completion,\r\n        ...callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Executes an input command.\r\n   * @param {string} input - The input command.\r\n   * @returns {Promise<any>} The execution result.\r\n   */\r\n  public execute = async (input: string, mode: ExecutionMode) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService execute`, {\r\n        input,\r\n        mode,\r\n      });\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).execute(input, mode);\r\n  };\r\n\r\n  /**\r\n   * Waits for the output from the agent.\r\n   * @returns {Promise<any>} The output result.\r\n   */\r\n  public waitForOutput = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService waitForOutput`);\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).waitForOutput();\r\n  };\r\n\r\n  /**\r\n   * Commits tool output.\r\n   * @param {string} content - The tool output content.\r\n   * @param {string} toolId - The `tool_call_id` for openai history\r\n   * @returns {Promise<any>} The commit result.\r\n   */\r\n  public commitToolOutput = async (toolId: string, content: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService commitToolOutput`, {\r\n        content,\r\n        toolId,\r\n      });\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).commitToolOutput(toolId, content);\r\n  };\r\n\r\n  /**\r\n   * Commits a system message.\r\n   * @param {string} message - The system message.\r\n   * @returns {Promise<any>} The commit result.\r\n   */\r\n  public commitSystemMessage = async (message: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService commitSystemMessage`, {\r\n        message,\r\n      });\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).commitSystemMessage(message);\r\n  };\r\n\r\n  /**\r\n   * Commits a user message without answer.\r\n   * @param {string} message - The message.\r\n   * @returns {Promise<any>} The commit result.\r\n   */\r\n  public commitUserMessage = async (message: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService commitUserMessage`, {\r\n        message,\r\n      });\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).commitUserMessage(message);\r\n  };\r\n\r\n  /**\r\n   * Commits agent change to prevent the next tool execution from being called.\r\n   * @returns {Promise<any>} The commit result.\r\n   */\r\n  public commitAgentChange = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService commitAgentChange`);\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).commitAgentChange();\r\n  };\r\n\r\n  /**\r\n   * Commits flush of agent history\r\n   * @returns {Promise<any>} The commit result.\r\n   */\r\n  public commitFlush = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService commitFlush`);\r\n    return await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).commitFlush();\r\n  };\r\n\r\n  /**\r\n   * Disposes of the agent connection.\r\n   * @returns {Promise<void>} The dispose result.\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`agentConnectionService dispose`);\r\n    const key = `${this.methodContextService.context.clientId}-${this.methodContextService.context.agentName}`;\r\n    if (!this.getAgent.has(key)) {\r\n      return;\r\n    }\r\n    await this.getAgent(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).dispose();\r\n    this.getAgent.clear(key);\r\n    this.sessionValidationService.removeAgentUsage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    );\r\n  };\r\n}\r\n\r\nexport default AgentConnectionService;\r\n","import { IModelMessage } from \"../model/ModelMessage.model\";\r\nimport IHistory, { IHistoryParams } from \"../interfaces/History.interface\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { IBusEvent } from \"../model/Event.model\";\r\n\r\n/**\r\n * Class representing the history of client messages.\r\n * @implements {IHistory}\r\n */\r\nexport class ClientHistory implements IHistory {\r\n  /**\r\n   * Filter condition for `toArrayForAgent`\r\n   */\r\n  _filterCondition: (message: IModelMessage) => boolean;\r\n\r\n  /**\r\n   * Creates an instance of ClientHistory.\r\n   * @param {IHistoryParams} params - The parameters for the history.\r\n   */\r\n  constructor(readonly params: IHistoryParams) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientHistory agentName=${this.params.agentName} clientId=${this.params.clientId} CTOR`,\r\n        {\r\n          params,\r\n        }\r\n      );\r\n    this._filterCondition = GLOBAL_CONFIG.CC_AGENT_HISTORY_FILTER(\r\n      this.params.agentName\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Pushes a message to the history.\r\n   * @param {IModelMessage} message - The message to push.\r\n   * @returns {Promise<void>}\r\n   */\r\n  push = async (message: IModelMessage): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientHistory agentName=${this.params.agentName} push`,\r\n        { message }\r\n      );\r\n    await this.params.items.push(\r\n      message,\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    );\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"push\",\r\n      source: \"history-bus\",\r\n      input: {\r\n        message,\r\n      },\r\n      output: {},\r\n      context: {\r\n        agentName: this.params.agentName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Converts the history to an array of raw messages.\r\n   * @returns {Promise<IModelMessage[]>} - The array of raw messages.\r\n   */\r\n  toArrayForRaw = async (): Promise<IModelMessage[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientHistory agentName=${this.params.agentName} toArrayForRaw`\r\n      );\r\n    const result: IModelMessage[] = [];\r\n    for await (const item of this.params.items.iterate(\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    )) {\r\n      result.push(item);\r\n    }\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Converts the history to an array of messages for the agent.\r\n   * @param {string} prompt - The prompt message.\r\n   * @param {string} system - The tool calling protocol\r\n   * @returns {Promise<IModelMessage[]>} - The array of messages for the agent.\r\n   */\r\n  toArrayForAgent = async (\r\n    prompt: string,\r\n    system?: string[]\r\n  ): Promise<IModelMessage[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientHistory agentName=${this.params.agentName} toArrayForAgent`\r\n      );\r\n    const commonMessagesRaw: IModelMessage[] = [];\r\n    const systemMessagesRaw: IModelMessage[] = [];\r\n    for await (const content of this.params.items.iterate(\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    )) {\r\n      const message: IModelMessage = content;\r\n      if (message.role === \"resque\") {\r\n        commonMessagesRaw.splice(0, commonMessagesRaw.length);\r\n        systemMessagesRaw.splice(0, systemMessagesRaw.length);\r\n        continue;\r\n      }\r\n      if (message.role === \"flush\") {\r\n        commonMessagesRaw.splice(0, commonMessagesRaw.length);\r\n        systemMessagesRaw.splice(0, systemMessagesRaw.length);\r\n        continue;\r\n      }\r\n      if (message.role === \"system\") {\r\n        systemMessagesRaw.push(message);\r\n      } else {\r\n        commonMessagesRaw.push(message);\r\n      }\r\n    }\r\n    const systemMessages = systemMessagesRaw.filter(\r\n      ({ agentName }) => agentName === this.params.agentName\r\n    );\r\n    const commonMessages = commonMessagesRaw\r\n      .map(({ content, tool_calls, ...other }) => ({\r\n        ...other,\r\n        tool_calls,\r\n        content: tool_calls?.length ? \"\" : content,\r\n      }))\r\n      .filter(this._filterCondition)\r\n      .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);\r\n    const assistantToolOutputCallSet = new Set<string>(\r\n      commonMessages\r\n        .filter(({ tool_call_id }) => !!tool_call_id)\r\n        .map(({ tool_call_id }) => tool_call_id)\r\n    );\r\n    const assistantRawMessages = commonMessages\r\n      .map(({ tool_calls, ...message }) => ({\r\n        ...message,\r\n        tool_calls: tool_calls?.filter(({ id }) =>\r\n          assistantToolOutputCallSet.has(id)\r\n        ),\r\n      }))\r\n      .filter(({ content, tool_calls }) => !!content || !!tool_calls?.length);\r\n    const assistantToolCallSet = new Set<string>(\r\n      assistantRawMessages\r\n        .filter(({ tool_calls }) => !!tool_calls)\r\n        .flatMap(({ tool_calls }) => tool_calls?.map(({ id }) => id))\r\n    );\r\n    const assistantMessages = assistantRawMessages.filter(\r\n      ({ tool_call_id }) => {\r\n        if (tool_call_id) {\r\n          return assistantToolCallSet.has(tool_call_id);\r\n        }\r\n        return true;\r\n      }\r\n    );\r\n    const promptMessages: IModelMessage[] = [];\r\n    {\r\n      promptMessages.push({\r\n        agentName: this.params.agentName,\r\n        mode: \"tool\",\r\n        content: prompt,\r\n        role: \"system\",\r\n      });\r\n      GLOBAL_CONFIG.CC_AGENT_SYSTEM_PROMPT?.forEach((content) =>\r\n        promptMessages.push({\r\n          agentName: this.params.agentName,\r\n          mode: \"tool\",\r\n          content,\r\n          role: \"system\",\r\n        })\r\n      );\r\n      system?.forEach((content) =>\r\n        promptMessages.push({\r\n          agentName: this.params.agentName,\r\n          mode: \"tool\",\r\n          content,\r\n          role: \"system\",\r\n        })\r\n      );\r\n    }\r\n    return [...promptMessages, ...systemMessages, ...assistantMessages];\r\n  };\r\n\r\n  /**\r\n   * Should call on agent dispose\r\n   * @returns {Promise<void>}\r\n   */\r\n  dispose = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} dispose`\r\n      );\r\n    await this.params.items.dispose(\r\n      this.params.clientId,\r\n      this.params.agentName\r\n    );\r\n  };\r\n}\r\n\r\nexport default ClientHistory;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport IHistory from \"../../../interfaces/History.interface\";\r\nimport { IModelMessage } from \"../../../model/ModelMessage.model\";\r\nimport { memoize } from \"functools-kit\";\r\nimport ClientHistory from \"../../../client/ClientHistory\";\r\nimport { TMethodContextService } from \"../context/MethodContextService\";\r\nimport SessionValidationService from \"../validation/SessionValidationService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport BusService from \"../base/BusService\";\r\n\r\n/**\r\n * Service for managing history connections.\r\n * @implements {IHistory}\r\n */\r\nexport class HistoryConnectionService implements IHistory {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly busService = inject<BusService>(TYPES.busService);\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n\r\n  private readonly sessionValidationService = inject<SessionValidationService>(\r\n    TYPES.sessionValidationService\r\n  );\r\n\r\n  /**\r\n   * Retrieves the history for a given client and agent.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} agentName - The agent name.\r\n   * @returns {ClientHistory} The client history.\r\n   */\r\n  public getHistory = memoize(\r\n    ([clientId, agentName]) => `${clientId}-${agentName}`,\r\n    (clientId: string, agentName: string) => {\r\n      this.sessionValidationService.addHistoryUsage(clientId, agentName);\r\n      return new ClientHistory({\r\n        clientId,\r\n        agentName,\r\n        bus: this.busService,\r\n        items: GLOBAL_CONFIG.CC_GET_AGENT_HISTORY_ADAPTER(clientId, agentName),\r\n        logger: this.loggerService,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Pushes a message to the history.\r\n   * @param {IModelMessage} message - The message to push.\r\n   * @returns {Promise<void>} A promise that resolves when the message is pushed.\r\n   */\r\n  public push = async (message: IModelMessage) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`historyConnectionService push`, {\r\n        message,\r\n      });\r\n    return await this.getHistory(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).push(message);\r\n  };\r\n\r\n  /**\r\n   * Converts the history to an array for the agent.\r\n   * @param {string} prompt - The prompt.\r\n   * @returns {Promise<any[]>} A promise that resolves to an array for the agent.\r\n   */\r\n  public toArrayForAgent = async (prompt: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`historyConnectionService toArrayForAgent`, {\r\n        prompt,\r\n      });\r\n    return await this.getHistory(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).toArrayForAgent(prompt);\r\n  };\r\n\r\n  /**\r\n   * Converts the history to a raw array.\r\n   * @returns {Promise<any[]>} A promise that resolves to a raw array.\r\n   */\r\n  public toArrayForRaw = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`historyConnectionService toArrayForRaw`);\r\n    return await this.getHistory(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).toArrayForRaw();\r\n  };\r\n\r\n  /**\r\n   * Disposes of the history connection service.\r\n   * @returns {Promise<void>} A promise that resolves when the service is disposed.\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`historyConnectionService dispose`);\r\n    const key = `${this.methodContextService.context.clientId}-${this.methodContextService.context.agentName}`;\r\n    if (!this.getHistory.has(key)) {\r\n      return;\r\n    }\r\n    await this.getHistory(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    ).dispose();\r\n    this.getHistory.clear(key);\r\n    this.sessionValidationService.removeHistoryUsage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.agentName\r\n    );\r\n  };\r\n}\r\n\r\nexport default HistoryConnectionService;\r\n","import { ToolRegistry } from \"functools-kit\";\r\nimport { IAgentTool, ToolName } from \"../../../interfaces/Agent.interface\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport { inject } from \"../../core/di\";\r\nimport TYPES from \"../../core/types\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for managing tool schemas.\r\n */\r\nexport class ToolSchemaService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<Record<ToolName, IAgentTool>>(\r\n    \"toolSchemaService\"\r\n  );\r\n\r\n  /**\r\n   * Registers a tool with the given key and value.\r\n   * @param {ToolName} key - The name of the tool.\r\n   * @param {IAgentTool} value - The tool to register.\r\n   */\r\n  public register = (key: ToolName, value: IAgentTool) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"toolSchemaService register\");\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a tool by its key.\r\n   * @param {ToolName} key - The name of the tool.\r\n   * @returns {IAgentTool} The tool associated with the given key.\r\n   */\r\n  public get = (key: ToolName): IAgentTool => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"toolSchemaService get\", { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default ToolSchemaService;\r\n","import {\r\n  cancelable,\r\n  CANCELED_PROMISE_SYMBOL,\r\n  createAwaiter,\r\n  queued,\r\n  Subject,\r\n} from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { AgentName, IAgent } from \"../interfaces/Agent.interface\";\r\nimport ISwarm, { ISwarmParams } from \"../interfaces/Swarm.interface\";\r\nimport { IBusEvent } from \"../model/Event.model\";\r\n\r\nconst AGENT_NEED_FETCH = Symbol(\"agent-need-fetch\");\r\n\r\n/**\r\n * ClientSwarm class implements the ISwarm interface and manages agents within a swarm.\r\n */\r\nexport class ClientSwarm implements ISwarm {\r\n  private _agentChangedSubject = new Subject<\r\n    [agentName: AgentName, agent: IAgent]\r\n  >();\r\n\r\n  private _activeAgent: AgentName | typeof AGENT_NEED_FETCH = AGENT_NEED_FETCH;\r\n\r\n  private _cancelOutputSubject = new Subject<{\r\n    agentName: string;\r\n    output: string;\r\n  }>();\r\n\r\n  get _agentList() {\r\n    return Object.entries(this.params.agentMap);\r\n  }\r\n\r\n  /**\r\n   * Creates an instance of ClientSwarm.\r\n   * @param {ISwarmParams} params - The parameters for the swarm.\r\n   */\r\n  constructor(readonly params: ISwarmParams) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} CTOR`,\r\n        {\r\n          params,\r\n        }\r\n      );\r\n  }\r\n\r\n  /**\r\n   * Cancel the await of output by emit of empty string\r\n   * @returns {Promise<string>} - The output from the active agent.\r\n   */\r\n  cancelOutput = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} cancelOutput`\r\n      );\r\n    await this._cancelOutputSubject.next({\r\n      agentName: await this.getAgentName(),\r\n      output: \"\",\r\n    });\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"cancel-output\",\r\n      source: \"swarm-bus\",\r\n      input: {},\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Waits for output from the active agent.\r\n   * @returns {Promise<string>} - The output from the active agent.\r\n   */\r\n  waitForOutput = queued(async (): Promise<string> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} waitForOutput`\r\n      );\r\n\r\n    const [awaiter, { resolve }] = createAwaiter<{\r\n      agentName: AgentName;\r\n      output: string;\r\n    }>();\r\n\r\n    const getOutput = cancelable(\r\n      async () =>\r\n        await Promise.race(\r\n          this._agentList\r\n            .map(async ([agentName, agent]) => ({\r\n              agentName,\r\n              output: await agent.waitForOutput(),\r\n            }))\r\n            .concat(this._cancelOutputSubject.toPromise())\r\n        )\r\n    );\r\n\r\n    const handleOutput = () => {\r\n      getOutput.cancel();\r\n      getOutput().then((value) => {\r\n        if (value === CANCELED_PROMISE_SYMBOL) {\r\n          return;\r\n        }\r\n        resolve(value);\r\n      });\r\n    };\r\n\r\n    const un = this._agentChangedSubject.subscribe(handleOutput);\r\n    handleOutput();\r\n\r\n    const { agentName, output } = await awaiter;\r\n    un();\r\n\r\n    const expectAgent = await this.getAgentName();\r\n\r\n    agentName !== expectAgent &&\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} waitForAgent agent miss`,\r\n        { agentName, expectAgent }\r\n      );\r\n\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"wait-for-output\",\r\n      source: \"swarm-bus\",\r\n      input: {},\r\n      output: {\r\n        result: output,\r\n      },\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n\r\n    return output;\r\n  }) as () => Promise<string>;\r\n\r\n  /**\r\n   * Gets the name of the active agent.\r\n   * @returns {Promise<AgentName>} - The name of the active agent.\r\n   */\r\n  getAgentName = async (): Promise<AgentName> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} getAgentName`\r\n      );\r\n    if (this._activeAgent === AGENT_NEED_FETCH) {\r\n      this._activeAgent = await this.params.getActiveAgent(\r\n        this.params.clientId,\r\n        this.params.swarmName,\r\n        this.params.defaultAgent\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"get-agent-name\",\r\n      source: \"swarm-bus\",\r\n      input: {},\r\n      output: {\r\n        activeAgent: this._activeAgent,\r\n      },\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return this._activeAgent;\r\n  };\r\n\r\n  /**\r\n   * Gets the active agent.\r\n   * @returns {Promise<IAgent>} - The active agent.\r\n   */\r\n  getAgent = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} getAgent`\r\n      );\r\n    const agent = await this.getAgentName();\r\n    const result = this.params.agentMap[agent];\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"get-agent\",\r\n      source: \"swarm-bus\",\r\n      input: {\r\n        result,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Sets the reference of an agent in the swarm.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @param {IAgent} agent - The agent instance.\r\n   * @throws {Error} - If the agent is not in the swarm.\r\n   */\r\n  setAgentRef = async (agentName: AgentName, agent: IAgent) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} setAgentRef agentName=${agentName}`\r\n      );\r\n    if (!this.params.agentMap[agentName]) {\r\n      throw new Error(`agent-swarm agent ${agentName} not in the swarm`);\r\n    }\r\n    this.params.agentMap[agentName] = agent;\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"set-agent-ref\",\r\n      source: \"swarm-bus\",\r\n      input: {\r\n        agentName,\r\n        agent,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    await this._agentChangedSubject.next([agentName, agent]);\r\n  };\r\n\r\n  /**\r\n   * Sets the active agent by name.\r\n   * @param {AgentName} agentName - The name of the agent to set as active.\r\n   */\r\n  setAgentName = async (agentName: AgentName) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} setAgentName agentName=${agentName}`\r\n      );\r\n    this._activeAgent = agentName;\r\n    await this.params.setActiveAgent(\r\n      this.params.clientId,\r\n      agentName,\r\n      this.params.swarmName\r\n    );\r\n    if (this.params.callbacks?.onAgentChanged) {\r\n      this.params.callbacks.onAgentChanged(\r\n        this.params.clientId,\r\n        agentName,\r\n        this.params.swarmName\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"set-agent-name\",\r\n      source: \"swarm-bus\",\r\n      input: {\r\n        agentName,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n}\r\n\r\nexport default ClientSwarm;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { memoize } from \"functools-kit\";\r\nimport { TMethodContextService } from \"../context/MethodContextService\";\r\nimport ClientSwarm from \"../../../client/ClientSwarm\";\r\nimport SwarmSchemaService from \"../schema/SwarmSchemaService\";\r\nimport AgentConnectionService from \"./AgentConnectionService\";\r\nimport { AgentName, IAgent } from \"../../../interfaces/Agent.interface\";\r\nimport ISwarm from \"../../../interfaces/Swarm.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport BusService from \"../base/BusService\";\r\n\r\n/**\r\n * Service for managing swarm connections.\r\n * @implements {ISwarm}\r\n */\r\nexport class SwarmConnectionService implements ISwarm {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly busService = inject<BusService>(TYPES.busService);\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n\r\n  private readonly agentConnectionService = inject<AgentConnectionService>(\r\n    TYPES.agentConnectionService\r\n  );\r\n\r\n  private readonly swarmSchemaService = inject<SwarmSchemaService>(\r\n    TYPES.swarmSchemaService\r\n  );\r\n\r\n  /**\r\n   * Retrieves a swarm instance based on client ID and swarm name.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} swarmName - The swarm name.\r\n   * @returns {ClientSwarm} The client swarm instance.\r\n   */\r\n  public getSwarm = memoize(\r\n    ([clientId, swarmName]) => `${clientId}-${swarmName}`,\r\n    (clientId: string, swarmName: string) => {\r\n      const {\r\n        agentList,\r\n        defaultAgent,\r\n        callbacks,\r\n        getActiveAgent = GLOBAL_CONFIG.CC_SWARM_DEFAULT_AGENT,\r\n        setActiveAgent = GLOBAL_CONFIG.CC_SWARM_AGENT_CHANGED,\r\n      } = this.swarmSchemaService.get(swarmName);\r\n      const agentMap: Record<AgentName, IAgent> = {};\r\n      for (const agentName of agentList) {\r\n        agentMap[agentName] = this.agentConnectionService.getAgent(\r\n          clientId,\r\n          agentName\r\n        );\r\n      }\r\n      return new ClientSwarm({\r\n        clientId,\r\n        agentMap,\r\n        defaultAgent,\r\n        swarmName,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        getActiveAgent,\r\n        setActiveAgent,\r\n        callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Cancel the await of output by emit of empty string\r\n   * @returns {Promise<void>}\r\n   */\r\n  public cancelOutput = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService cancelOutput`);\r\n    return await this.getSwarm(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).cancelOutput();\r\n  };\r\n\r\n  /**\r\n   * Waits for the output from the swarm.\r\n   * @returns {Promise<any>} The output from the swarm.\r\n   */\r\n  public waitForOutput = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService waitForOutput`);\r\n    return await this.getSwarm(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).waitForOutput();\r\n  };\r\n\r\n  /**\r\n   * Retrieves the agent name from the swarm.\r\n   * @returns {Promise<string>} The agent name.\r\n   */\r\n  public getAgentName = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService getAgentName`);\r\n    return await this.getSwarm(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).getAgentName();\r\n  };\r\n\r\n  /**\r\n   * Retrieves the agent from the swarm.\r\n   * @returns {Promise<IAgent>} The agent instance.\r\n   */\r\n  public getAgent = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService getAgent`);\r\n    return await this.getSwarm(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).getAgent();\r\n  };\r\n\r\n  /**\r\n   * Sets the agent reference in the swarm.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @param {IAgent} agent - The agent instance.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public setAgentRef = async (agentName: AgentName, agent: IAgent) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService setAgentRef`, {\r\n        agentName,\r\n      });\r\n    return await this.getSwarm(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).setAgentRef(agentName, agent);\r\n  };\r\n\r\n  /**\r\n   * Sets the agent name in the swarm.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public setAgentName = async (agentName: AgentName) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService setAgentName`, {\r\n        agentName,\r\n      });\r\n    return await this.getSwarm(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).setAgentName(agentName);\r\n  };\r\n\r\n  /**\r\n   * Disposes of the swarm connection.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmConnectionService dispose`);\r\n    const key = `${this.methodContextService.context.clientId}-${this.methodContextService.context.swarmName}`;\r\n    if (!this.getSwarm.has(key)) {\r\n      return;\r\n    }\r\n    this.getSwarm.clear(key);\r\n  };\r\n}\r\n\r\nexport default SwarmConnectionService;\r\n","import { ToolRegistry } from \"functools-kit\";\r\nimport { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { ISwarmSchema, SwarmName } from \"../../../interfaces/Swarm.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for managing swarm schemas.\r\n */\r\nexport class SwarmSchemaService {\r\n  readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<Record<SwarmName, ISwarmSchema>>(\r\n    \"swarmSchemaService\"\r\n  );\r\n\r\n  /**\r\n   * Registers a new swarm schema.\r\n   * @param {SwarmName} key - The name of the swarm.\r\n   * @param {ISwarmSchema} value - The schema of the swarm.\r\n   */\r\n  public register = (key: SwarmName, value: ISwarmSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmSchemaService register`, { key });\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a swarm schema by its name.\r\n   * @param {SwarmName} key - The name of the swarm.\r\n   * @returns {ISwarmSchema} The schema of the swarm.\r\n   */\r\n  public get = (key: SwarmName): ISwarmSchema => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`swarmSchemaService get`, { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default SwarmSchemaService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { ToolRegistry } from \"functools-kit\";\r\nimport {\r\n  ICompletionSchema,\r\n  CompletionName,\r\n} from \"../../../interfaces/Completion.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for managing completion schemas.\r\n */\r\nexport class CompletionSchemaService {\r\n  readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<\r\n    Record<CompletionName, ICompletionSchema>\r\n  >(\"completionSchemaService\");\r\n\r\n  /**\r\n   * Registers a new completion schema.\r\n   * @param {CompletionName} key - The key for the schema.\r\n   * @param {ICompletionSchema} value - The schema to register.\r\n   */\r\n  public register = (key: CompletionName, value: ICompletionSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`completionSchemaService register`, { key });\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a completion schema by key.\r\n   * @param {CompletionName} key - The key of the schema to retrieve.\r\n   * @returns {ICompletionSchema} The retrieved schema.\r\n   */\r\n  public get = (key: CompletionName): ICompletionSchema => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`completionSchemaService get`, { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default CompletionSchemaService;\r\n","import { Subject } from \"functools-kit\";\r\nimport { IIncomingMessage } from \"../model/EmitMessage.model\";\r\n\r\nimport {\r\n  ExecutionMode,\r\n  ISessionParams,\r\n  ReceiveMessageFn,\r\n  SendMessageFn,\r\n} from \"../interfaces/Session.interface\";\r\nimport { ISession } from \"../interfaces/Session.interface\";\r\nimport { IBusEvent } from \"../model/Event.model\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\n/**\r\n * ClientSession class implements the ISession interface.\r\n */\r\nexport class ClientSession implements ISession {\r\n  readonly _emitSubject = new Subject<string>();\r\n\r\n  /**\r\n   * Constructs a new ClientSession instance.\r\n   * @param {ISessionParams} params - The session parameters.\r\n   */\r\n  constructor(readonly params: ISessionParams) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} CTOR`,\r\n        {\r\n          params,\r\n        }\r\n      );\r\n    this.params.onInit && this.params.onInit(params.clientId, params.swarmName);\r\n  }\r\n\r\n  /**\r\n   * Emits a message.\r\n   * @param {string} message - The message to emit.\r\n   * @returns {Promise<void>}\r\n   */\r\n  emit = async (message: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} emit`,\r\n        {\r\n          message,\r\n        }\r\n      );\r\n    this.params.onEmit &&\r\n      this.params.onEmit(this.params.clientId, this.params.swarmName, message);\r\n    await this._emitSubject.next(message);\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"emit\",\r\n      source: \"session-bus\",\r\n      input: {\r\n        message,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Executes a message and optionally emits the output.\r\n   * @param {string} message - The message to execute.\r\n   * @param {boolean} [noEmit=false] - Whether to emit the output or not.\r\n   * @returns {Promise<string>} - The output of the execution.\r\n   */\r\n  execute = async (message: string, mode: ExecutionMode) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} execute`,\r\n        {\r\n          message,\r\n          mode,\r\n        }\r\n      );\r\n    this.params.onExecute &&\r\n      this.params.onExecute(\r\n        this.params.clientId,\r\n        this.params.swarmName,\r\n        message,\r\n        mode\r\n      );\r\n    const agent = await this.params.swarm.getAgent();\r\n    const outputAwaiter = this.params.swarm.waitForOutput();\r\n    agent.execute(message, mode);\r\n    const output = await outputAwaiter;\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"execute\",\r\n      source: \"session-bus\",\r\n      input: {\r\n        message,\r\n        mode,\r\n      },\r\n      output: {\r\n        result: output,\r\n      },\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return output;\r\n  };\r\n\r\n  /**\r\n   * Commits tool output.\r\n   * @param {string} toolId - The `tool_call_id` for openai history\r\n   * @param {string} content - The content to commit.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitToolOutput = async (toolId: string, content: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} commitToolOutput`,\r\n        {\r\n          content,\r\n          toolId,\r\n        }\r\n      );\r\n    const agent = await this.params.swarm.getAgent();\r\n    const result = await agent.commitToolOutput(toolId, content);\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-tool-output\",\r\n      source: \"session-bus\",\r\n      input: {\r\n        toolId,\r\n        content,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Commits user message without answer.\r\n   * @param {string} message - The message to commit.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitUserMessage = async (message: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} commitUserMessage`,\r\n        {\r\n          message,\r\n        }\r\n      );\r\n    const agent = await this.params.swarm.getAgent();\r\n    const result = await agent.commitUserMessage(message);\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-user-message\",\r\n      source: \"session-bus\",\r\n      input: {\r\n        message,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Commits flush of agent history\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitFlush = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} commitFlush`\r\n      );\r\n    const agent = await this.params.swarm.getAgent();\r\n    const result = await agent.commitFlush();\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-flush\",\r\n      source: \"session-bus\",\r\n      input: {},\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Commits a system message.\r\n   * @param {string} message - The system message to commit.\r\n   * @returns {Promise<void>}\r\n   */\r\n  commitSystemMessage = async (message: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} commitSystemMessage`,\r\n        {\r\n          message,\r\n        }\r\n      );\r\n    const agent = await this.params.swarm.getAgent();\r\n    const result = await agent.commitSystemMessage(message);\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"commit-system-message\",\r\n      source: \"session-bus\",\r\n      input: {\r\n        message,\r\n      },\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Connects the session to a connector function.\r\n   * @param {SendMessageFn} connector - The connector function.\r\n   * @returns {ReceiveMessageFn} - The function to receive messages.\r\n   */\r\n  connect = (connector: SendMessageFn): ReceiveMessageFn => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} connect`\r\n      );\r\n    this.params.onConnect &&\r\n      this.params.onConnect(this.params.clientId, this.params.swarmName);\r\n    this._emitSubject.subscribe(\r\n      async (data: string) =>\r\n        await connector({\r\n          data,\r\n          agentName: await this.params.swarm.getAgentName(),\r\n          clientId: this.params.clientId,\r\n        })\r\n    );\r\n    this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"connect\",\r\n      source: \"session-bus\",\r\n      input: {},\r\n      output: {},\r\n      context: {\r\n        swarmName: this.params.swarmName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return async (incoming: IIncomingMessage) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n        this.params.logger.debug(\r\n          `ClientSession clientId=${this.params.clientId} connect call`\r\n        );\r\n      const data = await this.execute(incoming.data, \"user\");\r\n      if (!data) {\r\n        return;\r\n      }\r\n      await connector({\r\n        data,\r\n        agentName: await this.params.swarm.getAgentName(),\r\n        clientId: incoming.clientId,\r\n      });\r\n    };\r\n  };\r\n\r\n  /**\r\n   * Should call on session dispose\r\n   * @returns {Promise<void>}\r\n   */\r\n  dispose = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientSession clientId=${this.params.clientId} dispose`\r\n      );\r\n    this.params.onDispose &&\r\n      this.params.onDispose(this.params.clientId, this.params.swarmName);\r\n  };\r\n}\r\n\r\nexport default ClientSession;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport { TMethodContextService } from \"../context/MethodContextService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { memoize } from \"functools-kit\";\r\nimport ClientSession from \"../../../client/ClientSession\";\r\nimport SwarmConnectionService from \"./SwarmConnectionService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport {\r\n  ExecutionMode,\r\n  ISession,\r\n  ReceiveMessageFn,\r\n  SendMessageFn,\r\n} from \"../../../interfaces/Session.interface\";\r\nimport SwarmSchemaService from \"../schema/SwarmSchemaService\";\r\nimport BusService from \"../base/BusService\";\r\nimport { SwarmName } from \"../../../interfaces/Swarm.interface\";\r\n\r\n/**\r\n * Service for managing session connections.\r\n * @implements {ISession}\r\n */\r\nexport class SessionConnectionService implements ISession {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly busService = inject<BusService>(TYPES.busService);\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n\r\n  private readonly swarmConnectionService = inject<SwarmConnectionService>(\r\n    TYPES.swarmConnectionService\r\n  );\r\n\r\n  private readonly swarmSchemaService = inject<SwarmSchemaService>(\r\n    TYPES.swarmSchemaService\r\n  );\r\n\r\n  /**\r\n   * Retrieves a memoized session based on clientId and swarmName.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} swarmName - The swarm name.\r\n   * @returns {ClientSession} The client session.\r\n   */\r\n  public getSession = memoize(\r\n    ([clientId, swarmName]) => `${clientId}-${swarmName}`,\r\n    (clientId: string, swarmName: string) => {\r\n      const { callbacks } = this.swarmSchemaService.get(swarmName);\r\n      return new ClientSession({\r\n        clientId,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        swarm: this.swarmConnectionService.getSwarm(clientId, swarmName),\r\n        swarmName,\r\n        ...callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Emits a message to the session.\r\n   * @param {string} content - The content to emit.\r\n   * @returns {Promise<void>} A promise that resolves when the message is emitted.\r\n   */\r\n  public emit = async (content: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService emit`, {\r\n        content,\r\n      });\r\n    return await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).emit(content);\r\n  };\r\n\r\n  /**\r\n   * Executes a command in the session.\r\n   * @param {string} content - The content to execute.\r\n   * @returns {Promise<string>} A promise that resolves with the execution result.\r\n   */\r\n  public execute = async (\r\n    content: string,\r\n    mode: ExecutionMode\r\n  ): Promise<string> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService execute`, {\r\n        content,\r\n        mode,\r\n      });\r\n    return await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).execute(content, mode);\r\n  };\r\n\r\n  /**\r\n   * Connects to the session using the provided connector.\r\n   * @param {SendMessageFn} connector - The function to send messages.\r\n   * @returns {ReceiveMessageFn} The function to receive messages.\r\n   */\r\n  public connect = (\r\n    connector: SendMessageFn,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ): ReceiveMessageFn => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService connect`);\r\n    return this.getSession(clientId, swarmName).connect(connector);\r\n  };\r\n\r\n  /**\r\n   * Commits tool output to the session.\r\n   * @param {string} toolId - The `tool_call_id` for openai history\r\n   * @param {string} content - The content to commit.\r\n   * @returns {Promise<void>} A promise that resolves when the content is committed.\r\n   */\r\n  public commitToolOutput = async (\r\n    toolId: string,\r\n    content: string\r\n  ): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService commitToolOutput`, {\r\n        content,\r\n        toolId,\r\n      });\r\n    return await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).commitToolOutput(toolId, content);\r\n  };\r\n\r\n  /**\r\n   * Commits a system message to the session.\r\n   * @param {string} message - The message to commit.\r\n   * @returns {Promise<void>} A promise that resolves when the message is committed.\r\n   */\r\n  public commitSystemMessage = async (message: string): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService commitSystemMessage`, {\r\n        message,\r\n      });\r\n    return await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).commitSystemMessage(message);\r\n  };\r\n\r\n  /**\r\n   * Commits user message to the agent without answer.\r\n   * @param {string} message - The message to commit.\r\n   * @returns {Promise<void>} A promise that resolves when the message is committed.\r\n   */\r\n  public commitUserMessage = async (message: string): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService commitUserMessage`, {\r\n        message,\r\n      });\r\n    return await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).commitUserMessage(message);\r\n  };\r\n\r\n  /**\r\n   * Commits user message to the agent without answer.\r\n   * @param {string} message - The message to commit.\r\n   * @returns {Promise<void>} A promise that resolves when the message is committed.\r\n   */\r\n  public commitFlush = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService commitFlush`);\r\n    return await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).commitFlush();\r\n  };\r\n\r\n  /**\r\n   * Disposes of the session connection service.\r\n   * @returns {Promise<void>} A promise that resolves when the service is disposed.\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`sessionConnectionService dispose`);\r\n    const key = `${this.methodContextService.context.clientId}-${this.methodContextService.context.swarmName}`;\r\n    if (!this.getSession.has(key)) {\r\n      return;\r\n    }\r\n    await this.getSession(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.swarmName\r\n    ).dispose();\r\n    this.getSession.clear(key);\r\n  };\r\n}\r\n\r\nexport default SessionConnectionService;\r\n","import { inject } from \"../../core/di\";\r\nimport { AgentConnectionService } from \"../connection/AgentConnectionService\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport MethodContextService from \"../context/MethodContextService\";\r\nimport { AgentName } from \"../../../interfaces/Agent.interface\";\r\nimport { ExecutionMode } from \"../../../interfaces/Session.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\ninterface IAgentConnectionService extends AgentConnectionService {}\r\n\r\ntype InternalKeys = keyof {\r\n  getAgent: never;\r\n};\r\n\r\ntype TAgentConnectionService = {\r\n  [key in Exclude<keyof IAgentConnectionService, InternalKeys>]: unknown;\r\n};\r\n\r\n/**\r\n * Service for managing public agent operations.\r\n */\r\nexport class AgentPublicService implements TAgentConnectionService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly agentConnectionService = inject<AgentConnectionService>(\r\n    TYPES.agentConnectionService\r\n  );\r\n\r\n  /**\r\n   * Creates a reference to an agent.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The agent reference.\r\n   */\r\n  public createAgentRef = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService createAgentRef\", {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.getAgent(clientId, agentName);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Executes a command on the agent.\r\n   * @param {string} input - The input command.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The execution result.\r\n   */\r\n  public execute = async (\r\n    input: string,\r\n    mode: ExecutionMode,\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService execute\", {\r\n        methodName,\r\n        input,\r\n        clientId,\r\n        agentName,\r\n        mode,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.execute(input, mode);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Waits for the agent's output.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The output result.\r\n   */\r\n  public waitForOutput = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService waitForOutput\", {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.waitForOutput();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits tool output to the agent.\r\n   * @param {string} toolId - The `tool_call_id` for openai history\r\n   * @param {string} content - The content to commit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The commit result.\r\n   */\r\n  public commitToolOutput = async (\r\n    toolId: string,\r\n    content: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService commitToolOutput\", {\r\n        methodName,\r\n        content,\r\n        clientId,\r\n        toolId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.commitToolOutput(\r\n          toolId,\r\n          content\r\n        );\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits a system message to the agent.\r\n   * @param {string} message - The message to commit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The commit result.\r\n   */\r\n  public commitSystemMessage = async (\r\n    message: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService commitSystemMessage\", {\r\n        methodName,\r\n        message,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.commitSystemMessage(message);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits user message to the agent without answer.\r\n   * @param {string} message - The message to commit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The commit result.\r\n   */\r\n  public commitUserMessage = async (\r\n    message: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService commitUserMessage\", {\r\n        methodName,\r\n        message,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.commitUserMessage(message);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits flush of agent history\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The commit result.\r\n   */\r\n  public commitFlush = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService commitFlush\", {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.commitFlush();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits change of agent to prevent the next tool execution from being called.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The commit result.\r\n   */\r\n  public commitAgentChange = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService commitAgentChange\", {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.commitAgentChange();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Disposes of the agent.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @returns {Promise<unknown>} The dispose result.\r\n   */\r\n  public dispose = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentPublicService dispose\", {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.agentConnectionService.dispose();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\nexport default AgentPublicService;\r\n","import { inject } from \"../../core/di\";\r\nimport { HistoryConnectionService } from \"../connection/HistoryConnectionService\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport MethodContextService from \"../context/MethodContextService\";\r\nimport { IModelMessage } from \"../../../model/ModelMessage.model\";\r\nimport { AgentName } from \"../../../interfaces/Agent.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\ninterface IHistoryConnectionService extends HistoryConnectionService {}\r\n\r\ntype InternalKeys = keyof {\r\n  getHistory: never;\r\n  getItems: never;\r\n};\r\n\r\ntype THistoryConnectionService = {\r\n  [key in Exclude<keyof IHistoryConnectionService, InternalKeys>]: unknown;\r\n};\r\n\r\n/**\r\n * Service for handling public history operations.\r\n */\r\nexport class HistoryPublicService implements THistoryConnectionService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly historyConnectionService = inject<HistoryConnectionService>(\r\n    TYPES.historyConnectionService\r\n  );\r\n\r\n  /**\r\n   * Pushes a message to the history.\r\n   * @param {IModelMessage} message - The message to push.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @returns {Promise<void>} A promise that resolves when the operation is complete.\r\n   */\r\n  public push = async (\r\n    message: IModelMessage,\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"historyPublicService push\", {\r\n        methodName,\r\n        message,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.historyConnectionService.push(message);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Converts history to an array for a specific agent.\r\n   * @param {string} prompt - The prompt.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @returns {Promise<any[]>} A promise that resolves to an array of history items.\r\n   */\r\n  public toArrayForAgent = async (\r\n    prompt: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"historyPublicService toArrayForAgent\", {\r\n        prompt,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.historyConnectionService.toArrayForAgent(prompt);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Converts history to a raw array.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @returns {Promise<any[]>} A promise that resolves to a raw array of history items.\r\n   */\r\n  public toArrayForRaw = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"historyPublicService toArrayForRaw\", {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.historyConnectionService.toArrayForRaw();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Disposes of the history.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @returns {Promise<void>} A promise that resolves when the operation is complete.\r\n   */\r\n  public dispose = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    agentName: AgentName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"historyPublicService dispose\", {\r\n        clientId,\r\n        agentName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.historyConnectionService.dispose();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        agentName,\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\nexport default HistoryPublicService;\r\n","import { inject } from \"../../core/di\";\r\nimport { SessionConnectionService } from \"../connection/SessionConnectionService\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport MethodContextService from \"../context/MethodContextService\";\r\nimport { SwarmName } from \"../../../interfaces/Swarm.interface\";\r\nimport {\r\n  ExecutionMode,\r\n  ReceiveMessageFn,\r\n  SendMessageFn,\r\n} from \"../../../interfaces/Session.interface\";\r\nimport ExecutionContextService from \"../context/ExecutionContextService\";\r\nimport { randomString } from \"functools-kit\";\r\nimport { IIncomingMessage } from \"../../../model/EmitMessage.model\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\ninterface ISessionConnectionService extends SessionConnectionService {}\r\n\r\ntype InternalKeys = keyof {\r\n  getSession: never;\r\n};\r\n\r\ntype TSessionConnectionService = {\r\n  [key in Exclude<keyof ISessionConnectionService, InternalKeys>]: unknown;\r\n};\r\n\r\n/**\r\n * Service for managing public session interactions.\r\n */\r\nexport class SessionPublicService implements TSessionConnectionService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly sessionConnectionService = inject<SessionConnectionService>(\r\n    TYPES.sessionConnectionService\r\n  );\r\n\r\n  /**\r\n   * Emits a message to the session.\r\n   * @param {string} content - The content to emit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public emit = async (\r\n    content: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService emit\", {\r\n        content,\r\n        clientId,\r\n        methodName,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.emit(content);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Executes a command in the session.\r\n   * @param {string} content - The content to execute.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public execute = async (\r\n    content: string,\r\n    mode: ExecutionMode,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService execute\", {\r\n        content,\r\n        mode,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.execute(content, mode);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Connects to the session.\r\n   * @param {SendMessageFn} connector - The function to send messages.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {ReceiveMessageFn}\r\n   */\r\n  public connect = (\r\n    connector: SendMessageFn,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ): ReceiveMessageFn => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService connect\", {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    const send = this.sessionConnectionService.connect(\r\n      connector,\r\n      clientId,\r\n      swarmName\r\n    );\r\n    return async (incoming: IIncomingMessage) => {\r\n      const executionId = randomString();\r\n      return ExecutionContextService.runInContext(\r\n        async () => {\r\n          GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n            this.loggerService.log(\"sessionPublicService connect execute\", {\r\n              content: incoming,\r\n              methodName,\r\n              clientId,\r\n              executionId,\r\n            });\r\n          return await send(incoming);\r\n        },\r\n        {\r\n          clientId,\r\n          executionId,\r\n        }\r\n      );\r\n    };\r\n  };\r\n\r\n  /**\r\n   * Commits tool output to the session.\r\n   * @param {string} toolId - The `tool_call_id` for openai history\r\n   * @param {string} content - The content to commit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public commitToolOutput = async (\r\n    toolId: string,\r\n    content: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService commitToolOutput\", {\r\n        methodName,\r\n        toolId,\r\n        content,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.commitToolOutput(\r\n          toolId,\r\n          content\r\n        );\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits a system message to the session.\r\n   * @param {string} message - The message to commit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public commitSystemMessage = async (\r\n    message: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService commitSystemMessage\", {\r\n        methodName,\r\n        message,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.commitSystemMessage(message);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits user message to the agent without answer.\r\n   * @param {string} message - The message to commit.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public commitUserMessage = async (\r\n    message: string,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService commitUserMessage\", {\r\n        methodName,\r\n        message,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.commitUserMessage(message);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Commits flush of agent history\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public commitFlush = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService commitFlush\", {\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.commitFlush();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Disposes of the session.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionPublicService dispose\", {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.sessionConnectionService.dispose();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\nexport default SessionPublicService;\r\n","import { inject } from \"../../core/di\";\r\nimport { SwarmConnectionService } from \"../connection/SwarmConnectionService\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport MethodContextService from \"../context/MethodContextService\";\r\nimport { SwarmName } from \"../../../interfaces/Swarm.interface\";\r\nimport { AgentName, IAgent } from \"../../../interfaces/Agent.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\ninterface ISwarmConnectionService extends SwarmConnectionService {}\r\n\r\ntype InternalKeys = keyof {\r\n  getSwarm: never;\r\n};\r\n\r\ntype TSwarmConnectionService = {\r\n  [key in Exclude<keyof ISwarmConnectionService, InternalKeys>]: unknown;\r\n};\r\n\r\n/**\r\n * Service for managing public swarm interactions.\r\n */\r\nexport class SwarmPublicService implements TSwarmConnectionService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly swarmConnectionService = inject<SwarmConnectionService>(\r\n    TYPES.swarmConnectionService\r\n  );\r\n\r\n  /**\r\n   * Cancel the await of output by emit of empty string\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public cancelOutput = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService cancelOutput\", {\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.cancelOutput();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Waits for output from the swarm.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public waitForOutput = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService waitForOutput\", {\r\n        clientId,\r\n        methodName,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.waitForOutput();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Gets the agent name from the swarm.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<string>}\r\n   */\r\n  public getAgentName = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService getAgentName\", {\r\n        clientId,\r\n        swarmName,\r\n        methodName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.getAgentName();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Gets the agent from the swarm.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<IAgent>}\r\n   */\r\n  public getAgent = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService getAgent\", {\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.getAgent();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Sets the agent reference in the swarm.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {IAgent} agent - The agent instance.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public setAgentRef = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName,\r\n    agentName: AgentName,\r\n    agent: IAgent\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService setAgentRef\", {\r\n        methodName,\r\n        agentName,\r\n        agent,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.setAgentRef(agentName, agent);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Sets the agent name in the swarm.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public setAgentName = async (\r\n    agentName: AgentName,\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService setAgentName\", {\r\n        methodName,\r\n        agentName,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.setAgentName(agentName);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Disposes of the swarm.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {SwarmName} swarmName - The swarm name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    swarmName: SwarmName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmPublicService dispose\", {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.swarmConnectionService.dispose();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        swarmName,\r\n        agentName: \"\",\r\n        storageName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\nexport default SwarmPublicService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport {\r\n  AgentName,\r\n  IAgentSchema,\r\n  ToolName,\r\n} from \"../../../interfaces/Agent.interface\";\r\nimport ToolValidationService from \"./ToolValidationService\";\r\nimport CompletionValidationService from \"./CompletionValidationService\";\r\nimport { memoize } from \"functools-kit\";\r\nimport StorageValidationService from \"./StorageValidationService\";\r\nimport { StorageName } from \"../../../interfaces/Storage.interface\";\r\nimport { StateName } from \"../../../interfaces/State.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating agents within the agent swarm.\r\n */\r\nexport class AgentValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private readonly toolValidationService = inject<ToolValidationService>(\r\n    TYPES.toolValidationService\r\n  );\r\n  private readonly completionValidationService =\r\n    inject<CompletionValidationService>(TYPES.completionValidationService);\r\n  private readonly storageValidationService = inject<StorageValidationService>(\r\n    TYPES.storageValidationService\r\n  );\r\n\r\n  private _agentMap = new Map<AgentName, IAgentSchema>();\r\n\r\n  /**\r\n   * Retrieves the storages used by the agent\r\n   * @param {agentName} agentName - The name of the swarm.\r\n   * @returns {string[]} The list of storage names.\r\n   * @throws Will throw an error if the swarm is not found.\r\n   */\r\n  public getStorageList = (agentName: string) => {\r\n    if (!this._agentMap.has(agentName)) {\r\n      throw new Error(\r\n        `agent-swarm agent ${agentName} not exist (getStorageList)`\r\n      );\r\n    }\r\n    return this._agentMap.get(agentName).storages;\r\n  };\r\n\r\n  /**\r\n   * Retrieves the states used by the agent\r\n   * @param {agentName} agentName - The name of the swarm.\r\n   * @returns {string[]} The list of state names.\r\n   * @throws Will throw an error if the swarm is not found.\r\n   */\r\n  public getStateList = (agentName: string) => {\r\n    if (!this._agentMap.has(agentName)) {\r\n      throw new Error(\r\n        `agent-swarm agent ${agentName} not exist (getStateList)`\r\n      );\r\n    }\r\n    return this._agentMap.get(agentName).states;\r\n  };\r\n\r\n  /**\r\n   * Adds a new agent to the validation service.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @param {IAgentSchema} agentSchema - The schema of the agent.\r\n   * @throws {Error} If the agent already exists.\r\n   */\r\n  public addAgent = (agentName: AgentName, agentSchema: IAgentSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"agentValidationService addAgent\", {\r\n        agentName,\r\n        agentSchema,\r\n      });\r\n    if (this._agentMap.has(agentName)) {\r\n      throw new Error(`agent-swarm agent ${agentName} already exist`);\r\n    }\r\n    this._agentMap.set(agentName, agentSchema);\r\n  };\r\n\r\n  /**\r\n   * Check if agent got registered storage\r\n   */\r\n  public hasStorage = memoize(\r\n    ([agentName, storageName]) => `${agentName}-${storageName}`,\r\n    (agentName: AgentName, storageName: StorageName) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"agentValidationService hasStorage\", {\r\n          agentName,\r\n          storageName,\r\n        });\r\n      if (!this._agentMap.has(agentName)) {\r\n        throw new Error(\r\n          `agent-swarm agent ${agentName} not exist (hasStorage)`\r\n        );\r\n      }\r\n      const { storages = [] } = this._agentMap.get(agentName);\r\n      return storages.includes(storageName);\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Check if agent got registered state\r\n   */\r\n  public hasState = memoize(\r\n    ([agentName, stateName]) => `${agentName}-${stateName}`,\r\n    (agentName: AgentName, stateName: StateName) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"agentValidationService hasState\", {\r\n          agentName,\r\n          stateName,\r\n        });\r\n      if (!this._agentMap.has(agentName)) {\r\n        throw new Error(`agent-swarm agent ${agentName} not exist (hasState)`);\r\n      }\r\n      const { states = [] } = this._agentMap.get(agentName);\r\n      return states.includes(stateName);\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Validates an agent by its name and source.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws {Error} If the agent is not found.\r\n   */\r\n  public validate = memoize(\r\n    ([agentName]) => agentName,\r\n    (agentName: AgentName, source: string) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"agentValidationService validate\", {\r\n          agentName,\r\n          source,\r\n        });\r\n      const agent = this._agentMap.get(agentName);\r\n      if (!agent) {\r\n        throw new Error(\r\n          `agent-swarm agent ${agentName} not found source=${source}`\r\n        );\r\n      }\r\n      this.completionValidationService.validate(agent.completion, source);\r\n      agent.tools?.forEach((toolName: ToolName) => {\r\n        if (typeof toolName !== \"string\") {\r\n          throw new Error(\r\n            `agent-swarm agent ${agentName} tool list is invalid (toolName=${String(\r\n              toolName\r\n            )}) source=${source}`\r\n          );\r\n        }\r\n        this.toolValidationService.validate(toolName, source);\r\n      });\r\n      agent.storages?.forEach((storageName: StorageName) => {\r\n        if (typeof storageName !== \"string\") {\r\n          throw new Error(\r\n            `agent-swarm agent ${agentName} storage list is invalid (storageName=${String(\r\n              storageName\r\n            )}) source=${source}`\r\n          );\r\n        }\r\n        this.storageValidationService.validate(storageName, source);\r\n      });\r\n      return {} as unknown as void;\r\n    }\r\n  ) as (agentName: AgentName, source: string) => void;\r\n}\r\n\r\nexport default AgentValidationService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { CompletionName } from \"../../../interfaces/Completion.interface\";\r\nimport { memoize } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating completion names.\r\n */\r\nexport class CompletionValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private _completionSet = new Set<CompletionName>();\r\n\r\n  /**\r\n   * Adds a new completion name to the set.\r\n   * @param {CompletionName} completionName - The name of the completion to add.\r\n   * @throws Will throw an error if the completion name already exists.\r\n   */\r\n  public addCompletion = (completionName: CompletionName) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"completionValidationService addCompletion\", {\r\n        completionName,\r\n      });\r\n    if (this._completionSet.has(completionName)) {\r\n      throw new Error(`agent-swarm completion ${completionName} already exist`);\r\n    }\r\n    this._completionSet.add(completionName);\r\n  };\r\n\r\n  /**\r\n   * Validates if a completion name exists in the set.\r\n   * @param {CompletionName} completionName - The name of the completion to validate.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws Will throw an error if the completion name is not found.\r\n   */\r\n  public validate = memoize(\r\n    ([completionName]) => completionName,\r\n    (completionName: CompletionName, source: string) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"completionValidationService validate\", {\r\n          completionName,\r\n          source,\r\n        });\r\n      if (!this._completionSet.has(completionName)) {\r\n        throw new Error(\r\n          `agent-swarm completion ${completionName} not found source=${source}`\r\n        );\r\n      }\r\n      return {} as unknown as void;\r\n    }\r\n  ) as (completionName: CompletionName, source: string) => void;\r\n}\r\n\r\nexport default CompletionValidationService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { SessionId, SessionMode } from \"../../../interfaces/Session.interface\";\r\nimport { SwarmName } from \"../../../interfaces/Swarm.interface\";\r\nimport { AgentName } from \"../../../interfaces/Agent.interface\";\r\nimport { StorageName } from \"../../../interfaces/Storage.interface\";\r\nimport { StateName } from \"../../../interfaces/State.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating and managing sessions.\r\n */\r\nexport class SessionValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private _storageSwarmMap = new Map<SessionId, StorageName[]>();\r\n  private _historySwarmMap = new Map<SessionId, AgentName[]>();\r\n  private _agentSwarmMap = new Map<SessionId, AgentName[]>();\r\n  private _stateSwarmMap = new Map<SessionId, AgentName[]>();\r\n\r\n  private _sessionSwarmMap = new Map<SessionId, SwarmName>();\r\n  private _sessionModeMap = new Map<SessionId, SessionMode>();\r\n\r\n  /**\r\n   * Adds a new session.\r\n   * @param {SessionId} clientId - The ID of the client.\r\n   * @param {SwarmName} swarmName - The name of the swarm.\r\n   * @param {SessionMode} sessionMode - The mode of the session.\r\n   * @throws Will throw an error if the session already exists.\r\n   */\r\n  public addSession = (\r\n    clientId: SessionId,\r\n    swarmName: SwarmName,\r\n    sessionMode: SessionMode\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService addSession\", {\r\n        clientId,\r\n      });\r\n    if (this._sessionSwarmMap.has(clientId)) {\r\n      throw new Error(`agent-swarm session clientId=${clientId} already exist`);\r\n    }\r\n    this._sessionSwarmMap.set(clientId, swarmName);\r\n    this._sessionModeMap.set(clientId, sessionMode);\r\n  };\r\n\r\n  /**\r\n   * Adds an agent usage to a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   */\r\n  public addAgentUsage = (sessionId: SessionId, agentName: AgentName): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService addAgentUsage\", {\r\n        sessionId,\r\n        agentName,\r\n      });\r\n    if (this._agentSwarmMap.has(sessionId)) {\r\n      const agents = this._agentSwarmMap.get(sessionId)!;\r\n      if (!agents.includes(agentName)) {\r\n        agents.push(agentName);\r\n      }\r\n    } else {\r\n      this._agentSwarmMap.set(sessionId, [agentName]);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Adds a history usage to a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   */\r\n  public addHistoryUsage = (\r\n    sessionId: SessionId,\r\n    agentName: AgentName\r\n  ): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService addHistoryUsage\", {\r\n        sessionId,\r\n        agentName,\r\n      });\r\n    if (this._historySwarmMap.has(sessionId)) {\r\n      const agents = this._historySwarmMap.get(sessionId)!;\r\n      if (!agents.includes(agentName)) {\r\n        agents.push(agentName);\r\n      }\r\n    } else {\r\n      this._historySwarmMap.set(sessionId, [agentName]);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Adds a storage usage to a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {StorageName} storageName - The name of the storage.\r\n   */\r\n  public addStorageUsage = (\r\n    sessionId: SessionId,\r\n    storageName: StorageName\r\n  ): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService addStorageUsage\", {\r\n        sessionId,\r\n        storageName,\r\n      });\r\n    if (this._storageSwarmMap.has(sessionId)) {\r\n      const storages = this._storageSwarmMap.get(sessionId)!;\r\n      if (!storages.includes(storageName)) {\r\n        storages.push(storageName);\r\n      }\r\n    } else {\r\n      this._storageSwarmMap.set(sessionId, [storageName]);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Adds a state usage to a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {StateName} stateName - The name of the state.\r\n   */\r\n  public addStateUsage = (sessionId: SessionId, stateName: StateName): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService addStateUsage\", {\r\n        sessionId,\r\n        stateName,\r\n      });\r\n    if (this._stateSwarmMap.has(sessionId)) {\r\n      const states = this._stateSwarmMap.get(sessionId)!;\r\n      if (!states.includes(stateName)) {\r\n        states.push(stateName);\r\n      }\r\n    } else {\r\n      this._stateSwarmMap.set(sessionId, [stateName]);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Removes an agent usage from a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @throws Will throw an error if no agents are found for the session.\r\n   */\r\n  public removeAgentUsage = (\r\n    sessionId: SessionId,\r\n    agentName: AgentName\r\n  ): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService removeAgentUsage\", {\r\n        sessionId,\r\n        agentName,\r\n      });\r\n    if (this._agentSwarmMap.has(sessionId)) {\r\n      const agents = this._agentSwarmMap.get(sessionId)!;\r\n      const agentIndex = agents.indexOf(agentName);\r\n      if (agentIndex !== -1) {\r\n        agents.splice(agentIndex, 1);\r\n      }\r\n      if (agents.length === 0) {\r\n        this._agentSwarmMap.delete(sessionId);\r\n      }\r\n    } else {\r\n      throw new Error(`No agents found for sessionId=${sessionId}`);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Removes a history usage from a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {AgentName} agentName - The name of the agent.\r\n   * @throws Will throw an error if no agents are found for the session.\r\n   */\r\n  public removeHistoryUsage = (\r\n    sessionId: SessionId,\r\n    agentName: AgentName\r\n  ): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService removeHistoryUsage\", {\r\n        sessionId,\r\n        agentName,\r\n      });\r\n    if (this._historySwarmMap.has(sessionId)) {\r\n      const agents = this._historySwarmMap.get(sessionId)!;\r\n      const agentIndex = agents.indexOf(agentName);\r\n      if (agentIndex !== -1) {\r\n        agents.splice(agentIndex, 1);\r\n      }\r\n      if (agents.length === 0) {\r\n        this._historySwarmMap.delete(sessionId);\r\n      }\r\n    } else {\r\n      throw new Error(`No agents found for sessionId=${sessionId}`);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Removes a storage usage from a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {StorageName} storageName - The name of the storage.\r\n   * @throws Will throw an error if no storages are found for the session.\r\n   */\r\n  public removeStorageUsage = (\r\n    sessionId: SessionId,\r\n    storageName: StorageName\r\n  ): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService removeStorageUsage\", {\r\n        sessionId,\r\n        storageName,\r\n      });\r\n    if (this._storageSwarmMap.has(sessionId)) {\r\n      const agents = this._storageSwarmMap.get(sessionId)!;\r\n      const agentIndex = agents.indexOf(storageName);\r\n      if (agentIndex !== -1) {\r\n        agents.splice(agentIndex, 1);\r\n      }\r\n      if (agents.length === 0) {\r\n        this._storageSwarmMap.delete(sessionId);\r\n      }\r\n    } else {\r\n      throw new Error(`No agents found for sessionId=${sessionId}`);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Removes a state usage from a session.\r\n   * @param {SessionId} sessionId - The ID of the session.\r\n   * @param {StateName} stateName - The name of the state.\r\n   * @throws Will throw an error if no states are found for the session.\r\n   */\r\n  public removeStateUsage = (\r\n    sessionId: SessionId,\r\n    stateName: StateName\r\n  ): void => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService removeStateUsage\", {\r\n        sessionId,\r\n        stateName,\r\n      });\r\n    if (this._stateSwarmMap.has(sessionId)) {\r\n      const agents = this._stateSwarmMap.get(sessionId)!;\r\n      const agentIndex = agents.indexOf(stateName);\r\n      if (agentIndex !== -1) {\r\n        agents.splice(agentIndex, 1);\r\n      }\r\n      if (agents.length === 0) {\r\n        this._stateSwarmMap.delete(sessionId);\r\n      }\r\n    } else {\r\n      throw new Error(`No agents found for sessionId=${sessionId}`);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Gets the mode of a session.\r\n   * @param {SessionId} clientId - The ID of the client.\r\n   * @returns {SessionMode} The mode of the session.\r\n   * @throws Will throw an error if the session does not exist.\r\n   */\r\n  public getSessionMode = (clientId: SessionId) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService getSessionMode\", {\r\n        clientId,\r\n      });\r\n    if (!this._sessionModeMap.has(clientId)) {\r\n      throw new Error(\r\n        `agent-swarm session getSessionMode clientId=${clientId} session not exist`\r\n      );\r\n    }\r\n    return this._sessionModeMap.get(clientId)!;\r\n  };\r\n\r\n  /**\r\n   * Ensures session is exist\r\n   * @returns {boolean}\r\n   */\r\n  public hasSession = (clientId: SessionId) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService hasSession\");\r\n    return this._sessionSwarmMap.has(clientId);\r\n  };\r\n\r\n  /**\r\n   * Gets the list of all session IDs.\r\n   * @returns {SessionId[]} The list of session IDs.\r\n   */\r\n  public getSessionList = () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService getSessionList\");\r\n    return [...this._sessionSwarmMap.keys()];\r\n  };\r\n\r\n  /**\r\n   * Gets the list of agents for a session.\r\n   * @param {string} clientId - The ID of the client.\r\n   * @returns {AgentName[]} The list of agent names.\r\n   */\r\n  public getSessionAgentList = (clientId: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService getSessionAgentList\", {\r\n        clientId,\r\n      });\r\n    return this._agentSwarmMap.get(clientId) ?? [];\r\n  };\r\n\r\n  /**\r\n   * Gets the history list of agents for a session.\r\n   * @param {string} clientId - The ID of the client.\r\n   * @returns {AgentName[]} The list of agent names.\r\n   */\r\n  public getSessionHistoryList = (clientId: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\r\n        \"sessionValidationService getSessionHistoryList\",\r\n        {\r\n          clientId,\r\n        }\r\n      );\r\n    return this._agentSwarmMap.get(clientId) ?? [];\r\n  };\r\n\r\n  /**\r\n   * Gets the swarm name for a session.\r\n   * @param {SessionId} clientId - The ID of the client.\r\n   * @returns {SwarmName} The name of the swarm.\r\n   * @throws Will throw an error if the session does not exist.\r\n   */\r\n  public getSwarm = (clientId: SessionId) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService getSwarm\", {\r\n        clientId,\r\n      });\r\n    const session = this._sessionSwarmMap.get(clientId);\r\n    if (session === undefined) {\r\n      throw new Error(`agent-swarm session clientId=${clientId} not found`);\r\n    }\r\n    return session;\r\n  };\r\n\r\n  /**\r\n   * Validates if a session exists.\r\n   * @param {SessionId} clientId - The ID of the client.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws Will throw an error if the session does not exist.\r\n   */\r\n  public validate = (clientId: SessionId, source: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService validate\", {\r\n        clientId,\r\n      });\r\n    if (!this._sessionSwarmMap.has(clientId)) {\r\n      throw new Error(\r\n        `agent-swarm session clientId=${clientId} not exist source=${source}`\r\n      );\r\n    }\r\n    return {} as unknown as void;\r\n  };\r\n\r\n  /**\r\n   * Removes a session.\r\n   * @param {SessionId} clientId - The ID of the client.\r\n   */\r\n  public removeSession = (clientId: SessionId) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"sessionValidationService addSession\", {\r\n        clientId,\r\n      });\r\n    this._sessionSwarmMap.delete(clientId);\r\n    this._sessionModeMap.delete(clientId);\r\n  };\r\n}\r\n\r\nexport default SessionValidationService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { SwarmName, ISwarmSchema } from \"../../../interfaces/Swarm.interface\";\r\nimport AgentValidationService from \"./AgentValidationService\";\r\nimport { memoize } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating swarms and their agents.\r\n */\r\nexport class SwarmValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private readonly agentValidationService = inject<AgentValidationService>(\r\n    TYPES.agentValidationService\r\n  );\r\n\r\n  private _swarmMap = new Map<SwarmName, ISwarmSchema>();\r\n\r\n  /**\r\n   * Adds a new swarm to the swarm map.\r\n   * @param {SwarmName} swarmName - The name of the swarm.\r\n   * @param {ISwarmSchema} swarmSchema - The schema of the swarm.\r\n   * @throws Will throw an error if the swarm already exists.\r\n   */\r\n  public addSwarm = (swarmName: SwarmName, swarmSchema: ISwarmSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmValidationService addSwarm\", {\r\n        swarmName,\r\n        swarmSchema,\r\n      });\r\n    if (this._swarmMap.has(swarmName)) {\r\n      throw new Error(`swarm-swarm swarm ${swarmName} already exist`);\r\n    }\r\n    this._swarmMap.set(swarmName, swarmSchema);\r\n  };\r\n\r\n  /**\r\n   * Retrieves the list of agents for a given swarm.\r\n   * @param {SwarmName} swarmName - The name of the swarm.\r\n   * @returns {string[]} The list of agent names.\r\n   * @throws Will throw an error if the swarm is not found.\r\n   */\r\n  public getAgentList = (swarmName: SwarmName) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"swarmValidationService getAgentList\", {\r\n        swarmName,\r\n      });\r\n    const swarm = this._swarmMap.get(swarmName);\r\n    if (!swarm) {\r\n      throw new Error(`agent-swarm swarm ${swarmName} not found`);\r\n    }\r\n    return swarm.agentList;\r\n  };\r\n\r\n  /**\r\n   * Validates a swarm and its agents.\r\n   * @param {SwarmName} swarmName - The name of the swarm.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws Will throw an error if the swarm is not found or if the default agent is not in the agent list.\r\n   */\r\n  public validate = memoize(\r\n    ([swarmName]) => swarmName,\r\n    (swarmName: SwarmName, source: string) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"swarmValidationService validate\", {\r\n          swarmName,\r\n          source,\r\n        });\r\n      const swarm = this._swarmMap.get(swarmName);\r\n      if (!swarm) {\r\n        throw new Error(`agent-swarm swarm ${swarmName} not found`);\r\n      }\r\n      if (!swarm.agentList.includes(swarm.defaultAgent)) {\r\n        throw new Error(\r\n          `agent-swarm swarm ${swarmName} default agent not in agent list`\r\n        );\r\n      }\r\n      swarm.agentList.forEach((agentName) =>\r\n        this.agentValidationService.validate(agentName, source)\r\n      );\r\n      return {} as unknown as void;\r\n    }\r\n  ) as (swarmName: SwarmName, source: string) => void;\r\n}\r\n\r\nexport default SwarmValidationService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { IAgentTool, ToolName } from \"../../../interfaces/Agent.interface\";\r\nimport { memoize } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating tools within the agent-swarm.\r\n */\r\nexport class ToolValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private _toolMap = new Map<ToolName, IAgentTool>();\r\n\r\n  /**\r\n   * Adds a new tool to the validation service.\r\n   * @param {ToolName} toolName - The name of the tool to add.\r\n   * @param {IAgentTool} toolSchema - The schema of the tool to add.\r\n   * @throws Will throw an error if the tool already exists.\r\n   */\r\n  public addTool = (toolName: ToolName, toolSchema: IAgentTool) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"toolValidationService addTool\", {\r\n        toolName,\r\n        toolSchema,\r\n      });\r\n    if (this._toolMap.has(toolName)) {\r\n      throw new Error(`agent-swarm tool ${toolName} already exist`);\r\n    }\r\n    this._toolMap.set(toolName, toolSchema);\r\n  };\r\n\r\n  /**\r\n   * Validates if a tool exists in the validation service.\r\n   * @param {ToolName} toolName - The name of the tool to validate.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws Will throw an error if the tool is not found.\r\n   */\r\n  public validate = memoize(\r\n    ([toolName]) => toolName,\r\n    (toolName: ToolName, source: string) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"toolValidationService validate\", {\r\n          toolName,\r\n          source,\r\n        });\r\n      if (!this._toolMap.has(toolName)) {\r\n        throw new Error(\r\n          `agent-swarm tool ${toolName} not found source=${source}`\r\n        );\r\n      }\r\n      return {} as unknown as void;\r\n    }\r\n  ) as (toolName: ToolName, source: string) => void;\r\n}\r\n\r\nexport default ToolValidationService;\r\n","import { ToolRegistry } from \"functools-kit\";\r\nimport {\r\n  IEmbeddingSchema,\r\n  EmbeddingName,\r\n} from \"../../../interfaces/Embedding.interface\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport { inject } from \"../../core/di\";\r\nimport TYPES from \"../../core/types\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for managing embedding schemas.\r\n */\r\nexport class EmbeddingSchemaService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<Record<EmbeddingName, IEmbeddingSchema>>(\r\n    \"embeddingSchemaService\"\r\n  );\r\n\r\n  /**\r\n   * Registers a embedding with the given key and value.\r\n   * @param {EmbeddingName} key - The name of the embedding.\r\n   * @param {IAgentTool} value - The embedding to register.\r\n   */\r\n  public register = (key: EmbeddingName, value: IEmbeddingSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"embeddingSchemaService register\");\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a embedding by its key.\r\n   * @param {EmbeddingName} key - The name of the embedding.\r\n   * @returns {IAgentTool} The embedding associated with the given key.\r\n   */\r\n  public get = (key: EmbeddingName): IEmbeddingSchema => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"embeddingSchemaService get\", { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default EmbeddingSchemaService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { ToolRegistry } from \"functools-kit\";\r\nimport {\r\n  IStorageSchema,\r\n  StorageName,\r\n} from \"../../../interfaces/Storage.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for managing storage schemas.\r\n */\r\nexport class StorageSchemaService {\r\n  readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<Record<StorageName, IStorageSchema>>(\r\n    \"storageSchemaService\"\r\n  );\r\n\r\n  /**\r\n   * Registers a new storage schema.\r\n   * @param {StorageName} key - The key for the schema.\r\n   * @param {IStorageSchema} value - The schema to register.\r\n   */\r\n  public register = (key: StorageName, value: IStorageSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageSchemaService register`, { key });\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a storage schema by key.\r\n   * @param {StorageName} key - The key of the schema to retrieve.\r\n   * @returns {IStorageSchema} The retrieved schema.\r\n   */\r\n  public get = (key: StorageName): IStorageSchema => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageSchemaService get`, { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default StorageSchemaService;\r\n","import { execpool, memoize, singleshot, SortedArray } from \"functools-kit\";\r\nimport {\r\n  IStorage,\r\n  IStorageData,\r\n  IStorageParams,\r\n} from \"../interfaces/Storage.interface\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { IBusEvent } from \"../model/Event.model\";\r\n\r\n/**\r\n * ClientStorage class to manage storage operations.\r\n * @template T - The type of storage data.\r\n */\r\nexport class ClientStorage<T extends IStorageData = IStorageData>\r\n  implements IStorage<T>\r\n{\r\n  private _itemMap = new Map<IStorageData[\"id\"], T>();\r\n\r\n  /**\r\n   * Creates an instance of ClientStorage.\r\n   * @param {IStorageParams<T>} params - The storage parameters.\r\n   */\r\n  constructor(readonly params: IStorageParams<T>) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} CTOR`,\r\n        {\r\n          params,\r\n        }\r\n      );\r\n    if (this.params.callbacks?.onInit) {\r\n      this.params.callbacks.onInit(\r\n        this.params.clientId,\r\n        this.params.storageName\r\n      );\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Creates an embedding for the given item.\r\n   * @param {T} item - The item to create an embedding for.\r\n   * @returns {Promise<readonly [any, any]>} - The embeddings and index.\r\n   */\r\n  _createEmbedding = memoize(\r\n    ([{ id }]) => id,\r\n    async (item: T) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n        this.params.logger.debug(\r\n          `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} _createEmbedding`,\r\n          {\r\n            id: item.id,\r\n          }\r\n        );\r\n      const index = await this.params.createIndex(item);\r\n      const embeddings = await this.params.createEmbedding(index);\r\n      if (this.params.onCreate) {\r\n        this.params.onCreate(\r\n          index,\r\n          embeddings,\r\n          this.params.clientId,\r\n          this.params.embedding\r\n        );\r\n      }\r\n      return [embeddings, index] as const;\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Waits for the initialization of the storage.\r\n   * @returns {Promise<void>}\r\n   */\r\n  waitForInit = singleshot(async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} waitForInit`\r\n      );\r\n    if (!this.params.getData) {\r\n      return;\r\n    }\r\n    const data = await this.params.getData(\r\n      this.params.clientId,\r\n      this.params.storageName\r\n    );\r\n    await Promise.all(\r\n      data.map(\r\n        execpool(this._createEmbedding, {\r\n          delay: 10,\r\n          maxExec: GLOBAL_CONFIG.CC_STORAGE_SEARCH_POOL,\r\n        })\r\n      )\r\n    );\r\n    this._itemMap = new Map(data.map((item) => [item.id, item]));\r\n  });\r\n\r\n  /**\r\n   * Takes a specified number of items based on the search criteria.\r\n   * @param {string} search - The search string.\r\n   * @param {number} total - The total number of items to take.\r\n   * @param {number} [score=GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY] - The similarity score.\r\n   * @returns {Promise<T[]>} - The list of items.\r\n   */\r\n  take = async (\r\n    search: string,\r\n    total: number,\r\n    score = GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY\r\n  ): Promise<T[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} take`,\r\n        {\r\n          search,\r\n          total,\r\n        }\r\n      );\r\n    const indexed = new SortedArray<T>();\r\n    const searchEmbeddings = await this.params.createEmbedding(search);\r\n    if (this.params.onCreate) {\r\n      this.params.onCreate(\r\n        search,\r\n        searchEmbeddings,\r\n        this.params.clientId,\r\n        this.params.embedding\r\n      );\r\n    }\r\n    await Promise.all(\r\n      Array.from(this._itemMap.values()).map(\r\n        execpool(\r\n          async (item) => {\r\n            const [targetEmbeddings, index] = await this._createEmbedding(item);\r\n            const score = await this.params.calculateSimilarity(\r\n              searchEmbeddings,\r\n              targetEmbeddings\r\n            );\r\n            if (this.params.onCompare) {\r\n              this.params.onCompare(\r\n                search,\r\n                index,\r\n                score,\r\n                this.params.clientId,\r\n                this.params.embedding\r\n              );\r\n            }\r\n            indexed.push(item, score);\r\n          },\r\n          {\r\n            delay: 10,\r\n            maxExec: GLOBAL_CONFIG.CC_STORAGE_SEARCH_POOL,\r\n          }\r\n        )\r\n      )\r\n    );\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} take indexed`,\r\n        {\r\n          indexed: indexed.getEntries(),\r\n        }\r\n      );\r\n    if (this.params.callbacks?.onSearch) {\r\n      this.params.callbacks?.onSearch(\r\n        search,\r\n        indexed,\r\n        this.params.clientId,\r\n        this.params.storageName\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"take\",\r\n      source: \"storage-bus\",\r\n      input: {\r\n        search,\r\n        total,\r\n        score,\r\n      },\r\n      output: {\r\n        indexed,\r\n      },\r\n      context: {\r\n        storageName: this.params.storageName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return indexed.take(total, score);\r\n  };\r\n\r\n  /**\r\n   * Upserts an item into the storage.\r\n   * @param {T} item - The item to upsert.\r\n   * @returns {Promise<void>}\r\n   */\r\n  upsert = async (item: T) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} upsert`,\r\n        {\r\n          item,\r\n        }\r\n      );\r\n    this._itemMap.set(item.id, item);\r\n    this._createEmbedding.clear(item.id);\r\n    await this._createEmbedding(item);\r\n    if (this.params.callbacks?.onUpdate) {\r\n      this.params.callbacks?.onUpdate(\r\n        [...this._itemMap.values()],\r\n        this.params.clientId,\r\n        this.params.storageName\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"upsert\",\r\n      source: \"storage-bus\",\r\n      input: {\r\n        item,\r\n      },\r\n      output: {},\r\n      context: {\r\n        storageName: this.params.storageName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Removes an item from the storage.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to remove.\r\n   * @returns {Promise<void>}\r\n   */\r\n  remove = async (itemId: IStorageData[\"id\"]) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} remove`,\r\n        {\r\n          id: itemId,\r\n        }\r\n      );\r\n    this._itemMap.delete(itemId);\r\n    this._createEmbedding.clear(itemId);\r\n    if (this.params.callbacks?.onUpdate) {\r\n      this.params.callbacks?.onUpdate(\r\n        [...this._itemMap.values()],\r\n        this.params.clientId,\r\n        this.params.storageName\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"remove\",\r\n      source: \"storage-bus\",\r\n      input: {\r\n        itemId,\r\n      },\r\n      output: {},\r\n      context: {\r\n        storageName: this.params.storageName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Clears all items from the storage.\r\n   * @returns {Promise<void>}\r\n   */\r\n  clear = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} clear`\r\n      );\r\n    this._itemMap.clear();\r\n    this._createEmbedding.clear();\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"clear\",\r\n      source: \"storage-bus\",\r\n      input: {},\r\n      output: {},\r\n      context: {\r\n        storageName: this.params.storageName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n  };\r\n\r\n  /**\r\n   * Gets an item by its ID.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to get.\r\n   * @returns {Promise<T | null>} - The item or null if not found.\r\n   */\r\n  get = async (itemId: IStorageData[\"id\"]): Promise<T | null> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} get`,\r\n        {\r\n          id: itemId,\r\n        }\r\n      );\r\n    const result = this._itemMap.get(itemId) ?? null;\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"get\",\r\n      source: \"storage-bus\",\r\n      input: {\r\n        itemId,\r\n      },\r\n      output: {\r\n        result,\r\n      },\r\n      context: {\r\n        storageName: this.params.storageName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Lists all items in the storage, optionally filtered by a predicate.\r\n   * @param {(item: T) => boolean} [filter] - The filter predicate.\r\n   * @returns {Promise<T[]>} - The list of items.\r\n   */\r\n  list = async (filter?: (item: T) => boolean) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} list`\r\n      );\r\n    if (!filter) {\r\n      return [...this._itemMap.values()];\r\n    }\r\n    const result: T[] = [];\r\n    for (const item of this._itemMap.values()) {\r\n      if (filter(item)) {\r\n        result.push(item);\r\n      }\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"list\",\r\n      source: \"storage-bus\",\r\n      input: {},\r\n      output: {\r\n        result,\r\n      },\r\n      context: {\r\n        storageName: this.params.storageName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return result;\r\n  };\r\n\r\n  /**\r\n   * Disposes of the state.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientStorage storageName=${this.params.storageName} clientId=${this.params.clientId} shared=${this.params.shared} dispose`\r\n      );\r\n    if (this.params.callbacks?.onDispose) {\r\n      this.params.callbacks.onDispose(\r\n        this.params.clientId,\r\n        this.params.storageName\r\n      );\r\n    }\r\n  };\r\n}\r\n\r\nexport default ClientStorage;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { memoize } from \"functools-kit\";\r\nimport { TMethodContextService } from \"../context/MethodContextService\";\r\nimport ClientStorage from \"../../../client/ClientStorage\";\r\nimport StorageSchemaService from \"../schema/StorageSchemaService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport {\r\n  IStorage,\r\n  IStorageData,\r\n  StorageName,\r\n} from \"../../../interfaces/Storage.interface\";\r\nimport EmbeddingSchemaService from \"../schema/EmbeddingSchemaService\";\r\nimport SessionValidationService from \"../validation/SessionValidationService\";\r\nimport BusService from \"../base/BusService\";\r\n\r\n/**\r\n * Service for managing storage connections.\r\n * @implements {IStorage}\r\n */\r\nexport class StorageConnectionService implements IStorage {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly busService = inject<BusService>(TYPES.busService);\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n\r\n  private readonly storageSchemaService = inject<StorageSchemaService>(\r\n    TYPES.storageSchemaService\r\n  );\r\n\r\n  private readonly sessionValidationService = inject<SessionValidationService>(\r\n    TYPES.sessionValidationService\r\n  );\r\n\r\n  private readonly embeddingSchemaService = inject<EmbeddingSchemaService>(\r\n    TYPES.embeddingSchemaService\r\n  );\r\n\r\n  /**\r\n   * Retrieves a shared storage instance based on storage name.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} storageName - The storage name.\r\n   * @returns {ClientStorage} The client storage instance.\r\n   */\r\n  public getSharedStorage = memoize(\r\n    ([, storageName]) => `${storageName}`,\r\n    (clientId: string, storageName: StorageName) => {\r\n      const {\r\n        createIndex,\r\n        getData,\r\n        embedding: embeddingName,\r\n        shared,\r\n        callbacks,\r\n      } = this.storageSchemaService.get(storageName);\r\n      const {\r\n        calculateSimilarity,\r\n        createEmbedding,\r\n        callbacks: embedding,\r\n      } = this.embeddingSchemaService.get(embeddingName);\r\n      if (!shared) {\r\n        throw new Error(\r\n          `agent-swarm storage not shared storageName=${storageName}`\r\n        );\r\n      }\r\n      return new ClientStorage({\r\n        clientId,\r\n        storageName,\r\n        embedding: embeddingName,\r\n        calculateSimilarity,\r\n        createEmbedding,\r\n        createIndex,\r\n        getData,\r\n        shared,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        ...embedding,\r\n        callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Retrieves a storage instance based on client ID and storage name.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {string} storageName - The storage name.\r\n   * @returns {ClientStorage} The client storage instance.\r\n   */\r\n  public getStorage = memoize(\r\n    ([clientId, storageName]) => `${clientId}-${storageName}`,\r\n    (clientId: string, storageName: StorageName) => {\r\n      this.sessionValidationService.addStorageUsage(clientId, storageName);\r\n      const {\r\n        createIndex,\r\n        getData,\r\n        embedding: embeddingName,\r\n        shared = false,\r\n        callbacks,\r\n      } = this.storageSchemaService.get(storageName);\r\n      if (shared) {\r\n        return this.getSharedStorage(clientId, storageName);\r\n      }\r\n      const {\r\n        calculateSimilarity,\r\n        createEmbedding,\r\n        callbacks: embedding,\r\n      } = this.embeddingSchemaService.get(embeddingName);\r\n      return new ClientStorage({\r\n        clientId,\r\n        storageName,\r\n        embedding: embeddingName,\r\n        calculateSimilarity,\r\n        createEmbedding,\r\n        createIndex,\r\n        getData,\r\n        shared,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        ...embedding,\r\n        callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Retrieves a list of storage data based on a search query and total number of items.\r\n   * @param {string} search - The search query.\r\n   * @param {number} total - The total number of items to retrieve.\r\n   * @returns {Promise<IStorageData[]>} The list of storage data.\r\n   */\r\n  public take = async (\r\n    search: string,\r\n    total: number,\r\n    score?: number\r\n  ): Promise<IStorageData[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService take`, {\r\n        search,\r\n        total,\r\n        score,\r\n      });\r\n    const storage = this.getStorage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n    await storage.waitForInit();\r\n    return await storage.take(search, total, score);\r\n  };\r\n\r\n  /**\r\n   * Upserts an item in the storage.\r\n   * @param {IStorageData} item - The item to upsert.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public upsert = async (item: IStorageData): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService upsert`, {\r\n        item,\r\n      });\r\n    const storage = this.getStorage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n    await storage.waitForInit();\r\n    return await storage.upsert(item);\r\n  };\r\n\r\n  /**\r\n   * Removes an item from the storage.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to remove.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public remove = async (itemId: IStorageData[\"id\"]): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService remove`, {\r\n        itemId,\r\n      });\r\n    const storage = this.getStorage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n    await storage.waitForInit();\r\n    return await storage.remove(itemId);\r\n  };\r\n\r\n  /**\r\n   * Retrieves an item from the storage by its ID.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to retrieve.\r\n   * @returns {Promise<IStorageData>} The retrieved item.\r\n   */\r\n  public get = async (\r\n    itemId: IStorageData[\"id\"]\r\n  ): Promise<IStorageData | null> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService get`, {\r\n        itemId,\r\n      });\r\n    const storage = this.getStorage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n    await storage.waitForInit();\r\n    return await storage.get(itemId);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a list of items from the storage, optionally filtered by a predicate function.\r\n   * @param {function(IStorageData): boolean} [filter] - The optional filter function.\r\n   * @returns {Promise<IStorageData[]>} The list of items.\r\n   */\r\n  public list = async (\r\n    filter?: (item: IStorageData) => boolean\r\n  ): Promise<IStorageData[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService list`);\r\n    const storage = this.getStorage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n    await storage.waitForInit();\r\n    return await storage.list(filter);\r\n  };\r\n\r\n  /**\r\n   * Clears all items from the storage.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public clear = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService clear`);\r\n    const storage = this.getStorage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n    await storage.waitForInit();\r\n    return await storage.clear();\r\n  };\r\n\r\n  /**\r\n   * Disposes of the storage connection.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storageConnectionService dispose`);\r\n    const key = `${this.methodContextService.context.clientId}-${this.methodContextService.context.storageName}`;\r\n    if (!this.getStorage.has(key)) {\r\n      return;\r\n    }\r\n    if (\r\n      !this.getSharedStorage.has(this.methodContextService.context.storageName)\r\n    ) {\r\n      const storage = this.getSharedStorage(\r\n        this.methodContextService.context.clientId,\r\n        this.methodContextService.context.storageName\r\n      );\r\n      await storage.waitForInit();\r\n      await storage.dispose();\r\n    }\r\n    this.getStorage.clear(key);\r\n    this.sessionValidationService.removeStorageUsage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.storageName\r\n    );\r\n  };\r\n}\r\n\r\nexport default StorageConnectionService;\r\n","import { inject } from \"../../core/di\";\r\nimport { StorageConnectionService } from \"../connection/StorageConnectionService\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport MethodContextService from \"../context/MethodContextService\";\r\nimport {\r\n  IStorageData,\r\n  StorageName,\r\n} from \"../../../interfaces/Storage.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\ninterface IStorageConnectionService extends StorageConnectionService {}\r\n\r\ntype InternalKeys = keyof {\r\n  getStorage: never;\r\n  getSharedStorage: never;\r\n};\r\n\r\ntype TStorageConnectionService = {\r\n  [key in Exclude<keyof IStorageConnectionService, InternalKeys>]: unknown;\r\n};\r\n\r\n/**\r\n * Service for managing public storage interactions.\r\n */\r\nexport class StoragePublicService implements TStorageConnectionService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly storageConnectionService = inject<StorageConnectionService>(\r\n    TYPES.storageConnectionService\r\n  );\r\n\r\n  /**\r\n   * Retrieves a list of storage data based on a search query and total number of items.\r\n   * @param {string} search - The search query.\r\n   * @param {number} total - The total number of items to retrieve.\r\n   * @returns {Promise<IStorageData[]>} The list of storage data.\r\n   */\r\n  public take = async (\r\n    search: string,\r\n    total: number,\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName,\r\n    score?: number\r\n  ): Promise<IStorageData[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storagePublicService take`, {\r\n        methodName,\r\n        search,\r\n        total,\r\n        clientId,\r\n        storageName,\r\n        score,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.take(search, total, score);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Upserts an item in the storage.\r\n   * @param {IStorageData} item - The item to upsert.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public upsert = async (\r\n    item: IStorageData,\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName\r\n  ): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storagePublicService upsert`, {\r\n        item,\r\n        clientId,\r\n        storageName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.upsert(item);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Removes an item from the storage.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to remove.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public remove = async (\r\n    itemId: IStorageData[\"id\"],\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName\r\n  ): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storagePublicService remove`, {\r\n        itemId,\r\n        clientId,\r\n        storageName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.remove(itemId);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Retrieves an item from the storage by its ID.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to retrieve.\r\n   * @returns {Promise<IStorageData>} The retrieved item.\r\n   */\r\n  public get = async (\r\n    itemId: IStorageData[\"id\"],\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName\r\n  ): Promise<IStorageData | null> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storagePublicService get`, {\r\n        methodName,\r\n        itemId,\r\n        clientId,\r\n        storageName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.get(itemId);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Retrieves a list of items from the storage, optionally filtered by a predicate function.\r\n   * @param {function(IStorageData): boolean} [filter] - The optional filter function.\r\n   * @returns {Promise<IStorageData[]>} The list of items.\r\n   */\r\n  public list = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName,\r\n    filter?: (item: IStorageData) => boolean\r\n  ): Promise<IStorageData[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storagePublicService list`, {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.list(filter);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Clears all items from the storage.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public clear = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName\r\n  ): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`storagePublicService clear`, {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.clear();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Disposes of the storage.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    storageName: StorageName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"storagePublicService dispose\", {\r\n        clientId,\r\n        storageName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.storageConnectionService.dispose();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        storageName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        stateName: \"\",\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\nexport default StoragePublicService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport {\r\n  StorageName,\r\n  IStorageSchema,\r\n} from \"../../../interfaces/Storage.interface\";\r\nimport { memoize } from \"functools-kit\";\r\nimport EmbeddingValidationService from \"./EmbeddingValidationService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating storages within the storage swarm.\r\n */\r\nexport class StorageValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private readonly embeddingValidationService =\r\n    inject<EmbeddingValidationService>(TYPES.embeddingValidationService);\r\n\r\n  private _storageMap = new Map<StorageName, IStorageSchema>();\r\n\r\n  /**\r\n   * Adds a new storage to the validation service.\r\n   * @param {StorageName} storageName - The name of the storage.\r\n   * @param {IStorageSchema} storageSchema - The schema of the storage.\r\n   * @throws {Error} If the storage already exists.\r\n   */\r\n  public addStorage = (\r\n    storageName: StorageName,\r\n    storageSchema: IStorageSchema\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"storageValidationService addStorage\", {\r\n        storageName,\r\n        storageSchema,\r\n      });\r\n    if (this._storageMap.has(storageName)) {\r\n      throw new Error(`storage-swarm storage ${storageName} already exist`);\r\n    }\r\n    this._storageMap.set(storageName, storageSchema);\r\n  };\r\n\r\n  /**\r\n   * Validates an storage by its name and source.\r\n   * @param {StorageName} storageName - The name of the storage.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws {Error} If the storage is not found.\r\n   */\r\n  public validate = memoize(\r\n    ([storageName]) => storageName,\r\n    (storageName: StorageName, source: string) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"storageValidationService validate\", {\r\n          storageName,\r\n          source,\r\n        });\r\n      const storage = this._storageMap.get(storageName);\r\n      if (!storage) {\r\n        throw new Error(\r\n          `storage-swarm storage ${storageName} not found source=${source}`\r\n        );\r\n      }\r\n      this.embeddingValidationService.validate(storage.embedding, source);\r\n      return {} as unknown as void;\r\n    }\r\n  ) as (storageName: StorageName, source: string) => void;\r\n}\r\n\r\nexport default StorageValidationService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport {\r\n  IEmbeddingSchema,\r\n  EmbeddingName,\r\n} from \"../../../interfaces/Embedding.interface\";\r\nimport { memoize } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for validating embeddings within the agent-swarm.\r\n */\r\nexport class EmbeddingValidationService {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private _embeddingMap = new Map<EmbeddingName, IEmbeddingSchema>();\r\n\r\n  /**\r\n   * Adds a new embedding to the validation service.\r\n   * @param {EmbeddingName} embeddingName - The name of the embedding to add.\r\n   * @param {IAgentEmbedding} embeddingSchema - The schema of the embedding to add.\r\n   * @throws Will throw an error if the embedding already exists.\r\n   */\r\n  public addEmbedding = (\r\n    embeddingName: EmbeddingName,\r\n    embeddingSchema: IEmbeddingSchema\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"embeddingValidationService addEmbedding\", {\r\n        embeddingName,\r\n        embeddingSchema,\r\n      });\r\n    if (this._embeddingMap.has(embeddingName)) {\r\n      throw new Error(`agent-swarm embedding ${embeddingName} already exist`);\r\n    }\r\n    this._embeddingMap.set(embeddingName, embeddingSchema);\r\n  };\r\n\r\n  /**\r\n   * Validates if a embedding exists in the validation service.\r\n   * @param {EmbeddingName} embeddingName - The name of the embedding to validate.\r\n   * @param {string} source - The source of the validation request.\r\n   * @throws Will throw an error if the embedding is not found.\r\n   */\r\n  public validate = memoize(\r\n    ([embeddingName]) => embeddingName,\r\n    (embeddingName: EmbeddingName, source: string) => {\r\n      GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n        this.loggerService.info(\"embeddingValidationService validate\", {\r\n          embeddingName,\r\n          source,\r\n        });\r\n      if (!this._embeddingMap.has(embeddingName)) {\r\n        throw new Error(\r\n          `agent-swarm embedding ${embeddingName} not found source=${source}`\r\n        );\r\n      }\r\n      return {} as unknown as void;\r\n    }\r\n  ) as (embeddingName: EmbeddingName, source: string) => void;\r\n}\r\n\r\nexport default EmbeddingValidationService;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { ToolRegistry } from \"functools-kit\";\r\nimport { IStateSchema, StateName } from \"../../../interfaces/State.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\n/**\r\n * Service for managing state schemas.\r\n */\r\nexport class StateSchemaService {\r\n  readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n\r\n  private registry = new ToolRegistry<Record<StateName, IStateSchema>>(\r\n    \"stateSchemaService\"\r\n  );\r\n\r\n  /**\r\n   * Registers a new state schema.\r\n   * @param {StateName} key - The key for the schema.\r\n   * @param {IStateSchema} value - The schema to register.\r\n   */\r\n  public register = (key: StateName, value: IStateSchema) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`stateSchemaService register`, { key });\r\n    this.registry = this.registry.register(key, value);\r\n  };\r\n\r\n  /**\r\n   * Retrieves a state schema by key.\r\n   * @param {StateName} key - The key of the schema to retrieve.\r\n   * @returns {IStateSchema} The retrieved schema.\r\n   */\r\n  public get = (key: StateName): IStateSchema => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`stateSchemaService get`, { key });\r\n    return this.registry.get(key);\r\n  };\r\n}\r\n\r\nexport default StateSchemaService;\r\n","import { queued, singleshot } from \"functools-kit\";\r\nimport {\r\n  IState,\r\n  IStateData,\r\n  IStateParams,\r\n} from \"../interfaces/State.interface\";\r\nimport { IBusEvent } from \"../model/Event.model\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\ntype DispatchFn<State extends IStateData = IStateData> = (\r\n  prevState: State\r\n) => Promise<State>;\r\n\r\ntype Action = \"read\" | \"write\";\r\n\r\n/**\r\n * Class representing the client state.\r\n * @template State - The type of the state data.\r\n * @implements {IState<State>}\r\n */\r\nexport class ClientState<State extends IStateData = IStateData>\r\n  implements IState<State>\r\n{\r\n  private _state: State = null as State;\r\n\r\n  private dispatch = queued(\r\n    async (action: Action, payload?: DispatchFn<State>) => {\r\n      if (action === \"read\") {\r\n        return this._state;\r\n      }\r\n      if (action === \"write\") {\r\n        console.assert(\r\n          payload,\r\n          `agent-swarm ClientState write action undefined payload`\r\n        );\r\n        return (this._state = await payload(this._state));\r\n      }\r\n      throw new Error(\"agent-swarm ClientState unknown action\");\r\n    }\r\n  ) as (action: string, payload?: DispatchFn<State>) => Promise<State>;\r\n\r\n  /**\r\n   * Creates an instance of ClientState.\r\n   * @param {IStateParams<State>} params - The state parameters.\r\n   */\r\n  constructor(readonly params: IStateParams<State>) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} CTOR`,\r\n        {\r\n          params,\r\n        }\r\n      );\r\n    if (this.params.callbacks?.onInit) {\r\n      this.params.callbacks.onInit(this.params.clientId, this.params.stateName);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * Waits for the state to initialize.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public waitForInit = singleshot(async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} waitForInit`\r\n      );\r\n    this._state = await this.params.getState(\r\n      this.params.clientId,\r\n      this.params.stateName\r\n    );\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} waitForInit output`,\r\n        { initialState: this._state }\r\n      );\r\n    if (this.params.callbacks?.onLoad) {\r\n      this.params.callbacks.onLoad(\r\n        this._state,\r\n        this.params.clientId,\r\n        this.params.stateName\r\n      );\r\n    }\r\n  });\r\n\r\n  /**\r\n   * Sets the state using the provided dispatch function.\r\n   * @param {DispatchFn<State>} dispatchFn - The dispatch function.\r\n   * @returns {Promise<State>}\r\n   */\r\n  public setState = async (dispatchFn: DispatchFn<State>) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} setState`\r\n      );\r\n    await this.dispatch(\"write\", async (currentState: State) => {\r\n      for (const middleware of this.params.middlewares) {\r\n        currentState = await middleware(\r\n          currentState,\r\n          this.params.clientId,\r\n          this.params.stateName\r\n        );\r\n      }\r\n      return await dispatchFn(currentState);\r\n    });\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} setState output`,\r\n        { pendingState: this._state }\r\n      );\r\n    this.params.setState &&\r\n      this.params.setState(\r\n        this._state,\r\n        this.params.clientId,\r\n        this.params.stateName\r\n      );\r\n    if (this.params.callbacks?.onWrite) {\r\n      this.params.callbacks.onWrite(\r\n        this._state,\r\n        this.params.clientId,\r\n        this.params.stateName\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"set-state\",\r\n      source: \"state-bus\",\r\n      input: {},\r\n      output: {\r\n        state: this._state,\r\n      },\r\n      context: {\r\n        stateName: this.params.stateName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return this._state;\r\n  };\r\n\r\n  /**\r\n   * Gets the current state.\r\n   * @returns {Promise<State>}\r\n   */\r\n  public getState = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} getState`\r\n      );\r\n    await this.dispatch(\"read\");\r\n    if (this.params.callbacks?.onRead) {\r\n      this.params.callbacks.onRead(\r\n        this._state,\r\n        this.params.clientId,\r\n        this.params.stateName\r\n      );\r\n    }\r\n    await this.params.bus.emit<IBusEvent>(this.params.clientId, {\r\n      type: \"get-state\",\r\n      source: \"state-bus\",\r\n      input: {},\r\n      output: {\r\n        state: this._state,\r\n      },\r\n      context: {\r\n        stateName: this.params.stateName,\r\n      },\r\n      clientId: this.params.clientId,\r\n    });\r\n    return this._state;\r\n  };\r\n\r\n  /**\r\n   * Disposes of the state.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async () => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&\r\n      this.params.logger.debug(\r\n        `ClientState stateName=${this.params.stateName} clientId=${this.params.clientId} shared=${this.params.shared} dispose`\r\n      );\r\n    if (this.params.callbacks?.onDispose) {\r\n      this.params.callbacks.onDispose(\r\n        this.params.clientId,\r\n        this.params.stateName\r\n      );\r\n    }\r\n  };\r\n}\r\n\r\nexport default ClientState;\r\n","import { inject } from \"../../core/di\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport { memoize, queued } from \"functools-kit\";\r\nimport { TMethodContextService } from \"../context/MethodContextService\";\r\nimport ClientState from \"../../../client/ClientState\";\r\nimport StateSchemaService from \"../schema/StateSchemaService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\nimport {\r\n  IState,\r\n  IStateData,\r\n  StateName,\r\n} from \"../../../interfaces/State.interface\";\r\nimport SessionValidationService from \"../validation/SessionValidationService\";\r\nimport BusService from \"../base/BusService\";\r\n\r\n/**\r\n * Service for managing state connections.\r\n * @template T - The type of state data.\r\n * @implements {IState<T>}\r\n */\r\nexport class StateConnectionService<T extends IStateData = IStateData>\r\n  implements IState<T>\r\n{\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly busService = inject<BusService>(TYPES.busService);\r\n  private readonly methodContextService = inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  );\r\n\r\n  private readonly stateSchemaService = inject<StateSchemaService>(\r\n    TYPES.stateSchemaService\r\n  );\r\n\r\n  private readonly sessionValidationService = inject<SessionValidationService>(\r\n    TYPES.sessionValidationService\r\n  );\r\n\r\n  /**\r\n   * Memoized function to get a shared state reference.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {StateName} stateName - The state name.\r\n   * @returns {ClientState} The client state.\r\n   */\r\n  public getSharedStateRef = memoize(\r\n    ([, stateName]) => `${stateName}`,\r\n    (clientId: string, stateName: StateName) => {\r\n      this.sessionValidationService.addStateUsage(clientId, stateName);\r\n      const {\r\n        getState,\r\n        setState,\r\n        middlewares = [],\r\n        shared,\r\n        callbacks,\r\n      } = this.stateSchemaService.get(stateName);\r\n      if (!shared) {\r\n        throw new Error(`agent-swarm state not shared stateName=${stateName}`);\r\n      }\r\n      return new ClientState({\r\n        clientId,\r\n        stateName,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        setState: setState\r\n          ? (queued(\r\n              async (...args) => await setState(...args)\r\n            ) as typeof setState)\r\n          : setState,\r\n        getState,\r\n        middlewares,\r\n        callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Memoized function to get a state reference.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {StateName} stateName - The state name.\r\n   * @returns {ClientState} The client state.\r\n   */\r\n  public getStateRef = memoize(\r\n    ([clientId, stateName]) => `${clientId}-${stateName}`,\r\n    (clientId: string, stateName: StateName) => {\r\n      this.sessionValidationService.addStateUsage(clientId, stateName);\r\n      const {\r\n        getState,\r\n        setState,\r\n        middlewares = [],\r\n        callbacks,\r\n        shared = false,\r\n      } = this.stateSchemaService.get(stateName);\r\n      if (shared) {\r\n        return this.getSharedStateRef(clientId, stateName);\r\n      }\r\n      return new ClientState({\r\n        clientId,\r\n        stateName,\r\n        logger: this.loggerService,\r\n        bus: this.busService,\r\n        setState: setState\r\n          ? (queued(\r\n              async (...args) => await setState(...args)\r\n            ) as typeof setState)\r\n          : setState,\r\n        getState,\r\n        middlewares,\r\n        callbacks,\r\n      });\r\n    }\r\n  );\r\n\r\n  /**\r\n   * Sets the state.\r\n   * @param {function(T): Promise<T>} dispatchFn - The function to dispatch the new state.\r\n   * @returns {Promise<T>} The new state.\r\n   */\r\n  public setState = async (\r\n    dispatchFn: (prevState: T) => Promise<T>\r\n  ): Promise<T> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`stateConnectionService setState`);\r\n    const state = this.getStateRef(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.stateName\r\n    );\r\n    await state.waitForInit();\r\n    return await state.setState(dispatchFn);\r\n  };\r\n\r\n  /**\r\n   * Gets the state.\r\n   * @returns {Promise<T>} The current state.\r\n   */\r\n  public getState = async (): Promise<T> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`stateConnectionService getState`);\r\n    const state = this.getStateRef(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.stateName\r\n    );\r\n    await state.waitForInit();\r\n    return await state.getState();\r\n  };\r\n\r\n  /**\r\n   * Disposes the state connection.\r\n   * @returns {Promise<void>}\r\n   */\r\n  public dispose = async (): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`stateConnectionService dispose`);\r\n    const key = `${this.methodContextService.context.clientId}-${this.methodContextService.context.stateName}`;\r\n    if (!this.getStateRef.has(key)) {\r\n      return;\r\n    }\r\n    if (\r\n      !this.getSharedStateRef.has(this.methodContextService.context.stateName)\r\n    ) {\r\n      const state = this.getStateRef(\r\n        this.methodContextService.context.clientId,\r\n        this.methodContextService.context.stateName\r\n      );\r\n      await state.waitForInit();\r\n      await state.dispose();\r\n    }\r\n    this.getStateRef.clear(key);\r\n    this.sessionValidationService.removeStateUsage(\r\n      this.methodContextService.context.clientId,\r\n      this.methodContextService.context.stateName\r\n    );\r\n  };\r\n}\r\n\r\nexport default StateConnectionService;\r\n","import { inject } from \"../../core/di\";\r\nimport { StateConnectionService } from \"../connection/StateConnectionService\";\r\nimport LoggerService from \"../base/LoggerService\";\r\nimport TYPES from \"../../core/types\";\r\nimport MethodContextService from \"../context/MethodContextService\";\r\nimport { IStateData, StateName } from \"../../../interfaces/State.interface\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\ninterface IStateConnectionService extends StateConnectionService {}\r\n\r\ntype InternalKeys = keyof {\r\n  getStateRef: never;\r\n  getSharedStateRef: never;\r\n};\r\n\r\ntype TStateConnectionService = {\r\n  [key in Exclude<keyof IStateConnectionService, InternalKeys>]: unknown;\r\n};\r\n\r\nexport class StatePublicService<T extends IStateData = IStateData>\r\n  implements TStateConnectionService\r\n{\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly stateConnectionService = inject<StateConnectionService>(\r\n    TYPES.stateConnectionService\r\n  );\r\n\r\n  /**\r\n   * Sets the state using the provided dispatch function.\r\n   * @param {function(T): Promise<T>} dispatchFn - The function to dispatch the state change.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {StateName} stateName - The name of the state.\r\n   * @returns {Promise<T>} - The updated state.\r\n   */\r\n  public setState = async (\r\n    dispatchFn: (prevState: T) => Promise<T>,\r\n    methodName: string,\r\n    clientId: string,\r\n    stateName: StateName\r\n  ): Promise<T> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`statePublicService setState`, {\r\n        methodName,\r\n        clientId,\r\n        stateName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.stateConnectionService.setState(dispatchFn);\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        stateName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Gets the current state.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {StateName} stateName - The name of the state.\r\n   * @returns {Promise<T>} - The current state.\r\n   */\r\n  public getState = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    stateName: StateName\r\n  ): Promise<T> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`statePublicService getState`, {\r\n        clientId,\r\n        stateName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.stateConnectionService.getState();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        stateName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n      }\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Disposes the state.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {StateName} stateName - The name of the state.\r\n   * @returns {Promise<void>} - A promise that resolves when the state is disposed.\r\n   */\r\n  public dispose = async (\r\n    methodName: string,\r\n    clientId: string,\r\n    stateName: StateName\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(\"statePublicService dispose\", {\r\n        methodName,\r\n        clientId,\r\n        stateName,\r\n      });\r\n    return await MethodContextService.runInContext(\r\n      async () => {\r\n        return await this.stateConnectionService.dispose();\r\n      },\r\n      {\r\n        methodName,\r\n        clientId,\r\n        stateName,\r\n        agentName: \"\",\r\n        swarmName: \"\",\r\n        storageName: \"\",\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\nexport default StatePublicService;\r\n","import { memoize, Subject } from \"functools-kit\";\r\nimport { inject } from \"../../../lib/core/di\";\r\nimport LoggerService from \"./LoggerService\";\r\nimport TYPES from \"../../../lib/core/types\";\r\nimport { IBus } from \"../../../interfaces/Bus.interface\";\r\nimport IBaseEvent, { EventSource } from \"../../../model/Event.model\";\r\nimport SessionValidationService from \"../validation/SessionValidationService\";\r\nimport { GLOBAL_CONFIG } from \"../../../config/params\";\r\n\r\nexport class BusService implements IBus {\r\n  private readonly loggerService = inject<LoggerService>(TYPES.loggerService);\r\n  private readonly sessionValidationService = inject<SessionValidationService>(\r\n    TYPES.sessionValidationService\r\n  );\r\n\r\n  private _eventSourceSet = new Set<EventSource>();\r\n  private _eventWildcardMap = new Map<EventSource, boolean>();\r\n\r\n  private getEventSubject = memoize<\r\n    (clientId: string, source: EventSource) => Subject<IBaseEvent>\r\n  >(\r\n    ([clientId, source]) => `${clientId}-${source}`,\r\n    () => new Subject()\r\n  );\r\n\r\n  /**\r\n   * Subscribes to events for a specific client and source.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {EventSource} source - The event source.\r\n   * @param {(event: T) => void} fn - The callback function to handle the event.\r\n   */\r\n  public subscribe = <T extends IBaseEvent>(\r\n    clientId: string,\r\n    source: EventSource,\r\n    fn: (event: T) => void\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`busService subscribe`, {\r\n        clientId,\r\n        source,\r\n      });\r\n    if (clientId === \"*\") {\r\n      this._eventWildcardMap.set(source, true);\r\n    }\r\n    this._eventSourceSet.add(source);\r\n    return this.getEventSubject(clientId, source).subscribe(fn);\r\n  };\r\n\r\n  /**\r\n   * Subscribes to a single event for a specific client and source.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {EventSource} source - The event source.\r\n   * @param {(event: T) => boolean} filterFn - The filter function to determine if the event should be handled.\r\n   * @param {(event: T) => void} fn - The callback function to handle the event.\r\n   * @returns {Subscription} The subscription object.\r\n   */\r\n  public once = <T extends IBaseEvent>(\r\n    clientId: string,\r\n    source: EventSource,\r\n    filterFn: (event: T) => boolean,\r\n    fn: (event: T) => void\r\n  ) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`busService once`, {\r\n        clientId,\r\n        source,\r\n      });\r\n    if (clientId === \"*\") {\r\n      this._eventWildcardMap.set(source, true);\r\n    }\r\n    this._eventSourceSet.add(source);\r\n    return this.getEventSubject(clientId, source).filter(filterFn).once(fn);\r\n  };\r\n\r\n  /**\r\n   * Emits an event for a specific client.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {T} event - The event to emit.\r\n   * @returns {Promise<void>} A promise that resolves when the event has been emitted.\r\n   */\r\n  public emit = async <T extends IBaseEvent>(clientId: string, event: T) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`busService emit`, {\r\n        clientId,\r\n        event,\r\n      });\r\n    if (!this.sessionValidationService.hasSession(clientId)) {\r\n      return;\r\n    }\r\n    if (this.getEventSubject.has(`${clientId}-${event.source}`)) {\r\n      await this.getEventSubject(clientId, event.source).next(event);\r\n    }\r\n    if (this._eventWildcardMap.has(event.source)) {\r\n      await this.getEventSubject(\"*\", event.source).next(event);\r\n    }\r\n  };\r\n\r\n  /**\r\n   * Disposes of all event subscriptions for a specific client.\r\n   * @param {string} clientId - The client ID.\r\n   */\r\n  public dispose = (clientId: string) => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&\r\n      this.loggerService.info(`busService dispose`, {\r\n        clientId,\r\n      });\r\n    for (const source of this._eventSourceSet) {\r\n      const key = `${clientId}-${source}`;\r\n      if (this.getEventSubject.has(key)) {\r\n        this.getEventSubject(clientId, source).unsubscribeAll();\r\n      }\r\n      this.getEventSubject.clear(`${clientId}-${source}`);\r\n    }\r\n  };\r\n}\r\n\r\nexport default BusService;\r\n","import MethodContextService from \"../services/context/MethodContextService\";\r\nimport LoggerService from \"../services/base/LoggerService\";\r\nimport AgentSchemaService from \"../services/schema/AgentSchemaService\";\r\nimport AgentConnectionService from \"../services/connection/AgentConnectionService\";\r\nimport HistoryConnectionService from \"../services/connection/HistoryConnectionService\";\r\nimport { provide } from \"./di\";\r\nimport TYPES from \"./types\";\r\nimport ToolSchemaService from \"../services/schema/ToolSchemaService\";\r\nimport SwarmConnectionService from \"../services/connection/SwarmConnectionService\";\r\nimport SwarmSchemaService from \"../services/schema/SwarmSchemaService\";\r\nimport CompletionSchemaService from \"../services/schema/CompletionSchemaService\";\r\nimport SessionConnectionService from \"../services/connection/SessionConnectionService\";\r\nimport AgentPublicService from \"../services/public/AgentPublicService\";\r\nimport HistoryPublicService from \"../services/public/HistoryPublicService\";\r\nimport SessionPublicService from \"../services/public/SessionPublicService\";\r\nimport SwarmPublicService from \"../services/public/SwarmPublicService\";\r\nimport AgentValidationService from \"../services/validation/AgentValidationService\";\r\nimport CompletionValidationService from \"../services/validation/CompletionValidationService\";\r\nimport SessionValidationService from \"../services/validation/SessionValidationService\";\r\nimport SwarmValidationService from \"../services/validation/SwarmValidationService\";\r\nimport ToolValidationService from \"../services/validation/ToolValidationService\";\r\nimport EmbeddingSchemaService from \"../services/schema/EmbeddingSchemaService\";\r\nimport StorageSchemaService from \"../services/schema/StorageSchemaService\";\r\nimport StorageConnectionService from \"../services/connection/StorageConnectionService\";\r\nimport StoragePublicService from \"../services/public/StoragePublicService\";\r\nimport StorageValidationService from \"../services/validation/StorageValidationService\";\r\nimport EmbeddingValidationService from \"../services/validation/EmbeddingValidationService\";\r\nimport StateSchemaService from \"../services/schema/StateSchemaService\";\r\nimport StateConnectionService from \"../services/connection/StateConnectionService\";\r\nimport StatePublicService from \"../services/public/StatePublicService\";\r\nimport BusService from \"../services/base/BusService\";\r\nimport ExecutionContextService from \"../services/context/ExecutionContextService\";\r\n\r\n{\r\n    provide(TYPES.busService, () => new BusService());\r\n    provide(TYPES.loggerService, () => new LoggerService());\r\n}\r\n\r\n{\r\n    provide(TYPES.methodContextService, () => new MethodContextService());\r\n    provide(TYPES.executionContextService, () => new ExecutionContextService());\r\n}\r\n\r\n{\r\n    provide(TYPES.agentConnectionService, () => new AgentConnectionService());\r\n    provide(TYPES.historyConnectionService, () => new HistoryConnectionService());\r\n    provide(TYPES.swarmConnectionService, () => new SwarmConnectionService());\r\n    provide(TYPES.sessionConnectionService, () => new SessionConnectionService());\r\n    provide(TYPES.storageConnectionService, () => new StorageConnectionService());\r\n    provide(TYPES.stateConnectionService, () => new StateConnectionService());\r\n}\r\n\r\n{\r\n    provide(TYPES.agentSchemaService, () => new AgentSchemaService());\r\n    provide(TYPES.toolSchemaService, () => new ToolSchemaService());\r\n    provide(TYPES.swarmSchemaService, () => new SwarmSchemaService());\r\n    provide(TYPES.completionSchemaService, () => new CompletionSchemaService());\r\n    provide(TYPES.embeddingSchemaService, () => new EmbeddingSchemaService());\r\n    provide(TYPES.storageSchemaService, () => new StorageSchemaService());\r\n    provide(TYPES.stateSchemaService, () => new StateSchemaService());\r\n}\r\n\r\n{\r\n    provide(TYPES.agentPublicService, () => new AgentPublicService());\r\n    provide(TYPES.historyPublicService, () => new HistoryPublicService());\r\n    provide(TYPES.sessionPublicService, () => new SessionPublicService());\r\n    provide(TYPES.swarmPublicService, () => new SwarmPublicService());\r\n    provide(TYPES.storagePublicService, () => new StoragePublicService());\r\n    provide(TYPES.statePublicService, () => new StatePublicService());\r\n}\r\n\r\n{\r\n    provide(TYPES.agentPublicService, () => new AgentPublicService());\r\n    provide(TYPES.historyPublicService, () => new HistoryPublicService());\r\n    provide(TYPES.sessionPublicService, () => new SessionPublicService());\r\n    provide(TYPES.swarmPublicService, () => new SwarmPublicService());\r\n}\r\n\r\n{\r\n    provide(TYPES.agentValidationService, () => new AgentValidationService());\r\n    provide(TYPES.completionValidationService, () => new CompletionValidationService());\r\n    provide(TYPES.sessionValidationService, () => new SessionValidationService());\r\n    provide(TYPES.swarmValidationService, () => new SwarmValidationService());\r\n    provide(TYPES.toolValidationService, () => new ToolValidationService());\r\n    provide(TYPES.storageValidationService, () => new StorageValidationService());\r\n    provide(TYPES.embeddingValidationService, () => new EmbeddingValidationService());\r\n}\r\n","import \"./core/provide\";\r\nimport { inject, init } from \"./core/di\";\r\nimport TYPES from \"./core/types\";\r\nimport LoggerService from \"./services/base/LoggerService\";\r\nimport AgentConnectionService from \"./services/connection/AgentConnectionService\";\r\nimport HistoryConnectionService from \"./services/connection/HistoryConnectionService\";\r\nimport AgentSchemaService from \"./services/schema/AgentSchemaService\";\r\nimport ToolSchemaService from \"./services/schema/ToolSchemaService\";\r\nimport SwarmConnectionService from \"./services/connection/SwarmConnectionService\";\r\nimport SwarmSchemaService from \"./services/schema/SwarmSchemaService\";\r\nimport CompletionSchemaService from \"./services/schema/CompletionSchemaService\";\r\nimport MethodContextService, {\r\n  TMethodContextService,\r\n} from \"./services/context/MethodContextService\";\r\nimport SessionConnectionService from \"./services/connection/SessionConnectionService\";\r\nimport AgentPublicService from \"./services/public/AgentPublicService\";\r\nimport HistoryPublicService from \"./services/public/HistoryPublicService\";\r\nimport SessionPublicService from \"./services/public/SessionPublicService\";\r\nimport SwarmPublicService from \"./services/public/SwarmPublicService\";\r\nimport AgentValidationService from \"./services/validation/AgentValidationService\";\r\nimport ToolValidationService from \"./services/validation/ToolValidationService\";\r\nimport SessionValidationService from \"./services/validation/SessionValidationService\";\r\nimport SwarmValidationService from \"./services/validation/SwarmValidationService\";\r\nimport CompletionValidationService from \"./services/validation/CompletionValidationService\";\r\nimport EmbeddingSchemaService from \"./services/schema/EmbeddingSchemaService\";\r\nimport StorageSchemaService from \"./services/schema/StorageSchemaService\";\r\nimport StorageConnectionService from \"./services/connection/StorageConnectionService\";\r\nimport StoragePublicService from \"./services/public/StoragePublicService\";\r\nimport StorageValidationService from \"./services/validation/StorageValidationService\";\r\nimport EmbeddingValidationService from \"./services/validation/EmbeddingValidationService\";\r\nimport StatePublicService from \"./services/public/StatePublicService\";\r\nimport StateSchemaService from \"./services/schema/StateSchemaService\";\r\nimport StateConnectionService from \"./services/connection/StateConnectionService\";\r\nimport BusService from \"./services/base/BusService\";\r\nimport ExecutionContextService, {\r\n  TExecutionContextService,\r\n} from \"./services/context/ExecutionContextService\";\r\n\r\nconst baseServices = {\r\n  busService: inject<BusService>(TYPES.busService),\r\n  loggerService: inject<LoggerService>(TYPES.loggerService),\r\n};\r\n\r\nconst contextServices = {\r\n  methodContextService: inject<TMethodContextService>(\r\n    TYPES.methodContextService\r\n  ),\r\n  executionContextService: inject<TExecutionContextService>(\r\n    TYPES.executionContextService\r\n  ),\r\n};\r\n\r\nconst connectionServices = {\r\n  agentConnectionService: inject<AgentConnectionService>(\r\n    TYPES.agentConnectionService\r\n  ),\r\n  historyConnectionService: inject<HistoryConnectionService>(\r\n    TYPES.historyConnectionService\r\n  ),\r\n  swarmConnectionService: inject<SwarmConnectionService>(\r\n    TYPES.swarmConnectionService\r\n  ),\r\n  sessionConnectionService: inject<SessionConnectionService>(\r\n    TYPES.sessionConnectionService\r\n  ),\r\n  storageConnectionService: inject<StorageConnectionService>(\r\n    TYPES.storageConnectionService\r\n  ),\r\n  stateConnectionService: inject<StateConnectionService>(\r\n    TYPES.stateConnectionService\r\n  ),\r\n};\r\n\r\nconst schemaServices = {\r\n  agentSchemaService: inject<AgentSchemaService>(TYPES.agentSchemaService),\r\n  toolSchemaService: inject<ToolSchemaService>(TYPES.toolSchemaService),\r\n  swarmSchemaService: inject<SwarmSchemaService>(TYPES.swarmSchemaService),\r\n  completionSchemaService: inject<CompletionSchemaService>(\r\n    TYPES.completionSchemaService\r\n  ),\r\n  embeddingSchemaService: inject<EmbeddingSchemaService>(\r\n    TYPES.embeddingSchemaService\r\n  ),\r\n  storageSchemaService: inject<StorageSchemaService>(\r\n    TYPES.storageSchemaService\r\n  ),\r\n  stateSchemaService: inject<StateSchemaService>(TYPES.stateSchemaService),\r\n};\r\n\r\nconst publicServices = {\r\n  agentPublicService: inject<AgentPublicService>(TYPES.agentPublicService),\r\n  historyPublicService: inject<HistoryPublicService>(\r\n    TYPES.historyPublicService\r\n  ),\r\n  sessionPublicService: inject<SessionPublicService>(\r\n    TYPES.sessionPublicService\r\n  ),\r\n  swarmPublicService: inject<SwarmPublicService>(TYPES.swarmPublicService),\r\n  storagePublicService: inject<StoragePublicService>(\r\n    TYPES.storagePublicService\r\n  ),\r\n  statePublicService: inject<StatePublicService>(TYPES.statePublicService),\r\n};\r\n\r\nconst validationServices = {\r\n  agentValidationService: inject<AgentValidationService>(\r\n    TYPES.agentValidationService\r\n  ),\r\n  toolValidationService: inject<ToolValidationService>(\r\n    TYPES.toolValidationService\r\n  ),\r\n  sessionValidationService: inject<SessionValidationService>(\r\n    TYPES.sessionValidationService\r\n  ),\r\n  swarmValidationService: inject<SwarmValidationService>(\r\n    TYPES.swarmValidationService\r\n  ),\r\n  completionValidationService: inject<CompletionValidationService>(\r\n    TYPES.completionValidationService\r\n  ),\r\n  storageValidationService: inject<StorageValidationService>(\r\n    TYPES.storageValidationService\r\n  ),\r\n  embeddingValidationService: inject<EmbeddingValidationService>(\r\n    TYPES.embeddingValidationService\r\n  ),\r\n};\r\n\r\nexport const swarm = {\r\n  ...baseServices,\r\n  ...contextServices,\r\n  ...connectionServices,\r\n  ...schemaServices,\r\n  ...publicServices,\r\n  ...validationServices,\r\n};\r\n\r\ninit();\r\n\r\nexport { MethodContextService };\r\n\r\nexport { ExecutionContextService };\r\n\r\nexport default swarm;\r\n","import { IAgentSchema } from \"../interfaces/Agent.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addAgent\";\r\n\r\n/**\r\n * Adds a new agent to the agent registry. The swarm takes only those agents which was registered\r\n *\r\n * @param {IAgentSchema} agentSchema - The schema of the agent to be added.\r\n * @returns {string} The name of the added agent.\r\n */\r\nexport const addAgent = (agentSchema: IAgentSchema) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      agentSchema,\r\n    });\r\n  swarm.agentValidationService.addAgent(agentSchema.agentName, agentSchema);\r\n  swarm.agentSchemaService.register(agentSchema.agentName, agentSchema);\r\n  return agentSchema.agentName;\r\n};\r\n","import { ICompletionSchema } from \"../interfaces/Completion.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addCompletion\";\r\n\r\n/**\r\n * Adds a completion engine for agents. Agents could use different models and\r\n * framewords for completion like: mock, gpt4all, ollama, openai\r\n *\r\n * @param {ICompletionSchema} completionSchema - The completion schema to be added.\r\n * @returns {string} The name of the completion that was added.\r\n */\r\nexport const addCompletion = (completionSchema: ICompletionSchema) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      completionSchema,\r\n    });\r\n  swarm.completionValidationService.addCompletion(\r\n    completionSchema.completionName\r\n  );\r\n  swarm.completionSchemaService.register(\r\n    completionSchema.completionName,\r\n    completionSchema\r\n  );\r\n  return completionSchema.completionName;\r\n};\r\n","import { ISwarmSchema } from \"../interfaces/Swarm.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addSwarm\";\r\n\r\n/**\r\n * Adds a new swarm to the system. The swarm is a root for starting client session\r\n *\r\n * @param {ISwarmSchema} swarmSchema - The schema of the swarm to be added.\r\n * @returns {string} The name of the added swarm.\r\n */\r\nexport const addSwarm = (swarmSchema: ISwarmSchema) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      swarmSchema,\r\n    });\r\n  swarm.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);\r\n  swarm.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);\r\n  return swarmSchema.swarmName;\r\n};\r\n","import { IAgentTool } from \"../interfaces/Agent.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addTool\";\r\n\r\n/**\r\n * Adds a new tool for agents in a swarm. Tool should be registered in `addAgent`\r\n * declaration\r\n *\r\n * @param {IAgentTool} toolSchema - The schema of the tool to be added.\r\n * @returns {string} The name of the tool that was added.\r\n */\r\nexport const addTool = (toolSchema: IAgentTool) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      toolSchema,\r\n    });\r\n  swarm.toolValidationService.addTool(toolSchema.toolName, toolSchema);\r\n  swarm.toolSchemaService.register(toolSchema.toolName, toolSchema);\r\n  return toolSchema.toolName;\r\n};\r\n","import { IStateSchema } from \"../interfaces/State.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addState\";\r\n\r\n/**\r\n * Adds a new state to the state registry. The swarm takes only those states which was registered\r\n *\r\n * @param {IStateSchema} stateSchema - The schema of the state to be added.\r\n * @returns {string} The name of the added state.\r\n */\r\nexport const addState = (stateSchema: IStateSchema) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      stateSchema,\r\n    });\r\n  swarm.stateSchemaService.register(stateSchema.stateName, stateSchema);\r\n  if (stateSchema.shared) {\r\n    swarm.stateConnectionService\r\n      .getSharedStateRef(\"shared\", stateSchema.stateName)\r\n      .waitForInit();\r\n  }\r\n  return stateSchema.stateName;\r\n};\r\n","import { IEmbeddingSchema } from \"../interfaces/Embedding.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addEmbedding\";\r\n\r\n/**\r\n * Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered\r\n *\r\n * @param {IEmbeddingSchema} embeddingSchema - The schema of the embedding to be added.\r\n * @returns {string} The name of the added embedding.\r\n */\r\nexport const addEmbedding = (embeddingSchema: IEmbeddingSchema) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      embeddingSchema,\r\n    });\r\n  swarm.embeddingValidationService.addEmbedding(\r\n    embeddingSchema.embeddingName,\r\n    embeddingSchema\r\n  );\r\n  swarm.embeddingSchemaService.register(\r\n    embeddingSchema.embeddingName,\r\n    embeddingSchema\r\n  );\r\n  return embeddingSchema.embeddingName;\r\n};\r\n","import { IStorageData, IStorageSchema } from \"../interfaces/Storage.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.addStorage\";\r\n\r\n/**\r\n * Adds a new storage to the storage registry. The swarm takes only those storages which was registered\r\n *\r\n * @param {IStorageSchema} storageSchema - The schema of the storage to be added.\r\n * @returns {string} The name of the added storage.\r\n */\r\nexport const addStorage = <T extends IStorageData = IStorageData>(\r\n  storageSchema: IStorageSchema<T>\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      storageSchema,\r\n    });\r\n  swarm.storageValidationService.addStorage(\r\n    storageSchema.storageName,\r\n    storageSchema\r\n  );\r\n  swarm.storageSchemaService.register(storageSchema.storageName, storageSchema);\r\n  if (storageSchema.shared) {\r\n    swarm.storageConnectionService\r\n      .getSharedStorage(\"shared\", storageSchema.storageName)\r\n      .waitForInit();\r\n  }\r\n  return storageSchema.storageName;\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitSystemMessage\";\r\n\r\n/**\r\n * Commits a user message to the active agent history in as swarm without answer.\r\n *\r\n * @param {string} content - The content of the message.\r\n * @param {string} clientId - The ID of the client.\r\n * @param {string} agentName - The name of the agent.\r\n * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n */\r\nexport const commitUserMessage = async (\r\n  content: string,\r\n  clientId: string,\r\n  agentName: string\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n      agentName,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"commitUserMessage\" skipped due to the agent change',\r\n        {\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  await swarm.sessionPublicService.commitUserMessage(\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.getAgentName\";\r\n\r\n/**\r\n * Retrieves the agent name for a given client ID.\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @returns {Promise<string>} The name of the agent.\r\n * @throws Will throw an error if the client ID is invalid or if the swarm validation fails.\r\n */\r\nexport const getAgentName = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  return await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { queued, schedule } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { ReceiveMessageFn } from \"../interfaces/Session.interface\";\r\nimport { SwarmName } from \"../interfaces/Swarm.interface\";\r\nimport swarm from \"../lib\";\r\nimport { commitUserMessage } from \"./commitUserMessage\";\r\nimport { getAgentName } from \"./getAgentName\";\r\n\r\ntype SendMessageFn = (outgoing: string) => Promise<void>;\r\n\r\nconst SCHEDULED_DELAY = 1_000;\r\n\r\nconst METHOD_NAME = \"function.makeConnection\";\r\n\r\n/**\r\n * A connection factory for a client to a swarm and returns a function to send messages.\r\n *\r\n * @param {ReceiveMessageFn} connector - The function to receive messages.\r\n * @param {string} clientId - The unique identifier of the client.\r\n * @param {SwarmName} swarmName - The name of the swarm.\r\n * @returns {SendMessageFn} - A function to send messages to the swarm.\r\n */\r\nconst makeConnection = (\r\n  connector: ReceiveMessageFn,\r\n  clientId: string,\r\n  swarmName: SwarmName\r\n): SendMessageFn => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      swarmName,\r\n    });\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  swarm.sessionValidationService.addSession(\r\n    clientId,\r\n    swarmName,\r\n    \"makeConnection\"\r\n  );\r\n  const send = swarm.sessionPublicService.connect(\r\n    connector,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  return queued(async (outgoing) => {\r\n    swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n    return await send({\r\n      data: outgoing,\r\n      agentName: await swarm.swarmPublicService.getAgentName(\r\n        METHOD_NAME,\r\n        clientId,\r\n        swarmName\r\n      ),\r\n      clientId,\r\n    });\r\n  }) as SendMessageFn;\r\n};\r\n\r\n/**\r\n * Configuration for scheduling messages.\r\n *\r\n * @interface IMakeConnectionConfig\r\n * @property {number} [delay] - The delay in milliseconds for scheduling messages.\r\n */\r\nexport interface IMakeConnectionConfig {\r\n  delay?: number;\r\n}\r\n\r\n/**\r\n * A scheduled connection factory for a client to a swarm and returns a function to send messages.\r\n *\r\n * @param {ReceiveMessageFn} connector - The function to receive messages.\r\n * @param {string} clientId - The unique identifier of the client.\r\n * @param {SwarmName} swarmName - The name of the swarm.\r\n * @param {Partial<IMakeConnectionConfig>} [config] - The configuration for scheduling.\r\n * @returns {SendMessageFn} - A function to send scheduled messages to the swarm.\r\n */\r\nmakeConnection.scheduled = (\r\n  connector: ReceiveMessageFn,\r\n  clientId: string,\r\n  swarmName: SwarmName,\r\n  { delay = SCHEDULED_DELAY }: Partial<IMakeConnectionConfig> = {}\r\n) => {\r\n  const send = makeConnection(connector, clientId, swarmName);\r\n\r\n  /**\r\n   * A wrapped send function that schedules the message sending.\r\n   *\r\n   * @param {string} content - The message content to be sent.\r\n   * @returns {Promise<void>} - A promise that resolves when the message is sent.\r\n   */\r\n  const wrappedSend: typeof send = schedule(\r\n    async (content: string) => {\r\n      if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n        return;\r\n      }\r\n      return await send(content);\r\n    },\r\n    {\r\n      /**\r\n       * A function that is called when a message is scheduled.\r\n       *\r\n       * @param {[string]} content - The message content to be scheduled.\r\n       * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n       */\r\n      onSchedule: async ([content]) => {\r\n        if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n          return;\r\n        }\r\n        await commitUserMessage(\r\n          content,\r\n          clientId,\r\n          await getAgentName(clientId)\r\n        );\r\n      },\r\n      /**\r\n       * The delay for message scheduler\r\n       */\r\n      delay,\r\n    }\r\n  );\r\n\r\n  /**\r\n   * A function to send scheduled messages.\r\n   *\r\n   * @param {string} content - The message content to be sent.\r\n   * @returns {Promise<void>} - A promise that resolves when the message is sent.\r\n   */\r\n  return async (content: string) => {\r\n    return await wrappedSend(content);\r\n  };\r\n};\r\n\r\nexport { makeConnection };\r\n","import { queued, singleshot, ttl } from \"functools-kit\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.changeAgent\";\r\n\r\n/**\r\n * Time-to-live for the change agent function in milliseconds.\r\n * @constant {number}\r\n */\r\nconst CHANGE_AGENT_TTL = 15 * 60 * 1_000;\r\n\r\n/**\r\n * Garbage collection interval for the change agent function in milliseconds.\r\n * @constant {number}\r\n */\r\nconst CHANGE_AGENT_GC = 60 * 1_000;\r\n\r\ntype TChangeAgentRun = (methodName: string, agentName: string) => Promise<void>;\r\n\r\n/**\r\n * Creates a change agent function with TTL and queuing.\r\n * @function\r\n * @param {string} clientId - The client ID.\r\n * @returns {TChangeAgentRun} - The change agent function.\r\n */\r\nconst createChangeAgent = ttl(\r\n  (clientId: string) =>\r\n    queued(async (methodName: string, agentName: AgentName) => {\r\n      swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n      swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n      const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n      await Promise.all(\r\n        swarm.swarmValidationService\r\n          .getAgentList(swarmName)\r\n          .map(async (agentName) => {\r\n            await swarm.agentPublicService.commitAgentChange(\r\n              methodName,\r\n              clientId,\r\n              agentName\r\n            );\r\n          })\r\n      );\r\n      {\r\n        await swarm.agentPublicService.dispose(methodName, clientId, agentName);\r\n        await swarm.historyPublicService.dispose(\r\n          methodName,\r\n          clientId,\r\n          agentName\r\n        );\r\n        await swarm.swarmPublicService.setAgentRef(\r\n          methodName,\r\n          clientId,\r\n          swarmName,\r\n          agentName,\r\n          await swarm.agentPublicService.createAgentRef(\r\n            methodName,\r\n            clientId,\r\n            agentName\r\n          )\r\n        );\r\n      }\r\n      await swarm.swarmPublicService.setAgentName(\r\n        agentName,\r\n        methodName,\r\n        clientId,\r\n        swarmName\r\n      );\r\n    }) as TChangeAgentRun,\r\n  {\r\n    key: ([clientId]) => `${clientId}`,\r\n    timeout: CHANGE_AGENT_TTL,\r\n  }\r\n);\r\n\r\n/**\r\n * Creates a garbage collector for the change agent function.\r\n * @function\r\n * @returns {Promise<void>} - A promise that resolves when the garbage collector is created.\r\n */\r\nconst createGc = singleshot(async () => {\r\n  setInterval(createChangeAgent.gc, CHANGE_AGENT_GC);\r\n});\r\n\r\n/**\r\n * Changes the agent for a given client session in swarm.\r\n * @async\r\n * @function\r\n * @param {AgentName} agentName - The name of the agent.\r\n * @param {string} clientId - The client ID.\r\n * @returns {Promise<void>} - A promise that resolves when the agent is changed.\r\n */\r\nexport const changeAgent = async (agentName: AgentName, clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      agentName,\r\n      clientId,\r\n    });\r\n  const run = await createChangeAgent(clientId);\r\n  createGc();\r\n  return await run(METHOD_NAME, agentName);\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport History from \"../classes/History\";\r\nimport { SwarmName } from \"../interfaces/Swarm.interface\";\r\nimport swarm from \"../lib\";\r\nimport LoggerAdapter from \"../classes/Logger\";\r\n\r\nconst METHOD_NAME = \"function.disposeConnection\";\r\n\r\n/**\r\n * Disposes the session for a given client with all related swarms and agents.\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {SwarmName} swarmName - The name of the swarm.\r\n * @returns {Promise<void>} A promise that resolves when the connection is disposed.\r\n */\r\nexport const disposeConnection = async (\r\n  clientId: string,\r\n  swarmName: SwarmName,\r\n  methodName = METHOD_NAME\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      swarmName,\r\n    });\r\n  swarm.swarmValidationService.validate(swarmName, methodName);\r\n  await swarm.sessionPublicService.dispose(methodName, clientId, swarmName);\r\n  await swarm.swarmPublicService.dispose(methodName, clientId, swarmName);\r\n  await Promise.all(\r\n    swarm.swarmValidationService\r\n      .getAgentList(swarmName)\r\n      .map(async (agentName) => {\r\n        await swarm.agentPublicService.dispose(methodName, clientId, agentName);\r\n        await swarm.historyPublicService.dispose(\r\n          methodName,\r\n          clientId,\r\n          agentName\r\n        );\r\n      })\r\n  );\r\n  await Promise.all(\r\n    swarm.swarmValidationService\r\n      .getAgentList(swarmName)\r\n      .flatMap((agentName) =>\r\n        swarm.agentValidationService.getStorageList(agentName)\r\n      )\r\n      .filter((storageName) => !!storageName)\r\n      .map(async (storageName) => {\r\n        await swarm.storagePublicService.dispose(\r\n          methodName,\r\n          clientId,\r\n          storageName\r\n        );\r\n      })\r\n  );\r\n  await Promise.all(\r\n    swarm.swarmValidationService\r\n      .getAgentList(swarmName)\r\n      .flatMap((agentName) =>\r\n        swarm.agentValidationService.getStateList(agentName)\r\n      )\r\n      .filter((stateName) => !!stateName)\r\n      .map(async (stateName) => {\r\n        await swarm.statePublicService.dispose(methodName, clientId, stateName);\r\n      })\r\n  );\r\n  await History.dispose(clientId, null);\r\n  await LoggerAdapter.dispose(clientId);\r\n  swarm.sessionValidationService.removeSession(clientId);\r\n  swarm.busService.dispose(clientId);\r\n};\r\n","import { queued, randomString, singleshot, ttl } from \"functools-kit\";\r\nimport { SwarmName } from \"../interfaces/Swarm.interface\";\r\nimport swarm, { ExecutionContextService } from \"../lib\";\r\nimport { disposeConnection } from \"./disposeConnection\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.complete\";\r\n\r\n/**\r\n * Type definition for the complete run function.\r\n * @typedef {function(string): Promise<string>} TCompleteRun\r\n */\r\ntype TCompleteRun = (METHOD_NAME: string, content: string) => Promise<string>;\r\n\r\nconst COMPLETE_TTL = 15 * 60 * 1_000;\r\nconst COMPLETE_GC = 60 * 1_000;\r\n\r\n/**\r\n * Creates a complete function with TTL and queuing.\r\n * @param {string} clientId - The client ID.\r\n * @param {SwarmName} swarmName - The swarm name.\r\n * @returns {TCompleteRun} The complete run function.\r\n */\r\nconst createComplete = ttl(\r\n  (clientId: string, swarmName: SwarmName) =>\r\n    queued(async (METHOD_NAME: string, content: string) => {\r\n      swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n      swarm.sessionValidationService.addSession(\r\n        clientId,\r\n        swarmName,\r\n        \"complete\"\r\n      );\r\n      const result = await swarm.sessionPublicService.execute(\r\n        content,\r\n        \"user\",\r\n        METHOD_NAME,\r\n        clientId,\r\n        swarmName\r\n      );\r\n      await disposeConnection(clientId, swarmName, METHOD_NAME);\r\n      return result;\r\n    }) as TCompleteRun,\r\n  {\r\n    key: ([clientId, swarmName]) => `${clientId}-${swarmName}`,\r\n    timeout: COMPLETE_TTL,\r\n  }\r\n);\r\n\r\n/**\r\n * Creates a garbage collector for the complete function.\r\n * @returns {Promise<void>} A promise that resolves when the GC is set up.\r\n */\r\nconst createGc = singleshot(async () => {\r\n  setInterval(createComplete.gc, COMPLETE_GC);\r\n});\r\n\r\n/**\r\n * The complete function will create a swarm, execute single command and dispose it\r\n * Best for developer needs like troubleshooting tool execution\r\n *\r\n * @param {string} content - The content to process.\r\n * @param {string} clientId - The client ID.\r\n * @param {SwarmName} swarmName - The swarm name.\r\n * @returns {Promise<string>} The result of the complete function.\r\n */\r\nexport const complete = async (\r\n  content: string,\r\n  clientId: string,\r\n  swarmName: SwarmName\r\n) => {\r\n  const executionId = randomString();\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n      executionId,\r\n      swarmName,\r\n    });\r\n  const run = await createComplete(clientId, swarmName);\r\n  createGc();\r\n  return ExecutionContextService.runInContext(\r\n    async () => {\r\n      return await run(METHOD_NAME, content);\r\n    },\r\n    {\r\n      clientId,\r\n      executionId,\r\n    }\r\n  );\r\n};\r\n","import { queued, randomString, schedule } from \"functools-kit\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { SwarmName } from \"../interfaces/Swarm.interface\";\r\nimport swarm, { ExecutionContextService } from \"../lib\";\r\nimport { disposeConnection } from \"./disposeConnection\";\r\nimport { commitUserMessage } from \"./commitUserMessage\";\r\nimport { getAgentName } from \"./getAgentName\";\r\n\r\ntype TComplete = (content: string) => Promise<string>;\r\n\r\nconst SCHEDULED_DELAY = 1_000;\r\n\r\nconst METHOD_NAME = \"function.session\";\r\n\r\n/**\r\n * Creates a session for the given client and swarm.\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {SwarmName} swarmName - The name of the swarm.\r\n * @returns {Object} An object containing the session methods.\r\n * @returns {TComplete} complete - A function to complete the session with content.\r\n * @returns {Function} dispose - A function to dispose of the session.\r\n */\r\nconst session = (clientId: string, swarmName: SwarmName) => {\r\n  const executionId = randomString();\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      swarmName,\r\n      executionId,\r\n    });\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  swarm.sessionValidationService.addSession(clientId, swarmName, \"session\");\r\n  return {\r\n    /**\r\n     * Completes the session with the given content.\r\n     *\r\n     * @param {string} content - The content to complete the session with.\r\n     * @returns {Promise<string>} A promise that resolves with the result of the session execution.\r\n     */\r\n    complete: queued(async (content: string) => {\r\n      swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n      return ExecutionContextService.runInContext(\r\n        async () => {\r\n          return await swarm.sessionPublicService.execute(\r\n            content,\r\n            \"user\",\r\n            METHOD_NAME,\r\n            clientId,\r\n            swarmName\r\n          );\r\n        },\r\n        {\r\n          clientId,\r\n          executionId,\r\n        }\r\n      );\r\n    }) as TComplete,\r\n\r\n    /**\r\n     * Disposes of the session.\r\n     *\r\n     * @returns {Promise<void>} A promise that resolves when the session is disposed.\r\n     */\r\n    dispose: async () => {\r\n      return await disposeConnection(clientId, swarmName, METHOD_NAME);\r\n    },\r\n  };\r\n};\r\n\r\n/**\r\n * Configuration options for a scheduled session.\r\n *\r\n * @interface ISessionConfig\r\n * @property {number} [delay] - The delay for the scheduled session in milliseconds.\r\n */\r\nexport interface ISessionConfig {\r\n  delay?: number;\r\n}\r\n\r\n/**\r\n * Creates a scheduled session for the given client and swarm.\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {SwarmName} swarmName - The name of the swarm.\r\n * @param {Partial<ISessionConfig>} [config] - The configuration for the scheduled session.\r\n * @param {number} [config.delay] - The delay for the scheduled session.\r\n * @returns {Object} An object containing the scheduled session methods.\r\n * @returns {TComplete} complete - A function to complete the session with content.\r\n * @returns {Function} dispose - A function to dispose of the session.\r\n */\r\nsession.scheduled = (\r\n  clientId: string,\r\n  swarmName: SwarmName,\r\n  { delay = SCHEDULED_DELAY }: Partial<ISessionConfig> = {}\r\n) => {\r\n  const { complete, dispose } = session(clientId, swarmName);\r\n\r\n  let isMounted = true;\r\n\r\n  /**\r\n   * Completes the scheduled session with the given content.\r\n   *\r\n   * @param {string} content - The content to complete the session with.\r\n   * @returns {Promise<string>} A promise that resolves with the result of the session execution.\r\n   */\r\n  const wrappedComplete: typeof complete = schedule(\r\n    async (content: string) => {\r\n      if (!isMounted) {\r\n        return;\r\n      }\r\n      return await complete(content);\r\n    },\r\n    {\r\n      onSchedule: async ([content]) => {\r\n        if (!isMounted) {\r\n          return;\r\n        }\r\n        await commitUserMessage(\r\n          content,\r\n          clientId,\r\n          await getAgentName(clientId)\r\n        );\r\n      },\r\n      delay,\r\n    }\r\n  );\r\n\r\n  return {\r\n    /**\r\n     * Completes the scheduled session with the given content.\r\n     *\r\n     * @param {string} content - The content to complete the session with.\r\n     * @returns {Promise<string>} A promise that resolves with the result of the session execution.\r\n     */\r\n    async complete(content: string) {\r\n      return await wrappedComplete(content);\r\n    },\r\n    /**\r\n     * Disposes of the scheduled session.\r\n     *\r\n     * @returns {Promise<void>} A promise that resolves when the session is disposed.\r\n     */\r\n    async dispose() {\r\n      isMounted = false;\r\n      return await dispose();\r\n    },\r\n  };\r\n};\r\n\r\nexport { session };\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.getRawHistory\";\r\n\r\n/**\r\n * Retrieves the raw history as it is for a given client ID without any modifications.\r\n *\r\n * @param {string} clientId - The ID of the client whose history is to be retrieved.\r\n * @returns {Promise<Array>} A promise that resolves to an array containing the raw history.\r\n */\r\nexport const getRawHistory = async (\r\n  clientId: string,\r\n  methodName = METHOD_NAME,\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, methodName);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, methodName);\r\n  const agentName = await swarm.swarmPublicService.getAgentName(\r\n    methodName,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  const history = await swarm.historyPublicService.toArrayForRaw(\r\n    methodName,\r\n    clientId,\r\n    agentName\r\n  );\r\n  return [...history];\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.getAgentHistory\";\r\n\r\n/**\r\n * Retrieves the history prepared for a specific agent with resque algorithm tweaks\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {AgentName} agentName - The name of the agent.\r\n * @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.\r\n */\r\nexport const getAgentHistory = async (\r\n  clientId: string,\r\n  agentName: AgentName\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      agentName,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  const { prompt } = swarm.agentSchemaService.get(agentName);\r\n  const history = await swarm.historyPublicService.toArrayForAgent(\r\n    prompt,\r\n    METHOD_NAME,\r\n    clientId,\r\n    agentName\r\n  );\r\n  return [...history];\r\n};\r\n","import swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.getSessionMode\";\r\n\r\n/**\r\n * Return the session mode (`\"session\" | \"makeConnection\" | \"complete\"`) for clientId\r\n *\r\n * @param {string} clientId - The client ID of the session.\r\n */\r\nexport const getSessionMode = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  return swarm.sessionValidationService.getSessionMode(clientId);\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitToolOutput\";\r\n\r\n/**\r\n * Commits the tool output to the active agent in a swarm session\r\n *\r\n * @param {string} content - The content to be committed.\r\n * @param {string} clientId - The client ID associated with the session.\r\n * @param {AgentName} agentName - The name of the agent committing the output.\r\n * @returns {Promise<void>} - A promise that resolves when the operation is complete.\r\n */\r\nexport const commitToolOutput = async (\r\n  toolId: string,\r\n  content: string,\r\n  clientId: string,\r\n  agentName: AgentName\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      toolId,\r\n      content,\r\n      clientId,\r\n      agentName,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"commitToolOutput\" skipped due to the agent change',\r\n        {\r\n          toolId,\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  await swarm.sessionPublicService.commitToolOutput(\r\n    toolId,\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitSystemMessage\";\r\n\r\n/**\r\n * Commits a system message to the active agent in the swarm.\r\n *\r\n * @param {string} content - The content of the system message.\r\n * @param {string} clientId - The ID of the client.\r\n * @param {string} agentName - The name of the agent.\r\n * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n */\r\nexport const commitSystemMessage = async (\r\n  content: string,\r\n  clientId: string,\r\n  agentName: string\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n      agentName,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"commitSystemMessage\" skipped due to the agent change',\r\n        {\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  await swarm.sessionPublicService.commitSystemMessage(\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitFlush\";\r\n\r\n/**\r\n * Commits flush of agent history\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {string} agentName - The name of the agent.\r\n * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n */\r\nexport const commitFlush = async (clientId: string, agentName: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      agentName,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"commitFlush\" skipped due to the agent change',\r\n        {\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  await swarm.sessionPublicService.commitFlush(METHOD_NAME, clientId, swarmName);\r\n};\r\n","import { randomString } from \"functools-kit\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm, { ExecutionContextService } from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.execute\";\r\n\r\n/**\r\n * Send the message to the active agent in the swarm content like it income from client side\r\n * Should be used to review tool output and initiate conversation from the model side to client\r\n *\r\n * @param {string} content - The content to be executed.\r\n * @param {string} clientId - The ID of the client requesting execution.\r\n * @param {AgentName} agentName - The name of the agent executing the command.\r\n * @returns {Promise<void>} - A promise that resolves when the execution is complete.\r\n */\r\nexport const execute = async (\r\n  content: string,\r\n  clientId: string,\r\n  agentName: AgentName\r\n) => {\r\n  const executionId = randomString();\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n      agentName,\r\n      executionId,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"execute\" skipped due to the agent change',\r\n        {\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  return ExecutionContextService.runInContext(\r\n    async () => {\r\n      return await swarm.sessionPublicService.execute(\r\n        content,\r\n        \"tool\",\r\n        METHOD_NAME,\r\n        clientId,\r\n        swarmName\r\n      );\r\n    },\r\n    {\r\n      clientId,\r\n      executionId,\r\n    }\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.emit\";\r\n\r\n/**\r\n * Emits a string constant as the model output without executing incoming message\r\n * Works only for `makeConnection`\r\n *\r\n * @param {string} content - The content to be emitted.\r\n * @param {string} clientId - The client ID of the session.\r\n * @param {AgentName} agentName - The name of the agent to emit the content to.\r\n * @throws Will throw an error if the session mode is not \"makeConnection\".\r\n * @returns {Promise<void>} A promise that resolves when the content is emitted.\r\n */\r\nexport const emit = async (\r\n  content: string,\r\n  clientId: string,\r\n  agentName: AgentName\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n      agentName,\r\n    });\r\n  if (\r\n    swarm.sessionValidationService.getSessionMode(clientId) !== \"makeConnection\"\r\n  ) {\r\n    throw new Error(\r\n      `agent-swarm-kit emit session is not makeConnection clientId=${clientId}`\r\n    );\r\n  }\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"emit\" skipped due to the agent change',\r\n        {\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  return await swarm.sessionPublicService.emit(\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitToolOutputForce\";\r\n\r\n/**\r\n * Commits the tool output to the active agent in a swarm session without checking active agent\r\n *\r\n * @param {string} content - The content to be committed.\r\n * @param {string} clientId - The client ID associated with the session.\r\n * @returns {Promise<void>} - A promise that resolves when the operation is complete.\r\n */\r\nexport const commitToolOutputForce = async (\r\n  toolId: string,\r\n  content: string,\r\n  clientId: string\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      toolId,\r\n      content,\r\n      clientId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  await swarm.sessionPublicService.commitToolOutput(\r\n    toolId,\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitSystemMessageForce\";\r\n\r\n/**\r\n * Commits a system message to the active agent in as swarm without checking active agent.\r\n *\r\n * @param {string} content - The content of the system message.\r\n * @param {string} clientId - The ID of the client.\r\n * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n */\r\nexport const commitSystemMessageForce = async (\r\n  content: string,\r\n  clientId: string\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  await swarm.sessionPublicService.commitSystemMessage(\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitFlushForce\";\r\n\r\n/**\r\n * Commits flush of agent history without active agent check\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n */\r\nexport const commitFlushForce = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      METHOD_NAME,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  await swarm.sessionPublicService.commitFlush(METHOD_NAME, clientId, swarmName);\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.commitSystemMessage\";\r\n\r\n/**\r\n * Commits a user message to the active agent history in as swarm without answer and checking active agent\r\n *\r\n * @param {string} content - The content of the message.\r\n * @param {string} clientId - The ID of the client.\r\n * @returns {Promise<void>} - A promise that resolves when the message is committed.\r\n */\r\nexport const commitUserMessageForce = async (\r\n  content: string,\r\n  clientId: string\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  await swarm.sessionPublicService.commitUserMessage(\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.emitForce\";\r\n\r\n/**\r\n * Emits a string constant as the model output without executing incoming message and checking active agent\r\n * Works only for `makeConnection`\r\n *\r\n * @param {string} content - The content to be emitted.\r\n * @param {string} clientId - The client ID of the session.\r\n * @param {AgentName} agentName - The name of the agent to emit the content to.\r\n * @throws Will throw an error if the session mode is not \"makeConnection\".\r\n * @returns {Promise<void>} A promise that resolves when the content is emitted.\r\n */\r\nexport const emitForce = async (content: string, clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n    });\r\n  if (\r\n    swarm.sessionValidationService.getSessionMode(clientId) !== \"makeConnection\"\r\n  ) {\r\n    throw new Error(\r\n      `agent-swarm-kit emitForce session is not makeConnection clientId=${clientId}`\r\n    );\r\n  }\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  return await swarm.sessionPublicService.emit(\r\n    content,\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n};\r\n","import { randomString } from \"functools-kit\";\r\nimport swarm, { ExecutionContextService } from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.executeForce\";\r\n\r\n/**\r\n * Send the message to the active agent in the swarm content like it income from client side\r\n * Should be used to review tool output and initiate conversation from the model side to client\r\n *\r\n * Will execute even if the agent is inactive\r\n *\r\n * @param {string} content - The content to be executed.\r\n * @param {string} clientId - The ID of the client requesting execution.\r\n * @returns {Promise<void>} - A promise that resolves when the execution is complete.\r\n */\r\nexport const executeForce = async (content: string, clientId: string) => {\r\n  const executionId = randomString();\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      content,\r\n      clientId,\r\n      executionId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  return ExecutionContextService.runInContext(\r\n    async () => {\r\n      return await swarm.sessionPublicService.execute(\r\n        content,\r\n        \"tool\",\r\n        METHOD_NAME,\r\n        clientId,\r\n        swarmName\r\n      );\r\n    },\r\n    {\r\n      clientId,\r\n      executionId,\r\n    }\r\n  );\r\n};\r\n","import { EventSource, ICustomEvent } from \"../model/Event.model\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.listenEvent\";\r\n\r\nconst DISALLOWED_EVENT_SOURCE_LIST: Set<EventSource> = new Set([\r\n  \"agent-bus\",\r\n  \"history-bus\",\r\n  \"session-bus\",\r\n  \"state-bus\",\r\n  \"storage-bus\",\r\n  \"swarm-bus\",\r\n]);\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(\r\n      `agent-swarm listenEvent session not found for clientId=${clientId}`\r\n    );\r\n  }\r\n};\r\n\r\n/**\r\n * Listens for an event on the swarm bus service and executes a callback function when the event is received.\r\n *\r\n * @template T - The type of the data payload.\r\n * @param {string} clientId - The ID of the client to listen for events from.\r\n * @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.\r\n */\r\nexport const listenEvent = <T extends unknown = any>(\r\n  clientId: string,\r\n  topicName: string,\r\n  fn: (data: T) => void\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {\r\n    throw new Error(\r\n      `agent-swarm listenEvent topic is reserved topicName=${topicName}`\r\n    );\r\n  }\r\n  validateClientId(clientId);\r\n  return swarm.busService.subscribe<ICustomEvent<T>>(\r\n    clientId,\r\n    topicName,\r\n    ({ payload }) => fn(payload)\r\n  );\r\n};\r\n","import { EventSource, ICustomEvent } from \"../model/Event.model\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.listenEventOnce\";\r\n\r\nconst DISALLOWED_EVENT_SOURCE_LIST: Set<EventSource> = new Set([\r\n  \"agent-bus\",\r\n  \"history-bus\",\r\n  \"session-bus\",\r\n  \"state-bus\",\r\n  \"storage-bus\",\r\n  \"swarm-bus\",\r\n]);\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(\r\n      `agent-swarm listenEventOnce session not found for clientId=${clientId}`\r\n    );\r\n  }\r\n};\r\n\r\n/**\r\n * Listens for an event on the swarm bus service and executes a callback function when the event is received.\r\n *\r\n * @template T - The type of the data payload.\r\n * @param {string} clientId - The ID of the client to listen for events from.\r\n * @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.\r\n */\r\nexport const listenEventOnce = <T extends unknown = any>(\r\n  clientId: string,\r\n  topicName: string,\r\n  filterFn: (event: T) => boolean,\r\n  fn: (data: T) => void\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {\r\n    throw new Error(\r\n      `agent-swarm listenEventOnce topic is reserved topicName=${topicName}`\r\n    );\r\n  }\r\n  validateClientId(clientId);\r\n  return swarm.busService.once<ICustomEvent<T>>(\r\n    clientId,\r\n    topicName,\r\n    ({ payload }) => filterFn(payload),\r\n    ({ payload }) => fn(payload)\r\n  );\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\nimport { getRawHistory } from \"./getRawHistory\";\r\n\r\nconst METHOD_NAME = \"function.getLastUserMessage\";\r\n\r\n/**\r\n * Retrieves the last message sent by the user from the client's message history.\r\n *\r\n * @param {string} clientId - The ID of the client whose message history is being retrieved.\r\n * @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.\r\n */\r\nexport const getLastUserMessage = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  const history = await getRawHistory(clientId, METHOD_NAME);\r\n  const last = history.findLast(\r\n    ({ role, mode }) => role === \"user\" && mode === \"user\"\r\n  );\r\n  return last ? last.content : null;\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\nimport { getRawHistory } from \"./getRawHistory\";\r\n\r\nconst METHOD_NAME = \"function.getUserHistory\";\r\n\r\n/**\r\n * Retrieves the user history for a given client ID.\r\n *\r\n * @param {string} clientId - The ID of the client whose history is to be retrieved.\r\n * @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.\r\n */\r\nexport const getUserHistory = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  const history = await getRawHistory(clientId, METHOD_NAME);\r\n  return history.filter(({ role, mode }) => role === \"user\" && mode === \"user\");\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\nimport { getRawHistory } from \"./getRawHistory\";\r\n\r\nconst METHOD_NAME = \"function.getAssistantHistory\";\r\n\r\n/**\r\n * Retrieves the assistant's history for a given client.\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is \"assistant\".\r\n */\r\nexport const getAssistantHistory = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  const history = await getRawHistory(clientId, METHOD_NAME);\r\n  return history.filter(({ role }) => role === \"assistant\");\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\nimport { getRawHistory } from \"./getRawHistory\";\r\n\r\nconst METHOD_NAME = \"function.getLastAssistantMessage\";\r\n\r\n/**\r\n * Retrieves the last message sent by the assistant from the client's message history.\r\n *\r\n * @param {string} clientId - The ID of the client whose message history is being retrieved.\r\n * @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.\r\n */\r\nexport const getLastAssistantMessage = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  const history = await getRawHistory(clientId, METHOD_NAME);\r\n  const last = history.findLast(({ role }) => role === \"assistant\");\r\n  return last ? last.content : null;\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\nimport { getRawHistory } from \"./getRawHistory\";\r\n\r\nconst METHOD_NAME = \"function.getLastSystemMessage\";\r\n\r\n/**\r\n * Retrieves the last message sent by the system from the client's message history.\r\n *\r\n * @param {string} clientId - The ID of the client whose message history is being retrieved.\r\n * @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.\r\n */\r\nexport const getLastSystemMessage = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  const history = await getRawHistory(clientId, METHOD_NAME);\r\n  const last = history.findLast(({ role }) => role === \"system\");\r\n  return last ? last.content : null;\r\n};\r\n","import { Source } from \"functools-kit\";\r\nimport { SwarmName } from \"../interfaces/Swarm.interface\";\r\nimport { disposeConnection } from \"./disposeConnection\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.makeAutoDispose\";\r\n\r\nconst DEFAULT_TIMEOUT = 15 * 60;\r\n\r\n/**\r\n * Interface for the parameters of the makeAutoDispose function.\r\n */\r\nexport interface IMakeDisposeParams {\r\n  /**\r\n   * Timeout in seconds before auto-dispose is triggered.\r\n   */\r\n  timeoutSeconds: number;\r\n  /**\r\n   * Callback when session is closed\r\n   */\r\n  onDestroy?: (clientId: string, swarmName: SwarmName) => void;\r\n}\r\n\r\n/**\r\n * Creates an auto-dispose mechanism for a client in a swarm.\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {SwarmName} swarmName - The name of the swarm.\r\n * @param {Partial<IMakeDisposeParams>} [params={}] - Optional parameters for auto-dispose.\r\n * @returns {Object} An object with tick and stop methods to control the auto-dispose.\r\n */\r\nexport const makeAutoDispose = (\r\n  clientId: string,\r\n  swarmName: SwarmName,\r\n  {\r\n    timeoutSeconds = DEFAULT_TIMEOUT,\r\n    onDestroy,\r\n  }: Partial<IMakeDisposeParams> = {}\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      swarmName,\r\n    });\r\n\r\n  let isOk = true;\r\n\r\n  const unSource = Source.fromInterval(1_000)\r\n    .reduce((acm) => {\r\n      if (isOk) {\r\n        isOk = false;\r\n        return 0;\r\n      }\r\n      return acm + 1;\r\n    }, 0)\r\n    .filter((ticker) => ticker >= timeoutSeconds)\r\n    .once(async () => {\r\n      unSource();\r\n      if (swarm.sessionValidationService.hasSession(clientId)) {\r\n        await disposeConnection(clientId, swarmName);\r\n      }\r\n      onDestroy && onDestroy(clientId, swarmName);\r\n    });\r\n\r\n  return {\r\n    /**\r\n     * Signals that the client is active, resetting the auto-dispose timer.\r\n     */\r\n    tick() {\r\n      isOk = true;\r\n    },\r\n    /**\r\n     * Stops the auto-dispose mechanism.\r\n     */\r\n    destroy() {\r\n      unSource();\r\n      onDestroy && onDestroy(clientId, swarmName);\r\n    },\r\n  };\r\n};\r\n","import { EventSource, ICustomEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.listenEvent\";\r\n\r\nconst DISALLOWED_EVENT_SOURCE_LIST: Set<EventSource> = new Set([\r\n  \"agent-bus\",\r\n  \"history-bus\",\r\n  \"session-bus\",\r\n  \"state-bus\",\r\n  \"storage-bus\",\r\n  \"swarm-bus\",\r\n]);\r\n\r\n/**\r\n * Emits an event to the swarm bus service.\r\n *\r\n * @template T - The type of the payload.\r\n * @param {string} clientId - The ID of the client emitting the event.\r\n * @param {T} payload - The payload of the event.\r\n * @returns {boolean} - Returns true if the event was successfully emitted.\r\n */\r\nexport const event = <T extends unknown = any>(\r\n  clientId: string,\r\n  topicName: string,\r\n  payload: T\r\n) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {\r\n    throw new Error(\r\n      `agent-swarm event topic is reserved topicName=${topicName}`\r\n    );\r\n  }\r\n  return swarm.busService.emit<ICustomEvent>(clientId, {\r\n    source: topicName,\r\n    payload,\r\n    clientId,\r\n  });\r\n};\r\n","import swarm from \"../lib\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\nconst METHOD_NAME = \"function.cancelOutput\";\r\n\r\n/**\r\n * Cancel the await of output by emit of empty string\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {string} agentName - The name of the agent.\r\n * @returns {Promise<void>} - A promise that resolves when the output is canceled\r\n */\r\nexport const cancelOutput = async (clientId: string, agentName: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n      agentName,\r\n    });\r\n  swarm.agentValidationService.validate(agentName, METHOD_NAME);\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  const currentAgentName = await swarm.swarmPublicService.getAgentName(\r\n    METHOD_NAME,\r\n    clientId,\r\n    swarmName\r\n  );\r\n  if (currentAgentName !== agentName) {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(\r\n        'function \"cancelOutput\" skipped due to the agent change',\r\n        {\r\n          currentAgentName,\r\n          agentName,\r\n          clientId,\r\n        }\r\n      );\r\n    return;\r\n  }\r\n  await swarm.swarmPublicService.cancelOutput(METHOD_NAME, clientId, swarmName);\r\n};\r\n","import { GLOBAL_CONFIG } from \"../config/params\";\r\nimport swarm from \"../lib\";\r\n\r\nconst METHOD_NAME = \"function.cancelOutputForce\";\r\n\r\n/**\r\n * Cancel the await of output by emit of empty string without checking active agent\r\n *\r\n * @param {string} clientId - The ID of the client.\r\n * @param {string} agentName - The name of the agent.\r\n * @returns {Promise<void>} - A promise that resolves when the output is canceled\r\n */\r\nexport const cancelOutputForce = async (clientId: string) => {\r\n  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n    swarm.loggerService.log(METHOD_NAME, {\r\n      clientId,\r\n    });\r\n  swarm.sessionValidationService.validate(clientId, METHOD_NAME);\r\n  const swarmName = swarm.sessionValidationService.getSwarm(clientId);\r\n  swarm.swarmValidationService.validate(swarmName, METHOD_NAME);\r\n  await swarm.swarmPublicService.cancelOutput(METHOD_NAME, clientId, swarmName);\r\n};\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenAgentEvent session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to agent events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to events for.\r\n * @param {function} fn - The callback function to handle the event.\r\n */\r\nexport const listenAgentEvent = (\r\n  clientId: string,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenAgentEvent\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.subscribe(\r\n    clientId,\r\n    \"agent-bus\",\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenAgentEvent;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenHistoryEvent session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to history events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to.\r\n * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.\r\n */\r\nexport const listenHistoryEvent = (\r\n  clientId: string,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenHistoryEvent\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.subscribe(\r\n    clientId,\r\n    \"history-bus\",\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenHistoryEvent;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenSessionEvent session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to session events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to session events for.\r\n * @param {function} fn - The callback function to handle the session events.\r\n */\r\nexport const listenSessionEvent = (\r\n  clientId: string,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenSessionEvent\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.subscribe(\r\n    clientId,\r\n    \"session-bus\",\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenSessionEvent;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenStateEvent session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to state events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to.\r\n * @param {function} fn - The callback function to handle the event.\r\n */\r\nexport const listenStateEvent = (\r\n  clientId: string,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenStateEvent\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.subscribe(\r\n    clientId,\r\n    \"state-bus\",\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenStateEvent;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenStorageEvent session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to storage events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to storage events for.\r\n * @param {function} fn - The callback function to handle the storage event.\r\n */\r\nexport const listenStorageEvent = (\r\n  clientId: string,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenStorageEvent\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId)\r\n  return swarm.busService.subscribe(\r\n    clientId,\r\n    \"storage-bus\",\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenStorageEvent;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenSwarmEvent session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to swarm events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to events for.\r\n * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.\r\n */\r\nexport const listenSwarmEvent = (\r\n  clientId: string,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenSwarmEvent\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.subscribe(\r\n    clientId,\r\n    \"swarm-bus\",\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenSwarmEvent;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenAgentEventOnce session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to agent events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to events for.\r\n * @param {function} fn - The callback function to handle the event.\r\n */\r\nexport const listenAgentEventOnce = (\r\n  clientId: string,\r\n  filterFn: (event: IBusEvent) => boolean,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenAgentEventOnce\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.once(\r\n    clientId,\r\n    \"agent-bus\",\r\n    filterFn,\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenAgentEventOnce;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenHistoryEventOnce session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to history events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to.\r\n * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.\r\n */\r\nexport const listenHistoryEventOnce = (\r\n  clientId: string,\r\n  filterFn: (event: IBusEvent) => boolean,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenHistoryEventOnce\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.once(\r\n    clientId,\r\n    \"history-bus\",\r\n    filterFn,\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenHistoryEventOnce;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenSessionEventOnce session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to session events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to session events for.\r\n * @param {function} fn - The callback function to handle the session events.\r\n */\r\nexport const listenSessionEventOnce = (\r\n  clientId: string,\r\n  filterFn: (event: IBusEvent) => boolean,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenSessionEventOnce\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.once(\r\n    clientId,\r\n    \"session-bus\",\r\n    filterFn,\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenSessionEventOnce;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenStateEventOnce session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to state events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to.\r\n * @param {function} fn - The callback function to handle the event.\r\n */\r\nexport const listenStateEventOnce = (\r\n  clientId: string,\r\n  filterFn: (event: IBusEvent) => boolean,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenStateEventOnce\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.once(\r\n    clientId,\r\n    \"state-bus\",\r\n    filterFn,\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenStateEventOnce;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenStorageEventOnce session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to storage events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to storage events for.\r\n * @param {function} fn - The callback function to handle the storage event.\r\n */\r\nexport const listenStorageEventOnce = (\r\n  clientId: string,\r\n  filterFn: (event: IBusEvent) => boolean,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenStorageEventOnce\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId)\r\n  return swarm.busService.once(\r\n    clientId,\r\n    \"storage-bus\",\r\n    filterFn,\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenStorageEventOnce;\r\n","import { IBusEvent } from \"../model/Event.model\";\r\nimport swarm from \"../lib\";\r\n\r\nconst validateClientId = (clientId: string) => {\r\n  if (clientId === \"*\") {\r\n    return;\r\n  }\r\n  if (!swarm.sessionValidationService.hasSession(clientId)) {\r\n    throw new Error(`agent-swarm listenSwarmEventOnce session not found for clientId=${clientId}`);\r\n  }\r\n};\r\n\r\n/**\r\n * Hook to subscribe to swarm events for a specific client.\r\n *\r\n * @param {string} clientId - The ID of the client to subscribe to events for.\r\n * @param {(event: IBusEvent) => void} fn - The callback function to handle the event.\r\n */\r\nexport const listenSwarmEventOnce = (\r\n  clientId: string,\r\n  filterFn: (event: IBusEvent) => boolean,\r\n  fn: (event: IBusEvent) => void\r\n) => {\r\n  swarm.loggerService.log(\"middleware listenSwarmEventOnce\", {\r\n    clientId,\r\n  });\r\n  validateClientId(clientId);\r\n  return swarm.busService.once(\r\n    clientId,\r\n    \"swarm-bus\",\r\n    filterFn,\r\n    fn\r\n  );\r\n};\r\n\r\nexport default listenSwarmEventOnce;\r\n","import swarm from \"../lib\";\r\nimport {\r\n  IStorage,\r\n  IStorageData,\r\n  StorageName,\r\n} from \"../interfaces/Storage.interface\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\ntype TStorage = {\r\n  [key in keyof IStorage]: unknown;\r\n};\r\n\r\n\r\nconst METHOD_NAME_TAKE = \"StorageUtils.take\";\r\nconst METHOD_NAME_UPSERT = \"StorageUtils.upsert\";\r\nconst METHOD_NAME_REMOVE = \"StorageUtils.remove\";\r\nconst METHOD_NAME_GET = \"StorageUtils.get\";\r\nconst METHOD_NAME_LIST = \"StorageUtils.list\";\r\nconst METHOD_NAME_CLEAR = \"StorageUtils.clear\";\r\n\r\nexport class StorageUtils implements TStorage {\r\n  /**\r\n   * Takes items from the storage.\r\n   * @param {string} search - The search query.\r\n   * @param {number} total - The total number of items to take.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @returns {Promise<T[]>} - A promise that resolves to an array of items.\r\n   * @template T\r\n   */\r\n  public take = async <T extends IStorageData = IStorageData>(payload: {\r\n    search: string;\r\n    total: number;\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    storageName: StorageName;\r\n    score?: number;\r\n  }): Promise<T[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_TAKE, {\r\n        search: payload.search,\r\n        total: payload.total,\r\n        clientId: payload.clientId,\r\n        storageName: payload.storageName,\r\n        score: payload.score,\r\n      });\r\n    swarm.storageValidationService.validate(\r\n      payload.storageName,\r\n      METHOD_NAME_TAKE\r\n    );\r\n    if (\r\n      !swarm.agentValidationService.hasStorage(\r\n        payload.agentName,\r\n        payload.storageName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (take)`\r\n      );\r\n    }\r\n    return (await swarm.storagePublicService.take(\r\n      payload.search,\r\n      payload.total,\r\n      METHOD_NAME_TAKE,\r\n      payload.clientId,\r\n      payload.storageName,\r\n      payload.score\r\n    )) as T[];\r\n  };\r\n\r\n  /**\r\n   * Upserts an item in the storage.\r\n   * @param {T} item - The item to upsert.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @returns {Promise<void>} - A promise that resolves when the operation is complete.\r\n   * @template T\r\n   */\r\n  public upsert = async <T extends IStorageData = IStorageData>(payload: {\r\n    item: T;\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    storageName: StorageName;\r\n  }): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_UPSERT, {\r\n        item: payload.item,\r\n        clientId: payload.clientId,\r\n        storageName: payload.storageName,\r\n      });\r\n    swarm.storageValidationService.validate(\r\n      payload.storageName,\r\n      METHOD_NAME_UPSERT\r\n    );\r\n    if (\r\n      !swarm.agentValidationService.hasStorage(\r\n        payload.agentName,\r\n        payload.storageName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (upsert)`\r\n      );\r\n    }\r\n    return await swarm.storagePublicService.upsert(\r\n      payload.item,\r\n      METHOD_NAME_UPSERT,\r\n      payload.clientId,\r\n      payload.storageName\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Removes an item from the storage.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to remove.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @returns {Promise<void>} - A promise that resolves when the operation is complete.\r\n   */\r\n  public remove = async (payload: {\r\n    itemId: IStorageData[\"id\"];\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    storageName: StorageName;\r\n  }): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_REMOVE, {\r\n        itemId: payload.itemId,\r\n        clientId: payload.clientId,\r\n        storageName: payload.storageName,\r\n      });\r\n    swarm.storageValidationService.validate(\r\n      payload.storageName,\r\n      METHOD_NAME_REMOVE\r\n    );\r\n    if (\r\n      !swarm.agentValidationService.hasStorage(\r\n        payload.agentName,\r\n        payload.storageName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (remove)`\r\n      );\r\n    }\r\n    return await swarm.storagePublicService.remove(\r\n      payload.itemId,\r\n      METHOD_NAME_REMOVE,\r\n      payload.clientId,\r\n      payload.storageName\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Gets an item from the storage.\r\n   * @param {IStorageData[\"id\"]} itemId - The ID of the item to get.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.\r\n   * @template T\r\n   */\r\n  public get = async <T extends IStorageData = IStorageData>(payload: {\r\n    itemId: IStorageData[\"id\"];\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    storageName: StorageName;\r\n  }): Promise<T | null> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_GET, {\r\n        itemId: payload.itemId,\r\n        clientId: payload.clientId,\r\n        storageName: payload.storageName,\r\n      });\r\n    swarm.storageValidationService.validate(\r\n      payload.storageName,\r\n      METHOD_NAME_GET\r\n    );\r\n    if (\r\n      !swarm.agentValidationService.hasStorage(\r\n        payload.agentName,\r\n        payload.storageName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (get)`\r\n      );\r\n    }\r\n    return (await swarm.storagePublicService.get(\r\n      payload.itemId,\r\n      METHOD_NAME_GET,\r\n      payload.clientId,\r\n      payload.storageName\r\n    )) as T | null;\r\n  };\r\n\r\n  /**\r\n   * Lists items from the storage.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @param {(item: T) => boolean} [filter] - Optional filter function.\r\n   * @returns {Promise<T[]>} - A promise that resolves to an array of items.\r\n   * @template T\r\n   */\r\n  public list = async <T extends IStorageData = IStorageData>(payload: {\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    storageName: StorageName;\r\n    filter?: (item: T) => boolean;\r\n  }): Promise<T[]> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_LIST, {\r\n        clientId: payload.clientId,\r\n        storageName: payload.storageName,\r\n      });\r\n    swarm.storageValidationService.validate(\r\n      payload.storageName,\r\n      METHOD_NAME_LIST\r\n    );\r\n    if (\r\n      !swarm.agentValidationService.hasStorage(\r\n        payload.agentName,\r\n        payload.storageName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (list)`\r\n      );\r\n    }\r\n    return (await swarm.storagePublicService.list(\r\n      METHOD_NAME_LIST,\r\n      payload.clientId,\r\n      payload.storageName,\r\n      payload.filter\r\n    )) as T[];\r\n  };\r\n\r\n  /**\r\n   * Clears the storage.\r\n   * @param {string} clientId - The client ID.\r\n   * @param {AgentName} agentName - The agent name.\r\n   * @param {StorageName} storageName - The storage name.\r\n   * @returns {Promise<void>} - A promise that resolves when the operation is complete.\r\n   */\r\n  public clear = async (payload: {\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    storageName: StorageName;\r\n  }): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_CLEAR, {\r\n        clientId: payload.clientId,\r\n        storageName: payload.storageName,\r\n      });\r\n    swarm.storageValidationService.validate(\r\n      payload.storageName,\r\n      METHOD_NAME_CLEAR\r\n    );\r\n    if (\r\n      !swarm.agentValidationService.hasStorage(\r\n        payload.agentName,\r\n        payload.storageName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StorageUtils ${payload.storageName} not registered in ${payload.agentName} (clear)`\r\n      );\r\n    }\r\n    return await swarm.storagePublicService.clear(\r\n      METHOD_NAME_CLEAR,\r\n      payload.clientId,\r\n      payload.storageName\r\n    );\r\n  };\r\n}\r\n\r\nexport const Storage = new StorageUtils();\r\n\r\nexport default Storage;\r\n","import swarm from \"../lib\";\r\nimport { IState, IStateData, StateName } from \"../interfaces/State.interface\";\r\nimport { AgentName } from \"../interfaces/Agent.interface\";\r\nimport { GLOBAL_CONFIG } from \"../config/params\";\r\n\r\ntype TState = {\r\n  [key in keyof IState]: unknown;\r\n};\r\n\r\nconst METHOD_NAME_GET = \"StateUtils.getState\";\r\nconst METHOD_NAME_SET = \"StateUtils.setState\";\r\n\r\n/**\r\n * Utility class for managing state in the agent swarm.\r\n * @implements {TState}\r\n */\r\nexport class StateUtils implements TState {\r\n  /**\r\n   * Retrieves the state for a given client and state name.\r\n   * @template T\r\n   * @param {Object} payload - The payload containing client and state information.\r\n   * @param {string} payload.clientId - The client ID.\r\n   * @param {AgentName} payload.agentName - The agent name.\r\n   * @param {StateName} payload.stateName - The state name.\r\n   * @returns {Promise<T>} The state data.\r\n   * @throws Will throw an error if the state is not registered in the agent.\r\n   */\r\n  public getState = async <T extends IStateData = IStateData>(payload: {\r\n    clientId: string;\r\n    agentName: AgentName;\r\n    stateName: StateName;\r\n  }): Promise<T> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_GET, {\r\n        clientId: payload.clientId,\r\n        stateName: payload.stateName,\r\n      });\r\n    if (\r\n      !swarm.agentValidationService.hasState(\r\n        payload.agentName,\r\n        payload.stateName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StateUtils ${payload.stateName} not registered in ${payload.agentName} (getState)`\r\n      );\r\n    }\r\n    return await swarm.statePublicService.getState(\r\n      METHOD_NAME_GET,\r\n      payload.clientId,\r\n      payload.stateName\r\n    );\r\n  };\r\n\r\n  /**\r\n   * Sets the state for a given client and state name.\r\n   * @template T\r\n   * @param {T | ((prevState: T) => Promise<T>)} dispatchFn - The new state or a function that returns the new state.\r\n   * @param {Object} payload - The payload containing client and state information.\r\n   * @param {string} payload.clientId - The client ID.\r\n   * @param {AgentName} payload.agentName - The agent name.\r\n   * @param {StateName} payload.stateName - The state name.\r\n   * @returns {Promise<void>}\r\n   * @throws Will throw an error if the state is not registered in the agent.\r\n   */\r\n  public setState = async <T extends IStateData = IStateData>(\r\n    dispatchFn: T | ((prevState: T) => Promise<T>),\r\n    payload: {\r\n      clientId: string;\r\n      agentName: AgentName;\r\n      stateName: StateName;\r\n    }\r\n  ): Promise<void> => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_SET, {\r\n        clientId: payload.clientId,\r\n        stateName: payload.stateName,\r\n      });\r\n    if (\r\n      !swarm.agentValidationService.hasState(\r\n        payload.agentName,\r\n        payload.stateName\r\n      )\r\n    ) {\r\n      throw new Error(\r\n        `agent-swarm StateUtils ${payload.stateName} not registered in ${payload.agentName} (setState)`\r\n      );\r\n    }\r\n    if (typeof dispatchFn === \"function\") {\r\n      return await swarm.statePublicService.setState(\r\n        dispatchFn as (prevState: T) => Promise<T>,\r\n        METHOD_NAME_SET,\r\n        payload.clientId,\r\n        payload.stateName\r\n      );\r\n    }\r\n    return await swarm.statePublicService.setState(\r\n      async () => dispatchFn as T,\r\n      METHOD_NAME_SET,\r\n      payload.clientId,\r\n      payload.stateName\r\n    );\r\n  };\r\n}\r\n\r\n/**\r\n * Instance of StateUtils for managing state.\r\n * @type {StateUtils}\r\n */\r\nexport const State = new StateUtils();\r\n\r\nexport default State;\r\n","import { isObject } from \"functools-kit\";\r\n\r\ntype Entry = [string, string];\r\n\r\n/**\r\n * Function that recursively flattens a nested object to array of entries.\r\n */\r\nexport const objectFlat = <T extends object = any>(data: T) => {\r\n  const result: Entry[] = [];\r\n  const process = (entries: any[] = []) =>\r\n    entries.forEach(([key, value]) => {\r\n      if (typeof value === \"function\") {\r\n        return;\r\n      }\r\n      if (isObject(value)) {\r\n        result.push([\"\", \"\"]);\r\n        result.push([key, \"\"]);\r\n        process(Object.entries(value));\r\n        result.push([\"\", \"\"]);\r\n        return;\r\n      }\r\n      if (Array.isArray(value)) {\r\n        result.push([\"\", \"\"]);\r\n        result.push([key, \"\"]);\r\n        process(value.map((value, idx) => [String(idx + 1), value]));\r\n        result.push([\"\", \"\"]);\r\n        return;\r\n      }\r\n      result.push([key, String(value)]);\r\n    });\r\n  process(Object.entries(data));\r\n  return result;\r\n};\r\n\r\nexport default objectFlat;\r\n","import { GLOBAL_CONFIG } from \"src/config/params\";\r\nimport objectFlat from \"../utils/objectFlat\";\r\nimport swarm from \"../lib\";\r\n\r\nconst LIST_SEPARATOR = Array.from({ length: 80 }, () => \"-\");\r\n\r\nconst METHOD_NAME_SERIALIZE = \"SchemaUtils.serialize\";\r\n\r\n/**\r\n * Utility class for schema-related operations.\r\n */\r\nexport class SchemaUtils {\r\n  /**\r\n   * Serializes an object or an array of objects into a formatted string.\r\n   *\r\n   * @template T - The type of the object.\r\n   * @param {T[] | T} data - The data to serialize.\r\n   * @returns {string} The serialized string.\r\n   */\r\n  public serialize = <T extends object = any>(data: T[] | T): string => {\r\n    GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&\r\n      swarm.loggerService.log(METHOD_NAME_SERIALIZE, {\r\n        data,\r\n      });\r\n    if (Array.isArray(data)) {\r\n      return data\r\n        .map((item: T) =>\r\n          objectFlat(item)\r\n            .map(([key, value]) => [GLOBAL_CONFIG.CC_NAME_TO_TITLE(key), value])\r\n            .map(([key, value]) => `${key}: ${value}`)\r\n            .join(\"\\n\")\r\n        )\r\n        .join(`\\n${LIST_SEPARATOR}\\n`);\r\n    }\r\n    return objectFlat(data)\r\n      .map(([key, value]) => [GLOBAL_CONFIG.CC_NAME_TO_TITLE(key), value])\r\n      .map(([key, value]) => `${key}: ${value}`)\r\n      .join(\"\\n\");\r\n  };\r\n}\r\n\r\n/**\r\n * An instance of the SchemaUtils class.\r\n */\r\nexport const Schema = new SchemaUtils();\r\n\r\nexport default Schema;\r\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__rest","e","indexOf","getOwnPropertySymbols","propertyIsEnumerable","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","rejected","result","done","then","__generator","body","f","y","_","label","sent","trys","ops","g","create","Iterator","verb","Symbol","iterator","v","op","TypeError","pop","push","__values","o","m","__read","r","ar","error","__spreadArray","to","from","pack","l","Array","slice","concat","__await","__asyncGenerator","asyncIterator","q","AsyncIterator","a","b","resume","fulfill","settle","shift","__asyncValues","d","SuppressedError","MethodContextService","scoped","context","init","_a","createActivator","inject","provide","baseServices","busService","loggerService","contextServices","methodContextService","executionContextService","connectionServices","agentConnectionService","historyConnectionService","swarmConnectionService","sessionConnectionService","storageConnectionService","stateConnectionService","schemaServices","completionSchemaService","agentSchemaService","swarmSchemaService","toolSchemaService","embeddingSchemaService","storageSchemaService","stateSchemaService","publicServices","agentPublicService","historyPublicService","sessionPublicService","swarmPublicService","storagePublicService","statePublicService","validationServices","agentValidationService","toolValidationService","sessionValidationService","swarmValidationService","completionValidationService","embeddingValidationService","storageValidationService","TYPES","ExecutionContextService","validateNoEmptyResult","output","trim","toolParser","xml2js","Parser","validateNoToolCall","trycatch","GLOBAL_CONFIG","CC_AGENT_DISALLOWED_SYMBOLS","symbol","_b","includes","parseStringPromise","_g","_c","CC_AGENT_DISALLOWED_TAGS","tag","_d","defaultValue","validateDefault","validation","HISTORY_INSTANCE_WAIT_FOR_INIT","HistoryInstance","clientId","callbacks","_this","_array","singleshot","agentName","CC_LOGGER_ENABLE_DEBUG","swarm","debug","getData","onInit","onRef","filterCondition","iterate","onRead","onReadBegin","item","_p","getSystemPrompt","_e","role","content","mode","onReadEnd","_f","_h","_j","waitForInit","_l","onPush","onChange","dispose","onDispose","HistoryAdapter","HistoryUtils","HistoryFactory","HistoryCallbacks","getHistory","memoize","useHistoryAdapter","Ctor","CC_LOGGER_ENABLE_LOG","log","useHistoryCallbacks","Callbacks","isInitial","has","history","clear","History","LOGGER_INSTANCE_WAIT_FOR_INIT","LoggerInstance","topic","args","_i","CC_LOGGER_ENABLE_CONSOLE","console","onLog","onDebug","info","onInfo","LoggerAdapter","LoggerFactory","LoggerCallbacks","getLogger","useCommonAdapter","logger","setLogger","useClientCallbacks","useClientAdapter","logClient","hasSession","runInContext","methodName","stateName","storageName","swarmName","infoClient","CC_LOGGER_ENABLE_INFO","debugClient","Logger","CC_TOOL_CALL_EXCEPTION_PROMPT","CC_EMPTY_OUTPUT_PLACEHOLDERS","CC_KEEP_MESSAGES","CC_GET_AGENT_HISTORY_ADAPTER","CC_GET_CLIENT_LOGGER_ADAPTER","CC_SWARM_AGENT_CHANGED","CC_SWARM_DEFAULT_AGENT","defaultAgent_1","defaultAgent","CC_AGENT_DEFAULT_VALIDATION","CC_AGENT_HISTORY_FILTER","message","isOk","tool_calls","CC_AGENT_OUTPUT_TRANSFORM","input","replace","CC_AGENT_OUTPUT_MAP","CC_AGENT_SYSTEM_PROMPT","undefined","CC_STORAGE_SEARCH_SIMILARITY","CC_STORAGE_SEARCH_POOL","CC_NAME_TO_TITLE","name","tokens","split","reverse","word","rest","charAt","toUpperCase","join","setConfig","config","NOOP_LOGGER","LoggerService","_commonLogger","getLoggerAdapter","methodContext","hasContext","executionContext","AgentSchemaService","registry","ToolRegistry","register","key","get","AGENT_CHANGE_SYMBOL","ClientAgent","params","_agentChangeSubject","Subject","_toolCommitSubject","_toolErrorSubject","_outputSubject","_emitOuput","rawResult","transform","validate","_resurrectModel","rawResult_1","result_1","Error","onOutput","bus","emit","type","source","reason","onResurrect","getCompletion","rawMessage","map","Math","floor","random","waitForOutput","toPromise","toArrayForAgent","prompt","system","messages","tools","omit","completion","onComplete","commitUserMessage","onUserMessage","commitFlush","onFlush","commitAgentChange","commitSystemMessage","onSystemMessage","commitToolOutput","toolId","onToolOutput","tool_call_id","execute","queued","incoming","onExecute","toolCalls","function","id","randomString","idx","tool","targetFn","this_1","find","result_2","onValidate","not","JSON","stringify","result_3","onBeforeCall","isLast","onAfterCall","catch","getErrorMessage","errorData","onCallError","race","status","onAfterToolCalls","result1","AgentConnectionService","getAgent","storages","states","completionName","addAgentUsage","forEach","getStorage","removeAgentUsage","ClientHistory","items","toArrayForRaw","commonMessagesRaw","systemMessagesRaw","splice","systemMessages","filter","commonMessages","other","_filterCondition","assistantToolOutputCallSet","Set","assistantRawMessages","assistantToolCallSet","flatMap","assistantMessages","promptMessages","HistoryConnectionService","addHistoryUsage","removeHistoryUsage","ToolSchemaService","AGENT_NEED_FETCH","ClientSwarm","_agentChangedSubject","_activeAgent","_cancelOutputSubject","cancelOutput","getAgentName","createAwaiter","awaiter","getOutput","cancelable","_agentList","agent","handleOutput","cancel","CANCELED_PROMISE_SYMBOL","un","subscribe","expectAgent","getActiveAgent","activeAgent","agentMap","setAgentRef","setAgentName","setActiveAgent","onAgentChanged","defineProperty","entries","SwarmConnectionService","getSwarm","agentList","agentList_1","agentList_1_1","SwarmSchemaService","CompletionSchemaService","ClientSession","_emitSubject","onEmit","outputAwaiter","connect","connector","onConnect","data","SessionConnectionService","getSession","AgentPublicService","createAgentRef","HistoryPublicService","SessionPublicService","send","executionId","SwarmPublicService","AgentValidationService","_agentMap","Map","getStorageList","getStateList","addAgent","agentSchema","set","hasStorage","hasState","toolName","String","CompletionValidationService","_completionSet","addCompletion","add","SessionValidationService","_storageSwarmMap","_historySwarmMap","_agentSwarmMap","_stateSwarmMap","_sessionSwarmMap","_sessionModeMap","addSession","sessionMode","sessionId","agents","addStorageUsage","addStateUsage","agentIndex","delete","removeStorageUsage","removeStateUsage","getSessionMode","getSessionList","keys","getSessionAgentList","getSessionHistoryList","session","removeSession","SwarmValidationService","_swarmMap","addSwarm","swarmSchema","getAgentList","ToolValidationService","_toolMap","addTool","toolSchema","EmbeddingSchemaService","StorageSchemaService","ClientStorage","_itemMap","_createEmbedding","shared","createIndex","index","createEmbedding","embeddings","onCreate","embedding","all","execpool","delay","maxExec","take","search_1","total_1","search","total","score","indexed","SortedArray","searchEmbeddings","values","targetEmbeddings","calculateSimilarity","onCompare","getEntries","onSearch","upsert","onUpdate","remove","itemId","list","StorageConnectionService","getSharedStorage","embeddingName","storage","StoragePublicService","StorageValidationService","_storageMap","addStorage","storageSchema","EmbeddingValidationService","_embeddingMap","addEmbedding","embeddingSchema","StateSchemaService","ClientState","_state","dispatch","action","payload","assert","getState","initialState","onLoad","setState","dispatchFn","currentState","middlewares","middleware","pendingState","onWrite","state","StateConnectionService","getSharedStateRef","getStateRef","StatePublicService","BusService","_eventSourceSet","_eventWildcardMap","getEventSubject","fn","once","filterFn","event","unsubscribeAll","swarm$1","completionSchema","addState","stateSchema","METHOD_NAME","currentAgentName","makeConnection","outgoing","scheduled","wrappedSend","schedule","onSchedule","createChangeAgent","ttl","timeout","createGc","setInterval","gc","changeAgent","run","disposeConnection","clientId_1","swarmName_1","createComplete","complete","isMounted","wrappedComplete","getRawHistory","args_1","getAgentHistory","commitToolOutputForce","commitSystemMessageForce","commitFlushForce","commitUserMessageForce","emitForce","executeForce","DISALLOWED_EVENT_SOURCE_LIST","listenEvent","topicName","validateClientId","listenEventOnce","getLastUserMessage","last","findLast","getUserHistory","getAssistantHistory","getLastAssistantMessage","getLastSystemMessage","makeAutoDispose","timeoutSeconds","onDestroy","unSource","Source","fromInterval","reduce","acm","ticker","tick","destroy","cancelOutputForce","listenAgentEvent","listenHistoryEvent","listenSessionEvent","listenStateEvent","listenStorageEvent","listenSwarmEvent","listenAgentEventOnce","listenHistoryEventOnce","listenSessionEventOnce","listenStateEventOnce","listenStorageEventOnce","listenSwarmEventOnce","METHOD_NAME_TAKE","METHOD_NAME_UPSERT","METHOD_NAME_REMOVE","METHOD_NAME_GET","METHOD_NAME_LIST","METHOD_NAME_CLEAR","StorageUtils","Storage","METHOD_NAME_SET","StateUtils","State","objectFlat","process","isObject","isArray","LIST_SEPARATOR","SchemaUtils","serialize","Schema"],"mappings":"mcA+BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACV,EACMH,EAASa,MAAMC,KAAMP,UAChC,EAEO,SAASQ,EAAOX,EAAGY,GACtB,IAAIb,EAAI,CAAA,EACR,IAAK,IAAIM,KAAKL,EAAOH,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,IAAMO,EAAEC,QAAQR,GAAK,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