@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,393 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
import { Tool } from '../types/Tools.types';
|
|
4
|
+
import { logger } from '../utils/logger';
|
|
5
|
+
import { JsonOutputParser } from '@langchain/core/output_parsers';
|
|
6
|
+
import { SystemMessage } from '@langchain/core/messages';
|
|
7
|
+
import { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
8
|
+
|
|
9
|
+
// Type guard for checking if LLM supports structured output
|
|
10
|
+
interface StructuredOutputLLM extends BaseLanguageModel {
|
|
11
|
+
withStructuredOutput<T extends z.ZodType>(schema: T): BaseLanguageModel;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function supportsStructuredOutput(llm: BaseLanguageModel): llm is StructuredOutputLLM {
|
|
15
|
+
return 'withStructuredOutput' in llm && typeof (llm as any).withStructuredOutput === 'function';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Type definitions for extraction configuration using Zod
|
|
19
|
+
export type ExtractionSchema = z.ZodTypeAny;
|
|
20
|
+
|
|
21
|
+
export interface ExtractionConfig {
|
|
22
|
+
schema: ExtractionSchema;
|
|
23
|
+
systemPrompt?: string;
|
|
24
|
+
examples?: Array<{ input: string; output?: any }>;
|
|
25
|
+
defaultValue?: any;
|
|
26
|
+
maxRetries?: number;
|
|
27
|
+
strictMode?: boolean; // If true, will validate against schema
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ExtractionResult = z.infer<ExtractionSchema>;
|
|
31
|
+
|
|
32
|
+
// Default configuration
|
|
33
|
+
const DEFAULT_CONFIG: Partial<ExtractionConfig> = {
|
|
34
|
+
maxRetries: 3,
|
|
35
|
+
strictMode: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Convert Zod schema to JSON schema format for prompt
|
|
40
|
+
*/
|
|
41
|
+
function schemaToJsonFormat(schema: ExtractionSchema): string {
|
|
42
|
+
// Use zod-to-json-schema for robust conversion
|
|
43
|
+
const jsonSchema = zodToJsonSchema(schema, {
|
|
44
|
+
target: 'openApi3',
|
|
45
|
+
$refStrategy: 'none', // Inline all references for simpler prompts
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Remove the $schema property for cleaner output
|
|
49
|
+
if (typeof jsonSchema === 'object' && jsonSchema !== null && '$schema' in jsonSchema) {
|
|
50
|
+
delete (jsonSchema as any).$schema;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return JSON.stringify(jsonSchema, null, 2);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Build prompt with schema for JSON parsing mode
|
|
58
|
+
*/
|
|
59
|
+
function buildPromptWithSchema(
|
|
60
|
+
basePrompt: string,
|
|
61
|
+
schema: ExtractionSchema,
|
|
62
|
+
examples: Array<{ input: string; output?: any }> | undefined,
|
|
63
|
+
content: string,
|
|
64
|
+
): string {
|
|
65
|
+
const schemaDescription = schemaToJsonFormat(schema);
|
|
66
|
+
let prompt = `${basePrompt}\n\nExpected JSON format:\n${schemaDescription}\n\n`;
|
|
67
|
+
|
|
68
|
+
// Add examples if provided
|
|
69
|
+
if (examples && examples.length > 0) {
|
|
70
|
+
prompt += 'Examples:\n';
|
|
71
|
+
for (const example of examples) {
|
|
72
|
+
prompt += `Input: ${example.input}\nOutput: ${JSON.stringify(example.output)}\n\n`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
prompt += 'Return ONLY valid JSON that matches the schema. No additional text or explanation.\n\n';
|
|
77
|
+
prompt += `Content to extract from:\n${content}`;
|
|
78
|
+
|
|
79
|
+
return prompt;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Validate extraction result against Zod schema
|
|
84
|
+
*/
|
|
85
|
+
function validateResult(result: any, schema: ExtractionSchema): { valid: boolean; errors: string[] } {
|
|
86
|
+
try {
|
|
87
|
+
// Use Zod's built-in validation
|
|
88
|
+
schema.parse(result);
|
|
89
|
+
return { valid: true, errors: [] };
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error instanceof z.ZodError) {
|
|
92
|
+
// Extract error messages from Zod validation
|
|
93
|
+
const errors = error.errors.map((err) => {
|
|
94
|
+
const path = err.path.join('.');
|
|
95
|
+
return path ? `${path}: ${err.message}` : err.message;
|
|
96
|
+
});
|
|
97
|
+
return { valid: false, errors };
|
|
98
|
+
}
|
|
99
|
+
// Handle non-Zod errors
|
|
100
|
+
return { valid: false, errors: [error instanceof Error ? error.message : 'Unknown validation error'] };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Generic extraction utility that can be used standalone
|
|
106
|
+
*
|
|
107
|
+
* When strictMode is true:
|
|
108
|
+
* - If the LLM supports withStructuredOutput, it will use that for guaranteed schema compliance
|
|
109
|
+
* - Otherwise, it falls back to JSON parsing with Zod validation and retries
|
|
110
|
+
*
|
|
111
|
+
* When strictMode is false:
|
|
112
|
+
* - Uses JSON parsing without validation for more flexibility
|
|
113
|
+
*
|
|
114
|
+
* @param content The content to extract from
|
|
115
|
+
* @param config The extraction configuration
|
|
116
|
+
* @param llm The language model to use for extraction
|
|
117
|
+
* @param attemptNumber Current attempt number (used internally for retries)
|
|
118
|
+
* @returns The extraction result
|
|
119
|
+
*/
|
|
120
|
+
export async function extract(
|
|
121
|
+
content: string,
|
|
122
|
+
config: ExtractionConfig,
|
|
123
|
+
llm: BaseLanguageModel,
|
|
124
|
+
attemptNumber: number = 0,
|
|
125
|
+
): Promise<ExtractionResult> {
|
|
126
|
+
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const basePrompt = mergedConfig.systemPrompt || 'Extract structured information from the given content:';
|
|
130
|
+
|
|
131
|
+
let result: any;
|
|
132
|
+
|
|
133
|
+
if (mergedConfig.strictMode) {
|
|
134
|
+
// Use structured output when strict mode is enabled
|
|
135
|
+
try {
|
|
136
|
+
// Check if the LLM supports structured output
|
|
137
|
+
if (supportsStructuredOutput(llm)) {
|
|
138
|
+
// When using withStructuredOutput, we don't need to include the schema in the prompt
|
|
139
|
+
// The LLM already knows the structure from the withStructuredOutput method
|
|
140
|
+
let prompt = basePrompt;
|
|
141
|
+
|
|
142
|
+
// Add examples if provided (still useful for context)
|
|
143
|
+
if (mergedConfig.examples && mergedConfig.examples.length > 0) {
|
|
144
|
+
prompt += '\n\nExamples:\n';
|
|
145
|
+
for (const example of mergedConfig.examples) {
|
|
146
|
+
prompt += `Input: ${example.input}\nOutput: ${JSON.stringify(example.output)}\n\n`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
prompt += `\n\nContent to extract from:\n${content}`;
|
|
151
|
+
|
|
152
|
+
const structuredLLM = llm.withStructuredOutput(mergedConfig.schema);
|
|
153
|
+
const messages = [new SystemMessage(prompt)];
|
|
154
|
+
result = await structuredLLM.invoke(messages);
|
|
155
|
+
|
|
156
|
+
// The result should already be validated by withStructuredOutput
|
|
157
|
+
return result as ExtractionResult;
|
|
158
|
+
} else {
|
|
159
|
+
// Fallback to JSON parser with validation if withStructuredOutput is not available
|
|
160
|
+
logger.info({
|
|
161
|
+
message: 'LLM does not support withStructuredOutput, falling back to JSON parser with validation',
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// For JSON parsing mode, we need to include the schema in the prompt
|
|
165
|
+
const prompt = buildPromptWithSchema(basePrompt, mergedConfig.schema, mergedConfig.examples, content);
|
|
166
|
+
|
|
167
|
+
const parser = new JsonOutputParser();
|
|
168
|
+
const messages = [new SystemMessage(prompt)];
|
|
169
|
+
result = await llm.pipe(parser).invoke(messages);
|
|
170
|
+
|
|
171
|
+
// Validate the result
|
|
172
|
+
const validation = validateResult(result, mergedConfig.schema);
|
|
173
|
+
|
|
174
|
+
if (!validation.valid && attemptNumber < (mergedConfig.maxRetries || 3)) {
|
|
175
|
+
logger.warn({
|
|
176
|
+
message: 'Extraction validation failed, retrying',
|
|
177
|
+
errors: validation.errors,
|
|
178
|
+
attempt: attemptNumber + 1,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Add validation errors to prompt for retry
|
|
182
|
+
const retryConfig = {
|
|
183
|
+
...config,
|
|
184
|
+
systemPrompt: `${basePrompt}\n\nPrevious attempt had these errors:\n${validation.errors.join(
|
|
185
|
+
'\n',
|
|
186
|
+
)}\n\nPlease correct these issues and provide valid JSON.`,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
return extract(content, retryConfig, llm, attemptNumber + 1);
|
|
190
|
+
} else if (!validation.valid) {
|
|
191
|
+
logger.error({
|
|
192
|
+
message: 'Extraction validation failed after max retries',
|
|
193
|
+
errors: validation.errors,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
if (mergedConfig.defaultValue) {
|
|
197
|
+
return mergedConfig.defaultValue;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
throw new Error(`Extraction validation failed: ${validation.errors.join(', ')}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} catch (err) {
|
|
204
|
+
// If structured output fails, retry with adjusted config
|
|
205
|
+
if (attemptNumber < (mergedConfig.maxRetries || 3)) {
|
|
206
|
+
logger.warn({
|
|
207
|
+
message: 'Structured output failed, retrying',
|
|
208
|
+
error: err instanceof Error ? err.message : 'Unknown error',
|
|
209
|
+
attempt: attemptNumber + 1,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return extract(content, config, llm, attemptNumber + 1);
|
|
213
|
+
} else {
|
|
214
|
+
throw err;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
// Non-strict mode: use JSON parser without validation
|
|
219
|
+
const prompt = buildPromptWithSchema(basePrompt, mergedConfig.schema, mergedConfig.examples, content);
|
|
220
|
+
|
|
221
|
+
const parser = new JsonOutputParser();
|
|
222
|
+
const messages = [new SystemMessage(prompt)];
|
|
223
|
+
result = await llm.pipe(parser).invoke(messages);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return result as ExtractionResult;
|
|
227
|
+
} catch (err) {
|
|
228
|
+
logger.error({ message: 'Extraction failed', err });
|
|
229
|
+
|
|
230
|
+
if (mergedConfig.defaultValue) {
|
|
231
|
+
return mergedConfig.defaultValue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
throw err;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Create a simple extractor for common use cases
|
|
240
|
+
* @param schemaOrPrompt Either a Zod schema or a simple prompt string
|
|
241
|
+
* @param options Additional configuration options
|
|
242
|
+
* @returns A configured extract function
|
|
243
|
+
*/
|
|
244
|
+
export function createExtractor(schemaOrPrompt: ExtractionSchema | string, options?: Partial<ExtractionConfig>) {
|
|
245
|
+
let config: ExtractionConfig;
|
|
246
|
+
|
|
247
|
+
if (typeof schemaOrPrompt === 'string') {
|
|
248
|
+
// Simple prompt-based extraction - create a Zod schema for a single string result
|
|
249
|
+
config = {
|
|
250
|
+
schema: z.object({
|
|
251
|
+
result: z.string().describe('The extracted result'),
|
|
252
|
+
}),
|
|
253
|
+
systemPrompt: schemaOrPrompt,
|
|
254
|
+
...options,
|
|
255
|
+
};
|
|
256
|
+
} else {
|
|
257
|
+
// Schema-based extraction
|
|
258
|
+
config = {
|
|
259
|
+
schema: schemaOrPrompt,
|
|
260
|
+
...options,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return (content: string, llm: BaseLanguageModel) => extract(content, config, llm);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Schema for the extraction tool
|
|
268
|
+
export const schema = z.object({
|
|
269
|
+
content: z.string().describe('The content to extract information from'),
|
|
270
|
+
schema: z.record(z.any()).optional().describe('Extraction schema defining the structure of data to extract'),
|
|
271
|
+
systemPrompt: z.string().optional().describe('Custom system prompt for extraction'),
|
|
272
|
+
examples: z
|
|
273
|
+
.array(
|
|
274
|
+
z.object({
|
|
275
|
+
input: z.string(),
|
|
276
|
+
output: z.any(),
|
|
277
|
+
}),
|
|
278
|
+
)
|
|
279
|
+
.optional()
|
|
280
|
+
.describe('Examples to guide the extraction'),
|
|
281
|
+
strictMode: z.boolean().optional().default(true).describe('Whether to validate the extraction against the schema'),
|
|
282
|
+
maxRetries: z.number().optional().default(3).describe('Maximum number of retries if validation fails'),
|
|
283
|
+
defaultValue: z.any().optional().describe('Default value to return if extraction fails'),
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const extractionTool: Tool<typeof schema, any> = {
|
|
287
|
+
name: 'minded-extraction',
|
|
288
|
+
description:
|
|
289
|
+
'Extract structured data from unstructured text using AI. Supports custom Zod schemas, validation, examples, and retries. When strictMode is enabled, uses LLM structured output (if available) for guaranteed schema compliance. Perfect for extracting specific information like country codes, emails, dates, or any custom data structure.',
|
|
290
|
+
input: schema,
|
|
291
|
+
isGlobal: false,
|
|
292
|
+
execute: async ({ input, state, agent }) => {
|
|
293
|
+
const { content, schema: inputSchema, systemPrompt, examples, strictMode, maxRetries, defaultValue } = input;
|
|
294
|
+
|
|
295
|
+
logger.info({
|
|
296
|
+
message: 'Extracting structured data',
|
|
297
|
+
sessionId: state.sessionId,
|
|
298
|
+
contentLength: content.length,
|
|
299
|
+
hasSchema: !!inputSchema,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Convert input schema to Zod schema if provided
|
|
303
|
+
let extractionSchema: ExtractionSchema;
|
|
304
|
+
if (inputSchema) {
|
|
305
|
+
// Build a Zod schema from the input schema object
|
|
306
|
+
const zodShape: Record<string, z.ZodType> = {};
|
|
307
|
+
|
|
308
|
+
for (const [key, value] of Object.entries(inputSchema)) {
|
|
309
|
+
if (typeof value === 'object' && value !== null) {
|
|
310
|
+
const fieldConfig = value as any;
|
|
311
|
+
let zodType: z.ZodType;
|
|
312
|
+
|
|
313
|
+
// Create appropriate Zod type based on the field configuration
|
|
314
|
+
if (fieldConfig.type === 'string') {
|
|
315
|
+
zodType = z.string();
|
|
316
|
+
} else if (fieldConfig.type === 'number') {
|
|
317
|
+
zodType = z.number();
|
|
318
|
+
} else if (fieldConfig.type === 'boolean') {
|
|
319
|
+
zodType = z.boolean();
|
|
320
|
+
} else if (fieldConfig.type === 'array') {
|
|
321
|
+
zodType = z.array(z.any());
|
|
322
|
+
} else if (fieldConfig.type === 'object') {
|
|
323
|
+
zodType = z.object({});
|
|
324
|
+
} else {
|
|
325
|
+
// Default to string if type not specified
|
|
326
|
+
zodType = z.string();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Add description if available
|
|
330
|
+
if (fieldConfig.description) {
|
|
331
|
+
zodType = zodType.describe(fieldConfig.description);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Handle optional fields
|
|
335
|
+
if (fieldConfig.required === false) {
|
|
336
|
+
zodType = zodType.optional();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
zodShape[key] = zodType;
|
|
340
|
+
} else {
|
|
341
|
+
// Default to string for simple values
|
|
342
|
+
zodShape[key] = z.string();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
extractionSchema = z.object(zodShape);
|
|
347
|
+
} else {
|
|
348
|
+
// Default schema if none provided
|
|
349
|
+
extractionSchema = z.object({
|
|
350
|
+
result: z.string().describe('The extracted result'),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const config: ExtractionConfig = {
|
|
355
|
+
schema: extractionSchema,
|
|
356
|
+
systemPrompt,
|
|
357
|
+
examples,
|
|
358
|
+
strictMode,
|
|
359
|
+
maxRetries,
|
|
360
|
+
defaultValue,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
try {
|
|
364
|
+
const result = await extract(content, config, agent.llm);
|
|
365
|
+
|
|
366
|
+
logger.info({
|
|
367
|
+
message: 'Extraction completed',
|
|
368
|
+
sessionId: state.sessionId,
|
|
369
|
+
resultKeys: Object.keys(result),
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
state.memory.lastExtraction = {
|
|
373
|
+
content: content.substring(0, 100) + (content.length > 100 ? '...' : ''),
|
|
374
|
+
result,
|
|
375
|
+
timestamp: new Date().toISOString(),
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
return {
|
|
379
|
+
result,
|
|
380
|
+
};
|
|
381
|
+
} catch (err) {
|
|
382
|
+
logger.error({
|
|
383
|
+
message: 'Extraction failed',
|
|
384
|
+
sessionId: state.sessionId,
|
|
385
|
+
err,
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
throw err;
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export default extractionTool;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as parseDocument from './parseDocument';
|
|
2
|
+
import * as classifier from './classifier';
|
|
3
|
+
import * as extraction from './extraction';
|
|
4
|
+
|
|
5
|
+
// Export all tools as a collection for easy discovery
|
|
6
|
+
export const tools = {
|
|
7
|
+
'minded-parse-documents': parseDocument,
|
|
8
|
+
'minded-classifier': classifier,
|
|
9
|
+
'minded-extraction': extraction,
|
|
10
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Tool } from '../types/Tools.types';
|
|
3
|
+
import { extractFromDocument } from '../internalTools/documentExtraction/documentExtraction';
|
|
4
|
+
import { logger } from '../utils/logger';
|
|
5
|
+
|
|
6
|
+
// Schema for the tool - these are the parameters that can be inferred by LLM
|
|
7
|
+
export const schema = z.object({
|
|
8
|
+
// Document source parameters - only one should be provided based on loadFrom setting
|
|
9
|
+
documentPath: z.string().optional().nullable().describe('Path to the document file to parse (when loadFrom is "path")'),
|
|
10
|
+
documentContent: z
|
|
11
|
+
.union([z.instanceof(Buffer), z.string()])
|
|
12
|
+
.optional()
|
|
13
|
+
.nullable()
|
|
14
|
+
.describe('Document content as Buffer or string (when loadFrom is "buffer" or "string")'),
|
|
15
|
+
documentUrl: z.string().optional().nullable().describe('URL to fetch the document from (when loadFrom is "url")'),
|
|
16
|
+
|
|
17
|
+
// Processing parameters - these can be predefined in the UI
|
|
18
|
+
extractRaw: z.boolean().optional().nullable().describe('Extract raw text without AI processing'),
|
|
19
|
+
schema: z.any().optional().nullable().describe('Zod schema for structured data extraction (when not extracting raw)'),
|
|
20
|
+
|
|
21
|
+
// Load source indicator - this would be set from UI
|
|
22
|
+
loadFrom: z.enum(['url', 'path', 'buffer', 'string']).optional().nullable().describe('Source type for the document'),
|
|
23
|
+
systemPrompt: z.string().optional().nullable().describe('Prompt for guiding extraction (when not using schema or extracting raw)'),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const parseDocumentTool: Tool<typeof schema, any> = {
|
|
27
|
+
name: 'minded-parse-documents',
|
|
28
|
+
description:
|
|
29
|
+
'Parse and extract data from documents (PDFs, images, Word docs, etc.). Supports multiple input sources (URL, file path, buffer, or string) and can extract raw text, structured data with a schema, or unstructured data with a prompt. Parameters can be predefined in the flow configuration.',
|
|
30
|
+
input: schema,
|
|
31
|
+
isGlobal: false,
|
|
32
|
+
execute: async ({ input, state, agent }) => {
|
|
33
|
+
// The input here will be the combined input from both LLM and UI properties
|
|
34
|
+
const combinedInput = input as z.infer<typeof schema>;
|
|
35
|
+
|
|
36
|
+
logger.info({
|
|
37
|
+
msg: '*Action: Parse document*',
|
|
38
|
+
sessionId: state.sessionId,
|
|
39
|
+
loadFrom: combinedInput.loadFrom,
|
|
40
|
+
hasPath: !!combinedInput.documentPath,
|
|
41
|
+
hasContent: !!combinedInput.documentContent,
|
|
42
|
+
hasUrl: !!combinedInput.documentUrl,
|
|
43
|
+
hasSchema: !!combinedInput.schema,
|
|
44
|
+
hasPrompt: !!combinedInput.systemPrompt,
|
|
45
|
+
extractRaw: combinedInput.extractRaw,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// Validate document source based on loadFrom parameter
|
|
50
|
+
if (combinedInput.loadFrom) {
|
|
51
|
+
switch (combinedInput.loadFrom) {
|
|
52
|
+
case 'url':
|
|
53
|
+
if (!combinedInput.documentUrl) {
|
|
54
|
+
throw new Error('documentUrl is required when loadFrom is "url"');
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case 'path':
|
|
58
|
+
if (!combinedInput.documentPath) {
|
|
59
|
+
throw new Error('documentPath is required when loadFrom is "path"');
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case 'buffer':
|
|
63
|
+
case 'string':
|
|
64
|
+
if (!combinedInput.documentContent) {
|
|
65
|
+
throw new Error('documentContent is required when loadFrom is "buffer" or "string"');
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
// Fallback to original validation if loadFrom is not specified
|
|
71
|
+
if (!combinedInput.documentPath && !combinedInput.documentContent && !combinedInput.documentUrl) {
|
|
72
|
+
throw new Error('At least one document source must be provided: documentPath, documentContent, or documentUrl');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Prepare extraction options, filtering out null/undefined values
|
|
77
|
+
const extractionOptions: Parameters<typeof extractFromDocument>[0] = {};
|
|
78
|
+
|
|
79
|
+
if (combinedInput.documentPath) {
|
|
80
|
+
extractionOptions.documentPath = combinedInput.documentPath;
|
|
81
|
+
}
|
|
82
|
+
if (combinedInput.documentContent) {
|
|
83
|
+
extractionOptions.documentContent = combinedInput.documentContent;
|
|
84
|
+
}
|
|
85
|
+
if (combinedInput.documentUrl) {
|
|
86
|
+
extractionOptions.documentUrl = combinedInput.documentUrl;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Only include LLM if not extracting raw text
|
|
90
|
+
if (!combinedInput.extractRaw) {
|
|
91
|
+
extractionOptions.llm = agent.llm;
|
|
92
|
+
|
|
93
|
+
// Include schema or system prompt if provided
|
|
94
|
+
if (combinedInput.schema) {
|
|
95
|
+
extractionOptions.schema = combinedInput.schema;
|
|
96
|
+
} else if (combinedInput.systemPrompt) {
|
|
97
|
+
extractionOptions.systemPrompt = combinedInput.systemPrompt;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Extract from document using the SDK's document extraction capabilities
|
|
102
|
+
const result = await extractFromDocument(extractionOptions);
|
|
103
|
+
|
|
104
|
+
state.memory.lastParsedDocument = {
|
|
105
|
+
source: combinedInput.documentPath || combinedInput.documentUrl || 'content',
|
|
106
|
+
extractedAt: new Date().toISOString(),
|
|
107
|
+
extractedRaw: !!combinedInput.extractRaw,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Return only the extracted data, not the metadata as requested
|
|
111
|
+
return {
|
|
112
|
+
result: result.data,
|
|
113
|
+
};
|
|
114
|
+
} catch (err) {
|
|
115
|
+
logger.error({
|
|
116
|
+
message: 'Failed to parse document',
|
|
117
|
+
sessionId: state.sessionId,
|
|
118
|
+
err,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
state.memory.documentParsingError = err instanceof Error ? err.message : String(err);
|
|
122
|
+
return {
|
|
123
|
+
result: `Failed to parse document: ${err instanceof Error ? err.message : String(err)}`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default parseDocumentTool;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseMessage, HumanMessage } from '@langchain/core/messages';
|
|
2
|
+
|
|
3
|
+
const triggerTypeToDefaultMessage: Record<string, Record<string, (triggerBody: any) => Array<BaseMessage>>> = {
|
|
4
|
+
['Slack']: {
|
|
5
|
+
'New Direct Message (Instant)': (triggerBody: any) => [new HumanMessage({ content: triggerBody.text })],
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default triggerTypeToDefaultMessage;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AgentEventRequestPayloads, AgentEventResponsePayloads } from '../events/AgentEvents';
|
|
2
|
+
import { LLMConfig } from './LLM.types';
|
|
3
|
+
import { NodeType } from './Flows.types';
|
|
4
|
+
|
|
5
|
+
export type EmitSignature<Memory, E extends keyof AgentEventRequestPayloads<Memory>> = (
|
|
6
|
+
event: E,
|
|
7
|
+
payload: AgentEventRequestPayloads<Memory>[E],
|
|
8
|
+
) => Promise<AgentEventResponsePayloads[E][]>;
|
|
9
|
+
|
|
10
|
+
export type MindedSDKConfig = {
|
|
11
|
+
flows: string[];
|
|
12
|
+
llm: LLMConfig;
|
|
13
|
+
tools: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Optional directories containing playbook definition files. If omitted, no playbooks will be loaded.
|
|
16
|
+
*/
|
|
17
|
+
playbooks?: string[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Parameters for the Agent invoke method
|
|
22
|
+
*/
|
|
23
|
+
export interface AgentInvokeParams extends TriggerEvent {
|
|
24
|
+
/** Internal flag to bypass session processing check for recursive calls */
|
|
25
|
+
bypassSessionCheck?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface HistoryStep {
|
|
29
|
+
type: NodeType;
|
|
30
|
+
step: number;
|
|
31
|
+
raw: any;
|
|
32
|
+
nodeId: string;
|
|
33
|
+
nodeDisplayName: string;
|
|
34
|
+
messageIds?: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface AppTriggerHistoryStep extends HistoryStep {
|
|
38
|
+
type: NodeType.TRIGGER;
|
|
39
|
+
appName: string;
|
|
40
|
+
triggerBody: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TriggerHistoryStep extends HistoryStep {
|
|
44
|
+
type: NodeType.TRIGGER;
|
|
45
|
+
triggerBody: any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface AppActionInvocationHistoryStep extends HistoryStep {
|
|
49
|
+
type: NodeType.APP_TOOL;
|
|
50
|
+
appName: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface CustomActionInvocationHistoryStep extends HistoryStep {
|
|
54
|
+
type: NodeType.TOOL;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface JunctionHistoryStep extends HistoryStep {
|
|
58
|
+
type: NodeType.JUNCTION;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export enum SessionType {
|
|
62
|
+
VOICE = 'voice',
|
|
63
|
+
TEXT = 'text',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface TriggerEvent {
|
|
67
|
+
/** The payload/data associated with the trigger */
|
|
68
|
+
triggerBody: any;
|
|
69
|
+
/** The name/type of the trigger being invoked */
|
|
70
|
+
triggerName: string;
|
|
71
|
+
/** Optional name of the application triggering the agent in case of an app trigger */
|
|
72
|
+
appName?: string;
|
|
73
|
+
}
|