@midscene/computer-playground 1.2.3-beta-20260120095429.0 → 1.2.3-beta-20260122082712.0
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/es/bin.mjs +24 -20
- package/dist/lib/bin.js +25 -20
- package/package.json +5 -5
- package/static/index.html +1 -1
- package/static/static/js/index.e863238e.js +10 -0
- package/static/static/js/index.e863238e.js.map +1 -0
- package/static/static/js/index.ff663c58.js +0 -10
- package/static/static/js/index.ff663c58.js.map +0 -1
- /package/static/static/js/{index.ff663c58.js.LICENSE.txt → index.e863238e.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createServer } from "node:net";
|
|
2
|
+
import node_os from "node:os";
|
|
2
3
|
import node_path from "node:path";
|
|
3
4
|
import { ComputerDevice, agentFromComputer } from "@midscene/computer";
|
|
4
5
|
import { PlaygroundServer } from "@midscene/playground";
|
|
@@ -20,7 +21,7 @@ async function findAvailablePort(startPort) {
|
|
|
20
21
|
while(!await isPortAvailable(port)){
|
|
21
22
|
attempts++;
|
|
22
23
|
if (attempts >= maxAttempts) {
|
|
23
|
-
console.error(
|
|
24
|
+
console.error(`❌ Unable to find available port after ${maxAttempts} attempts starting from ${startPort}`);
|
|
24
25
|
process.exit(1);
|
|
25
26
|
}
|
|
26
27
|
port++;
|
|
@@ -32,14 +33,14 @@ const main = async ()=>{
|
|
|
32
33
|
try {
|
|
33
34
|
const displays = await ComputerDevice.listDisplays();
|
|
34
35
|
if (displays.length > 0) {
|
|
35
|
-
console.log('Available displays:');
|
|
36
|
-
for (const display of displays)console.log(`
|
|
36
|
+
console.log('🖥️ Available displays:');
|
|
37
|
+
for (const display of displays)console.log(` ${display.primary ? '✅' : ' '} ${display.name} (${display.id})${display.primary ? ' [Primary]' : ''}`);
|
|
37
38
|
}
|
|
38
39
|
const playgroundServer = new PlaygroundServer(async ()=>await agentFromComputer(), staticDir);
|
|
39
40
|
let windowController = null;
|
|
40
41
|
playgroundServer.app.use('/execute', async (_req, res, next)=>{
|
|
41
42
|
if (!windowController) {
|
|
42
|
-
console.warn('Window controller not initialized yet, skipping window control');
|
|
43
|
+
console.warn('⚠️ Window controller not initialized yet, skipping window control');
|
|
43
44
|
next();
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
@@ -52,9 +53,9 @@ const main = async ()=>{
|
|
|
52
53
|
windowState: 'minimized'
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
|
-
console.log('Window minimized
|
|
56
|
+
console.log('🔽 Window minimized, starting task execution...');
|
|
56
57
|
} catch (error) {
|
|
57
|
-
console.warn('Failed to minimize window:', error);
|
|
58
|
+
console.warn('⚠️ Failed to minimize window:', error);
|
|
58
59
|
}
|
|
59
60
|
const originalSend = res.send.bind(res);
|
|
60
61
|
res.send = (body)=>{
|
|
@@ -67,25 +68,25 @@ const main = async ()=>{
|
|
|
67
68
|
}),
|
|
68
69
|
page.bringToFront()
|
|
69
70
|
]).then(()=>{
|
|
70
|
-
console.log('Window restored
|
|
71
|
+
console.log('🔼 Window restored');
|
|
71
72
|
}).catch((error)=>{
|
|
72
|
-
console.warn('Failed to restore window:', error);
|
|
73
|
+
console.warn('⚠️ Failed to restore window:', error);
|
|
73
74
|
});
|
|
74
75
|
return originalSend(body);
|
|
75
76
|
};
|
|
76
77
|
next();
|
|
77
78
|
});
|
|
78
|
-
console.log('Starting server...');
|
|
79
|
+
console.log('🚀 Starting server...');
|
|
79
80
|
const availablePort = await findAvailablePort(PLAYGROUND_SERVER_PORT);
|
|
80
|
-
if (availablePort !== PLAYGROUND_SERVER_PORT) console.log(
|
|
81
|
+
if (availablePort !== PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${PLAYGROUND_SERVER_PORT} is busy, using port ${availablePort} instead`);
|
|
81
82
|
await playgroundServer.launch(availablePort);
|
|
82
83
|
console.log('');
|
|
83
|
-
console.log('Midscene Computer Playground is ready!');
|
|
84
|
-
console.log(
|
|
85
|
-
console.log(
|
|
84
|
+
console.log('✨ Midscene Computer Playground is ready!');
|
|
85
|
+
console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
|
|
86
|
+
console.log(`🔑 Server ID: ${playgroundServer.id}`);
|
|
86
87
|
console.log('');
|
|
87
88
|
const url = `http://localhost:${playgroundServer.port}`;
|
|
88
|
-
console.log('Launching browser in standalone window mode...');
|
|
89
|
+
console.log('🌐 Launching browser in standalone window mode...');
|
|
89
90
|
const device = new ComputerDevice();
|
|
90
91
|
await device.connect();
|
|
91
92
|
const screenSize = await device.size();
|
|
@@ -93,10 +94,13 @@ const main = async ()=>{
|
|
|
93
94
|
const windowWidth = 500;
|
|
94
95
|
const maxWindowHeight = 1200;
|
|
95
96
|
const windowHeight = Math.min(screenSize.height, maxWindowHeight);
|
|
96
|
-
console.log(
|
|
97
|
+
console.log(`📐 Screen size: ${screenSize.width}x${screenSize.height}, window size: ${windowWidth}x${windowHeight}`);
|
|
98
|
+
const userDataDir = node_path.join(node_os.homedir(), '.midscene', 'computer-playground');
|
|
99
|
+
console.log(`💾 User data directory: ${userDataDir}`);
|
|
97
100
|
const browser = await puppeteer.launch({
|
|
98
101
|
headless: false,
|
|
99
102
|
defaultViewport: null,
|
|
103
|
+
userDataDir,
|
|
100
104
|
args: [
|
|
101
105
|
`--app=${url}`,
|
|
102
106
|
`--window-size=${windowWidth},${windowHeight}`,
|
|
@@ -104,26 +108,26 @@ const main = async ()=>{
|
|
|
104
108
|
'--no-default-browser-check'
|
|
105
109
|
]
|
|
106
110
|
});
|
|
107
|
-
console.log('Browser launched successfully
|
|
111
|
+
console.log('✅ Browser launched successfully');
|
|
108
112
|
const pages = await browser.pages();
|
|
109
113
|
const page = pages[0];
|
|
110
114
|
const session = await page.createCDPSession();
|
|
111
115
|
const windowInfo = await session.send('Browser.getWindowForTarget');
|
|
112
116
|
const windowId = windowInfo.windowId;
|
|
113
|
-
console.log(
|
|
117
|
+
console.log(`🪟 Window ID: ${windowId}`);
|
|
114
118
|
windowController = {
|
|
115
119
|
session,
|
|
116
120
|
page,
|
|
117
121
|
windowId
|
|
118
122
|
};
|
|
119
|
-
console.log('Window controller initialized');
|
|
123
|
+
console.log('✅ Window controller initialized');
|
|
120
124
|
process.on('SIGINT', async ()=>{
|
|
121
|
-
console.log('\
|
|
125
|
+
console.log('\n👋 Shutting down...');
|
|
122
126
|
await browser.close();
|
|
123
127
|
process.exit(0);
|
|
124
128
|
});
|
|
125
129
|
} catch (error) {
|
|
126
|
-
console.error('Failed to start server:', error);
|
|
130
|
+
console.error('❌ Failed to start server:', error);
|
|
127
131
|
process.exit(1);
|
|
128
132
|
}
|
|
129
133
|
};
|
package/dist/lib/bin.js
CHANGED
|
@@ -22,6 +22,8 @@ var __webpack_require__ = {};
|
|
|
22
22
|
})();
|
|
23
23
|
var __webpack_exports__ = {};
|
|
24
24
|
const external_node_net_namespaceObject = require("node:net");
|
|
25
|
+
const external_node_os_namespaceObject = require("node:os");
|
|
26
|
+
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
25
27
|
const external_node_path_namespaceObject = require("node:path");
|
|
26
28
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
27
29
|
const computer_namespaceObject = require("@midscene/computer");
|
|
@@ -45,7 +47,7 @@ async function findAvailablePort(startPort) {
|
|
|
45
47
|
while(!await isPortAvailable(port)){
|
|
46
48
|
attempts++;
|
|
47
49
|
if (attempts >= maxAttempts) {
|
|
48
|
-
console.error(
|
|
50
|
+
console.error(`❌ Unable to find available port after ${maxAttempts} attempts starting from ${startPort}`);
|
|
49
51
|
process.exit(1);
|
|
50
52
|
}
|
|
51
53
|
port++;
|
|
@@ -57,14 +59,14 @@ const main = async ()=>{
|
|
|
57
59
|
try {
|
|
58
60
|
const displays = await computer_namespaceObject.ComputerDevice.listDisplays();
|
|
59
61
|
if (displays.length > 0) {
|
|
60
|
-
console.log('Available displays:');
|
|
61
|
-
for (const display of displays)console.log(`
|
|
62
|
+
console.log('🖥️ Available displays:');
|
|
63
|
+
for (const display of displays)console.log(` ${display.primary ? '✅' : ' '} ${display.name} (${display.id})${display.primary ? ' [Primary]' : ''}`);
|
|
62
64
|
}
|
|
63
65
|
const playgroundServer = new playground_namespaceObject.PlaygroundServer(async ()=>await (0, computer_namespaceObject.agentFromComputer)(), staticDir);
|
|
64
66
|
let windowController = null;
|
|
65
67
|
playgroundServer.app.use('/execute', async (_req, res, next)=>{
|
|
66
68
|
if (!windowController) {
|
|
67
|
-
console.warn('Window controller not initialized yet, skipping window control');
|
|
69
|
+
console.warn('⚠️ Window controller not initialized yet, skipping window control');
|
|
68
70
|
next();
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
@@ -77,9 +79,9 @@ const main = async ()=>{
|
|
|
77
79
|
windowState: 'minimized'
|
|
78
80
|
}
|
|
79
81
|
});
|
|
80
|
-
console.log('Window minimized
|
|
82
|
+
console.log('🔽 Window minimized, starting task execution...');
|
|
81
83
|
} catch (error) {
|
|
82
|
-
console.warn('Failed to minimize window:', error);
|
|
84
|
+
console.warn('⚠️ Failed to minimize window:', error);
|
|
83
85
|
}
|
|
84
86
|
const originalSend = res.send.bind(res);
|
|
85
87
|
res.send = (body)=>{
|
|
@@ -92,25 +94,25 @@ const main = async ()=>{
|
|
|
92
94
|
}),
|
|
93
95
|
page.bringToFront()
|
|
94
96
|
]).then(()=>{
|
|
95
|
-
console.log('Window restored
|
|
97
|
+
console.log('🔼 Window restored');
|
|
96
98
|
}).catch((error)=>{
|
|
97
|
-
console.warn('Failed to restore window:', error);
|
|
99
|
+
console.warn('⚠️ Failed to restore window:', error);
|
|
98
100
|
});
|
|
99
101
|
return originalSend(body);
|
|
100
102
|
};
|
|
101
103
|
next();
|
|
102
104
|
});
|
|
103
|
-
console.log('Starting server...');
|
|
105
|
+
console.log('🚀 Starting server...');
|
|
104
106
|
const availablePort = await findAvailablePort(constants_namespaceObject.PLAYGROUND_SERVER_PORT);
|
|
105
|
-
if (availablePort !== constants_namespaceObject.PLAYGROUND_SERVER_PORT) console.log(
|
|
107
|
+
if (availablePort !== constants_namespaceObject.PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${constants_namespaceObject.PLAYGROUND_SERVER_PORT} is busy, using port ${availablePort} instead`);
|
|
106
108
|
await playgroundServer.launch(availablePort);
|
|
107
109
|
console.log('');
|
|
108
|
-
console.log('Midscene Computer Playground is ready!');
|
|
109
|
-
console.log(
|
|
110
|
-
console.log(
|
|
110
|
+
console.log('✨ Midscene Computer Playground is ready!');
|
|
111
|
+
console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
|
|
112
|
+
console.log(`🔑 Server ID: ${playgroundServer.id}`);
|
|
111
113
|
console.log('');
|
|
112
114
|
const url = `http://localhost:${playgroundServer.port}`;
|
|
113
|
-
console.log('Launching browser in standalone window mode...');
|
|
115
|
+
console.log('🌐 Launching browser in standalone window mode...');
|
|
114
116
|
const device = new computer_namespaceObject.ComputerDevice();
|
|
115
117
|
await device.connect();
|
|
116
118
|
const screenSize = await device.size();
|
|
@@ -118,10 +120,13 @@ const main = async ()=>{
|
|
|
118
120
|
const windowWidth = 500;
|
|
119
121
|
const maxWindowHeight = 1200;
|
|
120
122
|
const windowHeight = Math.min(screenSize.height, maxWindowHeight);
|
|
121
|
-
console.log(
|
|
123
|
+
console.log(`📐 Screen size: ${screenSize.width}x${screenSize.height}, window size: ${windowWidth}x${windowHeight}`);
|
|
124
|
+
const userDataDir = external_node_path_default().join(external_node_os_default().homedir(), '.midscene', 'computer-playground');
|
|
125
|
+
console.log(`💾 User data directory: ${userDataDir}`);
|
|
122
126
|
const browser = await external_puppeteer_default().launch({
|
|
123
127
|
headless: false,
|
|
124
128
|
defaultViewport: null,
|
|
129
|
+
userDataDir,
|
|
125
130
|
args: [
|
|
126
131
|
`--app=${url}`,
|
|
127
132
|
`--window-size=${windowWidth},${windowHeight}`,
|
|
@@ -129,26 +134,26 @@ const main = async ()=>{
|
|
|
129
134
|
'--no-default-browser-check'
|
|
130
135
|
]
|
|
131
136
|
});
|
|
132
|
-
console.log('Browser launched successfully
|
|
137
|
+
console.log('✅ Browser launched successfully');
|
|
133
138
|
const pages = await browser.pages();
|
|
134
139
|
const page = pages[0];
|
|
135
140
|
const session = await page.createCDPSession();
|
|
136
141
|
const windowInfo = await session.send('Browser.getWindowForTarget');
|
|
137
142
|
const windowId = windowInfo.windowId;
|
|
138
|
-
console.log(
|
|
143
|
+
console.log(`🪟 Window ID: ${windowId}`);
|
|
139
144
|
windowController = {
|
|
140
145
|
session,
|
|
141
146
|
page,
|
|
142
147
|
windowId
|
|
143
148
|
};
|
|
144
|
-
console.log('Window controller initialized');
|
|
149
|
+
console.log('✅ Window controller initialized');
|
|
145
150
|
process.on('SIGINT', async ()=>{
|
|
146
|
-
console.log('\
|
|
151
|
+
console.log('\n👋 Shutting down...');
|
|
147
152
|
await browser.close();
|
|
148
153
|
process.exit(0);
|
|
149
154
|
});
|
|
150
155
|
} catch (error) {
|
|
151
|
-
console.error('Failed to start server:', error);
|
|
156
|
+
console.error('❌ Failed to start server:', error);
|
|
152
157
|
process.exit(1);
|
|
153
158
|
}
|
|
154
159
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/computer-playground",
|
|
3
|
-
"version": "1.2.3-beta-
|
|
3
|
+
"version": "1.2.3-beta-20260122082712.0",
|
|
4
4
|
"description": "Computer playground for Midscene - PC desktop automation",
|
|
5
5
|
"main": "./dist/lib/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"cors": "^2.8.5",
|
|
20
20
|
"express": "^4.21.2",
|
|
21
21
|
"puppeteer": "24.6.0",
|
|
22
|
-
"@midscene/
|
|
23
|
-
"@midscene/core": "1.2.3-beta-
|
|
24
|
-
"@midscene/
|
|
25
|
-
"@midscene/shared": "1.2.3-beta-
|
|
22
|
+
"@midscene/computer": "1.2.3-beta-20260122082712.0",
|
|
23
|
+
"@midscene/core": "1.2.3-beta-20260122082712.0",
|
|
24
|
+
"@midscene/playground": "1.2.3-beta-20260122082712.0",
|
|
25
|
+
"@midscene/shared": "1.2.3-beta-20260122082712.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@rslib/core": "^0.18.3",
|
package/static/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html><head><title>Midscene Computer Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.e13cc2e0.js"></script><script defer src="/static/js/119.b7e19680.js"></script><script defer src="/static/js/index.
|
|
1
|
+
<!doctype html><html><head><title>Midscene Computer Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.e13cc2e0.js"></script><script defer src="/static/js/119.b7e19680.js"></script><script defer src="/static/js/index.e863238e.js"></script><link href="/static/css/index.58f2c850.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
|