@minded-ai/mindedjs 2.0.6 → 2.0.7-beta-2
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/browserTask/README.md +419 -0
- package/dist/browserTask/browserAgent.py +632 -0
- package/dist/browserTask/captcha_isolated.png +0 -0
- package/dist/browserTask/executeBrowserTask.ts +79 -0
- package/dist/browserTask/requirements.txt +8 -0
- package/dist/browserTask/setup.sh +144 -0
- package/dist/cli/index.js +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- 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/nodes/addRpaNode.d.ts +16 -0
- package/dist/nodes/addRpaNode.d.ts.map +1 -0
- package/dist/nodes/addRpaNode.js +177 -0
- package/dist/nodes/addRpaNode.js.map +1 -0
- package/dist/nodes/nodeFactory.d.ts.map +1 -1
- package/dist/nodes/nodeFactory.js +4 -0
- package/dist/nodes/nodeFactory.js.map +1 -1
- package/dist/platform/config.js +1 -1
- package/dist/platform/config.js.map +1 -1
- package/dist/types/Flows.types.d.ts +35 -2
- package/dist/types/Flows.types.d.ts.map +1 -1
- package/dist/types/Flows.types.js +13 -1
- package/dist/types/Flows.types.js.map +1 -1
- 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/package.json +2 -1
- package/src/index.ts +3 -0
- package/src/nodes/addRpaNode.ts +205 -0
- package/src/nodes/nodeFactory.ts +4 -0
- package/src/platform/config.ts +1 -1
- package/src/types/Flows.types.ts +37 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { logger } from '../utils/logger';
|
|
4
|
+
|
|
5
|
+
export const executeBrowserTask = async (prompt: string): Promise<string> => {
|
|
6
|
+
const pythonScriptPath = join(__dirname, 'browserAgent.py');
|
|
7
|
+
const venvPythonPath = join(__dirname, '.venv', 'bin', 'python');
|
|
8
|
+
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
// Determine which Python to use - prefer venv if it exists
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const pythonCommand = fs.existsSync(venvPythonPath) ? venvPythonPath : 'python3';
|
|
13
|
+
|
|
14
|
+
// Use Python to run our browser agent script with CAPTCHA bypass
|
|
15
|
+
const child = spawn(pythonCommand, [pythonScriptPath, '-p', prompt, '--output-format', 'json'], {
|
|
16
|
+
env: {
|
|
17
|
+
...process.env,
|
|
18
|
+
// Ensure Python can find the script and dependencies
|
|
19
|
+
PYTHONPATH: __dirname,
|
|
20
|
+
// Set virtual environment if it exists
|
|
21
|
+
VIRTUAL_ENV: fs.existsSync(join(__dirname, '.venv')) ? join(__dirname, '.venv') : undefined,
|
|
22
|
+
},
|
|
23
|
+
cwd: __dirname,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
let output = '';
|
|
27
|
+
let errorOutput = '';
|
|
28
|
+
|
|
29
|
+
// Stream stdout to console and collect it
|
|
30
|
+
child.stdout.on('data', (data) => {
|
|
31
|
+
const chunk = data.toString();
|
|
32
|
+
logger.trace({ message: 'Browser task output', output: chunk });
|
|
33
|
+
output += chunk;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Stream stderr to console and collect errors
|
|
37
|
+
child.stderr.on('data', (data) => {
|
|
38
|
+
const chunk = data.toString();
|
|
39
|
+
logger.error({ message: 'Browser task error', error: chunk });
|
|
40
|
+
errorOutput += chunk;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
child.on('error', (error) => {
|
|
44
|
+
logger.error({ message: 'Failed to start browser task process', error: error.message });
|
|
45
|
+
reject(new Error(`Failed to start browser task: ${error.message}`));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
child.on('close', (code) => {
|
|
49
|
+
if (code !== 0) {
|
|
50
|
+
logger.error({
|
|
51
|
+
message: 'Browser task process exited with error',
|
|
52
|
+
code,
|
|
53
|
+
stderr: errorOutput,
|
|
54
|
+
});
|
|
55
|
+
reject(new Error(`Browser task failed with code ${code}: ${errorOutput}`));
|
|
56
|
+
} else {
|
|
57
|
+
try {
|
|
58
|
+
// Parse JSON output from Python script
|
|
59
|
+
const result = JSON.parse(output.trim());
|
|
60
|
+
if (result.success) {
|
|
61
|
+
logger.info({ message: 'Browser task completed successfully' });
|
|
62
|
+
resolve(result.result || 'Task completed successfully');
|
|
63
|
+
} else {
|
|
64
|
+
logger.error({ message: 'Browser task failed', error: result.error });
|
|
65
|
+
reject(new Error(result.error || 'Unknown error occurred'));
|
|
66
|
+
}
|
|
67
|
+
} catch (parseError) {
|
|
68
|
+
// Fallback to plain text output if JSON parsing fails
|
|
69
|
+
logger.warn({
|
|
70
|
+
message: 'Could not parse JSON output, using plain text',
|
|
71
|
+
output: output.trim(),
|
|
72
|
+
});
|
|
73
|
+
resolve(output.trim() || 'Task completed');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Browser Agent Setup Script
|
|
4
|
+
# This script sets up the Python environment for the browser agent with CAPTCHA bypass
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "🚀 Setting up Browser Agent with CAPTCHA Bypass..."
|
|
9
|
+
|
|
10
|
+
# Get the directory where this script is located
|
|
11
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
+
cd "$SCRIPT_DIR"
|
|
13
|
+
|
|
14
|
+
# Check if Python 3 is installed
|
|
15
|
+
if ! command -v python3 &> /dev/null; then
|
|
16
|
+
echo "❌ Python 3 is not installed. Please install Python 3.11 or higher."
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Check Python version - browser-use requires Python 3.11+
|
|
21
|
+
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
|
|
22
|
+
PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d. -f1)
|
|
23
|
+
PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d. -f2)
|
|
24
|
+
|
|
25
|
+
if [ "$PYTHON_MAJOR" -lt 3 ] || { [ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 11 ]; }; then
|
|
26
|
+
echo "❌ Python 3.11 or higher is required for browser-use. Found Python $PYTHON_VERSION"
|
|
27
|
+
echo "💡 Please install Python 3.11+ or use a version manager like pyenv:"
|
|
28
|
+
echo " # Install pyenv (if not installed)"
|
|
29
|
+
echo " curl https://pyenv.run | bash"
|
|
30
|
+
echo " # Install and use Python 3.12"
|
|
31
|
+
echo " pyenv install 3.12.0"
|
|
32
|
+
echo " pyenv local 3.12.0"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
echo "✅ Python $PYTHON_VERSION detected"
|
|
37
|
+
|
|
38
|
+
# Check if uv is installed
|
|
39
|
+
if ! command -v uv &> /dev/null; then
|
|
40
|
+
echo "⚠️ uv is not installed. Installing uv..."
|
|
41
|
+
# Install uv
|
|
42
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
43
|
+
|
|
44
|
+
# Source the shell to get uv in PATH
|
|
45
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
46
|
+
|
|
47
|
+
# Verify installation
|
|
48
|
+
if ! command -v uv &> /dev/null; then
|
|
49
|
+
echo "❌ Failed to install uv. Please install manually:"
|
|
50
|
+
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
echo "✅ uv detected"
|
|
56
|
+
|
|
57
|
+
echo "🐍 Setting up Python environment with uv..."
|
|
58
|
+
|
|
59
|
+
# Create virtual environment with uv (if not exists)
|
|
60
|
+
if [ ! -d ".venv" ]; then
|
|
61
|
+
echo "🐍 Creating virtual environment..."
|
|
62
|
+
|
|
63
|
+
# Try Python 3.12 first, then fall back to 3.11
|
|
64
|
+
if uv venv --python 3.12 2>/dev/null; then
|
|
65
|
+
echo "✅ Created virtual environment with Python 3.12"
|
|
66
|
+
elif uv venv --python 3.11 2>/dev/null; then
|
|
67
|
+
echo "✅ Created virtual environment with Python 3.11"
|
|
68
|
+
else
|
|
69
|
+
echo "❌ Failed to create virtual environment with Python 3.11+. Please check your Python installation."
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
else
|
|
73
|
+
echo "✅ Virtual environment already exists"
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
echo "📦 Installing Python dependencies with uv..."
|
|
77
|
+
|
|
78
|
+
# Install Python dependencies using uv
|
|
79
|
+
uv pip install -r requirements.txt
|
|
80
|
+
|
|
81
|
+
# Install playwright browsers
|
|
82
|
+
echo "🌐 Installing Playwright browsers..."
|
|
83
|
+
uv run playwright install
|
|
84
|
+
|
|
85
|
+
# Check if tesseract is installed (required for OCR)
|
|
86
|
+
if ! command -v tesseract &> /dev/null; then
|
|
87
|
+
echo "⚠️ Tesseract OCR is not installed. Installing..."
|
|
88
|
+
|
|
89
|
+
# Detect OS and install tesseract
|
|
90
|
+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
91
|
+
# Linux
|
|
92
|
+
if command -v apt-get &> /dev/null; then
|
|
93
|
+
sudo apt-get update
|
|
94
|
+
sudo apt-get install -y tesseract-ocr tesseract-ocr-eng
|
|
95
|
+
elif command -v yum &> /dev/null; then
|
|
96
|
+
sudo yum install -y tesseract tesseract-langpack-eng
|
|
97
|
+
elif command -v dnf &> /dev/null; then
|
|
98
|
+
sudo dnf install -y tesseract tesseract-langpack-eng
|
|
99
|
+
else
|
|
100
|
+
echo "❌ Could not install tesseract automatically. Please install it manually."
|
|
101
|
+
echo " For Ubuntu/Debian: sudo apt-get install tesseract-ocr"
|
|
102
|
+
echo " For CentOS/RHEL: sudo yum install tesseract"
|
|
103
|
+
fi
|
|
104
|
+
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
105
|
+
# macOS
|
|
106
|
+
if command -v brew &> /dev/null; then
|
|
107
|
+
brew install tesseract
|
|
108
|
+
else
|
|
109
|
+
echo "❌ Homebrew not found. Please install tesseract manually:"
|
|
110
|
+
echo " brew install tesseract"
|
|
111
|
+
exit 1
|
|
112
|
+
fi
|
|
113
|
+
else
|
|
114
|
+
echo "❌ Unsupported OS. Please install tesseract manually."
|
|
115
|
+
exit 1
|
|
116
|
+
fi
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# Verify tesseract installation
|
|
120
|
+
if command -v tesseract &> /dev/null; then
|
|
121
|
+
TESSERACT_VERSION=$(tesseract --version | head -n1)
|
|
122
|
+
echo "✅ $TESSERACT_VERSION detected"
|
|
123
|
+
else
|
|
124
|
+
echo "❌ Tesseract installation failed or not found in PATH"
|
|
125
|
+
exit 1
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# Make the Python script executable
|
|
129
|
+
chmod +x browserAgent.py
|
|
130
|
+
|
|
131
|
+
echo "🎉 Setup completed successfully!"
|
|
132
|
+
echo ""
|
|
133
|
+
echo "📋 Next steps:"
|
|
134
|
+
echo "1. Activate the virtual environment:"
|
|
135
|
+
echo " source .venv/bin/activate"
|
|
136
|
+
echo ""
|
|
137
|
+
echo "2. Set your OpenAI API key in environment variables:"
|
|
138
|
+
echo " export OPENAI_API_KEY='your-api-key-here'"
|
|
139
|
+
echo ""
|
|
140
|
+
echo "3. Test the browser agent:"
|
|
141
|
+
echo " uv run python browserAgent.py -p 'Navigate to google.com and search for browser automation'"
|
|
142
|
+
echo " # Or with activated venv: python browserAgent.py -p 'Navigate to google.com'"
|
|
143
|
+
echo ""
|
|
144
|
+
echo "✨ The browser agent is now ready with CAPTCHA bypass capabilities!"
|
package/dist/cli/index.js
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { createParallelWrapper } from './platform/models/parallelWrapper';
|
|
|
13
13
|
export type { MindedChatOpenAIFields, BaseParallelChatFields } from './platform/models/mindedChatOpenAI';
|
|
14
14
|
export type { BaseParallelChatFields as ParallelWrapperFields } from './platform/models/parallelWrapper';
|
|
15
15
|
export type { PIIGatewayInstance, HttpRequestConfig, HttpResponse } from './platform/piiGateway';
|
|
16
|
-
export type { Flow, Node, Edge, TriggerNode, AppTriggerNode, PromptNode, PromptConditionEdge, LogicalConditionEdge, StepForwardEdge, ManualTriggerNode, JunctionNode, ToolNode, AppToolNode, VoiceTriggerNode, WebhookTriggerNode, InterfaceTriggerNode, } from './types/Flows.types';
|
|
16
|
+
export type { Flow, Node, Edge, TriggerNode, AppTriggerNode, PromptNode, PromptConditionEdge, LogicalConditionEdge, StepForwardEdge, ManualTriggerNode, JunctionNode, ToolNode, AppToolNode, VoiceTriggerNode, WebhookTriggerNode, InterfaceTriggerNode, RpaNode, RpaStep, RpaActionType, } from './types/Flows.types';
|
|
17
17
|
export { NodeType, TriggerType, EdgeType, AppNodeMetadata, AppNodeMetadataType, NodeMetadata, KnownTriggerNames, } from './types/Flows.types';
|
|
18
18
|
export type { Tool, ToolExecuteInput } from './types/Tools.types';
|
|
19
19
|
export { DocumentProcessor, extractFromDocument } from './internalTools/documentExtraction/documentExtraction';
|
package/dist/index.d.ts.map
CH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B,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElG,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAW9B,sFAXO,aAAK,OAWP;AAVP,sDAA8B;AAW5B,iBAXK,gBAAM,CAWL;AAVR,2CAAwC;AAWtC,uFAXO,eAAM,OAWP;AAVR,yFAAsF;AAWpF,uGAXO,+CAAsB,OAWP;AAVxB,iDAAyE;AAWvE,2FAXO,kBAAU,OAWP;AACV,4FAZmB,mBAAW,OAYnB;AACX,wFAbgC,eAAO,OAahC;AAZT,yDAAyE;AAavE,2FAbO,mBAAU,OAaP;AACV,8FAdmB,sBAAa,OAcnB;AAbf,+EAA4E;AAc1E,kGAdO,qCAAiB,OAcP;AAbnB,4EAAqF;AAcnF,kHAdO,yDAAiC,OAcP;AAGnC,6BAA6B;AAC7B,uEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AACzB,qEAA0E;AAAjE,wHAAA,qBAAqB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAW9B,sFAXO,aAAK,OAWP;AAVP,sDAA8B;AAW5B,iBAXK,gBAAM,CAWL;AAVR,2CAAwC;AAWtC,uFAXO,eAAM,OAWP;AAVR,yFAAsF;AAWpF,uGAXO,+CAAsB,OAWP;AAVxB,iDAAyE;AAWvE,2FAXO,kBAAU,OAWP;AACV,4FAZmB,mBAAW,OAYnB;AACX,wFAbgC,eAAO,OAahC;AAZT,yDAAyE;AAavE,2FAbO,mBAAU,OAaP;AACV,8FAdmB,sBAAa,OAcnB;AAbf,+EAA4E;AAc1E,kGAdO,qCAAiB,OAcP;AAbnB,4EAAqF;AAcnF,kHAdO,yDAAiC,OAcP;AAGnC,6BAA6B;AAC7B,uEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AACzB,qEAA0E;AAAjE,wHAAA,qBAAqB,OAAA;AA4B9B,mDAQ6B;AAP3B,uGAAA,QAAQ,OAAA;AACR,0GAAA,WAAW,OAAA;AACX,uGAAA,QAAQ,OAAA;AAER,kHAAA,mBAAmB,OAAA;AAEnB,gHAAA,iBAAiB,OAAA;AAInB,gCAAgC;AAChC,4FAA+G;AAAtG,uHAAA,iBAAiB,OAAA;AAAE,yHAAA,mBAAmB,OAAA;AAO/C,mDAQ6B;AAF3B,0GAAA,WAAW,OAAA;AAMb,gDAA+C;AAAtC,kGAAA,OAAO,OAAA;AAEhB,uBAAuB;AACvB,+DAA+C;AAE/C,8BAA8B;AAC9B,wDAAsF;AAA7E,sGAAA,QAAQ,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,2GAAA,aAAa,OAAA;AAGlD,8BAA8B;AAC9B,wDAAqE;AAA5D,qGAAA,OAAO,OAAA;AAAE,6GAAA,eAAe,OAAA;AAGjC,qBAAqB;AACrB,oDAAmD;AAA1C,0GAAA,WAAW,OAAA;AAGpB,uEAA+F;AAAtF,0HAAA,oBAAoB,OAAA;AAAE,2HAAA,qBAAqB,OAAA;AAEpD,yCAAsD;AAA7C,oHAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TimerResetResponse, RetellGetCallResponse } from '../platform/mindedConnectionTypes';
|
|
2
|
+
export declare function retellCall({ sessionId, callName, callAgentId, vars, }: {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
callName: string;
|
|
5
|
+
callAgentId: string;
|
|
6
|
+
vars?: Record<string, any>;
|
|
7
|
+
}): Promise<TimerResetResponse>;
|
|
8
|
+
export declare function retellGetCall({ sessionId, callId }: {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
callId: string;
|
|
11
|
+
}): Promise<RetellGetCallResponse>;
|
|
12
|
+
//# sourceMappingURL=retell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.retellCall = retellCall;
|
|
37
|
+
exports.retellGetCall = retellGetCall;
|
|
38
|
+
const mindedConnection = __importStar(require("../platform/mindedConnection"));
|
|
39
|
+
const mindedConnectionTypes_1 = require("../platform/mindedConnectionTypes");
|
|
40
|
+
async function retellCall({ sessionId, callName, callAgentId, vars = {}, }) {
|
|
41
|
+
return await mindedConnection.awaitEmit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.RETELL_CALL, {
|
|
42
|
+
sessionId,
|
|
43
|
+
callName,
|
|
44
|
+
callAgentId,
|
|
45
|
+
vars,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async function retellGetCall({ sessionId, callId }) {
|
|
49
|
+
return await mindedConnection.awaitEmit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.RETELL_GET_CALL, {
|
|
50
|
+
sessionId,
|
|
51
|
+
callId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=retell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send a placeholder message to the dashboard voice session.
|
|
3
|
+
* This is typically used for voice sessions to provide immediate feedback to users.
|
|
4
|
+
*
|
|
5
|
+
* @param params - The parameters for sending the placeholder message
|
|
6
|
+
* @param params.sessionId - The session ID of the voice session
|
|
7
|
+
* @param params.message - The placeholder message to send
|
|
8
|
+
* @throws {Error} When the Minded connection is not established
|
|
9
|
+
*/
|
|
10
|
+
export declare function sendPlaceholderMessage(params: {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=sendPlaceholderMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.sendPlaceholderMessage = sendPlaceholderMessage;
|
|
37
|
+
const mindedConnection = __importStar(require("../platform/mindedConnection"));
|
|
38
|
+
const mindedConnectionTypes_1 = require("../platform/mindedConnectionTypes");
|
|
39
|
+
/**
|
|
40
|
+
* Send a placeholder message to the dashboard voice session.
|
|
41
|
+
* This is typically used for voice sessions to provide immediate feedback to users.
|
|
42
|
+
*
|
|
43
|
+
* @param params - The parameters for sending the placeholder message
|
|
44
|
+
* @param params.sessionId - The session ID of the voice session
|
|
45
|
+
* @param params.message - The placeholder message to send
|
|
46
|
+
* @throws {Error} When the Minded connection is not established
|
|
47
|
+
*/
|
|
48
|
+
async function sendPlaceholderMessage(params) {
|
|
49
|
+
const { sessionId, message } = params;
|
|
50
|
+
if (!mindedConnection.isConnected()) {
|
|
51
|
+
throw new Error('Minded connection is not established when trying to send placeholder message');
|
|
52
|
+
}
|
|
53
|
+
const connection = mindedConnection;
|
|
54
|
+
connection.emit(mindedConnectionTypes_1.mindedConnectionSocketMessageType.VOICE_PLACEHOLDER_MESSAGES, {
|
|
55
|
+
sessionId,
|
|
56
|
+
message,
|
|
57
|
+
timestamp: Date.now(),
|
|
58
|
+
type: mindedConnectionTypes_1.mindedConnectionSocketMessageType.VOICE_PLACEHOLDER_MESSAGES,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sendPlaceholderMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RpaNode } from '../types/Flows.types';
|
|
2
|
+
import { PreCompiledGraph } from '../types/LangGraph.types';
|
|
3
|
+
import { Tool } from '../types/Tools.types';
|
|
4
|
+
import { AgentEventRequestPayloads } from '../events/AgentEvents';
|
|
5
|
+
import { EmitSignature } from '../types/Agent.types';
|
|
6
|
+
import { Agent } from '../agent';
|
|
7
|
+
type AddRpaNodeParams = {
|
|
8
|
+
graph: PreCompiledGraph;
|
|
9
|
+
node: RpaNode;
|
|
10
|
+
tools: Tool<any, any>[];
|
|
11
|
+
emit: EmitSignature<any, keyof AgentEventRequestPayloads<any>>;
|
|
12
|
+
agent: Agent;
|
|
13
|
+
};
|
|
14
|
+
export declare const addRpaNode: ({ graph, node, tools, emit, agent }: AddRpaNodeParams) => Promise<void>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=addRpaNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addRpaNode.d.ts","sourceRoot":"","sources":["../../src/nodes/addRpaNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAe,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKjC,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACxB,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,MAAM,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,UAAU,wCAA+C,gBAAgB,kBAqHrF,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addRpaNode = void 0;
|
|
4
|
+
const Flows_types_1 = require("../types/Flows.types");
|
|
5
|
+
const logger_1 = require("../utils/logger");
|
|
6
|
+
const history_1 = require("../utils/history");
|
|
7
|
+
const playwright_1 = require("playwright");
|
|
8
|
+
const addRpaNode = async ({ graph, node, tools, emit, agent }) => {
|
|
9
|
+
const callback = async (state) => {
|
|
10
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId);
|
|
11
|
+
logger_1.logger.info({ msg: `[Node] Executing RPA node`, node: node.displayName, sessionId: state.sessionId });
|
|
12
|
+
let browser = null;
|
|
13
|
+
let page = null;
|
|
14
|
+
try {
|
|
15
|
+
// Get CDP URL from state
|
|
16
|
+
const cdpUrl = state.cdpUrl;
|
|
17
|
+
if (!cdpUrl) {
|
|
18
|
+
throw new Error('CDP URL not found in state. Make sure a browser session is available.');
|
|
19
|
+
}
|
|
20
|
+
logger_1.logger.debug({
|
|
21
|
+
msg: '[RPA] Connecting to browser via CDP',
|
|
22
|
+
cdpUrl,
|
|
23
|
+
sessionId: state.sessionId,
|
|
24
|
+
node: node.displayName,
|
|
25
|
+
});
|
|
26
|
+
// Connect to existing browser via CDP
|
|
27
|
+
browser = await playwright_1.chromium.connectOverCDP(cdpUrl);
|
|
28
|
+
const contexts = browser.contexts();
|
|
29
|
+
if (contexts.length === 0) {
|
|
30
|
+
throw new Error('No browser contexts found');
|
|
31
|
+
}
|
|
32
|
+
// Get the first page or create a new one
|
|
33
|
+
const pages = contexts[0].pages();
|
|
34
|
+
page = pages.length > 0 ? pages[0] : await contexts[0].newPage();
|
|
35
|
+
// Set viewport if specified
|
|
36
|
+
if (node.viewport) {
|
|
37
|
+
await page.setViewportSize(node.viewport);
|
|
38
|
+
}
|
|
39
|
+
// Execute each step
|
|
40
|
+
const results = [];
|
|
41
|
+
for (const [index, step] of node.steps.entries()) {
|
|
42
|
+
logger_1.logger.debug({
|
|
43
|
+
msg: '[RPA] Executing step',
|
|
44
|
+
stepIndex: index + 1,
|
|
45
|
+
stepType: step.type,
|
|
46
|
+
sessionId: state.sessionId,
|
|
47
|
+
node: node.displayName,
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const result = await executeRpaStep(page, step);
|
|
51
|
+
results.push({
|
|
52
|
+
stepIndex: index + 1,
|
|
53
|
+
type: step.type,
|
|
54
|
+
success: true,
|
|
55
|
+
result,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (stepError) {
|
|
59
|
+
logger_1.logger.error({
|
|
60
|
+
msg: '[RPA] Step execution failed',
|
|
61
|
+
stepIndex: index + 1,
|
|
62
|
+
stepType: step.type,
|
|
63
|
+
error: stepError instanceof Error ? stepError.message : 'Unknown error',
|
|
64
|
+
sessionId: state.sessionId,
|
|
65
|
+
node: node.displayName,
|
|
66
|
+
});
|
|
67
|
+
results.push({
|
|
68
|
+
stepIndex: index + 1,
|
|
69
|
+
type: step.type,
|
|
70
|
+
success: false,
|
|
71
|
+
error: stepError instanceof Error ? stepError.message : 'Unknown error',
|
|
72
|
+
});
|
|
73
|
+
// Stop execution on error unless configured otherwise
|
|
74
|
+
throw stepError;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Update history with RPA execution results
|
|
78
|
+
state.history.push((0, history_1.createHistoryStep)(state.history, {
|
|
79
|
+
type: Flows_types_1.NodeType.RPA,
|
|
80
|
+
nodeId: node.name,
|
|
81
|
+
nodeDisplayName: node.displayName,
|
|
82
|
+
raw: {
|
|
83
|
+
steps: node.steps,
|
|
84
|
+
results,
|
|
85
|
+
viewport: node.viewport,
|
|
86
|
+
},
|
|
87
|
+
messageIds: [],
|
|
88
|
+
}));
|
|
89
|
+
// Clear goto to allow natural flow progression
|
|
90
|
+
state.goto = null;
|
|
91
|
+
// Check for interrupts after RPA execution
|
|
92
|
+
await agent.interruptSessionManager.checkQueueAndInterrupt(state.sessionId, state);
|
|
93
|
+
return state;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
logger_1.logger.error({
|
|
97
|
+
msg: '[RPA] Error executing RPA node',
|
|
98
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
99
|
+
sessionId: state.sessionId,
|
|
100
|
+
node: node.displayName,
|
|
101
|
+
});
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
// Note: We don't close the browser as it's connected via CDP
|
|
106
|
+
// The browser session should remain active for other operations
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
graph.addNode(node.name, callback);
|
|
110
|
+
};
|
|
111
|
+
exports.addRpaNode = addRpaNode;
|
|
112
|
+
// Helper function to execute individual RPA steps
|
|
113
|
+
async function executeRpaStep(page, step) {
|
|
114
|
+
switch (step.type) {
|
|
115
|
+
case Flows_types_1.RpaActionType.CLICK:
|
|
116
|
+
if (step.xpath) {
|
|
117
|
+
await page.locator(`xpath=${step.xpath}`).click({ timeout: 30000 });
|
|
118
|
+
}
|
|
119
|
+
else if (step.selector) {
|
|
120
|
+
await page.click(step.selector, { timeout: 30000 });
|
|
121
|
+
}
|
|
122
|
+
return { action: 'clicked' };
|
|
123
|
+
case Flows_types_1.RpaActionType.TYPE:
|
|
124
|
+
if (step.shouldReplaceExistingText) {
|
|
125
|
+
if (step.xpath) {
|
|
126
|
+
await page.locator(`xpath=${step.xpath}`).fill(step.text || '');
|
|
127
|
+
}
|
|
128
|
+
else if (step.selector) {
|
|
129
|
+
await page.fill(step.selector, step.text || '');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
if (step.xpath) {
|
|
134
|
+
await page.locator(`xpath=${step.xpath}`).type(step.text || '');
|
|
135
|
+
}
|
|
136
|
+
else if (step.selector) {
|
|
137
|
+
await page.type(step.selector, step.text || '');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { action: 'typed', text: step.text };
|
|
141
|
+
case Flows_types_1.RpaActionType.WAIT:
|
|
142
|
+
await page.waitForTimeout(step.waitTime || 1000);
|
|
143
|
+
return { action: 'waited', duration: step.waitTime };
|
|
144
|
+
case Flows_types_1.RpaActionType.GOTO:
|
|
145
|
+
await page.goto(step.url || '', { waitUntil: 'networkidle' });
|
|
146
|
+
return { action: 'navigated', url: step.url };
|
|
147
|
+
case Flows_types_1.RpaActionType.PRESS:
|
|
148
|
+
await page.keyboard.press(step.key || 'Enter');
|
|
149
|
+
return { action: 'pressed', key: step.key };
|
|
150
|
+
case Flows_types_1.RpaActionType.SELECT:
|
|
151
|
+
if (step.xpath) {
|
|
152
|
+
await page.locator(`xpath=${step.xpath}`).selectOption(step.value || '');
|
|
153
|
+
}
|
|
154
|
+
else if (step.selector) {
|
|
155
|
+
await page.selectOption(step.selector, step.value || '');
|
|
156
|
+
}
|
|
157
|
+
return { action: 'selected', value: step.value };
|
|
158
|
+
case Flows_types_1.RpaActionType.HOVER:
|
|
159
|
+
if (step.xpath) {
|
|
160
|
+
await page.locator(`xpath=${step.xpath}`).hover();
|
|
161
|
+
}
|
|
162
|
+
else if (step.selector) {
|
|
163
|
+
await page.hover(step.selector);
|
|
164
|
+
}
|
|
165
|
+
return { action: 'hovered' };
|
|
166
|
+
case Flows_types_1.RpaActionType.SCREENSHOT:
|
|
167
|
+
const screenshot = await page.screenshot({ type: 'png' });
|
|
168
|
+
return {
|
|
169
|
+
action: 'screenshot',
|
|
170
|
+
description: step.description,
|
|
171
|
+
data: screenshot.toString('base64'),
|
|
172
|
+
};
|
|
173
|
+
default:
|
|
174
|
+
throw new Error(`Unknown RPA action type: ${step.type}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=addRpaNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addRpaNode.js","sourceRoot":"","sources":["../../src/nodes/addRpaNode.ts"],"names":[],"mappings":";;;AACA,sDAAwE;AAMxE,4CAAyC;AACzC,8CAAqD;AACrD,2CAAqD;AAU9C,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAoB,EAAE,EAAE;IACxF,MAAM,QAAQ,GAAiB,KAAK,EAAE,KAAmC,EAAE,EAAE;QAC3E,MAAM,KAAK,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC5E,eAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,2BAA2B,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QAEtG,IAAI,OAAO,GAAmB,IAAI,CAAC;QACnC,IAAI,IAAI,GAAgB,IAAI,CAAC;QAE7B,IAAI,CAAC;YACH,yBAAyB;YACzB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,uEAAuE,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3B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1D,OAAO;gBACL,MAAM,EAAE,YAAY;gBACpB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;aACpC,CAAC;QAEJ;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeFactory.d.ts","sourceRoot":"","sources":["../../src/nodes/nodeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"nodeFactory.d.ts","sourceRoot":"","sources":["../../src/nodes/nodeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAMjC,eAAO,MAAM,WAAW,8CAOrB;IACD,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACxB,GAAG,EAAE,CAAC,OAAO,YAAY,EAAE,MAAM,OAAO,YAAY,CAAC,CAAC;IACtD,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,MAAM,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,KAAK,EAAE,KAAK,CAAC;CACd,SA8BA,CAAC"}
|