@optima-chat/browser-cli 0.15.1 → 0.15.3

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 -4
  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,14 +821,14 @@ 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}`;
824
828
  }
825
829
  function hasStagedArtifact(task) {
826
830
  const output = task.output;
827
- return task.status === "completed" && !!output?.artifact_path;
831
+ return !!output?.artifact_path;
828
832
  }
829
833
  function downloadHint(task) {
830
834
  const filename = task.output?.filename;
@@ -960,6 +964,9 @@ function registerScriptCommands(program2) {
960
964
  saveSessionId(result.session_id);
961
965
  }
962
966
  console.log(formatScriptTask(result));
967
+ if (result.status !== "completed" && hasStagedArtifact(result)) {
968
+ console.log(downloadHint(result));
969
+ }
963
970
  if (result.status === "completed") {
964
971
  try {
965
972
  const saved = await deliverArtifact(result, opts.out);
@@ -988,7 +995,7 @@ ${downloadHint(result)}`);
988
995
  if (hasStagedArtifact(task)) console.log(downloadHint(task));
989
996
  return;
990
997
  }
991
- if (task.status !== "completed") {
998
+ if (task.status === "running") {
992
999
  throw new Error(`Task ${taskId} is ${task.status} \u2014 nothing to download yet`);
993
1000
  }
994
1001
  const saved = await deliverArtifact(task, typeof opts.download === "string" ? opts.download : void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/browser-cli",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {