teapot-coding-agent 0.37.159 → 0.37.161

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.
@@ -245,6 +245,15 @@ export class Agent {
245
245
  pendingSubReport = "";
246
246
  compactPhase = "";
247
247
  awaitingUser = false;
248
+ /**
249
+ * The event id of the question the loop is parked on.
250
+ *
251
+ * The status says `needs_operator`, but the ROW lives in the log and the client only holds the last page of events — so
252
+ * a question that was asked before that window was invisible until the operator scrolled far enough:
253
+ * "タイムラインにask_userが出てないのにneeds_operatorが出てる / しばらくいじいじしてたら出てきた". The id lets the client
254
+ * fetch the page that contains it.
255
+ */
256
+ pendingQuestionId = "";
248
257
  /** when the previous round finished, for the time anchor in harness messages (#194) */
249
258
  lastTurnEndedAt = null;
250
259
  /** the last assistant text, so the loop can tell a context-limit stop from a real one (#201) */
@@ -1246,7 +1255,17 @@ export class Agent {
1246
1255
  ...(this.compactPhase ? { compacting: this.compactPhase } : {}),
1247
1256
  },
1248
1257
  pendingPrompts: this.pendingPrompts.length,
1249
- pendingPromptIds: this.pendingPrompts.map((p) => p.id).filter((x) => !!x).slice(0, 64),
1258
+ /**
1259
+ * The CANCELLABLE set — user prompts only (#141).
1260
+ *
1261
+ * Harness prompts are named too now (they need a row and a count), but they must not appear here: the ✕ cancel is
1262
+ * offered for what this list contains, and a queued harness message is not the operator's to withdraw.
1263
+ */
1264
+ pendingPromptIds: this.pendingPrompts
1265
+ .filter((p) => p.source === "user")
1266
+ .map((p) => p.id)
1267
+ .filter((x) => !!x)
1268
+ .slice(0, 64),
1250
1269
  pendingPromptQueue: this.pendingPrompts
1251
1270
  .filter((p) => !!p.id)
1252
1271
  .slice(0, 64)
@@ -1260,6 +1279,7 @@ export class Agent {
1260
1279
  todo: this.todo.slice(0, 32_000),
1261
1280
  parent: this.opts.parent,
1262
1281
  awaiting: this.awaitingUser,
1282
+ ...(this.awaitingUser && this.pendingQuestionId ? { pendingQuestionId: this.pendingQuestionId } : {}),
1263
1283
  autoContinue: this.opts.autoContinue,
1264
1284
  autoCompact: this.opts.autoCompact,
1265
1285
  };
@@ -1277,8 +1297,18 @@ export class Agent {
1277
1297
  this.activityChars = 0;
1278
1298
  this.turnsSinceProgress = 0;
1279
1299
  }
1280
- const promptId = source === "user" ? `u${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}` : "";
1281
- const entry = { source, text, images, ...(promptId ? { id: promptId } : {}) };
1300
+ /**
1301
+ * EVERY queued prompt gets an id, harness ones included.
1302
+ *
1303
+ * Only user prompts were given one, and the snapshot publishes just the prompts it can name
1304
+ * (`pendingPromptQueue`/`pendingPromptIds` filter on `id`). A queued harness prompt was therefore invisible to the
1305
+ * client — no row, no count — which is the remaining half of "harnessからのメッセージにqueuedがついてない問題が
1306
+ * v0.37.160 でもあった".
1307
+ */
1308
+ const promptId = source === "user"
1309
+ ? `u${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`
1310
+ : `h${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
1311
+ const entry = { source, text, images, id: promptId };
1282
1312
  this.pendingPrompts.push(entry);
1283
1313
  void this.ensureReady()
1284
1314
  .then(async () => {
@@ -1909,11 +1939,12 @@ export class Agent {
1909
1939
  })
1910
1940
  .filter((o) => o.trim())
1911
1941
  : [];
1912
- await this.log.append("question", this.currentSession, this.currentBranch, {
1942
+ const questionEvent = await this.log.append("question", this.currentSession, this.currentBranch, {
1913
1943
  question,
1914
1944
  options,
1915
1945
  callId: call.id,
1916
1946
  });
1947
+ this.pendingQuestionId = questionEvent?.id ?? "";
1917
1948
  await this.answerMeta(call, "question shown to the operator — the loop is parked until they reply. " +
1918
1949
  "Their reply (possibly free text, not one of the options) arrives as your next user message.");
1919
1950
  this.awaitingUser = true;
@@ -2766,7 +2797,7 @@ export class Agent {
2766
2797
  : `The auditor returned no specific gaps. Re-read the verification contract above and re-run it yourself, item by item, before finishing again:\n\n${this.goal.verify?.slice(0, 2000) || this.goal.text.slice(0, 2000)}`;
2767
2798
  const retryText = `[harness] The completion audit REJECTED this finish. Address these gaps, then finish again with goalComplete=true:\n\n${gaps}`;
2768
2799
  if (this.consecutiveAuditRejects < (this.opts.maxAuditRejects ?? 3)) {
2769
- this.pendingPrompts.push({ source: "harness", text: retryText });
2800
+ this.pendingPrompts.push({ source: "harness", text: retryText, id: `h${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}` });
2770
2801
  await this.log.append("prompt", this.currentSession, this.currentBranch, {
2771
2802
  source: "harness",
2772
2803
  text: retryText,
@@ -2808,7 +2839,7 @@ export class Agent {
2808
2839
  `AUDIT, not a finding about your work. Before finishing again, state plainly and briefly what ` +
2809
2840
  `you verified for each item of the contract, so the auditor has something to judge.\n\n` +
2810
2841
  `${this.goal.verify?.slice(0, 2000) || this.goal.text.slice(0, 2000)}`;
2811
- this.pendingPrompts.push({ source: "harness", text });
2842
+ this.pendingPrompts.push({ source: "harness", text, id: `h${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}` });
2812
2843
  void this.log
2813
2844
  .append("prompt", this.currentSession, this.currentBranch, { source: "harness", text })
2814
2845
  .catch(() => { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.159",
3
+ "version": "0.37.161",
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",