@cortask/core 0.2.24 → 0.2.25
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 +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2972,8 +2972,9 @@ function createArtifactTool(artifactStore) {
|
|
|
2972
2972
|
|
|
2973
2973
|
// src/agent/tools/browser-manager.ts
|
|
2974
2974
|
import { execFile } from "child_process";
|
|
2975
|
-
import { existsSync } from "fs";
|
|
2975
|
+
import { existsSync, mkdirSync } from "fs";
|
|
2976
2976
|
import { join } from "path";
|
|
2977
|
+
import { homedir } from "os";
|
|
2977
2978
|
import { createRequire } from "module";
|
|
2978
2979
|
var DEFAULT_TIMEOUT = 3e4;
|
|
2979
2980
|
function getNativeBinName() {
|
|
@@ -3011,12 +3012,19 @@ var instance = null;
|
|
|
3011
3012
|
function resetBrowserInstance() {
|
|
3012
3013
|
instance = null;
|
|
3013
3014
|
}
|
|
3015
|
+
function getAgentBrowserHome() {
|
|
3016
|
+
if (process.env.AGENT_BROWSER_HOME) return process.env.AGENT_BROWSER_HOME;
|
|
3017
|
+
const dir = join(homedir(), ".agent-browser");
|
|
3018
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
3019
|
+
return dir;
|
|
3020
|
+
}
|
|
3014
3021
|
function exec2(args, timeout = DEFAULT_TIMEOUT) {
|
|
3015
3022
|
return new Promise((resolve, reject) => {
|
|
3016
3023
|
const isScript = CMD.endsWith(".js");
|
|
3017
3024
|
const cmd = isScript ? process.env.NODE_PATH_BIN || process.execPath : CMD;
|
|
3018
3025
|
const finalArgs = isScript ? [CMD, ...args] : args;
|
|
3019
|
-
|
|
3026
|
+
const env = { ...process.env, AGENT_BROWSER_HOME: getAgentBrowserHome() };
|
|
3027
|
+
execFile(cmd, finalArgs, { timeout, maxBuffer: 5 * 1024 * 1024, env }, (err, stdout, stderr) => {
|
|
3020
3028
|
if (err) {
|
|
3021
3029
|
const msg = stderr?.trim() || stdout?.trim() || err.message;
|
|
3022
3030
|
reject(new Error(msg));
|