


























@@ -1,3 +1,7 @@
1+/**
2+ * Helper functions for agent attempt execution, Claude CLI transcript probing,
3+ * fallback prompts, and ACP visible-text accumulation.
4+ */
15import fs from "node:fs/promises";
26import path from "node:path";
37import readline from "node:readline";
@@ -83,6 +87,7 @@ export async function sessionFileHasContent(sessionFile: string | undefined): Pr
8387return await jsonlFileHasAssistantMessage(sessionFile);
8488}
858990+/** Resolves the expected Claude CLI transcript JSONL path for a session. */
8691export function claudeCliSessionTranscriptPath(params: {
8792sessionId: string | undefined;
8893workspaceDir: string | undefined;
@@ -108,6 +113,7 @@ export function claudeCliSessionTranscriptPath(params: {
108113const CLAUDE_CLI_TRANSCRIPT_FLUSH_GRACE_MS = 250;
109114const CLAUDE_CLI_ORPHAN_PROBE_TAIL_BYTES = 1024 * 1024;
110115116+/** Checks whether Claude CLI has flushed assistant content for a session. */
111117export async function claudeCliSessionTranscriptHasContent(params: {
112118sessionId: string | undefined;
113119workspaceDir: string | undefined;
@@ -243,6 +249,7 @@ async function jsonlFileHasOrphanedTrailingToolUse(filePath: string): Promise<bo
243249}
244250}
245251252+/** Checks whether the latest Claude CLI transcript tail has unanswered tool use. */
246253export async function claudeCliSessionTranscriptHasOrphanedToolUse(params: {
247254sessionId: string | undefined;
248255workspaceDir: string | undefined;
@@ -259,6 +266,7 @@ export async function claudeCliSessionTranscriptHasOrphanedToolUse(params: {
259266return await jsonlFileHasOrphanedTrailingToolUse(expectedPath);
260267}
261268269+/** Builds the retry prompt sent to fallback models after a failed attempt. */
262270export function resolveFallbackRetryPrompt(params: {
263271body: string;
264272isFallbackRetry: boolean;
@@ -435,6 +443,7 @@ export function buildClaudeCliFallbackContextPrelude(params: {
435443return formatClaudeCliFallbackPrelude(seed, { charBudget: params.charBudget });
436444}
437445446+/** Creates an accumulator that strips ACP silent-reply prefixes while streaming. */
438447export function createAcpVisibleTextAccumulator() {
439448let pendingSilentPrefix = "";
440449let visibleText = "";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。