@tiens.nguyen/gonext-local-worker 1.0.315 → 1.0.317

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 +28 -9
  2. package/package.json +1 -1
package/gonext-repl.mjs CHANGED
@@ -1182,6 +1182,10 @@ let jobIdForApprovalRace = "";
1182
1182
  // Per-session coding-model override chosen via /model (empty = use the account default).
1183
1183
  // Sent to /agent-ask as codingModelOverride; the API validates it against the whitelist.
1184
1184
  let sessionCodingModel = "";
1185
+ // The default coding model id (from the startup agent-payload probe) — shown in the
1186
+ // per-turn token footer next to the GLOBAL output total so it's clear which model that
1187
+ // lifetime count belongs to. The /model override (sessionCodingModel) wins when set.
1188
+ let defaultCodingModel = "";
1185
1189
  // Auto-test mode (/test-auto): when on, the agent verifies its work (build/run/curl/…)
1186
1190
  // and fixes → re-tests until it passes before finishing. Default off; remembered per
1187
1191
  // folder in the session file; sent to /agent-ask as autoTest so python drives the loop.
@@ -1937,13 +1941,20 @@ async function runAgentTurn(history) {
1937
1941
  }
1938
1942
  }
1939
1943
  clearStatus();
1940
- // Task #104: expose this turn's code-model INPUT + OUTPUT token totals so the caller
1941
- // can print a persistent footer at the bottom of the screen.
1944
+ // Task #104: expose this turn's code-model INPUT + the CUMULATIVE output-token
1945
+ // total (all turns for this user + coding server) so the caller can print a
1946
+ // persistent footer. Output is the running total (globalOutputTokens already holds
1947
+ // every prior turn; latestOutputTokens is THIS turn, not yet folded in because the
1948
+ // addOutputTokens POST above is async) — the same figure the live "↓" showed during
1949
+ // the turn, so it doesn't drop back to just this turn's count at the prompt (#112).
1950
+ // `turnOutputTokens` is kept separately so the caller's footer guard reflects whether
1951
+ // THIS turn used the code model (a plain-reply greeting = 0 → no footer).
1942
1952
  return {
1943
1953
  text: answerFrom(text),
1944
1954
  shown: answerShownLive,
1945
1955
  inputTokens: latestCodeTokens,
1946
- outputTokens: latestOutputTokens,
1956
+ outputTokens: globalOutputTokens + latestOutputTokens,
1957
+ turnOutputTokens: latestOutputTokens,
1947
1958
  };
1948
1959
  }
1949
1960
  if (text.length > shownChars) {
@@ -2053,6 +2064,8 @@ async function main() {
2053
2064
  try {
2054
2065
  const probe = await fetchAgentPayload([{ role: "user", content: "ping" }]);
2055
2066
  const p = probe?.payload ?? {};
2067
+ // Remember the default coder id for the token footer's global-total label.
2068
+ if (p.codingModelId) defaultCodingModel = p.codingModelId;
2056
2069
  // RAG storage choice (task #97): ask ONCE per folder, and only when RAG is actually
2057
2070
  // enabled in Settings. Default Yes = LOCAL (kept on this machine, no S3 needed).
2058
2071
  if (p.ragEnabled && sessionRagMode === null) {
@@ -2270,7 +2283,7 @@ async function main() {
2270
2283
  }
2271
2284
  history.push({ role: "user", content: taskLine });
2272
2285
  try {
2273
- const { text: answer, shown, cancelled, inputTokens, outputTokens } =
2286
+ const { text: answer, shown, cancelled, inputTokens, outputTokens, turnOutputTokens } =
2274
2287
  await runAgentTurn(history);
2275
2288
  if (answer) {
2276
2289
  history.push({ role: "assistant", content: answer });
@@ -2281,15 +2294,21 @@ async function main() {
2281
2294
  // A plain-reply answer already streamed live in the loop above — printing it
2282
2295
  // again here would just duplicate it; a blank line is enough for spacing.
2283
2296
  console.log(shown ? "" : `\n\n${answer}\n`);
2284
- // Task #104: persistent per-turn token footer at the bottom of the screen — the
2285
- // last turn's code-model INPUT + OUTPUT tokens, kept visible above the next prompt.
2286
- // Only for turns that actually used the code model (plain-reply greetings = 0/0).
2287
- if ((inputTokens ?? 0) > 0 || (outputTokens ?? 0) > 0) {
2297
+ // Task #104: persistent token footer at the bottom of the screen — this turn's
2298
+ // code-model INPUT + this turn's OUTPUT (↓ out), then the model's GLOBAL lifetime
2299
+ // output total (all turns for this user + coding server), labelled with the model
2300
+ // name so it's clear which coder that running total belongs to. Guard on THIS turn's
2301
+ // activity so a plain-reply greeting that did no code-model work shows nothing (#112).
2302
+ if ((inputTokens ?? 0) > 0 || (turnOutputTokens ?? 0) > 0) {
2303
+ const coder = sessionCodingModel || defaultCodingModel;
2288
2304
  console.log(
2289
2305
  dim("tokens · ↑ in ") +
2290
2306
  fmtTokens(inputTokens ?? 0) +
2291
2307
  dim(" · ") +
2292
- cyan(`↓ out ${fmtTokens(outputTokens ?? 0)}`)
2308
+ cyan(`↓ out ${fmtTokens(turnOutputTokens ?? 0)}`) +
2309
+ dim(" · ") +
2310
+ dim(`${coder ? coder + " " : ""}total `) +
2311
+ cyan(`↓ ${fmtTokens(outputTokens ?? 0)}`)
2293
2312
  );
2294
2313
  }
2295
2314
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.315",
3
+ "version": "1.0.317",
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",