@optima-chat/browser-cli 0.15.2 → 0.15.4

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -773,7 +773,7 @@ function registerTabCommands(program2) {
773
773
  // src/commands/script.ts
774
774
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, statSync, writeFileSync as writeFileSync3 } from "fs";
775
775
  import { tmpdir } from "os";
776
- import { basename, dirname, join as join3, resolve } from "path";
776
+ import { basename, dirname, isAbsolute, join as join3, relative, resolve } from "path";
777
777
  var POLL_INTERVAL_MS = 2e3;
778
778
  var POLL_TIMEOUT_MS = 18e4;
779
779
  var REQUIRED_ARG_FLAG = {
@@ -789,6 +789,10 @@ function formatRequiredArgs(s) {
789
789
  var ArtifactLostError = class extends Error {
790
790
  };
791
791
  var errMsg = (err) => err instanceof Error ? err.message : String(err);
792
+ function displayPath(abs) {
793
+ const rel = relative(process.cwd(), abs);
794
+ return rel && !rel.startsWith("..") && !isAbsolute(rel) ? `./${rel}` : abs;
795
+ }
792
796
  function resolveArtifactTarget(out, name) {
793
797
  if (!out) return resolve(`./${name}`);
794
798
  const wantsDir = /[\\/]$/.test(out) || existsSync3(out) && statSync(out).isDirectory();
@@ -817,7 +821,7 @@ async function deliverArtifact(task, out) {
817
821
  console.error(`Could not write ${target} (${errMsg(err)}); saved to ${fallback} instead`);
818
822
  return { path: fallback, size: content.length };
819
823
  }
820
- return { path: target, size: content.length };
824
+ return { path: displayPath(target), size: content.length };
821
825
  }
822
826
  function artifactUrl(artifactPath) {
823
827
  return `${BROWSER_API_URL}${artifactPath}`;
@@ -883,7 +887,10 @@ function formatScriptTask(task) {
883
887
  }
884
888
  lines.push("");
885
889
  }
886
- lines.push("Session is still open \u2014 use browser-cli dom/click/input to continue");
890
+ const sid = task.session_id;
891
+ lines.push(
892
+ sid ? `Session ${sid} may still be open \u2014 continue with browser-cli --session ${sid} dom/click/input, or free it with browser-cli --session ${sid} close` : "Session id not reported \u2014 if one remains, close it by id: browser-cli --session <id> close"
893
+ );
887
894
  } else if (task.status === "failed") {
888
895
  lines.push(`\u2717 Script failed: ${task.error ?? "unknown error"}`);
889
896
  } else {
@@ -986,6 +993,7 @@ ${downloadHint(result)}`);
986
993
  program2.command("script-task").argument("<task-id>", "Task ID").description("Check script task status").option("--download [path]", "Save the task's exported file (default: ./<filename>)").action(async (taskId, opts) => {
987
994
  try {
988
995
  const task = await api.getScriptTask(taskId);
996
+ if (task.status === "needs_fallback" && task.session_id) saveSessionId(task.session_id);
989
997
  if (opts.download === void 0) {
990
998
  console.log(formatScriptTask(task));
991
999
  if (hasStagedArtifact(task)) console.log(downloadHint(task));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/browser-cli",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {