@minded-ai/mindedjs 1.0.150 → 2.0.0-beta1
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/dist/agent.d.ts +2 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +31 -53
- package/dist/agent.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/edges/createLogicalRouter.d.ts.map +1 -1
- package/dist/edges/createLogicalRouter.js +4 -18
- package/dist/edges/createLogicalRouter.js.map +1 -1
- package/dist/events/AgentEvents.d.ts +5 -14
- package/dist/events/AgentEvents.d.ts.map +1 -1
- package/dist/guidelines/guidelinesManager.d.ts +37 -0
- package/dist/guidelines/guidelinesManager.d.ts.map +1 -0
- package/dist/guidelines/guidelinesManager.js +172 -0
- package/dist/guidelines/guidelinesManager.js.map +1 -0
- package/dist/internalTools/documentExtraction.d.ts +69 -0
- package/dist/internalTools/documentExtraction.d.ts.map +1 -0
- package/dist/internalTools/documentExtraction.js +65 -0
- package/dist/internalTools/documentExtraction.js.map +1 -0
- package/dist/internalTools/libraryActionRunnerTool.d.ts.map +1 -1
- package/dist/internalTools/libraryActionRunnerTool.js +0 -1
- package/dist/internalTools/libraryActionRunnerTool.js.map +1 -1
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.d.ts +10 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.d.ts.map +1 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.js +80 -0
- package/dist/internalTools/managedDocumentParser/managedDocumentParser.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 +44 -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 +51 -0
- package/dist/internalTools/sendPlaceholderMessage.js.map +1 -0
- package/dist/interrupts/BaseInterruptSessionManager.d.ts +2 -2
- package/dist/interrupts/BaseInterruptSessionManager.d.ts.map +1 -1
- package/dist/interrupts/BaseInterruptSessionManager.js +1 -7
- package/dist/interrupts/BaseInterruptSessionManager.js.map +1 -1
- package/dist/nodes/addAppToolNode.d.ts.map +1 -1
- package/dist/nodes/addAppToolNode.js +24 -18
- package/dist/nodes/addAppToolNode.js.map +1 -1
- package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskNode.js +30 -27
- package/dist/nodes/addBrowserTaskNode.js.map +1 -1
- package/dist/nodes/addBrowserTaskRunNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskRunNode.js +18 -20
- package/dist/nodes/addBrowserTaskRunNode.js.map +1 -1
- package/dist/nodes/addJumpToNode.d.ts.map +1 -1
- package/dist/nodes/addJumpToNode.js +8 -9
- package/dist/nodes/addJumpToNode.js.map +1 -1
- package/dist/nodes/addJunctionNode.d.ts.map +1 -1
- package/dist/nodes/addJunctionNode.js +8 -9
- package/dist/nodes/addJunctionNode.js.map +1 -1
- package/dist/nodes/addPromptNode.d.ts.map +1 -1
- package/dist/nodes/addPromptNode.js +40 -58
- package/dist/nodes/addPromptNode.js.map +1 -1
- package/dist/nodes/addToolNode.d.ts.map +1 -1
- package/dist/nodes/addToolNode.js +33 -20
- package/dist/nodes/addToolNode.js.map +1 -1
- package/dist/nodes/addToolRunNode.d.ts.map +1 -1
- package/dist/nodes/addToolRunNode.js +15 -21
- package/dist/nodes/addToolRunNode.js.map +1 -1
- package/dist/nodes/addTriggerNode.js +9 -11
- package/dist/nodes/addTriggerNode.js.map +1 -1
- package/dist/nodes/compilePrompt.d.ts.map +1 -1
- package/dist/nodes/compilePrompt.js +2 -0
- package/dist/nodes/compilePrompt.js.map +1 -1
- package/dist/pii-gateway/gateway.d.ts +17 -0
- package/dist/pii-gateway/gateway.d.ts.map +1 -0
- package/dist/pii-gateway/gateway.js +77 -0
- package/dist/pii-gateway/gateway.js.map +1 -0
- package/dist/pii-gateway/index.d.ts +4 -0
- package/dist/pii-gateway/index.d.ts.map +1 -0
- package/dist/pii-gateway/index.js +14 -0
- package/dist/pii-gateway/index.js.map +1 -0
- package/dist/pii-gateway/proxy.d.ts +80 -0
- package/dist/pii-gateway/proxy.d.ts.map +1 -0
- package/dist/pii-gateway/proxy.js +106 -0
- package/dist/pii-gateway/proxy.js.map +1 -0
- package/dist/pii-gateway/types.d.ts +27 -0
- package/dist/pii-gateway/types.d.ts.map +1 -0
- package/dist/pii-gateway/types.js +3 -0
- package/dist/pii-gateway/types.js.map +1 -0
- package/dist/platform/mindedChatOpenAI.d.ts +5 -0
- package/dist/platform/mindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/mindedChatOpenAI.js +23 -0
- package/dist/platform/mindedChatOpenAI.js.map +1 -0
- package/dist/platform/mindedCheckpointSaver.js.map +1 -1
- package/dist/platform/mindedUtils.d.ts +1 -0
- package/dist/platform/mindedUtils.d.ts.map +1 -0
- package/dist/platform/mindedUtils.js +2 -0
- package/dist/platform/mindedUtils.js.map +1 -0
- package/dist/platform/parallelAzureChatOpenAI.d.ts +39 -0
- package/dist/platform/parallelAzureChatOpenAI.d.ts.map +1 -0
- package/dist/platform/parallelAzureChatOpenAI.js +114 -0
- package/dist/platform/parallelAzureChatOpenAI.js.map +1 -0
- package/dist/platform/parallelChatOpenAI.d.ts +38 -0
- package/dist/platform/parallelChatOpenAI.d.ts.map +1 -0
- package/dist/platform/parallelChatOpenAI.js +111 -0
- package/dist/platform/parallelChatOpenAI.js.map +1 -0
- package/dist/platform/parallelMindedChatOpenAI.d.ts +39 -0
- package/dist/platform/parallelMindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/parallelMindedChatOpenAI.js +111 -0
- package/dist/platform/parallelMindedChatOpenAI.js.map +1 -0
- package/dist/platform/piiGateway/proxy.d.ts +20 -0
- package/dist/platform/piiGateway/proxy.d.ts.map +1 -0
- package/dist/platform/piiGateway/proxy.js +24 -0
- package/dist/platform/piiGateway/proxy.js.map +1 -0
- package/dist/platform/toolExecutor.d.ts.map +1 -1
- package/dist/platform/toolExecutor.js +4 -20
- package/dist/platform/toolExecutor.js.map +1 -1
- package/dist/playbooks/playbooks.d.ts +1 -1
- package/dist/playbooks/playbooks.d.ts.map +1 -1
- package/dist/playbooks/playbooks.js +1 -1
- package/dist/playbooks/playbooks.js.map +1 -1
- package/dist/toolsLibrary/classifier.d.ts.map +1 -1
- package/dist/toolsLibrary/classifier.js +5 -9
- package/dist/toolsLibrary/classifier.js.map +1 -1
- package/dist/toolsLibrary/extraction.d.ts.map +1 -1
- package/dist/toolsLibrary/extraction.js +5 -9
- package/dist/toolsLibrary/extraction.js.map +1 -1
- package/dist/toolsLibrary/parseDocument.d.ts.map +1 -1
- package/dist/toolsLibrary/parseDocument.js +6 -14
- package/dist/toolsLibrary/parseDocument.js.map +1 -1
- package/dist/types/Agent.d.ts +2 -0
- package/dist/types/Agent.d.ts.map +1 -0
- package/dist/types/Agent.js +18 -0
- package/dist/types/Agent.js.map +1 -0
- package/dist/types/Agent.types.d.ts +1 -1
- package/dist/types/Agent.types.d.ts.map +1 -1
- package/dist/types/Flows.d.ts +2 -0
- package/dist/types/Flows.d.ts.map +1 -0
- package/dist/types/Flows.js +18 -0
- package/dist/types/Flows.js.map +1 -0
- package/dist/types/LLM.d.ts +2 -0
- package/dist/types/LLM.d.ts.map +1 -0
- package/dist/types/LLM.js +18 -0
- package/dist/types/LLM.js.map +1 -0
- package/dist/types/LangGraph.d.ts +2 -0
- package/dist/types/LangGraph.d.ts.map +1 -0
- package/dist/types/LangGraph.js +18 -0
- package/dist/types/LangGraph.js.map +1 -0
- package/dist/types/LangGraph.types.d.ts.map +1 -1
- package/dist/types/LangGraph.types.js +30 -42
- package/dist/types/LangGraph.types.js.map +1 -1
- package/dist/types/Platform.d.ts +2 -0
- package/dist/types/Platform.d.ts.map +1 -0
- package/dist/types/Platform.js +18 -0
- package/dist/types/Platform.js.map +1 -0
- package/dist/types/Tools.d.ts +2 -0
- package/dist/types/Tools.d.ts.map +1 -0
- package/dist/types/Tools.js +18 -0
- package/dist/types/Tools.js.map +1 -0
- package/dist/types/Tools.types.d.ts +2 -7
- package/dist/types/Tools.types.d.ts.map +1 -1
- package/dist/types/Triggers.d.ts +2 -0
- package/dist/types/Triggers.d.ts.map +1 -0
- package/dist/types/Triggers.js +18 -0
- package/dist/types/Triggers.js.map +1 -0
- package/dist/types/Triggers.types.d.ts +25 -0
- package/dist/types/Triggers.types.d.ts.map +1 -0
- package/dist/types/Triggers.types.js +3 -0
- package/dist/types/Triggers.types.js.map +1 -0
- package/dist/types/Voice.d.ts +2 -0
- package/dist/types/Voice.d.ts.map +1 -0
- package/dist/types/Voice.js +18 -0
- package/dist/types/Voice.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/LogicalConditionDebugger.d.ts +57 -0
- package/dist/utils/LogicalConditionDebugger.d.ts.map +1 -0
- package/dist/utils/LogicalConditionDebugger.js +143 -0
- package/dist/utils/LogicalConditionDebugger.js.map +1 -0
- package/dist/utils/documentProcessor.d.ts +87 -0
- package/dist/utils/documentProcessor.d.ts.map +1 -0
- package/dist/utils/documentProcessor.js +726 -0
- package/dist/utils/documentProcessor.js.map +1 -0
- package/dist/utils/extractStateMemoryResponse.d.ts +0 -4
- package/dist/utils/extractStateMemoryResponse.d.ts.map +1 -1
- package/dist/utils/extractStateMemoryResponse.js +87 -89
- package/dist/utils/extractStateMemoryResponse.js.map +1 -1
- package/dist/utils/extractToolGuidelineParams.d.ts +4 -0
- package/dist/utils/extractToolGuidelineParams.d.ts.map +1 -0
- package/dist/utils/extractToolGuidelineParams.js +20 -0
- package/dist/utils/extractToolGuidelineParams.js.map +1 -0
- package/dist/utils/extractToolMemoryResponse.d.ts +4 -0
- package/dist/utils/extractToolMemoryResponse.d.ts.map +1 -0
- package/dist/utils/extractToolMemoryResponse.js +16 -0
- package/dist/utils/extractToolMemoryResponse.js.map +1 -0
- package/dist/utils/parseAttachments.d.ts +14 -0
- package/dist/utils/parseAttachments.d.ts.map +1 -0
- package/dist/utils/parseAttachments.js +54 -0
- package/dist/utils/parseAttachments.js.map +1 -0
- package/docs/sdk/agent-api.md +1 -1
- package/package.json +1 -1
- package/src/agent.ts +35 -61
- package/src/edges/createLogicalRouter.ts +4 -19
- package/src/events/AgentEvents.ts +5 -14
- package/src/internalTools/libraryActionRunnerTool.ts +0 -1
- package/src/interrupts/BaseInterruptSessionManager.ts +3 -9
- package/src/nodes/addAppToolNode.ts +19 -11
- package/src/nodes/addBrowserTaskNode.ts +22 -16
- package/src/nodes/addBrowserTaskRunNode.ts +10 -9
- package/src/nodes/addJumpToNode.ts +5 -4
- package/src/nodes/addJunctionNode.ts +5 -4
- package/src/nodes/addPromptNode.ts +39 -47
- package/src/nodes/addToolNode.ts +34 -20
- package/src/nodes/addToolRunNode.ts +15 -15
- package/src/nodes/addTriggerNode.ts +5 -5
- package/src/nodes/compilePrompt.ts +3 -0
- package/src/platform/mindedCheckpointSaver.ts +13 -13
- package/src/platform/toolExecutor.ts +4 -20
- package/src/playbooks/playbooks.ts +2 -2
- package/src/toolsLibrary/classifier.ts +6 -9
- package/src/toolsLibrary/extraction.ts +6 -9
- package/src/toolsLibrary/parseDocument.ts +7 -14
- package/src/types/Agent.types.ts +1 -1
- package/src/types/LangGraph.types.ts +30 -41
- package/src/types/Tools.types.ts +2 -7
- package/src/utils/extractStateMemoryResponse.ts +0 -94
|
@@ -23,30 +23,43 @@ const addToolNode = async ({ graph, node, tools, llm, agent, }) => {
|
|
|
23
23
|
description: matchedTool.description,
|
|
24
24
|
schema: matchedTool.input,
|
|
25
25
|
});
|
|
26
|
-
const combinedPlaybooks = (0, playbooks_1.combinePlaybooks)(agent.playbooks)
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const combinedPlaybooks = (0, playbooks_1.combinePlaybooks)(agent.playbooks);
|
|
27
|
+
const toolPrompt = node.prompt;
|
|
28
|
+
let finalMessage = toolPrompt;
|
|
29
|
+
if (combinedPlaybooks) {
|
|
30
|
+
if (toolPrompt) {
|
|
31
|
+
finalMessage = combinedPlaybooks + '\n\n' + toolPrompt;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
finalMessage = combinedPlaybooks;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (finalMessage) {
|
|
38
|
+
const compiledPrompt = (0, compilePrompt_1.compilePrompt)(finalMessage, { memory: state.memory });
|
|
39
|
+
const systemMessage = new messages_1.SystemMessage(compiledPrompt);
|
|
40
|
+
if (state.messages.length === 0 || state.messages[0].getType() === 'system') {
|
|
41
|
+
state.messages[0] = systemMessage;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
state.messages.unshift(systemMessage);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
30
47
|
const startTime = Date.now();
|
|
31
|
-
const AIToolCallMessage = await llm
|
|
32
|
-
.bindTools([tool], {
|
|
33
|
-
tool_choice: tool.name,
|
|
34
|
-
})
|
|
35
|
-
.invoke([...state.messages, new messages_1.SystemMessage(systemPrompt)]);
|
|
48
|
+
const AIToolCallMessage = await llm.bindTools([tool], { tool_choice: tool.name }).invoke(state.messages);
|
|
36
49
|
const endTime = Date.now();
|
|
37
50
|
logger_1.logger.debug({ msg: '[Tool] Model execution time', tool: matchedTool.name, executionTimeMs: endTime - startTime });
|
|
38
51
|
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
state.goto = null;
|
|
53
|
+
state.messages.push(AIToolCallMessage);
|
|
54
|
+
const historyMsg = (0, history_1.createHistoryStep)(state.history, {
|
|
55
|
+
type: Flows_types_1.NodeType.TOOL,
|
|
56
|
+
nodeId: node.name,
|
|
57
|
+
nodeDisplayName: node.displayName,
|
|
58
|
+
raw: ((_a = AIToolCallMessage.tool_calls) === null || _a === void 0 ? void 0 : _a[0]) || '',
|
|
59
|
+
messageIds: [AIToolCallMessage.id],
|
|
60
|
+
});
|
|
61
|
+
state.history.push(historyMsg);
|
|
62
|
+
return state;
|
|
50
63
|
};
|
|
51
64
|
graph.addNode(node.name, callback);
|
|
52
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addToolNode.js","sourceRoot":"","sources":["../../src/nodes/addToolNode.ts"],"names":[],"mappings":";;;AAAA,sDAA0D;AAE1D,iDAA8D;AAE9D,uDAAoE;AAGpE,4CAAyC;AAEzC,8CAAqD;AAErD,sDAA0D;AAC1D,mDAAgD;AAEzC,MAAM,WAAW,GAAG,KAAK,EAAE,EAChC,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,KAAK,GAON,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,IAAgB,CAAC;IAClC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,QAAQ,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,QAAQ,GAAiB,KAAK,EAAE,KAAmC,EAAE,EAAE;;QAC3E,MAAM,KAAK,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC5E,eAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,4BAA4B,EAAE,IAAI,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAEhF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AC;AAClD,OAAO,EAAiC,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"addToolRunNode.d.ts","sourceRoot":"","sources":["../../src/nodes/addToolRunNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAiC,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAMjC,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACxB,GAAG,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;IACtD,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAAc,MAAM,WAAiD,CAAC;AAGvG,eAAO,MAAM,cAAc,0DAAiE,oBAAoB,kBAsD/G,CAAC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.addToolRunNode = exports.buildToolRunNodeName = void 0;
|
|
7
4
|
const Flows_types_1 = require("../types/Flows.types");
|
|
8
5
|
const tools_1 = require("@langchain/core/tools");
|
|
9
|
-
const extractStateMemoryResponse_1 = __importDefault(require("../utils/extractStateMemoryResponse"));
|
|
10
6
|
const logger_1 = require("../utils/logger");
|
|
11
7
|
const history_1 = require("../utils/history");
|
|
12
8
|
const buildToolRunNodeName = (nodeName) => `${nodeName}${Flows_types_1.internalNodesSuffix.TOOL_RUN}`;
|
|
@@ -24,7 +20,7 @@ const addToolRunNode = async ({ graph, tools, toolNode, attachedToNodeName, agen
|
|
|
24
20
|
const response = await matchedTool.execute({ input, state, agent });
|
|
25
21
|
const endTime = Date.now();
|
|
26
22
|
logger_1.logger.debug({ msg: '[Tool] Tool execution time', tool: matchedTool.name, executionTimeMs: endTime - startTime });
|
|
27
|
-
return response
|
|
23
|
+
return response;
|
|
28
24
|
}
|
|
29
25
|
catch (err) {
|
|
30
26
|
logger_1.logger.error({ message: '[Tool] Error executing tool', err, node: toolNode.displayName });
|
|
@@ -41,22 +37,20 @@ const addToolRunNode = async ({ graph, tools, toolNode, attachedToNodeName, agen
|
|
|
41
37
|
throw new Error('Tool call not found');
|
|
42
38
|
}
|
|
43
39
|
const toolCallMessage = await tool.invoke(toolCallObj.tool_calls[0]);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
40
|
+
// Add the tool message to the state
|
|
41
|
+
state.messages.push(toolCallMessage);
|
|
42
|
+
// Add history step
|
|
43
|
+
state.history.push((0, history_1.createHistoryStep)(state.history, {
|
|
44
|
+
type: Flows_types_1.NodeType.TOOL,
|
|
45
|
+
nodeId: toolNode.name,
|
|
46
|
+
nodeDisplayName: toolNode.displayName,
|
|
47
|
+
raw: toolCallMessage,
|
|
48
|
+
messageIds: [toolCallObj.tool_calls[0].id],
|
|
49
|
+
}));
|
|
50
|
+
// Clear goto if it was set
|
|
51
|
+
state.goto = null;
|
|
52
|
+
// Return the entire modified state
|
|
53
|
+
return state;
|
|
60
54
|
};
|
|
61
55
|
graph.addNode((0, exports.buildToolRunNodeName)(attachedToNodeName), callback);
|
|
62
56
|
graph.addEdge(attachedToNodeName, (0, exports.buildToolRunNodeName)(attachedToNodeName));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addToolRunNode.js","sourceRoot":"","sources":["../../src/nodes/addToolRunNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addToolRunNode.js","sourceRoot":"","sources":["../../src/nodes/addToolRunNode.ts"],"names":[],"mappings":";;;AAIA,sDAA+E;AAC/E,iDAA8D;AAG9D,4CAAyC;AAEzC,8CAAqD;AAY9C,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,GAAG,QAAQ,GAAG,iCAAmB,CAAC,QAAQ,EAAE,CAAC;AAA1F,QAAA,oBAAoB,wBAAsE;AAEvG,uLAAuL;AAChL,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAwB,EAAE,EAAE;IAClH,MAAM,QAAQ,GAAiB,KAAK,EAAE,KAAmC,EAAE,EAAE;QAC3E,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1E,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,cAAc,GAAG,KAAK,EAAE,KAAwC,EAAE,EAAE;YACxE,IAAI,CAAC;gBACH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC7B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;gBACpE,MAA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YACrC,GAAG,EAAE,eAAe;YACpB,UAAU,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3C,CAAC,CACH,CAAC;QAEF,2BAA2B;QAC3B,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAElB,mCAAmC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,IAAA,4BAAoB,EAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClE,KAAK,CAAC,OAAO,CAAC,kBAAyB,EAAE,IAAA,4BAAoB,EAAC,kBAAkB,CAAQ,CAAC,CAAC;AAC5F,CAAC,CAAC;AAtDW,QAAA,cAAc,kBAsDzB"}
|
|
@@ -8,18 +8,16 @@ const addTriggerNode = async ({ graph, node }) => {
|
|
|
8
8
|
const callback = async (state) => {
|
|
9
9
|
logger_1.logger.debug({ msg: `[Trigger] Executing trigger node`, node: node.displayName });
|
|
10
10
|
if (node.triggerType === Flows_types_1.TriggerType.MANUAL) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
11
|
+
state.goto = null;
|
|
12
|
+
state.history.push((0, history_1.createHistoryStep)(state.history, {
|
|
13
|
+
type: Flows_types_1.NodeType.TRIGGER,
|
|
14
|
+
nodeId: node.name,
|
|
15
|
+
nodeDisplayName: node.displayName,
|
|
16
|
+
raw: '',
|
|
17
|
+
messageIds: [],
|
|
18
|
+
}));
|
|
21
19
|
}
|
|
22
|
-
return
|
|
20
|
+
return state;
|
|
23
21
|
};
|
|
24
22
|
graph.addNode(node.name, callback);
|
|
25
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addTriggerNode.js","sourceRoot":"","sources":["../../src/nodes/addTriggerNode.ts"],"names":[],"mappings":";;;AACA,sDAA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AAE,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC;AAnBW,QAAA,cAAc,kBAmBzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilePrompt.d.ts","sourceRoot":"","sources":["../../src/nodes/compilePrompt.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"compilePrompt.d.ts","sourceRoot":"","sources":["../../src/nodes/compilePrompt.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,MAAM,CAgBtF"}
|
|
@@ -31,6 +31,8 @@ const logger_1 = require("../utils/logger");
|
|
|
31
31
|
*/
|
|
32
32
|
function compilePrompt(prompt, params = {}) {
|
|
33
33
|
try {
|
|
34
|
+
// Define system parameters
|
|
35
|
+
params.system = { currentTime: new Date().toISOString() };
|
|
34
36
|
// First, render with EJS
|
|
35
37
|
let compiledPrompt = ejs.render(prompt, params);
|
|
36
38
|
// Then, replace placeholders in {} format
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilePrompt.js","sourceRoot":"","sources":["../../src/nodes/compilePrompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,
|
|
1
|
+
{"version":3,"file":"compilePrompt.js","sourceRoot":"","sources":["../../src/nodes/compilePrompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sCAgBC;AAtBD,yCAA2B;AAC3B,4CAAyC;AAEzC;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAc,EAAE,SAA8B,EAAE;IAC5E,IAAI,CAAC;QACH,2BAA2B;QAC3B,MAAM,CAAC,MAAM,GAAG,EA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Response, PIIGatewayInstance } from './types';
|
|
3
|
+
export declare class PIIGateway implements PIIGatewayInstance {
|
|
4
|
+
private mindedConnection;
|
|
5
|
+
private sessionId;
|
|
6
|
+
constructor(mindedConnection: MindedConnection, sessionId: string);
|
|
7
|
+
private makeRequest;
|
|
8
|
+
get<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
9
|
+
post<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
10
|
+
put<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
11
|
+
delete<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
12
|
+
patch<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
13
|
+
head<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
14
|
+
options<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
15
|
+
request<T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9E,qBAAa,UAAW,YAAW,kBAAkB;IACnD,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAS;gBAEd,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM;YAKnD,WAAW;IAmDnB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,O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const uuid_1 = require("uuid");
|
|
5
|
+
const mindedConnectionTypes_1 = require("../platform/mindedConnectionTypes");
|
|
6
|
+
class PIIGateway {
|
|
7
|
+
constructor(mindedConnection, sessionId) {
|
|
8
|
+
this.mindedConnection = mindedConnection;
|
|
9
|
+
this.sessionId = sessionId;
|
|
10
|
+
}
|
|
11
|
+
async makeRequest(method, url, data, config) {
|
|
12
|
+
var _a;
|
|
13
|
+
if (!((_a = this.mindedConnection) === null || _a === void 0 ? void 0 : _a.isConnected)) {
|
|
14
|
+
throw new Error('Minded connection is not established. PII-secured HTTP requests require a connection to the Minded platform.');
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const requestId = (0, uuid_1.v4)();
|
|
18
|
+
const requestPayload = {
|
|
19
|
+
type: mindedConnectionTypes_1.MindedConnectionSocketMessageType.PII_HTTP_REQUEST,
|
|
20
|
+
requestId,
|
|
21
|
+
method,
|
|
22
|
+
url,
|
|
23
|
+
headers: config === null || config === void 0 ? void 0 : config.headers,
|
|
24
|
+
params: config === null || config === void 0 ? void 0 : config.params,
|
|
25
|
+
data,
|
|
26
|
+
sessionId: this.sessionId,
|
|
27
|
+
};
|
|
28
|
+
const response = await this.mindedConnection.awaitEmit(mindedConnectionTypes_1.MindedConnectionSocketMessageType.PII_HTTP_REQUEST, requestPayload, 30000);
|
|
29
|
+
if (response.error) {
|
|
30
|
+
throw new Error(`HTTP request failed: ${response.error}`);
|
|
31
|
+
}
|
|
32
|
+
// Verify that the response requestId matches our request
|
|
33
|
+
if (response.requestId && response.requestId !== requestId) {
|
|
34
|
+
console.warn(`Response requestId (${response.requestId}) does not match request requestId (${requestId})`);
|
|
35
|
+
}
|
|
36
|
+
// Return generic HttpResponse format
|
|
37
|
+
return {
|
|
38
|
+
data: response.data,
|
|
39
|
+
status: response.status || 200,
|
|
40
|
+
statusText: response.statusText || 'OK',
|
|
41
|
+
headers: response.headers || {},
|
|
42
|
+
config: config || {},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new Error(`Secure HTTP request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async get(url, config) {
|
|
50
|
+
return this.makeRequest('GET', url, undefined, config);
|
|
51
|
+
}
|
|
52
|
+
async post(url, data, config) {
|
|
53
|
+
return this.makeRequest('POST', url, data, config);
|
|
54
|
+
}
|
|
55
|
+
async put(url, data, config) {
|
|
56
|
+
return this.makeRequest('PUT', url, data, config);
|
|
57
|
+
}
|
|
58
|
+
async delete(url, config) {
|
|
59
|
+
return this.makeRequest('DELETE', url, undefined, config);
|
|
60
|
+
}
|
|
61
|
+
async patch(url, data, config) {
|
|
62
|
+
return this.makeRequest('PATCH', url, data, config);
|
|
63
|
+
}
|
|
64
|
+
async head(url, config) {
|
|
65
|
+
return this.makeRequest('HEAD', url, undefined, config);
|
|
66
|
+
}
|
|
67
|
+
async options(url, config) {
|
|
68
|
+
return this.makeRequest('OPTIONS', url, undefined, config);
|
|
69
|
+
}
|
|
70
|
+
async request(config) {
|
|
71
|
+
var _a;
|
|
72
|
+
const method = (((_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'GET');
|
|
73
|
+
return this.makeRequest(method, config.url || '', config.data, config);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.PIIGateway = PIIGateway;
|
|
77
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/pii-gateway/gateway.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAEpC,6EAA2H;AAG3H,MAAa,UAAU;IAIrB,YAAY,gBAAkC,EAAE,SAAiB;QAC/D,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEO,KAAK,CAAC,WAAW,CACvB,MAAwE,E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OAAO,IAAI,CAAC,WAAW,CAAI,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,OAAO,CAAU,MAAyB;;QAC9C,MAAM,MAAM,GAAG,CAAC,CAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,WAAW,EAAE,KAAI,KAAK,CAAQ,CAAC;QAC9D,OAAO,IAAI,CAAC,WAAW,CAAI,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF;AA5FD,gCA4FC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { HttpRequestConfig, HttpResponse, PIIGatewayInstance } from './types';
|
|
2
|
+
export { PIIGateway } from './gateway';
|
|
3
|
+
export { piiGateway, getPIIGateway, createPIIGateway, _setGlobalPIIGateway, _clearGlobalPIIGateway } from './proxy';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGnF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._clearGlobalPIIGateway = exports._setGlobalPIIGateway = exports.createPIIGateway = exports.getPIIGateway = exports.piiGateway = exports.PIIGateway = void 0;
|
|
4
|
+
// Export core gateway class
|
|
5
|
+
var gateway_1 = require("./gateway");
|
|
6
|
+
Object.defineProperty(exports, "PIIGateway", { enumerable: true, get: function () { return gateway_1.PIIGateway; } });
|
|
7
|
+
// Export proxy and management functions
|
|
8
|
+
var proxy_1 = require("./proxy");
|
|
9
|
+
Object.defineProperty(exports, "piiGateway", { enumerable: true, get: function () { return proxy_1.piiGateway; } });
|
|
10
|
+
Object.defineProperty(exports, "getPIIGateway", { enumerable: true, get: function () { return proxy_1.getPIIGateway; } });
|
|
11
|
+
Object.defineProperty(exports, "createPIIGateway", { enumerable: true, get: function () { return proxy_1.createPIIGateway; } });
|
|
12
|
+
Object.defineProperty(exports, "_setGlobalPIIGateway", { enumerable: true, get: function () { return proxy_1._setGlobalPIIGateway; } });
|
|
13
|
+
Object.defineProperty(exports, "_clearGlobalPIIGateway", { enumerable: true, get: function () { return proxy_1._clearGlobalPIIGateway; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pii-gateway/index.ts"],"names":[],"mappings":";;;AAGA,4BAA4B;AAC5B,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,wCAAwC;AACxC,iCAAoH;AAA3G,mGAAA,UAAU,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,6GAAA,oBAAoB,OAAA;AAAE,+GAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { MindedConnection } from '../platform/mindedConnection';
|
|
2
|
+
import { PIIGatewayInstance } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Global PII Gateway that is automatically initialized when a trigger with sessionId is received.
|
|
5
|
+
* This provides seamless access to PII masking capabilities within workflows and custom tools.
|
|
6
|
+
*
|
|
7
|
+
* The gateway acts as a proxy that automatically uses the current session's PII context.
|
|
8
|
+
* All standard HTTP methods (get, post, put, delete, patch, head, options, request) are available.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { piiGateway } from '@minded-ai/mindedjs';
|
|
13
|
+
*
|
|
14
|
+
* // Within a custom tool or workflow (after trigger is received)
|
|
15
|
+
* async function fetchUserData() {
|
|
16
|
+
* const response = await piiGateway.get('/api/user/profile');
|
|
17
|
+
* return response.data;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // POST request
|
|
21
|
+
* const createResponse = await piiGateway.post('/api/users', {
|
|
22
|
+
* name: 'John Doe',
|
|
23
|
+
* email: 'john@example.com'
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const piiGateway: PIIGatewayInstance;
|
|
28
|
+
/**
|
|
29
|
+
* Get the global PII Gateway instance that is automatically initialized when a trigger with sessionId is received.
|
|
30
|
+
* This provides seamless access to PII masking capabilities within workflows and custom tools.
|
|
31
|
+
*
|
|
32
|
+
* @returns The PII Gateway instance for the current session
|
|
33
|
+
* @throws {Error} When no active session or PII gateway is not initialized
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { getPIIGateway } from '@minded-ai/mindedjs';
|
|
38
|
+
*
|
|
39
|
+
* // Within a custom tool or workflow (after trigger is received)
|
|
40
|
+
* async function fetchUserData() {
|
|
41
|
+
* const piiGateway = getPIIGateway();
|
|
42
|
+
* const response = await piiGateway.get('/api/user/profile');
|
|
43
|
+
* return response.data;
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function getPIIGateway(): PIIGatewayInstance;
|
|
48
|
+
/**
|
|
49
|
+
* Create a PII Gateway instance with a specific Minded connection and session ID.
|
|
50
|
+
* This is used internally by the Agent and for advanced use cases.
|
|
51
|
+
*
|
|
52
|
+
* @param mindedConnection - The Minded connection to use for the requests
|
|
53
|
+
* @param sessionId - Session ID for PII context (required for proper masking)
|
|
54
|
+
* @returns A PII Gateway instance
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { createPIIGateway } from '@minded-ai/mindedjs';
|
|
59
|
+
*
|
|
60
|
+
* const piiGateway = createPIIGateway(mindedConnection, 'session-123');
|
|
61
|
+
* const response = await piiGateway.get('/api/data');
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createPIIGateway(mindedConnection: MindedConnection, sessionId: string): PIIGatewayInstance;
|
|
65
|
+
/**
|
|
66
|
+
* Internal function used by the Agent to set the global PII gateway when a trigger is received.
|
|
67
|
+
* This ensures the PII masking is automatically available to SDK users.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
* @param mindedConnection - The Minded connection to use
|
|
71
|
+
* @param sessionId - The session ID from the trigger
|
|
72
|
+
*/
|
|
73
|
+
export declare function _setGlobalPIIGateway(mindedConnection: MindedConnection, sessionId: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Internal function to clear the global PII gateway.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare function _clearGlobalPIIGateway(): void;
|
|
80
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAM7C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,UAAU,EAAE,kBAOvB,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAKlD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAE1G;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.piiGateway = void 0;
|
|
4
|
+
exports.getPIIGateway = getPIIGateway;
|
|
5
|
+
exports.createPIIGateway = createPIIGateway;
|
|
6
|
+
exports._setGlobalPIIGateway = _setGlobalPIIGateway;
|
|
7
|
+
exports._clearGlobalPIIGateway = _clearGlobalPIIGateway;
|
|
8
|
+
const gateway_1 = require("./gateway");
|
|
9
|
+
// Global PII gateway instance that gets automatically set when triggers are received
|
|
10
|
+
let globalPIIGateway = null;
|
|
11
|
+
/**
|
|
12
|
+
* Global PII Gateway that is automatically initialized when a trigger with sessionId is received.
|
|
13
|
+
* This provides seamless access to PII masking capabilities within workflows and custom tools.
|
|
14
|
+
*
|
|
15
|
+
* The gateway acts as a proxy that automatically uses the current session's PII context.
|
|
16
|
+
* All standard HTTP methods (get, post, put, delete, patch, head, options, request) are available.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { piiGateway } from '@minded-ai/mindedjs';
|
|
21
|
+
*
|
|
22
|
+
* // Within a custom tool or workflow (after trigger is received)
|
|
23
|
+
* async function fetchUserData() {
|
|
24
|
+
* const response = await piiGateway.get('/api/user/profile');
|
|
25
|
+
* return response.data;
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* // POST request
|
|
29
|
+
* const createResponse = await piiGateway.post('/api/users', {
|
|
30
|
+
* name: 'John Doe',
|
|
31
|
+
* email: 'john@example.com'
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
exports.piiGateway = new Proxy({}, {
|
|
36
|
+
get(target, prop) {
|
|
37
|
+
if (!globalPIIGateway) {
|
|
38
|
+
throw new Error('PII Gateway is not available. Ensure a trigger with sessionId has been received first.');
|
|
39
|
+
}
|
|
40
|
+
return globalPIIGateway[prop];
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Get the global PII Gateway instance that is automatically initialized when a trigger with sessionId is received.
|
|
45
|
+
* This provides seamless access to PII masking capabilities within workflows and custom tools.
|
|
46
|
+
*
|
|
47
|
+
* @returns The PII Gateway instance for the current session
|
|
48
|
+
* @throws {Error} When no active session or PII gateway is not initialized
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { getPIIGateway } from '@minded-ai/mindedjs';
|
|
53
|
+
*
|
|
54
|
+
* // Within a custom tool or workflow (after trigger is received)
|
|
55
|
+
* async function fetchUserData() {
|
|
56
|
+
* const piiGateway = getPIIGateway();
|
|
57
|
+
* const response = await piiGateway.get('/api/user/profile');
|
|
58
|
+
* return response.data;
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
function getPIIGateway() {
|
|
63
|
+
if (!globalPIIGateway) {
|
|
64
|
+
throw new Error('PII Gateway is not available. Ensure a trigger with sessionId has been received first.');
|
|
65
|
+
}
|
|
66
|
+
return globalPIIGateway;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a PII Gateway instance with a specific Minded connection and session ID.
|
|
70
|
+
* This is used internally by the Agent and for advanced use cases.
|
|
71
|
+
*
|
|
72
|
+
* @param mindedConnection - The Minded connection to use for the requests
|
|
73
|
+
* @param sessionId - Session ID for PII context (required for proper masking)
|
|
74
|
+
* @returns A PII Gateway instance
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* import { createPIIGateway } from '@minded-ai/mindedjs';
|
|
79
|
+
*
|
|
80
|
+
* const piiGateway = createPIIGateway(mindedConnection, 'session-123');
|
|
81
|
+
* const response = await piiGateway.get('/api/data');
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
function createPIIGateway(mindedConnection, sessionId) {
|
|
85
|
+
return new gateway_1.PIIGateway(mindedConnection, sessionId);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Internal function used by the Agent to set the global PII gateway when a trigger is received.
|
|
89
|
+
* This ensures the PII masking is automatically available to SDK users.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
* @param mindedConnection - The Minded connection to use
|
|
93
|
+
* @param sessionId - The session ID from the trigger
|
|
94
|
+
*/
|
|
95
|
+
function _setGlobalPIIGateway(mindedConnection, sessionId) {
|
|
96
|
+
globalPIIGateway = new gateway_1.PIIGateway(mindedConnection, sessionId);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Internal function to clear the global PII gateway.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
function _clearGlobalPIIGateway() {
|
|
104
|
+
globalPIIGateway = null;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/pii-gateway/proxy.ts"],"names":[],"mappings":";;;AA2DA,sCAKC;AAkBD,4CAEC;AAUD,oDAEC;AAOD,wDAEC;AAvGD,uCAAuC;AAEvC,qFAAqF;AACrF,IAAI,gBAAgB,GAAsB,IAAI,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACU,QAAA,UAAU,GAAuB,IAAI,KAAK,CAAC,EAAwB,EAAE;IAChF,GAAG,CAAC,MAAM,EAAE,IAAI;QACd,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;QAC5G,CAAC;QACD,OAAQ,gBAAwB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,aAAa;IAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;IAC5G,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,gBAAgB,CAAC,gBAAkC,EAAE,SAAiB;IACpF,OAAO,IAAI,oBAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,gBAAkC,EAAE,SAAiB;IACxF,gBAAgB,GAAG,IAAI,oBAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB;IACpC,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface HttpRequestConfig {
|
|
2
|
+
method?: string;
|
|
3
|
+
url?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
params?: Record<string, any>;
|
|
6
|
+
data?: any;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface HttpResponse<T = any> {
|
|
11
|
+
data: T;
|
|
12
|
+
status: number;
|
|
13
|
+
statusText: string;
|
|
14
|
+
headers: Record<string, string>;
|
|
15
|
+
config: HttpRequestConfig;
|
|
16
|
+
}
|
|
17
|
+
export interface PIIGatewayInstance {
|
|
18
|
+
get<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
19
|
+
post<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
20
|
+
put<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
21
|
+
delete<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
22
|
+
patch<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
23
|
+
head<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
24
|
+
options<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
25
|
+
request<T = any>(config: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pii-gateway/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACnC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,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["../../src/platform/mindedChatOpenAI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGjE,qBAAa,gBAAiB,SAAQ,UAAU;gBAClC,MAAM,CAAC,EAAE,gBAAgB;CActC"}
|