@keyou007/agent-bot 0.1.16-alpha.1 → 0.1.16-alpha.3

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.
@@ -1900,18 +1900,20 @@ export class ProxySessionController {
1900
1900
  }
1901
1901
  async presentPromptQueueCard(localSessionId, contextKey) {
1902
1902
  await this.serializePromptQueueCardWrite(localSessionId, async () => {
1903
- const card = this.renderPromptQueueCard(localSessionId, contextKey);
1904
- const existing = this.queuedPromptCards.get(localSessionId)?.get(contextKey);
1903
+ const cards = this.queuedPromptCards.get(localSessionId);
1904
+ const existing = cards?.get(contextKey);
1905
1905
  if (existing) {
1906
1906
  try {
1907
- await this.outbound.updateInteractiveCard(contextKey, existing, card);
1908
- return;
1907
+ await this.outbound.updateInteractiveCard(contextKey, existing, this.renderPromptQueueCard(localSessionId, contextKey, "superseded"));
1909
1908
  }
1910
1909
  catch (error) {
1911
- this.logger.warn({ error, localSessionId, contextKey, messageId: existing }, "Failed to update prompt queue card; sending a replacement.");
1910
+ this.logger.warn({ error, localSessionId, contextKey, messageId: existing }, "Failed to stop the previous prompt queue card; sending a replacement.");
1912
1911
  }
1912
+ cards?.delete(contextKey);
1913
+ if (cards?.size === 0)
1914
+ this.queuedPromptCards.delete(localSessionId);
1913
1915
  }
1914
- const messageId = await this.outbound.sendInteractiveCard(contextKey, card);
1916
+ const messageId = await this.outbound.sendInteractiveCard(contextKey, this.renderPromptQueueCard(localSessionId, contextKey));
1915
1917
  if (messageId)
1916
1918
  this.rememberPromptQueueCard(localSessionId, contextKey, messageId);
1917
1919
  });
@@ -1931,10 +1933,11 @@ export class ProxySessionController {
1931
1933
  }));
1932
1934
  });
1933
1935
  }
