@minded-ai/mindedjs 2.0.13 → 2.0.14

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.
Files changed (96) hide show
  1. package/dist/agent.js +17 -7
  2. package/dist/agent.js.map +1 -1
  3. package/dist/browserTask/executeBrowserTask.d.ts +2 -2
  4. package/dist/browserTask/executeBrowserTask.d.ts.map +1 -1
  5. package/dist/browserTask/executeBrowserTask.js +16 -5
  6. package/dist/browserTask/executeBrowserTask.js.map +1 -1
  7. package/dist/browserTask/executeBrowserTask.py +0 -1
  8. package/dist/browserTask/localBrowserTask.js +17 -7
  9. package/dist/browserTask/localBrowserTask.js.map +1 -1
  10. package/dist/checkpointer/checkpointSaverFactory.js +17 -7
  11. package/dist/checkpointer/checkpointSaverFactory.js.map +1 -1
  12. package/dist/cli/index.js +45 -14
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/cli/lambdaHandlerTemplate.d.ts.map +1 -1
  15. package/dist/cli/localOperatorSetup.d.ts +6 -0
  16. package/dist/cli/localOperatorSetup.d.ts.map +1 -0
  17. package/dist/cli/localOperatorSetup.js +310 -0
  18. package/dist/cli/localOperatorSetup.js.map +1 -0
  19. package/dist/edges/createDirectEdge.d.ts.map +1 -1
  20. package/dist/edges/createLogicalRouter.d.ts.map +1 -1
  21. package/dist/edges/createLogicalRouter.js +17 -7
  22. package/dist/edges/createLogicalRouter.js.map +1 -1
  23. package/dist/edges/createPromptRouter.d.ts.map +1 -1
  24. package/dist/edges/edgeFactory.d.ts.map +1 -1
  25. package/dist/index.js +17 -7
  26. package/dist/index.js.map +1 -1
  27. package/dist/interfaces/zendesk.js +17 -7
  28. package/dist/interfaces/zendesk.js.map +1 -1
  29. package/dist/internalTools/appActionRunnerTool.d.ts.map +1 -1
  30. package/dist/internalTools/appActionRunnerTool.js +17 -7
  31. package/dist/internalTools/appActionRunnerTool.js.map +1 -1
  32. package/dist/internalTools/documentExtraction/documentExtraction.js +17 -7
  33. package/dist/internalTools/documentExtraction/documentExtraction.js.map +1 -1
  34. package/dist/internalTools/libraryActionRunnerTool.d.ts.map +1 -1
  35. package/dist/internalTools/timer.js +17 -7
  36. package/dist/internalTools/timer.js.map +1 -1
  37. package/dist/internalTools/voice/escalateVoiceCall.d.ts.map +1 -1
  38. package/dist/internalTools/voice/escalateVoiceCall.js +17 -7
  39. package/dist/internalTools/voice/escalateVoiceCall.js.map +1 -1
  40. package/dist/internalTools/voice/retell.js +17 -7
  41. package/dist/internalTools/voice/retell.js.map +1 -1
  42. package/dist/internalTools/voice/sendPlaceholderMessage.js +17 -7
  43. package/dist/internalTools/voice/sendPlaceholderMessage.js.map +1 -1
  44. package/dist/interrupts/MindedInterruptSessionManager.js +17 -7
  45. package/dist/interrupts/MindedInterruptSessionManager.js.map +1 -1
  46. package/dist/interrupts/interruptSessionManagerFactory.js +17 -7
  47. package/dist/interrupts/interruptSessionManagerFactory.js.map +1 -1
  48. package/dist/llm/createLlmInstance.d.ts.map +1 -1
  49. package/dist/nodes/addAppToolNode.d.ts.map +1 -1
  50. package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -1
  51. package/dist/nodes/addBrowserTaskNode.js.map +1 -1
  52. package/dist/nodes/addBrowserTaskRunNode.d.ts.map +1 -1
  53. package/dist/nodes/addHumanInTheLoopNode.d.ts.map +1 -1
  54. package/dist/nodes/addJumpToNode.d.ts.map +1 -1
  55. package/dist/nodes/addJunctionNode.d.ts.map +1 -1
  56. package/dist/nodes/addPromptNode.d.ts.map +1 -1
  57. package/dist/nodes/addRpaNode.d.ts.map +1 -1
  58. package/dist/nodes/addToolNode.d.ts.map +1 -1
  59. package/dist/nodes/addToolRunNode.d.ts.map +1 -1
  60. package/dist/nodes/addTriggerNode.d.ts.map +1 -1
  61. package/dist/nodes/compilePrompt.js +17 -7
  62. package/dist/nodes/compilePrompt.js.map +1 -1
  63. package/dist/nodes/nodeFactory.d.ts.map +1 -1
  64. package/dist/platform/mindedCheckpointSaver.js +17 -7
  65. package/dist/platform/mindedCheckpointSaver.js.map +1 -1
  66. package/dist/platform/mindedConnection.d.ts.map +1 -1
  67. package/dist/platform/mindedConnection.js +17 -7
  68. package/dist/platform/mindedConnection.js.map +1 -1
  69. package/dist/platform/piiGateway/gateway.js +17 -7
  70. package/dist/platform/piiGateway/gateway.js.map +1 -1
  71. package/dist/platform/utils/parseAttachments.d.ts.map +1 -1
  72. package/dist/platform/utils/tools.d.ts.map +1 -1
  73. package/dist/playbooks/playbooks.js +17 -7
  74. package/dist/playbooks/playbooks.js.map +1 -1
  75. package/dist/toolsLibrary/classifier.d.ts.map +1 -1
  76. package/dist/toolsLibrary/extraction.d.ts.map +1 -1
  77. package/dist/toolsLibrary/index.js +17 -7
  78. package/dist/toolsLibrary/index.js.map +1 -1
  79. package/dist/toolsLibrary/parseDocument.d.ts +3 -3
  80. package/dist/types/LLM.types.js.map +1 -1
  81. package/dist/types/LangGraph.types.d.ts.map +1 -1
  82. package/dist/utils/agentUtils.js +17 -7
  83. package/dist/utils/agentUtils.js.map +1 -1
  84. package/dist/utils/history.d.ts.map +1 -1
  85. package/dist/utils/logger.d.ts +2 -1
  86. package/dist/utils/logger.d.ts.map +1 -1
  87. package/dist/utils/wait.d.ts.map +1 -1
  88. package/dist/voice/voiceSession.js +17 -7
  89. package/dist/voice/voiceSession.js.map +1 -1
  90. package/package.json +2 -2
  91. package/src/browserTask/executeBrowserTask.py +0 -1
  92. package/src/browserTask/executeBrowserTask.ts +34 -20
  93. package/src/cli/index.ts +25 -7
  94. package/src/cli/localOperatorSetup.ts +308 -0
  95. package/src/nodes/addBrowserTaskNode.ts +2 -2
  96. package/src/types/LLM.types.ts +2 -2
