@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,305 @@
|
|
|
1
|
+
import { RunnableLike } from '@langchain/core/runnables';
|
|
2
|
+
import { NodeType, PromptNode } from '../types/Flows.types';
|
|
3
|
+
import { PreCompiledGraph, stateAnnotation } from '../types/LangGraph.types';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
6
|
+
import { SystemMessage, AIMessage, ToolMessage } from '@langchain/core/messages';
|
|
7
|
+
import { Tool } from '../types/Tools.types';
|
|
8
|
+
import { tool as langchainTool } from '@langchain/core/tools';
|
|
9
|
+
import { AgentEventRequestPayloads, AgentEvents } from '../events/AgentEvents';
|
|
10
|
+
import { EmitSignature, HistoryStep } from '../types/Agent.types';
|
|
11
|
+
import { createLlmInstance } from '../llm/createLlmInstance';
|
|
12
|
+
import { Agent } from '../agent';
|
|
13
|
+
import { logger } from '../utils/logger';
|
|
14
|
+
import { combinePlaybooks } from '../playbooks/playbooks';
|
|
15
|
+
import { createHistoryStep } from '../utils/history';
|
|
16
|
+
import { compilePrompt } from './compilePrompt';
|
|
17
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
18
|
+
|
|
19
|
+
type AddPromptNodeParams = {
|
|
20
|
+
graph: PreCompiledGraph;
|
|
21
|
+
node: PromptNode;
|
|
22
|
+
llm: BaseLanguageModel;
|
|
23
|
+
tools: Tool<any, any>[];
|
|
24
|
+
emit: EmitSignature<any, keyof AgentEventRequestPayloads<any>>;
|
|
25
|
+
agent: Agent;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const addPromptNode = async ({ graph, node, llm, tools, emit, agent }: AddPromptNodeParams) => {
|
|
29
|
+
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
30
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId);
|
|
31
|
+
logger.info({ msg: `[Node] Executing prompt node`, node: node.displayName, sessionId: state.sessionId });
|
|
32
|
+
const llmToUse = node.llmConfig ? createLlmInstance(node.llmConfig) : llm;
|
|
33
|
+
|
|
34
|
+
const scopedTools = tools
|
|
35
|
+
.filter((tool) => tool.isGlobal || node.prompt.includes(`{tools.${tool.name}}`))
|
|
36
|
+
.map((tool) =>
|
|
37
|
+
langchainTool((input: z.infer<typeof tool.input>) => tool.execute({ input, state, agent, invokedFromPromptNode: true }), {
|
|
38
|
+
name: tool.name,
|
|
39
|
+
description: tool.description,
|
|
40
|
+
schema: tool.input,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Get edges for the current node and format them
|
|
45
|
+
const edges = agent.flows?.flatMap((flow: any) => flow.edges) || [];
|
|
46
|
+
const nodeEdges = edges.filter((edge: any) => edge.source === node.name);
|
|
47
|
+
const currentPromptNode = getCurrentPromptNode(node, nodeEdges);
|
|
48
|
+
|
|
49
|
+
let finalMessage = currentPromptNode;
|
|
50
|
+
const combinedPlaybooks = combinePlaybooks(agent.playbooks);
|
|
51
|
+
if (combinedPlaybooks) {
|
|
52
|
+
finalMessage = combinedPlaybooks + '\n\n' + currentPromptNode;
|
|
53
|
+
}
|
|
54
|
+
const compiledPrompt = compilePrompt(finalMessage, { state: state, memory: state.memory, env: process.env });
|
|
55
|
+
const systemMessage = new SystemMessage(compiledPrompt);
|
|
56
|
+
if (state.messages.length === 0 || state.messages[0].getType() === 'system') {
|
|
57
|
+
state.messages[0] = systemMessage;
|
|
58
|
+
} else {
|
|
59
|
+
state.messages.unshift(systemMessage);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Check if we should use the agentic loop (only when humanInTheLoop is true)
|
|
63
|
+
const useAgenticLoop = node.humanInTheLoop === true;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* When humanInTheLoop is true: Run an agentic loop that continues invoking the LLM
|
|
67
|
+
* after tool calls until we get a final AI message without tool calls.
|
|
68
|
+
*
|
|
69
|
+
* When humanInTheLoop is false: Return immediately after tool execution without
|
|
70
|
+
* additional LLM invocations.
|
|
71
|
+
*/
|
|
72
|
+
let finalAIMessage: AIMessage | null = null;
|
|
73
|
+
let loopCount = 0;
|
|
74
|
+
const MAX_LOOP_ITERATIONS = process.env.MAX_TOOL_LOOP_ITERATIONS ? parseInt(process.env.MAX_TOOL_LOOP_ITERATIONS) : 10;
|
|
75
|
+
|
|
76
|
+
while (true) {
|
|
77
|
+
loopCount++;
|
|
78
|
+
|
|
79
|
+
// Break if we've reached the maximum number of iterations
|
|
80
|
+
if (loopCount > MAX_LOOP_ITERATIONS) {
|
|
81
|
+
logger.warn({
|
|
82
|
+
msg: '[Model] Reached maximum loop iterations, breaking agentic loop',
|
|
83
|
+
loopCount,
|
|
84
|
+
sessionId: state.sessionId,
|
|
85
|
+
node: node.displayName,
|
|
86
|
+
});
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const startTime = Date.now();
|
|
91
|
+
const result: AIMessage = await llmToUse.bindTools(scopedTools).invoke(state.messages);
|
|
92
|
+
const endTime = Date.now();
|
|
93
|
+
|
|
94
|
+
// Always pass accumulated state to interrupt manager
|
|
95
|
+
// Pass the accumulated messages from this prompt node execution
|
|
96
|
+
// If empty, pass undefined to avoid empty state updates
|
|
97
|
+
|
|
98
|
+
logger.debug({
|
|
99
|
+
msg: '[Model] Model execution time',
|
|
100
|
+
executionTimeMs: endTime - startTime,
|
|
101
|
+
sessionId: state.sessionId,
|
|
102
|
+
node: node.displayName,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId, state);
|
|
106
|
+
|
|
107
|
+
// Check if the result contains tool calls
|
|
108
|
+
if (result.tool_calls && result.tool_calls.length > 0) {
|
|
109
|
+
state.messages.push(result);
|
|
110
|
+
state.history.push(
|
|
111
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
112
|
+
type: NodeType.TOOL,
|
|
113
|
+
nodeId: node.name,
|
|
114
|
+
nodeDisplayName: node.displayName,
|
|
115
|
+
raw: result,
|
|
116
|
+
messageIds: [result.id!],
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// Execute the tools
|
|
121
|
+
// Ensure we process ALL tool calls, even if some fail
|
|
122
|
+
for (let toolIndex = 0; toolIndex < result.tool_calls.length; toolIndex++) {
|
|
123
|
+
const toolCall = result.tool_calls[toolIndex];
|
|
124
|
+
const matchedTool = scopedTools.find((t) => t.name === toolCall.name);
|
|
125
|
+
logger.info({
|
|
126
|
+
msg: `[Model] Calling tool inside prompt node`,
|
|
127
|
+
tool: matchedTool?.name || toolCall.name,
|
|
128
|
+
toolCallId: toolCall.id,
|
|
129
|
+
sessionId: state.sessionId,
|
|
130
|
+
node: node.displayName,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (matchedTool) {
|
|
134
|
+
// Invoke the LangChain tool directly
|
|
135
|
+
const toolStartTime = Date.now();
|
|
136
|
+
const toolResult = await matchedTool.invoke(toolCall);
|
|
137
|
+
const toolEndTime = Date.now();
|
|
138
|
+
|
|
139
|
+
logger.debug({
|
|
140
|
+
msg: `[Tool] Tool result inside prompt node`,
|
|
141
|
+
tool: matchedTool?.name,
|
|
142
|
+
result: toolResult,
|
|
143
|
+
executionTimeMs: toolEndTime - toolStartTime,
|
|
144
|
+
sessionId: state.sessionId,
|
|
145
|
+
node: node.displayName,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Add the tool result directly to allMessages
|
|
149
|
+
state.messages.push(toolResult);
|
|
150
|
+
|
|
151
|
+
state.history.push(
|
|
152
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
153
|
+
type: NodeType.TOOL,
|
|
154
|
+
nodeId: node.name,
|
|
155
|
+
nodeDisplayName: node.displayName,
|
|
156
|
+
raw: toolResult,
|
|
157
|
+
messageIds: [toolResult.id!],
|
|
158
|
+
}),
|
|
159
|
+
);
|
|
160
|
+
} else {
|
|
161
|
+
logger.error({
|
|
162
|
+
msg: `[Tool] Model called tool but it was not found inside prompt node`,
|
|
163
|
+
tool: toolCall.name,
|
|
164
|
+
toolCallId: toolCall.id,
|
|
165
|
+
sessionId: state.sessionId,
|
|
166
|
+
node: node.displayName,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// IMPORTANT: Create an error message for the missing tool with the correct tool_call_id
|
|
170
|
+
const missingToolMessage = new ToolMessage({
|
|
171
|
+
content: JSON.stringify({ error: `Tool '${toolCall.name}' doesnt exist` }),
|
|
172
|
+
tool_call_id: toolCall.id!, // This MUST match the tool_call_id from the AI message
|
|
173
|
+
name: toolCall.name,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
state.messages.push(missingToolMessage);
|
|
177
|
+
state.history.push(
|
|
178
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
179
|
+
type: NodeType.TOOL,
|
|
180
|
+
nodeId: node.name,
|
|
181
|
+
nodeDisplayName: node.displayName,
|
|
182
|
+
raw: missingToolMessage,
|
|
183
|
+
messageIds: [missingToolMessage.id!],
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Check for queue after tool call
|
|
189
|
+
const systemMessageId = uuidv4();
|
|
190
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId, {
|
|
191
|
+
...state,
|
|
192
|
+
messages: [
|
|
193
|
+
...state.messages,
|
|
194
|
+
new SystemMessage({
|
|
195
|
+
id: systemMessageId,
|
|
196
|
+
content:
|
|
197
|
+
'you called tools when the user send a new message, Consider calling the tools again after user message is processed',
|
|
198
|
+
}),
|
|
199
|
+
],
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// If humanInTheLoop is false, return immediately after tool execution
|
|
203
|
+
if (!useAgenticLoop) {
|
|
204
|
+
return state;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Continue the loop to see what the model wants to do next
|
|
208
|
+
continue;
|
|
209
|
+
} else {
|
|
210
|
+
// We got an AI message without tool calls - this is our final response
|
|
211
|
+
finalAIMessage = result;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Process the final AI message if we have one
|
|
217
|
+
if (finalAIMessage) {
|
|
218
|
+
// Add the final AI message to our messages first
|
|
219
|
+
state.messages.push(finalAIMessage);
|
|
220
|
+
|
|
221
|
+
logger.info({
|
|
222
|
+
msg: `[Model] Response`,
|
|
223
|
+
content: finalAIMessage.content,
|
|
224
|
+
sessionId: state.sessionId,
|
|
225
|
+
node: node.displayName,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
await emit(AgentEvents.AI_MESSAGE, {
|
|
229
|
+
message: finalAIMessage.content as string,
|
|
230
|
+
state: state,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Set goto to null
|
|
234
|
+
state.goto = null;
|
|
235
|
+
|
|
236
|
+
state.history.push(
|
|
237
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
238
|
+
type: NodeType.PROMPT_NODE,
|
|
239
|
+
nodeId: node.name,
|
|
240
|
+
nodeDisplayName: node.displayName,
|
|
241
|
+
raw: finalAIMessage.content,
|
|
242
|
+
messageIds: [finalAIMessage.id!],
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
return state;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// If we hit the loop limit without a final AI message, return what we have
|
|
250
|
+
if (loopCount > MAX_LOOP_ITERATIONS) {
|
|
251
|
+
logger.warn({
|
|
252
|
+
msg: '[Model] Returning accumulated messages after hitting loop limit',
|
|
253
|
+
sessionId: state.sessionId,
|
|
254
|
+
node: node.displayName,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
state.goto = null;
|
|
258
|
+
return state;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// This should only be reached in unexpected cases
|
|
262
|
+
throw new Error('Unexpected state: no messages generated in prompt node');
|
|
263
|
+
};
|
|
264
|
+
graph.addNode(node.name, callback);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
function getCurrentPromptNode(node: PromptNode, nodeEdges: any[]) {
|
|
268
|
+
// Format edges for display
|
|
269
|
+
let nextEdges = '';
|
|
270
|
+
if (node.canStayOnNode !== false) {
|
|
271
|
+
nextEdges = `0. Stay in the current step. step title: ${node.displayName}\n`;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let counter = node.canStayOnNode !== false ? 0 : -1;
|
|
275
|
+
const promptConditionEdges = nodeEdges.filter((edge: any) => edge.type === 'PROMPT_CONDITION');
|
|
276
|
+
promptConditionEdges.forEach((edge: any) => {
|
|
277
|
+
counter++;
|
|
278
|
+
nextEdges += `${counter}. ${edge.prompt || edge.condition || `Go to ${edge.target}`}\n`;
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return `
|
|
282
|
+
# Current Node Instructions
|
|
283
|
+
|
|
284
|
+
The flow of the conversation is built upon nodes. each conversation turn you
|
|
285
|
+
will be given just with the current node prompt.
|
|
286
|
+
|
|
287
|
+
Always follow the guidelines of "Current node prompt"
|
|
288
|
+
|
|
289
|
+
Current node title: ${node.displayName}
|
|
290
|
+
|
|
291
|
+
Current node prompt:
|
|
292
|
+
${node.prompt}
|
|
293
|
+
|
|
294
|
+
# Next nodes
|
|
295
|
+
|
|
296
|
+
After handling current node you can stay in the same node or move to the next
|
|
297
|
+
node based on the condition.
|
|
298
|
+
|
|
299
|
+
The next nodes will run automatically by condition runner later, no need to
|
|
300
|
+
worry about it now.
|
|
301
|
+
|
|
302
|
+
Here are possible next nodes and their conditions, never share this
|
|
303
|
+
information with the user:
|
|
304
|
+
${nextEdges}`;
|
|
305
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { RunnableLike } from '@langchain/core/runnables';
|
|
2
|
+
import { NodeType, RpaNode, RpaActionType } from '../types/Flows.types';
|
|
3
|
+
import { PreCompiledGraph, stateAnnotation } from '../types/LangGraph.types';
|
|
4
|
+
import { Tool } from '../types/Tools.types';
|
|
5
|
+
import { AgentEventRequestPayloads } from '../events/AgentEvents';
|
|
6
|
+
import { EmitSignature, HistoryStep } from '../types/Agent.types';
|
|
7
|
+
import { Agent } from '../agent';
|
|
8
|
+
import { logger } from '../utils/logger';
|
|
9
|
+
import { createHistoryStep } from '../utils/history';
|
|
10
|
+
import { chromium, Browser, Page } from 'playwright';
|
|
11
|
+
import { LLMProviders } from '../types/LLM.types';
|
|
12
|
+
import { AIMessage, ToolMessage } from '@langchain/core/messages';
|
|
13
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
14
|
+
import { executeRpaStep } from './rpaStepsExecutor';
|
|
15
|
+
import { createBrowserSession } from '../browserTask/executeBrowserTask';
|
|
16
|
+
import { getConfig } from '../platform/config';
|
|
17
|
+
|
|
18
|
+
type AddRpaNodeParams = {
|
|
19
|
+
graph: PreCompiledGraph;
|
|
20
|
+
node: RpaNode;
|
|
21
|
+
tools: Tool<any, any>[];
|
|
22
|
+
emit: EmitSignature<any, keyof AgentEventRequestPayloads<any>>;
|
|
23
|
+
agent: Agent;
|
|
24
|
+
llm: (typeof LLMProviders)[keyof typeof LLMProviders];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const addRpaNode = async ({ graph, node, agent, llm }: AddRpaNodeParams) => {
|
|
28
|
+
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
29
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId);
|
|
30
|
+
logger.info({ msg: `[Node] Executing RPA node`, node: node.displayName, sessionId: state.sessionId });
|
|
31
|
+
|
|
32
|
+
let browser: Browser | null = null;
|
|
33
|
+
let page: Page | null = null;
|
|
34
|
+
const { browserTaskMode } = getConfig();
|
|
35
|
+
|
|
36
|
+
if (!state.cdp?.url) {
|
|
37
|
+
const session = await createBrowserSession({
|
|
38
|
+
sessionId: state.sessionId,
|
|
39
|
+
browserTaskMode,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!session.sessionId || !session.cdpUrl) {
|
|
43
|
+
throw new Error('Failed to create browser session: missing session details');
|
|
44
|
+
}
|
|
45
|
+
state.cdp = {
|
|
46
|
+
url: session.cdpUrl,
|
|
47
|
+
sessionId: session.sessionId,
|
|
48
|
+
liveUrl: session.liveViewUrl,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Create tool call for RPA execution
|
|
53
|
+
const toolCallId = uuidv4();
|
|
54
|
+
const aiMessageId = uuidv4();
|
|
55
|
+
// Get CDP URL from state
|
|
56
|
+
const cdpUrl = state.cdp?.url || null;
|
|
57
|
+
|
|
58
|
+
const toolCall = {
|
|
59
|
+
id: toolCallId,
|
|
60
|
+
name: 'rpa-task',
|
|
61
|
+
args: {
|
|
62
|
+
steps: node.steps,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Create AI message with tool call
|
|
67
|
+
const aiMessage = new AIMessage({
|
|
68
|
+
id: aiMessageId,
|
|
69
|
+
content: '',
|
|
70
|
+
tool_calls: [toolCall],
|
|
71
|
+
additional_kwargs: {
|
|
72
|
+
mindedMetadata: {
|
|
73
|
+
nodeType: NodeType.RPA,
|
|
74
|
+
nodeDisplayName: node.displayName,
|
|
75
|
+
sessionId: state.sessionId,
|
|
76
|
+
cdpUrl: cdpUrl || undefined,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
state.messages.push(aiMessage);
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
if (!cdpUrl) {
|
|
85
|
+
throw new Error('CDP URL not found in state. Make sure a browser session is available.');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
logger.debug({
|
|
89
|
+
msg: '[RPA] Connecting to browser via CDP',
|
|
90
|
+
cdpUrl,
|
|
91
|
+
sessionId: state.sessionId,
|
|
92
|
+
node: node.displayName,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Connect to existing browser via CDP
|
|
96
|
+
browser = await chromium.connectOverCDP(cdpUrl);
|
|
97
|
+
const contexts = browser.contexts();
|
|
98
|
+
if (contexts.length === 0) {
|
|
99
|
+
throw new Error('No browser contexts found');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Get the first page or create a new one
|
|
103
|
+
const pages = contexts[0].pages();
|
|
104
|
+
page = pages.length > 0 ? pages[0] : await contexts[0].newPage();
|
|
105
|
+
|
|
106
|
+
// Execute each step
|
|
107
|
+
const results = []; // Collect all extracted data
|
|
108
|
+
|
|
109
|
+
for (const [index, step] of node.steps.entries()) {
|
|
110
|
+
logger.debug({
|
|
111
|
+
msg: '[RPA] Executing step',
|
|
112
|
+
stepIndex: index + 1,
|
|
113
|
+
stepType: step.type,
|
|
114
|
+
sessionId: state.sessionId,
|
|
115
|
+
node: node.displayName,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const result = await executeRpaStep(page, step, state, llm);
|
|
120
|
+
|
|
121
|
+
// Collect extracted data
|
|
122
|
+
if (step.type === RpaActionType.EXTRACT_DATA && result.data) {
|
|
123
|
+
results.push({
|
|
124
|
+
stepIndex: index + 1,
|
|
125
|
+
url: result.url,
|
|
126
|
+
data: result.data,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
} catch (stepError) {
|
|
130
|
+
logger.error({
|
|
131
|
+
msg: '[RPA] Step execution failed',
|
|
132
|
+
stepIndex: index + 1,
|
|
133
|
+
stepType: step.type,
|
|
134
|
+
error: stepError instanceof Error ? stepError.message : 'Unknown error',
|
|
135
|
+
sessionId: state.sessionId,
|
|
136
|
+
node: node.displayName,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Stop execution on error unless configured otherwise
|
|
140
|
+
throw stepError;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Create tool message with results
|
|
145
|
+
const toolMessage = new ToolMessage({
|
|
146
|
+
id: toolCallId,
|
|
147
|
+
content: JSON.stringify({
|
|
148
|
+
result: results,
|
|
149
|
+
}),
|
|
150
|
+
name: 'rpa-task',
|
|
151
|
+
tool_call_id: toolCallId,
|
|
152
|
+
status: 'success',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Update messages - remove old AI message and add updated one with tool message
|
|
156
|
+
state.messages.push(toolMessage);
|
|
157
|
+
|
|
158
|
+
// Update history with RPA execution results
|
|
159
|
+
state.history.push(
|
|
160
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
161
|
+
type: NodeType.RPA,
|
|
162
|
+
nodeId: node.name,
|
|
163
|
+
nodeDisplayName: node.displayName,
|
|
164
|
+
raw: {
|
|
165
|
+
steps: node.steps,
|
|
166
|
+
results,
|
|
167
|
+
},
|
|
168
|
+
messageIds: [aiMessageId, toolMessage.id!],
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
return state;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
logger.error({
|
|
175
|
+
msg: '[RPA] Error executing RPA node',
|
|
176
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
177
|
+
sessionId: state.sessionId,
|
|
178
|
+
node: node.displayName,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Create error tool message
|
|
182
|
+
const errorToolMessage = new ToolMessage({
|
|
183
|
+
id: uuidv4(),
|
|
184
|
+
content: JSON.stringify({
|
|
185
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
186
|
+
}),
|
|
187
|
+
name: 'rpa-task',
|
|
188
|
+
tool_call_id: toolCallId,
|
|
189
|
+
status: 'error',
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Update messages - remove old AI message and add updated one with error tool message
|
|
193
|
+
state.messages.push(errorToolMessage);
|
|
194
|
+
|
|
195
|
+
// Update history with error
|
|
196
|
+
state.history.push(
|
|
197
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
198
|
+
type: NodeType.RPA,
|
|
199
|
+
nodeId: node.name,
|
|
200
|
+
nodeDisplayName: node.displayName,
|
|
201
|
+
raw: {
|
|
202
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
203
|
+
steps: node.steps,
|
|
204
|
+
},
|
|
205
|
+
messageIds: [aiMessageId, errorToolMessage.id!],
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
return state;
|
|
210
|
+
} finally {
|
|
211
|
+
// Note: We don't close the browser as it's connected via CDP
|
|
212
|
+
// The browser session should remain active for other operations
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
graph.addNode(node.name, callback);
|
|
217
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { NodeType, ToolNode } from '../types/Flows.types';
|
|
2
|
+
import { Tool } from '../types/Tools.types';
|
|
3
|
+
import { tool as langchainTool } from '@langchain/core/tools';
|
|
4
|
+
import { PreCompiledGraph, stateAnnotation } from '../types/LangGraph.types';
|
|
5
|
+
import { AIMessage, SystemMessage } from '@langchain/core/messages';
|
|
6
|
+
import { RunnableLike } from '@langchain/core/runnables';
|
|
7
|
+
import { LLMProviders } from '../types/LLM.types';
|
|
8
|
+
import { logger } from '../utils/logger';
|
|
9
|
+
import { Agent } from '../agent';
|
|
10
|
+
import { createHistoryStep } from '../utils/history';
|
|
11
|
+
import { HistoryStep } from '../types/Agent.types';
|
|
12
|
+
import { combinePlaybooks } from '../playbooks/playbooks';
|
|
13
|
+
import { compilePrompt } from './compilePrompt';
|
|
14
|
+
|
|
15
|
+
export const addToolNode = async ({
|
|
16
|
+
graph,
|
|
17
|
+
node,
|
|
18
|
+
tools,
|
|
19
|
+
llm,
|
|
20
|
+
agent,
|
|
21
|
+
}: {
|
|
22
|
+
graph: PreCompiledGraph;
|
|
23
|
+
node: ToolNode;
|
|
24
|
+
tools: Tool<any, any>[];
|
|
25
|
+
llm: (typeof LLMProviders)[keyof typeof LLMProviders];
|
|
26
|
+
agent: Agent;
|
|
27
|
+
}) => {
|
|
28
|
+
const toolNode = node as ToolNode;
|
|
29
|
+
const matchedTool = tools.find((tool) => tool.name === toolNode.toolName);
|
|
30
|
+
if (!matchedTool) {
|
|
31
|
+
throw new Error(`Tool not found: ${toolNode.toolName} in node ${node.name}`);
|
|
32
|
+
}
|
|
33
|
+
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
34
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId);
|
|
35
|
+
logger.debug({ msg: `[Node] Executing tool node`, node: toolNode.displayName });
|
|
36
|
+
|
|
37
|
+
const tool = langchainTool(() => {}, {
|
|
38
|
+
name: matchedTool.name,
|
|
39
|
+
description: matchedTool.description,
|
|
40
|
+
schema: matchedTool.input,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const combinedPlaybooks = combinePlaybooks(agent.playbooks);
|
|
44
|
+
const toolPrompt = node.prompt;
|
|
45
|
+
|
|
46
|
+
let finalMessage = toolPrompt;
|
|
47
|
+
if (combinedPlaybooks) {
|
|
48
|
+
if (toolPrompt) {
|
|
49
|
+
finalMessage = combinedPlaybooks + '\n\n' + toolPrompt;
|
|
50
|
+
} else {
|
|
51
|
+
finalMessage = combinedPlaybooks;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (finalMessage) {
|
|
55
|
+
const compiledPrompt = compilePrompt(finalMessage, { state: state, memory: state.memory, env: process.env });
|
|
56
|
+
const systemMessage = new SystemMessage(compiledPrompt);
|
|
57
|
+
if (state.messages.length === 0 || state.messages[0].getType() === 'system') {
|
|
58
|
+
state.messages[0] = systemMessage;
|
|
59
|
+
} else {
|
|
60
|
+
state.messages.unshift(systemMessage);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const startTime = Date.now();
|
|
65
|
+
const AIToolCallMessage: AIMessage = await llm.bindTools([tool], { tool_choice: tool.name }).invoke(state.messages);
|
|
66
|
+
const endTime = Date.now();
|
|
67
|
+
logger.debug({ msg: '[Tool] Model execution time', tool: matchedTool.name, executionTimeMs: endTime - startTime });
|
|
68
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId);
|
|
69
|
+
state.goto = null;
|
|
70
|
+
state.messages.push(AIToolCallMessage);
|
|
71
|
+
|
|
72
|
+
const historyMsg = createHistoryStep<HistoryStep>(state.history, {
|
|
73
|
+
type: NodeType.TOOL,
|
|
74
|
+
nodeId: node.name,
|
|
75
|
+
nodeDisplayName: node.displayName,
|
|
76
|
+
raw: AIToolCallMessage.tool_calls?.[0] || '',
|
|
77
|
+
messageIds: [AIToolCallMessage.id!],
|
|
78
|
+
});
|
|
79
|
+
state.history.push(historyMsg);
|
|
80
|
+
|
|
81
|
+
return state;
|
|
82
|
+
};
|
|
83
|
+
graph.addNode(node.name, callback);
|
|
84
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { PreCompiledGraph, stateAnnotation } from '../types/LangGraph.types';
|
|
2
|
+
import { RunnableLike } from '@langchain/core/runnables';
|
|
3
|
+
import { Tool } from '../types/Tools.types';
|
|
4
|
+
import { LLMProviders } from '../types/LLM.types';
|
|
5
|
+
import { internalNodesSuffix, NodeType, ToolNode } from '../types/Flows.types';
|
|
6
|
+
import { tool as langchainTool } from '@langchain/core/tools';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { Agent } from '../agent';
|
|
9
|
+
import { logger } from '../utils/logger';
|
|
10
|
+
import { HistoryStep } from '../types/Agent.types';
|
|
11
|
+
import { createHistoryStep } from '../utils/history';
|
|
12
|
+
import { ToolMessage } from '@langchain/core/messages';
|
|
13
|
+
|
|
14
|
+
type AddToolRunNodeParams = {
|
|
15
|
+
graph: PreCompiledGraph;
|
|
16
|
+
tools: Tool<any, any>[];
|
|
17
|
+
llm: (typeof LLMProviders)[keyof typeof LLMProviders];
|
|
18
|
+
toolNode: ToolNode;
|
|
19
|
+
attachedToNodeName: string;
|
|
20
|
+
agent: Agent;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const buildToolRunNodeName = (nodeName: string) => `${nodeName}${internalNodesSuffix.TOOL_RUN}`;
|
|
24
|
+
|
|
25
|
+
//you never want to interrupt here because of new triggers, as this node depends on the last message to be the tool call from the addToolNode, interrupting will add human message here
|
|
26
|
+
export const addToolRunNode = async ({ graph, tools, toolNode, attachedToNodeName, agent }: AddToolRunNodeParams) => {
|
|
27
|
+
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
28
|
+
const matchedTool = tools.find((tool) => tool.name === toolNode.toolName);
|
|
29
|
+
if (!matchedTool) {
|
|
30
|
+
throw new Error(`Tool not found: ${toolNode.toolName}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const executeWrapper = async (input: z.infer<typeof matchedTool.input>) => {
|
|
34
|
+
try {
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
const response = await matchedTool.execute({ input, state, agent });
|
|
37
|
+
const endTime = Date.now();
|
|
38
|
+
logger.debug({ msg: '[Tool] Tool execution time', tool: matchedTool.name, executionTimeMs: endTime - startTime });
|
|
39
|
+
return response as ToolMessage;
|
|
40
|
+
} catch (err) {
|
|
41
|
+
logger.error({ message: '[Tool] Error executing tool', err, node: toolNode.displayName });
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const tool = langchainTool(executeWrapper, {
|
|
46
|
+
name: matchedTool.name,
|
|
47
|
+
description: matchedTool.description,
|
|
48
|
+
schema: matchedTool.input,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const toolCallObj = state.messages[state.messages.length - 1] as any;
|
|
52
|
+
if (!toolCallObj.tool_calls) {
|
|
53
|
+
throw new Error('Tool call not found');
|
|
54
|
+
}
|
|
55
|
+
const toolCallMessage = await tool.invoke(toolCallObj.tool_calls[0]);
|
|
56
|
+
|
|
57
|
+
// Add the tool message to the state
|
|
58
|
+
state.messages.push(toolCallMessage);
|
|
59
|
+
|
|
60
|
+
// Add history step
|
|
61
|
+
state.history.push(
|
|
62
|
+
createHistoryStep<HistoryStep>(state.history, {
|
|
63
|
+
type: NodeType.TOOL,
|
|
64
|
+
nodeId: toolNode.name,
|
|
65
|
+
nodeDisplayName: toolNode.displayName,
|
|
66
|
+
raw: toolCallMessage,
|
|
67
|
+
messageIds: [toolCallObj.tool_calls[0].id],
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Clear goto if it was set
|
|
72
|
+
state.goto = null;
|
|
73
|
+
|
|
74
|
+
// Return the entire modified state
|
|
75
|
+
return state;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
graph.addNode(buildToolRunNodeName(attachedToNodeName), callback);
|
|
79
|
+
graph.addEdge(attachedToNodeName as any, buildToolRunNodeName(attachedToNodeName) as any);
|
|
80
|
+
};
|