@minded-ai/mindedjs 1.0.120 → 1.0.121
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.js +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/edges/createLogicalRouter.js +1 -1
- package/dist/edges/createLogicalRouter.js.map +1 -1
- package/dist/edges/createPromptRouter.d.ts.map +1 -1
- package/dist/edges/createPromptRouter.js +0 -7
- package/dist/edges/createPromptRouter.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- 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 +42 -0
- package/dist/internalTools/voice/escalateVoiceCall.js.map +1 -0
- package/dist/internalTools/{retell.d.ts → voice/retell.d.ts} +1 -1
- package/dist/internalTools/voice/retell.d.ts.map +1 -0
- package/dist/internalTools/{retell.js → voice/retell.js} +2 -2
- package/dist/internalTools/voice/retell.js.map +1 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.d.ts.map +1 -0
- package/dist/internalTools/{sendPlaceholderMessage.js → voice/sendPlaceholderMessage.js} +2 -2
- package/dist/internalTools/voice/sendPlaceholderMessage.js.map +1 -0
- package/dist/nodes/addAppToolNode.d.ts.map +1 -1
- package/dist/nodes/addAppToolNode.js +7 -13
- package/dist/nodes/addAppToolNode.js.map +1 -1
- package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskNode.js +5 -72
- package/dist/nodes/addBrowserTaskNode.js.map +1 -1
- package/dist/nodes/addJumpToNode.js +1 -1
- package/dist/nodes/addJumpToNode.js.map +1 -1
- package/dist/nodes/addPromptNode.d.ts.map +1 -1
- package/dist/nodes/addPromptNode.js +12 -10
- package/dist/nodes/addPromptNode.js.map +1 -1
- package/dist/nodes/addToolNode.d.ts.map +1 -1
- package/dist/nodes/addToolNode.js +8 -13
- package/dist/nodes/addToolNode.js.map +1 -1
- package/dist/nodes/addToolRunNode.d.ts.map +1 -1
- package/dist/nodes/addToolRunNode.js +3 -0
- package/dist/nodes/addToolRunNode.js.map +1 -1
- package/dist/nodes/compilePrompt.d.ts +5 -0
- package/dist/nodes/compilePrompt.d.ts.map +1 -0
- package/dist/nodes/compilePrompt.js +63 -0
- package/dist/nodes/compilePrompt.js.map +1 -0
- package/dist/playbooks/playbooks.d.ts +2 -2
- package/dist/playbooks/playbooks.d.ts.map +1 -1
- package/dist/playbooks/playbooks.js +4 -33
- package/dist/playbooks/playbooks.js.map +1 -1
- package/dist/voice/voiceSession.d.ts +0 -1
- package/dist/voice/voiceSession.d.ts.map +1 -1
- package/dist/voice/voiceSession.js +0 -12
- package/dist/voice/voiceSession.js.map +1 -1
- package/package.json +2 -2
- package/src/agent.ts +8 -8
- package/src/edges/createLogicalRouter.ts +1 -1
- package/src/edges/createPromptRouter.ts +5 -12
- package/src/index.ts +4 -3
- package/src/internalTools/voice/escalateVoiceCall.ts +15 -0
- package/src/internalTools/{retell.ts → voice/retell.ts} +2 -2
- package/src/internalTools/{sendPlaceholderMessage.ts → voice/sendPlaceholderMessage.ts} +2 -2
- package/src/nodes/addAppToolNode.ts +10 -13
- package/src/nodes/addBrowserTaskNode.ts +6 -55
- package/src/nodes/addJumpToNode.ts +1 -1
- package/src/nodes/addPromptNode.ts +13 -11
- package/src/nodes/addToolNode.ts +9 -15
- package/src/nodes/addToolRunNode.ts +3 -0
- package/src/nodes/compilePrompt.ts +41 -0
- package/src/playbooks/playbooks.ts +4 -37
- package/src/voice/voiceSession.ts +0 -13
- package/dist/internalTools/retell.d.ts.map +0 -1
- package/dist/internalTools/retell.js.map +0 -1
- package/dist/internalTools/sendPlaceholderMessage.d.ts.map +0 -1
- package/dist/internalTools/sendPlaceholderMessage.js.map +0 -1
- /package/dist/internalTools/{sendPlaceholderMessage.d.ts → voice/sendPlaceholderMessage.d.ts} +0 -0
|
@@ -8,9 +8,10 @@ import { LLMProviders } from '../types/LLM.types';
|
|
|
8
8
|
import { AppActionInvocationHistoryStep } from '../types/Agent.types';
|
|
9
9
|
import { Agent } from '../agent';
|
|
10
10
|
import { logger } from '../utils/logger';
|
|
11
|
-
import { compilePlaybooks } from '../playbooks/playbooks';
|
|
12
11
|
import { createHistoryStep } from '../utils/history';
|
|
13
12
|
import { Tool } from '../types/Tools.types';
|
|
13
|
+
import { combinePlaybooks } from '../playbooks/playbooks';
|
|
14
|
+
import { compilePrompt } from './compilePrompt';
|
|
14
15
|
|
|
15
16
|
export const addAppToolNode = async ({
|
|
16
17
|
graph,
|
|
@@ -51,14 +52,10 @@ export const addAppToolNode = async ({
|
|
|
51
52
|
description: appRunnerTool.description,
|
|
52
53
|
schema: appRunnerTool.input,
|
|
53
54
|
});
|
|
54
|
-
// Get compiled playbooks with proper parameters
|
|
55
|
-
const playbookParams = {
|
|
56
|
-
...state.memory, // Spread memory fields at the top level
|
|
57
|
-
currentTime: new Date().toISOString(),
|
|
58
|
-
};
|
|
59
|
-
const compiledPlaybooks = compilePlaybooks(agent.playbooks, playbookParams) || '';
|
|
60
55
|
|
|
61
|
-
const
|
|
56
|
+
const combinedPlaybooks = combinePlaybooks(agent.playbooks) || '';
|
|
57
|
+
|
|
58
|
+
const message = `${combinedPlaybooks ? combinedPlaybooks + '\n\n' : ''}
|
|
62
59
|
Additional context:
|
|
63
60
|
previous messages are available for context.
|
|
64
61
|
Your goal is execute the tool with the correct parameters, some of them already chosen by the user and the rest should be generated.
|
|
@@ -70,15 +67,15 @@ export const addAppToolNode = async ({
|
|
|
70
67
|
Parameters manually configured by the user are:
|
|
71
68
|
${JSON.stringify(cleanedParameters)}
|
|
72
69
|
User instructions for choosing tool parameters are:
|
|
73
|
-
${node.prompt ? `${node.prompt}` : 'no instructions set by the user'}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
${node.prompt ? `${node.prompt}` : 'no instructions set by the user'}`;
|
|
71
|
+
|
|
72
|
+
const compiledPrompt = compilePrompt(message, { state, currentTime: new Date().toISOString() });
|
|
73
|
+
|
|
77
74
|
const AIToolCallMessage = await llm
|
|
78
75
|
.bindTools([tool], {
|
|
79
76
|
tool_choice: tool.name,
|
|
80
77
|
})
|
|
81
|
-
.invoke([...state.messages, new SystemMessage(
|
|
78
|
+
.invoke([...state.messages, new SystemMessage(compiledPrompt)]);
|
|
82
79
|
AIToolCallMessage.tool_calls[0].args = {
|
|
83
80
|
...AIToolCallMessage.tool_calls[0].args,
|
|
84
81
|
...cleanedParameters, //user set parameters have priority over ai generated parameters
|
|
@@ -11,46 +11,8 @@ import { createBrowserSession } from '../browserTask/executeBrowserTask';
|
|
|
11
11
|
import { tool as langchainTool } from '@langchain/core/tools';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { LLMProviders } from '../types/LLM.types';
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Compile prompt with parameters using EJS and placeholder replacement
|
|
19
|
-
*/
|
|
20
|
-
function compilePrompt(prompt: string, params: Record<string, any> = {}): string {
|
|
21
|
-
try {
|
|
22
|
-
// First, render with EJS
|
|
23
|
-
let compiledPrompt = ejs.render(prompt, params);
|
|
24
|
-
|
|
25
|
-
// Then, replace placeholders in {} format
|
|
26
|
-
compiledPrompt = replacePlaceholders(compiledPrompt, params);
|
|
27
|
-
|
|
28
|
-
return compiledPrompt;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
logger.error({ message: 'Error compiling prompt', error });
|
|
31
|
-
return prompt; // Return uncompiled if there's an error
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Replace placeholders in {key} format
|
|
37
|
-
*/
|
|
38
|
-
function replacePlaceholders(text: string, params: Record<string, any>): string {
|
|
39
|
-
return text.replace(/\{([^}]+)\}/g, (match, key) => {
|
|
40
|
-
const keys = key.split('.');
|
|
41
|
-
let value: any = params;
|
|
42
|
-
|
|
43
|
-
for (const k of keys) {
|
|
44
|
-
if (value && typeof value === 'object' && k in value) {
|
|
45
|
-
value = value[k];
|
|
46
|
-
} else {
|
|
47
|
-
return match; // Return original if key not found
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return String(value);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
14
|
+
import { compilePrompt } from './compilePrompt';
|
|
15
|
+
import { combinePlaybooks } from '../playbooks/playbooks';
|
|
54
16
|
|
|
55
17
|
type AddBrowserTaskNodeParams = {
|
|
56
18
|
graph: PreCompiledGraph;
|
|
@@ -92,23 +54,14 @@ export const addBrowserTaskNode = async ({ graph, node, agent, llm }: AddBrowser
|
|
|
92
54
|
const zodSchema = z.object(schemaFields);
|
|
93
55
|
|
|
94
56
|
// Create langchain tool
|
|
95
|
-
const tool = langchainTool(() => {}, {
|
|
57
|
+
const tool = langchainTool(() => { }, {
|
|
96
58
|
name: 'browser-task',
|
|
97
59
|
description: node.prompt,
|
|
98
60
|
schema: zodSchema,
|
|
99
61
|
});
|
|
100
62
|
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
...state.memory,
|
|
104
|
-
state,
|
|
105
|
-
currentTime: new Date().toISOString(),
|
|
106
|
-
};
|
|
107
|
-
const compiledPlaybooks = compilePlaybooks(agent.playbooks, playbookParams) || '';
|
|
108
|
-
|
|
109
|
-
const systemPrompt = `${compiledPlaybooks ? compiledPlaybooks + '\n\n' : ''}
|
|
110
|
-
Additional context:
|
|
111
|
-
- workflow memory: ${JSON.stringify(state.memory)}`;
|
|
63
|
+
const combinedPlaybooks = combinePlaybooks(agent.playbooks) || '';
|
|
64
|
+
const systemPrompt = combinedPlaybooks ? compilePrompt(combinedPlaybooks, { state, currentTime: new Date().toISOString() }) : '';
|
|
112
65
|
|
|
113
66
|
try {
|
|
114
67
|
// Use LLM to generate tool call
|
|
@@ -142,9 +95,7 @@ Follow the instructions. Any retrieved data should be printed as string and not
|
|
|
142
95
|
# Task instructions:
|
|
143
96
|
${compiledPrompt}
|
|
144
97
|
|
|
145
|
-
${Object.keys(inputParams).length > 0 ? `# Input parameters:\n${JSON.stringify(inputParams, null, 2)}\n\n` : ''}
|
|
146
|
-
${state.memory ? `# Task context:\n${JSON.stringify(state.memory)}\n\n` : ''}
|
|
147
|
-
`;
|
|
98
|
+
${Object.keys(inputParams).length > 0 ? `# Input parameters:\n${JSON.stringify(inputParams, null, 2)}\n\n` : ''}`;
|
|
148
99
|
|
|
149
100
|
// Create browser session using socket
|
|
150
101
|
const session = await createBrowserSession(node.proxy);
|
|
@@ -10,7 +10,7 @@ export const addJumpToNode = async ({ graph, node }: { graph: PreCompiledGraph;
|
|
|
10
10
|
logger.info(`Executing jump node ${node.displayName} – jumping to ${node.targetNodeId}`);
|
|
11
11
|
// No state modifications are necessary; control flow is handled via edges.
|
|
12
12
|
return {
|
|
13
|
-
goto:
|
|
13
|
+
goto: node.targetNodeId,
|
|
14
14
|
history: createHistoryStep<HistoryStep>(state.history, {
|
|
15
15
|
type: NodeType.JUMP_TO_NODE,
|
|
16
16
|
nodeId: node.name,
|
|
@@ -12,8 +12,9 @@ import { createLlmInstance } from '../llm/createLlmInstance';
|
|
|
12
12
|
import extractToolStateResponse from '../utils/extractStateMemoryResponse';
|
|
13
13
|
import { Agent } from '../agent';
|
|
14
14
|
import { logger } from '../utils/logger';
|
|
15
|
-
import {
|
|
15
|
+
import { combinePlaybooks } from '../playbooks/playbooks';
|
|
16
16
|
import { createHistoryStep } from '../utils/history';
|
|
17
|
+
import { compilePrompt } from './compilePrompt';
|
|
17
18
|
|
|
18
19
|
type AddPromptNodeParams = {
|
|
19
20
|
graph: PreCompiledGraph;
|
|
@@ -39,20 +40,19 @@ export const addPromptNode = async ({ graph, node, llm, tools, emit, agent }: Ad
|
|
|
39
40
|
}),
|
|
40
41
|
);
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
const playbookParams = {
|
|
44
|
-
...state.memory, // Spread memory fields at the top level
|
|
45
|
-
};
|
|
46
|
-
const compiledPlaybooks = compilePlaybooks(agent.playbooks, playbookParams) || '';
|
|
43
|
+
const combinedPlaybooks = combinePlaybooks(agent.playbooks) || '';
|
|
47
44
|
|
|
48
|
-
const
|
|
45
|
+
const prompt = `
|
|
49
46
|
${node.prompt ? `# Task instructions:\n${node.prompt}\n\n` : ''}
|
|
50
|
-
${
|
|
51
|
-
${compiledPlaybooks ? `# General guidelines:\n${compiledPlaybooks}\n\n` : ''}
|
|
47
|
+
${combinedPlaybooks ? `# General guidelines:\n${combinedPlaybooks}\n\n` : ''}
|
|
52
48
|
`;
|
|
53
49
|
|
|
54
|
-
const
|
|
50
|
+
const compiledPrompt = compilePrompt(prompt, { state, currentTime: new Date().toISOString() });
|
|
55
51
|
|
|
52
|
+
const startTime = Date.now();
|
|
53
|
+
const result: AIMessage = await llmToUse.bindTools(globalTools).invoke([...state.messages, new SystemMessage(compiledPrompt)]);
|
|
54
|
+
const endTime = Date.now();
|
|
55
|
+
logger.debug({ msg: '[Model] Model execution time', executionTimeMs: endTime - startTime });
|
|
56
56
|
// Check if the result contains tool calls
|
|
57
57
|
if (result.tool_calls && result.tool_calls.length > 0) {
|
|
58
58
|
// Execute the tools
|
|
@@ -65,8 +65,10 @@ export const addPromptNode = async ({ graph, node, llm, tools, emit, agent }: Ad
|
|
|
65
65
|
if (matchedTool) {
|
|
66
66
|
try {
|
|
67
67
|
// Invoke the LangChain tool directly
|
|
68
|
+
const startTime = Date.now();
|
|
68
69
|
const toolResult = await matchedTool.invoke(toolCall);
|
|
69
|
-
|
|
70
|
+
const endTime = Date.now();
|
|
71
|
+
logger.debug({ msg: `[Tool] Tool result`, tool: matchedTool?.name, result: toolResult, executionTimeMs: endTime - startTime });
|
|
70
72
|
const toolStateUpdate = extractToolStateResponse(toolResult);
|
|
71
73
|
// Properly merge memory and other state updates
|
|
72
74
|
stateUpdates = {
|
package/src/nodes/addToolNode.ts
CHANGED
|
@@ -7,9 +7,10 @@ import { RunnableLike } from '@langchain/core/runnables';
|
|
|
7
7
|
import { LLMProviders } from '../types/LLM.types';
|
|
8
8
|
import { logger } from '../utils/logger';
|
|
9
9
|
import { Agent } from '../agent';
|
|
10
|
-
import { compilePlaybooks } from '../playbooks/playbooks';
|
|
11
10
|
import { createHistoryStep } from '../utils/history';
|
|
12
11
|
import { HistoryStep } from '../types/Agent.types';
|
|
12
|
+
import { combinePlaybooks } from '../playbooks/playbooks';
|
|
13
|
+
import { compilePrompt } from './compilePrompt';
|
|
13
14
|
|
|
14
15
|
export const addToolNode = async ({
|
|
15
16
|
graph,
|
|
@@ -32,30 +33,23 @@ export const addToolNode = async ({
|
|
|
32
33
|
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
33
34
|
logger.debug({ msg: `[Node] Executing tool node`, node: toolNode.displayName });
|
|
34
35
|
|
|
35
|
-
const tool = langchainTool(() => {}, {
|
|
36
|
+
const tool = langchainTool(() => { }, {
|
|
36
37
|
name: matchedTool.name,
|
|
37
38
|
description: matchedTool.description,
|
|
38
39
|
schema: matchedTool.input,
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
...state.memory, // Spread memory fields at the top level
|
|
44
|
-
currentTime: new Date().toISOString(),
|
|
45
|
-
// Add any other common parameters that playbooks might need
|
|
46
|
-
};
|
|
47
|
-
const compiledPlaybooks = compilePlaybooks(agent.playbooks, playbookParams) || '';
|
|
42
|
+
const combinedPlaybooks = combinePlaybooks(agent.playbooks) || '';
|
|
43
|
+
const systemPrompt = combinedPlaybooks ? compilePrompt(combinedPlaybooks, { state, currentTime: new Date().toISOString() }) : '';
|
|
48
44
|
|
|
49
|
-
const
|
|
50
|
-
Additional context:
|
|
51
|
-
workflow memory: ${JSON.stringify(state.memory)}
|
|
52
|
-
`;
|
|
45
|
+
const startTime = Date.now();
|
|
53
46
|
const AIToolCallMessage: AIMessage = await llm
|
|
54
47
|
.bindTools([tool], {
|
|
55
48
|
tool_choice: tool.name,
|
|
56
49
|
})
|
|
57
|
-
.invoke([...state.messages, new SystemMessage(
|
|
58
|
-
|
|
50
|
+
.invoke([...state.messages, new SystemMessage(systemPrompt)]);
|
|
51
|
+
const endTime = Date.now();
|
|
52
|
+
logger.debug({ msg: '[Tool] Model execution time', tool: matchedTool.name, executionTimeMs: endTime - startTime });
|
|
59
53
|
return {
|
|
60
54
|
goto: null,
|
|
61
55
|
messages: [AIToolCallMessage],
|
|
@@ -32,7 +32,10 @@ export const addToolRunNode = async ({ graph, tools, toolNode, attachedToNodeNam
|
|
|
32
32
|
|
|
33
33
|
const executeWrapper = async (input: z.infer<typeof matchedTool.input>) => {
|
|
34
34
|
try {
|
|
35
|
+
const startTime = Date.now();
|
|
35
36
|
const response = await matchedTool.execute({ input, state, agent });
|
|
37
|
+
const endTime = Date.now();
|
|
38
|
+
logger.debug({ msg: '[Tool] Tool execution time', tool: matchedTool.name, executionTimeMs: endTime - startTime });
|
|
36
39
|
return response || {};
|
|
37
40
|
} catch (error) {
|
|
38
41
|
logger.error({ msg: '[Tool] Error executing tool', error, node: toolNode.displayName });
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import * as ejs from 'ejs';
|
|
3
|
+
import { logger } from '../utils/logger';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compile prompt with parameters using EJS and placeholder replacement
|
|
7
|
+
*/
|
|
8
|
+
export function compilePrompt(prompt: string, params: Record<string, any> = {}): string {
|
|
9
|
+
try {
|
|
10
|
+
// First, render with EJS
|
|
11
|
+
let compiledPrompt = ejs.render(prompt, params);
|
|
12
|
+
|
|
13
|
+
// Then, replace placeholders in {} format
|
|
14
|
+
compiledPrompt = replacePlaceholders(compiledPrompt, params);
|
|
15
|
+
|
|
16
|
+
return compiledPrompt;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
logger.error({ message: 'Error compiling prompt', error });
|
|
19
|
+
return prompt; // Return uncompiled if there's an error
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Replace placeholders in {key} format
|
|
25
|
+
*/
|
|
26
|
+
function replacePlaceholders(text: string, params: Record<string, any>): string {
|
|
27
|
+
return text.replace(/\{([^}]+)\}/g, (match, key) => {
|
|
28
|
+
const keys = key.split('.');
|
|
29
|
+
let value: any = params;
|
|
30
|
+
|
|
31
|
+
for (const k of keys) {
|
|
32
|
+
if (value && typeof value === 'object' && k in value) {
|
|
33
|
+
value = value[k];
|
|
34
|
+
} else {
|
|
35
|
+
return match; // Return original if key not found
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return String(value);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as yaml from 'js-yaml';
|
|
4
|
-
import * as ejs from 'ejs';
|
|
5
4
|
import * as mindedConnection from '../platform/mindedConnection';
|
|
6
5
|
import { mindedConnectionSocketMessageType } from '../platform/mindedConnectionTypes';
|
|
7
6
|
import { getConfig } from '../platform/config';
|
|
@@ -159,9 +158,9 @@ function getAllYamlFiles(dir: string): string[] {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
/**
|
|
162
|
-
*
|
|
161
|
+
* Combine playbooks into a single string
|
|
163
162
|
*/
|
|
164
|
-
export function
|
|
163
|
+
export function combinePlaybooks(playbooks: Playbook[]): string {
|
|
165
164
|
if (playbooks.length === 0) {
|
|
166
165
|
return '';
|
|
167
166
|
}
|
|
@@ -173,37 +172,5 @@ export function compilePlaybooks(playbooks: Playbook[], params: Record<string, a
|
|
|
173
172
|
});
|
|
174
173
|
|
|
175
174
|
const combinedPlaybooks = sections.join('\n\n');
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// First, render with EJS
|
|
179
|
-
let compiledPlaybooks = ejs.render(combinedPlaybooks, params);
|
|
180
|
-
|
|
181
|
-
// Then, replace placeholders in {} format
|
|
182
|
-
compiledPlaybooks = replacePlaceholders(compiledPlaybooks, params);
|
|
183
|
-
|
|
184
|
-
return compiledPlaybooks;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
logger.error({ message: 'Error compiling playbooks', error });
|
|
187
|
-
return combinedPlaybooks; // Return uncompiled if there's an error
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Replace placeholders in {key} format
|
|
193
|
-
*/
|
|
194
|
-
function replacePlaceholders(text: string, params: Record<string, any>): string {
|
|
195
|
-
return text.replace(/\{([^}]+)\}/g, (match, key) => {
|
|
196
|
-
const keys = key.split('.');
|
|
197
|
-
let value: any = params;
|
|
198
|
-
|
|
199
|
-
for (const k of keys) {
|
|
200
|
-
if (value && typeof value === 'object' && k in value) {
|
|
201
|
-
value = value[k];
|
|
202
|
-
} else {
|
|
203
|
-
return match; // Return original if key not found
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return String(value);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
175
|
+
return combinedPlaybooks;
|
|
176
|
+
}
|
|
@@ -252,19 +252,6 @@ export class VoiceSession {
|
|
|
252
252
|
this.elevenLabsSocket?.close();
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
/*
|
|
256
|
-
* Escalate the voice session
|
|
257
|
-
* @param parameters - The parameters to escalate the voice session. Parameters will be handeled differently according to the VOIP provider.
|
|
258
|
-
*/
|
|
259
|
-
public escalate(parameters: any): void {
|
|
260
|
-
mindedConnection.emit(mindedConnectionSocketMessageType.VOICE_ESCALATE, {
|
|
261
|
-
type: mindedConnectionSocketMessageType.VOICE_ESCALATE,
|
|
262
|
-
sessionId: this.sessionId,
|
|
263
|
-
timestamp: Date.now(),
|
|
264
|
-
parameters,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
255
|
/*
|
|
269
256
|
* Set callback for audio data in base64 format
|
|
270
257
|
* @param callback - The callback to handle the audio data
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retell.d.ts","sourceRoot":"","sources":["../../src/internalTools/retell.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAEjI,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9B;AAED,wBAAsB,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAKhI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retell.js","sourceRoot":"","sources":["../../src/internalTools/retell.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,gCAiBC;AAED,sCAKC;AA3BD,+EAAiE;AACjE,6EAAiI;AAE1H,KAAK,UAAU,UAAU,CAAC,EAC/B,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,GAAG,EAAE,GAMV;IACC,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,yDAAiC,CAAC,WAAW,EAAE;QACrF,SAAS;QACT,QAAQ;QACR,WAAW;QACX,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAyC;IAC9F,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,yDAAiC,CAAC,eAAe,EAAE;QACzF,SAAS;QACT,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendPlaceholderMessage.d.ts","sourceRoot":"","sources":["../../src/internalTools/sendPlaceholderMessage.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1G"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendPlaceholderMessage.js","sourceRoot":"","sources":["../../src/internalTools/sendPlaceholderMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wDAcC;AA1BD,+EAAiE;AACjE,6EAAsF;AAEtF;;;;;;;;GAQG;AACI,KAAK,UAAU,sBAAsB,CAAC,MAA8C;IACzF,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAEtC,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,UAAU,GAAG,gBAAgB,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,yDAAiC,CAAC,0BAA0B,EAAE;QAC5E,SAAS;QACT,OAAO;QACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,IAAI,EAAE,yDAAiC,CAAC,0BAA0B;KACnE,CAAC,CAAC;AACL,CAAC"}
|
/package/dist/internalTools/{sendPlaceholderMessage.d.ts → voice/sendPlaceholderMessage.d.ts}
RENAMED
|
File without changes
|