@askjo/camoufox-browser 1.0.6 → 1.0.8
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/package.json +1 -1
- package/plugin.ts +18 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askjo/camoufox-browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Headless browser automation server and OpenClaw plugin for AI agents - anti-detection, element refs, and session isolation",
|
|
5
5
|
"main": "server-camoufox.js",
|
|
6
6
|
"license": "MIT",
|
package/plugin.ts
CHANGED
|
@@ -6,7 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { spawn, ChildProcess } from "child_process";
|
|
9
|
-
import { join } from "path";
|
|
9
|
+
import { join, dirname } from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
|
|
12
|
+
// Get plugin directory - works in both ESM and CJS contexts
|
|
13
|
+
const getPluginDir = (): string => {
|
|
14
|
+
try {
|
|
15
|
+
// ESM context
|
|
16
|
+
return dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
} catch {
|
|
18
|
+
// CJS context
|
|
19
|
+
return __dirname;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
10
22
|
|
|
11
23
|
interface PluginConfig {
|
|
12
24
|
url?: string;
|
|
@@ -57,22 +69,22 @@ async function startServer(
|
|
|
57
69
|
|
|
58
70
|
proc.stdout?.on("data", (data: Buffer) => {
|
|
59
71
|
const msg = data.toString().trim();
|
|
60
|
-
if (msg) log
|
|
72
|
+
if (msg) log?.info?.(`[server] ${msg}`);
|
|
61
73
|
});
|
|
62
74
|
|
|
63
75
|
proc.stderr?.on("data", (data: Buffer) => {
|
|
64
76
|
const msg = data.toString().trim();
|
|
65
|
-
if (msg) log
|
|
77
|
+
if (msg) log?.error?.(`[server] ${msg}`);
|
|
66
78
|
});
|
|
67
79
|
|
|
68
80
|
proc.on("error", (err) => {
|
|
69
|
-
log
|
|
81
|
+
log?.error?.(`Server process error: ${err.message}`);
|
|
70
82
|
serverProcess = null;
|
|
71
83
|
});
|
|
72
84
|
|
|
73
85
|
proc.on("exit", (code) => {
|
|
74
86
|
if (code !== 0 && code !== null) {
|
|
75
|
-
log
|
|
87
|
+
log?.error?.(`Server exited with code ${code}`);
|
|
76
88
|
}
|
|
77
89
|
serverProcess = null;
|
|
78
90
|
});
|
|
@@ -133,7 +145,7 @@ export default function register(api: PluginApi) {
|
|
|
133
145
|
const port = api.config.port || 9377;
|
|
134
146
|
const baseUrl = api.config.url || `http://localhost:${port}`;
|
|
135
147
|
const autoStart = api.config.autoStart !== false; // default true
|
|
136
|
-
const pluginDir =
|
|
148
|
+
const pluginDir = getPluginDir();
|
|
137
149
|
|
|
138
150
|
// Auto-start server if configured (default: true)
|
|
139
151
|
if (autoStart) {
|