@minded-ai/mindedjs 1.0.0-ec2-beta-1
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/README.md +6 -0
- package/dist/agent.d.ts +256 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +896 -0
- package/dist/agent.js.map +1 -0
- package/dist/browserTask/README.md +419 -0
- package/dist/browserTask/browserAgent.py +632 -0
- package/dist/browserTask/captcha_isolated.png +0 -0
- package/dist/browserTask/executeBrowserTask.d.ts +14 -0
- package/dist/browserTask/executeBrowserTask.d.ts.map +1 -0
- package/dist/browserTask/executeBrowserTask.js +195 -0
- package/dist/browserTask/executeBrowserTask.js.map +1 -0
- package/dist/browserTask/executeBrowserTask.py +153 -0
- package/dist/browserTask/executeBrowserTask.ts +79 -0
- package/dist/browserTask/localBrowserTask.d.ts +49 -0
- package/dist/browserTask/localBrowserTask.d.ts.map +1 -0
- package/dist/browserTask/localBrowserTask.js +284 -0
- package/dist/browserTask/localBrowserTask.js.map +1 -0
- package/dist/browserTask/requirements.txt +8 -0
- package/dist/browserTask/setup.sh +144 -0
- package/dist/browserTask/types.d.ts +35 -0
- package/dist/browserTask/types.d.ts.map +1 -0
- package/dist/browserTask/types.js +10 -0
- package/dist/browserTask/types.js.map +1 -0
- package/dist/checkpointer/checkpointSaverFactory.d.ts +7 -0
- package/dist/checkpointer/checkpointSaverFactory.d.ts.map +1 -0
- package/dist/checkpointer/checkpointSaverFactory.js +53 -0
- package/dist/checkpointer/checkpointSaverFactory.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +209 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/lambdaHandlerTemplate.d.ts +10 -0
- package/dist/cli/lambdaHandlerTemplate.d.ts.map +1 -0
- package/dist/cli/lambdaHandlerTemplate.js +76 -0
- package/dist/cli/lambdaHandlerTemplate.js.map +1 -0
- package/dist/cli/lambdaHandlerTemplate.ts +78 -0
- package/dist/cli/localOperatorSetup.d.ts +6 -0
- package/dist/cli/localOperatorSetup.d.ts.map +1 -0
- package/dist/cli/localOperatorSetup.js +310 -0
- package/dist/cli/localOperatorSetup.js.map +1 -0
- package/dist/debugging/index.d.ts +2 -0
- package/dist/debugging/index.d.ts.map +1 -0
- package/dist/debugging/index.js +6 -0
- package/dist/debugging/index.js.map +1 -0
- package/dist/debugging/llmCallbackHandler.d.ts +36 -0
- package/dist/debugging/llmCallbackHandler.d.ts.map +1 -0
- package/dist/debugging/llmCallbackHandler.js +101 -0
- package/dist/debugging/llmCallbackHandler.js.map +1 -0
- package/dist/edges/createDirectEdge.d.ts +4 -0
- package/dist/edges/createDirectEdge.d.ts.map +1 -0
- package/dist/edges/createDirectEdge.js +24 -0
- package/dist/edges/createDirectEdge.js.map +1 -0
- package/dist/edges/createLogicalRouter.d.ts +8 -0
- package/dist/edges/createLogicalRouter.d.ts.map +1 -0
- package/dist/edges/createLogicalRouter.js +194 -0
- package/dist/edges/createLogicalRouter.js.map +1 -0
- package/dist/edges/createPromptRouter.d.ts +12 -0
- package/dist/edges/createPromptRouter.d.ts.map +1 -0
- package/dist/edges/createPromptRouter.js +176 -0
- package/dist/edges/createPromptRouter.js.map +1 -0
- package/dist/edges/edgeFactory.d.ts +14 -0
- package/dist/edges/edgeFactory.d.ts.map +1 -0
- package/dist/edges/edgeFactory.js +125 -0
- package/dist/edges/edgeFactory.js.map +1 -0
- package/dist/events/AgentEvents.d.ts +56 -0
- package/dist/events/AgentEvents.d.ts.map +1 -0
- package/dist/events/AgentEvents.js +13 -0
- package/dist/events/AgentEvents.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +5 -0
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/zendesk.d.ts +35 -0
- package/dist/interfaces/zendesk.d.ts.map +1 -0
- package/dist/interfaces/zendesk.js +219 -0
- package/dist/interfaces/zendesk.js.map +1 -0
- package/dist/internalTools/appActionRunnerTool.d.ts +5 -0
- package/dist/internalTools/appActionRunnerTool.d.ts.map +1 -0
- package/dist/internalTools/appActionRunnerTool.js +88 -0
- package/dist/internalTools/appActionRunnerTool.js.map +1 -0
- package/dist/internalTools/documentExtraction/documentExtraction.d.ts +129 -0
- package/dist/internalTools/documentExtraction/documentExtraction.d.ts.map +1 -0
- package/dist/internalTools/documentExtraction/documentExtraction.js +736 -0
- package/dist/internalTools/documentExtraction/documentExtraction.js.map +1 -0
- package/dist/internalTools/documentExtraction/types.d.ts +29 -0
- package/dist/internalTools/documentExtraction/types.d.ts.map +1 -0
- package/dist/internalTools/documentExtraction/types.js +35 -0
- package/dist/internalTools/documentExtraction/types.js.map +1 -0
- package/dist/internalTools/libraryActionRunnerTool.d.ts +4 -0
- package/dist/internalTools/libraryActionRunnerTool.d.ts.map +1 -0
- package/dist/internalTools/libraryActionRunnerTool.js +53 -0
- package/dist/internalTools/libraryActionRunnerTool.js.map +1 -0
- package/dist/internalTools/retell.d.ts +12 -0
- package/dist/internalTools/retell.d.ts.map +1 -0
- package/dist/internalTools/retell.js +54 -0
- package/dist/internalTools/retell.js.map +1 -0
- package/dist/internalTools/sendPlaceholderMessage.d.ts +14 -0
- package/dist/internalTools/sendPlaceholderMessage.d.ts.map +1 -0
- package/dist/internalTools/sendPlaceholderMessage.js +61 -0
- package/dist/internalTools/sendPlaceholderMessage.js.map +1 -0
- package/dist/internalTools/timer.d.ts +99 -0
- package/dist/internalTools/timer.d.ts.map +1 -0
- package/dist/internalTools/timer.js +139 -0
- package/dist/internalTools/timer.js.map +1 -0
- package/dist/internalTools/voice/escalateVoiceCall.d.ts +2 -0
- package/dist/internalTools/voice/escalateVoiceCall.d.ts.map +1 -0
- package/dist/internalTools/voice/escalateVoiceCall.js +52 -0
- package/dist/internalTools/voice/escalateVoiceCall.js.map +1 -0
- package/dist/internalTools/voice/retell.d.ts +12 -0
- package/dist/internalTools/voice/retell.d.ts.map +1 -0
- package/dist/internalTools/voice/retell.js +54 -0
- package/dist/internalTools/voice/retell.js.map +1 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.d.ts +14 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.d.ts.map +1 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.js +61 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.js.map +1 -0
- package/dist/interrupts/BaseInterruptSessionManager.d.ts +49 -0
- package/dist/interrupts/BaseInterruptSessionManager.d.ts.map +1 -0
- package/dist/interrupts/BaseInterruptSessionManager.js +34 -0
- package/dist/interrupts/BaseInterruptSessionManager.js.map +1 -0
- package/dist/interrupts/MemoryInterruptSessionManager.d.ts +14 -0
- package/dist/interrupts/MemoryInterruptSessionManager.d.ts.map +1 -0
- package/dist/interrupts/MemoryInterruptSessionManager.js +60 -0
- package/dist/interrupts/MemoryInterruptSessionManager.js.map +1 -0
- package/dist/interrupts/MindedInterruptSessionManager.d.ts +13 -0
- package/dist/interrupts/MindedInterruptSessionManager.d.ts.map +1 -0
- package/dist/interrupts/MindedInterruptSessionManager.js +162 -0
- package/dist/interrupts/MindedInterruptSessionManager.js.map +1 -0
- package/dist/interrupts/interruptSessionManagerFactory.d.ts +3 -0
- package/dist/interrupts/interruptSessionManagerFactory.d.ts.map +1 -0
- package/dist/interrupts/interruptSessionManagerFactory.js +56 -0
- package/dist/interrupts/interruptSessionManagerFactory.js.map +1 -0
- package/dist/llm/createLlmInstance.d.ts +3 -0
- package/dist/llm/createLlmInstance.d.ts.map +1 -0
- package/dist/llm/createLlmInstance.js +31 -0
- package/dist/llm/createLlmInstance.js.map +1 -0
- package/dist/nodes/addAppToolNode.d.ts +13 -0
- package/dist/nodes/addAppToolNode.d.ts.map +1 -0
- package/dist/nodes/addAppToolNode.js +87 -0
- package/dist/nodes/addAppToolNode.js.map +1 -0
- package/dist/nodes/addBrowserTaskNode.d.ts +13 -0
- package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -0
- package/dist/nodes/addBrowserTaskNode.js +167 -0
- package/dist/nodes/addBrowserTaskNode.js.map +1 -0
- package/dist/nodes/addBrowserTaskRunNode.d.ts +13 -0
- package/dist/nodes/addBrowserTaskRunNode.d.ts.map +1 -0
- package/dist/nodes/addBrowserTaskRunNode.js +167 -0
- package/dist/nodes/addBrowserTaskRunNode.js.map +1 -0
- package/dist/nodes/addHumanInTheLoopNode.d.ts +9 -0
- package/dist/nodes/addHumanInTheLoopNode.d.ts.map +1 -0
- package/dist/nodes/addHumanInTheLoopNode.js +22 -0
- package/dist/nodes/addHumanInTheLoopNode.js.map +1 -0
- package/dist/nodes/addJumpToNode.d.ts +7 -0
- package/dist/nodes/addJumpToNode.d.ts.map +1 -0
- package/dist/nodes/addJumpToNode.js +24 -0
- package/dist/nodes/addJumpToNode.js.map +1 -0
- package/dist/nodes/addJunctionNode.d.ts +7 -0
- package/dist/nodes/addJunctionNode.d.ts.map +1 -0
- package/dist/nodes/addJunctionNode.js +20 -0
- package/dist/nodes/addJunctionNode.js.map +1 -0
- package/dist/nodes/addPromptNode.d.ts +18 -0
- package/dist/nodes/addPromptNode.d.ts.map +1 -0
- package/dist/nodes/addPromptNode.js +253 -0
- package/dist/nodes/addPromptNode.js.map +1 -0
- package/dist/nodes/addRpaNode.d.ts +18 -0
- package/dist/nodes/addRpaNode.d.ts.map +1 -0
- package/dist/nodes/addRpaNode.js +180 -0
- package/dist/nodes/addRpaNode.js.map +1 -0
- package/dist/nodes/addToolNode.d.ts +13 -0
- package/dist/nodes/addToolNode.d.ts.map +1 -0
- package/dist/nodes/addToolNode.js +67 -0
- package/dist/nodes/addToolNode.js.map +1 -0
- package/dist/nodes/addToolRunNode.d.ts +17 -0
- package/dist/nodes/addToolRunNode.d.ts.map +1 -0
- package/dist/nodes/addToolRunNode.js +59 -0
- package/dist/nodes/addToolRunNode.js.map +1 -0
- package/dist/nodes/addTriggerNode.d.ts +7 -0
- package/dist/nodes/addTriggerNode.d.ts.map +1 -0
- package/dist/nodes/addTriggerNode.js +25 -0
- package/dist/nodes/addTriggerNode.js.map +1 -0
- package/dist/nodes/compilePrompt.d.ts +5 -0
- package/dist/nodes/compilePrompt.d.ts.map +1 -0
- package/dist/nodes/compilePrompt.js +76 -0
- package/dist/nodes/compilePrompt.js.map +1 -0
- package/dist/nodes/nodeFactory.d.ts +16 -0
- package/dist/nodes/nodeFactory.d.ts.map +1 -0
- package/dist/nodes/nodeFactory.js +45 -0
- package/dist/nodes/nodeFactory.js.map +1 -0
- package/dist/nodes/rpaStepsExecutor.d.ts +5 -0
- package/dist/nodes/rpaStepsExecutor.d.ts.map +1 -0
- package/dist/nodes/rpaStepsExecutor.js +156 -0
- package/dist/nodes/rpaStepsExecutor.js.map +1 -0
- package/dist/platform/config.d.ts +16 -0
- package/dist/platform/config.d.ts.map +1 -0
- package/dist/platform/config.js +80 -0
- package/dist/platform/config.js.map +1 -0
- package/dist/platform/mindedCheckpointSaver.d.ts +10 -0
- package/dist/platform/mindedCheckpointSaver.d.ts.map +1 -0
- package/dist/platform/mindedCheckpointSaver.js +137 -0
- package/dist/platform/mindedCheckpointSaver.js.map +1 -0
- package/dist/platform/mindedConnection.d.ts +15 -0
- package/dist/platform/mindedConnection.d.ts.map +1 -0
- package/dist/platform/mindedConnection.js +254 -0
- package/dist/platform/mindedConnection.js.map +1 -0
- package/dist/platform/mindedConnectionTypes.d.ts +404 -0
- package/dist/platform/mindedConnectionTypes.d.ts.map +1 -0
- package/dist/platform/mindedConnectionTypes.js +51 -0
- package/dist/platform/mindedConnectionTypes.js.map +1 -0
- package/dist/platform/models/mindedChatOpenAI.d.ts +20 -0
- package/dist/platform/models/mindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/models/mindedChatOpenAI.js +32 -0
- package/dist/platform/models/mindedChatOpenAI.js.map +1 -0
- package/dist/platform/models/parallelWrapper.d.ts +17 -0
- package/dist/platform/models/parallelWrapper.d.ts.map +1 -0
- package/dist/platform/models/parallelWrapper.js +105 -0
- package/dist/platform/models/parallelWrapper.js.map +1 -0
- package/dist/platform/piiGateway/gateway.d.ts +14 -0
- package/dist/platform/piiGateway/gateway.d.ts.map +1 -0
- package/dist/platform/piiGateway/gateway.js +117 -0
- package/dist/platform/piiGateway/gateway.js.map +1 -0
- package/dist/platform/piiGateway/index.d.ts +3 -0
- package/dist/platform/piiGateway/index.d.ts.map +1 -0
- package/dist/platform/piiGateway/index.js +7 -0
- package/dist/platform/piiGateway/index.js.map +1 -0
- package/dist/platform/piiGateway/types.d.ts +27 -0
- package/dist/platform/piiGateway/types.d.ts.map +1 -0
- package/dist/platform/piiGateway/types.js +3 -0
- package/dist/platform/piiGateway/types.js.map +1 -0
- package/dist/platform/toolExecutor.d.ts +29 -0
- package/dist/platform/toolExecutor.d.ts.map +1 -0
- package/dist/platform/toolExecutor.js +84 -0
- package/dist/platform/toolExecutor.js.map +1 -0
- package/dist/platform/utils/parseAttachments.d.ts +14 -0
- package/dist/platform/utils/parseAttachments.d.ts.map +1 -0
- package/dist/platform/utils/parseAttachments.js +53 -0
- package/dist/platform/utils/parseAttachments.js.map +1 -0
- package/dist/platform/utils/tools.d.ts +6 -0
- package/dist/platform/utils/tools.d.ts.map +1 -0
- package/dist/platform/utils/tools.js +57 -0
- package/dist/platform/utils/tools.js.map +1 -0
- package/dist/playbooks/playbooks.d.ts +15 -0
- package/dist/playbooks/playbooks.d.ts.map +1 -0
- package/dist/playbooks/playbooks.js +208 -0
- package/dist/playbooks/playbooks.js.map +1 -0
- package/dist/toolsLibrary/classifier.d.ts +74 -0
- package/dist/toolsLibrary/classifier.d.ts.map +1 -0
- package/dist/toolsLibrary/classifier.js +256 -0
- package/dist/toolsLibrary/classifier.js.map +1 -0
- package/dist/toolsLibrary/extraction.d.ts +83 -0
- package/dist/toolsLibrary/extraction.d.ts.map +1 -0
- package/dist/toolsLibrary/extraction.js +328 -0
- package/dist/toolsLibrary/extraction.js.map +1 -0
- package/dist/toolsLibrary/index.d.ts +9 -0
- package/dist/toolsLibrary/index.d.ts.map +1 -0
- package/dist/toolsLibrary/index.js +46 -0
- package/dist/toolsLibrary/index.js.map +1 -0
- package/dist/toolsLibrary/parseDocument.d.ts +30 -0
- package/dist/toolsLibrary/parseDocument.d.ts.map +1 -0
- package/dist/toolsLibrary/parseDocument.js +119 -0
- package/dist/toolsLibrary/parseDocument.js.map +1 -0
- package/dist/triggers/triggerTypeToDefaultMessage.d.ts +4 -0
- package/dist/triggers/triggerTypeToDefaultMessage.d.ts.map +1 -0
- package/dist/triggers/triggerTypeToDefaultMessage.js +10 -0
- package/dist/triggers/triggerTypeToDefaultMessage.js.map +1 -0
- package/dist/types/Agent.types.d.ts +60 -0
- package/dist/types/Agent.types.d.ts.map +1 -0
- package/dist/types/Agent.types.js +9 -0
- package/dist/types/Agent.types.js.map +1 -0
- package/dist/types/Flows.types.d.ts +232 -0
- package/dist/types/Flows.types.d.ts.map +1 -0
- package/dist/types/Flows.types.js +65 -0
- package/dist/types/Flows.types.js.map +1 -0
- package/dist/types/LLM.types.d.ts +7 -0
- package/dist/types/LLM.types.d.ts.map +1 -0
- package/dist/types/LLM.types.js +11 -0
- package/dist/types/LLM.types.js.map +1 -0
- package/dist/types/LangGraph.types.d.ts +45 -0
- package/dist/types/LangGraph.types.d.ts.map +1 -0
- package/dist/types/LangGraph.types.js +77 -0
- package/dist/types/LangGraph.types.js.map +1 -0
- package/dist/types/Platform.types.d.ts +7 -0
- package/dist/types/Platform.types.d.ts.map +1 -0
- package/dist/types/Platform.types.js +11 -0
- package/dist/types/Platform.types.js.map +1 -0
- package/dist/types/Tools.types.d.ts +26 -0
- package/dist/types/Tools.types.d.ts.map +1 -0
- package/dist/types/Tools.types.js +3 -0
- package/dist/types/Tools.types.js.map +1 -0
- package/dist/types/Voice.types.d.ts +5 -0
- package/dist/types/Voice.types.d.ts.map +1 -0
- package/dist/types/Voice.types.js +3 -0
- package/dist/types/Voice.types.js.map +1 -0
- package/dist/utils/agentUtils.d.ts +5 -0
- package/dist/utils/agentUtils.d.ts.map +1 -0
- package/dist/utils/agentUtils.js +97 -0
- package/dist/utils/agentUtils.js.map +1 -0
- package/dist/utils/extractStateMemoryResponse.d.ts +5 -0
- package/dist/utils/extractStateMemoryResponse.d.ts.map +1 -0
- package/dist/utils/extractStateMemoryResponse.js +91 -0
- package/dist/utils/extractStateMemoryResponse.js.map +1 -0
- package/dist/utils/history.d.ts +4 -0
- package/dist/utils/history.d.ts.map +1 -0
- package/dist/utils/history.js +33 -0
- package/dist/utils/history.js.map +1 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +39 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/schemaUtils.d.ts +15 -0
- package/dist/utils/schemaUtils.d.ts.map +1 -0
- package/dist/utils/schemaUtils.js +56 -0
- package/dist/utils/schemaUtils.js.map +1 -0
- package/dist/utils/wait.d.ts +2 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +6 -0
- package/dist/utils/wait.js.map +1 -0
- package/dist/voice/elevenLabsUtils.d.ts +65 -0
- package/dist/voice/elevenLabsUtils.d.ts.map +1 -0
- package/dist/voice/elevenLabsUtils.js +4 -0
- package/dist/voice/elevenLabsUtils.js.map +1 -0
- package/dist/voice/voiceSession.d.ts +37 -0
- package/dist/voice/voiceSession.d.ts.map +1 -0
- package/dist/voice/voiceSession.js +306 -0
- package/dist/voice/voiceSession.js.map +1 -0
- package/docs/.gitbook/assets/ADLC.png +0 -0
- package/docs/.gitbook/assets/PII-masking.png +0 -0
- package/docs/.gitbook/assets/image.png +0 -0
- package/docs/.gitbook/assets/on-prem.svg +4 -0
- package/docs/README.md +54 -0
- package/docs/SUMMARY.md +56 -0
- package/docs/examples/order-refund-flow.md +566 -0
- package/docs/getting-started/environment-configuration.md +158 -0
- package/docs/getting-started/installation.md +44 -0
- package/docs/getting-started/project-configuration.md +206 -0
- package/docs/getting-started/quick-start.md +262 -0
- package/docs/integrations/zendesk.md +554 -0
- package/docs/low-code-editor/edges.md +396 -0
- package/docs/low-code-editor/flows.md +74 -0
- package/docs/low-code-editor/nodes.md +367 -0
- package/docs/low-code-editor/playbooks.md +280 -0
- package/docs/low-code-editor/tools.md +358 -0
- package/docs/low-code-editor/triggers.md +182 -0
- package/docs/platform/on-prem.md +182 -0
- package/docs/platform/operator.md +89 -0
- package/docs/platform/pii-masking.md +221 -0
- package/docs/platform/scenarios.md +43 -0
- package/docs/platform/secrets.md +99 -0
- package/docs/platform/sso.md +27 -0
- package/docs/resources/your-first-eval.md +108 -0
- package/docs/sdk/agent-api.md +540 -0
- package/docs/sdk/debugging.md +80 -0
- package/docs/sdk/events.md +595 -0
- package/docs/sdk/logging.md +72 -0
- package/docs/sdk/memory.md +271 -0
- package/docs/sdk/parallel-llm.md +242 -0
- package/docs/sdk/vectorstore-query.md +60 -0
- package/docs/tooling/classifier.md +217 -0
- package/docs/tooling/document-processing.md +389 -0
- package/docs/tooling/extraction.md +78 -0
- package/docs/tooling/timers.md +61 -0
- package/package.json +73 -0
- package/src/agent.ts +1019 -0
- package/src/browserTask/executeBrowserTask.py +153 -0
- package/src/browserTask/executeBrowserTask.ts +253 -0
- package/src/browserTask/localBrowserTask.ts +300 -0
- package/src/browserTask/profile/Default/Extension Rules/000003.log +0 -0
- package/src/browserTask/profile/Default/Extension Scripts/000003.log +0 -0
- package/src/browserTask/profile/Default/Extension State/000003.log +0 -0
- package/src/browserTask/profile/Default/GCM Store/000003.log +0 -0
- package/src/browserTask/profile/Default/Local Storage/leveldb/000004.log +0 -0
- package/src/browserTask/profile/Default/Session Storage/000003.log +0 -0
- package/src/browserTask/profile/Default/Site Characteristics Database/000003.log +0 -0
- package/src/browserTask/profile/Default/Sync Data/LevelDB/000003.log +0 -0
- package/src/browserTask/profile/Default/shared_proto_db/000003.log +0 -0
- package/src/browserTask/profile/Default/shared_proto_db/metadata/000003.log +0 -0
- package/src/browserTask/types.ts +37 -0
- package/src/checkpointer/checkpointSaverFactory.ts +18 -0
- package/src/cli/index.ts +188 -0
- package/src/cli/lambdaHandlerTemplate.ts +78 -0
- package/src/cli/localOperatorSetup.ts +308 -0
- package/src/debugging/index.ts +1 -0
- package/src/debugging/llmCallbackHandler.ts +125 -0
- package/src/edges/createDirectEdge.ts +22 -0
- package/src/edges/createLogicalRouter.ts +182 -0
- package/src/edges/createPromptRouter.ts +213 -0
- package/src/edges/edgeFactory.ts +167 -0
- package/src/events/AgentEvents.ts +58 -0
- package/src/events/index.ts +3 -0
- package/src/index.ts +105 -0
- package/src/interfaces/zendesk.ts +212 -0
- package/src/internalTools/appActionRunnerTool.ts +68 -0
- package/src/internalTools/documentExtraction/documentExtraction.ts +804 -0
- package/src/internalTools/documentExtraction/types.ts +59 -0
- package/src/internalTools/libraryActionRunnerTool.ts +62 -0
- package/src/internalTools/timer.ts +125 -0
- package/src/internalTools/voice/escalateVoiceCall.ts +15 -0
- package/src/internalTools/voice/retell.ts +28 -0
- package/src/internalTools/voice/sendPlaceholderMessage.ts +27 -0
- package/src/interrupts/BaseInterruptSessionManager.ts +80 -0
- package/src/interrupts/MemoryInterruptSessionManager.ts +63 -0
- package/src/interrupts/MindedInterruptSessionManager.ts +163 -0
- package/src/interrupts/interruptSessionManagerFactory.ts +20 -0
- package/src/llm/createLlmInstance.ts +33 -0
- package/src/nodes/addAppToolNode.ts +111 -0
- package/src/nodes/addBrowserTaskNode.ts +191 -0
- package/src/nodes/addBrowserTaskRunNode.ts +190 -0
- package/src/nodes/addHumanInTheLoopNode.ts +26 -0
- package/src/nodes/addJumpToNode.ts +26 -0
- package/src/nodes/addJunctionNode.ts +21 -0
- package/src/nodes/addPromptNode.ts +305 -0
- package/src/nodes/addRpaNode.ts +217 -0
- package/src/nodes/addToolNode.ts +84 -0
- package/src/nodes/addToolRunNode.ts +80 -0
- package/src/nodes/addTriggerNode.ts +27 -0
- package/src/nodes/compilePrompt.ts +44 -0
- package/src/nodes/nodeFactory.ts +61 -0
- package/src/nodes/rpaStepsExecutor.ts +175 -0
- package/src/platform/config.ts +89 -0
- package/src/platform/mindedCheckpointSaver.ts +146 -0
- package/src/platform/mindedConnection.ts +250 -0
- package/src/platform/mindedConnectionTypes.ts +495 -0
- package/src/platform/models/mindedChatOpenAI.ts +49 -0
- package/src/platform/models/parallelWrapper.ts +141 -0
- package/src/platform/piiGateway/gateway.ts +103 -0
- package/src/platform/piiGateway/index.ts +5 -0
- package/src/platform/piiGateway/types.ts +29 -0
- package/src/platform/toolExecutor.ts +106 -0
- package/src/platform/utils/parseAttachments.ts +56 -0
- package/src/platform/utils/tools.ts +55 -0
- package/src/playbooks/playbooks.ts +200 -0
- package/src/toolsLibrary/classifier.ts +326 -0
- package/src/toolsLibrary/extraction.ts +393 -0
- package/src/toolsLibrary/index.ts +10 -0
- package/src/toolsLibrary/parseDocument.ts +129 -0
- package/src/triggers/triggerTypeToDefaultMessage.ts +9 -0
- package/src/types/Agent.types.ts +73 -0
- package/src/types/Flows.types.ts +262 -0
- package/src/types/LLM.types.ts +15 -0
- package/src/types/LangGraph.types.ts +86 -0
- package/src/types/Platform.types.ts +6 -0
- package/src/types/Tools.types.ts +28 -0
- package/src/types/Voice.types.ts +4 -0
- package/src/utils/agentUtils.ts +69 -0
- package/src/utils/history.ts +38 -0
- package/src/utils/logger.ts +38 -0
- package/src/utils/schemaUtils.ts +68 -0
- package/src/utils/wait.ts +1 -0
- package/src/voice/elevenLabsUtils.ts +81 -0
- package/src/voice/voiceSession.ts +309 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createLogicalRouter = void 0;
|
|
37
|
+
const logger_1 = require("../utils/logger");
|
|
38
|
+
const AgentEvents_1 = require("../events/AgentEvents");
|
|
39
|
+
const vm = __importStar(require("vm"));
|
|
40
|
+
// Default timeout for condition evaluation (in milliseconds)
|
|
41
|
+
const CONDITION_TIMEOUT = 5000; // 5 seconds
|
|
42
|
+
const createLogicalRouter = ({ edges, agent }) => {
|
|
43
|
+
return async (state) => {
|
|
44
|
+
logger_1.logger.debug({ msg: `[Router] Evaluating logical conditions for ${edges.length} edges`, sessionId: state.sessionId, edges });
|
|
45
|
+
if (state.goto) {
|
|
46
|
+
logger_1.logger.debug({ msg: `[Router] Jumping to node`, node: state.goto, sessionId: state.sessionId, edges });
|
|
47
|
+
return state.goto;
|
|
48
|
+
}
|
|
49
|
+
// Separate regular conditions from "else" conditions
|
|
50
|
+
const regularEdges = edges.filter((edge) => edge.condition.trim() !== 'else');
|
|
51
|
+
const elseEdges = edges.filter((edge) => edge.condition.trim() === 'else');
|
|
52
|
+
// First, evaluate all regular conditions
|
|
53
|
+
for (const edge of regularEdges) {
|
|
54
|
+
const startTime = Date.now();
|
|
55
|
+
try {
|
|
56
|
+
// Log condition start if in debug mode
|
|
57
|
+
logger_1.logger.debug({ msg: '[LogicalCondition] Evaluating condition', edge, sessionId: state.sessionId });
|
|
58
|
+
// Emit ON_LOGICAL_CONDITION event
|
|
59
|
+
await agent.emit(AgentEvents_1.AgentEvents.ON_LOGICAL_CONDITION, {
|
|
60
|
+
edge,
|
|
61
|
+
state,
|
|
62
|
+
condition: edge.condition,
|
|
63
|
+
});
|
|
64
|
+
// Customer is responsible for providing valid JavaScript syntax
|
|
65
|
+
// We execute their condition in a sandboxed VM with timeout protection
|
|
66
|
+
const conditionCode = `
|
|
67
|
+
(function({ state }) {
|
|
68
|
+
return ${edge.condition}
|
|
69
|
+
})
|
|
70
|
+
`;
|
|
71
|
+
// Create a sandboxed context with limited access
|
|
72
|
+
const context = vm.createContext({
|
|
73
|
+
// Provide safe utilities that customers might need
|
|
74
|
+
console: {
|
|
75
|
+
log: (...args) => logger_1.logger.debug('Customer condition log:', ...args),
|
|
76
|
+
error: (...args) => logger_1.logger.debug('Customer condition error:', ...args),
|
|
77
|
+
},
|
|
78
|
+
// Add other safe globals if needed
|
|
79
|
+
JSON,
|
|
80
|
+
Math,
|
|
81
|
+
Date,
|
|
82
|
+
// Prevent access to dangerous globals
|
|
83
|
+
process: undefined,
|
|
84
|
+
require: undefined,
|
|
85
|
+
global: undefined,
|
|
86
|
+
Buffer: undefined,
|
|
87
|
+
});
|
|
88
|
+
// Compile and run the condition with timeout
|
|
89
|
+
const script = new vm.Script(conditionCode, {
|
|
90
|
+
filename: `edge-condition-${edge.source}-to-${edge.target}`,
|
|
91
|
+
});
|
|
92
|
+
const conditionFn = script.runInContext(context, {
|
|
93
|
+
timeout: CONDITION_TIMEOUT,
|
|
94
|
+
});
|
|
95
|
+
// Execute the customer's condition with the current state
|
|
96
|
+
const result = await Promise.race([
|
|
97
|
+
Promise.resolve(conditionFn({ state })),
|
|
98
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Condition execution timeout')), CONDITION_TIMEOUT)),
|
|
99
|
+
]);
|
|
100
|
+
const executionTime = Date.now() - startTime;
|
|
101
|
+
const booleanResult = result === true;
|
|
102
|
+
// Log condition result if in debug mode
|
|
103
|
+
logger_1.logger.debug({
|
|
104
|
+
msg: '[LogicalCondition] Condition evaluated',
|
|
105
|
+
edge,
|
|
106
|
+
result: booleanResult,
|
|
107
|
+
executionTimeMs: executionTime,
|
|
108
|
+
nextNode: booleanResult ? edge.target : null,
|
|
109
|
+
sessionId: state.sessionId,
|
|
110
|
+
});
|
|
111
|
+
// Emit ON_LOGICAL_CONDITION_RESULT event
|
|
112
|
+
await agent.emit(AgentEvents_1.AgentEvents.ON_LOGICAL_CONDITION_RESULT, {
|
|
113
|
+
edge,
|
|
114
|
+
state,
|
|
115
|
+
condition: edge.condition,
|
|
116
|
+
result: booleanResult,
|
|
117
|
+
executionTimeMs: executionTime,
|
|
118
|
+
});
|
|
119
|
+
const goto = state.goto;
|
|
120
|
+
state.goto = null;
|
|
121
|
+
if (goto) {
|
|
122
|
+
logger_1.logger.debug({ msg: `[Router] Jumping to node`, node: goto, sessionId: state.sessionId });
|
|
123
|
+
return goto;
|
|
124
|
+
}
|
|
125
|
+
if (booleanResult) {
|
|
126
|
+
if (edge.source == edge.target) {
|
|
127
|
+
logger_1.logger.info({ msg: `[Router] Stay at node ${edge.source}`, node: edge.source, condition: edge.condition });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
logger_1.logger.info({
|
|
131
|
+
msg: `[Router] Logical condition matched`,
|
|
132
|
+
transitionFrom: edge.source,
|
|
133
|
+
transitionTo: edge.target,
|
|
134
|
+
condition: edge.condition,
|
|
135
|
+
sessionId: state.sessionId,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return edge.target;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
const executionTime = Date.now() - startTime;
|
|
143
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
144
|
+
const conditionPreview = edge.condition.length > 100 ? `${edge.condition.substring(0, 100)}...` : edge.condition;
|
|
145
|
+
logger_1.logger.error({
|
|
146
|
+
msg: `[Router] Error evaluating condition for edge ${edge.source} → ${edge.target}`,
|
|
147
|
+
condition: conditionPreview,
|
|
148
|
+
err,
|
|
149
|
+
edgeIndex: edges.indexOf(edge),
|
|
150
|
+
timeout: CONDITION_TIMEOUT,
|
|
151
|
+
});
|
|
152
|
+
// Emit ON_LOGICAL_CONDITION_RESULT event with error
|
|
153
|
+
const onLogicalConditionResultRes = await agent.emit(AgentEvents_1.AgentEvents.ON_LOGICAL_CONDITION_RESULT, {
|
|
154
|
+
edge,
|
|
155
|
+
state,
|
|
156
|
+
condition: edge.condition,
|
|
157
|
+
result: false,
|
|
158
|
+
executionTimeMs: executionTime,
|
|
159
|
+
error: errorObj,
|
|
160
|
+
});
|
|
161
|
+
const onLogicalConditionResultHandlerResult = onLogicalConditionResultRes.find((r) => r !== undefined);
|
|
162
|
+
let throwError = false;
|
|
163
|
+
throwError = (onLogicalConditionResultHandlerResult === null || onLogicalConditionResultHandlerResult === void 0 ? void 0 : onLogicalConditionResultHandlerResult.throwError) == true;
|
|
164
|
+
// Continue to next edge instead of failing completely
|
|
165
|
+
// This allows other conditions to be evaluated even if one fails
|
|
166
|
+
if (throwError) {
|
|
167
|
+
throw errorObj;
|
|
168
|
+
}
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// If no regular conditions matched, check for "else" conditions
|
|
173
|
+
if (elseEdges.length > 0) {
|
|
174
|
+
// Return the first "else" condition's target
|
|
175
|
+
const elseEdge = elseEdges[0];
|
|
176
|
+
logger_1.logger.info({
|
|
177
|
+
msg: `[Router] Else condition matched`,
|
|
178
|
+
transitionFrom: elseEdge.source,
|
|
179
|
+
transitionTo: elseEdge.target,
|
|
180
|
+
sessionId: state.sessionId,
|
|
181
|
+
});
|
|
182
|
+
return elseEdge.target;
|
|
183
|
+
}
|
|
184
|
+
// If no conditions matched or all failed, return to the source node
|
|
185
|
+
logger_1.logger.info({
|
|
186
|
+
msg: `[Router] Stay at node ${edges[0].source}, no conditions matched`,
|
|
187
|
+
node: edges[0].source,
|
|
188
|
+
sessionId: state.sessionId,
|
|
189
|
+
});
|
|
190
|
+
return null;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
exports.createLogicalRouter = createLogicalRouter;
|
|
194
|
+
//# sourceMappingURL=createLogicalRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLogicalRouter.js","sourceRoot":"","sources":["../../src/edges/createLogicalRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,4CAAyC;AAEzC,uDAAoD;AACpD,uCAAyB;AAEzB,6DAA6D;AAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,YAAY;AAErC,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAmD,EAAE,EAAE;IACvG,OAAO,KAAK,EAAE,KAAmC,EAAE,EAAE;QACnD,eAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,8CAA8C,KAAK,CAAC,MAAM,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAE7H,IAAI,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AC;gBAEvE,sDAAsD;gBACtD,iEAAiE;gBACjE,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,QAAQ,CAAC;gBACjB,CAAC;gBACD,SAAS;YACX,CAAC;QACH,CAAC;QAED,gEAAgE;QAChE,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,6CAA6C;YAC7C,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,eAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,iCAAiC;gBACtC,cAAc,EAAE,QAAQ,CAAC,MAAM;gBAC/B,YAAY,EAAE,QAAQ,CAAC,MAAM;gBAC7B,SAAS,EAAE,KAAK,CAAC,SAAS;aAC3B,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,MAAM,CAAC;QACzB,CAAC;QAED,oEAAoE;QACpE,eAAM,CAAC,IAAI,CAAC;YACV,GAAG,EAAE,yBAAyB,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,yBAAyB;YACtE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;YACrB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC,CAAC;AA3KW,QAAA,mBAAmB,uBA2K9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PromptConditionEdge } from '../types/Flows.types';
|
|
2
|
+
import { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
3
|
+
import { stateAnnotation } from '../types/LangGraph.types';
|
|
4
|
+
export declare const createPromptRouter: ({ edges, llm, includeReasoning, maxRetries, canStayInCurrentNode, currentNodeName, }: {
|
|
5
|
+
edges: PromptConditionEdge[];
|
|
6
|
+
llm: BaseLanguageModel;
|
|
7
|
+
includeReasoning?: boolean;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
canStayInCurrentNode?: boolean;
|
|
10
|
+
currentNodeName?: string;
|
|
11
|
+
}) => (state: typeof stateAnnotation.State) => Promise<string>;
|
|
12
|
+
//# sourceMappingURL=createPromptRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPromptRouter.d.ts","sourceRoot":"","sources":["../../src/edges/createPromptRouter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AA+C3D,eAAO,MAAM,kBAAkB,GAAI,sFAOhC;IACD,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,GAAG,EAAE,iBAAiB,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,MACe,OAAO,OAAO,eAAe,CAAC,KAAK,oBAkJlD,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPromptRouter = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const messages_1 = require("@langchain/core/messages");
|
|
6
|
+
const logger_1 = require("../utils/logger");
|
|
7
|
+
const compilePrompt_1 = require("../nodes/compilePrompt");
|
|
8
|
+
const ROUTER_PROMPT = `
|
|
9
|
+
You are a routing agent that decides which node to take in a flow based on the current state.
|
|
10
|
+
Based on the conversation history and memory state, you should classify the next step for the conversation.
|
|
11
|
+
Each step has a nodeId and a condition. You should decide to move to the right step based on the condition.
|
|
12
|
+
|
|
13
|
+
Here are the available options and their conditions:
|
|
14
|
+
<%= steps %>
|
|
15
|
+
|
|
16
|
+
Recent messages:
|
|
17
|
+
<%= messages %>
|
|
18
|
+
|
|
19
|
+
You MUST respond with the exact nodeId from the options above. Do not use step numbers or any other identifiers.
|
|
20
|
+
|
|
21
|
+
You should output the result in the following JSON format:
|
|
22
|
+
{
|
|
23
|
+
"nextNodeId": "exact_node_name_from_options_above",
|
|
24
|
+
"reasoning": "I think the next step should be exact_node_name_from_options_above because of the following reasons: ..."
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Return JSON and nothing more.
|
|
28
|
+
`;
|
|
29
|
+
const ROUTER_PROMPT_WITHOUT_REASONING = `
|
|
30
|
+
You are a routing agent that decides which node to take in a flow based on the current state.
|
|
31
|
+
Based on the conversation history and memory state, you should classify the next step for the conversation.
|
|
32
|
+
Each step has a nodeId and a condition. You should decide to move to the right step based on the condition.
|
|
33
|
+
|
|
34
|
+
Here are the available options and their conditions:
|
|
35
|
+
<%= steps %>
|
|
36
|
+
|
|
37
|
+
Recent messages:
|
|
38
|
+
<%= messages %>
|
|
39
|
+
|
|
40
|
+
You MUST respond with the exact nodeId from the options above. Do not use step numbers or any other identifiers.
|
|
41
|
+
|
|
42
|
+
You should output the result in the following JSON format:
|
|
43
|
+
{
|
|
44
|
+
"nextNodeId": "exact_node_name_from_options_above"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Return JSON and nothing more.
|
|
48
|
+
`;
|
|
49
|
+
const createPromptRouter = ({ edges, llm, includeReasoning = true, maxRetries = 3, canStayInCurrentNode = false, currentNodeName, }) => {
|
|
50
|
+
return async (state) => {
|
|
51
|
+
logger_1.logger.debug({ msg: `[Router] Executing prompt router`, currentNodeName, sessionId: state.sessionId, edges });
|
|
52
|
+
if (state.goto) {
|
|
53
|
+
logger_1.logger.debug({ msg: `[Router] Jumping to node`, node: state.goto, sessionId: state.sessionId, edges });
|
|
54
|
+
return state.goto;
|
|
55
|
+
}
|
|
56
|
+
// If canStayInCurrentNode is true and there are no edges, return current node immediately
|
|
57
|
+
if (canStayInCurrentNode && edges.length === 0 && currentNodeName) {
|
|
58
|
+
logger_1.logger.info({
|
|
59
|
+
msg: `[Router] Stay at node, No edges available and canStayInCurrentNode==true`,
|
|
60
|
+
node: currentNodeName,
|
|
61
|
+
sessionId: state.sessionId,
|
|
62
|
+
});
|
|
63
|
+
return currentNodeName;
|
|
64
|
+
}
|
|
65
|
+
// Prepare the steps string
|
|
66
|
+
let stepsStr = '';
|
|
67
|
+
// Add "stay in current node" option if enabled
|
|
68
|
+
if (canStayInCurrentNode && currentNodeName) {
|
|
69
|
+
stepsStr = `- Node: "${currentNodeName}" (stay in current node)\n`;
|
|
70
|
+
}
|
|
71
|
+
// Add the edge options
|
|
72
|
+
stepsStr += edges.map((edge) => `- Node: "${edge.target}" - Condition: "${edge.prompt}"`).join('\n');
|
|
73
|
+
// Prepare recent messages (last 10 messages for context)
|
|
74
|
+
const recentMessages = state.messages.slice(-10);
|
|
75
|
+
const messagesStr = recentMessages
|
|
76
|
+
.map((msg) => {
|
|
77
|
+
const role = msg.getType();
|
|
78
|
+
const content = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content);
|
|
79
|
+
return `${role}: ${content}`;
|
|
80
|
+
})
|
|
81
|
+
.join('\n');
|
|
82
|
+
// Select prompt based on reasoning preference
|
|
83
|
+
const promptTemplate = includeReasoning ? ROUTER_PROMPT : ROUTER_PROMPT_WITHOUT_REASONING;
|
|
84
|
+
// Compile prompt with EJS and parameters
|
|
85
|
+
const routerPrompt = (0, compilePrompt_1.compilePrompt)(promptTemplate, {
|
|
86
|
+
steps: stepsStr,
|
|
87
|
+
messages: messagesStr,
|
|
88
|
+
memory: state.memory,
|
|
89
|
+
state: state,
|
|
90
|
+
env: process.env,
|
|
91
|
+
});
|
|
92
|
+
// Define response schema
|
|
93
|
+
const responseSchema = includeReasoning
|
|
94
|
+
? zod_1.z.object({
|
|
95
|
+
nextNodeId: zod_1.z.string(),
|
|
96
|
+
reasoning: zod_1.z.string(),
|
|
97
|
+
})
|
|
98
|
+
: zod_1.z.object({
|
|
99
|
+
nextNodeId: zod_1.z.string(),
|
|
100
|
+
});
|
|
101
|
+
let attempts = 0;
|
|
102
|
+
let lastError = null;
|
|
103
|
+
while (attempts < maxRetries) {
|
|
104
|
+
try {
|
|
105
|
+
attempts++;
|
|
106
|
+
// Create messages for the LLM
|
|
107
|
+
const messages = [new messages_1.SystemMessage(routerPrompt)];
|
|
108
|
+
// If this is a retry, add the error message
|
|
109
|
+
if (lastError) {
|
|
110
|
+
messages.push(new messages_1.SystemMessage(`Previous attempt failed with error: ${lastError.message}. Please provide a valid JSON response.`));
|
|
111
|
+
}
|
|
112
|
+
// Call the LLM with structured output
|
|
113
|
+
const response = await llm.invoke(messages);
|
|
114
|
+
// Extract content from response
|
|
115
|
+
let content = '';
|
|
116
|
+
if (typeof response.content === 'string') {
|
|
117
|
+
content = response.content;
|
|
118
|
+
}
|
|
119
|
+
else if (response.content && typeof response.content === 'object' && 'text' in response.content) {
|
|
120
|
+
content = response.content.text;
|
|
121
|
+
}
|
|
122
|
+
// Try to parse JSON from the response
|
|
123
|
+
let parsedResponse;
|
|
124
|
+
try {
|
|
125
|
+
// Clean the response - remove markdown code blocks if present
|
|
126
|
+
content = content
|
|
127
|
+
.replace(/```json\n?/g, '')
|
|
128
|
+
.replace(/```\n?/g, '')
|
|
129
|
+
.trim();
|
|
130
|
+
parsedResponse = JSON.parse(content);
|
|
131
|
+
}
|
|
132
|
+
catch (_a) {
|
|
133
|
+
throw new Error(`Failed to parse JSON response: ${content}`);
|
|
134
|
+
}
|
|
135
|
+
// Validate the response
|
|
136
|
+
const validatedResponse = responseSchema.parse(parsedResponse);
|
|
137
|
+
// Check if the selected node is valid
|
|
138
|
+
const validTargets = edges.map((e) => e.target);
|
|
139
|
+
if (canStayInCurrentNode && currentNodeName) {
|
|
140
|
+
validTargets.push(currentNodeName);
|
|
141
|
+
}
|
|
142
|
+
if (!validTargets.includes(validatedResponse.nextNodeId)) {
|
|
143
|
+
throw new Error(`Invalid nextNodeId: ${validatedResponse.nextNodeId}. Must be one of: ${validTargets.join(', ')}`);
|
|
144
|
+
}
|
|
145
|
+
const decision = validatedResponse.nextNodeId === currentNodeName ? 'stay in current node' : validatedResponse.nextNodeId;
|
|
146
|
+
const reasoning = includeReasoning && 'reasoning' in validatedResponse ? ` - Reasoning: ${validatedResponse.reasoning}` : '';
|
|
147
|
+
logger_1.logger.debug({ msg: `[Router] Decision: ${decision}`, reasoning, sessionId: state.sessionId, edges });
|
|
148
|
+
return validatedResponse.nextNodeId;
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
152
|
+
logger_1.logger.warn({
|
|
153
|
+
message: `[Router] Prompt router attempt ${attempts} failed`,
|
|
154
|
+
err: lastError,
|
|
155
|
+
attempt: attempts,
|
|
156
|
+
maxRetries,
|
|
157
|
+
sessionId: state.sessionId,
|
|
158
|
+
edges,
|
|
159
|
+
});
|
|
160
|
+
if (attempts >= maxRetries) {
|
|
161
|
+
logger_1.logger.error({
|
|
162
|
+
msg: '[Router] Prompt router reached max retries',
|
|
163
|
+
lastError: lastError.message,
|
|
164
|
+
sessionId: state.sessionId,
|
|
165
|
+
edges,
|
|
166
|
+
});
|
|
167
|
+
throw new Error('Prompt router reached max retries, no edges available for routing');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// This should never be reached, but TypeScript needs it
|
|
172
|
+
throw new Error('Unexpected error in prompt router');
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
exports.createPromptRouter = createPromptRouter;
|
|
176
|
+
//# sourceMappingURL=createPromptRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPromptRouter.js","sourceRoot":"","sources":["../../src/edges/createPromptRouter.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGxB,uDAAyD;AAEzD,4CAAyC;AACzC,0DAAuD;AAEvD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC;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GAAG,EAAE,SAAS;oBACd,OAAO,EAAE,QAAQ;oBACjB,UAAU;oBACV,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,KAAK;iBACN,CAAC,CAAC;gBAEH,IAAI,QAAQ,IAAI,UAAU,EAAE,CAAC;oBAC3B,eAAM,CAAC,KAAK,CAAC;wBACX,GAAG,EAAE,4CAA4C;wBACjD,SAAS,EAAE,SAAS,CAAC,OAAO;wBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;wBAC1B,KAAK;qBACN,CAAC,CAAC;oBACH,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;gBACvF,CAAC;YACH,CAAC;QACH,CAAC;QAED,wDAAwD;QACxD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC,CAAC;AAjKW,QAAA,kBAAkB,sBAiK7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Edge, Node } from '../types/Flows.types';
|
|
2
|
+
import { PreCompiledGraph } from '../types/LangGraph.types';
|
|
3
|
+
import { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
4
|
+
import { Tool } from '../types/Tools.types';
|
|
5
|
+
import { Agent } from '../agent';
|
|
6
|
+
export declare const edgeFactory: ({ graph, edges, nodes, tools, llm, agent, }: {
|
|
7
|
+
graph: PreCompiledGraph;
|
|
8
|
+
edges: Edge[];
|
|
9
|
+
nodes: Record<string, Node>;
|
|
10
|
+
tools: Tool<any, any>[];
|
|
11
|
+
llm: BaseLanguageModel;
|
|
12
|
+
agent: Agent;
|
|
13
|
+
}) => void;
|
|
14
|
+
//# sourceMappingURL=edgeFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edgeFactory.d.ts","sourceRoot":"","sources":["../../src/edges/edgeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,IAAI,EAOL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAOzE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AASjC,eAAO,MAAM,WAAW,GAAI,6CAOzB;IACD,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACxB,GAAG,EAAE,iBAAiB,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;CACd,SA2HA,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.edgeFactory = void 0;
|
|
4
|
+
const Flows_types_1 = require("../types/Flows.types");
|
|
5
|
+
const createPromptRouter_1 = require("./createPromptRouter");
|
|
6
|
+
const createLogicalRouter_1 = require("./createLogicalRouter");
|
|
7
|
+
const createDirectEdge_1 = require("./createDirectEdge");
|
|
8
|
+
const addHumanInTheLoopNode_1 = require("../nodes/addHumanInTheLoopNode");
|
|
9
|
+
const addToolRunNode_1 = require("../nodes/addToolRunNode");
|
|
10
|
+
const addBrowserTaskRunNode_1 = require("../nodes/addBrowserTaskRunNode");
|
|
11
|
+
const logger_1 = require("../utils/logger");
|
|
12
|
+
const edgeFactory = ({ graph, edges, nodes, tools, llm, agent, }) => {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a combined router that handles edge priority: step forward > logical > prompt
|
|
15
|
+
*/
|
|
16
|
+
const createCombinedRouter = (sourceNode, edgesBySource, originalNode) => {
|
|
17
|
+
return async (state) => {
|
|
18
|
+
// Priority 1: Step forward edge (max 1)
|
|
19
|
+
if (edgesBySource.stepForward) {
|
|
20
|
+
const directRouter = (0, createDirectEdge_1.createDirectEdge)(edgesBySource.stepForward);
|
|
21
|
+
return await directRouter(state);
|
|
22
|
+
}
|
|
23
|
+
// Priority 2: Logical condition edges
|
|
24
|
+
if (edgesBySource.logical.length > 0) {
|
|
25
|
+
const logicalRouter = (0, createLogicalRouter_1.createLogicalRouter)({ edges: edgesBySource.logical, agent });
|
|
26
|
+
const result = await logicalRouter(state);
|
|
27
|
+
if (result) {
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
logger_1.logger.debug({
|
|
32
|
+
msg: 'No logical conditions matched, continuing to prompt conditions',
|
|
33
|
+
sessionId: state.sessionId,
|
|
34
|
+
originalNode: originalNode === null || originalNode === void 0 ? void 0 : originalNode.displayName,
|
|
35
|
+
sourceNode: sourceNode,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Priority 3: Prompt condition edges
|
|
40
|
+
if (edgesBySource.prompt.length > 0) {
|
|
41
|
+
// Use the original node to check canStayOnNode property
|
|
42
|
+
// For PROMPT_NODE: default to true when undefined
|
|
43
|
+
// For other types: default to false when undefined
|
|
44
|
+
let canStayInCurrentNode = originalNode === null || originalNode === void 0 ? void 0 : originalNode.canStayOnNode;
|
|
45
|
+
if (canStayInCurrentNode === undefined) {
|
|
46
|
+
canStayInCurrentNode = (originalNode === null || originalNode === void 0 ? void 0 : originalNode.type) === Flows_types_1.NodeType.PROMPT_NODE;
|
|
47
|
+
}
|
|
48
|
+
const promptRouter = (0, createPromptRouter_1.createPromptRouter)({
|
|
49
|
+
edges: edgesBySource.prompt,
|
|
50
|
+
llm,
|
|
51
|
+
canStayInCurrentNode,
|
|
52
|
+
currentNodeName: (originalNode === null || originalNode === void 0 ? void 0 : originalNode.name) || sourceNode,
|
|
53
|
+
});
|
|
54
|
+
return await promptRouter(state);
|
|
55
|
+
}
|
|
56
|
+
// Fallback: stay at current source node
|
|
57
|
+
const source = (originalNode === null || originalNode === void 0 ? void 0 : originalNode.name) || sourceNode;
|
|
58
|
+
if (originalNode.type !== Flows_types_1.NodeType.PROMPT_NODE || originalNode.canStayOnNode == false) {
|
|
59
|
+
logger_1.logger.error({
|
|
60
|
+
msg: `No conditions matched but cannot stay on current node`,
|
|
61
|
+
sessionId: state.sessionId,
|
|
62
|
+
originalNode: originalNode,
|
|
63
|
+
sourceNode: sourceNode,
|
|
64
|
+
});
|
|
65
|
+
throw new Error('Tried to stay on current node but but current node is not a prompt node or canStayOnNode is false');
|
|
66
|
+
}
|
|
67
|
+
logger_1.logger.info({
|
|
68
|
+
msg: `No conditions matched, returning to source: ${source}`,
|
|
69
|
+
sessionId: state.sessionId,
|
|
70
|
+
originalNode: originalNode === null || originalNode === void 0 ? void 0 : originalNode.displayName,
|
|
71
|
+
sourceNode: sourceNode,
|
|
72
|
+
});
|
|
73
|
+
return source;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Processes all edges for a specific source node with enhanced capabilities
|
|
78
|
+
*/
|
|
79
|
+
const processEdgesForNode = (source, edgesBySource) => {
|
|
80
|
+
let effectiveSource = source;
|
|
81
|
+
const originalNode = nodes[source];
|
|
82
|
+
// Handle human-in-the-loop enhancement
|
|
83
|
+
if (originalNode === null || originalNode === void 0 ? void 0 : originalNode.humanInTheLoop) {
|
|
84
|
+
(0, addHumanInTheLoopNode_1.addHumanInTheLoopNode)({ graph, attachedToNodeName: source });
|
|
85
|
+
effectiveSource = (0, addHumanInTheLoopNode_1.buildHumanInTheLoopNodeName)(source);
|
|
86
|
+
}
|
|
87
|
+
if ((originalNode === null || originalNode === void 0 ? void 0 : originalNode.type) === Flows_types_1.NodeType.TOOL) {
|
|
88
|
+
(0, addToolRunNode_1.addToolRunNode)({ graph, tools, llm, toolNode: originalNode, attachedToNodeName: source, agent });
|
|
89
|
+
effectiveSource = (0, addToolRunNode_1.buildToolRunNodeName)(source);
|
|
90
|
+
}
|
|
91
|
+
if ((originalNode === null || originalNode === void 0 ? void 0 : originalNode.type) === Flows_types_1.NodeType.BROWSER_TASK) {
|
|
92
|
+
(0, addBrowserTaskRunNode_1.addBrowserTaskRunNode)({ graph, browserTaskNode: originalNode, attachedToNodeName: source, agent });
|
|
93
|
+
effectiveSource = (0, addBrowserTaskRunNode_1.buildBrowserTaskRunNodeName)(source);
|
|
94
|
+
}
|
|
95
|
+
// Create and add the combined conditional edge with original node reference
|
|
96
|
+
const combinedRouter = createCombinedRouter(effectiveSource, edgesBySource, originalNode);
|
|
97
|
+
graph.addConditionalEdges(effectiveSource, combinedRouter);
|
|
98
|
+
};
|
|
99
|
+
// Get all unique source nodes and categorize their edges in a single pass
|
|
100
|
+
const edgesBySource = edges.reduce((acc, edge) => {
|
|
101
|
+
if (!acc[edge.source]) {
|
|
102
|
+
acc[edge.source] = {
|
|
103
|
+
stepForward: undefined,
|
|
104
|
+
logical: [],
|
|
105
|
+
prompt: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (edge.type === Flows_types_1.EdgeType.STEP_FORWARD) {
|
|
109
|
+
acc[edge.source].stepForward = edge;
|
|
110
|
+
}
|
|
111
|
+
else if (edge.type === Flows_types_1.EdgeType.LOGICAL_CONDITION) {
|
|
112
|
+
acc[edge.source].logical.push(edge);
|
|
113
|
+
}
|
|
114
|
+
else if (edge.type === Flows_types_1.EdgeType.PROMPT_CONDITION) {
|
|
115
|
+
acc[edge.source].prompt.push(edge);
|
|
116
|
+
}
|
|
117
|
+
return acc;
|
|
118
|
+
}, {});
|
|
119
|
+
// Process edges for each source node
|
|
120
|
+
Object.entries(edgesBySource).forEach(([source, categorizedEdges]) => {
|
|
121
|
+
processEdgesForNode(source, categorizedEdges);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
exports.edgeFactory = edgeFactory;
|
|
125
|
+
//# sourceMappingURL=edgeFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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raph.types';
|
|
2
|
+
import { LogicalConditionEdge } from '../types/Flows.types';
|
|
3
|
+
import { TriggerEvent } from '../types/Agent.types';
|
|
4
|
+
export declare enum AgentEvents {
|
|
5
|
+
AI_MESSAGE = "AI_MESSAGE",
|
|
6
|
+
TRIGGER_EVENT = "TRIGGER_EVENT",
|
|
7
|
+
VOICE_SESSION_START = "VOICE_SESSION_START",
|
|
8
|
+
ERROR = "ERROR",
|
|
9
|
+
ON_LOGICAL_CONDITION = "ON_LOGICAL_CONDITION",
|
|
10
|
+
ON_LOGICAL_CONDITION_RESULT = "ON_LOGICAL_CONDITION_RESULT"
|
|
11
|
+
}
|
|
12
|
+
export type AgentEventRequestPayloads<Memory> = {
|
|
13
|
+
[AgentEvents.AI_MESSAGE]: {
|
|
14
|
+
message: string;
|
|
15
|
+
state: State<Memory>;
|
|
16
|
+
};
|
|
17
|
+
[AgentEvents.TRIGGER_EVENT]: TriggerEvent & {
|
|
18
|
+
state: State<Memory>;
|
|
19
|
+
};
|
|
20
|
+
[AgentEvents.VOICE_SESSION_START]: {
|
|
21
|
+
metadata?: Record<string, any>;
|
|
22
|
+
state: State<Memory>;
|
|
23
|
+
};
|
|
24
|
+
[AgentEvents.ERROR]: {
|
|
25
|
+
error: Error;
|
|
26
|
+
state: State<Memory>;
|
|
27
|
+
};
|
|
28
|
+
[AgentEvents.ON_LOGICAL_CONDITION]: {
|
|
29
|
+
edge: LogicalConditionEdge;
|
|
30
|
+
state: State<Memory>;
|
|
31
|
+
condition: string;
|
|
32
|
+
};
|
|
33
|
+
[AgentEvents.ON_LOGICAL_CONDITION_RESULT]: {
|
|
34
|
+
edge: LogicalConditionEdge;
|
|
35
|
+
state: State<Memory>;
|
|
36
|
+
condition: string;
|
|
37
|
+
result: boolean;
|
|
38
|
+
executionTimeMs: number;
|
|
39
|
+
error?: Error;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type AgentEventResponsePayloads = {
|
|
43
|
+
[AgentEvents.AI_MESSAGE]: void;
|
|
44
|
+
[AgentEvents.TRIGGER_EVENT]: {
|
|
45
|
+
isQualified: boolean;
|
|
46
|
+
};
|
|
47
|
+
[AgentEvents.VOICE_SESSION_START]: void;
|
|
48
|
+
[AgentEvents.ERROR]: {
|
|
49
|
+
throwError: boolean;
|
|
50
|
+
};
|
|
51
|
+
[AgentEvents.ON_LOGICAL_CONDITION]: void;
|
|
52
|
+
[AgentEvents.ON_LOGICAL_CONDITION_RESULT]: {
|
|
53
|
+
throwError: boolean;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=AgentEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentEvents.d.ts","sourceRoot":"","sources":["../../src/events/AgentEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,oBAAY,WAAW;IACrB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,mBAAmB,wBAAwB;IAC3C,KAAK,UAAU;IACf,oBAAoB,yBAAyB;IAC7C,2BAA2B,gCAAgC;CAC5D;AAED,MAAM,MAAM,yBAAyB,CAAC,MAAM,IAAI;IAC9C,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACtB,CAAC;IACF,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,YAAY,GAAG;QAC1C,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACtB,CAAC;IACF,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE;QACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACtB,CAAC;IACF,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;QACnB,KAAK,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACtB,CAAC;IACF,CAAC,WAAW,CAAC,oBAAoB,CAAC,EAAE;QAClC,IAAI,EAAE,oBAAoB,CAAC;QAC3B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,CAAC,WAAW,CAAC,2BAA2B,CAAC,EAAE;QACzC,IAAI,EAAE,oBAAoB,CAAC;QAC3B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC;IAC/B,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE;QAC3B,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;IACF,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC;IACxC,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;QACnB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,CAAC,WAAW,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC;IACzC,CAAC,WAAW,CAAC,2BAA2B,CAAC,EAAE;QACzC,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentEvents = void 0;
|
|
4
|
+
var AgentEvents;
|
|
5
|
+
(function (AgentEvents) {
|
|
6
|
+
AgentEvents["AI_MESSAGE"] = "AI_MESSAGE";
|
|
7
|
+
AgentEvents["TRIGGER_EVENT"] = "TRIGGER_EVENT";
|
|
8
|
+
AgentEvents["VOICE_SESSION_START"] = "VOICE_SESSION_START";
|
|
9
|
+
AgentEvents["ERROR"] = "ERROR";
|
|
10
|
+
AgentEvents["ON_LOGICAL_CONDITION"] = "ON_LOGICAL_CONDITION";
|
|
11
|
+
AgentEvents["ON_LOGICAL_CONDITION_RESULT"] = "ON_LOGICAL_CONDITION_RESULT";
|
|
12
|
+
})(AgentEvents || (exports.AgentEvents = AgentEvents = {}));
|
|
13
|
+
//# sourceMappingURL=AgentEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentEvents.js","sourceRoot":"","sources":["../../src/events/AgentEvents.ts"],"names":[],"mappings":";;;AAIA,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,8CAA+B,CAAA;IAC/B,0DAA2C,CAAA;IAC3C,8BAAe,CAAA;IACf,4DAA6C,CAAA;IAC7C,0EAA2D,CAAA;AAC7D,CAAC,EAPW,WAAW,2BAAX,WAAW,QAOtB"}
|