@tiens.nguyen/gonext-local-worker 1.0.301 → 1.0.302

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/gonext-repl.mjs +29 -4
  2. package/package.json +1 -1
package/gonext-repl.mjs CHANGED
@@ -1383,11 +1383,15 @@ async function runAgentTurn(history) {
1383
1383
  // > the "almost done" heartbeat > the bare fallback.
1384
1384
  const max = Math.max(24, (process.stdout.columns || 80) - 14);
1385
1385
  const fit = (s) => (s.length > max ? s.slice(0, max - 1) + "…" : s);
1386
+ // Task #104: global (user + coding-URL) OUTPUT-token total, ↓ = generated. Add THIS
1387
+ // turn's in-progress output (latestOutputTokens) to the persisted global so the live
1388
+ // count climbs in real time and matches the web; it's reset to 0 once the turn's total
1389
+ // is POSTed into globalOutputTokens (so it's never double-counted).
1390
+ const liveOutputTotal = globalOutputTokens + latestOutputTokens;
1386
1391
  const tokLabel =
1387
1392
  dim(` · ${fmtTokens(latestCodeTokens)} tok`) +
1388
1393
  orange(` · ${fmtTokens(sessionMaxCodeTokens)} max`) +
1389
- // Task #104: global (user + coding-URL) lifetime OUTPUT-token total, ↓ = generated.
1390
- (globalOutputTokens > 0 ? cyan(` · ↓ ${fmtTokens(globalOutputTokens)}`) : "");
1394
+ (liveOutputTotal > 0 ? cyan(` · ↓ ${fmtTokens(liveOutputTotal)}`) : "");
1391
1395
  // Task #96: the thought line is "clickable" only when the fuller thought has MORE text than
1392
1396
  // fits on line 1 (a live command / bare "Thinking" / a thought that already fits has nothing
1393
1397
  // to reveal). Line 1 (what's happening now): a live command > the model's current Thought >
@@ -1765,6 +1769,9 @@ async function runAgentTurn(history) {
1765
1769
  outputTokensPosted = true;
1766
1770
  void addOutputTokens(resolve(process.cwd()), latestOutputTokens).then((t) => {
1767
1771
  if (t && Number.isFinite(t.globalTotal)) globalOutputTokens = t.globalTotal;
1772
+ // This turn's total is now folded into globalOutputTokens — zero the live
1773
+ // per-turn tally so the ↓ (global + latest) doesn't double-count it.
1774
+ latestOutputTokens = 0;
1768
1775
  });
1769
1776
  }
1770
1777
  // The job can flip to "completed" between polls with authoritative resultText that
@@ -1802,7 +1809,14 @@ async function runAgentTurn(history) {
1802
1809
  }
1803
1810
  }
1804
1811
  clearStatus();
1805
- return { text: answerFrom(text), shown: answerShownLive };
1812
+ // Task #104: expose this turn's code-model INPUT + OUTPUT token totals so the caller
1813
+ // can print a persistent footer at the bottom of the screen.
1814
+ return {
1815
+ text: answerFrom(text),
1816
+ shown: answerShownLive,
1817
+ inputTokens: latestCodeTokens,
1818
+ outputTokens: latestOutputTokens,
1819
+ };
1806
1820
  }
1807
1821
  if (text.length > shownChars) {
1808
1822
  if (seenRaw.length < 4096) {
@@ -2112,7 +2126,8 @@ async function main() {
2112
2126
  }
2113
2127
  history.push({ role: "user", content: taskLine });
2114
2128
  try {
2115
- const { text: answer, shown, cancelled } = await runAgentTurn(history);
2129
+ const { text: answer, shown, cancelled, inputTokens, outputTokens } =
2130
+ await runAgentTurn(history);
2116
2131
  if (answer) {
2117
2132
  history.push({ role: "assistant", content: answer });
2118
2133
  // Persist after every successful turn (not just on clean exit) — an ungraceful
@@ -2122,6 +2137,16 @@ async function main() {
2122
2137
  // A plain-reply answer already streamed live in the loop above — printing it
2123
2138
  // again here would just duplicate it; a blank line is enough for spacing.
2124
2139
  console.log(shown ? "" : `\n\n${answer}\n`);
2140
+ // Task #104: persistent per-turn token footer at the bottom of the screen — the
2141
+ // last turn's code-model INPUT + OUTPUT tokens, kept visible above the next prompt.
2142
+ // Only for turns that actually used the code model (plain-reply greetings = 0/0).
2143
+ if ((inputTokens ?? 0) > 0 || (outputTokens ?? 0) > 0) {
2144
+ console.log(
2145
+ dim(" tokens · in ") +
2146
+ fmtTokens(inputTokens ?? 0) +
2147
+ cyan(` · ↓ out ${fmtTokens(outputTokens ?? 0)}`)
2148
+ );
2149
+ }
2125
2150
  } else {
2126
2151
  history.pop(); // aborted/failed/cancelled turn — don't poison the next request
2127
2152
  // A turn that ended WITHOUT an answer (Ctrl+C cancel, or an abort/failure) must not
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.301",
3
+ "version": "1.0.302",
4
4
  "description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
5
5
  "type": "module",
6
6
  "license": "MIT",