autoclaw 1.0.26 → 1.0.27
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/README.md +4 -4
- package/dist/tools/screenshot.js +33 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,18 +156,18 @@ Built-in utility to provide the agent with the current system time, ensuring acc
|
|
|
156
156
|
## Docker Support
|
|
157
157
|
|
|
158
158
|
### Chinese Font Issues in Screenshots
|
|
159
|
-
When running AutoClaw inside a Docker container (especially Alpine or Debian Slim), screenshots of Chinese websites may display text as square boxes ("tofu") due to missing fonts.
|
|
159
|
+
When running AutoClaw inside a Docker container (especially Alpine or Debian Slim), screenshots of Chinese websites may display text as square boxes ("tofu") due to missing fonts. Emojis (e.g., 🔥) may also appear as squares.
|
|
160
160
|
|
|
161
|
-
**Solution:** Install CJK (Chinese/Japanese/Korean) fonts in your container.
|
|
161
|
+
**Solution:** Install CJK (Chinese/Japanese/Korean) and Emoji fonts in your container.
|
|
162
162
|
|
|
163
163
|
**For Debian/Ubuntu:**
|
|
164
164
|
```bash
|
|
165
|
-
apt-get update && apt-get install -y fonts-noto-cjk fonts-wqy-zenhei
|
|
165
|
+
apt-get update && apt-get install -y fonts-noto-cjk fonts-wqy-zenhei fonts-noto-color-emoji
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
**For Alpine Linux:**
|
|
169
169
|
```bash
|
|
170
|
-
apk add font-noto-cjk
|
|
170
|
+
apk add font-noto-cjk font-noto-emoji
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
## License
|
package/dist/tools/screenshot.js
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
import { chromium } from 'playwright';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as os from 'os';
|
|
4
|
-
// Helper to check for common CJK font paths on Linux
|
|
4
|
+
// Helper to check for common CJK and Emoji font paths on Linux
|
|
5
5
|
const checkLinuxFonts = () => {
|
|
6
6
|
if (os.platform() !== 'linux')
|
|
7
|
-
return true;
|
|
7
|
+
return { cjk: true, emoji: true };
|
|
8
8
|
// Check for specific font files rather than just directories
|
|
9
|
-
const
|
|
9
|
+
const commonCJKFontFiles = [
|
|
10
10
|
'/usr/share/fonts/noto/NotoSansCJK-Regular.ttc', // Alpine / Some Debian
|
|
11
11
|
'/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc', // Debian / Ubuntu
|
|
12
12
|
'/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc', // ZenHei
|
|
13
13
|
'/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc' // Arch
|
|
14
14
|
];
|
|
15
|
-
|
|
15
|
+
const commonEmojiFontFiles = [
|
|
16
|
+
'/usr/share/fonts/noto/NotoColorEmoji.ttf',
|
|
17
|
+
'/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf',
|
|
18
|
+
'/usr/share/fonts/google-noto-emoji/NotoColorEmoji.ttf'
|
|
19
|
+
];
|
|
20
|
+
const hasCJK = commonCJKFontFiles.some(path => fs.existsSync(path));
|
|
21
|
+
const hasEmoji = commonEmojiFontFiles.some(path => fs.existsSync(path));
|
|
22
|
+
// Also check if fc-list finds fonts (if available) - secondary check
|
|
16
23
|
try {
|
|
17
24
|
const child_process = require('child_process');
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
const cjkOutput = child_process.execSync('fc-list :lang=zh', { stdio: 'pipe' }).toString();
|
|
26
|
+
const emojiOutput = child_process.execSync('fc-list :family=Emoji', { stdio: 'pipe' }).toString(); // Approximate check
|
|
27
|
+
return {
|
|
28
|
+
cjk: hasCJK || cjkOutput.length > 0,
|
|
29
|
+
emoji: hasEmoji || emojiOutput.length > 0
|
|
30
|
+
};
|
|
21
31
|
}
|
|
22
32
|
catch (e) {
|
|
23
33
|
// fc-list might not be installed or failed, fall back to file check
|
|
34
|
+
return { cjk: hasCJK, emoji: hasEmoji };
|
|
24
35
|
}
|
|
25
|
-
return commonFontFiles.some(path => fs.existsSync(path));
|
|
26
36
|
};
|
|
27
37
|
export const ScreenshotTool = {
|
|
28
38
|
name: "Screenshot Tool",
|
|
@@ -45,7 +55,7 @@ export const ScreenshotTool = {
|
|
|
45
55
|
},
|
|
46
56
|
fullPage: {
|
|
47
57
|
type: "boolean",
|
|
48
|
-
description: "If true, takes a screenshot of the full scrollable page
|
|
58
|
+
description: "If true (default), takes a screenshot of the full scrollable page. Set to false for viewport only."
|
|
49
59
|
}
|
|
50
60
|
},
|
|
51
61
|
required: ["url", "outputPath"]
|
|
@@ -54,9 +64,16 @@ export const ScreenshotTool = {
|
|
|
54
64
|
},
|
|
55
65
|
handler: async (args, config) => {
|
|
56
66
|
// Check for fonts on Linux to prevent "tofu" characters
|
|
57
|
-
if (os.platform() === 'linux'
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
if (os.platform() === 'linux') {
|
|
68
|
+
const fonts = checkLinuxFonts();
|
|
69
|
+
if (!fonts.cjk) {
|
|
70
|
+
console.warn("⚠️ Warning: No CJK fonts detected. Chinese characters may appear as squares (tofu).");
|
|
71
|
+
console.warn(" Run 'apk add font-noto-cjk' (Alpine) or 'apt-get install fonts-noto-cjk' (Debian/Ubuntu).");
|
|
72
|
+
}
|
|
73
|
+
if (!fonts.emoji) {
|
|
74
|
+
console.warn("⚠️ Warning: No Emoji fonts detected. Emojis may appear as squares.");
|
|
75
|
+
console.warn(" Run 'apk add font-noto-emoji' (Alpine) or 'apt-get install fonts-noto-color-emoji' (Debian/Ubuntu).");
|
|
76
|
+
}
|
|
60
77
|
}
|
|
61
78
|
let browser;
|
|
62
79
|
const launchOptions = {
|
|
@@ -91,12 +108,12 @@ export const ScreenshotTool = {
|
|
|
91
108
|
await page.goto(args.url, { waitUntil: 'networkidle', timeout: 30000 });
|
|
92
109
|
// Inject CSS to force common Chinese fonts
|
|
93
110
|
// Note: For Docker environments (Alpine/Debian), ensure fonts are installed.
|
|
94
|
-
// Alpine: apk add font-noto-cjk
|
|
95
|
-
// Debian/Ubuntu: apt-get install fonts-noto-cjk fonts-wqy-zenhei
|
|
111
|
+
// Alpine: apk add font-noto-cjk font-noto-emoji
|
|
112
|
+
// Debian/Ubuntu: apt-get install fonts-noto-cjk fonts-wqy-zenhei fonts-noto-color-emoji
|
|
96
113
|
await page.addStyleTag({
|
|
97
114
|
content: `
|
|
98
115
|
body, h1, h2, h3, h4, h5, h6, p, span, div, li, a, button, input, textarea {
|
|
99
|
-
font-family: "PingFang SC", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif !important;
|
|
116
|
+
font-family: "PingFang SC", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Noto Sans CJK SC", "Noto Sans SC", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif !important;
|
|
100
117
|
}
|
|
101
118
|
`
|
|
102
119
|
});
|
|
@@ -106,7 +123,7 @@ export const ScreenshotTool = {
|
|
|
106
123
|
await page.waitForTimeout(1000);
|
|
107
124
|
await page.screenshot({
|
|
108
125
|
path: args.outputPath,
|
|
109
|
-
fullPage: args.fullPage
|
|
126
|
+
fullPage: args.fullPage !== false // Default to true if undefined
|
|
110
127
|
});
|
|
111
128
|
return `Successfully captured screenshot of ${args.url} and saved to ${args.outputPath}`;
|
|
112
129
|
}
|