camel-ai 0.2.72a10__py3-none-any.whl → 0.2.73__py3-none-any.whl

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.

Potentially problematic release.


This version of camel-ai might be problematic. Click here for more details.

Files changed (52) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +140 -345
  3. camel/memories/agent_memories.py +18 -17
  4. camel/societies/__init__.py +2 -0
  5. camel/societies/workforce/prompts.py +36 -10
  6. camel/societies/workforce/single_agent_worker.py +7 -5
  7. camel/societies/workforce/workforce.py +6 -4
  8. camel/storages/key_value_storages/mem0_cloud.py +48 -47
  9. camel/storages/vectordb_storages/__init__.py +1 -0
  10. camel/storages/vectordb_storages/surreal.py +100 -150
  11. camel/toolkits/__init__.py +6 -1
  12. camel/toolkits/base.py +60 -2
  13. camel/toolkits/excel_toolkit.py +153 -64
  14. camel/toolkits/file_write_toolkit.py +67 -0
  15. camel/toolkits/hybrid_browser_toolkit/config_loader.py +136 -413
  16. camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +131 -1966
  17. camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit_ts.py +1177 -0
  18. camel/toolkits/hybrid_browser_toolkit/ts/package-lock.json +4356 -0
  19. camel/toolkits/hybrid_browser_toolkit/ts/package.json +33 -0
  20. camel/toolkits/hybrid_browser_toolkit/ts/src/browser-scripts.js +125 -0
  21. camel/toolkits/hybrid_browser_toolkit/ts/src/browser-session.ts +945 -0
  22. camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +226 -0
  23. camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +522 -0
  24. camel/toolkits/hybrid_browser_toolkit/ts/src/index.ts +7 -0
  25. camel/toolkits/hybrid_browser_toolkit/ts/src/types.ts +110 -0
  26. camel/toolkits/hybrid_browser_toolkit/ts/tsconfig.json +26 -0
  27. camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +254 -0
  28. camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +582 -0
  29. camel/toolkits/hybrid_browser_toolkit_py/__init__.py +17 -0
  30. camel/toolkits/hybrid_browser_toolkit_py/config_loader.py +447 -0
  31. camel/toolkits/hybrid_browser_toolkit_py/hybrid_browser_toolkit.py +2077 -0
  32. camel/toolkits/mcp_toolkit.py +341 -46
  33. camel/toolkits/message_integration.py +719 -0
  34. camel/toolkits/notion_mcp_toolkit.py +234 -0
  35. camel/toolkits/screenshot_toolkit.py +116 -31
  36. camel/toolkits/search_toolkit.py +20 -2
  37. camel/toolkits/slack_toolkit.py +43 -48
  38. camel/toolkits/terminal_toolkit.py +288 -46
  39. camel/toolkits/video_analysis_toolkit.py +13 -13
  40. camel/toolkits/video_download_toolkit.py +11 -11
  41. camel/toolkits/web_deploy_toolkit.py +207 -12
  42. camel/types/enums.py +6 -0
  43. {camel_ai-0.2.72a10.dist-info → camel_ai-0.2.73.dist-info}/METADATA +49 -9
  44. {camel_ai-0.2.72a10.dist-info → camel_ai-0.2.73.dist-info}/RECORD +52 -35
  45. /camel/toolkits/{hybrid_browser_toolkit → hybrid_browser_toolkit_py}/actions.py +0 -0
  46. /camel/toolkits/{hybrid_browser_toolkit → hybrid_browser_toolkit_py}/agent.py +0 -0
  47. /camel/toolkits/{hybrid_browser_toolkit → hybrid_browser_toolkit_py}/browser_session.py +0 -0
  48. /camel/toolkits/{hybrid_browser_toolkit → hybrid_browser_toolkit_py}/snapshot.py +0 -0
  49. /camel/toolkits/{hybrid_browser_toolkit → hybrid_browser_toolkit_py}/stealth_script.js +0 -0
  50. /camel/toolkits/{hybrid_browser_toolkit → hybrid_browser_toolkit_py}/unified_analyzer.js +0 -0
  51. {camel_ai-0.2.72a10.dist-info → camel_ai-0.2.73.dist-info}/WHEEL +0 -0
  52. {camel_ai-0.2.72a10.dist-info → camel_ai-0.2.73.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,254 @@
1
+ const WebSocket = require('ws');
2
+ const { HybridBrowserToolkit } = require('./dist/index.js');
3
+
4
+ class WebSocketBrowserServer {
5
+ constructor() {
6
+ this.toolkit = null;
7
+ this.port = 0; // Let the OS assign a free port
8
+ this.server = null;
9
+ }
10
+
11
+ async start() {
12
+ return new Promise((resolve, reject) => {
13
+ this.server = new WebSocket.Server({
14
+ port: this.port,
15
+ maxPayload: 50 * 1024 * 1024 // 50MB limit instead of default 1MB
16
+ }, () => {
17
+ this.port = this.server.address().port;
18
+ console.log(`WebSocket server started on port ${this.port}`);
19
+ resolve(this.port);
20
+ });
21
+
22
+ this.server.on('connection', (ws) => {
23
+ console.log('Client connected');
24
+
25
+ ws.on('message', async (message) => {
26
+ try {
27
+ const data = JSON.parse(message.toString());
28
+ const { id, command, params } = data;
29
+
30
+ console.log(`Received command: ${command} with id: ${id}`);
31
+
32
+ const result = await this.handleCommand(command, params);
33
+
34
+ const response = {
35
+ id,
36
+ success: true,
37
+ result
38
+ };
39
+
40
+ ws.send(JSON.stringify(response));
41
+ } catch (error) {
42
+ console.error('Error handling command:', error);
43
+
44
+ const errorResponse = {
45
+ id: data?.id || 'unknown',
46
+ success: false,
47
+ error: error.message,
48
+ stack: error.stack
49
+ };
50
+
51
+ ws.send(JSON.stringify(errorResponse));
52
+ }
53
+ });
54
+
55
+ ws.on('close', (code, reason) => {
56
+ console.log('Client disconnected, code:', code, 'reason:', reason?.toString());
57
+ // Clean up resources when client disconnects
58
+ if (this.toolkit) {
59
+ this.toolkit.closeBrowser().catch(err => {
60
+ console.error('Error closing browser on disconnect:', err);
61
+ });
62
+ }
63
+ });
64
+
65
+ ws.on('error', (error) => {
66
+ console.error('WebSocket error:', error);
67
+ });
68
+ });
69
+
70
+ this.server.on('error', (error) => {
71
+ console.error('Server error:', error);
72
+ reject(error);
73
+ });
74
+ });
75
+ }
76
+
77
+ async handleCommand(command, params) {
78
+ switch (command) {
79
+ case 'init':
80
+ console.log('Initializing toolkit with params:', JSON.stringify(params, null, 2));
81
+
82
+ // Check if CDP is available first
83
+ let useCdp = false;
84
+ let cdpUrl = params.cdpUrl || 'http://localhost:9222';
85
+
86
+ // Extract base URL and port for validation
87
+ const baseUrl = cdpUrl.includes('/devtools/') ? cdpUrl.split('/devtools/')[0] : cdpUrl;
88
+
89
+ try {
90
+ // Test if Chrome debug port is accessible and get page URL
91
+ const response = await fetch(`${baseUrl}/json`);
92
+ if (response.ok) {
93
+ const pages = await response.json();
94
+ if (pages && pages.length > 0) {
95
+ // If user provided a specific page URL, use it; otherwise use first available
96
+ if (cdpUrl.includes('/devtools/page/') || cdpUrl.includes('/devtools/browser/')) {
97
+ useCdp = true;
98
+ console.log(`Using provided CDP URL: ${cdpUrl}`);
99
+ } else {
100
+ // Use the first available page
101
+ const firstPage = pages[0];
102
+ const pageUrl = firstPage.devtoolsFrontendUrl;
103
+ const pageId = pageUrl.match(/ws=localhost:\d+(.*)$/)?.[1];
104
+
105
+ if (pageId) {
106
+ useCdp = true;
107
+ cdpUrl = `${baseUrl}${pageId}`;
108
+ console.log(`Chrome debug port detected, using CDP connection to: ${pageId}`);
109
+ }
110
+ }
111
+ }
112
+ }
113
+ } catch (error) {
114
+ console.log('Chrome debug port not accessible, will start new browser instance');
115
+ }
116
+
117
+ const config = {
118
+ connectOverCdp: useCdp,
119
+ cdpUrl: useCdp ? cdpUrl : undefined,
120
+ headless: false,
121
+ ...params
122
+ };
123
+
124
+ console.log('Final config:', JSON.stringify(config, null, 2));
125
+ this.toolkit = new HybridBrowserToolkit(config);
126
+ return { message: 'Toolkit initialized with CDP connection' };
127
+
128
+ case 'open_browser':
129
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
130
+ return await this.toolkit.openBrowser(params.startUrl);
131
+
132
+ case 'close_browser':
133
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
134
+ return await this.toolkit.closeBrowser();
135
+
136
+ case 'visit_page':
137
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
138
+ return await this.toolkit.visitPage(params.url);
139
+
140
+ case 'get_page_snapshot':
141
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
142
+ return await this.toolkit.getPageSnapshot(params.viewport_limit);
143
+
144
+ case 'get_snapshot_for_ai':
145
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
146
+ return await this.toolkit.getSnapshotForAI();
147
+
148
+ case 'get_som_screenshot': {
149
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
150
+ console.log('Starting screenshot...');
151
+ const startTime = Date.now();
152
+ const result = await this.toolkit.getSomScreenshot();
153
+ const endTime = Date.now();
154
+ console.log(`Screenshot completed in ${endTime - startTime}ms`);
155
+ return result;
156
+ }
157
+ case 'click':
158
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
159
+ return await this.toolkit.click(params.ref);
160
+
161
+ case 'type':
162
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
163
+ return await this.toolkit.type(params.ref, params.text);
164
+
165
+ case 'select':
166
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
167
+ return await this.toolkit.select(params.ref, params.value);
168
+
169
+ case 'scroll':
170
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
171
+ return await this.toolkit.scroll(params.direction, params.amount);
172
+
173
+ case 'enter':
174
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
175
+ return await this.toolkit.enter();
176
+
177
+ case 'back':
178
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
179
+ return await this.toolkit.back();
180
+
181
+ case 'forward':
182
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
183
+ return await this.toolkit.forward();
184
+
185
+ case 'switch_tab':
186
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
187
+ return await this.toolkit.switchTab(params.tabId);
188
+
189
+ case 'close_tab':
190
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
191
+ return await this.toolkit.closeTab(params.tabId);
192
+
193
+ case 'get_tab_info':
194
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
195
+ return await this.toolkit.getTabInfo();
196
+
197
+ case 'wait_user':
198
+ if (!this.toolkit) throw new Error('Toolkit not initialized');
199
+ return await this.toolkit.waitUser(params.timeout);
200
+
201
+ case 'shutdown':
202
+ console.log('Shutting down server...');
203
+ if (this.toolkit) {
204
+ try {
205
+ await this.toolkit.closeBrowser();
206
+ } catch (error) {
207
+ console.error('Error closing browser:', error);
208
+ }
209
+ }
210
+ setTimeout(() => {
211
+ process.exit(0);
212
+ }, 1000);
213
+ return { message: 'Server shutting down' };
214
+
215
+ default:
216
+ throw new Error(`Unknown command: ${command}`);
217
+ }
218
+ }
219
+
220
+ async stop() {
221
+ if (this.server) {
222
+ this.server.close();
223
+ console.log('WebSocket server stopped');
224
+ }
225
+ }
226
+ }
227
+
228
+ // Start server if this file is run directly
229
+ if (require.main === module) {
230
+ const server = new WebSocketBrowserServer();
231
+
232
+ server.start().then((port) => {
233
+ // Output the port so the Python client can connect
234
+ console.log(`SERVER_READY:${port}`);
235
+ }).catch((error) => {
236
+ console.error('Failed to start server:', error);
237
+ process.exit(1);
238
+ });
239
+
240
+ // Handle graceful shutdown
241
+ process.on('SIGINT', async () => {
242
+ console.log('Received SIGINT, shutting down gracefully...');
243
+ await server.stop();
244
+ process.exit(0);
245
+ });
246
+
247
+ process.on('SIGTERM', async () => {
248
+ console.log('Received SIGTERM, shutting down gracefully...');
249
+ await server.stop();
250
+ process.exit(0);
251
+ });
252
+ }
253
+
254
+ module.exports = WebSocketBrowserServer;