@cortask/core 0.2.21 → 0.2.23
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/index.js +11 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3001,7 +3001,6 @@ function resolveCmd() {
|
|
|
3001
3001
|
}
|
|
3002
3002
|
var CMD = resolveCmd();
|
|
3003
3003
|
var instance = null;
|
|
3004
|
-
var _available = null;
|
|
3005
3004
|
function exec2(args, timeout = DEFAULT_TIMEOUT) {
|
|
3006
3005
|
return new Promise((resolve, reject) => {
|
|
3007
3006
|
const isScript = CMD.endsWith(".js");
|
|
@@ -3017,18 +3016,23 @@ function exec2(args, timeout = DEFAULT_TIMEOUT) {
|
|
|
3017
3016
|
});
|
|
3018
3017
|
});
|
|
3019
3018
|
}
|
|
3020
|
-
|
|
3021
|
-
|
|
3019
|
+
var _installed = false;
|
|
3020
|
+
async function ensureInstalled() {
|
|
3021
|
+
if (_installed) return;
|
|
3022
3022
|
try {
|
|
3023
3023
|
await exec2(["--version"], 5e3);
|
|
3024
|
-
_available = true;
|
|
3025
3024
|
} catch {
|
|
3026
|
-
|
|
3025
|
+
throw new Error("agent-browser is not installed. Run: npm install -g agent-browser");
|
|
3027
3026
|
}
|
|
3028
|
-
|
|
3027
|
+
try {
|
|
3028
|
+
await exec2(["install"], 12e4);
|
|
3029
|
+
} catch {
|
|
3030
|
+
}
|
|
3031
|
+
_installed = true;
|
|
3029
3032
|
}
|
|
3030
3033
|
async function ensureBrowser() {
|
|
3031
3034
|
if (instance) return instance;
|
|
3035
|
+
await ensureInstalled();
|
|
3032
3036
|
const inst = {
|
|
3033
3037
|
async run(args) {
|
|
3034
3038
|
return exec2(args);
|
|
@@ -3089,9 +3093,7 @@ async function ensureBrowser() {
|
|
|
3089
3093
|
await exec2(["press", key]);
|
|
3090
3094
|
},
|
|
3091
3095
|
async wait(target) {
|
|
3092
|
-
if (
|
|
3093
|
-
await exec2(["wait", target]);
|
|
3094
|
-
} else if (target.startsWith("http")) {
|
|
3096
|
+
if (target.startsWith("http")) {
|
|
3095
3097
|
await exec2(["wait", "--url", target]);
|
|
3096
3098
|
} else {
|
|
3097
3099
|
await exec2(["wait", target]);
|
|
@@ -3180,14 +3182,6 @@ function createBrowserTool(artifactStore) {
|
|
|
3180
3182
|
}
|
|
3181
3183
|
},
|
|
3182
3184
|
async execute(args, _context) {
|
|
3183
|
-
const available = await isAgentBrowserAvailable();
|
|
3184
|
-
if (!available) {
|
|
3185
|
-
return {
|
|
3186
|
-
toolCallId: "",
|
|
3187
|
-
content: "agent-browser is not installed. Run: npm install -g agent-browser && agent-browser install",
|
|
3188
|
-
isError: true
|
|
3189
|
-
};
|
|
3190
|
-
}
|
|
3191
3185
|
const action = args.action;
|
|
3192
3186
|
if (action === "close") {
|
|
3193
3187
|
await closeBrowser();
|