@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,595 @@
|
|
|
1
|
+
# Events
|
|
2
|
+
|
|
3
|
+
Events are messages that flow through your agent during execution, providing visibility into what's happening and enabling reactive behavior.
|
|
4
|
+
|
|
5
|
+
MindedJS currently supports 6 main event types. Each event type has its own specific input structure, output requirements, and use cases.
|
|
6
|
+
|
|
7
|
+
## History Structure
|
|
8
|
+
|
|
9
|
+
All events provide access to the agent's history, which is a crucial part of understanding and tracking the execution flow. The history is an array of `HistoryStep` objects that represent each step the agent has taken during execution.
|
|
10
|
+
|
|
11
|
+
### HistoryStep Structure
|
|
12
|
+
|
|
13
|
+
Each history step contains the following information:
|
|
14
|
+
|
|
15
|
+
- `step`: Sequential step number in the agent's execution flow
|
|
16
|
+
- `type`: Type of the step (e.g., TRIGGER_NODE, APP_TRIGGER_NODE, TOOL_NODE, LLM_NODE)
|
|
17
|
+
- `nodeId`: ID of the node that was executed
|
|
18
|
+
- `nodeDisplayName`: Human-readable name of the node
|
|
19
|
+
- `raw`: Raw data associated with the step (e.g., trigger input, tool output)
|
|
20
|
+
- `messageIds`: IDs of messages associated with this step
|
|
21
|
+
|
|
22
|
+
Additional fields are available depending on the step type:
|
|
23
|
+
|
|
24
|
+
- For `APP_TRIGGER_NODE` steps: `appName` identifies the source application
|
|
25
|
+
- For `TOOL_NODE` steps: Contains tool input and output information
|
|
26
|
+
|
|
27
|
+
### Example Usage
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
agent.on(events.AI_MESSAGE, async ({ message, state }) => {
|
|
31
|
+
// Access the complete execution history
|
|
32
|
+
const history = state.history;
|
|
33
|
+
|
|
34
|
+
// Find the initial trigger that started this conversation
|
|
35
|
+
const triggerStep = history.find((step) => step.type === 'TRIGGER_NODE' || step.type === 'APP_TRIGGER_NODE');
|
|
36
|
+
|
|
37
|
+
// Find all tool executions in this conversation
|
|
38
|
+
const toolSteps = history.filter((step) => step.type === 'TOOL_NODE');
|
|
39
|
+
|
|
40
|
+
// Get the last executed node
|
|
41
|
+
const lastStep = history[history.length - 1];
|
|
42
|
+
|
|
43
|
+
console.log(`Conversation started with trigger: ${triggerStep?.nodeDisplayName}`);
|
|
44
|
+
console.log(`Used ${toolSteps.length} tools so far`);
|
|
45
|
+
console.log(`Last executed node: ${lastStep?.nodeDisplayName}`);
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## INIT
|
|
50
|
+
|
|
51
|
+
The `INIT` event is emitted when the agent's graph state is initialized. This happens when a new session begins or when the agent starts processing a new conversation context.
|
|
52
|
+
|
|
53
|
+
### Input Structure
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
{
|
|
57
|
+
state: { // Full initial agent state
|
|
58
|
+
messages: BaseMessage[]; // Empty array - no messages yet
|
|
59
|
+
memory: Memory; // Initial memory state (from your schema defaults)
|
|
60
|
+
history: HistoryStep[]; // Empty array - no flow history yet
|
|
61
|
+
sessionId: string; // Session identifier (generated or provided)
|
|
62
|
+
sessionType: SessionType; // Type of session (TEXT, VOICE, etc.)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Handler Return Value
|
|
68
|
+
|
|
69
|
+
- **Return type**: `void`
|
|
70
|
+
- **Purpose**: Handlers are used for side effects like logging, setup, or initialization tasks
|
|
71
|
+
- **Note**: Return values are ignored
|
|
72
|
+
|
|
73
|
+
### Usage Example
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { Agent, events } from 'mindedjs';
|
|
77
|
+
|
|
78
|
+
const agent = new Agent({
|
|
79
|
+
memorySchema,
|
|
80
|
+
config,
|
|
81
|
+
tools,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Listen to initialization events
|
|
85
|
+
agent.on(events.INIT, async ({ state }) => {
|
|
86
|
+
console.log('Agent initialized for session:', state.sessionId);
|
|
87
|
+
console.log('Session type:', state.sessionType);
|
|
88
|
+
console.log('Initial memory:', state.memory);
|
|
89
|
+
|
|
90
|
+
// Setup session-specific resources
|
|
91
|
+
await initializeSessionResources(state.sessionId);
|
|
92
|
+
|
|
93
|
+
// Log session start for analytics
|
|
94
|
+
await logSessionStart({
|
|
95
|
+
sessionId: state.sessionId,
|
|
96
|
+
sessionType: state.sessionType,
|
|
97
|
+
timestamp: new Date(),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Initialize external services if needed
|
|
101
|
+
if (state.sessionType === 'VOICE') {
|
|
102
|
+
await setupVoiceSession(state.sessionId);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Common Use Cases
|
|
108
|
+
|
|
109
|
+
- **Session Logging**: Track when new sessions begin for analytics
|
|
110
|
+
- **Resource Initialization**: Set up session-specific resources or connections
|
|
111
|
+
- **State Validation**: Verify initial memory state meets requirements
|
|
112
|
+
- **External Service Setup**: Initialize third-party services for the session
|
|
113
|
+
- **Session Routing**: Route sessions to appropriate handlers based on type
|
|
114
|
+
- **Debugging**: Log initial state for troubleshooting
|
|
115
|
+
|
|
116
|
+
## AI_MESSAGE
|
|
117
|
+
|
|
118
|
+
The `AI_MESSAGE` event is emitted when an AI generates a message that should be sent to the user.
|
|
119
|
+
|
|
120
|
+
### Input Structure
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
{
|
|
124
|
+
message: string; // The AI-generated message content
|
|
125
|
+
state: { // Full agent state
|
|
126
|
+
messages: BaseMessage[]; // Conversation messages
|
|
127
|
+
memory: Memory; // Current memory state (your defined memory schema)
|
|
128
|
+
history: HistoryStep[]; // Flow execution history with detailed step information
|
|
129
|
+
sessionId: string; // Session identifier
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Handler Return Value
|
|
135
|
+
|
|
136
|
+
- **Return type**: `void`
|
|
137
|
+
- **Purpose**: Handlers are used for side effects like sending messages to UI
|
|
138
|
+
- **Note**: Return values are ignored
|
|
139
|
+
|
|
140
|
+
### Usage Example
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { Agent, events } from 'mindedjs';
|
|
144
|
+
|
|
145
|
+
const agent = new Agent({
|
|
146
|
+
memorySchema,
|
|
147
|
+
config,
|
|
148
|
+
tools,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Listen to AI messages
|
|
152
|
+
agent.on(events.AI_MESSAGE, async ({ message, state }) => {
|
|
153
|
+
console.log('AI said:', message);
|
|
154
|
+
console.log('Current memory:', state.memory);
|
|
155
|
+
console.log('Session ID:', state.sessionId);
|
|
156
|
+
console.log('Message count:', state.messages.length);
|
|
157
|
+
|
|
158
|
+
// Send message to user interface with session context
|
|
159
|
+
await sendMessageToUser(message, state.sessionId);
|
|
160
|
+
|
|
161
|
+
// Send via WebSocket with session information
|
|
162
|
+
await websocket.send(
|
|
163
|
+
JSON.stringify({
|
|
164
|
+
type: 'ai_message',
|
|
165
|
+
content: message,
|
|
166
|
+
sessionId: state.sessionId,
|
|
167
|
+
memory: state.memory,
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Common Use Cases
|
|
174
|
+
|
|
175
|
+
- **Real-time Chat UI**: Send AI responses to chat interfaces with session context
|
|
176
|
+
- **Logging**: Record AI responses for analytics or debugging with session tracking
|
|
177
|
+
- **Message Formatting**: Transform AI messages before displaying to users
|
|
178
|
+
- **Notifications**: Trigger alerts or notifications based on AI responses
|
|
179
|
+
- **Session Management**: Route messages to specific user sessions or conversation threads
|
|
180
|
+
|
|
181
|
+
## TRIGGER_EVENT
|
|
182
|
+
|
|
183
|
+
The `TRIGGER_EVENT` event is emitted when a trigger node is executed. This event allows you to qualify, transform, and provide initial state for trigger inputs before they're processed by the agent.
|
|
184
|
+
|
|
185
|
+
### Input Structure
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
{
|
|
189
|
+
triggerName: string; // Name of the trigger being executed
|
|
190
|
+
triggerBody: any; // The trigger input data (type varies by trigger)
|
|
191
|
+
sessionId?: string; // Optional session ID for the trigger execution
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Handler Return Values
|
|
196
|
+
|
|
197
|
+
TRIGGER_EVENT handlers **must** return an object that contains, at minimum, an `isQualified: boolean` field.
|
|
198
|
+
|
|
199
|
+
**Important v2.0 Change**: Event handlers now update state by reference instead of returning state updates. The handler receives the current state (if it exists) and can modify it directly.
|
|
200
|
+
|
|
201
|
+
The three common patterns are:
|
|
202
|
+
|
|
203
|
+
#### 1. Qualify & Modify State
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
{
|
|
207
|
+
isQualified: true, // ✅ The trigger should be processed
|
|
208
|
+
// No state/memory/messages in return - modify state directly in handler
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### 2. Disqualify the Trigger
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
{
|
|
216
|
+
isQualified: false; // ❌ Rejects / disqualifies the trigger
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### 3. Qualify Without Extra State
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
{
|
|
224
|
+
isQualified: true; // ✅ Accept the trigger – no extra state needed
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Note on sessionId**: The `sessionId` is crucial for persistence and resuming existing sessions. When you provide a `sessionId` that already exists, the agent will resume from the previous state. If none is provided or a new one is given, a fresh execution starts. The platform will automatically generate a `sessionId` for you in the sandbox playground – make sure to pass it forward in that environment.
|
|
229
|
+
|
|
230
|
+
### Usage Examples
|
|
231
|
+
|
|
232
|
+
#### Processing User Input
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody, sessionId, state }) => {
|
|
236
|
+
if (triggerName === 'userMessage') {
|
|
237
|
+
console.log('Processing trigger for session:', sessionId);
|
|
238
|
+
|
|
239
|
+
// Update state directly by reference (v2.0 change)
|
|
240
|
+
if (state) {
|
|
241
|
+
state.memory.conversationStarted = true;
|
|
242
|
+
state.memory.sessionId = sessionId; // Store session ID in memory if needed
|
|
243
|
+
state.messages.push(new HumanMessage(triggerBody));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
isQualified: true,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Trigger Qualification
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody, state }) => {
|
|
257
|
+
// Validate the trigger input
|
|
258
|
+
if (!isValidInput(triggerBody)) {
|
|
259
|
+
return { isQualified: false }; // Disqualify the trigger
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Only process during business hours
|
|
263
|
+
if (triggerName === 'supportRequest' && !isBusinessHours()) {
|
|
264
|
+
return { isQualified: false };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Update state directly by reference (v2.0 change)
|
|
268
|
+
if (state) {
|
|
269
|
+
state.memory.validatedInput = triggerBody;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
isQualified: true,
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### Input Transformation
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody, state }) => {
|
|
282
|
+
if (triggerName === 'emailTrigger') {
|
|
283
|
+
// Transform email data into structured format
|
|
284
|
+
const parsedEmail = parseEmailContent(triggerBody);
|
|
285
|
+
|
|
286
|
+
// Update state directly by reference (v2.0 change)
|
|
287
|
+
if (state) {
|
|
288
|
+
state.memory.emailSubject = parsedEmail.subject;
|
|
289
|
+
state.memory.senderEmail = parsedEmail.from;
|
|
290
|
+
state.messages.push(new HumanMessage(parsedEmail.content));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return {
|
|
294
|
+
isQualified: true,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
// Disqualify all other triggers handled by this listener
|
|
298
|
+
return { isQualified: false };
|
|
299
|
+
});
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
#### Dynamic Flow Control with goto
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
agent.on(events.TRIGGER_EVENT, async ({ triggerName, triggerBody, state }) => {
|
|
306
|
+
// Check condition and jump to specific node
|
|
307
|
+
if (triggerBody.priority === 'high') {
|
|
308
|
+
// Update state directly by reference (v2.0 change)
|
|
309
|
+
if (state) {
|
|
310
|
+
state.goto = 'high-priority-handler'; // Jump to specific node
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
isQualified: true,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return { isQualified: true };
|
|
319
|
+
});
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
> **Note:** The jump occurs only when the current invocation completes and the next one begins. The agent will finish executing the current node before jumping to the specified node.
|
|
323
|
+
|
|
324
|
+
### Common Use Cases
|
|
325
|
+
|
|
326
|
+
- **Input Validation**: Ensure trigger data meets requirements before processing
|
|
327
|
+
- **Data Transformation**: Convert trigger inputs into standardized formats
|
|
328
|
+
- **Context Setting**: Provide initial memory state based on trigger context
|
|
329
|
+
- **Access Control**: Disqualify triggers based on permissions or business rules
|
|
330
|
+
- **Routing Logic**: Handle different trigger types with specific logic
|
|
331
|
+
|
|
332
|
+
## ERROR
|
|
333
|
+
|
|
334
|
+
The `ERROR` event is emitted when an error occurs during agent execution. This event allows you to handle errors gracefully, log them for debugging, implement custom error recovery logic, or control whether the error should be thrown onwards.
|
|
335
|
+
|
|
336
|
+
### Input Structure
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
{
|
|
340
|
+
error: Error; // The error object that was thrown
|
|
341
|
+
state: { // Full agent state at the time of error
|
|
342
|
+
messages: BaseMessage[]; // Conversation messages
|
|
343
|
+
memory: Memory; // Current memory state (your defined memory schema)
|
|
344
|
+
history: HistoryStep[]; // Flow execution history with detailed step information
|
|
345
|
+
sessionId: string; // Session identifier
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Handler Return Value
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
{
|
|
354
|
+
throwError: boolean; // Whether to throw the error onwards and stop the agent run
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
- **throwError**: When set to `true`, the error will be thrown onwards and the agent run will stop. If `false` or not returned, the error is caught and the agent continues.
|
|
359
|
+
|
|
360
|
+
**Important v2.0 Change**: State is now updated by reference directly within the handler. You no longer return state updates.
|
|
361
|
+
|
|
362
|
+
### Usage Example
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
import { Agent, events } from 'mindedjs';
|
|
366
|
+
|
|
367
|
+
const agent = new Agent({
|
|
368
|
+
memorySchema,
|
|
369
|
+
config,
|
|
370
|
+
tools,
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
// Listen to errors and control error flow
|
|
374
|
+
agent.on(events.ERROR, async ({ error, state }) => {
|
|
375
|
+
console.error('Agent error occurred:', error.message);
|
|
376
|
+
console.error('Error stack:', error.stack);
|
|
377
|
+
console.log('Session ID:', state.sessionId);
|
|
378
|
+
console.log('Current memory:', state.memory);
|
|
379
|
+
|
|
380
|
+
// Log to external service
|
|
381
|
+
await logger.error({
|
|
382
|
+
message: 'Agent execution error',
|
|
383
|
+
error: error.message,
|
|
384
|
+
stack: error.stack,
|
|
385
|
+
sessionId: state.sessionId,
|
|
386
|
+
memory: state.memory,
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// Handle recoverable vs non-recoverable errors
|
|
390
|
+
if (error.message.includes('rate limit')) {
|
|
391
|
+
// Recoverable error - update state and continue
|
|
392
|
+
// Update state directly by reference (v2.0 change)
|
|
393
|
+
state.memory.errorRecovered = true;
|
|
394
|
+
state.memory.lastError = error.message;
|
|
395
|
+
|
|
396
|
+
return {
|
|
397
|
+
throwError: false, // Don't stop the agent
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Critical error - stop the agent
|
|
402
|
+
if (error.message.includes('authentication failed')) {
|
|
403
|
+
await notificationService.alert({
|
|
404
|
+
type: 'critical_error',
|
|
405
|
+
error: error.message,
|
|
406
|
+
sessionId: state.sessionId,
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
return {
|
|
410
|
+
throwError: true, // Stop the agent run
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Default: let the error be handled normally
|
|
415
|
+
return { throwError: false };
|
|
416
|
+
});
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Common Use Cases
|
|
420
|
+
|
|
421
|
+
- **Error Logging**: Record errors for debugging and monitoring with full context
|
|
422
|
+
- **Error Recovery**: Implement custom recovery logic by returning `throwError: false` and updating state
|
|
423
|
+
- **Critical Error Handling**: Stop agent execution for unrecoverable errors with `throwError: true`
|
|
424
|
+
- **User Notifications**: Provide graceful error messages to users
|
|
425
|
+
- **Monitoring & Alerting**: Integrate with monitoring systems for error tracking
|
|
426
|
+
- **Session Management**: Clean up or reset sessions that encountered errors
|
|
427
|
+
- **Analytics**: Track error patterns and frequencies for system improvement
|
|
428
|
+
- **Graceful Degradation**: Continue execution with fallback behavior for non-critical errors
|
|
429
|
+
|
|
430
|
+
## ON_LOGICAL_CONDITION
|
|
431
|
+
|
|
432
|
+
The `ON_LOGICAL_CONDITION` event is emitted when the agent is about to evaluate a logical condition on an edge. This event provides visibility into the condition evaluation process and allows you to track which conditions are being checked during flow execution.
|
|
433
|
+
|
|
434
|
+
### Input Structure
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
{
|
|
438
|
+
edge: LogicalConditionEdge; // The edge containing the condition
|
|
439
|
+
state: { // Full agent state at evaluation time
|
|
440
|
+
messages: BaseMessage[]; // Conversation messages
|
|
441
|
+
memory: Memory; // Current memory state (your defined memory schema)
|
|
442
|
+
history: HistoryStep[]; // Flow execution history with detailed step information
|
|
443
|
+
sessionId: string; // Session identifier
|
|
444
|
+
};
|
|
445
|
+
condition: string; // The condition expression being evaluated
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Handler Return Value
|
|
450
|
+
|
|
451
|
+
- **Return type**: `void`
|
|
452
|
+
- **Purpose**: Handlers are used for debugging, logging, and monitoring condition evaluations
|
|
453
|
+
- **Note**: Return values are ignored
|
|
454
|
+
|
|
455
|
+
### Usage Example
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
import { Agent, events } from 'mindedjs';
|
|
459
|
+
|
|
460
|
+
const agent = new Agent({
|
|
461
|
+
memorySchema,
|
|
462
|
+
config,
|
|
463
|
+
tools,
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// Listen to condition evaluation events
|
|
467
|
+
agent.on(events.ON_LOGICAL_CONDITION, async ({ edge, state, condition }) => {
|
|
468
|
+
console.log('Evaluating condition:', condition);
|
|
469
|
+
console.log('On edge from:', edge.source, 'to:', edge.target);
|
|
470
|
+
console.log('Current memory:', state.memory);
|
|
471
|
+
console.log('Session ID:', state.sessionId);
|
|
472
|
+
|
|
473
|
+
// Log for debugging
|
|
474
|
+
await logger.debug({
|
|
475
|
+
event: 'condition_evaluation_start',
|
|
476
|
+
condition,
|
|
477
|
+
edge: {
|
|
478
|
+
source: edge.source,
|
|
479
|
+
target: edge.target,
|
|
480
|
+
},
|
|
481
|
+
memory: state.memory,
|
|
482
|
+
sessionId: state.sessionId,
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// Track condition usage analytics
|
|
486
|
+
await analytics.track('condition_evaluated', {
|
|
487
|
+
condition,
|
|
488
|
+
edgeSource: edge.source,
|
|
489
|
+
edgeTarget: edge.target,
|
|
490
|
+
sessionId: state.sessionId,
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Common Use Cases
|
|
496
|
+
|
|
497
|
+
- **Debugging Flow Logic**: Trace which conditions are evaluated and in what order
|
|
498
|
+
- **Performance Monitoring**: Track when condition evaluations start
|
|
499
|
+
- **Analytics**: Understand which flow paths are most commonly evaluated
|
|
500
|
+
- **Testing**: Verify that expected conditions are being checked
|
|
501
|
+
- **Audit Logging**: Record decision points for compliance or debugging
|
|
502
|
+
|
|
503
|
+
## ON_LOGICAL_CONDITION_RESULT
|
|
504
|
+
|
|
505
|
+
The `ON_LOGICAL_CONDITION_RESULT` event is emitted after a logical condition has been evaluated, providing the result and execution metrics. This event is crucial for understanding flow decisions and monitoring performance.
|
|
506
|
+
|
|
507
|
+
### Input Structure
|
|
508
|
+
|
|
509
|
+
```typescript
|
|
510
|
+
{
|
|
511
|
+
edge: LogicalConditionEdge; // The edge containing the condition
|
|
512
|
+
state: { // Full agent state after evaluation
|
|
513
|
+
messages: BaseMessage[]; // Conversation messages
|
|
514
|
+
memory: Memory; // Current memory state (your defined memory schema)
|
|
515
|
+
history: HistoryStep[]; // Flow execution history with detailed step information
|
|
516
|
+
sessionId: string; // Session identifier
|
|
517
|
+
};
|
|
518
|
+
condition: string; // The condition expression that was evaluated
|
|
519
|
+
result: boolean; // The evaluation result (true/false)
|
|
520
|
+
executionTimeMs: number; // Time taken to evaluate the condition in milliseconds
|
|
521
|
+
error?: Error; // Optional error if evaluation failed
|
|
522
|
+
}
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### Handler Return Value
|
|
526
|
+
|
|
527
|
+
- **Return type**: `void`
|
|
528
|
+
- **Purpose**: Handlers are used for logging results, performance monitoring, and debugging
|
|
529
|
+
- **Note**: Return values are ignored
|
|
530
|
+
|
|
531
|
+
### Usage Example
|
|
532
|
+
|
|
533
|
+
```typescript
|
|
534
|
+
import { Agent, events } from 'mindedjs';
|
|
535
|
+
|
|
536
|
+
const agent = new Agent({
|
|
537
|
+
memorySchema,
|
|
538
|
+
config,
|
|
539
|
+
tools,
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// Listen to condition results
|
|
543
|
+
agent.on(events.ON_LOGICAL_CONDITION_RESULT, async ({ edge, state, condition, result, executionTimeMs, error }) => {
|
|
544
|
+
console.log('Condition result:', result);
|
|
545
|
+
console.log('Execution time:', executionTimeMs, 'ms');
|
|
546
|
+
|
|
547
|
+
if (error) {
|
|
548
|
+
console.error('Condition evaluation failed:', error.message);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// Log detailed results
|
|
552
|
+
await logger.debug({
|
|
553
|
+
event: 'condition_evaluation_complete',
|
|
554
|
+
condition,
|
|
555
|
+
result,
|
|
556
|
+
executionTimeMs,
|
|
557
|
+
edge: {
|
|
558
|
+
source: edge.source,
|
|
559
|
+
target: edge.target,
|
|
560
|
+
},
|
|
561
|
+
memory: state.memory,
|
|
562
|
+
sessionId: state.sessionId,
|
|
563
|
+
error: error?.message,
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// Performance monitoring
|
|
567
|
+
if (executionTimeMs > 10) {
|
|
568
|
+
await logger.warn({
|
|
569
|
+
message: 'Slow condition detected',
|
|
570
|
+
condition,
|
|
571
|
+
executionTimeMs,
|
|
572
|
+
sessionId: state.sessionId,
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Track failed conditions
|
|
577
|
+
if (!result) {
|
|
578
|
+
await analytics.track('condition_failed', {
|
|
579
|
+
condition,
|
|
580
|
+
edgeSource: edge.source,
|
|
581
|
+
edgeTarget: edge.target,
|
|
582
|
+
sessionId: state.sessionId,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
### Common Use Cases
|
|
589
|
+
|
|
590
|
+
- **Performance Monitoring**: Track execution times to identify slow conditions
|
|
591
|
+
- **Debugging Failed Conditions**: Understand why certain flow paths aren't taken
|
|
592
|
+
- **Flow Analytics**: Analyze which conditions pass/fail most frequently
|
|
593
|
+
- **Error Tracking**: Monitor and alert on condition evaluation errors
|
|
594
|
+
- **Optimization**: Identify conditions that could be simplified or cached
|
|
595
|
+
- **Testing**: Verify condition results match expected behavior
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Logging
|
|
2
|
+
|
|
3
|
+
MindedJS provides a structured logging system that helps you monitor, debug, and audit your agent's behavior. The logger is available throughout your agent code and provides consistent, contextual logging with proper PII handling.
|
|
4
|
+
|
|
5
|
+
## Using the Logger
|
|
6
|
+
|
|
7
|
+
Import the logger from MindedJS:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { logger } from 'mindedjs';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The logger is also available in all tool contexts, so you can use it directly in your tools without importing.
|
|
14
|
+
|
|
15
|
+
## Log Levels
|
|
16
|
+
|
|
17
|
+
The logger supports standard log levels:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// Info level - general information
|
|
21
|
+
logger.info('Processing customer request');
|
|
22
|
+
|
|
23
|
+
// Warning level - potential issues
|
|
24
|
+
logger.warn('Customer tier not found, using default');
|
|
25
|
+
|
|
26
|
+
// Error level - errors and exceptions
|
|
27
|
+
logger.error('Failed to process payment');
|
|
28
|
+
|
|
29
|
+
// Debug level - detailed debugging information
|
|
30
|
+
logger.debug('Memory state updated');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Structured Logging
|
|
34
|
+
|
|
35
|
+
Use structured logging with contextual data for better observability:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// Basic structured logging
|
|
39
|
+
logger.info('Order processed', {
|
|
40
|
+
orderId: 'ORD-123',
|
|
41
|
+
customerId: 'CUST-456',
|
|
42
|
+
amount: 99.99,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Include session context in tools
|
|
46
|
+
logger.info('Tool execution started', {
|
|
47
|
+
sessionId: state.sessionId,
|
|
48
|
+
toolName: 'refundOrder',
|
|
49
|
+
orderId: input.orderId,
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Log Configuration
|
|
54
|
+
|
|
55
|
+
The logger can be configured through environment variables:
|
|
56
|
+
|
|
57
|
+
```env
|
|
58
|
+
# Set log level (debug, info, warn, error)
|
|
59
|
+
LOG_LEVEL=info
|
|
60
|
+
|
|
61
|
+
# In development, you might want debug level
|
|
62
|
+
LOG_LEVEL=debug
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Best Practices
|
|
66
|
+
|
|
67
|
+
1. **Always Include Session Context**: Include `sessionId` in all tool-related logs
|
|
68
|
+
2. **Use Appropriate Log Levels**: Don't use `info` for debugging information
|
|
69
|
+
3. **Structure Your Data**: Use objects for structured logging rather than strings
|
|
70
|
+
4. **Log State Changes**: Log important state transitions and memory updates
|
|
71
|
+
5. **Error Context**: Use `err` parameter for error objects to get proper stack traces
|
|
72
|
+
6. **Performance Metrics**: Log timing information for performance monitoring
|