@@ -0,0 +1,308 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { execSync, spawn } from 'child_process';
4
+ import * as readline from 'readline';
5
+
6
+ const VENV_DIR = '.venv';
7
+ const SETUP_MARKER_FILE = '.minded-local-operator-setup';
8
+
9
+ interface SetupPackage {
10
+ name: string;
11
+ description: string;
12
+ command: string;
13
+ checkCommand?: string;
14
+ }
15
+
16
+ const REQUIRED_PACKAGES: SetupPackage[] = [
17
+ {
18
+ name: 'uv',
19
+ description: 'Python package manager for fast dependency installation',
20
+ command: 'curl -LsSf https://astral.sh/uv/install.sh | sh',
21
+ checkCommand: 'uv --version',
22
+ },
23
+ {
24
+ name: 'Python 3.12',
25
+ description: 'Python runtime for browser automation',
26
+ command: 'python3.12 --version',
27
+ checkCommand: 'python3.12 --version',
28
+ },
29
+ {
30
+ name: 'browser-use',
31
+ description: 'Browser automation library',
32
+ command: 'uv pip install browser-use',
33
+ },
34
+ {
35
+ name: 'Playwright Chromium',
36
+ description: 'Chromium browser for automation',
37
+ command: 'uvx playwright install chromium --with-deps',
38
+ },
39
+ ];
40
+
41
+ export function isLocalOperatorSetup(): boolean {
42
+ const setupMarkerPath = path.join(process.cwd(), SETUP_MARKER_FILE);
43
+ const venvPath = path.join(process.cwd(), VENV_DIR);
44
+
45
+ // Check if both the marker file and venv directory exist
46
+ return fs.existsSync(setupMarkerPath) && fs.existsSync(venvPath);
47
+ }
48
+
49
+ function checkCommand(command: string): boolean {
50
+ try {
51
+ execSync(command, { stdio: 'ignore' });
52
+ return true;
53
+ } catch {
54
+ return false;
55
+ }
56
+ }
57
+
58
+ function promptUser(question: string): Promise<boolean> {
59
+ // Check if we're in an interactive terminal
60
+ if (!process.stdin.isTTY) {
61
+ console.warn('Non-interactive terminal detected, skipping prompt and cancelling installation');
62
+ return Promise.resolve(false);
63
+ }
64
+
65
+ return new Promise((resolve) => {
66
+ const rl = readline.createInterface({
67
+ input: process.stdin,
68
+ output: process.stdout,
69
+ });
70
+
71
+ // Set a timeout in case the prompt hangs
72
+ const timeout = setTimeout(() => {
73
+ console.warn('Prompt timeout (30s), cancelling installation');
74
+ rl.close();
75
+ resolve(false);
76
+ }, 30000); // 30 second timeout
77
+
78
+ console.log('Displaying prompt to user');
79
+
80
+ rl.question(question, (answer) => {
81
+ clearTimeout(timeout);
82
+ console.log(`User answered: "${answer}"`);
83
+
84
+ rl.close();
85
+
86
+ const confirmed = answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes';
87
+ console.log(`Prompt result: ${confirmed}`);
88
+
89
+ resolve(confirmed);
90
+ });
91
+
92
+ // Handle potential readline errors
93
+ rl.on('error', (error) => {
94
+ console.error('Readline error, cancelling installation:', error.message);
95
+ clearTimeout(timeout);
96
+ rl.close();
97
+ resolve(false);
98
+ });
99
+ });
100
+ }
101
+
102
+ async function runCommand(command: string, description: string): Promise<void> {
103
+ return new Promise((resolve, reject) => {
104
+ console.log(`Installing ${description}...`);
105
+
106
+ const isComplexCommand = command.includes('|') || command.includes('&&');
107
+
108
+ if (isComplexCommand) {
109
+ // For complex commands with pipes or &&, use shell
110
+ const child = spawn('sh', ['-c', command], {
111
+ stdio: 'inherit',
112
+ shell: true,
113
+ });
114
+
115
+ child.on('error', (error) => {
116
+ console.error(`Failed to install ${description}:`, error.message);
117
+ reject(error);
118
+ });
119
+
120
+ child.on('close', (code) => {
121
+ if (code === 0) {
122
+ console.log(`✓ ${description} installed successfully`);
123
+ resolve();
124
+ } else {
125
+ reject(new Error(`Command exited with code ${code}`));
126
+ }
127
+ });
128
+ } else {
129
+ // For simple commands, use execSync
130
+ try {
131
+ execSync(command, { stdio: 'inherit' });
132
+ console.log(`✓ ${description} installed successfully`);
133
+ resolve();
134
+ } catch (error) {
135
+ console.error(`Failed to install ${description}:`, error);
136
+ reject(error);
137
+ }
138
+ }
139
+ });
140
+ }
141
+
142
+ export async function setupLocalOperator(skipPrompt: boolean = false): Promise<void> {
143
+ console.log('\n🤖 Minded Local Operator Setup\n');
144
+
145
+ // Check if already setup
146
+ if (isLocalOperatorSetup()) {
147
+ console.log('✓ Local operator is already set up');
148
+ return;
149
+ }
150
+
151
+ // Display what will be installed
152
+ console.log('The following packages will be installed for local browser automation:\n');
153
+ REQUIRED_PACKAGES.forEach((pkg, index) => {
154
+ console.log(` ${index + 1}. ${pkg.name} - ${pkg.description}`);
155
+ });
156
+ console.log('');
157
+
158
+ // Ask for confirmation unless skipped
159
+ if (!skipPrompt) {
160
+ console.log('Waiting for user confirmation...');
161
+ const confirmed = await promptUser('Do you want to proceed with the installation? (y/n): ');
162
+ if (!confirmed) {
163
+ console.log('Installation cancelled by user');
164
+ process.exit(0);
165
+ }
166
+ console.log('User confirmed, proceeding with installation');
167
+ } else {
168
+ console.log('Skipping confirmation prompt, proceeding with installation...');
169
+ }
170
+
171
+ console.log('\n📦 Starting installation...\n');
172
+
173
+ try {
174
+ // Check and install uv if needed
175
+ if (!checkCommand('uv --version')) {
176
+ console.log('Installing uv package manager...');
177
+ await runCommand('curl -LsSf https://astral.sh/uv/install.sh | sh', 'uv');
178
+
179
+ // Add uv to PATH for current session
180
+ const uvPath = path.join(process.env.HOME || '', '.cargo', 'bin');
181
+ process.env.PATH = `${uvPath}:${process.env.PATH}`;
182
+ } else {
183
+ console.log('✓ uv is already installed');
184
+ }
185
+
186
+ // Check Python 3.12
187
+ if (!checkCommand('python3.12 --version')) {
188
+ console.error('Python 3.12 is required but not found');
189
+ console.log('Please install Python 3.12 manually:');
190
+ console.log(' macOS: brew install python@3.12');
191
+ console.log(' Ubuntu/Debian: sudo apt install python3.12');
192
+ console.log(' Or visit: https://www.python.org/downloads/');
193
+ process.exit(1);
194
+ } else {
195
+ console.log('✓ Python 3.12 is available');
196
+ }
197
+
198
+ // Create virtual environment
199
+ console.log('Creating Python virtual environment...');
200
+ execSync(`uv venv --python 3.12 ${VENV_DIR}`, { stdio: 'inherit' });
201
+ console.log('✓ Virtual environment created');
202
+
203
+ // Install browser-use in the venv
204
+ console.log('Installing browser-use package...');
205
+ execSync(`uv pip install --python ${path.join(process.cwd(), VENV_DIR, 'bin', 'python')} browser-use`, {
206
+ stdio: 'inherit',
207
+ });
208
+ console.log('✓ browser-use installed');
209
+
210
+ // Install Playwright Chromium
211
+ console.log('Installing Playwright Chromium browser...');
212
+ execSync(`uvx playwright install chromium --with-deps`, { stdio: 'inherit' });
213
+ console.log('✓ Playwright Chromium installed');
214
+
215
+ // Create setup marker file
216
+ const setupMarkerPath = path.join(process.cwd(), SETUP_MARKER_FILE);
217
+ const setupInfo = {
218
+ version: '1.0.0',
219
+ setupDate: new Date().toISOString(),
220
+ packages: REQUIRED_PACKAGES.map((p) => p.name),
221
+ venvPath: VENV_DIR,
222
+ };
223
+ fs.writeFileSync(setupMarkerPath, JSON.stringify(setupInfo, null, 2));
224
+
225
+ // Add to .gitignore if not already there
226
+ const gitignorePath = path.join(process.cwd(), '.gitignore');
227
+ if (fs.existsSync(gitignorePath)) {
228
+ const gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
229
+ const itemsToIgnore = [VENV_DIR, SETUP_MARKER_FILE, 'downloads/'];
230
+ const linesToAdd: string[] = [];
231
+
232
+ itemsToIgnore.forEach((item) => {
233
+ if (!gitignoreContent.includes(item)) {
234
+ linesToAdd.push(item);
235
+ }
236
+ });
237
+
238
+ if (linesToAdd.length > 0) {
239
+ const newContent = gitignoreContent.trimEnd() + '\n\n# Minded Local Operator\n' + linesToAdd.join('\n') + '\n';
240
+ fs.writeFileSync(gitignorePath, newContent);
241
+ console.log('✓ Updated .gitignore');
242
+ }
243
+ }
244
+
245
+ // Add BROWSER_TASK_MODE to .env file
246
+ const envPath = path.join(process.cwd(), '.env');
247
+ const browserTaskModeVar = 'BROWSER_TASK_MODE=localRun';
248
+
249
+ if (fs.existsSync(envPath)) {
250
+ const envContent = fs.readFileSync(envPath, 'utf8');
251
+
252
+ // Check if BROWSER_TASK_MODE is already set
253
+ if (!envContent.includes('BROWSER_TASK_MODE')) {
254
+ // Append to existing .env file
255
+ const newEnvContent = envContent.trimEnd() + '\n' + browserTaskModeVar + '\n';
256
+ fs.writeFileSync(envPath, newEnvContent);
257
+ console.log('✓ Added BROWSER_TASK_MODE=localRun to .env');
258
+ } else if (!envContent.includes('BROWSER_TASK_MODE=localRun')) {
259
+ // BROWSER_TASK_MODE exists but with different value, update it
260
+ const updatedEnvContent = envContent.replace(/BROWSER_TASK_MODE=.*$/m, browserTaskModeVar);
261
+ fs.writeFileSync(envPath, updatedEnvContent);
262
+ console.log('✓ Updated BROWSER_TASK_MODE to localRun in .env');
263
+ } else {
264
+ console.log('✓ BROWSER_TASK_MODE=localRun already configured in .env');
265
+ }
266
+ } else {
267
+ // Create new .env file
268
+ fs.writeFileSync(envPath, browserTaskModeVar + '\n');
269
+ console.log('✓ Created .env file with BROWSER_TASK_MODE=localRun');
270
+ }
271
+
272
+ console.log('\n' + '='.repeat(50));
273
+ console.log('✅ Local operator setup completed successfully!');
274
+ console.log('='.repeat(50) + '\n');
275
+
276
+ console.log('You can now use browser automation features locally.');
277
+ console.log('The virtual environment will be activated automatically when needed.');
278
+ } catch (error) {
279
+ console.error('Setup failed:', error);
280
+
281
+ // Clean up partial installation
282
+ try {
283
+ if (fs.existsSync(path.join(process.cwd(), VENV_DIR))) {
284
+ fs.rmSync(path.join(process.cwd(), VENV_DIR), { recursive: true });
285
+ }
286
+ } catch {
287
+ // Ignore cleanup errors
288
+ }
289
+
290
+ process.exit(1);
291
+ }
292
+ }
293
+
294
+ export function validateLocalOperatorSetup(): void {
295
+ if (!isLocalOperatorSetup()) {
296
+ console.error('Local operator is not set up');
297
+ console.log('Please run: npx minded setup-local-operator');
298
+ throw new Error('Local operator not configured');
299
+ }
300
+ }
301
+
302
+ export function getVenvPath(): string {
303
+ return path.join(process.cwd(), VENV_DIR);
304
+ }
305
+
306
+ export function getVenvBinPath(): string {
307
+ return path.join(getVenvPath(), 'bin');
308
+ }
@@ -31,10 +31,10 @@ export const addBrowserTaskNode = async ({ graph, node, agent, llm }: AddBrowser
31
31
  const zodSchema = createZodSchemaFromFields(node.inputSchema);
32
32
 
33
33
  // Create langchain tool
34
- const tool = langchainTool(() => { }, {
34
+ const tool = langchainTool(() => {}, {
35
35
  name: 'browser-task',
36
36
  description: node.prompt,
37
- schema: zodSchema,
37
+ schema: zodSchema as any,
38
38
  });
39
39
 
40
40
  const combinedPlaybooks = combinePlaybooks(agent.playbooks);
@@ -9,7 +9,7 @@ export type LLMConfig = {
9
9
  export type LLMProvider = 'ChatOpenAI' | 'AzureChatOpenAI' | 'MindedChatOpenAI';
10
10
 
11
11
  export const LLMProviders: Record<LLMProvider, any> = {
12
- ChatOpenAI: ChatOpenAI,
13
- AzureChatOpenAI: AzureChatOpenAI,
12
+ ChatOpenAI,
13
+ AzureChatOpenAI,
14
14
  MindedChatOpenAI,
15
15
  };