1934
- renderPromptQueueCard(localSessionId, contextKey) {
1936
+ renderPromptQueueCard(localSessionId, contextKey, phase = "active") {
1935
1937
  return this.cardRenderer.renderPromptQueue({
1936
1938
  sessionId: localSessionId,
1937
1939
  contextKey,
1940
+ phase,
1938
1941
  prompts: this.store.listQueuedPrompts(localSessionId).map((prompt) => ({
1939
1942
  id: prompt.promptId,
1940
1943
  text: prompt.displayPrompt ?? prompt.text,
@@ -3794,7 +3797,43 @@ export class ProxySessionController {
3794
3797
  if (!current.remoteSessionId || !this.isCodexSession(current)) {
3795
3798
  throw new Error("当前任务不是可 Reset 的 App Server 任务。");
3796
3799
  }
3797
- const allTurns = this.store.listTaskTurnGraph(current.localSessionId);
3800
+ const completedTurns = this.store.listTaskTurnGraph(current.localSessionId);
3801
+ const completedTurnIds = new Set(completedTurns.map((turn) => turn.turnId));
3802
+ const runningTurnId = current.lastTurnStatus === "running" && current.lastTurnId
3803
+ && !completedTurnIds.has(current.lastTurnId)
3804
+ ? current.lastTurnId
3805
+ : undefined;
3806
+ const persistedRunningSnapshot = runningTurnId
3807
+ ? turnViewSnapshot(this.store.getTurnSnapshot(runningTurnId))
3808
+ : undefined;
3809
+ const runningAttempt = runningTurnId
3810
+ ? this.store.findIncompleteTurnAttemptByTurnId(runningTurnId)
3811
+ : undefined;
3812
+ const attemptStartedAt = Date.parse(runningAttempt?.createdAt ?? "");
3813
+ const runningSnapshot = runningTurnId
3814
+ ? persistedRunningSnapshot ?? {
3815
+ sessionId: current.localSessionId,
3816
+ turnId: runningTurnId,
3817
+ prompt: runningAttempt?.promptText ?? current.title,
3818
+ status: "running",
3819
+ startedAt: Number.isFinite(attemptStartedAt) ? attemptStartedAt : Date.now(),
3820
+ assistantText: "",
3821
+ plan: [],
3822
+ activities: [],
3823
+ completedTools: [],
3824
+ failedTools: [],
3825
+ fileSummary: [],
3826
+ }
3827
+ : undefined;
3828
+ const runningTurn = runningTurnId && runningSnapshot
3829
+ ? {
3830
+ turnId: runningTurnId,
3831
+ parentTurnId: this.store.getTurnParent(runningTurnId, current.localSessionId),
3832
+ snapshot: runningSnapshot,
3833
+ updatedAt: runningAttempt?.updatedAt ?? new Date(runningSnapshot.startedAt).toISOString(),
3834
+ }
3835
+ : undefined;
3836
+ const allTurns = runningTurn ? [runningTurn, ...completedTurns] : completedTurns;
3798
3837
  const graphRows = buildTurnGraphRows(allTurns.map((turn) => ({
3799
3838
  turnId: turn.turnId,
3800
3839
  parentTurnId: turn.parentTurnId,
@@ -3811,16 +3850,18 @@ export class ProxySessionController {
3811
3850
  const graph = graphRows[offset + index];
3812
3851
  const summary = truncateText((snapshot.prompt ?? snapshot.taskTitle ?? "未记录对话内容").replace(/\s+/g, " ").trim(), 100);
3813
3852
  const isCurrent = current.lastTurnId === turn.turnId && current.lastTurnStatus === "completed";
3853
+ const isRunning = runningTurnId === turn.turnId;
3814
3854
  return [{
3815
3855
  sequence: graph.sequence,
3816
3856
  graphNodeLine: graph.nodeLine,
3817
3857
  graphConnectorLine: graph.connectorLine,
3818
3858
  lines: [
3819
- `**${cardText(summary || "未记录对话内容")}**`,
3820
- `${formatResetTurnTime(snapshot.completedAt ?? snapshot.startedAt)} · ${cardCode(turn.turnId)}`,
3859
+ cardText(summary || "未记录对话内容"),
3860
+ `${formatResetTurnTime(snapshot.completedAt ?? snapshot.startedAt)} · ${cardText(turn.turnId)}`,
3821
3861
  ],
3822
3862
  current: isCurrent,
3823
- actions: isCurrent ? undefined : [{
3863
+ running: isRunning,
3864
+ actions: isCurrent || isRunning ? undefined : [{
3824
3865
  text: "Reset",
3825
3866
  value: {
3826
3867
  action: "turn_reset",
@@ -3856,7 +3897,9 @@ export class ProxySessionController {
3856
3897
  const card = this.cardRenderer.renderResetHistoryCard({
3857
3898
  entries,
3858
3899
  footerLines: [
3859
- `第 ${page + 1}/${totalPages} 页 · 共 ${total} 个已完成 turn`,
3900
+ runningTurn
3901
+ ? `第 ${page + 1}/${totalPages} 页 · 共 ${total} 个 turn(${completedTurns.length} 个已完成,1 个运行中)`
3902
+ : `第 ${page + 1}/${totalPages} 页 · 共 ${total} 个已完成 turn`,
3860
3903
  ],
3861
3904
  pageActions,
3862
3905
  });
@@ -4199,8 +4242,8 @@ export class ProxySessionController {
4199
4242
  reference: entry.reference,
4200
4243
  summary: `${offset + index + 1}. ${marker}${title} · ${entry.agentName}`,
4201
4244
  detailLines: [
4202
- cardText(lastUserPrompt),
4203
- `**更新时间**:${cardText(entry.updatedLabel)}`,
4245
+ `**最新 Prompt**:${cardText(lastUserPrompt)}`,
4246
+ `<font color='grey'>最近更新:${cardText(entry.updatedLabel)}</font>`,
4204
4247
  ],
4205
4248
  actions,
4206
4249
  current: entry.current,