@@ -8,7 +8,10 @@ import {
|
8 | 8 | isRecord, |
9 | 9 | normalizeOptionalString as readNonEmptyString, |
10 | 10 | } from "openclaw/plugin-sdk/string-coerce-runtime"; |
11 | | -import { createDirectReplyTranscriptSentinelScanner } from "./gateway-log-sentinel.js"; |
| 11 | +import { |
| 12 | +createDirectReplyTranscriptSentinelScanner, |
| 13 | +extractGatewayMessageText, |
| 14 | +} from "./gateway-log-sentinel.js"; |
12 | 15 | import { liveTurnTimeoutMs } from "./suite-runtime-agent-common.js"; |
13 | 16 | import type { |
14 | 17 | QaRawSessionStoreEntry, |
@@ -47,41 +50,6 @@ function isSessionStoreLockTimeout(error: unknown) {
|
47 | 50 | ); |
48 | 51 | } |
49 | 52 | |
50 | | -function extractSessionTranscriptText(message: Record<string, unknown>) { |
51 | | -const rawContent = message.content; |
52 | | -if (typeof rawContent === "string") { |
53 | | -return rawContent.trim(); |
54 | | -} |
55 | | -if (!Array.isArray(rawContent)) { |
56 | | -return ""; |
57 | | -} |
58 | | -const parts: string[] = []; |
59 | | -for (const block of rawContent) { |
60 | | -if (typeof block === "string") { |
61 | | -if (block.trim()) { |
62 | | -parts.push(block.trim()); |
63 | | -} |
64 | | -continue; |
65 | | -} |
66 | | -if (!isRecord(block)) { |
67 | | -continue; |
68 | | -} |
69 | | -const text = readNonEmptyString(block.text); |
70 | | -if (text) { |
71 | | -parts.push(text); |
72 | | -continue; |
73 | | -} |
74 | | -const content = readNonEmptyString(block.content); |
75 | | -if ( |
76 | | -content && |
77 | | -(block.type === "output_text" || block.type === "text" || block.type === "message") |
78 | | -) { |
79 | | -parts.push(content); |
80 | | -} |
81 | | -} |
82 | | -return parts.join("\n").trim(); |
83 | | -} |
84 | | - |
85 | 53 | function readSessionTranscriptLineMessage(line: string) { |
86 | 54 | const trimmed = line.trim(); |
87 | 55 | if (!trimmed) { |
@@ -132,7 +100,7 @@ async function readSessionTranscriptFileSummary(
|
132 | 100 | if (!message || message.role !== "assistant") { |
133 | 101 | return; |
134 | 102 | } |
135 | | -const text = extractSessionTranscriptText(message); |
| 103 | +const text = extractGatewayMessageText(message); |
136 | 104 | if (text) { |
137 | 105 | finalText = text; |
138 | 106 | } |
|