@minded-ai/mindedjs 2.0.25 → 2.0.26-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/cdp.d.ts +23 -0
- package/dist/browserTask/cdp.d.ts.map +1 -0
- package/dist/browserTask/cdp.js +162 -0
- package/dist/browserTask/cdp.js.map +1 -0
- package/dist/browserTask/cookieStore.py +108 -0
- package/dist/browserTask/executeBrowserTask.d.ts.map +1 -1
- package/dist/browserTask/executeBrowserTask.js +5 -5
- package/dist/browserTask/executeBrowserTask.js.map +1 -1
- package/dist/browserTask/executeBrowserTask.py +10 -15
- package/dist/browserTask/localBrowserTask.d.ts.map +1 -1
- package/dist/browserTask/localBrowserTask.js +45 -8
- package/dist/browserTask/localBrowserTask.js.map +1 -1
- package/dist/browserTask/types.d.ts +4 -6
- package/dist/browserTask/types.d.ts.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/guidelines/guidelinesManager.d.ts +37 -0
- package/dist/guidelines/guidelinesManager.d.ts.map +1 -0
- package/dist/guidelines/guidelinesManager.js +172 -0
- package/dist/guidelines/guidelinesManager.js.map +1 -0
- package/dist/internalTools/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/addBrowserTaskRunNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskRunNode.js +6 -35
- package/dist/nodes/addBrowserTaskRunNode.js.map +1 -1
- package/dist/platform/mindedChatOpenAI.d.ts +5 -0
- package/dist/platform/mindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/mindedChatOpenAI.js +23 -0
- package/dist/platform/mindedChatOpenAI.js.map +1 -0
- package/dist/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/dist/utils/extractToolMemoryResponse.d.ts +4 -0
- package/dist/utils/extractToolMemoryResponse.d.ts.map +1 -0
- package/dist/utils/extractToolMemoryResponse.js +16 -0
- package/dist/utils/extractToolMemoryResponse.js.map +1 -0
- package/package.json +2 -2
- package/src/browserTask/executeBrowserTask.py +10 -15
- package/src/browserTask/executeBrowserTask.ts +11 -9
- package/src/browserTask/localBrowserTask.ts +51 -7
- package/src/browserTask/types.ts +4 -6
- package/src/nodes/addBrowserTaskRunNode.ts +7 -41
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const extractToolMemoryResponse = (toolMessage) => {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = JSON.parse(toolMessage.content);
|
|
6
|
+
if (typeof parsed === 'object' && parsed !== null && 'memory' in parsed) {
|
|
7
|
+
return parsed.memory;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.error('Error parsing tool memory response', error);
|
|
12
|
+
}
|
|
13
|
+
return {};
|
|
14
|
+
};
|
|
15
|
+
exports.default = extractToolMemoryResponse;
|
|
16
|
+
//# sourceMappingURL=extractToolMemoryResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractToolMemoryResponse.js","sourceRoot":"","sources":["../../src/utils/extractToolMemoryResponse.ts"],"names":[],"mappings":";;AAEA,MAAM,yBAAyB,GAAG,CAAS,WAAwB,EAAmB,EAAE;IACtF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAiB,CAAC,CAAC;QACzD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;YACxE,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,kBAAe,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minded-ai/mindedjs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.26-beta.2",
|
|
4
4
|
"description": "MindedJS is a TypeScript library for building agents.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -72,4 +72,4 @@
|
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"playwright": "^1.55.0"
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|
|
@@ -55,11 +55,11 @@ class ScreenshotCapture:
|
|
|
55
55
|
)
|
|
56
56
|
|
|
57
57
|
# S3 configuration with defaults
|
|
58
|
-
self.s3_bucket = self.config.get('s3_bucket'
|
|
59
|
-
self.s3_prefix = self.config.get('s3_prefix'
|
|
58
|
+
self.s3_bucket = self.config.get('s3_bucket')
|
|
59
|
+
self.s3_prefix = self.config.get('s3_prefix')
|
|
60
60
|
|
|
61
61
|
# AWS region configuration
|
|
62
|
-
self.aws_region = self.config.get('aws_region'
|
|
62
|
+
self.aws_region = self.config.get('aws_region')
|
|
63
63
|
|
|
64
64
|
# Ensure prefix ends with slash
|
|
65
65
|
if not self.s3_prefix.endswith('/'):
|
|
@@ -167,12 +167,12 @@ class LogsCapture:
|
|
|
167
167
|
"or run: npx minded setup-local-operator"
|
|
168
168
|
)
|
|
169
169
|
|
|
170
|
-
# S3 configuration
|
|
171
|
-
self.s3_bucket = self.config.get('s3_bucket'
|
|
172
|
-
self.s3_prefix = self.config.get('s3_prefix'
|
|
170
|
+
# S3 configuration
|
|
171
|
+
self.s3_bucket = self.config.get('s3_bucket')
|
|
172
|
+
self.s3_prefix = self.config.get('s3_prefix')
|
|
173
173
|
|
|
174
174
|
# AWS region configuration
|
|
175
|
-
self.aws_region = self.config.get('aws_region'
|
|
175
|
+
self.aws_region = self.config.get('aws_region')
|
|
176
176
|
|
|
177
177
|
# Ensure prefix ends with slash
|
|
178
178
|
if not self.s3_prefix.endswith('/'):
|
|
@@ -301,11 +301,8 @@ async def main(session_id: str, cdp_url: str, task: str, output_schema_json: Opt
|
|
|
301
301
|
screenshot_capture = None
|
|
302
302
|
logs_capture = None
|
|
303
303
|
on_step_end_hook = None
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
enable_screenshot_capture_to_s3 = screenshot_config and screenshot_config.get('enableScreenshotCaptureToS3', False)
|
|
307
|
-
|
|
308
|
-
if enable_screenshot_capture_to_s3:
|
|
304
|
+
|
|
305
|
+
if screenshot_config:
|
|
309
306
|
logger.info("-" * 50)
|
|
310
307
|
logger.info("🎯 Initializing screenshot capture for browser task")
|
|
311
308
|
logger.info(f" Session: {session_id}")
|
|
@@ -318,9 +315,7 @@ async def main(session_id: str, cdp_url: str, task: str, output_schema_json: Opt
|
|
|
318
315
|
logger.info("📷 Screenshot capture is DISABLED for this browser task")
|
|
319
316
|
|
|
320
317
|
# Initialize logs capture if enabled (independent from screenshots)
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if enable_logs_capture_to_s3:
|
|
318
|
+
if screenshot_config:
|
|
324
319
|
logger.info("-" * 50)
|
|
325
320
|
logger.info("🎯 Initializing logs capture for browser task")
|
|
326
321
|
logger.info(f" Session: {session_id}")
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { kill, getOrStartLocalCDP, isLocalBrowserRunning } from './localBrowserTask';
|
|
16
16
|
import { BrowserTaskMode, InvokeBrowserTaskOptions } from './types';
|
|
17
17
|
import { isLocalOperatorSetup, validateLocalOperatorSetup } from '../cli/localOperatorSetup';
|
|
18
|
+
import { getConfig } from '../platform/config';
|
|
18
19
|
import CDP from 'chrome-remote-interface';
|
|
19
20
|
import { CookieStore } from './CookieStore';
|
|
20
21
|
|
|
@@ -206,9 +207,14 @@ export const destroyBrowserSession = async ({
|
|
|
206
207
|
export const invokeBrowserTask = async (options: InvokeBrowserTaskOptions): Promise<InvokeBrowserTaskResponse> => {
|
|
207
208
|
try {
|
|
208
209
|
const { sessionId, cdpUrl, task, keepAlive, hooks, browserTaskMode, toolSchemas, outputSchema, screenshotConfig, toolCallId } = options;
|
|
210
|
+
const { isDeployed } = getConfig();
|
|
209
211
|
|
|
210
212
|
if (browserTaskMode === BrowserTaskMode.LOCAL) {
|
|
211
|
-
|
|
213
|
+
|
|
214
|
+
if (!isDeployed) {
|
|
215
|
+
validateLocalOperatorSetup();
|
|
216
|
+
}
|
|
217
|
+
|
|
212
218
|
const pythonScriptPath = path.resolve(__dirname, 'executeBrowserTask.py');
|
|
213
219
|
|
|
214
220
|
// Calculate folder path for downloads
|
|
@@ -218,18 +224,16 @@ export const invokeBrowserTask = async (options: InvokeBrowserTaskOptions): Prom
|
|
|
218
224
|
logger.info({
|
|
219
225
|
message: 'Spawning Python process',
|
|
220
226
|
args,
|
|
221
|
-
enableScreenshotCaptureToS3: screenshotConfig?.enableScreenshotCaptureToS3 || false,
|
|
222
|
-
enableLogsCaptureToS3: screenshotConfig?.enableLogsCaptureToS3 || false,
|
|
223
227
|
});
|
|
224
228
|
|
|
225
229
|
const child = spawn('uv', args, {
|
|
226
230
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
227
231
|
env: isLocalOperatorSetup()
|
|
228
232
|
? {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
...process.env,
|
|
234
|
+
VIRTUAL_ENV: path.join(process.cwd(), '.venv'),
|
|
235
|
+
PATH: `${path.join(process.cwd(), '.venv', 'bin')}:${process.env.PATH}`,
|
|
236
|
+
}
|
|
233
237
|
: process.env,
|
|
234
238
|
});
|
|
235
239
|
|
|
@@ -341,8 +345,6 @@ export const invokeBrowserTask = async (options: InvokeBrowserTaskOptions): Prom
|
|
|
341
345
|
hooksCount: hooks?.length || 0,
|
|
342
346
|
onPrem: browserTaskMode === BrowserTaskMode.ON_PREM,
|
|
343
347
|
outputSchemaFields: outputSchema?.length || 0,
|
|
344
|
-
enableScreenshotCaptureToS3: screenshotConfig?.enableScreenshotCaptureToS3 || false,
|
|
345
|
-
enableLogsCaptureToS3: screenshotConfig?.enableLogsCaptureToS3 || false,
|
|
346
348
|
});
|
|
347
349
|
|
|
348
350
|
const response = await mindedConnection.awaitEmit<InvokeBrowserTaskRequest, InvokeBrowserTaskResponse>(
|
|
@@ -6,6 +6,7 @@ import { chromium } from 'playwright';
|
|
|
6
6
|
import { logger } from '../utils/logger';
|
|
7
7
|
import { wait } from '../utils/wait';
|
|
8
8
|
import * as net from 'net';
|
|
9
|
+
import { getConfig } from '../platform/config';
|
|
9
10
|
|
|
10
11
|
interface BrowserInstance {
|
|
11
12
|
id: string;
|
|
@@ -86,6 +87,7 @@ export type StartChromiumOptions = {
|
|
|
86
87
|
* Works with Chrome/Chromium/Chrome for Testing.
|
|
87
88
|
*/
|
|
88
89
|
export async function getOrStartLocalCDP(opts: StartChromiumOptions): Promise<{ cdpUrl: string; instanceId: string }> {
|
|
90
|
+
const { isDeployed } = getConfig();
|
|
89
91
|
// If instanceId is provided, try to reuse existing instance
|
|
90
92
|
if (opts.instanceId && browserInstances.has(opts.instanceId)) {
|
|
91
93
|
const instance = browserInstances.get(opts.instanceId)!;
|
|
@@ -100,7 +102,9 @@ export async function getOrStartLocalCDP(opts: StartChromiumOptions): Promise<{
|
|
|
100
102
|
|
|
101
103
|
const { env } = opts;
|
|
102
104
|
|
|
103
|
-
const executablePath = chromium.executablePath();
|
|
105
|
+
const executablePath = process.env.CHROMIUM_PATH || chromium.executablePath();
|
|
106
|
+
|
|
107
|
+
logger.info({ message: 'Chromium executable path', executablePath });
|
|
104
108
|
|
|
105
109
|
// Find an available port
|
|
106
110
|
const port = opts.preferredPort
|
|
@@ -119,7 +123,11 @@ export async function getOrStartLocalCDP(opts: StartChromiumOptions): Promise<{
|
|
|
119
123
|
const args = [
|
|
120
124
|
'--new-window',
|
|
121
125
|
`--user-data-dir=${userDataDir}`,
|
|
122
|
-
...(
|
|
126
|
+
...(isDeployed ? [
|
|
127
|
+
'--headless',
|
|
128
|
+
'--no-sandbox', // Required for running in Docker/containerized environments
|
|
129
|
+
'--disable-setuid-sandbox', // Additional sandbox bypass for containers
|
|
130
|
+
] : []),
|
|
123
131
|
'--disable-component-extensions-with-background-pages',
|
|
124
132
|
'--disable-background-networking',
|
|
125
133
|
'--disable-back-forward-cache',
|
|
@@ -192,13 +200,49 @@ export async function getOrStartLocalCDP(opts: StartChromiumOptions): Promise<{
|
|
|
192
200
|
env: { ...process.env, ...env },
|
|
193
201
|
});
|
|
194
202
|
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
// Capture stderr output to help debug crashes
|
|
204
|
+
let stderrBuffer = '';
|
|
205
|
+
proc.stderr?.on('data', (data) => {
|
|
206
|
+
const output = data.toString();
|
|
207
|
+
stderrBuffer += output;
|
|
208
|
+
|
|
209
|
+
// Skip common non-critical errors in containerized environments
|
|
210
|
+
const ignoredPatterns = [
|
|
211
|
+
'Failed to connect to the bus',
|
|
212
|
+
'Failed to call method: org.freedesktop.DBus',
|
|
213
|
+
'DEPRECATED_ENDPOINT',
|
|
214
|
+
'Authentication Failed: wrong_secret', // Google GCM
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
const shouldIgnore = ignoredPatterns.some(pattern => output.includes(pattern));
|
|
218
|
+
if (shouldIgnore) {
|
|
219
|
+
return; // Silently ignore these expected container warnings
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Log important error messages immediately
|
|
223
|
+
if (output.includes('ERROR') || output.includes('FATAL') || output.includes('Segmentation fault')) {
|
|
224
|
+
logger.error({ message: 'Chromium stderr', output: output.trim() });
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
proc.on("error", (error) => {
|
|
229
|
+
logger.error({ message: 'Chromium spawn error', error });
|
|
197
230
|
});
|
|
198
231
|
|
|
199
|
-
proc.on(
|
|
200
|
-
|
|
201
|
-
|
|
232
|
+
proc.on("exit", (code, signal) => {
|
|
233
|
+
const exitInfo: any = {
|
|
234
|
+
message: 'Chromium exited',
|
|
235
|
+
code,
|
|
236
|
+
signal,
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// Include recent stderr output in exit log
|
|
240
|
+
if (stderrBuffer) {
|
|
241
|
+
const recentStderr = stderrBuffer.slice(-500); // Last 500 chars
|
|
242
|
+
exitInfo.recentStderr = recentStderr;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
logger.error(exitInfo);
|
|
202
246
|
browserInstances.delete(instanceId);
|
|
203
247
|
});
|
|
204
248
|
|
package/src/browserTask/types.ts
CHANGED
|
@@ -26,11 +26,9 @@ export type ToolSchema = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export type ScreenshotConfig = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
s3_prefix?: string;
|
|
33
|
-
aws_region?: string;
|
|
29
|
+
s3_bucket: string;
|
|
30
|
+
s3_prefix: string;
|
|
31
|
+
aws_region: string;
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
export interface InvokeBrowserTaskOptions {
|
|
@@ -42,6 +40,6 @@ export interface InvokeBrowserTaskOptions {
|
|
|
42
40
|
browserTaskMode: BrowserTaskMode;
|
|
43
41
|
toolSchemas?: ToolSchema[];
|
|
44
42
|
outputSchema?: OutputSchemaField[];
|
|
45
|
-
screenshotConfig
|
|
43
|
+
screenshotConfig: ScreenshotConfig | null;
|
|
46
44
|
toolCallId: string;
|
|
47
45
|
}
|
|
@@ -55,47 +55,13 @@ export const addBrowserTaskRunNode = async ({ graph, browserTaskNode, attachedTo
|
|
|
55
55
|
// We compile the env variables to avoid having to pass them to the platform in the tool input
|
|
56
56
|
const promptCompiledWithEnv = compilePrompt(prompt, { env: process.env });
|
|
57
57
|
|
|
58
|
-
const { browserTaskMode } = getConfig();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// If neither is enabled, return undefined
|
|
67
|
-
if (!enableScreenshotCaptureToS3 && !enableLogsCaptureToS3) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Build config with separate flags
|
|
72
|
-
const config: ScreenshotConfig = {
|
|
73
|
-
enableScreenshotCaptureToS3,
|
|
74
|
-
enableLogsCaptureToS3,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Add optional S3 configuration if provided
|
|
78
|
-
if (process.env.SCREENSHOT_S3_BUCKET) {
|
|
79
|
-
config.s3_bucket = process.env.SCREENSHOT_S3_BUCKET;
|
|
80
|
-
}
|
|
81
|
-
if (process.env.SCREENSHOT_S3_PREFIX) {
|
|
82
|
-
config.s3_prefix = process.env.SCREENSHOT_S3_PREFIX;
|
|
83
|
-
}
|
|
84
|
-
if (process.env.AWS_REGION) {
|
|
85
|
-
config.aws_region = process.env.AWS_REGION;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
logger.debug({
|
|
89
|
-
msg: 'Browser task capture configuration',
|
|
90
|
-
screenshots: enableScreenshotCaptureToS3,
|
|
91
|
-
logs: enableLogsCaptureToS3,
|
|
92
|
-
bucket: config.s3_bucket || 'default',
|
|
93
|
-
prefix: config.s3_prefix || 'default',
|
|
94
|
-
region: config.aws_region || 'default',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return config;
|
|
98
|
-
})();
|
|
58
|
+
const { browserTaskMode, isDeployed } = getConfig();
|
|
59
|
+
|
|
60
|
+
const screenshotConfig: ScreenshotConfig | null = isDeployed ? null : {
|
|
61
|
+
aws_region: process.env.AWS_REGION || 'us-east-1',
|
|
62
|
+
s3_bucket: process.env.AWS_BUCKET || 'minded-agents',
|
|
63
|
+
s3_prefix: 'browser-task/',
|
|
64
|
+
}
|
|
99
65
|
|
|
100
66
|
// Invoke browser task via socket
|
|
101
67
|
const result = await invokeBrowserTask({
|