@minded-ai/mindedjs 1.0.144 → 1.0.145-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,8 @@
1
+ browser-use>=0.5.6
2
+ opencv-python>=4.8.0
3
+ pytesseract>=0.3.10
4
+ pillow>=10.0.0
5
+ numpy>=1.24.0
6
+ playwright>=1.40.0
7
+ python-dotenv>=1.0.0
8
+ openai>=1.97.0
@@ -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!"
@@ -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"}
@@ -1,8 +1,10 @@
1
1
  import { TimerResetResponse, TimerCancelResponse } from '../platform/mindedConnectionTypes';
2
+ import { State } from '../types/LangGraph.types';
2
3
  export declare const timerHandlers: Map<string, {
3
4
  handler: (params: {
4
5
  sessionId: string;
5
6
  payload: Record<string, any>;
7
+ state: State<any>;
6
8
  }) => void | Promise<void>;
7
9
  }>;
8
10
  /**
@@ -91,6 +93,7 @@ export declare function onTimer({ timerName, handler, }: {
91
93
  handler: (params: {
92
94
  sessionId: string;
93
95
  payload: Record<string, any>;
96
+ state: State<any>;
94
97
  }) => void | Promise<void>;
95
98
  }): void;
96
99
  //# sourceMappingURL=timer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/internalTools/timer.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAG/H,eAAO,MAAM,aAAa;aAGb,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;EAE/F,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,OAAO,EACP,SAAS,EACT,OAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAQpG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,OAAO,CAAC,EACtB,SAAS,EACT,OAAO,GACR,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,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C,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnH,GAAG,IAAI,CAGP"}
@@ -126,15 +126,4 @@ function onTimer({ timerName, handler, }) {
126
126
  // Set the handler for this timer name (replaces any existing handler)
127
127
  exports.timerHandlers.set(timerName, { handler });
128
128
  }
129
- mindedConnection.on(mindedConnectionTypes_1.mindedConnectionSocketMessageType.TIMER_TRIGGER, async (timerTriggerMessage) => {
130
- // Get handler for the specific timer name
131
- const handlerEntry = exports.timerHandlers.get(timerTriggerMessage.timerName);
132
- // Call the handler if it exists
133
- if (handlerEntry) {
134
- await handlerEntry.handler({
135
- sessionId: timerTriggerMessage.sessionId,
136
- payload: timerTriggerMessage.eventArgs,
137
- });
138
- }
139
- });
140
129
  //# sourceMappingURL=timer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.js","sourceRoot":"","sources":["../../src/internalTools/timer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,gCAiBC;AAkBD,kCAQC;AAiCD,0BASC;AA3HD,+EAAiE;AACjE,6EAA+H;AAE/H,kEAAkE;AACrD,QAAA,aAAa,GAAG,IAAI,GAAG,EAKjC,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,KAAK,UAAU,UAAU,CAAC,EAC/B,SAAS,EACT,OAAO,EACP,SAAS,EACT,OAAO,GAAG,EAAE,GAMb;IACC,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,yDAAiC,CAAC,WAAW,EAAE;QACrF,SAAS;QACT,OAAO;QACP,SAAS;QACT,SAAS,EAAE,OAAO;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,WAAW,CAAC,SAAiB,EAAE,SAAiB;IACpE,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC;QACp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SAAS;QACT,OAAO;QACP,SAAS;QACT,SAAS,EAAE,OAAO;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,WAAW,CAAC,SAAiB,EAAE,SAAiB;IACpE,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,MAAM,gBAAgB,CAAC,SAAS,CAAC,yDAAiC,CAAC,YAAY,EAAE;QACtF,SAAS;QACT,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,OAAO,CAAC,EACtB,SAAS,EACT,OAAO,GAIR;IACC,sEAAsE;IACtE,qBAAa,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minded-ai/mindedjs",
3
- "version": "1.0.144",
3
+ "version": "1.0.145-beta-1",
4
4
  "description": "MindedJS is a TypeScript library for building agents.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/agent.ts CHANGED
@@ -185,6 +185,20 @@ export class Agent {
185
185
  return result;
186
186
  });
187
187
 
188
+ mindedConnection.on(mindedConnectionSocketMessageType.TIMER_TRIGGER, async (timerTriggerMessage) => {
189
+ // Get handler for the specific timer name
190
+ const handlerEntry = timerHandlers.get(timerTriggerMessage.timerName);
191
+
192
+ // Call the handler if it exists
193
+ if (handlerEntry) {
194
+ await handlerEntry.handler({
195
+ sessionId: timerTriggerMessage.sessionId,
196
+ payload: timerTriggerMessage.eventArgs,
197
+ state: await this.getState(timerTriggerMessage.sessionId),
198
+ });
199
+ }
200
+ });
201
+
188
202
  mindedConnection.on(mindedConnectionSocketMessageType.RESTORE_CHECKPOINT, async (restoreCheckpointMessage) => {
189
203
  await this.restoreCheckpoint(restoreCheckpointMessage.sessionId, restoreCheckpointMessage.checkpointId);
190
204
  return { success: true };
@@ -852,6 +866,7 @@ export class Agent {
852
866
  await handlerEntry.handler({
853
867
  sessionId: params.sessionId,
854
868
  payload: params.eventArgs,
869
+ state: await this.getState(params.sessionId),
855
870
  });
856
871
  }
857
872
  }
@@ -1,11 +1,12 @@
1
1
  import * as mindedConnection from '../platform/mindedConnection';
2
2
  import { mindedConnectionSocketMessageType, TimerResetResponse, TimerCancelResponse } from '../platform/mindedConnectionTypes';
3
+ import { State } from '../types/LangGraph.types';
3
4
 
4
5
  // Store timer handlers by timer name (one handler per timer name)
5
6
  export const timerHandlers = new Map<
6
7
  string,
7
8
  {
8
- handler: (params: { sessionId: string; payload: Record<string, any> }) => void | Promise<void>;
9
+ handler: (params: { sessionId: string; payload: Record<string, any>; state: State<any> }) => void | Promise<void>;
9
10
  }
10
11
  >();
11
12
 
@@ -117,21 +118,8 @@ export function onTimer({
117
118
  handler,
118
119
  }: {
119
120
  timerName: string;
120
- handler: (params: { sessionId: string; payload: Record<string, any> }) => void | Promise<void>;
121
+ handler: (params: { sessionId: string; payload: Record<string, any>; state: State<any> }) => void | Promise<void>;
121
122
  }): void {
122
123
  // Set the handler for this timer name (replaces any existing handler)
123
124
  timerHandlers.set(timerName, { handler });
124
125
  }
125
-
126
- mindedConnection.on(mindedConnectionSocketMessageType.TIMER_TRIGGER, async (timerTriggerMessage) => {
127
- // Get handler for the specific timer name
128
- const handlerEntry = timerHandlers.get(timerTriggerMessage.timerName);
129
-
130
- // Call the handler if it exists
131
- if (handlerEntry) {
132
- await handlerEntry.handler({
133
- sessionId: timerTriggerMessage.sessionId,
134
- payload: timerTriggerMessage.eventArgs,
135
- });
136
- }
137
- });