@cortask/core 0.2.22 → 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 CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/providers/openai-compatible.ts
9
2
  import OpenAI from "openai";
10
3
 
@@ -2992,16 +2985,9 @@ function getNativeBinName() {
2992
2985
  return null;
2993
2986
  }
2994
2987
  function resolveCmd() {
2995
- const nativeBin = getNativeBinName();
2996
- const resourcesPath = process.resourcesPath;
2997
- if (resourcesPath && nativeBin) {
2998
- const path18 = __require("path");
2999
- const fs20 = __require("fs");
3000
- const candidate = path18.join(resourcesPath, "agent-browser", nativeBin);
3001
- if (fs20.existsSync(candidate)) return candidate;
3002
- }
3003
2988
  try {
3004
2989
  const require2 = createRequire(import.meta.url);
2990
+ const nativeBin = getNativeBinName();
3005
2991
  if (nativeBin) {
3006
2992
  try {
3007
2993
  return require2.resolve(`agent-browser/bin/${nativeBin}`);
@@ -3015,7 +3001,6 @@ function resolveCmd() {
3015
3001
  }
3016
3002
  var CMD = resolveCmd();
3017
3003
  var instance = null;
3018
- var _available = null;
3019
3004
  function exec2(args, timeout = DEFAULT_TIMEOUT) {
3020
3005
  return new Promise((resolve, reject) => {
3021
3006
  const isScript = CMD.endsWith(".js");
@@ -3031,18 +3016,23 @@ function exec2(args, timeout = DEFAULT_TIMEOUT) {
3031
3016
  });
3032
3017
  });
3033
3018
  }
3034
- async function isAgentBrowserAvailable() {
3035
- if (_available !== null) return _available;
3019
+ var _installed = false;
3020
+ async function ensureInstalled() {
3021
+ if (_installed) return;
3036
3022
  try {
3037
3023
  await exec2(["--version"], 5e3);
3038
- _available = true;
3039
3024
  } catch {
3040
- _available = false;
3025
+ throw new Error("agent-browser is not installed. Run: npm install -g agent-browser");
3026
+ }
3027
+ try {
3028
+ await exec2(["install"], 12e4);
3029
+ } catch {
3041
3030
  }
3042
- return _available;
3031
+ _installed = true;
3043
3032
  }
3044
3033
  async function ensureBrowser() {
3045
3034
  if (instance) return instance;
3035
+ await ensureInstalled();
3046
3036
  const inst = {
3047
3037
  async run(args) {
3048
3038
  return exec2(args);
@@ -3103,9 +3093,7 @@ async function ensureBrowser() {
3103
3093
  await exec2(["press", key]);
3104
3094
  },
3105
3095
  async wait(target) {
3106
- if (/^\d+$/.test(target)) {
3107
- await exec2(["wait", target]);
3108
- } else if (target.startsWith("http")) {
3096
+ if (target.startsWith("http")) {
3109
3097
  await exec2(["wait", "--url", target]);
3110
3098
  } else {
3111
3099
  await exec2(["wait", target]);
@@ -3194,14 +3182,6 @@ function createBrowserTool(artifactStore) {
3194
3182
  }
3195
3183
  },
3196
3184
  async execute(args, _context) {
3197
- const available = await isAgentBrowserAvailable();
3198
- if (!available) {
3199
- return {
3200
- toolCallId: "",
3201
- content: "agent-browser is not installed. Run: npm install -g agent-browser && agent-browser install",
3202
- isError: true
3203
- };
3204
- }
3205
3185
  const action = args.action;
3206
3186
  if (action === "close") {
3207
3187
  await closeBrowser();