@optima-chat/browser-cli 0.23.0 → 0.24.0

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 +12 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -833,8 +833,18 @@ function parseWaitTimeout(raw) {
833
833
  return n;
834
834
  }
835
835
  function stillRunningMessage(task, waitedS, nowMs = Date.now()) {
836
- const started = task.created_at ? Date.parse(task.created_at) : Number.NaN;
837
- const elapsed = Number.isFinite(started) ? `running for ${Math.max(0, Math.round((nowMs - started) / 1e3))}s` : `waited ${waitedS}s`;
836
+ const secondsSince = (iso) => {
837
+ const t = iso ? Date.parse(iso) : Number.NaN;
838
+ return Number.isFinite(t) ? Math.max(0, Math.round((nowMs - t) / 1e3)) : null;
839
+ };
840
+ const created = secondsSince(task.created_at);
841
+ let elapsed;
842
+ if (task.queue?.queued) {
843
+ elapsed = `queued, ${task.queue.ahead} task(s) of this user ahead` + (created !== null ? `, created ${created}s ago` : "");
844
+ } else {
845
+ const ran = secondsSince(task.queue?.started_at) ?? created;
846
+ elapsed = ran !== null ? `running for ${ran}s` : `waited ${waitedS}s`;
847
+ }
838
848
  const step = task.total_steps ? `, step ${task.current_step}/${task.total_steps}` : "";
839
849
  const waiting = waitingHumanLine(task);
840
850
  return `Still running (${elapsed}${step}). Call again as a separate command: browser-cli script-task ${task.id} --wait` + (waiting ? ` --through-human
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/browser-cli",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {