teapot-coding-agent 0.37.165 → 0.37.166

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.
@@ -228,6 +228,22 @@ export class Agent {
228
228
  return this.opts.provider;
229
229
  }
230
230
  pendingPrompts = [];
231
+ /**
232
+ * Will this prompt WAIT, and behind how much? The server's answer, because only the server knows.
233
+ *
234
+ * The client used to decide from a snapshot it happened to hold (`pendingPrompts`, which lags) and from its own
235
+ * leftover echoes, and MEASURED that as the surviving half of "idle状態でプロンプトを送っても一瞬queuedになる問題":
236
+ * a prompt to an idle agent still flickered "queued…". A prompt waits behind the prompts already queued and behind a
237
+ * turn that is still running — nothing else.
238
+ */
239
+ pendingAheadOf(id) {
240
+ const idx = this.pendingPrompts.findIndex((p) => p.id === id);
241
+ if (idx < 0)
242
+ return 0;
243
+ const queuedAhead = idx;
244
+ const turnRunning = this.status === "running" ? 1 : 0;
245
+ return queuedAhead + (queuedAhead === 0 ? turnRunning : 0);
246
+ }
231
247
  stopRequested = false;
232
248
  windDownRequested = false;
233
249
  wake = null;
@@ -871,9 +871,15 @@ export function buildApp(master) {
871
871
  const text = body.text ?? "";
872
872
  const src = body.source === "harness" ? "harness" : "user";
873
873
  const promptId = a.enqueuePrompt(text || "(see attached image)", src, images.length ? images : undefined, body.clientId);
874
+ /**
875
+ * `ahead` is the answer the client draws "queued…" from — computed BEFORE `start()` flips the status, so a prompt
876
+ * that starts the agent reports 0 and never blinks queued. `queued` (a count taken after the enqueue, so always ≥ 1)
877
+ * stays for the API's older callers but is not what the row uses any more.
878
+ */
879
+ const ahead = a.pendingAheadOf(promptId);
874
880
  if (body.start !== false && a.status !== "running")
875
881
  a.start("prompt");
876
- return c.json({ ok: true, promptId, queued: a.snapshot().pendingPrompts });
882
+ return c.json({ ok: true, promptId, ahead, queued: a.snapshot().pendingPrompts });
877
883
  });
878
884
  /**
879
885
  * Force-load and follow a skill.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.165",
3
+ "version": "0.37.166",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",