@colabo-flow/s-go 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/dist/cjs/index.js +1800 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/index.js +1749 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/types/demo/config.d.ts +10 -0
- package/dist/types/demo/create-client.d.ts +1 -0
- package/dist/types/demo/create-host.d.ts +7 -0
- package/dist/types/demo/create-orchestrator.d.ts +1 -0
- package/dist/types/demo/send.d.ts +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/jest.config.d.ts +3 -0
- package/dist/types/lib/client/index.d.ts +4 -0
- package/dist/types/lib/flowchestrator/index.d.ts +1 -0
- package/dist/types/lib/flowchestrator/store/flow.store.d.ts +57 -0
- package/dist/types/lib/flowchestrator/store/flow.store.test.d.ts +1 -0
- package/dist/types/lib/flowchestrator/store/flowFlowchestrator.store.test.d.ts +1 -0
- package/dist/types/lib/flowchestrator/store/flowchestrator.store.d.ts +82 -0
- package/dist/types/lib/flowchestrator/store/index.d.ts +42 -0
- package/dist/types/lib/host/index.d.ts +7 -0
- package/dist/types/lib/host/omnipresentTasks.d.ts +13 -0
- package/dist/types/lib/host/vos.d.ts +4 -0
- package/dist/types/lib/operators.d.ts +5 -0
- package/dist/types/lib/orchestrator/index.d.ts +2 -0
- package/dist/types/lib/params.d.ts +1 -0
- package/dist/types/lib/uuid_fix.d.ts +15 -0
- package/dist/types/lib/vos.d.ts +205 -0
- package/dist/types/vitest.config.d.ts +2 -0
- package/package.json +73 -13
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../index.ts", "../../lib/client/index.ts", "../../lib/uuid_fix.ts", "../../lib/operators.ts", "../../lib/vos.ts", "../../lib/orchestrator/index.ts", "../../lib/host/index.ts", "../../lib/host/omnipresentTasks.ts", "../../lib/flowchestrator/store/flowchestrator.store.ts", "../../lib/flowchestrator/store/flow.store.ts", "../../lib/flowchestrator/store/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./lib/client\";\nexport * from \"./lib/orchestrator\";\nexport * from \"./lib/host\";\nexport * from \"./lib/vos\";\n\nimport { getPackagePath_ToBeInvited } from \"@colabo-utils/i-register\";\n\n/**\n * This is a special utility function that provides a path to this package (the file in which this function is defined).\n * \n * @returns path of the package\n */\nexport const __getPackagePath = (): string => {\n\treturn getPackagePath_ToBeInvited();\n};\nexport { useFlowFlowchestratorStore } from \"./lib/flowchestrator/store/flowchestrator.store\";\nexport type { IFlowFlowchestratorStoreState, IFlowFlowchestratorStoreActions } from \"./lib/flowchestrator/store/flowchestrator.store\";\nexport { useGlobalStore, type IGlobalStore, type UseGlobalStoreOptions } from \"./lib/flowchestrator/store/index\";", "// https://www.npmjs.com/package/amqplib\nimport { connect } from \"amqplib\";\nimport chalk from \"chalk\";\nimport { uuidv1 } from \"../operators\";\nimport type { Socket } from \"net\";\n\nimport { EColaboFlowGoMsgType, IClientExecuteTaskOptions, IColaboFlowClientData, IColaboFlowGoMsg, IColaboFlowGoMsgExtension_TaskExecute_Request, IColaboFlowGoMsgExtension_TaskExecute_Response } from \"../vos\";\nimport { createGoMsg } from \"../operators\";\n\nconst MINIMUM_FRAME_MAX = 8_192;\n\nconst isAmqpDebugEnabled = (): boolean => {\n\tconst debugRaw: string = process.env.COLABO_FLOW_AMQP_DEBUG || \"\";\n\treturn debugRaw === \"1\" || debugRaw.toLowerCase() === \"true\";\n};\n\nconst parsePositiveInt = (rawValue: string | undefined, fallback: number): number => {\n\tif (!rawValue) return fallback;\n\tconst parsed = Number.parseInt(rawValue, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n};\n\nconst formatError = (err: unknown): string => {\n\tif (!(err instanceof Error)) return String(err);\n\tconst errorExtended = err as Error & { code?: string; errno?: number | string; syscall?: string; address?: string; port?: number; };\n\tconst meta = [\n\t\terrorExtended.code ? `code=${errorExtended.code}` : \"\",\n\t\terrorExtended.errno !== undefined ? `errno=${errorExtended.errno}` : \"\",\n\t\terrorExtended.syscall ? `syscall=${errorExtended.syscall}` : \"\",\n\t\terrorExtended.address ? `address=${errorExtended.address}` : \"\",\n\t\terrorExtended.port !== undefined ? `port=${errorExtended.port}` : \"\",\n\t].filter(Boolean).join(\", \");\n\treturn meta ? `${err.message} (${meta})` : err.message;\n};\n\nconst logAmqpUrlDetails = (client: IColaboFlowClientData, urlRaw: string): void => {\n\ttry {\n\t\tconst parsed = new URL(urlRaw);\n\t\tconst vhostRaw = parsed.pathname || \"/\";\n\t\tconst vhostDecoded = decodeURIComponent(vhostRaw);\n\t\tconst heartbeatQuery = parsed.searchParams.get(\"heartbeat\") || \"(broker default)\";\n\t\tconst frameMaxQuery = parsed.searchParams.get(\"frameMax\") || \"(amqplib default)\";\n\t\tconsole.log(`${client.appNameText} AMQP URL details: protocol=${parsed.protocol}, host=${parsed.hostname}, port=${parsed.port || \"5672\"}, vhostRaw=\"${vhostRaw}\", vhostDecoded=\"${vhostDecoded}\", heartbeat=${heartbeatQuery}, frameMax=${frameMaxQuery}`);\n\t} catch (err) {\n\t\tconsole.warn(`${client.appNameText} Could not parse AMQP URL \"${urlRaw}\": ${formatError(err)}`);\n\t}\n};\n\nconst getEffectiveAmqpUrl = (client: IColaboFlowClientData, urlRaw: string): string => {\n\ttry {\n\t\tconst parsed = new URL(urlRaw);\n\t\tconst defaultFrameMax = parsePositiveInt(process.env.COLABO_FLOW_AMQP_FRAME_MAX, 131_072);\n\t\tconst frameMaxConfiguredRaw = parsed.searchParams.get(\"frameMax\") || undefined;\n\t\tlet frameMax = parsePositiveInt(frameMaxConfiguredRaw, defaultFrameMax);\n\t\tif (frameMax < MINIMUM_FRAME_MAX) {\n\t\t\tconsole.warn(`${client.appNameText} frameMax=${frameMax} is too low; forcing frameMax=${MINIMUM_FRAME_MAX}`);\n\t\t\tframeMax = MINIMUM_FRAME_MAX;\n\t\t}\n\t\tparsed.searchParams.set(\"frameMax\", String(frameMax));\n\t\treturn parsed.toString();\n\t} catch {\n\t\treturn urlRaw;\n\t}\n};\n\nconst getConnectSocketOptions = (connectionName: string) => {\n\treturn {\n\t\tnoDelay: true,\n\t\tkeepAlive: true,\n\t\tkeepAliveDelay: parsePositiveInt(process.env.COLABO_FLOW_AMQP_KEEPALIVE_DELAY_MS, 1_000),\n\t\ttimeout: parsePositiveInt(process.env.COLABO_FLOW_AMQP_CONNECT_TIMEOUT_MS, 10_000),\n\t\tclientProperties: {\n\t\t\tconnection_name: connectionName,\n\t\t},\n\t};\n};\n\nconst attachConnectionDebugHandlers = (client: IColaboFlowClientData): void => {\n\tif (!client.connection) return;\n\tclient.connection.on(\"error\", (err: unknown) => {\n\t\tconsole.error(`${client.appNameText} AMQP connection error: ${formatError(err)}`);\n\t});\n\tclient.connection.on(\"close\", () => {\n\t\tconsole.warn(`${client.appNameText} AMQP connection closed`);\n\t});\n\tclient.connection.on(\"blocked\", (reason: unknown) => {\n\t\tconsole.warn(`${client.appNameText} AMQP connection blocked: ${String(reason)}`);\n\t});\n\tclient.connection.on(\"unblocked\", () => {\n\t\tconsole.warn(`${client.appNameText} AMQP connection unblocked`);\n\t});\n\tclient.connection.on(\"frameError\", (err: unknown) => {\n\t\tconsole.error(`${client.appNameText} AMQP frameError: ${formatError(err)}`);\n\t});\n\n\tconst maybeSocket: Socket | undefined = (client.connection as any)?.connection?.stream as Socket | undefined;\n\tif (maybeSocket && isAmqpDebugEnabled()) {\n\t\tmaybeSocket.on(\"error\", (err: unknown) => {\n\t\t\tconsole.error(`${client.appNameText} AMQP socket error: ${formatError(err)}`);\n\t\t});\n\t\tmaybeSocket.on(\"close\", (hadError: boolean) => {\n\t\t\tconsole.warn(`${client.appNameText} AMQP socket close (hadError=${hadError})`);\n\t\t});\n\t\tmaybeSocket.on(\"end\", () => {\n\t\t\tconsole.warn(`${client.appNameText} AMQP socket end`);\n\t\t});\n\t\tmaybeSocket.on(\"timeout\", () => {\n\t\t\tconsole.warn(`${client.appNameText} AMQP socket timeout`);\n\t\t});\n\t}\n};\n\nconst attachChannelDebugHandlers = (client: IColaboFlowClientData): void => {\n\tif (!client.channel) return;\n\tclient.channel.on(\"error\", (err: unknown) => {\n\t\tconsole.error(`${client.appNameText} AMQP channel error: ${formatError(err)}`);\n\t});\n\tclient.channel.on(\"close\", () => {\n\t\tconsole.warn(`${client.appNameText} AMQP channel closed`);\n\t});\n\tclient.channel.on(\"return\", (msg: unknown) => {\n\t\tif (isAmqpDebugEnabled()) {\n\t\t\tconsole.warn(`${client.appNameText} AMQP channel returned a message: ${JSON.stringify(msg)}`);\n\t\t}\n\t});\n\tclient.channel.on(\"drain\", () => {\n\t\tif (isAmqpDebugEnabled()) {\n\t\t\tconsole.log(`${client.appNameText} AMQP channel drain`);\n\t\t}\n\t});\n};\n\nexport const clientRun = async (client: IColaboFlowClientData) => {\n\tprocess.title = `ColaboFlow.Go.Client-${client.clientName}`;\n\tclient.appNameText = `[${chalk.red.bold(\"Colabo\")}${chalk.blue.bold(\"Flow\")}${chalk.green.bold(\".Go\")}-${chalk.green.yellow(client.clientName)}]`;\n\n\tconsole.log(`${client.appNameText} Connecting to the ColaboFlow orchestrator: ${chalk.greenBright(client.amqpUrl)}`);\n\tconst effectiveAmqpUrl = getEffectiveAmqpUrl(client, client.amqpUrl);\n\tif (effectiveAmqpUrl !== client.amqpUrl) {\n\t\tconsole.log(`${client.appNameText} Effective AMQP URL: ${chalk.greenBright(effectiveAmqpUrl)}`);\n\t}\n\tlogAmqpUrlDetails(client, effectiveAmqpUrl);\n\tconst connectionName = `${client.clientName}-pid-${process.pid}`;\n\tconst socketOptions = getConnectSocketOptions(connectionName);\n\tif (isAmqpDebugEnabled()) {\n\t\tconsole.log(`${client.appNameText} AMQP socket options: ${JSON.stringify(socketOptions)}`);\n\t}\n\ttry {\n\t\tclient.connection = await connect(effectiveAmqpUrl, socketOptions);\n\t} catch (err) {\n\t\tconsole.error(`${client.appNameText} Error connecting to the \"${chalk.greenBright(effectiveAmqpUrl)}\" ColaboFlow orchestrator: ${formatError(err)}`);\n\t\tif (isAmqpDebugEnabled() && err instanceof Error && err.stack) {\n\t\t\tconsole.error(`${client.appNameText} connect stack: ${err.stack}`);\n\t\t}\n\t\treturn;\n\t}\n\tattachConnectionDebugHandlers(client);\n\n\ttry {\n\t\tclient.channel = await client.connection.createChannel();\n\t} catch (err) {\n\t\tconsole.error(`${client.appNameText} Error creating the channel: ${formatError(err)}`);\n\t\treturn;\n\t}\n\tattachChannelDebugHandlers(client);\n\n\n\t// console.log(`${client.appNameText} Closing the ${chalk.bold.italic(\"channel\")} to the ColaboFlow orchestrator...`);\n\t// await colaboFlowOrchestratorChannel.close();\n\n\t// console.log(`${client.appNameText} Closing the ${chalk.bold.italic(\"connection\")} to the ColaboFlow orchestrator...`);\n\t// await colaboFlowOrchestrator.close();\n};\n\nexport const clientExecuteTask = async (client: IColaboFlowClientData, taskId: string, taskInput?: any, options?: IClientExecuteTaskOptions): Promise<any> => {\n\tconst promise = new Promise(async (resolve, reject) => {\n\t\tif (!client.channel) {\n\t\t\treject(new Error(`${client.appNameText} Client channel is not initialized. Call clientRun(...) first.`));\n\t\t\treturn;\n\t\t}\n\t\tconst taskExecuteResponseQueue = `client-task_execute_response-${uuidv1()}`;\n\t\tconst msgTaskRequest: IColaboFlowGoMsg = {\n\t\t\t...createGoMsg(client.clientName, EColaboFlowGoMsgType.TASK_EXECUTE_REQUEST),\n\t\t\treplyTo: taskExecuteResponseQueue,\n\t\t\textension: {\n\t\t\t\ttaskId,\n\t\t\t\ttaskInput,\n\t\t\t\toptions,\n\t\t\t} as IColaboFlowGoMsgExtension_TaskExecute_Request,\n\t\t\tmsg: `run a \"${taskId}\" task`,\n\t\t};\n\n\t\tconst msgTaskRequestStr: string = JSON.stringify(msgTaskRequest);\n\t\t// reduce to `responseMaxChars` characters\n\t\tconst responseMaxChars: number = 200;\n\t\tconst msgTaskRequestStrShort: string = msgTaskRequestStr.length > responseMaxChars ? msgTaskRequestStr.substring(0, responseMaxChars/2) + \" [...] \" + msgTaskRequestStr.substring(msgTaskRequestStr.length - responseMaxChars/2) : msgTaskRequestStr;\n\t\n\t\tconsole.log(`${client.appNameText} Sending task request [queue: \"${chalk.blueBright(client.queueOrchestrator)}\"] (reduced to ${responseMaxChars} chars): ${msgTaskRequestStrShort}`);\n\n\t\ttry {\n\t\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\t\tclient.channel.sendToQueue(client.queueOrchestrator, Buffer.from(JSON.stringify(msgTaskRequest)));\n\t\t} catch (err) {\n\t\t\treject(new Error(`${client.appNameText} Failed sending TASK_EXECUTE_REQUEST to \"${client.queueOrchestrator}\": ${formatError(err)}`));\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// https://amqp-node.github.io/amqplib/channel_api.html#channel_assertQueue\n\t\t\tawait client.channel.assertQueue(taskExecuteResponseQueue, {\n\t\t\t\texclusive: true,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\treject(new Error(`${client.appNameText} Failed creating reply queue \"${taskExecuteResponseQueue}\": ${formatError(err)}`));\n\t\t\treturn;\n\t\t}\n\n\t\tclient.channel.consume(\n\t\t\ttaskExecuteResponseQueue,\n\t\t\tfunction (msgOrchestratorRes: any) {\n\t\t\t\tif (!msgOrchestratorRes) {\n\t\t\t\t\treject(new Error(`${client.appNameText} Consumer for \"${taskExecuteResponseQueue}\" cancelled by broker`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet msgOrchestratorResObj: IColaboFlowGoMsg;\n\t\t\t\ttry {\n\t\t\t\t\tmsgOrchestratorResObj = JSON.parse(msgOrchestratorRes.content.toString());\n\n\t\t\t\t\t// console.log(`${client.appNameText} Received: \"${chalk.blueBright(JSON.stringify(msgHostResObj))}\"`);\n\t\t\t\t\t// console.log(`${client.appNameText} msgObj.sender: \"${chalk.blueBright(msgHostResObj.sender)}\", msgObj.type: \"${chalk.blueBright(msgHostResObj.type)}, msgObj.msg: \"${chalk.blueBright(msgHostResObj.msg)}\"`);\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(new Error(`${client.appNameText} Error parsing response message: ${formatError(err)}`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst msgOrchestratorResObjExtension: IColaboFlowGoMsgExtension_TaskExecute_Response = (msgOrchestratorResObj.extension as IColaboFlowGoMsgExtension_TaskExecute_Response);\n\n\t\t\t\tresolve(msgOrchestratorResObjExtension.taskOutput);\n\t\t\t},\n\t\t\t{\n\t\t\t\tnoAck: true,\n\t\t\t}\n\t\t).catch((err) => {\n\t\t\treject(new Error(`${client.appNameText} Failed starting consumer on \"${taskExecuteResponseQueue}\": ${formatError(err)}`));\n\t\t});\n\t});\n\n\treturn promise;\n}\n\nexport const clientClose = async (client: IColaboFlowClientData): Promise<boolean> => {\n\tconst promise: Promise<boolean> = new Promise<boolean>( (resolve, reject) => {\n\t\tsetTimeout(async () => {\n\t\t\tconsole.log(`${client.appNameText} Closing the ${chalk.bold.italic(\"channel\")} to the ColaboFlow orchestrator...`);\n\t\t\ttry {\n\t\t\t\tif(client.channel) {\n\t\t\t\t\tawait client.channel.close();\n\t\t\t\t}\n\n\t\t\t\tconsole.log(`${client.appNameText} Closing the ${chalk.bold.italic(\"connection\")} to the ColaboFlow orchestrator...`);\n\t\t\t\tif(client.connection) {\n\t\t\t\t\tawait client.connection.close();\n\t\t\t\t}\n\n\t\t\t\tresolve(true);\n\t\t\t} catch (err) {\n\t\t\t\treject(new Error(`${client.appNameText} Error while closing client resources: ${formatError(err)}`));\n\t\t\t}\n\n\t\t}, 500);\n\t});\n\n\treturn promise;\n}\n", "// import base64Decode from 'fast-base64-decode'\n// https://github.com/facebook/react-native/blob/main/Libraries/BatchedBridge/NativeModules.js\n// https://github.com/facebook/react-native/blob/main/index.js\n// https://github.com/thenativeweb/uuidv4/issues/127\n// https://www.npmjs.com/package/react-native-get-random-values\n// https://www.reddit.com/r/reactnative/comments/hce4ja/issue_with_uuidv4/\n// https://github.com/expo/expo/tree/main/packages/expo-standard-web-crypto\n// https://github.com/expo/expo/issues/17270\n// https://stackoverflow.com/questions/66377449/how-to-fix-nativemodules-rngetrandomvalues-getrandombase64-error\n\n/**\n * I (@mPrinS) do not want that we depend on `react-native` as a solution for UUID crypto mismatch ...\n * and there is also this erro: `https://github.com/rollup/plugins/issues/1065`\n */\n// const { NativeModules } = require('react-native')\n\n// @mPrinC: Errors like `Duplicate identifier 'TypeMismatchError'.ts(2300)`\n// are due to the built version of the puzzle\n// to be further investigated, but at the moment just delete built version before building/using\nclass TypeMismatchError extends Error {}\nclass QuotaExceededError extends Error {}\n\n// declare const __DEV__;\n//\tfalled back to the __DEV__ unsafe solution, as we need it anyway just for UUID and not a crypto safe context\nconst __DEV__ = true;\n\nlet warned = false\nfunction insecureRandomValues (array) {\n\tif (!warned) {\n\t\t// console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto.getRandomValues')\n\t\tconsole.warn('WARNING: Using an insecure random number generator, as there is no support for crypto.getRandomValues in node native and we do not need it anyway for unique IDs in ColaboFlow messaging identification')\n\t\twarned = true\n\t}\n\n\tfor (let i = 0, r; i < array.length; i++) {\n\t\tif ((i & 0x03) === 0) r = Math.random() * 0x100000000\n\t\tarray[i] = (r >>> ((i & 0x03) << 3)) & 0xff\n\t}\n\n\treturn array\n}\n\n// /**\n//\t* @mPrinC: not sure what exactly it does and there is no online doc or references\n//\t* falled back to the __DEV__ unsafe solution, as we need it anyway just for UUID and not a crypto safe context\n//\t* @param {number} byteLength\n//\t* @returns {string}\n//\t*/\n// function getRandomBase64 (byteLength) {\n//\t if (NativeModules.RNGetRandomValues) {\n//\t\t return NativeModules.RNGetRandomValues.getRandomBase64(byteLength)\n//\t } else if (NativeModules.ExpoRandom) {\n//\t\t // Expo SDK 41-44\n//\t\t return NativeModules.ExpoRandom.getRandomBase64String(byteLength)\n//\t } else if (global.ExpoModules) {\n//\t\t // Expo SDK 45+\n//\t\t return global.ExpoModules.ExpoRandom.getRandomBase64String(byteLength);\n//\t } else {\n//\t\t throw new Error('Native module not found')\n//\t }\n// }\n\n/**\n * @param {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Uint8ClampedArray} array\n */\nfunction getRandomValues (array) {\n\tif (!(array instanceof Int8Array || array instanceof Uint8Array || array instanceof Int16Array || array instanceof Uint16Array || array instanceof Int32Array || array instanceof Uint32Array || array instanceof Uint8ClampedArray)) {\n\t\tthrow new TypeMismatchError('Expected an integer array')\n\t}\n\n\tif (array.byteLength > 65536) {\n\t\tthrow new QuotaExceededError('Can only request a maximum of 65536 bytes')\n\t}\n\n\t// Calling getRandomBase64 in debug mode leads to the error\n\t// \"Calling synchronous methods on native modules is not supported in Chrome\".\n\t// So in that specific case we fall back to just using Math.random.\n\tif (__DEV__) {\n\t\tif (typeof global[\"nativeCallSyncHook\"] === 'undefined') {\n\t\t\treturn insecureRandomValues(array)\n\t\t}\n\t}\n\n\t//\t@mPrinC: removed as no support for getRandomBase64\n\t// import base64Decode(getRandomBase6from byteLength), new Uint8Array(array.buffer, array.byteOffset, arraybyteLength))\n\n\treturn array\n}\n\nif (typeof global.crypto !== 'object') {\n\tglobal.crypto = {} as Crypto;\n}\n\nif (typeof global.crypto.getRandomValues !== 'function') {\n\tglobal.crypto.getRandomValues = getRandomValues\n}\n", "import { EColaboFlowGoMsgType, IColaboFlowGoMsg } from \"./vos\";\n// https://stackoverflow.com/a/62841516/257561\n// import uuidv1 from \"uuid/v1\";\n// it breaks with TS/rollup and anyway it imports `react-native` (?!, too heavy)\n// import \"react-native-get-random-values\"\nimport \"./uuid_fix\"\n\nimport {v1 as uuidv1} from \"uuid\";\nexport {uuidv1};\n\nexport const createGoMsg = (sender: string, type: EColaboFlowGoMsgType): IColaboFlowGoMsg => {\n\tconst msg: IColaboFlowGoMsg = {\n\t\tid: `ColaboFlow-msg:${uuidv1()}`,\n\t\trequestId: `ColaboFlow-request:${uuidv1()}`,\n\t\tsender,\n\t\tproxies: [],\n\t\tmsgReplyChainIds: [],\n\t\ttype,\n\t};\n\n\treturn msg;\n};\n", "// describes types used in the ColaboFlow.GO puzzle\n\nimport { IFlowTask, IFlowTaskInstance, ITaskExecutor } from \"@colabo-flow/i-core\";\n\n// import { ChannelModel, Channel } from \"amqplib/lib/channel_model\";\nimport { Channel } from \"amqplib\";\ntype ChannelModel = any;\n\nexport enum EColaboFlowGoMsgType {\n\tTASK_EXECUTE_REQUEST = \"TASK_EXECUTE_REQUEST\",\n\tTASK_EXECUTE_PROGRESS = \"TASK_EXECUTE_PROGRESS\",\n\tTASK_EXECUTE_RESPONSE = \"TASK_EXECUTE_RESPONSE\",\n\tTASK_INSTANCES_REPORT__REQUEST = \"TASK_INSTANCES_REPORT__REQUEST\",\n\tTASK_INSTANCES_REPORT__RESPONSE = \"TASK_INSTANCES_REPORT__RESPONSE\",\n\tHEARTBEAT = \"HEARTBEAT\",\n}\n\n/** time (in milliseconds) between two heartbeat pulses */\nexport const HEARTBEAT_TIME = 3000;\n\n\n/**\n * An interface describing messages exchanged between ColaboFlow.GO peers\n */\nexport interface IColaboFlowGoMsg {\n\t/** unique message id */\n\tid: string;\n\ttype: EColaboFlowGoMsgType;\n\t/** unique request id, should be kept the same along the course of a same single message exchange */\n\trequestId: string;\n\t/** the id of the message sender */\n\tsender: string;\n\t/** the name of the queue to reply to (if there is a reply to the message) */\n\treplyTo?: string;\n\t/** the list of proxies that forwarded the message */\n\tproxies: string[];\n\t/**\n\t * list of msg ids with the history of the replying messages\n\t */\n\tmsgReplyChainIds: string[];\n\t/** string message that can be used for human purpose mainly */\n\tmsg?: string;\n\n\t/** extension for various types of messages */\n\textension?: any;\n}\n\n/** enumeration of all the languages that are supported by ColaboFlow */\nexport enum EProgrammingLanguageSupported {\n\t/** Javascript or its extensions that will be compiled to JavaScript eventually (TypeScript, Coffeescript) */\n\tJAVASCRIPT = \"JAVASCRIPT\",\n\tPYTHON = \"PYTHON\",\n\tNATIVE = \"NATIVE\",\n}\n/** Message extension for the heartbeat message */\nexport interface IColaboFlowGoMsgExtension_Heartbeat {\n\t/** the id of the heartbeat pulse message */\n\tid: number;\n\t/** the programming language that the host speaks */\n\tlanguage: EProgrammingLanguageSupported;\n\t/** the list of the tasks' ids that the host implements */\n\ttaskIds: string[];\n\t/** The queue that the host listens to */\n\tqueueHost: string;\n}\n\nexport interface IColaboFlowGoMsgExtension_Heartbeat_Response {\n\t/** the id of the heartbeat pulse message */\n\tid: number;\n\t/** the name of the orchestrator responding */\n\torchestratorName: string;\n}\n\n/** Message extension for the task execution request */\nexport interface IColaboFlowGoMsgExtension_TaskExecute_Request {\n\t/** the id of the task we want to execute */\n\ttaskId: string;\n\t/** input to the task we want to execute */\n\ttaskInput: unknown;\n\t/** task execution options */\n\toptions: IClientExecuteTaskOptions,\n}\n\nexport enum ETaskExecute_Progress_Status {\n\tINITIALIZED = \"INITIALIZED\",\n}\n\n/** Message extension for the task execution response */\nexport interface IColaboFlowGoMsgExtension_TaskExecute_Progress {\n\t/** the id if the task executing instance */\n\ttaskInstanceId: string;\n\t/** the current status of the task execution */\n\tstatus: ETaskExecute_Progress_Status;\n\t/** the percentage of the task executed */\n\tprogress: number;\n}\n\n/** Message extension for the task execution response */\nexport interface IColaboFlowGoMsgExtension_TaskExecute_Response {\n\t/** output of the executed task */\n\ttaskOutput: any;\n}\n\n/** Message extension for the task instances report requesting */\nexport interface IColaboFlowGoMsgExtension_TaskInstancesReport_Request {\n\treportFinalizedTaskInstances: boolean;\n\treportRunningTaskInstances: boolean;\n}\n\n/** Message extension for the task instances report response */\nexport interface IColaboFlowGoMsgExtension_TaskInstancesReport_Response {\n\ttasksInstanceInfos: Record<string, IColaboFlowGoTaskInstanceInfo>;\n}\n\n/**\n * Provides all required info about the task execution request and its progress, etc\n */\nexport interface IColaboFlowGoTaskInstanceInfo {\n\t/** taskInstance id */\n\tid: string;\n\t/** task instance */\n\ttaskInstance: IFlowTaskInstance;\n}\n\nexport interface IReportsConfig {\n\t/**\n\t * Should we report ColaboFlow heartbeat messages\n\t * 0 - no, \n\t * n>0 - yes, each n-th message of each identified worker\n \t*/ \n\tshowHeartbeatMsgs: number;\n\tshowReportsMsgs: boolean;\n\tshowExecutionMsgs: boolean;\n}\n\n/** contains all the data that are necessary for a ColaboFlow.Go host to operate */\nexport interface IColaboFlowHostData {\n\t/** reporting config data */\n\treportsConfig: IReportsConfig;\n\n\thostname: string;\n\n\tappNameText?: string;\n\n\tamqpUrl: string;\n\n\tqueueHost: string;\n\tqueueHostHeartbeat: string;\n\n\tconnection?: ChannelModel;\n\tchHostHeartbeat?: Channel;\n\n\ttaskExecutorsAvailable: Record<string, ITaskExecutor>;\n\ttasksAvailable: Record<string, IFlowTask>;\n\ttaskInstances: Record<string, IFlowTaskInstance>;\n\n\t/** Provides all required info about the task execution requests (except the executed ones) coming for this particular host and its progress, etc\n\t * Provides all required info about the task execution request and its progress, etc\n\t * ***record key*** is the `id` of the `taskInstance`\n\t */\n\trunningTaskInstancesInfos: Record<string, IColaboFlowGoTaskInstanceInfo>;\n\n\t/** Provides all required info about the finalized (finished, stopped, failed, ...) task execution requests coming for this particular host and its progress, etc\n\t * Provides all required info about the task execution request and its progress, etc\n\t * ***record key*** is the `id` of the `taskInstance`\n\t */\n\tfinalizedTaskInstancesInfos: Record<string, IColaboFlowGoTaskInstanceInfo>;\n}\n\n/** contains all the data that are necessary for a ColaboFlow.Go client to operate */\nexport interface IColaboFlowClientData {\n\tclientName: string;\n\n\tappNameText?: string;\n\n\tamqpUrl: string;\n\n\tqueueOrchestrator: string;\n\n\tconnection?: ChannelModel;\n\tchannel?: Channel;\n\n\ttaskInstances: Record<string, IFlowTaskInstance>;\n}\n\n/**\n * Options that are provided when requesting task execution from a ColaboFlow client\n */\nexport interface IClientExecuteTaskOptions {\n\t/** host-executing-task related options */\n\thosts: {\n\t\t/** list of hostnames that should be used for the task execution */\n\t\thostNames?: string[],\n\t\t/** if set to true it will run task only if it is implemented on any of the provided hosts in `hostNames` \n\t\t * otherwise it will treat the `hostNames` as recomendations and run on any other available host */\n\t\trunOnlyOnEnlistedHosts?: boolean;\n\t}\n}\n\n/** Contains all the data that are necessary for a ColaboFlow.Go orchestrator to handle a node */\nexport interface IColaboFlowOrchestratorHostData {\n\t/** the name of the host */\n\thostName: string;\n\t/** the name of the queue host listens on */\n\tqueueHost: string;\n\n\t/** tasks' ids available for a specific host */\n\ttaskIdsAvailable: string[];\n\t/** tasks instances' ids available for a specific host */\n\ttaskInstanceIds: string[];\n}\n\n/** contains all the data that are necessary for a ColaboFlow.Go orchestrator to operate */\nexport interface IColaboFlowOrchestratorData {\n\t/** reporting config data */\n\treportsConfig: IReportsConfig;\n\n\torchestratorName: string;\n\n\tamqpUrl: string;\n\n\t/** the heartbeat queue that the orchestrator uses to listens heartbeat (registration) for the hosts */\n\tqueueHostHeartbeat: string;\n\n\t/** the orchestrator queue that the orchestrator uses to listens from the clients */\n\tqueueOrchestrator: string;\n\n\t/** the channel for the clients communication */\n\tclientsChannel?: Channel;\n\n\t/** the channel for the hosts communication */\n\thostsChannel?: Channel;\n\n\t/** infos about each host known to the orchestrator\n\t * currently hosts are discovered by receiving heartbeat messages from the hosts\n\t */\n\thosts: Record<string, IColaboFlowOrchestratorHostData>;\n\n\t/** Provides all required info about the task execution requests (except the executed ones) coming for this particular host and its progress, etc\n\t * Provides all required info about the task execution request and its progress, etc\n\t * ***record key*** is the `id` of the `taskInstance`\n\t */\n\trunningTaskInstancesInfos: Record<string, IColaboFlowGoTaskInstanceInfo>;\n\n\t/** Provides all required info about the finalized (finished, stopped, failed, ...) task execution requests coming for this particular host and its progress, etc\n\t * Provides all required info about the task execution request and its progress, etc\n\t * ***record key*** is the `id` of the `taskInstance`\n\t */\n\tfinalizedTaskInstancesInfos: Record<string, IColaboFlowGoTaskInstanceInfo>;\n\n\thostsForTaskIds: Record<string, string[]>;\n}\n", "/* eslint-disable no-case-declarations */\n// https://www.npmjs.com/package/amqplib\nimport { connect, ConsumeMessage } from \"amqplib\";\nimport { ChannelModel, Channel } from \"amqplib/lib/channel_model\";\nimport chalk from \"chalk\";\nimport { uuidv1 } from \"../operators\";\nimport type { Socket } from \"net\";\n\nimport { createGoMsg } from \"../operators\";\nimport { EColaboFlowGoMsgType, IColaboFlowGoMsg, IColaboFlowGoMsgExtension_TaskExecute_Request, IColaboFlowOrchestratorData, IColaboFlowGoMsgExtension_Heartbeat, IColaboFlowGoMsgExtension_Heartbeat_Response, IColaboFlowOrchestratorHostData, IColaboFlowGoMsgExtension_TaskExecute_Response, IColaboFlowGoMsgExtension_TaskExecute_Progress, HEARTBEAT_TIME } from \"../vos\";\nimport { assert } from \"@colabo-utils/i-verify\";\n\nprocess.title = \"ColaboFlow.Go.Orchestrator\";\nconst appNameText = `[${chalk.red.bold(\"Colabo\")}${chalk.blue.bold(\"Flow\")}${chalk.green.bold(\".Go\")}${chalk.green.yellow(\".Orchestrator\")}]`;\n\nconst isAmqpDebugEnabled = (): boolean => {\n\tconst debugRaw: string = process.env.COLABO_FLOW_AMQP_DEBUG || \"\";\n\treturn debugRaw === \"1\" || debugRaw.toLowerCase() === \"true\";\n};\n\nconst parsePositiveInt = (rawValue: string | undefined, fallback: number): number => {\n\tif (!rawValue) return fallback;\n\tconst parsed = Number.parseInt(rawValue, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n};\n\nconst MINIMUM_FRAME_MAX = 8_192;\n\nconst formatError = (err: unknown): string => {\n\tif (!(err instanceof Error)) return String(err);\n\tconst errorExtended = err as Error & { code?: string; errno?: number | string; syscall?: string; address?: string; port?: number; };\n\tconst meta = [\n\t\terrorExtended.code ? `code=${errorExtended.code}` : \"\",\n\t\terrorExtended.errno !== undefined ? `errno=${errorExtended.errno}` : \"\",\n\t\terrorExtended.syscall ? `syscall=${errorExtended.syscall}` : \"\",\n\t\terrorExtended.address ? `address=${errorExtended.address}` : \"\",\n\t\terrorExtended.port !== undefined ? `port=${errorExtended.port}` : \"\",\n\t].filter(Boolean).join(\", \");\n\treturn meta ? `${err.message} (${meta})` : err.message;\n};\n\nconst logAmqpUrlDetails = (urlRaw: string): void => {\n\ttry {\n\t\tconst parsed = new URL(urlRaw);\n\t\tconst vhostRaw = parsed.pathname || \"/\";\n\t\tconst vhostDecoded = decodeURIComponent(vhostRaw);\n\t\tconst heartbeatQuery = parsed.searchParams.get(\"heartbeat\") || \"(broker default)\";\n\t\tconst frameMaxQuery = parsed.searchParams.get(\"frameMax\") || \"(amqplib default)\";\n\t\tconsole.log(`${appNameText} AMQP URL details: protocol=${parsed.protocol}, host=${parsed.hostname}, port=${parsed.port || \"5672\"}, vhostRaw=\"${vhostRaw}\", vhostDecoded=\"${vhostDecoded}\", heartbeat=${heartbeatQuery}, frameMax=${frameMaxQuery}`);\n\t} catch (err) {\n\t\tconsole.warn(`${appNameText} Could not parse AMQP URL \"${urlRaw}\": ${formatError(err)}`);\n\t}\n};\n\nconst getEffectiveAmqpUrl = (urlRaw: string): string => {\n\ttry {\n\t\tconst parsed = new URL(urlRaw);\n\t\tconst defaultFrameMax = parsePositiveInt(process.env.COLABO_FLOW_AMQP_FRAME_MAX, 131_072);\n\t\tconst frameMaxConfiguredRaw = parsed.searchParams.get(\"frameMax\") || undefined;\n\t\tlet frameMax = parsePositiveInt(frameMaxConfiguredRaw, defaultFrameMax);\n\t\tif (frameMax < MINIMUM_FRAME_MAX) {\n\t\t\tconsole.warn(`${appNameText} frameMax=${frameMax} is too low; forcing frameMax=${MINIMUM_FRAME_MAX}`);\n\t\t\tframeMax = MINIMUM_FRAME_MAX;\n\t\t}\n\t\tparsed.searchParams.set(\"frameMax\", String(frameMax));\n\t\treturn parsed.toString();\n\t} catch {\n\t\treturn urlRaw;\n\t}\n};\n\nconst attachConnectionDebugHandlers = (connection: ChannelModel): void => {\n\tconnection.on(\"error\", (err: unknown) => {\n\t\tconsole.error(`${appNameText} AMQP connection error: ${formatError(err)}`);\n\t});\n\tconnection.on(\"close\", () => {\n\t\tconsole.warn(`${appNameText} AMQP connection closed`);\n\t});\n\tconnection.on(\"blocked\", (reason: unknown) => {\n\t\tconsole.warn(`${appNameText} AMQP connection blocked: ${String(reason)}`);\n\t});\n\tconnection.on(\"unblocked\", () => {\n\t\tconsole.warn(`${appNameText} AMQP connection unblocked`);\n\t});\n\tconnection.on(\"frameError\", (err: unknown) => {\n\t\tconsole.error(`${appNameText} AMQP frameError: ${formatError(err)}`);\n\t});\n\n\tconst maybeSocket: Socket | undefined = (connection as any)?.connection?.stream as Socket | undefined;\n\tif (maybeSocket && isAmqpDebugEnabled()) {\n\t\tmaybeSocket.on(\"error\", (err: unknown) => {\n\t\t\tconsole.error(`${appNameText} AMQP socket error: ${formatError(err)}`);\n\t\t});\n\t\tmaybeSocket.on(\"close\", (hadError: boolean) => {\n\t\t\tconsole.warn(`${appNameText} AMQP socket close (hadError=${hadError})`);\n\t\t});\n\t\tmaybeSocket.on(\"end\", () => {\n\t\t\tconsole.warn(`${appNameText} AMQP socket end`);\n\t\t});\n\t\tmaybeSocket.on(\"timeout\", () => {\n\t\t\tconsole.warn(`${appNameText} AMQP socket timeout`);\n\t\t});\n\t}\n};\n\nconst attachChannelDebugHandlers = (channelName: string, channel: Channel): void => {\n\tchannel.on(\"error\", (err: unknown) => {\n\t\tconsole.error(`${appNameText} AMQP channel \"${channelName}\" error: ${formatError(err)}`);\n\t});\n\tchannel.on(\"close\", () => {\n\t\tconsole.warn(`${appNameText} AMQP channel \"${channelName}\" closed`);\n\t});\n\tchannel.on(\"return\", (msg: unknown) => {\n\t\tif (isAmqpDebugEnabled()) {\n\t\t\tconsole.warn(`${appNameText} AMQP channel \"${channelName}\" returned a message: ${JSON.stringify(msg)}`);\n\t\t}\n\t});\n\tchannel.on(\"drain\", () => {\n\t\tif (isAmqpDebugEnabled()) {\n\t\t\tconsole.log(`${appNameText} AMQP channel \"${channelName}\" drain`);\n\t\t}\n\t});\n};\n\nconst getConnectSocketOptions = (connectionName: string) => {\n\treturn {\n\t\tnoDelay: true,\n\t\tkeepAlive: true,\n\t\tkeepAliveDelay: parsePositiveInt(process.env.COLABO_FLOW_AMQP_KEEPALIVE_DELAY_MS, 1_000),\n\t\ttimeout: parsePositiveInt(process.env.COLABO_FLOW_AMQP_CONNECT_TIMEOUT_MS, 10_000),\n\t\tclientProperties: {\n\t\t\tconnection_name: connectionName,\n\t\t},\n\t};\n};\n\nconst asyncProcessColaboFlowMsg_TaskExecute = async (orchestrator: IColaboFlowOrchestratorData, msgClientReqObj: IColaboFlowGoMsg): Promise<void> => {\n\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\n\t/**\n\t * process the request from a client\n\t * */\n\tconst msgClientReqExtension: IColaboFlowGoMsgExtension_TaskExecute_Request = msgClientReqObj.extension as IColaboFlowGoMsgExtension_TaskExecute_Request;\n\tconst taskId: string = msgClientReqExtension.taskId;\n\n\tconsole.log(`${appNameText} Executing task taskId: \"${chalk.blueBright(taskId)}\"`);\n\t/** the name of the queue that the host should return the task execution result and we should listen in the orchestrator for it */\n\tconst taskExecuteResponseQueue = `orchestrator-task_execute_response-${uuidv1()}`;\n\n\tconst hostsForTaskId: string[] = orchestrator.hostsForTaskIds[taskId];\n\tif (!hostsForTaskId || hostsForTaskId.length <= 0) {\n\t\tconsole.error(`${appNameText} Error, there is no host implementing the task: \"${taskId}\"`);\n\t\t// TODO: return the response\n\t\treturn;\n\t}\n\n\tlet hostName: string | undefined = undefined;\n\tif(msgClientReqExtension?.options?.hosts?.hostNames) {\n\t\tconsole.info(`${appNameText} Client requested for the task \"${taskId}\" to be executed across one of the following hostNames: ${msgClientReqExtension?.options?.hosts?.hostNames}.`);\n\t\tfor(const hostNameTemp of msgClientReqExtension.options.hosts.hostNames){\n\t\t\tif(hostsForTaskId.indexOf(hostNameTemp) >= 0) {\n\t\t\t\thostName = hostNameTemp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(!hostName) {\n\t\t\tif(msgClientReqExtension.options.hosts.runOnlyOnEnlistedHosts) {\n\t\t\t\tconsole.error(`${appNameText} Error, there is no host implementing the task: \"${taskId}\" that matches the requested hosts hostNames: ${msgClientReqExtension.options.hosts.hostNames}`);\n\t\t\t\t// TODO: return the response\n\t\t\t\treturn;\t\n\t\t\t} else {\n\t\t\t\t// TODO: initially a simple assumption of a single host implementing the task\n\t\t\t\thostName = hostsForTaskId[0];\n\n\t\t\t\tconsole.info(`${appNameText} There is no host implementing the task: \"${taskId}\" that matches the requested hosts hostNames: ${msgClientReqExtension.options.hosts.hostNames}. Instead using the first availabile host: ${hostName}`);\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.info(`${appNameText} We found the host implementing the task: \"${taskId}\" that matches the requested hosts hostNames: ${hostName}.`);\n\t\t}\n\t} else {\n\t\t// TODO: initially a simple assumption of a single host implementing the task\n\t\thostName = hostsForTaskId[0];\n\t\tconsole.info(`${appNameText} There are no preferences for a host implementing the task: \"${taskId}\" Using the first available host: ${hostName}.`);\n\t}\n\n\tconst hostData: IColaboFlowOrchestratorHostData = orchestrator.hosts[hostName];\n\n\tconsole.log(`${appNameText} Delivering the task \"${chalk.blueBright(taskId)}\" to host \"${chalk.blueBright(hostName)}\" via queue \"${chalk.blueBright(hostData.queueHost)}\" and listening for the response on the queue: \"${chalk.blueBright(taskExecuteResponseQueue)}\"`);\n\n\t/**\n\t * send the request to the host\n\t * */\n\tconst msgHostObjRequest: IColaboFlowGoMsg = {\n\t\t...createGoMsg(orchestrator.orchestratorName, EColaboFlowGoMsgType.TASK_EXECUTE_REQUEST),\n\t\treplyTo: taskExecuteResponseQueue,\n\t\textension: msgClientReqExtension as IColaboFlowGoMsgExtension_TaskExecute_Request,\n\t\tmsg: msgClientReqObj.msg,\n\t};\n\n\tconsole.log(`${appNameText} Creating the task execution response queue: \"${chalk.blueBright(taskExecuteResponseQueue)}\" ...`);\n\t/**\n\t * listen for the response from the host\n\t * */\n\t// https://amqp-node.github.io/amqplib/channel_api.html#channel_assertQueue\n\tawait orchestrator.hostsChannel.assertQueue(taskExecuteResponseQueue, {\n\t\texclusive: true,\n\t});\n\t// NOTE: very important to send the message AFTER activating listener (consumer) on the listening `taskExecuteResponseQueue` queue as otherwise the response from the host could have arrived back BEFORE the listener (consumer) is activated. This was a REAL rat-racing issue!!! (probably due to the long time with handshaking and enabling a new `taskExecuteResponseQueue` with RabbitMQ)\n\torchestrator.hostsChannel.consume(\n\t\ttaskExecuteResponseQueue,\n\t\tfunction (msgHostRes: ConsumeMessage | null) {\n\t\t\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\t\t\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\n\t\t\tconsole.log(`${appNameText} Task Execution reply on the queue: \"${chalk.blueBright(taskExecuteResponseQueue)}\" for the taskId: \"${chalk.blueBright(taskId)}\"`);\n\t\t\tassert(msgHostRes, `msgHostRes is not defined`);\n\t\t\tlet msgHostResObj: IColaboFlowGoMsg;\n\t\t\ttry {\n\t\t\t\tmsgHostResObj = JSON.parse(msgHostRes.content.toString());\n\n\t\t\t\t// console.log(`${appNameText} Received: \"${chalk.blueBright(JSON.stringify(msgHostResObj))}\"`);\n\t\t\t\t// console.log(`${appNameText} msgObj.sender: \"${chalk.blueBright(msgHostResObj.sender)}\", msgObj.type: \"${chalk.blueBright(msgHostResObj.type)}, msgObj.msg: \"${chalk.blueBright(msgHostResObj.msg)}\"`);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`${appNameText} Error parsing host response message: ${formatError(err)} | raw=${msgHostRes.content.toString()}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tswitch (msgHostResObj.type) {\n\t\t\t\tcase EColaboFlowGoMsgType.TASK_EXECUTE_PROGRESS:\n\t\t\t\t\tconst msgHostProgressObjExtension: IColaboFlowGoMsgExtension_TaskExecute_Progress = msgHostResObj.extension as IColaboFlowGoMsgExtension_TaskExecute_Progress;\n\t\t\t\t\tconsole.log(`${appNameText} Task Execution PROGRESS: ${JSON.stringify(msgHostProgressObjExtension)}`);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase EColaboFlowGoMsgType.TASK_EXECUTE_RESPONSE:\n\t\t\t\t\tconst msgHostResObjExtension: IColaboFlowGoMsgExtension_TaskExecute_Response = msgHostResObj.extension as IColaboFlowGoMsgExtension_TaskExecute_Response;\n\n\n\t\t\t\t\tconst executionResponse: string = JSON.stringify(msgHostResObjExtension.taskOutput);\n\t\t\t\t\t// reduce to `responseMaxChars` characters\n\t\t\t\t\tconst responseMaxChars: number = 200;\n\t\t\t\t\tconst executionResponseShort: string = executionResponse.length > responseMaxChars ? executionResponse.substring(0, responseMaxChars/2) + \" [...] \" + executionResponse.substring(executionResponse.length - responseMaxChars/2) : executionResponse;\n\t\t\t\t\tconsole.log(`${appNameText} Task Execution RESPONSE (reduced to ${responseMaxChars} chars): ${executionResponseShort}`);\n\n\t\t\t\t\tif (!msgClientReqObj.replyTo) {\n\t\t\t\t\t\tconsole.error(`${appNameText} replyTo is missing in the msgClientReqObj [msgClientReqObj.id: \"${chalk.blueBright(msgClientReqObj.id)}\"]`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst queueReplyTo: string = msgClientReqObj.replyTo;\n\t\t\t\t\tconst msgClientRes: IColaboFlowGoMsg = {\n\t\t\t\t\t\t...createGoMsg(orchestrator.orchestratorName, EColaboFlowGoMsgType.TASK_EXECUTE_RESPONSE),\n\t\t\t\t\t\trequestId: msgClientReqObj.requestId,\n\t\t\t\t\t\tmsgReplyChainIds: [msgClientReqObj.id],\n\t\t\t\t\t\textension: msgHostResObjExtension,\n\t\t\t\t\t\tmsg: `Host with tasks`,\n\t\t\t\t\t};\n\t\t\t\t\tconsole.log(`${appNameText} Sending the task Execution response back to the client \"${chalk.blueBright(msgClientReqObj.sender)}\" through queue: \"${chalk.blueBright(queueReplyTo)}\"`);\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\t\t\t\t\torchestrator.clientsChannel.sendToQueue(queueReplyTo, Buffer.from(JSON.stringify(msgClientRes)));\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(`${appNameText} Failed to send TASK_EXECUTE_RESPONSE to client queue \"${queueReplyTo}\": ${formatError(err)}`);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// no need due to `noAck: true,`\n\t\t\t// orchestrator.hostsChannel.ack(msgHostRes);\n\t\t},\n\t\t{\n\t\t\t// check if it is good to have it\n\t\t\tnoAck: true,\n\t\t}\n\t);\n\n\tconsole.log(`${appNameText} Listening on the queue: \"${chalk.blueBright(taskExecuteResponseQueue)}\" for the execution response for the task \"${chalk.blueBright(taskId)}\"`);\n\n\ttry {\n\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\t// NOTE: very important to send the message AFTER activating listener (consumer) on the listening `taskExecuteResponseQueue` queue as otherwise the response from the host could have arrived back BEFORE the listener (consumer) is activated. This was a REAL rat-racing issue!!! (probably due to the long time with handshaking and enabling a new `taskExecuteResponseQueue` with RabbitMQ)\n\t\torchestrator.hostsChannel.sendToQueue(hostData.queueHost, Buffer.from(JSON.stringify(msgHostObjRequest)));\n\t} catch (err) {\n\t\tconsole.error(`${appNameText} Failed to send TASK_EXECUTE_REQUEST to host queue \"${hostData.queueHost}\": ${formatError(err)}`);\n\t}\n};\n\nconst asyncProcessColaboFlowMsg_Heartbeat = async (orchestrator: IColaboFlowOrchestratorData, msgObj: IColaboFlowGoMsg): Promise<void> => {\n\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\n\tconst msgExtension: IColaboFlowGoMsgExtension_Heartbeat = msgObj.extension as IColaboFlowGoMsgExtension_Heartbeat;\n\n\tconst hostName: string = msgObj.sender;\n\t// console.log(`${appNameText} [processColaboFlowMsg_TaskExecute] Executing id: ${chalk.blueBright(taskId)}, task.description: ${task.description}`);\n\n\t// we got a new host\n\tif (!(hostName in orchestrator.hosts)) {\n\t\tconsole.log(`${appNameText} Discovered a new host: \"${chalk.blueBright(hostName)}\" with the tasks available: ${chalk.blueBright(JSON.stringify(msgExtension.taskIds))}`);\n\t\torchestrator.hosts[hostName] = {\n\t\t\thostName,\n\t\t\tqueueHost: msgExtension.queueHost,\n\t\t\t// we make it empty as we want to populate it properly in the next section\n\t\t\ttaskIdsAvailable: [],\n\t\t\ttaskInstanceIds: [],\n\t\t};\n\t}\n\n\tconst hostData: IColaboFlowOrchestratorHostData = orchestrator.hosts[hostName];\n\n\t/****************************************** \n\t * HANDLING CHANGES IN THE HOST TASKS \n\t ******************************************/\n\t/** the list of tasks that are removed compared to the previous heartbeat */\n\tconst tasksRemoved: string[] = hostData.taskIdsAvailable.filter((newTaskId: string) => msgExtension.taskIds.indexOf(newTaskId) < 0);\n\tif(tasksRemoved.length) console.log(`${appNameText} The host: \"${chalk.blueBright(hostName)}\" doesn't offers anymore the following tasks: ${chalk.blueBright(JSON.stringify(tasksRemoved))}`);\n\t// remove tasks from `orchestrator.hostsForTaskIds`\n\tfor (const taskId of tasksRemoved) {\n\t\tconst hostsForTheTaskId: string[] = orchestrator.hostsForTaskIds[taskId];\n\t\tif(!Array.isArray(hostsForTheTaskId)) return;\n\t\tvar hostIndex = hostsForTheTaskId.indexOf(hostName);\n\t\tif (hostIndex !== -1) {\n\t\t\thostsForTheTaskId.splice(hostIndex, 1);\n\t\t}\n\t}\n\n\t/** the list of tasks that are added compared to the previous heartbeat */\n\tconst tasksAdded: string[] = msgExtension.taskIds.filter((newTaskId: string) => hostData.taskIdsAvailable.indexOf(newTaskId) < 0);\n\tif(tasksAdded.length) console.log(`${appNameText} The host: \"${chalk.blueBright(hostName)}\" offers now the additional tasks: ${chalk.blueBright(JSON.stringify(tasksAdded))}`);\n\t// update the available tasks on each heartbeat as they can evolve\n\thostData.taskIdsAvailable = msgExtension.taskIds;\n\t// add tasks to `orchestrator.hostsForTaskIds`\n\tfor (const taskId of tasksAdded) {\n\t\t// a completely new task (not served by any of the known hosts)\n\t\tif (!orchestrator.hostsForTaskIds[taskId]) orchestrator.hostsForTaskIds[taskId] = [];\n\t\t// if the host is not among the \"known\" hosts serving the task, add it\n\t\tif (orchestrator.hostsForTaskIds[taskId].indexOf(hostName) < 0) {\n\t\t\torchestrator.hostsForTaskIds[taskId].push(hostName);\n\t\t}\n\t}\n\n\tif (orchestrator.reportsConfig.showHeartbeatMsgs && ((msgExtension.id % orchestrator.reportsConfig.showHeartbeatMsgs) == 0)) {\n\t\tconsole.log(`${appNameText} Received heartbeat: hostName: \"${chalk.blueBright(hostName)}\", id: ${msgExtension.id}`);\n\t\t// console.log(`${appNameText} Received heartbeat: \"${chalk.blueBright(JSON.stringify(msgObj))}\"`);\n\t\t// console.log(`${appNameText} [${msgObj.id}] hostName: \"${chalk.blueBright(hostName)}\", msgObj.type: \"${chalk.blueBright(msgObj.type)}, msgExtension.language: \"${chalk.blueBright(msgExtension.language)}, msgExtension.tasks: \"${chalk.blueBright(msgExtension.taskIds.toString())}, msgObj.msg: \"${chalk.blueBright(msgObj.msg)}\"`);\n\t}\n\n\t// TODO: Send heartbeat reply\n\t// We want the host know that we (orchestrator) are there listening\n\t// const msgHeartbeatReply: IColaboFlowGoMsg = {\n\t// \t...createGoMsg(orchestrator.orchestratorName, EColaboFlowGoMsgType.TASK_INSTANCES_REPORT__RESPONSE),\n\t// \trequestId: msgObj.requestId,\n\t// \tmsgReplyChainIds: [msgObj.id],\n\t// \textension: {\n\t// \t\tid: msgExtension.id,\n\t// \t\torchestratorName: orchestrator.orchestratorName,\n\t// \t} as IColaboFlowGoMsgExtension_Heartbeat_Response,\n\t// \tmsg: `\"${orchestrator.orchestratorName}\" orchestrator received the heartbeat from the \"${hostName}\" host`,\n\t// };\n\n\t// const queueReplyTo: string = msgObj.replyTo ?? \"\";\n\t// if (reportsConfig.showReportsMsgs) {\n\t// \tconsole.log(`${appNameText} Sending response to the task instances report [queue: \"${chalk.blueBright(queueReplyTo)}\"]: ${JSON.stringify(msgHeartbeatReply)}`);\n\t// }\n\t// // https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t// orchestrator.orchestrator.hostsChannel.sendToQueue(queueReplyTo, Buffer.from(JSON.stringify(msgHeartbeatReply)));\n};\n\nconst listenOnClientRequests = async (orchestrator: IColaboFlowOrchestratorData): Promise<void> => {\n\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\n\t// Orchestrator (tasks) Listener\n\tconsole.log(`${appNameText} Listening on the orchestrator queue: \"${chalk.blueBright(orchestrator.queueOrchestrator)}\"`);\n\tconsole.log(`${appNameText} [*] Waiting for orchestrator messages. To exit press \"${chalk.blueBright(\"CTRL+C\")}\"`);\n\torchestrator.clientsChannel.consume(orchestrator.queueOrchestrator, (msg) => {\n\t\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\t\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\n\t\tif (msg !== null) {\n\t\t\tlet msgObj: IColaboFlowGoMsg;\n\t\t\ttry {\n\t\t\t\tmsgObj = JSON.parse(msg.content.toString());\n\n\t\t\t\t// console.log(`${appNameText} Received: \"${chalk.blueBright(JSON.stringify(msgObj))}\"`);\n\t\t\t\tconsole.log(`${appNameText} msgObj.sender: \"${chalk.blueBright(msgObj.sender)}\", msgObj.msg: \"${chalk.blueBright(msgObj.msg)}\"`);\n\n\t\t\t\tswitch (msgObj.type) {\n\t\t\t\t\tcase EColaboFlowGoMsgType.TASK_EXECUTE_REQUEST:\n\t\t\t\t\t\tvoid asyncProcessColaboFlowMsg_TaskExecute(orchestrator, msgObj).catch((err) => {\n\t\t\t\t\t\t\tconsole.error(`${appNameText} Error while processing TASK_EXECUTE_REQUEST: ${formatError(err)}`);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`${appNameText} Error parsing client message: ${formatError(err)} | raw=${msg.content.toString()}`);\n\t\t\t}\n\t\t\torchestrator.clientsChannel.ack(msg);\n\t\t} else {\n\t\t\tconsole.log(\"${appNameText} Consumer cancelled by server\");\n\t\t}\n\t});\n};\n\nconst listenOnHeartbeatMessages = async (orchestrator: IColaboFlowOrchestratorData): Promise<void> => {\n\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\torchestrator.clientsChannel.ackAll();\n\n\t// Heartbeat Listener\n\tconsole.log(`${appNameText} Listening on the heartbeat queue: \"${chalk.blueBright(orchestrator.queueHostHeartbeat)}\"`);\n\tconsole.log(`${appNameText} [*] Waiting for heartbeat messages. To exit press \"${chalk.blueBright(\"CTRL+C\")}\"`);\n\torchestrator.clientsChannel.consume(orchestrator.queueHostHeartbeat, (msg) => {\n\t\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\t\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\t\tif (msg !== null) {\n\t\t\tlet msgObj: IColaboFlowGoMsg;\n\t\t\ttry {\n\t\t\t\t// console.log(`${appNameText} msgHostRes.content: ${msg.content}`);\n\t\t\t\tmsgObj = JSON.parse(msg.content.toString());\n\n\t\t\t\tswitch (msgObj.type) {\n\t\t\t\t\tcase EColaboFlowGoMsgType.HEARTBEAT:\n\t\t\t\t\t\tvoid asyncProcessColaboFlowMsg_Heartbeat(orchestrator, msgObj).catch((err) => {\n\t\t\t\t\t\t\tconsole.error(`${appNameText} Error while processing HEARTBEAT: ${formatError(err)}`);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`${appNameText} Error parsing heartbeat message: ${formatError(err)} | raw=${msg.content.toString()}`);\n\t\t\t}\n\t\t\torchestrator.clientsChannel.ack(msg);\n\t\t} else {\n\t\t\tconsole.log(\"${appNameText} Consumer cancelled by server\");\n\t\t}\n\t});\n};\n\nexport const orchestratorRun = async (orchestrator: IColaboFlowOrchestratorData): Promise<void> => {\n\tconsole.log(`${appNameText} Connecting to the server: ${chalk.greenBright(orchestrator.amqpUrl)}`);\n\tconst effectiveAmqpUrl = getEffectiveAmqpUrl(orchestrator.amqpUrl);\n\tif (effectiveAmqpUrl !== orchestrator.amqpUrl) {\n\t\tconsole.log(`${appNameText} Effective AMQP URL: ${chalk.greenBright(effectiveAmqpUrl)}`);\n\t}\n\tlogAmqpUrlDetails(effectiveAmqpUrl);\n\tlet colaboFlowOrchestratorConnection: ChannelModel;\n\tconst connectionName = `${orchestrator.orchestratorName}-pid-${process.pid}`;\n\tconst socketOptions = getConnectSocketOptions(connectionName);\n\tif (isAmqpDebugEnabled()) {\n\t\tconsole.log(`${appNameText} AMQP socket options: ${JSON.stringify(socketOptions)}`);\n\t}\n\ttry {\n\t\tcolaboFlowOrchestratorConnection = await connect(effectiveAmqpUrl, socketOptions);\n\t} catch (err) {\n\t\tconsole.error(`Error connecting to the \"${chalk.greenBright(effectiveAmqpUrl)}\" server: ${formatError(err)}`);\n\t\tif (isAmqpDebugEnabled() && err instanceof Error && err.stack) {\n\t\t\tconsole.error(`${appNameText} connect stack: ${err.stack}`);\n\t\t}\n\t\treturn;\n\t}\n\tattachConnectionDebugHandlers(colaboFlowOrchestratorConnection);\n\n\tconsole.log(`${appNameText} Opening the ${chalk.bold.italic(\"clients\")} channel`);\n\ttry {\n\t\torchestrator.clientsChannel = await colaboFlowOrchestratorConnection.createChannel();\n\t} catch (err) {\n\t\tconsole.error(`Error creating the ${chalk.greenBright(\"clients\")} queue: ${formatError(err)}`);\n\t\treturn;\n\t}\n\tattachChannelDebugHandlers(\"clients\", orchestrator.clientsChannel);\n\tconsole.log(`${appNameText} Opening the ${chalk.bold.italic(\"hosts\")} channel`);\n\ttry {\n\t\torchestrator.hostsChannel = await colaboFlowOrchestratorConnection.createChannel();\n\t} catch (err) {\n\t\tconsole.error(`Error creating the ${chalk.greenBright(\"hosts\")} queue: ${formatError(err)}`);\n\t\treturn;\n\t}\n\tattachChannelDebugHandlers(\"hosts\", orchestrator.hostsChannel);\n\tassert(orchestrator.hostsChannel, `orchestrator.hostsChannel is not defined`);\n\tassert(orchestrator.clientsChannel, `orchestrator.clientsChannel is not defined`);\n\n\tconsole.log(`${appNameText} Opening the ${chalk.bold.italic(\"orchestrator\")} queue as a listener: ${chalk.greenBright(orchestrator.queueOrchestrator)}`);\n\t// https://amqp-node.github.io/amqplib/channel_api.html#channel_assertQueue\n\tawait orchestrator.clientsChannel.assertQueue(orchestrator.queueOrchestrator, {\n\t\tdurable: true,\n\t\texclusive: false,\n\t\tautoDelete: false,\n\t});\n\n\tconsole.log(`${appNameText} Opening the ${chalk.bold.italic(\"heartbeat\")} queue as a listener: ${chalk.greenBright(orchestrator.queueHostHeartbeat)}`);\n\t// https://amqp-node.github.io/amqplib/channel_api.html#channel_assertQueue\n\tawait orchestrator.hostsChannel.assertQueue(orchestrator.queueHostHeartbeat, {\n\t\tdurable: true,\n\t\texclusive: false,\n\t\tautoDelete: false,\n\t});\n\n\tconsole.log(`${appNameText} ${chalk.blueBright(\"Delaying\")} listening on clients to give time for hosts to register (to avoid task execution request errors due to no hosts that implement tasks (executors)) )`);\n\tsetTimeout(() => listenOnClientRequests(orchestrator), 2 * HEARTBEAT_TIME);\n\n\tlistenOnHeartbeatMessages(orchestrator);\n};\n", "// https://www.npmjs.com/package/amqplib\nimport { connect } from \"amqplib\";\n// import { ChannelModel, Channel } from \"amqplib/lib/channel_model\";\nimport { Channel } from \"amqplib\";\ntype ChannelModel = any;\nimport type { Socket } from \"net\";\n// import {chalk} from \"../tests/units/chalk\";\nimport chalk from \"chalk\";\n// https://stackoverflow.com/a/62841516/257561\n// import uuidv1 from \"uuid/v1\";\nimport { uuidv1 } from \"../operators\";\n\nimport { EExecutingEnvironment, EFlowPlaceType, EFlowTaskType, IFlowTask, IFlowTaskInstance, ITaskExecutor } from \"@colabo-flow/i-core\";\n\nimport { createTaskInstanceForTaskWithoutFlow } from \"@colabo-flow/i-core\";\n\nimport { EColaboFlowGoMsgType, EProgrammingLanguageSupported, ETaskExecute_Progress_Status, HEARTBEAT_TIME, IColaboFlowGoMsg, IColaboFlowGoMsgExtension_Heartbeat, IColaboFlowGoMsgExtension_TaskExecute_Progress, IColaboFlowGoMsgExtension_TaskExecute_Request, IColaboFlowGoMsgExtension_TaskExecute_Response, IColaboFlowGoMsgExtension_TaskInstancesReport_Request, IColaboFlowGoMsgExtension_TaskInstancesReport_Response, IColaboFlowGoTaskInstanceInfo, IColaboFlowHostData } from \"../vos\";\nimport { createGoMsg } from \"../operators\";\nimport { addOmnipresentTasks } from \"./omnipresentTasks\";\nimport { THostRegisterTaskExecutor } from \"./vos\";\n\nconst LANGUAGE = EProgrammingLanguageSupported.JAVASCRIPT;\nconst MINIMUM_FRAME_MAX = 8_192;\n\nconst isAmqpDebugEnabled = (): boolean => {\n\tconst debugRaw: string = process.env.COLABO_FLOW_AMQP_DEBUG || \"\";\n\treturn debugRaw === \"1\" || debugRaw.toLowerCase() === \"true\";\n};\n\nconst parsePositiveInt = (rawValue: string | undefined, fallback: number): number => {\n\tif (!rawValue) return fallback;\n\tconst parsed = Number.parseInt(rawValue, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n};\n\nconst formatError = (err: unknown): string => {\n\tif (!(err instanceof Error)) return String(err);\n\tconst errorExtended = err as Error & { code?: string; errno?: number | string; syscall?: string; address?: string; port?: number; };\n\tconst meta = [\n\t\terrorExtended.code ? `code=${errorExtended.code}` : \"\",\n\t\terrorExtended.errno !== undefined ? `errno=${errorExtended.errno}` : \"\",\n\t\terrorExtended.syscall ? `syscall=${errorExtended.syscall}` : \"\",\n\t\terrorExtended.address ? `address=${errorExtended.address}` : \"\",\n\t\terrorExtended.port !== undefined ? `port=${errorExtended.port}` : \"\",\n\t].filter(Boolean).join(\", \");\n\tconst msg = meta ? `${err.message} (${meta})` : err.message;\n\treturn err.stack ? `${msg}\\n${err.stack}` : msg;\n};\n\nconst logAmqpUrlDetails = (host: IColaboFlowHostData, urlRaw: string): void => {\n\ttry {\n\t\tconst parsed = new URL(urlRaw);\n\t\tconst vhostRaw = parsed.pathname || \"/\";\n\t\tconst vhostDecoded = decodeURIComponent(vhostRaw);\n\t\tconst heartbeatQuery = parsed.searchParams.get(\"heartbeat\") || \"(broker default)\";\n\t\tconst frameMaxQuery = parsed.searchParams.get(\"frameMax\") || \"(amqplib default)\";\n\t\tconsole.log(`${host.appNameText} AMQP URL details: protocol=${parsed.protocol}, host=${parsed.hostname}, port=${parsed.port || \"5672\"}, vhostRaw=\"${vhostRaw}\", vhostDecoded=\"${vhostDecoded}\", heartbeat=${heartbeatQuery}, frameMax=${frameMaxQuery}`);\n\t} catch (err) {\n\t\tconsole.warn(`${host.appNameText} Could not parse AMQP URL \"${urlRaw}\": ${formatError(err)}`);\n\t}\n};\n\nconst getEffectiveAmqpUrl = (host: IColaboFlowHostData, urlRaw: string): string => {\n\ttry {\n\t\tconst parsed = new URL(urlRaw);\n\t\tconst defaultFrameMax = parsePositiveInt(process.env.COLABO_FLOW_AMQP_FRAME_MAX, 131_072);\n\t\tconst frameMaxConfiguredRaw = parsed.searchParams.get(\"frameMax\") || undefined;\n\t\tlet frameMax = parsePositiveInt(frameMaxConfiguredRaw, defaultFrameMax);\n\t\tif (frameMax < MINIMUM_FRAME_MAX) {\n\t\t\tconsole.warn(`${host.appNameText} frameMax=${frameMax} is too low; forcing frameMax=${MINIMUM_FRAME_MAX}`);\n\t\t\tframeMax = MINIMUM_FRAME_MAX;\n\t\t}\n\t\tparsed.searchParams.set(\"frameMax\", String(frameMax));\n\t\treturn parsed.toString();\n\t} catch {\n\t\treturn urlRaw;\n\t}\n};\n\nconst getConnectSocketOptions = (connectionName: string) => {\n\treturn {\n\t\tnoDelay: true,\n\t\tkeepAlive: true,\n\t\tkeepAliveDelay: parsePositiveInt(process.env.COLABO_FLOW_AMQP_KEEPALIVE_DELAY_MS, 1_000),\n\t\ttimeout: parsePositiveInt(process.env.COLABO_FLOW_AMQP_CONNECT_TIMEOUT_MS, 10_000),\n\t\tclientProperties: {\n\t\t\tconnection_name: connectionName,\n\t\t},\n\t};\n};\n\nconst attachConnectionDebugHandlers = (host: IColaboFlowHostData, connection: ChannelModel): void => {\n\tconnection.on(\"error\", (err: unknown) => {\n\t\tconsole.error(`${host.appNameText} AMQP connection error: ${formatError(err)}`);\n\t});\n\tconnection.on(\"close\", () => {\n\t\tconsole.warn(`${host.appNameText} AMQP connection closed`);\n\t});\n\tconnection.on(\"blocked\", (reason: unknown) => {\n\t\tconsole.warn(`${host.appNameText} AMQP connection blocked: ${String(reason)}`);\n\t});\n\tconnection.on(\"unblocked\", () => {\n\t\tconsole.warn(`${host.appNameText} AMQP connection unblocked`);\n\t});\n\tconnection.on(\"frameError\", (err: unknown) => {\n\t\tconsole.error(`${host.appNameText} AMQP frameError: ${formatError(err)}`);\n\t});\n\n\tconst maybeSocket: Socket | undefined = (connection as any)?.connection?.stream as Socket | undefined;\n\tif (maybeSocket && isAmqpDebugEnabled()) {\n\t\tmaybeSocket.on(\"error\", (err: unknown) => {\n\t\t\tconsole.error(`${host.appNameText} AMQP socket error: ${formatError(err)}`);\n\t\t});\n\t\tmaybeSocket.on(\"close\", (hadError: boolean) => {\n\t\t\tconsole.warn(`${host.appNameText} AMQP socket close (hadError=${hadError})`);\n\t\t});\n\t\tmaybeSocket.on(\"end\", () => {\n\t\t\tconsole.warn(`${host.appNameText} AMQP socket end`);\n\t\t});\n\t\tmaybeSocket.on(\"timeout\", () => {\n\t\t\tconsole.warn(`${host.appNameText} AMQP socket timeout`);\n\t\t});\n\t}\n};\n\nconst attachChannelDebugHandlers = (host: IColaboFlowHostData, channelName: string, channel: Channel): void => {\n\tchannel.on(\"error\", (err: unknown) => {\n\t\tconsole.error(`${host.appNameText} AMQP channel \"${channelName}\" error: ${formatError(err)}`);\n\t});\n\tchannel.on(\"close\", () => {\n\t\tconsole.warn(`${host.appNameText} AMQP channel \"${channelName}\" closed`);\n\t});\n\tchannel.on(\"return\", (msg: unknown) => {\n\t\tif (isAmqpDebugEnabled()) {\n\t\t\tconsole.warn(`${host.appNameText} AMQP channel \"${channelName}\" returned a message: ${JSON.stringify(msg)}`);\n\t\t}\n\t});\n\tchannel.on(\"drain\", () => {\n\t\tif (isAmqpDebugEnabled()) {\n\t\t\tconsole.log(`${host.appNameText} AMQP channel \"${channelName}\" drain`);\n\t\t}\n\t});\n};\n\nexport const hostSetTitles = (host: IColaboFlowHostData): void => {\n\tprocess.title = `ColaboFlow.Go-${host.hostname}`;\n\thost.appNameText = `[${chalk.red.bold(\"Colabo\")}${chalk.blue.bold(\"Flow\")}${chalk.green.bold(\".Go\")}-${chalk.green.yellow(host.hostname)}]`;\n\t// console.log(`${host.appNameText} title is set`);\n};\n\nexport const hostRegisterTaskExecutor: THostRegisterTaskExecutor = (host: IColaboFlowHostData, executor: ITaskExecutor): void => {\n\tconsole.log(`${host.appNameText} Registering task executor, executor.id \"${chalk.greenBright(executor.id)}\"`);\n\thost.taskExecutorsAvailable[executor.id] = executor;\n};\n\nconst getTaskExecutor = (host: IColaboFlowHostData, executorId: string): ITaskExecutor => {\n\treturn host.taskExecutorsAvailable[executorId];\n};\n\nexport const hostRegisterTask = (host: IColaboFlowHostData, task: IFlowTask): void => {\n\thost.tasksAvailable[task.id] = task;\n\tconsole.log(`${host.appNameText} Registered task with task.id \"${chalk.greenBright(task.id)}\"`);\n};\n\nconst connectToServer = async (host: IColaboFlowHostData): Promise<ChannelModel> => {\n\tconsole.log(`${host.appNameText} Connecting to the server: ${chalk.greenBright(host.amqpUrl)}`);\n\tconst effectiveAmqpUrl = getEffectiveAmqpUrl(host, host.amqpUrl);\n\tif (effectiveAmqpUrl !== host.amqpUrl) {\n\t\tconsole.log(`${host.appNameText} Effective AMQP URL: ${chalk.greenBright(effectiveAmqpUrl)}`);\n\t}\n\tlogAmqpUrlDetails(host, effectiveAmqpUrl);\n\tlet colaboFlowOrchestratorConnection: ChannelModel;\n\tconst connectionName = `${host.hostname}-pid-${process.pid}`;\n\tconst socketOptions = getConnectSocketOptions(connectionName);\n\tif (isAmqpDebugEnabled()) {\n\t\tconsole.log(`${host.appNameText} AMQP socket options: ${JSON.stringify(socketOptions)}`);\n\t}\n\ttry {\n\t\tcolaboFlowOrchestratorConnection = await connect(effectiveAmqpUrl, socketOptions);\n\t\thost.connection = colaboFlowOrchestratorConnection;\n\t\tattachConnectionDebugHandlers(host, colaboFlowOrchestratorConnection);\n\t\treturn colaboFlowOrchestratorConnection;\n\t} catch (err) {\n\t\tconsole.error(`Error connecting to the \"${chalk.greenBright(effectiveAmqpUrl)}\" server: ${formatError(err)}`);\n\t\tif (isAmqpDebugEnabled() && err instanceof Error && err.stack) {\n\t\t\tconsole.error(`${host.appNameText} connect stack: ${err.stack}`);\n\t\t}\n\t\tthrow err;\n\t}\n};\n\nconst connectToHost = async (host: IColaboFlowHostData, colaboFlowOrchestratorConnection: ChannelModel): Promise<Channel> => {\n\tconsole.log(`${host.appNameText} Opening the ${chalk.bold.italic(\"node host\")} channel as a listener (consumer): ${chalk.greenBright(host.queueHost)}`);\n\tlet chHost: Channel;\n\ttry {\n\t\tchHost = await colaboFlowOrchestratorConnection.createChannel();\n\t\tattachChannelDebugHandlers(host, \"host-listener\", chHost);\n\t\treturn chHost;\n\t} catch (err) {\n\t\tconsole.error(`${host.appNameText} Error creating the \"${chalk.greenBright(host.queueHost)}\" queue: ${formatError(err)}`);\n\t\tthrow err;\n\t}\n};\n\nconst connectToOrchestratorHeartbeat = async (host: IColaboFlowHostData, colaboFlowOrchestratorConnection: ChannelModel): Promise<Channel> => {\n\tconsole.log(`${host.appNameText} Opening the ${chalk.bold.italic(\"orchestrator heartbeat\")} channel as a produced (emitter): ${chalk.greenBright(host.queueHostHeartbeat)}`);\n\ttry {\n\t\tconst chHostHeartbeat = await colaboFlowOrchestratorConnection.createChannel();\n\t\thost.chHostHeartbeat = chHostHeartbeat;\n\t\tattachChannelDebugHandlers(host, \"host-heartbeat\", chHostHeartbeat);\n\t\treturn chHostHeartbeat;\n\t} catch (err) {\n\t\tconsole.error(`${host.appNameText} Error creating the \"${chalk.greenBright(host.queueHostHeartbeat)}\" queue: ${formatError(err)}`);\n\t\tthrow err;\n\t}\n};\n\n/**\n * the orchestrator heartbeat counter\n */\nlet heartbeatId: number = 0;\n/**\n * sends heartbeat messages back to the ColaboFlow orchestrator\n * to\n * 1. know the host exists\n * 2. know or update (not implemented yet) the available task executors\n */\n\nconst sendHeartbeatToHost = async (host: IColaboFlowHostData) => {\n\tif (!host.chHostHeartbeat) {\n\t\tconsole.error(`${host.appNameText} [sendHeartbeatToHost] Error: channel host.chHostHeartbeat is not existing`);\n\t\treturn;\n\t}\n\t// TODO: support listening for the heartbeat reply and set the timeout after we should send a warning/error on no response\n\tconst heartbeat: IColaboFlowGoMsg = {\n\t\t...createGoMsg(host.hostname, EColaboFlowGoMsgType.HEARTBEAT),\n\t\textension: {\n\t\t\tid: heartbeatId++,\n\t\t\tqueueHost: host.queueHost,\n\t\t\tlanguage: EProgrammingLanguageSupported.JAVASCRIPT,\n\t\t\ttaskIds: Object.keys(host.taskExecutorsAvailable),\n\t\t} as IColaboFlowGoMsgExtension_Heartbeat,\n\t\tmsg: `node host with tasks: ${JSON.stringify(Object.keys(host.taskExecutorsAvailable))}`,\n\t};\n\tif (host.reportsConfig.showHeartbeatMsgs && ((heartbeat.extension.id % host.reportsConfig.showHeartbeatMsgs) == 0)) {\n\t\tconsole.log(`${host.appNameText} Sending heartbeat [${heartbeat.extension.id}] [from \"${chalk.blueBright(host.hostname)}\" queue: \"${chalk.blueBright(host.queueHostHeartbeat)}\"]`);\n\t\t// console.log(`${host.appNameText} Sending heartbeat [queue: \"${chalk.blueBright(host.queueHostHeartbeat)}\"]: ${JSON.stringify(heartbeat)}`);\n\t}\n\t\ttry {\n\t\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\t\thost.chHostHeartbeat.sendToQueue(host.queueHostHeartbeat, Buffer.from(JSON.stringify(heartbeat)));\n\t\t} catch (err) {\n\t\t\tconsole.error(`${host.appNameText} [sendHeartbeatToHost] Failed to send heartbeat: ${formatError(err)}`);\n\t\t}\n\t};\n\nconst asyncProcessColaboFlowMsg_TaskExecute = async (host: IColaboFlowHostData, msgOrchestratorReqObj: IColaboFlowGoMsg): Promise<void> => {\n\tif (!host.chHostHeartbeat) {\n\t\tconsole.error(`${host.appNameText} [sendHeartbeatToHost] Error: channel host.chHostHeartbeat is not existing`);\n\t\treturn;\n\t}\n\tconst msgOrchestratorTaskExecuteReqObjExtension: IColaboFlowGoMsgExtension_TaskExecute_Request = msgOrchestratorReqObj.extension as IColaboFlowGoMsgExtension_TaskExecute_Request;\n\tconst taskId: string = msgOrchestratorTaskExecuteReqObjExtension.taskId;\n\tconst taskInput: unknown = msgOrchestratorTaskExecuteReqObjExtension.taskInput;\n\tconst queueReplyTo: string = msgOrchestratorReqObj.replyTo ?? host.queueHostHeartbeat;\n\n\tif (host.reportsConfig.showExecutionMsgs) {\n\t\tconsole.log(`${host.appNameText} [asyncProcessColaboFlowMsg_TaskExecute] Got a task to execute [and return over the RPC-reply queue: \"${chalk.blueBright(queueReplyTo)}\"]: taskId: ${taskId}`);\n\t}\n\n\tconst task: IFlowTask = host.tasksAvailable[taskId];\n\n\tif (!task) {\n\t\tconsole.error(`${host.appNameText} [asyncProcessColaboFlowMsg_TaskExecute] task is missing for the id: ${taskId}`);\n\t}\n\n\tconsole.log(`${host.appNameText} [asyncProcessColaboFlowMsg_TaskExecute] Executing id: ${chalk.blueBright(taskId)}, task.description: ${task.description}`);\n\n\tconst taskInstanceId: string = `taskId:lang-${LANGUAGE}:host-${host.hostname}:${uuidv1()}`;\n\tconst taskInstance: IFlowTaskInstance = createTaskInstanceForTaskWithoutFlow(task);\n\ttaskInstance.id = taskInstanceId;\n\thost.taskInstances[taskId] = taskInstance;\n\thost.runningTaskInstancesInfos[taskId] = {\n\t\tid: taskInstanceId,\n\t\ttaskInstance,\n\t};\n\n\tif (typeof task.executorRef?.id === \"undefined\") {\n\t\tconsole.error(`Executor ID is not provided for the task: ${taskId}`);\n\t\treturn;\n\t}\n\tconst taskExecutor: ITaskExecutor = getTaskExecutor(host, task.executorRef?.id);\n\n\t/*************************\n\t * REPLYING THE TASK PROGRESS (task instance id)\n\t *************************/\n\tconst msgTaskExecutionProgress: IColaboFlowGoMsg = {\n\t\t...createGoMsg(host.hostname, EColaboFlowGoMsgType.TASK_EXECUTE_PROGRESS),\n\t\trequestId: msgOrchestratorReqObj.requestId,\n\t\tmsgReplyChainIds: [msgOrchestratorReqObj.id],\n\t\textension: {\n\t\t\ttaskInstanceId,\n\t\t\tstatus: ETaskExecute_Progress_Status.INITIALIZED,\n\t\t\tprogress: 0,\n\t\t} as IColaboFlowGoMsgExtension_TaskExecute_Progress,\n\t\tmsg: `Returning task execution for the taskId: '${taskId}' over queue: '${queueReplyTo}'}`,\n\t};\n\tif (host.reportsConfig.showExecutionMsgs) {\n\t\tconsole.log(`${host.appNameText} Sending PROGRESS to the task execution requester (orchestrator) [queue: \"${chalk.blueBright(queueReplyTo)}\"]: ${JSON.stringify(msgTaskExecutionProgress)}`);\n\t}\n\n\ttry {\n\t\t// host.chHostHeartbeat.checkQueue\n\t\t// host.connection\n\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\thost.chHostHeartbeat.sendToQueue(queueReplyTo, Buffer.from(JSON.stringify(msgTaskExecutionProgress)));\n\t} catch (err) {\n\t\tconsole.error(`${host.appNameText} Failed sending TASK_EXECUTE_PROGRESS to queue \"${queueReplyTo}\": ${formatError(err)}`);\n\t}\n\n\t/*************************\n\t * EXECUTING THE TASK\n\t *************************/\n\t/** task execution output */\n\tconst taskOutput: unknown = await taskExecutor.reference?.method(taskInput);\n\tconst taskOutputStr: string = JSON.stringify(taskOutput);\n\t// reduce to `responseMaxChars` characters\n\tconst responseMaxChars: number = 200;\n\tconst taskOutputStrShort: string = taskOutputStr.length > responseMaxChars ? taskOutputStr.substring(0, responseMaxChars/2) + \" [...] \" + taskOutputStr.substring(taskOutputStr.length - responseMaxChars/2) : taskOutputStr;\n\n\tconsole.log(`${host.appNameText} [asyncProcessColaboFlowMsg_TaskExecute] task executed. Result is (reduced to ${responseMaxChars} chars): ${chalk.blueBright(taskOutputStrShort)}`);\n\n\t/*************************\n\t * SENDING back THE TASK RESULT\n\t *************************/\n\t/** task execution output */\n\tconst msgTaskExecutionReply: IColaboFlowGoMsg = {\n\t\t...createGoMsg(host.hostname, EColaboFlowGoMsgType.TASK_EXECUTE_RESPONSE),\n\t\trequestId: msgOrchestratorReqObj.requestId,\n\t\tmsgReplyChainIds: [msgOrchestratorReqObj.id],\n\t\textension: {\n\t\t\ttaskOutput,\n\t\t} as IColaboFlowGoMsgExtension_TaskExecute_Response,\n\t\tmsg: `Returning task execution for the taskId: '${taskId}' over queue: '${queueReplyTo}'}`,\n\t};\n\tconst msgTaskExecutionReplyStr = JSON.stringify(msgTaskExecutionReply);\n\t// reduce to `responseMaxChars` characters\n\tconst msgTaskExecutionReplyStrShort: string = msgTaskExecutionReplyStr.length > responseMaxChars ? msgTaskExecutionReplyStr.substring(0, responseMaxChars/2) + \" [...] \" + msgTaskExecutionReplyStr.substring(msgTaskExecutionReplyStr.length - responseMaxChars/2) : msgTaskExecutionReplyStr;\n\n\tif (host.reportsConfig.showExecutionMsgs) {\n\t\tconsole.log(`${host.appNameText} Sending RESPONSE to the task execution requester (orchestrator) [queue: \"${chalk.blueBright(queueReplyTo)}\"]: (reduced to ${responseMaxChars} chars) ${msgTaskExecutionReplyStrShort}`);\n\t}\n\ttry {\n\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\thost.chHostHeartbeat.sendToQueue(queueReplyTo, Buffer.from(msgTaskExecutionReplyStr));\n\t} catch (err) {\n\t\tconsole.error(`${host.appNameText} Failed sending TASK_EXECUTE_RESPONSE to queue \"${queueReplyTo}\": ${formatError(err)}`);\n\t}\n};\n\n/**\n * Process a msg with request to send report on the internal tasks instances.\n *\n * Based on the request (should provide running or finalized task instances, etc) it will assemble report on the internal task instances.\n *\n * It sends back a message with the report\n * @param host\n * @param msgObj\n */\nconst processColaboFlowMsg_TaskInstancesReport = (host: IColaboFlowHostData, msgObj: IColaboFlowGoMsg): void => {\n\tif (!host.chHostHeartbeat) {\n\t\tconsole.error(`${host.appNameText} [sendHeartbeatToHost] Error: channel host.chHostHeartbeat is not existing`);\n\t\treturn;\n\t}\n\tconst msgExtension: IColaboFlowGoMsgExtension_TaskInstancesReport_Request = msgObj.extension as IColaboFlowGoMsgExtension_TaskInstancesReport_Request;\n\tconst reportFinalizedTaskInstances: boolean = msgExtension.reportFinalizedTaskInstances;\n\tconst reportRunningTaskInstances: boolean = msgExtension.reportRunningTaskInstances;\n\n\tconsole.log(`${host.appNameText} [processColaboFlowMsg_TaskInstancesReport] Sending task instances report to the requester: ${chalk.blueBright(msgObj.sender)}`);\n\n\tconst tasksInstanceInfos: Record<string, IColaboFlowGoTaskInstanceInfo> = {};\n\tif (reportRunningTaskInstances) {\n\t\tObject.assign(tasksInstanceInfos, host.runningTaskInstancesInfos);\n\t}\n\tif (reportFinalizedTaskInstances) {\n\t\tObject.assign(tasksInstanceInfos, host.finalizedTaskInstancesInfos);\n\t}\n\n\tconst msgReply: IColaboFlowGoMsg = {\n\t\t...createGoMsg(host.hostname, EColaboFlowGoMsgType.TASK_INSTANCES_REPORT__RESPONSE),\n\t\trequestId: msgObj.requestId,\n\t\tmsgReplyChainIds: [msgObj.id],\n\t\textension: {\n\t\t\ttasksInstanceInfos,\n\t\t} as IColaboFlowGoMsgExtension_TaskInstancesReport_Response,\n\t\tmsg: `node host with tasks: ${JSON.stringify(Object.keys(host.taskExecutorsAvailable))}`,\n\t};\n\tconst queueReplyTo: string = msgObj.replyTo ?? host.queueHostHeartbeat;\n\tif (host.reportsConfig.showReportsMsgs) {\n\t\tconsole.log(`${host.appNameText} Sending response to the task instances report [queue: \"${chalk.blueBright(queueReplyTo)}\"]: ${JSON.stringify(msgReply)}`);\n\t}\n\ttry {\n\t\t// https://www.w3schools.com/nodejs/met_buffer_from.asp\n\t\thost.chHostHeartbeat.sendToQueue(queueReplyTo, Buffer.from(JSON.stringify(msgReply)));\n\t} catch (err) {\n\t\tconsole.error(`${host.appNameText} Failed sending TASK_INSTANCES_REPORT__RESPONSE to queue \"${queueReplyTo}\": ${formatError(err)}`);\n\t}\n};\n\nexport const hostRun = async (host: IColaboFlowHostData): Promise<void> => {\n\tprocess.title = `ColaboFlow.Go-${host.hostname}`;\n\n\taddOmnipresentTasks(host, hostRegisterTaskExecutor, hostRegisterTask);\n\n\tconst colaboFlowOrchestratorConnection: ChannelModel = await connectToServer(host);\n\n\tconst chHost: Channel = await connectToHost(host, colaboFlowOrchestratorConnection);\n\n\tawait connectToOrchestratorHeartbeat(host, colaboFlowOrchestratorConnection);\n\n\tconsole.log(`${host.appNameText} Hosting tasks: \"${chalk.greenBright(Object.keys(host.tasksAvailable).toString())}\"`);\n\n\tsetInterval(() => {\n\t\tsendHeartbeatToHost(host);\n\t}, HEARTBEAT_TIME);\n\n\t// Listener (consumer)\n\tconsole.log(`${host.appNameText} Listening on the queue: \"${chalk.blueBright(host.queueHost)}\"`);\n\t// https://amqp-node.github.io/amqplib/channel_api.html#channel_assertQueue\n\tawait chHost.assertQueue(host.queueHost, {\n\t\texclusive: true,\n\t});\n\tconsole.log(`${host.appNameText} [*] Waiting for messages in %s. To exit press \"${chalk.blueBright(\"CTRL+C\")}\"`);\n\tchHost.consume(host.queueHost, async (msg) => {\n\t\tif (msg !== null) {\n\t\t\t// Acknowledge immediately to prevent RabbitMQ consumer_timeout (default 30 min)\n\t\t\t// from closing the channel during long-running tasks (e.g. bulk DB inserts).\n\t\t\t// This is safe because task completion is tracked at the application level\n\t\t\t// via TASK_EXECUTE_RESPONSE messages sent over chHostHeartbeat.\n\t\t\tchHost.ack(msg);\n\n\t\t\tlet msgObj: IColaboFlowGoMsg;\n\t\t\t\ttry {\n\t\t\t\t\tmsgObj = JSON.parse(msg.content.toString());\n\n\t\t\t\tconst msgObjStr: string = JSON.stringify(msgObj);\n\t\t\t\t// reduce to `responseMaxChars` characters\n\t\t\t\tconst responseMaxChars: number = 200;\n\t\t\t\tconst msgObjStrShort: string = msgObjStr.length > responseMaxChars ? msgObjStr.substring(0, responseMaxChars/2) + \" [...] \" + msgObjStr.substring(msgObjStr.length - responseMaxChars/2) : msgObjStr;\n\t\t\t\tconsole.log(`${host.appNameText} Received (reduced to ${responseMaxChars} chars): \"${chalk.blueBright(msgObjStrShort)}\"`);\n\n\t\t\t\t\tconsole.log(`${host.appNameText} msgObj.sender: \"${chalk.blueBright(msgObj.sender)}\", msgObj.type: \"${chalk.blueBright(msgObj.type)}, msgObj.msg: \"${chalk.blueBright(msgObj.msg)}\"`);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`${host.appNameText} Error parsing the message: ${formatError(err)} | raw=${msg.content.toString()}`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tswitch (msgObj.type) {\n\t\t\t\t\t\tcase EColaboFlowGoMsgType.TASK_EXECUTE_REQUEST:\n\t\t\t\t\t\t\tawait asyncProcessColaboFlowMsg_TaskExecute(host, msgObj);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EColaboFlowGoMsgType.TASK_INSTANCES_REPORT__REQUEST:\n\t\t\t\t\t\t\tprocessColaboFlowMsg_TaskInstancesReport(host, msgObj);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`${host.appNameText} Error while processing message type \"${msgObj.type}\": ${formatError(err)}`);\n\t\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(\"${host.appNameText} Consumer cancelled by server\");\n\t\t}\n\t});\n};\n", "/** \n * Here are the tasks that are embeded in any host\n * \n */\n\nimport { EExecutingEnvironment, EFlowPlaceType, EFlowTaskType, IFlowTask, ITaskExecutor } from \"@colabo-flow/i-core\";\nimport { IColaboFlowHostData } from \"../vos\";\nimport { THostRegisterTask, THostRegisterTaskExecutor } from \"./vos\";\n\n/**\n * Adds all the omnipresent tasks for each host\n * @param host the host to which we are adding tasks\n * @param hostRegisterTaskExecutor function that registers executors\n * @param hostRegisterTask function that registers task\n */\nexport const addOmnipresentTasks = async (host: IColaboFlowHostData, hostRegisterTaskExecutor: THostRegisterTaskExecutor, hostRegisterTask: THostRegisterTask): Promise<void> => {\n\n\t/************\n\t * echoPing task implementation for each node.js worker\n\t*/\n\n\tconst echoPing = (input: any): any => {\n\t\tconsole.log(`${host.appNameText} [echoPing] Pinged with the input: ${JSON.stringify(input)}`);\n\n\t\tconst output = {\n\t\t\tinput,\n\t\t\ttimeDateNow: Date.now(), \n\t\t\t// https://nodejs.org/api/perf_hooks.html#performancenow\n\t\t\ttimePerformance: performance.now(),\n\t\t\t// https://timestamp.online/article/how-to-get-current-date-and-time-in-javascript\n\t\t\ttimeHuman: (new Date()).toISOString(),\n\t\t\thostname: host.hostname,\n\t\t\tqueueHost: host.queueHost\n\t\t};\n\n\t\treturn output;\n\t}\n\n\tconst executorEchoPing: ITaskExecutor = {\n\t\tid: \"colabo.flow.echoPing\",\n\t\tdescription: \"(Node.js) Used for testing worker availability. Returns the sender message in addition with the local metadata\",\n\t\tenvironment: EExecutingEnvironment.ISOMORPHIC,\n\t\treference: {\n\t\t\tmethod: echoPing,\n\t\t},\n\t};\n\n\tconst taskEchoPing: IFlowTask = {\n\t\tid: \"colabo.flow.echoPing\",\n\t\ttype: EFlowTaskType.SCRIPT,\n\t\texecutorRef: {\n\t\t\tenvironment: EExecutingEnvironment.ISOMORPHIC,\n\t\t\tid: executorEchoPing.id,\n\t\t},\n\t\tplaceType: EFlowPlaceType.TASK,\n\t\tinputs: [],\n\t\toutputs: [],\n\t\tinoutputs: [],\n\t};\n\n\tconsole.log(`${host.appNameText} Adding echoPing task executor and task`);\n\thostRegisterTaskExecutor(host, executorEchoPing);\n\thostRegisterTask(host, taskEchoPing);\n}", "const DEBUG: boolean = true;\nconst DEBUG_VERBOSE: boolean = true;\n\nimport chalk from 'chalk'\nimport { StoreApi, UseBoundStore } from \"zustand\";\n\nimport { assertCondensedFlow, EFlowExecutionStatus, findPlaceByIdInFlow, FlowInstanceEngine, flowInstancePack, flowInstanceUnpack, getStartEventInFlow, IActionPayload_ExecuteFlowInstance, IActionPayload_FLOW_INSTANCE_CREATE, IActionPayload_FLOW_INSTANCE_DELETE, IActionPayload_FLOW_INSTANCE_DEPERSIST, IActionPayload_FLOW_INSTANCE_PERSIST, IActionPayload_FLOW_INSTANCE_SET_STATUS, IActionPayload_GetAgentTokenForFlowInstance, IActionPayload_JoinFlowInstance, IActionPayload_LoadTokens, IActionPayload_MoveAllTokensToPlace, IActionPayload_MoveTokenToPlace, IFlow, IFlowInstance, IFlowInstanceContainer, IFlowInstanceContext, IFlowInstanceObserver, IFlowInstancesContainer, IFlowPlace, IFlowSequence, IFlowTask, IFlowToken, IMutationPayload__FLOW_INSTANCE_ADD, IMutationPayload__FLOW_INSTANCE_ID_UPDATE, IMutationPayload__FLOW_INSTANCE_REMOVE, IProcessNewFlowInstance_Payload, KFlowTypes } from \"@colabo-flow/i-core\";\nimport { createBaseStore } from \"@colabo-utils/i-store\";\nimport { EApiRequestParamType, IApiRequest, IKNode, KEDGE_API_TYPE, KnAllEdge_EntityEphemeralIdPrefix, KNODE_API_PARAMS, KNODE_API_TYPE } from '@colabo-knalledge/i-core';\nimport { IFlowStoreProtected } from \"./flow.store\";\nimport { g } from 'vitest/dist/chunks/suite.d.FvehnV49';\nimport { assert } from '@colabo-utils/i-verify';\nimport { tokenPack, tokenUnpack } from \"@colabo-flow/i-core\";\n\n/**\n * Interface describing the flow store state\n */\nexport interface IFlowFlowchestratorStoreState {\n\t// /** \n\t// * All available flows\n\t// */\n\t// flows: Record<string, IFlow>;\n\n\t/** \n\t * Contains all registered observers that should be notified on flow instance ***\"events\"*** (like new flow instance created or a new visual task encountered) \n\t * */\n\tflowInstanceObservers: IFlowInstanceObserver[];\n\n\t/** TODO: Should we merge IFlowInstanceContainer in IFlowInstanceContext ? */\n\tflowInstanceContexts: Record<string, IFlowInstanceContext>;\n\n\t/** -----------------\n\t * Regular flow that are executed, either from\n\t * 0. the flows that are loaded from the KnAllEdge store\n\t * 1. the flows that come from routes or from\n\t * 2. the flows initiated by some datatalks component or from\n\t * 3. the flows provided by 3rd party components or from\n\t * 4. the flows provided externally (through JSON schemas) or from\n\t * 5. the programmatically constructed flows\n\t * -----------------\n\t */\n\t/* Contains flow instance containers. Each container contains all properties (context) related to the execution (instance) of a flow */\n\tflowInstancesContainer: IFlowInstancesContainer;\n};\n\n/**\n * Interface describing the flow store mutations\n */\nexport interface IFlowFlowchestratorStoreMutations {\n\taddFlowInstance: (payload: IMutationPayload__FLOW_INSTANCE_ADD) => void;\n\tremoveFlowInstance: (payload: IMutationPayload__FLOW_INSTANCE_REMOVE) => void;\n\tupdateFlowInstanceId: (payload: IMutationPayload__FLOW_INSTANCE_ID_UPDATE) => void;\n};\n\n/**\n * Interface describing the flow store actions\n */\nexport interface IFlowFlowchestratorStoreActions {\n\t/** \n\t * Loads all (or all of the specified flow) instances from the persistent store into the flow store.\n\t * @param flowId Flow id which instances we want to load (optional)\n\t * @param flowInstanceNodeId Flow instance node id which instances we want to load (optional)\n\t * @param statuses Flow instance statuses which instances we want to load (optional)\n\t * @returns List of flow instances as JSON\n\t*/\n\tloadFlowInstances: (flowId?: string, flowInstanceNodeId?: string, statuses?: EFlowExecutionStatus[]) => Promise<IFlowInstance[]>;\t\n\tcreateFlowInstance: (payload: IActionPayload_FLOW_INSTANCE_CREATE) => Promise<IFlowInstance>;\n\tdeleteFlowInstance: (payload: IActionPayload_FLOW_INSTANCE_DELETE) => Promise<void>;\n\tpersistFlowInstance: (payload: IActionPayload_FLOW_INSTANCE_PERSIST) => Promise<IFlowInstance>;\n\tdepersistFlowInstance: (payload: IActionPayload_FLOW_INSTANCE_DEPERSIST) => Promise<IFlowInstance>;\n\texecuteFlowInstance: (payload: IActionPayload_ExecuteFlowInstance) => Promise<void>;\n\tsetFlowInstanceStatus: (payload: IActionPayload_FLOW_INSTANCE_SET_STATUS) => Promise<EFlowExecutionStatus>;\n\t/**\n\t * Join agent to a flow instance. It joins the agent to a flow instance by creating a token in the flow instance associated with the agent.\n\t * \n\t * It also notifies the flow instance observers about the new token created in the flow instance.\n\t * \n\t * @param payload - payload containing the flow instance knode ID, the place ID, agent type and ID where the agent should be joined\n\t * @returns A promise that resolves to the knode ID of the created token.\n\t * \n\t * TODO: Should we return knode ID or the token ID?\n\t */\n\tjoinAgentToFlowInstance: (payload: IActionPayload_JoinFlowInstance) => Promise<string>;\n\tgetAgentTokenForFlowInstance: (payload: IActionPayload_GetAgentTokenForFlowInstance) => Promise<IFlowToken | undefined>;\n\t/**\n\t * Loads token by its knode ID from the persistent store into the flow store.\n\t * @param tokenKnodeId Token knode id\n\t * @returns Token as JSON\n\t */\n\tloadToken: (tokenKnodeId: string) => Promise<IFlowToken>;\n\tloadTokens: (payload: IActionPayload_LoadTokens) => Promise<IFlowToken[]>;\n\tmoveToken : (payload: IActionPayload_MoveTokenToPlace) => Promise<IFlowToken>;\n\tmoveAllTokens : (payload: IActionPayload_MoveAllTokensToPlace) => Promise<IFlowToken[]>;\n};\n\n\n/**\n * Flowchestrator store interface containing all the store's aspects (state, modules, mutation, and actions)\n */\nexport type IFlowFlowchestratorStore = IFlowFlowchestratorStoreState & IFlowFlowchestratorStoreMutations & IFlowFlowchestratorStoreActions;\n\nlet appNameText: string = \"ColaboFlow.Go.FlowCheStrator.Store\";\n\n/**\n * Flowchestrator Store singleton\n */\nlet _store: StoreApi<IFlowFlowchestratorStore> | undefined;\n\n/**\n * Returns the Flowchestrator store either creating it if not created or just passing the previously created one\n * @param flowStoreProtected internal (protected) props of the parent domain store (like KnAllEdge services, etc)\n * @returns FlowChestrator store\n */\nexport const useFlowFlowchestratorStore = (flowStoreProtected: IFlowStoreProtected): IFlowFlowchestratorStore => {\n\tconst _appNameText = flowStoreProtected.appNameText;\n\tappNameText = `${_appNameText}:[${chalk.bold.yellow(\"STORE\")}]`;\n\n\tif(!_store) {\n\t\t_store = createBaseStore<IFlowFlowchestratorStore>((set, _get) => {\n\t\t\tconst get = (): IFlowFlowchestratorStore => {\n\t\t\t\treturn _get();\n\t\t\t};\n\t\t\tconst storeObj: IFlowFlowchestratorStore = {\n\t\t\t\t// state\n\t\t\t\t// ========================\n\t\t\t\tflowInstanceObservers: [],\n\t\t\t\tflowInstanceContexts: {},\n\t\t\t\tflowInstancesContainer: {},\n\n\t\t\t\t// mutations\n\t\t\t\t// ========================\n\t\t\t\taddFlowInstance: (payload: IMutationPayload__FLOW_INSTANCE_ADD): void => {\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer } = get();\n\t\t\t\t\tflowInstanceContexts[payload.flowInstance.id] = {\n\t\t\t\t\t\tvisualTaskContainers: {},\n\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = {\n\t\t\t\t\t\tflowInstance: payload.flowInstance,\n\t\t\t\t\t\tflowInstanceEngine: payload.flowEngine,\n\t\t\t\t\t\tisFlowStarted: false,\n\t\t\t\t\t\tflowInput: payload.flowInput,\n\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\tflowInstancesContainer[payload.flowInstance.id] = flowInstanceContainer;\t\n\t\t\t\t},\n\t\t\t\tremoveFlowInstance: (payload: IMutationPayload__FLOW_INSTANCE_REMOVE): void => {\n\t\t\t\t\tconst { flowInstancesContainer, flowInstanceContexts } = get();\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[removeFlowInstance] removing flow instance with ID: ${payload.flowInstanceId}`);\n\t\t\t\t\tdelete flowInstancesContainer[payload.flowInstanceId];\n\t\t\t\t\tdelete flowInstanceContexts[payload.flowInstanceId];\n\t\t\t\t},\n\t\t\t\tupdateFlowInstanceId: (payload: IMutationPayload__FLOW_INSTANCE_ID_UPDATE): void => {\n\t\t\t\t\tconst { flowInstancesContainer, flowInstanceContexts } = get();\n\t\t\t\t\tflowInstancesContainer[payload.flowInstanceIdNew] = flowInstancesContainer[payload.flowInstanceIdCurrent];\n\t\t\t\t\tdelete flowInstancesContainer[payload.flowInstanceIdCurrent];\n\n\t\t\t\t\tflowInstancesContainer[payload.flowInstanceIdNew].flowInstance.id = payload.flowInstanceIdNew;\n\t\t\t\t\t\n\t\t\t\t\tflowInstanceContexts[payload.flowInstanceIdNew] = flowInstanceContexts[payload.flowInstanceIdCurrent];\n\t\t\t\t\tdelete flowInstanceContexts[payload.flowInstanceIdCurrent];\n\t\t\t\t},\n\n\t\t\t\t// actions\n\t\t\t\t// ========================\n\t\t\t\tloadFlowInstances: async (flowId?: string, flowInstanceNodeId?: string, statuses?: EFlowExecutionStatus[]): Promise<IFlowInstance[]> => {\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadFlowInstances] loading flow instances...`);\n\t\t\t\t\tconst request: IApiRequest = {\n\t\t\t\t\t\ttype: KEDGE_API_TYPE.INDEX_COLABO_API,\n\t\t\t\t\t\tparamsDetailed: {\n\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\tpath: \"type\",\n\t\t\t\t\t\t\t\tvalue: KFlowTypes.FLOW_INSTANCE,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\n\t\t\t\t\tif (flowId) {\n\t\t\t\t\t\trequest.paramsDetailed ??= {};\n\t\t\t\t\t\trequest.paramsDetailed[\"flowId\"] = {\n\t\t\t\t\t\t\tpath: \"dataContent.flowId\",\n\t\t\t\t\t\t\tvalue: flowId,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (flowInstanceNodeId) {\n\t\t\t\t\t\trequest.paramsDetailed ??= {};\n\t\t\t\t\t\trequest.paramsDetailed[\"flowInstanceNodeId\"] = {\n\t\t\t\t\t\t\tpath: \"_id\",\n\t\t\t\t\t\t\tvalue: flowInstanceNodeId,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (statuses) {\n\t\t\t\t\t\tconst statusesStrArray: string[] = statuses.map((status: EFlowExecutionStatus) => status.toString());\n\t\t\t\t\t\trequest.paramsDetailed ??= {};\n\t\t\t\t\t\trequest.paramsDetailed[\"statuses\"] = {\n\t\t\t\t\t\t\tpath: \"dataContent.executionStatus.status\",\n\t\t\t\t\t\t\tvalue: statusesStrArray,\n\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\ttype: EApiRequestParamType.IN,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceKNodes: IKNode[] = await flowStoreProtected.kNodeService.getVosWithColaboApi(request);\n\t\t\t\t\tif(!flowInstanceKNodes) {\n\t\t\t\t\t\tthrow new Error(\"persisted Flow instances not retrieved from store\");\n\t\t\t\t\t}\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadFlowInstances] flow instances retrieved (packed) from store with IDs ${flowInstanceKNodes.map(kNode => kNode._id)}`);\n\t\t\t\t\tconst flowInstances: IFlowInstance[] = await Promise.all(flowInstanceKNodes.map(async (flowInstanceKNode: IKNode) => {\n\t\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceUnpack(flowInstanceKNode);\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadFlowInstances] flow instance unpacked: ${JSON.stringify(flowInstance, null, 4)}`);\n\n\t\t\t\t\t\t// depersist tokens\n\t\t\t\t\t\tfor (const tokenKnodeId of flowInstanceKNode?.dataContent?.tokenKnodeIds ?? []) {\n\t\t\t\t\t\t\tconst tokenKNode: IKNode = await flowStoreProtected.kNodeService.getById(tokenKnodeId);\n\t\t\t\t\t\t\tif(!tokenKNode) {\n\t\t\t\t\t\t\t\tthrow new Error(`Token not found, tokenKnodeId: ${tokenKnodeId}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst token: IFlowToken = tokenUnpack(tokenKNode);\n\t\t\t\t\t\t\tif(DEBUG_VERBOSE) console.log(`${appNameText}:[loadFlowInstances] token unpacked: ID ${token.id}`);\n\t\t\t\t\t\t\tflowInstance.tokens.push(token);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn flowInstance;\n\t\t\t\t\t}));\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadFlowInstances] flow instances unpacked`);\n\n\t\t\t\t\t// add flow instances to the in-memory store\n\t\t\t\t\tfor (const flowInstance of flowInstances) {\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadFlowInstances] adding flow instance with ID ${flowInstance.id} to the in-memory store`);\n\n\t\t\t\t\t\tconst flow: IFlow = await flowStoreProtected.getDomainStore().loadFlow(flowInstance.flowId);\n\t\t\t\t\t\tif(DEBUG_VERBOSE) console.log(`${appNameText}:[loadFlowInstances] flow with ID ${flow.id} loaded from the store: ${JSON.stringify(flow, null, 4)}`);\n\n\t\t\t\t\t\tconst flowEngine: FlowInstanceEngine<IFlow, IFlowPlace, IFlowTask, IFlowSequence> = new FlowInstanceEngine(flow, flowInstance);\n\t\t\t\t\t\tconst payloadFlowInstanceAdd: IMutationPayload__FLOW_INSTANCE_ADD = { \n\t\t\t\t\t\t\tflowInstance: flowInstance, \n\t\t\t\t\t\t\tflowEngine: flowEngine, \n\t\t\t\t\t\t\t// TODO: we should understand what to do with flowInput, where it is persisted and how to depersist it\n\t\t\t\t\t\t\tflowInput: undefined \n\t\t\t\t\t\t};\n\t\t\t\t\t\tget().addFlowInstance(payloadFlowInstanceAdd);\n\t\t\t\t\t}\n\n\t\t\t\t\tif(DEBUG_VERBOSE) console.log(`${appNameText}:[loadInstances] flow instances loaded: ${JSON.stringify(flowInstances, null, 4)}`);\n\t\t\t\t\treturn flowInstances;\n\n\t\t\t\t},\n\t\t\t\tcreateFlowInstance: async (payload: IActionPayload_FLOW_INSTANCE_CREATE): Promise<IFlowInstance> => {\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[createFlowInstance] starting...`);\n\n\t\t\t\t\t// initialize flow\n\t\t\t\t\tconst flow: IFlow = payload.flow;\n\t\t\t\t\t/** flow instance engine, helps with managing tokens in the instance */\n\t\t\t\t\tconst flowEngine: FlowInstanceEngine<IFlow, IFlowPlace, IFlowTask, IFlowSequence> = new FlowInstanceEngine(flow, undefined, {createEntitiesIds: true, flowInstancePartial: payload.flowInstancePartial});\n\t\t\t\t\tconst flowInstance: IFlowInstance = await flowEngine.asyncGetFlowInstance();\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[createFlowInstance] flow instance created: ${JSON.stringify(flowInstance, null, 4)}`);\n\t\t\t\n\t\t\t\t\t// notify flow instance observers\n\t\t\t\t\tconst processNewFlowInstance_payload: IProcessNewFlowInstance_Payload = {\n\t\t\t\t\t\tflow,\n\t\t\t\t\t\tflowInstance,\n\t\t\t\t\t};\n\t\t\t\t\tconst { flowInstanceObservers } = get(); // access current state\n\t\t\t\t\tfor (const observer of flowInstanceObservers) {\n\t\t\t\t\t\tif(DEBUG) console.log(`[FlowActions.FLOW_INSTANCE_CREATE] running flow instance observer, observer.name = ${observer.name}`);\n\t\t\t\t\t\tif (observer.asyncNewFlowInstanceProcessor) {\n\t\t\t\t\t\t\tawait observer.asyncNewFlowInstanceProcessor(processNewFlowInstance_payload);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t// add flow instance to the store\n\t\t\t\t\tconst payloadFlowInstanceAdd: IMutationPayload__FLOW_INSTANCE_ADD = { flowInstance: flowInstance, flowEngine: flowEngine, flowInput: payload.flowInput };\n\t\t\t\t\tget().addFlowInstance(payloadFlowInstanceAdd);\n\t\t\t\t\treturn flowInstance;\n\t\t\t\t},\n\n\t\t\t\tdeleteFlowInstance: async (payload: IActionPayload_FLOW_INSTANCE_DELETE): Promise<void> => {\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[deleteFlowInstance] deleting flow instance with ID: ${payload.flowInstanceId}`);\n\t\t\t\t\tconst { flowInstancesContainer, removeFlowInstance } = get();\n\t\t\t\t\tremoveFlowInstance({ flowInstanceId: payload.flowInstanceId });\n\t\t\t\t\tflowStoreProtected.kNodeService.destroy(payload.flowInstanceId);\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[deleteFlowInstance] flow instance with ID ${payload.flowInstanceId} deleted from the in-memory and persistent store`);\n\t\t\t\t},\n\n\t\t\t\tpersistFlowInstance: async (payload: IActionPayload_FLOW_INSTANCE_PERSIST): Promise<IFlowInstance> => {\n\t\t\t\t\tconst flowInstanceId: string = payload.flowInstanceId;\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] persisting flow instance with ID: ${flowInstanceId}`);\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer } = get();\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[flowInstanceId];\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] persisting flow instance with ID: ${flowInstance.id}: ${JSON.stringify(flowInstance, null, 4)}`);\n\t\t\t\t\t// const flow: IFlow = flowStoreProtected.getDomainStore().flows[flowInstance.flowId];\n\t\t\t\t\tconst flowInstanceKNode: IKNode = flowInstancePack(flowInstance);\n\t\t\t\t\t// remove the ephemeral ID from the flow instance knode ID\n\t\t\t\t\tif(flowInstanceKNode._id?.startsWith(KnAllEdge_EntityEphemeralIdPrefix)) flowInstanceKNode._id = undefined;\n\n\t\t\t\t\t// if flow instance is already created, just update it\n\t\t\t\t\tif(flowInstanceKNode._id) {\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] flow instance with ID ${flowInstance.id} already exists, updating it...`);\n\t\t\t\t\t\tconst updateRequest: IApiRequest = {\n\t\t\t\t\t\t\ttype: KNODE_API_TYPE.UPDATE_COLABO_API,\n\t\t\t\t\t\t\tparamsDetailed: {\n\t\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t\tpath: \"_id\",\n\t\t\t\t\t\t\t\t\tvalue: flowInstance.id,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdata: flowInstanceKNode,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst kNodeFromServer: IKNode = await flowStoreProtected.kNodeService.updateSingleWithColaboApi(updateRequest);\n\t\t\t\t\t\tif(!kNodeFromServer) {\n\t\t\t\t\t\t\tthrow new Error(\"Flow instance not updated\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] flow instance updated with flow knode ID: ${kNodeFromServer._id}: ${JSON.stringify(kNodeFromServer, null, 4)}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] flow instance with ID ${flowInstance.id} does not exist, creating it...`);\n\t\t\t\t\t\tconst createResult: IKNode[] = await flowStoreProtected.kNodeService.create(flowInstanceKNode);\n\t\t\t\t\t\tif(!createResult || createResult.length !== 1) {\n\t\t\t\t\t\t\tthrow new Error(\"Flow instance not created\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst kNodeFromServer: IKNode = createResult[0];\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] flow instance persisted with flow knode ID: ${kNodeFromServer._id}: ${JSON.stringify(kNodeFromServer, null, 4)}`);\n\n\t\t\t\t\t\t// update the in-memory store with the persisted flow instance ID instead of the ephemeral one\n\t\t\t\t\t\tget().updateFlowInstanceId({\n\t\t\t\t\t\t\tflowInstanceIdCurrent: flowInstance.id,\n\t\t\t\t\t\t\tflowInstanceIdNew: kNodeFromServer._id!\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\treturn flowInstance;\n\t\t\t\t},\n\n\t\t\t\tdepersistFlowInstance: async (payload: IActionPayload_FLOW_INSTANCE_DEPERSIST): Promise<IFlowInstance> => {\n\t\t\t\t\tconst flowInstanceKnodeId: string = payload.flowInstanceId;\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] depersisting flow instance from kNode with ID: ${flowInstanceKnodeId}`);\n\n\t\t\t\t\tconst flowInstanceKNode: IKNode = await flowStoreProtected.kNodeService.getById(flowInstanceKnodeId);\n\t\t\t\t\tif(!flowInstanceKNode) {\n\t\t\t\t\t\tthrow new Error(\"persisted Flow instance not retrieved from store\");\n\t\t\t\t\t}\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] flow instance retrieved (packed) from store with ID ${flowInstanceKNode._id}: ${JSON.stringify(flowInstanceKNode, null, 4)}`);\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceUnpack(flowInstanceKNode);\n\t\t\t\t\t\n\t\t\t\t\t// depersist tokens\n\t\t\t\t\tfor (const tokenKnodeId of flowInstanceKNode?.dataContent?.tokenKnodeIds ?? []) {\n\t\t\t\t\t\tconst tokenKNode: IKNode = await flowStoreProtected.kNodeService.getById(tokenKnodeId);\n\t\t\t\t\t\tif(!tokenKNode) {\n\t\t\t\t\t\t\tthrow new Error(`Token not found, tokenKnodeId: ${tokenKnodeId}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst token: IFlowToken = tokenUnpack(tokenKNode);\n\t\t\t\t\t\tflowInstance.tokens.push(token);\n\t\t\t\t\t}\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[persistFlowInstance] flow instance unpacked from kNode with ID ${flowInstanceKNode._id}: ${JSON.stringify(flowInstance, null, 4)}`);\n\n\t\t\t\t\tconst flow: IFlow = await flowStoreProtected.getDomainStore().loadFlow(flowInstance.flowId);\n\n\t\t\t\t\tconst flowInstanceEngine: FlowInstanceEngine<IFlow, IFlowPlace, IFlowTask, IFlowSequence> = new FlowInstanceEngine(flow);\n\n\t\t\t\t\t// notify flow instance observers\n\t\t\t\t\tconst processNewFlowInstance_payload: IProcessNewFlowInstance_Payload = {\n\t\t\t\t\t\tflow,\n\t\t\t\t\t\tflowInstance,\n\t\t\t\t\t};\n\t\t\t\t\tconst { flowInstanceObservers } = get(); // access current state\n\t\t\t\t\tfor (const observer of flowInstanceObservers) {\n\t\t\t\t\t\tif(DEBUG) console.log(`[FlowActions.FLOW_INSTANCE_CREATE] running flow instance observer, observer.name = ${observer.name}`);\n\t\t\t\t\t\tif (observer.asyncNewFlowInstanceProcessor) {\n\t\t\t\t\t\t\tawait observer.asyncNewFlowInstanceProcessor(processNewFlowInstance_payload);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// TODO: we should understand what to do with flowInput, when is it used, how is it persisted and depersisted\n\t\t\t\t\tconst flowInput = undefined;\n\t\t\t\t\t// add flow instance to the store\n\t\t\t\t\tconst payloadFlowInstanceAdd: IMutationPayload__FLOW_INSTANCE_ADD = { flowInstance, flowEngine: flowInstanceEngine, flowInput };\n\t\t\t\t\tget().addFlowInstance(payloadFlowInstanceAdd);\n\n\t\t\t\t\treturn flowInstance;\n\n\t\t\t\t\t// const { flowInstanceContexts, flowInstancesContainer } = get();\n\t\t\t\t\t// const flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[flowInstanceId];\n\t\t\t\t\t// // const flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\t// // const flow: IFlow = flowStoreProtected.getDomainStore().flows[flowInstance.flowId];\n\t\t\t\t},\n\n\t\t\t\texecuteFlowInstance: async (payload: IActionPayload_ExecuteFlowInstance): Promise<void> => {\n\t\t\t\t},\n\t\t\t\tsetFlowInstanceStatus: async (payload: IActionPayload_FLOW_INSTANCE_SET_STATUS): Promise<EFlowExecutionStatus> => {\n\t\t\t\t\tconst flowInstanceKnodeId: string = payload.flowInstanceKnodeId;\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[setFlowInstanceStatus] setting flow instance status to ${payload.status} for flow instance with ID: ${flowInstanceKnodeId}`);\n\t\t\t\t\tconst { flowInstancesContainer, depersistFlowInstance } = get();\n\t\t\t\t\tif(!(payload.flowInstanceKnodeId in flowInstancesContainer)) {\n\t\t\t\t\t\tconsole.info(`${appNameText}:[getAgentTokenForFlowInstance] flow instance with ID ${payload.flowInstanceKnodeId} not found in the in-memory store. Retrieving it from the persistent store...`);\n\t\t\t\t\t\tawait depersistFlowInstance({ flowInstanceId: payload.flowInstanceKnodeId });\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[payload.flowInstanceKnodeId];\n\t\t\t\t\tif(!flowInstanceContainer) {\n\t\t\t\t\t\tconst errorMsg: string = `Flow instance with ID ${payload.flowInstanceKnodeId} not found in the in-memory store after trying to depersist it.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[getAgentTokenForFlowInstance] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\tconsole.log(`${appNameText}:[setFlowInstanceStatus] flow instance with ID ${flowInstance.id} found in the in-memory store: ${JSON.stringify(flowInstance, null, 4)}`);\n\t\t\t\t\tflowInstance.executionStatus.status = payload.status;\n\t\t\t\t\tget().persistFlowInstance({ flowInstanceId: flowInstance.id });\n\t\t\t\t\treturn flowInstance.executionStatus.status;\n\t\t\t\t},\n\n\t\t\t\tjoinAgentToFlowInstance: async (payload: IActionPayload_JoinFlowInstance): Promise<string> => {\n\t\t\t\t\t// retrieve the necessary data from the store\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer, depersistFlowInstance } = get();\n\t\t\t\t\tif(!(payload.flowInstanceKnodeId in flowInstancesContainer)) {\n\t\t\t\t\t\tconsole.info(`${appNameText}:[joinFlowInstance] flow instance with ID ${payload.flowInstanceKnodeId} not found in the in-memory store. Retrieving it from the persistent store...`);\n\t\t\t\t\t\tawait depersistFlowInstance({ flowInstanceId: payload.flowInstanceKnodeId })\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[payload.flowInstanceKnodeId];\n\t\t\t\t\tif(!flowInstanceContainer) {\n\t\t\t\t\t\tconst errorMsg: string = `Flow instance with ID ${payload.flowInstanceKnodeId} not found in the in-memory store after trying to depersist it.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[joinFlowInstance] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\tconst flowEngine: FlowInstanceEngine<IFlow, IFlowPlace, IFlowTask, IFlowSequence> = flowInstanceContainer.flowInstanceEngine;\n\t\t\t\t\tconst flow: IFlow = await flowEngine.asyncGetFlow();\n\n\t\t\t\t\tlet place: IFlowPlace | undefined;\n\t\t\t\t\tif(payload.placeId) {\n\t\t\t\t\t\t// find the place in the flow based on the placeId\n\t\t\t\t\t\tplace = findPlaceByIdInFlow(flow, payload.placeId);\n\t\t\t\t\t\tassert(place, `Flow place with ID ${payload.placeId} not found in flow with ID ${flow.id}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// get the start event as the joining place to the flow instance\n\t\t\t\t\t\tconst startEvent: IFlowPlace | undefined = getStartEventInFlow(flow);\n\t\t\t\t\t\tassert(startEvent, `Flow start event not found in flow with ID ${flow.id}`);\n\t\t\t\t\t\tplace = startEvent;\n\t\t\t\t\t}\n\n\t\t\t\t\t// create token\n\t\t\t\t\tconst token: IFlowToken = flowEngine.createTokenInPlace(place, payload.whoAmI, payload.agentType, undefined, payload.flowInstanceKnodeId);\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[joinFlowInstance] created token: ${token.id} in place: ${place.id}`);\n\n\t\t\t\t\t// persist token\n\t\t\t\t\tconst tokenKNode: IKNode = tokenPack(token);\n\t\t\t\t\tconsole.log(`${appNameText}:[joinFlowInstance] tokenKNode: ${JSON.stringify(tokenKNode, null, 4)}`);\n\t\t\t\t\tconst createResult: IKNode[] = await flowStoreProtected.kNodeService.create(tokenKNode);\n\t\t\t\t\tif(!createResult || createResult.length !== 1) {\n\t\t\t\t\t\tthrow new Error(\"Token not created\");\n\t\t\t\t\t}\n\t\t\t\t\tconst kNodeFromServer: IKNode = createResult[0];\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[joinFlowInstance] token persisted with flow knode ID: ${kNodeFromServer._id}: ${JSON.stringify(kNodeFromServer, null, 4)}`);\n\t\t\t\t\t// update token id with the knode ID\n\t\t\t\t\ttoken.id = kNodeFromServer._id as string;\n\n\t\t\t\t\t// update flow instance regarding the new token\n\t\t\t\t\tflowInstance.tokens.push(token);\n\t\t\t\t\t// TODO: update flow instance in the store\n\t\t\t\t\tconst flowInstanceKnodeId = get().persistFlowInstance({ flowInstanceId: flowInstance.id });\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[joinFlowInstance] flow instance persisted with flow knode ID: ${flowInstanceKnodeId}: ${JSON.stringify(flowInstance, null, 4)}`);\n\t\t\t\t\treturn kNodeFromServer._id as string;\n\t\t\t\t},\n\n\t\t\t\tgetAgentTokenForFlowInstance: async (payload: IActionPayload_GetAgentTokenForFlowInstance): Promise<IFlowToken | undefined> => {\n\t\t\t\t\t// retrieve the necessary data from the store\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer, depersistFlowInstance } = get();\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[getAgentTokenForFlowInstance] starting...`);\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[getAgentTokenForFlowInstance] flowInstanceKnodeId: ${payload.flowInstanceId}, whoAmI: ${payload.whoAmI}`);\n\t\t\t\t\tif(!(payload.flowInstanceId in flowInstancesContainer)) {\n\t\t\t\t\t\tconsole.info(`${appNameText}:[getAgentTokenForFlowInstance] flow instance with ID ${payload.flowInstanceId} not found in the in-memory store. Retrieving it from the persistent store...`);\n\t\t\t\t\t\tawait depersistFlowInstance({ flowInstanceId: payload.flowInstanceId });\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[payload.flowInstanceId];\n\t\t\t\t\tif(!flowInstanceContainer) {\n\t\t\t\t\t\tconst errorMsg: string = `Flow instance with ID ${payload.flowInstanceId} not found in the in-memory store after trying to depersist it.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[getAgentTokenForFlowInstance] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\t// check if the token is in the flow instance\n\t\t\t\t\tconst token: IFlowToken | undefined = flowInstance.tokens.find((token: IFlowToken) => token.whoAmI === payload.whoAmI);\n\t\t\t\t\tif(token) {\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[getAgentTokenForFlowInstance] token found in flow instance with ID ${flowInstance.id}: ${JSON.stringify(token, null, 4)}`);\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[getAgentTokenForFlowInstance] token not found in flow instance with ID ${flowInstance.id}`);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tloadToken: async (tokenKnodeId: string): Promise<IFlowToken> => {\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadToken] loading token with ID: ${tokenKnodeId}`);\n\t\t\t\t\tconst tokenKNode: IKNode = await flowStoreProtected.kNodeService.getById(tokenKnodeId);\n\t\t\t\t\tif(!tokenKNode) {\n\t\t\t\t\t\tthrow new Error(\"Token not found\");\n\t\t\t\t\t}\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadToken] token retrieved from store with ID: ${tokenKNode._id}: ${JSON.stringify(tokenKNode, null, 4)}`);\n\t\t\t\t\tconst token: IFlowToken = tokenUnpack(tokenKNode);\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadToken] token unpacked from kNode with ID: ${tokenKNode._id}: ${JSON.stringify(token, null, 4)}`);\n\t\t\t\t\treturn token;\n\t\t\t\t},\n\t\t\t\tloadTokens: async (payload: IActionPayload_LoadTokens): Promise<IFlowToken[]> => {\n\t\t\t\t\t// retrieve the necessary data from the store\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer, depersistFlowInstance } = get();\n\t\t\t\t\tif(!(payload.flowInstanceKnodeId in flowInstancesContainer)) {\n\t\t\t\t\t\tconsole.info(`${appNameText}:[joinFlowInstance] flow instance with ID ${payload.flowInstanceKnodeId} not found in the in-memory store. Retrieving it from the persistent store...`);\n\t\t\t\t\t\tawait depersistFlowInstance({ flowInstanceId: payload.flowInstanceKnodeId })\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[payload.flowInstanceKnodeId];\n\t\t\t\t\tif(!flowInstanceContainer) {\n\t\t\t\t\t\tconst errorMsg: string = `Flow instance with ID ${payload.flowInstanceKnodeId} not found in the in-memory store after trying to depersist it.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[joinFlowInstance] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\tconst tokens: IFlowToken[] = flowInstance.tokens;\n\t\t\t\t\tconst tokensReduced: any[] = tokens.map((token: IFlowToken) => {\n\t\t\t\t\t\tconst tokenReduced: any = {\n\t\t\t\t\t\t\tid: token.id,\n\t\t\t\t\t\t\twhoAmI: token.whoAmI,\n\t\t\t\t\t\t\tagentType: token.agentType,\n\t\t\t\t\t\t\tplaceId: token.placeId,\n\t\t\t\t\t\t\tdataEntryReferencesNo: token.dataEntryReferences.length,\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn tokenReduced;\n\t\t\t\t\t});\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[loadTokens] tokens loaded from flow instance with ID ${flowInstance.id}: ${JSON.stringify(tokensReduced, null, 4)}`);\n\t\t\t\t\treturn tokens;\n\t\t\t\t},\n\t\t\t\tmoveToken: async (payload: IActionPayload_MoveTokenToPlace): Promise<IFlowToken> => {\n\t\t\t\t\t// load token\n\t\t\t\t\t// TODO: This should be optimised to use in-memory store and token directly from the corresponding flow instance\n\t\t\t\t\t// NOW we need it just to get the flow instance ID :(\n\t\t\t\t\tconst tokenId: string = payload.tokenId;\n\t\t\t\t\tconst tokenTemp: IFlowToken = await get().loadToken(tokenId);\n\t\t\t\t\t\t\t\t\t\t// retrieve the necessary data from the store\n\t\t\t\t\tconst flowInstanceId: string = tokenTemp.flowInstanceId;\n\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer, depersistFlowInstance } = get();\n\t\t\t\t\tif(!(flowInstanceId in flowInstancesContainer)) {\n\t\t\t\t\t\tconsole.info(`${appNameText}:[joinFlowInstance] flow instance with ID ${flowInstanceId} not found in the in-memory store. Retrieving it from the persistent store...`);\n\t\t\t\t\t\tawait depersistFlowInstance({ flowInstanceId: flowInstanceId })\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[flowInstanceId];\n\t\t\t\t\tif(!flowInstanceContainer) {\n\t\t\t\t\t\tconst errorMsg: string = `Flow instance with ID ${flowInstanceId} not found in the in-memory store after trying to depersist it.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[joinFlowInstance] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\tconst flowEngine: FlowInstanceEngine<IFlow, IFlowPlace, IFlowTask, IFlowSequence> = flowInstanceContainer.flowInstanceEngine;\n\t\t\t\t\tconst flow: IFlow = await flowEngine.asyncGetFlow();\n\t\t\t\t\tconst tokens: IFlowToken[] = flowInstance.tokens;\n\n\t\t\t\t\t// find the token to move\n\t\t\t\t\tconst token: IFlowToken | undefined = tokens.find((token: IFlowToken) => token.id === payload.tokenId);\n\t\t\t\t\tif(!token) {\n\t\t\t\t\t\tconst errorMsg: string = `Token with ID ${payload.tokenId} not found in flow instance with ID ${flowInstance.id}.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[moveToken] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\n\t\t\t\t\t// move the token to the new place\n\t\t\t\t\tconst newPlaceId: string = payload.placeId;\n\t\t\t\t\tconst place: IFlowPlace | undefined = findPlaceByIdInFlow(flow, newPlaceId);\n\t\t\t\t\tif(!place) {\n\t\t\t\t\t\tconst errorMsg: string = `Place with ID ${newPlaceId} not found in flow with ID ${flow.id}.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[moveToken] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\n\t\t\t\t\t// update the token's place\n\t\t\t\t\ttoken.placeId = newPlaceId;\n\n\t\t\t\t\t// persist the token\n\t\t\t\t\tconst tokenKNode: IKNode = tokenPack(token);\n\n\t\t\t\t\tconst updateRequest: IApiRequest = {\n\t\t\t\t\t\ttype: KNODE_API_TYPE.UPDATE_COLABO_API,\n\t\t\t\t\t\t\tparamsDetailed: {\n\t\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t\tpath: \"_id\",\n\t\t\t\t\t\t\t\t\tvalue: token.id,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdata: tokenKNode,\n\t\t\t\t\t};\n\t\t\t\t\tconst kNodeFromServer: IKNode = await flowStoreProtected.kNodeService.updateSingleWithColaboApi(updateRequest);\n\t\t\t\t\tif(!kNodeFromServer) {\n\t\t\t\t\t\tthrow new Error(\"Token not updated\");\n\t\t\t\t\t}\n\n\t\t\t\t\t// TODO: create new place instance, etc\n\t\t\t\t\t// follow the `progressTokenToNextPlace` method in the FlowInstanceEngine class (flow-instance-engine.ts)\n\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[moveToken] token moved in flow instance with ID ${flowInstance.id} to placeId: ${newPlaceId}`);\n\t\t\t\t\treturn token;\n\t\t\t\t},\n\t\t\t\tmoveAllTokens: async (payload: IActionPayload_MoveAllTokensToPlace): Promise<IFlowToken[]> => {\n\t\t\t\t\t// retrieve the necessary data from the store\n\t\t\t\t\tconst { flowInstanceContexts, flowInstancesContainer, depersistFlowInstance } = get();\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[moveAllTokens] starting...`);\n\t\t\t\t\tif(DEBUG) console.log(`${appNameText}:[moveAllTokens] flowInstanceId: ${payload.flowInstanceId}, placeId: ${payload.placeId}`);\n\t\t\t\t\tif(!(payload.flowInstanceId in flowInstancesContainer)) {\n\t\t\t\t\t\tconsole.info(`${appNameText}:[moveAllTokens] flow instance with ID ${payload.flowInstanceId} not found in the in-memory store. Retrieving it from the persistent store...`);\n\t\t\t\t\t\tawait depersistFlowInstance({ flowInstanceId: payload.flowInstanceId });\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstanceContainer: IFlowInstanceContainer = flowInstancesContainer[payload.flowInstanceId];\n\t\t\t\t\tif(!flowInstanceContainer) {\n\t\t\t\t\t\tconst errorMsg: string = `Flow instance with ID ${payload.flowInstanceId} not found in the in-memory store after trying to depersist it.`;\n\t\t\t\t\t\tconsole.error(`${appNameText}:[moveAllTokens] ${errorMsg}`);\n\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t}\n\t\t\t\t\tconst flowInstance: IFlowInstance = flowInstanceContainer.flowInstance;\n\t\t\t\t\tconst flowEngine: FlowInstanceEngine<IFlow, IFlowPlace, IFlowTask, IFlowSequence> = flowInstanceContainer.flowInstanceEngine;\n\t\t\t\t\tconst flow: IFlow = await flowEngine.asyncGetFlow();\n\n\t\t\t\t\tconst tokens: IFlowToken[] = flowInstance.tokens;\n\n\t\t\t\t\tfor (const token of tokens) {\n\t\t\t\t\t\t// move the token to the new place\n\t\t\t\t\t\tconst newPlaceId: string = payload.placeId;\n\t\t\t\t\t\tconst place: IFlowPlace | undefined = findPlaceByIdInFlow(flow, newPlaceId);\n\t\t\t\t\t\tif(!place) {\n\t\t\t\t\t\t\tconst errorMsg: string = `Place with ID ${newPlaceId} not found in flow with ID ${flow.id}.`;\n\t\t\t\t\t\t\tconsole.error(`${appNameText}:[moveAllTokens] ${errorMsg}`);\n\t\t\t\t\t\t\treturn Promise.reject(new Error(errorMsg));\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// update the token's place\n\t\t\t\t\t\ttoken.placeId = newPlaceId;\n\n\t\t\t\t\t\t// persist the token\n\t\t\t\t\t\tconst tokenKNode: IKNode = tokenPack(token);\n\n\t\t\t\t\t\tconst updateRequest: IApiRequest = {\n\t\t\t\t\t\t\ttype: KNODE_API_TYPE.UPDATE_COLABO_API,\n\t\t\t\t\t\t\t\tparamsDetailed: {\n\t\t\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t\t\tpath: \"_id\",\n\t\t\t\t\t\t\t\t\t\tvalue: token.id,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdata: tokenKNode,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst kNodeFromServer: IKNode = await flowStoreProtected.kNodeService.updateSingleWithColaboApi(updateRequest);\n\t\t\t\t\t\tif(!kNodeFromServer) {\n\t\t\t\t\t\t\tthrow new Error(\"Token not updated\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn tokens;\n\t\t\t\t},\n\t\t\t};\n\t\t\treturn storeObj;\n\t\t});\n\t}\n\n\tconst storeState: IFlowFlowchestratorStore = _store.getState();\n\treturn storeState;\n}", "const DEBUG: boolean = true;\nconst DEBUG_VERBOSE: boolean = false;\n\nimport chalk from 'chalk'\nimport { StoreApi, UseBoundStore } from \"zustand\";\n\nimport { ColaboKnAllEdgeContainerService } from \"@colabo-knalledge/i-core-services\";\nimport { ColaboKnAllEdgeNodeService } from \"@colabo-knalledge/i-core-services\";\nimport { ColaboKnAllEdgeNodeServiceExtended } from \"@colabo-knalledge/i-core-services\";\n\nimport { KNodeFrontend, KEdgeIsomorphic, IKNode, IApiRequest, KEDGE_API_TYPE } from \"@colabo-knalledge/i-core\";\nimport { HttpClient, UtilsNotificationService } from \"@colabo-headless/i-core\";\nimport { flowUnpack, IFlowInstance, KFlowTypes } from \"@colabo-flow/i-core\";\n\nimport { IFlowFlowchestratorStore, useFlowFlowchestratorStore } from \"./flowchestrator.store\";\nimport { createBaseStore } from \"@colabo-utils/i-store\";\nimport { IFlow, IMutationPayload__FLOW_INSTANCE_ADD } from '@colabo-flow/i-core';\nimport { assert } from '@colabo-utils/i-verify';\n\nexport interface IFlowState {\n\t/** \n\t * All available flows\n\t */\n\tflows: Record<string, IFlow>;\n};\n\n/**\n * Interface describing the flow store modules\n */\nexport interface IFlowStoreModules {\n\t// sub-domains stores\n\tmodules: {\n\t\tflowchestrator: IFlowFlowchestratorStore;\n\t};\n};\n\n/**\n * Interface describing the flow store mutations\n */\nexport interface IFlowStoreMutations {\n\taddFlow: (flow: IFlow) => void;\n\tgetFlow: (flowId: string) => IFlow | undefined;\n};\n\n/**\n * Interface describing the flow store actions\n */\nexport interface IFlowActions {\n\tloadFlow: (flowId: string) => Promise<IFlow>;\n\t/**\n\t * Loads all flows from the persistent store into the flow store.\n\t * @returns List of flows as JSON\n\t */\n\tloadFlows: () => Promise<IFlow[]>;\n};\n\n/**\n * Flow store interface containing all the store's aspects (state, modules, mutation, and actions)\n */\nexport type IFlowStore = IFlowState & IFlowStoreMutations & IFlowActions & IFlowStoreModules;\n\nlet appNameText: string = \"ColaboFlow.Go.Store\";\n\n/**\n * Flow Store singleton\n */\nlet _store: StoreApi<IFlowStore> | undefined;\n\n/** Default Knode Service singleton. */\nlet defaultKNodeServiceSingleton: ColaboKnAllEdgeNodeServiceExtended | undefined;\n\nfunction getDefaultKNodeService(): ColaboKnAllEdgeNodeServiceExtended {\n if (!defaultKNodeServiceSingleton) {\n defaultKNodeServiceSingleton = new ColaboKnAllEdgeNodeServiceExtended(\n (null as unknown) as HttpClient,\n (null as unknown) as UtilsNotificationService\n );\n }\n return defaultKNodeServiceSingleton;\n}\n\n/** External initialization interface for the flow store */\nexport interface UseFlowStoreOptions {\n\tappNameText: string;\n\tkNodeService?: ColaboKnAllEdgeNodeServiceExtended;\n\tuseDefaultKNodeService?: boolean;\n}\n\n/** Interface that describes all the protected props of the domain store (Flow) that should be shared with sub-domain stores */\nexport interface IFlowStoreProtected {\n\tappNameText: string;\n\tkNodeService: ColaboKnAllEdgeNodeServiceExtended;\n\tgetDomainStore: () => IFlowStore;\n}\n/**\n * Returns the Flow store either creating it if not created or just passing the previously created one\n * @param _appNameText the app name text that will be used for logging\n * @returns Flow store\n */\nexport const useFlowStore = (options: UseFlowStoreOptions): IFlowStore => {\n\tconst { appNameText: _appNameText, kNodeService: injectedKNodeService } = options;\n\tappNameText = `${_appNameText}:[${chalk.bold.yellow(\"STORE\")}]`;\n\n\tif (!_store) {\n\t\tif (!options.kNodeService && !options.useDefaultKNodeService) {\n\t\t\tthrow new Error(\n\t\t\t\t`${appNameText} useFlowStore: Missing kNodeService and useDefaultKNodeService not set`\n\t\t\t);\n\t\t}\n\n\t\t// Create the KNode service\n\t\t// If a kNodeService is provided, use it\n\t\t// It is shared with all the sub-domain stores\n\t\tconst kNodeService = options.useDefaultKNodeService ? getDefaultKNodeService() : options.kNodeService;\n\t\tassert(kNodeService, \"[] KNode service is not initialized\");\n\n\t\tconst _getDomainStore = (): IFlowStore => {\n\t\t\tassert(_store, `${appNameText} Flow Store is not initialized`);\n\t\t\treturn _store?.getState();\n\t\t}\n\n\t\tconst flowStoreProtected: IFlowStoreProtected = {\n\t\t\tappNameText: _appNameText,\n\t\t\tkNodeService: kNodeService,\n\t\t\tgetDomainStore: _getDomainStore,\n\t\t}\n\n\t\t_store = createBaseStore((set, _get) => {\n\t\t\tconst get = (): IFlowStore => {\n\t\t\t\treturn _get();\n\t\t\t};\n\t\t\tconst storeObj: IFlowStore = {\n\t\t\t\t// state\n\t\t\t\t// ========================\n\t\t\t\tflows: {},\n\n\t\t\t\t// modules\n\t\t\t\t// ========================\n\t\t\t\tmodules: {\n\t\t\t\t\tflowchestrator: useFlowFlowchestratorStore(flowStoreProtected),\n\t\t\t\t},\n\n\t\t\t\t// mutations\n\t\t\t\t// ========================\n\t\t\t\tgetFlow: (flowId: string): IFlow | undefined => {\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[getFlow] Getting flow: ${flowId}`);\n\t\t\t\t\tconst { flows } = get();\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[getFlow] store.flows: ${Object.keys(flows)}`);\n\t\t\t\t\tconst flow = flows[flowId];\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[getFlow] Flow found: ${flow ? flow.id : \"undefined\"}`);\n\t\t\t\t\treturn flow;\n\t\t\t\t},\n\t\t\t\taddFlow: (flow: IFlow) => {\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[addFlow] Adding flow: ${flow.id}`);\n\t\t\t\t\tset((state) => ({\n\t\t\t\t\t\tflows: {\n\t\t\t\t\t\t\t...state.flows,\n\t\t\t\t\t\t\t[flow.id]: flow,\n\t\t\t\t\t\t},\n\t\t\t\t\t}));\n\t\t\t\t\tconst { flows } = get();\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[addFlow] store.flows: ${Object.keys(flows)}`);\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[addFlow] Flow added: ${flow.id}`);\n\t\t\t\t},\n\n\t\t\t\t// actions\n\t\t\t\t// ========================\n\t\t\t\tloadFlow: async (flowId: string): Promise<IFlow> => {\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[loadFlow] Loading flow: ${flowId}`);\n\t\t\t\t\tconst flowKNode: IKNode = await kNodeService.getById(flowId);\n\t\t\t\t\tif (DEBUG_VERBOSE) console.log(`${appNameText} flowKNode: ${JSON.stringify(flowKNode, null, 4)}`);\n\t\t\t\t\tconst flow = flowUnpack(flowKNode);\n\t\t\t\t\tif (DEBUG_VERBOSE) console.log(`${appNameText} flow: ${JSON.stringify(flow, null, 4)}`);\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[loadFlow] Flow loaded: ${flow.id}`);\n\t\t\t\t\tget().addFlow(flow);\n\t\t\t\t\treturn flow;\n\t\t\t\t},\n\t\t\t\tloadFlows: async (): Promise<IFlow[]> => {\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[loadFlows] Loading flows`);\n\t\t\t\t\tconst request: IApiRequest = {\n\t\t\t\t\t\ttype: KEDGE_API_TYPE.INDEX_COLABO_API,\n\t\t\t\t\t\tparamsDetailed: {\n\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\tpath: \"type\",\n\t\t\t\t\t\t\t\tvalue: KFlowTypes.FLOW,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tconst flowsKNode: IKNode[] = await kNodeService.getVosWithColaboApi(request);\n\t\t\t\t\tconst flows: IFlow[] = flowsKNode.map((flowKNode) => {\n\t\t\t\t\t\tconst flow = flowUnpack(flowKNode);\n\t\t\t\t\t\treturn flow;\n\t\t\t\t\t});\n\t\t\t\t\tconst flowNames: string[] = flows.map((flow) => flow.name ?? flow.id);\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[loadFlows] Flows loaded: ${JSON.stringify(flowNames, null, 4)}`);\n\n\t\t\t\t\t// Add flows to the store\n\t\t\t\t\tflows.forEach((flow) => {\n\t\t\t\t\t\tget().addFlow(flow);\n\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif (DEBUG) console.log(`${appNameText}:[loadFlows] Flows added to the in-memory store`);\n\t\t\t\t\treturn flows;\n\t\t\t\t},\n\t\t\t};\n\t\t\treturn storeObj;\n\t\t});\n\t}\n\n\t// WARNING: This is a snapshot of the store (state), NOT the store itself\n\t// this means, if we change the store, this will not be updated\n\t// so we need to call `useFlowStore` again or use the `store.getState()` to get the latest state\n\tconst storeState: IFlowStore = _store.getState();\n\treturn storeState;\n};", "import { IFlowStore, useFlowStore, UseFlowStoreOptions } from \"./flow.store\";\n// import { useDocumentStore } from \"@/store/documentStore\";\nimport { createBaseStore } from \"@colabo-utils/i-store\";\nimport { IFlowFlowchestratorStore } from \"./flowchestrator.store\";\nimport { StoreApi } from \"zustand\";\nimport { ColaboKnAllEdgeNodeServiceExtended } from \"@colabo-knalledge/i-core-services\";\nimport { HttpClient, UtilsNotificationService } from \"@colabo-headless/i-core\";\n\nexport interface IGlobalState {\n\t/**\n\t * The version of the app\n\t */\n\tappVersion: string;\n}\n\n/**\n * Interface describing the flow store modules\n */\nexport interface IGlobalStoreModules {\n\t// domains stores\n\tmodules: {\n\t\tflow: IFlowStore;\n\t}\n};\n\n/**\n * Interface describing the global store mutations\n */\nexport interface IGlobalStoreMutations {\n};\n\n/**\n * Interface describing the global store actions\n */\nexport interface IGlobalActions {\n};\n\n/**\n * Global store interface containing all the store's aspects (state, modules, mutation, and actions)\n */\nexport type IGlobalStore = IGlobalState & IGlobalStoreModules & IGlobalStoreMutations & IGlobalActions;\n\n/**\n * Global Store singleton\n */\nlet _store: StoreApi<IGlobalStore> | undefined;\n\n/** External initialization interface for the flow store */\nexport interface UseGlobalStoreOptions {\n\tappNameText: string;\n\tkNodeService?: ColaboKnAllEdgeNodeServiceExtended;\n\tuseDefaultKNodeService?: boolean;\n}\n\n/** Default Knode Service singleton. */\nlet defaultKNodeServiceSingleton: ColaboKnAllEdgeNodeServiceExtended | undefined;\n\nfunction getDefaultKNodeService(): ColaboKnAllEdgeNodeServiceExtended {\n if (!defaultKNodeServiceSingleton) {\n\tdefaultKNodeServiceSingleton = new ColaboKnAllEdgeNodeServiceExtended(\n\t (null as unknown) as HttpClient,\n\t (null as unknown) as UtilsNotificationService\n\t);\n }\n return defaultKNodeServiceSingleton;\n}\n\n/**\n * Returns the global store either creating it if not created or just passing the previously created one\n * @param _appNameText the app name text that will be used for logging\n * @returns global store\n */\nexport const useGlobalStore = (options: UseGlobalStoreOptions): IGlobalStore => {\n\tif(!_store) {\n\t\tconst useFlowStoreOptions: UseFlowStoreOptions = {\n\t\t\tappNameText: options.appNameText,\n\t\t\tkNodeService: options.kNodeService ? options.kNodeService : getDefaultKNodeService(),\n\t\t\tuseDefaultKNodeService: options.useDefaultKNodeService,\n\t\t}; \n\t\t_store = createBaseStore((set, _get) => {\n\t\tconst get = (): IGlobalStore => {\n\t\t\treturn _get();\n\t\t};\n\t\tconst storeObj: IGlobalStore = {\n\t\t\t// state\n\t\t\t// ========================\n\t\t\tappVersion: \"1.0.0\",\n\n\t\t\t// modules\n\t\t\t// ========================\n\t\t\tmodules: {\n\t\t\t\tflow: useFlowStore(useFlowStoreOptions),\n\t\t\t\t// documents: useDocumentStore(),\n\t\t\t},\n\n\t\t\t// mutations\n\t\t\t// ========================\n\n\t\t\t// actions\n\t\t\t// ========================\n\t\t};\n\t\treturn storeObj;\n\t\t});\n\t}\n\tconst storeState: IGlobalStore = _store.getState();\n\treturn storeState;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAE,QAAQ,IAAI;AAAA,YACnB;AAAA,UACA;AACA,cAAIG,OAAO,SAAQ,IAAI,GAAGH,YAAW,iDAAiD;AACtF,iBAAO;AAAA,QACR;AAAA,MACD;AACA,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAKA,QAAM,aAAyBC,QAAO,SAAS;AAC/C,SAAO;AACR;;;ACpNA,IAAAI,kBAAgC;AAGhC,IAAAC,0BAAmD;AAwCnD,IAAIC;AAUJ,IAAIC;AAEJ,SAASC,0BAA6D;AACpE,MAAI,CAACD,+BAA8B;AACpC,IAAAA,gCAA+B,IAAI;AAAA,MAChC;AAAA,MACA;AAAA,IACH;AAAA,EACC;AACA,SAAOA;AACT;AAOO,IAAM,iBAAkB,CAAC,YAAiD;AAChF,MAAG,CAACD,SAAQ;AACX,UAAM,sBAA2C;AAAA,MAChD,aAAa,QAAQ;AAAA,MACrB,cAAc,QAAQ,eAAe,QAAQ,eAAeE,wBAAuB;AAAA,MACnF,wBAAwB,QAAQ;AAAA,IACjC;AACA,IAAAF,cAAS,iCAAgB,CAAC,KAAK,SAAS;AACxC,YAAM,MAAM,MAAoB;AAC/B,eAAO,KAAK;AAAA,MACb;AACA,YAAM,WAAyB;AAAA;AAAA;AAAA,QAG9B,YAAY;AAAA;AAAA;AAAA,QAIZ,SAAS;AAAA,UACR,MAAM,aAAa,mBAAmB;AAAA;AAAA,QAEvC;AAAA;AAAA;AAAA;AAAA;AAAA,MAOD;AACA,aAAO;AAAA,IACP,CAAC;AAAA,EACF;AACA,QAAM,aAA2BA,QAAO,SAAS;AACjD,SAAO;AACR;;;AV9FO,IAAM,mBAAmB,MAAc;AAC7C,aAAO,8CAA2B;AACnC;",
|
|
6
|
+
"names": ["uuidv1", "EColaboFlowGoMsgType", "EProgrammingLanguageSupported", "ETaskExecute_Progress_Status", "chalk", "uuidv1", "import_amqplib", "import_chalk", "chalk", "isAmqpDebugEnabled", "parsePositiveInt", "MINIMUM_FRAME_MAX", "formatError", "logAmqpUrlDetails", "getEffectiveAmqpUrl", "attachConnectionDebugHandlers", "attachChannelDebugHandlers", "getConnectSocketOptions", "uuidv1", "import_amqplib", "import_chalk", "import_i_core", "hostRegisterTaskExecutor", "hostRegisterTask", "MINIMUM_FRAME_MAX", "isAmqpDebugEnabled", "parsePositiveInt", "formatError", "logAmqpUrlDetails", "getEffectiveAmqpUrl", "getConnectSocketOptions", "attachConnectionDebugHandlers", "attachChannelDebugHandlers", "chalk", "asyncProcessColaboFlowMsg_TaskExecute", "uuidv1", "import_chalk", "import_i_core", "import_i_verify", "appNameText", "chalk", "token", "import_chalk", "import_i_core", "import_i_store", "import_i_verify", "DEBUG", "DEBUG_VERBOSE", "appNameText", "_store", "chalk", "DEBUG", "DEBUG_VERBOSE", "import_i_store", "import_i_core_services", "_store", "defaultKNodeServiceSingleton", "getDefaultKNodeService"]
|
|
7
|
+
}
|