@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,540 @@
|
|
|
1
|
+
# Agent API
|
|
2
|
+
|
|
3
|
+
The Agent class is the core component of MindedJS that orchestrates conversations, manages state, and coordinates flows. This document covers the initialization options and key methods available on the Agent instance.
|
|
4
|
+
|
|
5
|
+
## Constructor
|
|
6
|
+
|
|
7
|
+
The Agent constructor accepts configuration options to customize its behavior:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
new Agent({
|
|
11
|
+
memorySchema: z.ZodSchema,
|
|
12
|
+
config: MindedSDKConfig,
|
|
13
|
+
tools: Tool[],
|
|
14
|
+
platformToken?: string,
|
|
15
|
+
memorySaver?: BaseCheckpointSaver,
|
|
16
|
+
interruptSessionManager?: InterruptSessionManager,
|
|
17
|
+
parseSessionIdFromTrigger?: (trigger: any) => string,
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Options
|
|
22
|
+
|
|
23
|
+
- **memorySchema** (required): Zod schema defining the agent's memory structure
|
|
24
|
+
- **config** (required): SDK configuration including flows and LLM settings
|
|
25
|
+
- **tools** (required): Array of custom tools available to the agent
|
|
26
|
+
- **platformToken**: Optional token for platform authentication
|
|
27
|
+
- **memorySaver**: Optional custom checkpoint saver for conversation memory
|
|
28
|
+
- **interruptSessionManager**: Optional custom interrupt session manager
|
|
29
|
+
- **parseSessionIdFromTrigger**: Optional function to extract session ID from triggers (defaults to `triggerBody.sessionId`)
|
|
30
|
+
|
|
31
|
+
## Key Methods
|
|
32
|
+
|
|
33
|
+
### updateState
|
|
34
|
+
|
|
35
|
+
Updates the state of an active session. This method allows you to programmatically modify the conversation state, including messages, memory, and other state properties.
|
|
36
|
+
|
|
37
|
+
#### Signature
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
async updateState({
|
|
41
|
+
sessionId: string,
|
|
42
|
+
state: Partial<State>
|
|
43
|
+
}): Promise<void>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Parameters
|
|
47
|
+
|
|
48
|
+
- `sessionId` (string): The unique identifier of the session to update
|
|
49
|
+
- `state` (Partial<State>): An object containing the state properties to update. Can include:
|
|
50
|
+
- `messages`: Array of messages to add or update
|
|
51
|
+
- `memory`: Partial memory object to merge with existing memory
|
|
52
|
+
- `goto`: Node ID to override the next execution point
|
|
53
|
+
- Any other state properties defined in your agent
|
|
54
|
+
|
|
55
|
+
#### Usage Examples
|
|
56
|
+
|
|
57
|
+
##### Update Memory
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Update specific memory fields
|
|
61
|
+
await agent.updateState({
|
|
62
|
+
sessionId: 'session-123',
|
|
63
|
+
state: {
|
|
64
|
+
memory: {
|
|
65
|
+
user: {
|
|
66
|
+
name: 'John Doe',
|
|
67
|
+
preferences: {
|
|
68
|
+
language: 'en',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
##### Add Messages
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { HumanMessage, AIMessage } from '@langchain/core/messages';
|
|
80
|
+
|
|
81
|
+
// Add a new message to the conversation
|
|
82
|
+
await agent.updateState({
|
|
83
|
+
sessionId: 'session-123',
|
|
84
|
+
state: {
|
|
85
|
+
messages: [new HumanMessage('User input'), new AIMessage('Agent response')],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### Update Multiple State Properties
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// Update both memory and messages
|
|
94
|
+
await agent.updateState({
|
|
95
|
+
sessionId: 'session-123',
|
|
96
|
+
state: {
|
|
97
|
+
memory: {
|
|
98
|
+
conversation: {
|
|
99
|
+
topic: 'Order inquiry',
|
|
100
|
+
urgency: 'high',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
messages: [new HumanMessage('I need help with my order')],
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Common Use Cases
|
|
109
|
+
|
|
110
|
+
1. **Tool State Updates**: Tools can update state after execution
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Inside a tool's execute method
|
|
114
|
+
async execute({ input, state, agent }) {
|
|
115
|
+
// Perform tool logic
|
|
116
|
+
const result = await processOrder(input.orderId);
|
|
117
|
+
|
|
118
|
+
// Update state with results
|
|
119
|
+
await agent.updateState({
|
|
120
|
+
sessionId: state.sessionId,
|
|
121
|
+
state: {
|
|
122
|
+
memory: {
|
|
123
|
+
order: {
|
|
124
|
+
id: result.orderId,
|
|
125
|
+
status: result.status
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return { result };
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
2. **External Event Handling**: Update state based on external events
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Handle webhook or external trigger
|
|
139
|
+
async handleWebhook(sessionId: string, webhookData: any) {
|
|
140
|
+
await agent.updateState({
|
|
141
|
+
sessionId,
|
|
142
|
+
state: {
|
|
143
|
+
memory: {
|
|
144
|
+
externalData: webhookData,
|
|
145
|
+
lastWebhookTime: new Date().toISOString()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
3. **Voice Session Corrections**: Update messages during voice conversations
|
|
153
|
+
```typescript
|
|
154
|
+
// Correct a voice transcription
|
|
155
|
+
await agent.updateState({
|
|
156
|
+
sessionId: voiceSessionId,
|
|
157
|
+
state: {
|
|
158
|
+
messages: [correctedMessage],
|
|
159
|
+
goto: currentNodeId,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### getState
|
|
165
|
+
|
|
166
|
+
Retrieves the current state of a session.
|
|
167
|
+
|
|
168
|
+
#### Signature
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
async getState(sessionId: string): Promise<State<Memory>>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Parameters
|
|
175
|
+
|
|
176
|
+
- `sessionId` (string): The unique identifier of the session
|
|
177
|
+
|
|
178
|
+
#### Returns
|
|
179
|
+
|
|
180
|
+
A `State` object containing:
|
|
181
|
+
|
|
182
|
+
- `sessionId`: The session identifier
|
|
183
|
+
- `memory`: The current memory state
|
|
184
|
+
- `messages`: Array of conversation messages
|
|
185
|
+
- `sessionType`: The type of session (TEXT, VOICE, etc.)
|
|
186
|
+
- Other state properties
|
|
187
|
+
|
|
188
|
+
#### Usage Example
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Get current state
|
|
192
|
+
const state = await agent.getState('session-123');
|
|
193
|
+
|
|
194
|
+
// Access memory
|
|
195
|
+
console.log('User name:', state.memory.user?.name);
|
|
196
|
+
|
|
197
|
+
// Check conversation history
|
|
198
|
+
console.log('Message count:', state.messages.length);
|
|
199
|
+
|
|
200
|
+
// Get session type
|
|
201
|
+
console.log('Session type:', state.sessionType);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### compiledGraph
|
|
205
|
+
|
|
206
|
+
Access to the underlying LangGraph compiled graph for advanced operations.
|
|
207
|
+
|
|
208
|
+
#### Usage Example
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// Get LangGraph state directly
|
|
212
|
+
const graphState = await agent.compiledGraph.getState(agent.getLangraphConfig(sessionId));
|
|
213
|
+
|
|
214
|
+
// Update state with LangGraph API
|
|
215
|
+
await agent.compiledGraph.updateState(agent.getLangraphConfig(sessionId), {
|
|
216
|
+
messages: [newMessage],
|
|
217
|
+
goto: 'specific-node',
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## State Management Best Practices
|
|
222
|
+
|
|
223
|
+
### 1. Partial Updates
|
|
224
|
+
|
|
225
|
+
Always use partial updates to avoid overwriting existing state:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
// ✅ Good - Partial update
|
|
229
|
+
await agent.updateState({
|
|
230
|
+
sessionId,
|
|
231
|
+
state: {
|
|
232
|
+
memory: {
|
|
233
|
+
user: { name: 'Jane' },
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// ❌ Avoid - Don't replace entire memory
|
|
239
|
+
await agent.updateState({
|
|
240
|
+
sessionId,
|
|
241
|
+
state: {
|
|
242
|
+
memory: completeMemoryObject, // This might lose other fields
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### 2. Atomic Operations
|
|
248
|
+
|
|
249
|
+
Group related updates together:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
// ✅ Good - Single atomic update
|
|
253
|
+
await agent.updateState({
|
|
254
|
+
sessionId,
|
|
255
|
+
state: {
|
|
256
|
+
memory: {
|
|
257
|
+
order: { id: '123', status: 'confirmed' },
|
|
258
|
+
lastAction: 'order_confirmed',
|
|
259
|
+
},
|
|
260
|
+
messages: [confirmationMessage],
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// ❌ Avoid - Multiple separate updates
|
|
265
|
+
await agent.updateState({ sessionId, state: { memory: { order: { id: '123' } } } });
|
|
266
|
+
await agent.updateState({ sessionId, state: { memory: { order: { status: 'confirmed' } } } });
|
|
267
|
+
await agent.updateState({ sessionId, state: { messages: [confirmationMessage] } });
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 3. State Validation
|
|
271
|
+
|
|
272
|
+
The state updates are validated against your memory schema:
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
try {
|
|
276
|
+
await agent.updateState({
|
|
277
|
+
sessionId,
|
|
278
|
+
state: {
|
|
279
|
+
memory: {
|
|
280
|
+
user: {
|
|
281
|
+
email: 'invalid-email', // Will fail validation if email has format validation
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
} catch (err) {
|
|
287
|
+
logger.error({ message: 'State validation failed', err });
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### 4. Tool State Updates
|
|
292
|
+
|
|
293
|
+
Tools should return state updates rather than calling `updateState` directly when possible:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
// ✅ Preferred - Return state updates
|
|
297
|
+
async execute({ input, state }) {
|
|
298
|
+
const result = await processData(input);
|
|
299
|
+
return {
|
|
300
|
+
result,
|
|
301
|
+
state: {
|
|
302
|
+
memory: {
|
|
303
|
+
processedData: result.data
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// ⚠️ Use only when necessary - Direct update
|
|
310
|
+
async execute({ input, state, agent }) {
|
|
311
|
+
const result = await processData(input);
|
|
312
|
+
await agent.updateState({
|
|
313
|
+
sessionId: state.sessionId,
|
|
314
|
+
state: {
|
|
315
|
+
memory: { processedData: result.data }
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
return { result };
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Tool Execution API
|
|
323
|
+
|
|
324
|
+
### ToolExecutor
|
|
325
|
+
|
|
326
|
+
The `ToolExecutor` class enables standalone tool execution, particularly useful for browser automation and external tool invocations.
|
|
327
|
+
|
|
328
|
+
#### Setting Up Tool Execution
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import { ToolExecutor } from '@minded-ai/mindedjs';
|
|
332
|
+
|
|
333
|
+
// Create a tool executor
|
|
334
|
+
const toolExecutor = new ToolExecutor(agent);
|
|
335
|
+
|
|
336
|
+
// Register tools that can be executed via requests
|
|
337
|
+
// Only tools with allowExecutionRequests: true will be registered
|
|
338
|
+
toolExecutor.registerTools(tools);
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### Tool Configuration for Execution
|
|
342
|
+
|
|
343
|
+
Tools must explicitly opt-in to be executable via requests:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
import { Tool } from '@minded-ai/mindedjs';
|
|
347
|
+
|
|
348
|
+
const myBrowserTool: Tool<typeof schema, Memory> = {
|
|
349
|
+
name: 'browserAction',
|
|
350
|
+
description: 'Performs browser automation',
|
|
351
|
+
input: schema,
|
|
352
|
+
allowExecutionRequests: true, // Required for ToolExecutor
|
|
353
|
+
execute: async ({ input, state, agent }) => {
|
|
354
|
+
// Access CDP URL if available (browser-use context)
|
|
355
|
+
if (state.cdp?.url) {
|
|
356
|
+
// Connect to browser using Playwright or similar
|
|
357
|
+
const browser = await chromium.connectOverCDP(state.cdp.url);
|
|
358
|
+
const page = browser.contexts()[0].pages()[0];
|
|
359
|
+
|
|
360
|
+
// Perform browser automation
|
|
361
|
+
await page.goto(input.url);
|
|
362
|
+
const title = await page.title();
|
|
363
|
+
|
|
364
|
+
return {
|
|
365
|
+
result: { pageTitle: title },
|
|
366
|
+
state: {
|
|
367
|
+
memory: {
|
|
368
|
+
lastVisitedUrl: input.url,
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Fallback for non-browser context
|
|
375
|
+
return { result: 'Browser context not available' };
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### Executing Tools
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
const response = await toolExecutor.executeTool({
|
|
384
|
+
toolName: 'browserAction',
|
|
385
|
+
toolParams: { url: 'https://example.com' },
|
|
386
|
+
sessionId: 'session-123',
|
|
387
|
+
requestId: 'req-456',
|
|
388
|
+
cdpUrl: 'ws://localhost:9222/devtools/browser/...', // Optional, for browser-use
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
if (response.error) {
|
|
392
|
+
logger.error({ message: 'Tool execution failed', error: response.error });
|
|
393
|
+
} else {
|
|
394
|
+
logger.info({ message: 'Tool result', result: response.result });
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### CDP URL and Browser Automation
|
|
399
|
+
|
|
400
|
+
When tools are executed in a browser-use context, the Chrome DevTools Protocol (CDP) URL is available in the state:
|
|
401
|
+
|
|
402
|
+
#### Accessing CDP URL in Tools
|
|
403
|
+
|
|
404
|
+
```typescript
|
|
405
|
+
const browserTool: Tool<typeof schema, Memory> = {
|
|
406
|
+
name: 'advancedBrowserAction',
|
|
407
|
+
description: 'Advanced browser automation with direct CDP access',
|
|
408
|
+
input: schema,
|
|
409
|
+
allowExecutionRequests: true,
|
|
410
|
+
execute: async ({ input, state, agent }) => {
|
|
411
|
+
const cdp = state.cdp;
|
|
412
|
+
|
|
413
|
+
if (!cdp?.url) {
|
|
414
|
+
return {
|
|
415
|
+
result: 'This tool requires browser context',
|
|
416
|
+
error: 'CDP URL not available',
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Use Playwright with CDP
|
|
421
|
+
const browser = await playwright.chromium.connectOverCDP(cdp.url);
|
|
422
|
+
const context = browser.contexts()[0];
|
|
423
|
+
const page = context.pages()[0];
|
|
424
|
+
|
|
425
|
+
// Perform complex browser automation
|
|
426
|
+
await page.evaluate(() => {
|
|
427
|
+
// Execute JavaScript in the browser
|
|
428
|
+
document.querySelector('#submit')?.click();
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// Take screenshot
|
|
432
|
+
const screenshot = await page.screenshot();
|
|
433
|
+
|
|
434
|
+
return {
|
|
435
|
+
result: {
|
|
436
|
+
success: true,
|
|
437
|
+
screenshot: screenshot.toString('base64'),
|
|
438
|
+
},
|
|
439
|
+
state: {
|
|
440
|
+
memory: {
|
|
441
|
+
lastAction: 'browser_automation',
|
|
442
|
+
timestamp: new Date().toISOString(),
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
};
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### Browser-Use Integration Flow
|
|
451
|
+
|
|
452
|
+
1. Browser-use requests tool execution via socket
|
|
453
|
+
2. ToolExecutor receives request with CDP URL
|
|
454
|
+
3. CDP info is injected into state (`state.cdp`)
|
|
455
|
+
4. Tool connects to browser using CDP URL from `state.cdp.url`
|
|
456
|
+
5. Tool performs automation and returns results
|
|
457
|
+
6. State updates are automatically applied
|
|
458
|
+
|
|
459
|
+
#### Security Considerations
|
|
460
|
+
|
|
461
|
+
- Tools must have `allowExecutionRequests: true` to be executable via ToolExecutor
|
|
462
|
+
- CDP URLs are only available during browser-use execution context
|
|
463
|
+
- Tools should validate CDP URL availability before attempting browser operations
|
|
464
|
+
- Always handle connection failures gracefully
|
|
465
|
+
|
|
466
|
+
## Integration with Other Features
|
|
467
|
+
|
|
468
|
+
### With Browser Use Tools
|
|
469
|
+
|
|
470
|
+
When using browser automation tools, state updates happen automatically through the ToolExecutor:
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
// Browser tools can update state via the ToolExecutor
|
|
474
|
+
const toolExecutor = new ToolExecutor(agent);
|
|
475
|
+
toolExecutor.registerTools(browserTools);
|
|
476
|
+
|
|
477
|
+
// State updates are handled internally when tools return state changes
|
|
478
|
+
// The CDP info is automatically injected when available in state.cdp
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### With Voice Sessions
|
|
482
|
+
|
|
483
|
+
Voice sessions use `updateState` for real-time corrections:
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
// Voice session correction flow
|
|
487
|
+
const voiceSession = new VoiceSession(agent, sessionId);
|
|
488
|
+
// Corrections use updateState internally
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### With Events
|
|
492
|
+
|
|
493
|
+
State can be updated in event handlers:
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, sessionId }) => {
|
|
497
|
+
if (triggerName === 'external_update') {
|
|
498
|
+
await agent.updateState({
|
|
499
|
+
sessionId,
|
|
500
|
+
state: {
|
|
501
|
+
memory: {
|
|
502
|
+
lastTrigger: triggerName,
|
|
503
|
+
triggerTime: new Date().toISOString(),
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
## Error Handling
|
|
512
|
+
|
|
513
|
+
Always handle potential errors when updating state:
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
try {
|
|
517
|
+
await agent.updateState({
|
|
518
|
+
sessionId,
|
|
519
|
+
state,
|
|
520
|
+
});
|
|
521
|
+
} catch (err) {
|
|
522
|
+
if (err.message.includes('Session not found')) {
|
|
523
|
+
// Handle missing session
|
|
524
|
+
logger.error({ message: 'Session does not exist', sessionId, err });
|
|
525
|
+
} else if (err.message.includes('Validation')) {
|
|
526
|
+
// Handle validation errors
|
|
527
|
+
logger.error({ message: 'Invalid state update', err });
|
|
528
|
+
} else {
|
|
529
|
+
// Handle other errors
|
|
530
|
+
logger.error({ message: 'Failed to update state', err });
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
## Related Documentation
|
|
536
|
+
|
|
537
|
+
- [Memory](./memory.md) - Learn about memory schemas and management
|
|
538
|
+
- [Events](./events.md) - Handle agent events and triggers
|
|
539
|
+
- [Debugging](./debugging.md) - Debug state updates and transitions
|
|
540
|
+
- [Tools](../low-code-editor/tools.md) - Create tools that update state
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Debugging
|
|
2
|
+
|
|
3
|
+
MindedJS provides comprehensive debugging capabilities to help you understand and troubleshoot your agent's behavior during development and production. This guide covers various debugging techniques and tools available in the SDK.
|
|
4
|
+
|
|
5
|
+
## Debug Logging
|
|
6
|
+
|
|
7
|
+
Set the log level to debug in your environment:
|
|
8
|
+
|
|
9
|
+
```env
|
|
10
|
+
LOG_LEVEL=debug
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Debugging Logical Conditions
|
|
14
|
+
|
|
15
|
+
You can debug and breakpoint on logical conditions during development:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Listen to condition evaluation events
|
|
19
|
+
import { AgentEvents } from 'mindedjs';
|
|
20
|
+
|
|
21
|
+
agent.on(AgentEvents.ON_LOGICAL_CONDITION, async ({ edge, state, condition }) => {
|
|
22
|
+
console.log('[Debug] Evaluating condition:', condition);
|
|
23
|
+
console.log('[Debug] Current memory:', state.memory);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
agent.on(AgentEvents.ON_LOGICAL_CONDITION_RESULT, async ({ condition, result, executionTimeMs }) => {
|
|
27
|
+
console.log('[Debug] Result:', result);
|
|
28
|
+
console.log('[Debug] Execution time:', executionTimeMs, 'ms');
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## LLM Debug Callback Handler
|
|
33
|
+
|
|
34
|
+
A good practice is to periodically inspect the actual messages being sent to the LLM to ensure they match your expectations.
|
|
35
|
+
You can breakpoint and view the final prompt messages after compilation using `LLMDebugCallbackHandler`.
|
|
36
|
+
|
|
37
|
+
### Using the LLM Debug Callback Handler
|
|
38
|
+
|
|
39
|
+
The `LLMDebugCallbackHandler` can be imported directly from the main package:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { Agent, LLMDebugCallbackHandler } from '@minded-ai/mindedjs';
|
|
43
|
+
|
|
44
|
+
// Create the debug handler
|
|
45
|
+
const debugHandler = new LLMDebugCallbackHandler();
|
|
46
|
+
|
|
47
|
+
// Configure your agent with the debug handler
|
|
48
|
+
const agent = new Agent({
|
|
49
|
+
config: {
|
|
50
|
+
...config,
|
|
51
|
+
llm: {
|
|
52
|
+
...config.llm,
|
|
53
|
+
properties: {
|
|
54
|
+
...config.llm.properties,
|
|
55
|
+
callbacks: [debugHandler],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
tools,
|
|
60
|
+
memorySchema,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Advanced Usage - Custom Debug Handler
|
|
65
|
+
|
|
66
|
+
You can extend the `LLMDebugCallbackHandler` to add your own debugging logic:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { LLMDebugCallbackHandler } from '@minded-ai/mindedjs';
|
|
70
|
+
|
|
71
|
+
class CustomDebugHandler extends LLMDebugCallbackHandler {
|
|
72
|
+
async handleLLMEnd(output: any, ...args: any[]): Promise<void> {
|
|
73
|
+
// Log token usage if available
|
|
74
|
+
const tokenUsage = output.llmOutput?.tokenUsage;
|
|
75
|
+
console.log(`Token usage: ${tokenUsage.totalTokens}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The `LLMDebugCallbackHandler` extends LangChain's `BaseCallbackHandler` and can override different mathods in langchain flow. See the [LangChain documentation](https://js.langchain.com/docs/modules/callbacks/).
|