@@ -19,6 +19,7 @@ import {
|
19 | 19 | hasVisibleStreamParts, |
20 | 20 | historyReplacedVisibleStream, |
21 | 21 | materializeVisibleStreamState, |
| 22 | +messageTimestampMs, |
22 | 23 | maybeResetToolStream, |
23 | 24 | persistedCurrentToolStreamIds, |
24 | 25 | prunePersistedToolStreamMessages, |
@@ -31,6 +32,7 @@ import {
|
31 | 32 | recordControlUiPerformanceEvent, |
32 | 33 | roundedControlUiDurationMs, |
33 | 34 | } from "../control-ui-performance.ts"; |
| 35 | +import { isGatewayMethodAdvertised } from "../gateway-methods.ts"; |
34 | 36 | import { GatewayRequestError, type GatewayBrowserClient, type GatewayHelloOk } from "../gateway.ts"; |
35 | 37 | import { |
36 | 38 | areUiSessionKeysEquivalent, |
@@ -52,6 +54,8 @@ import {
|
52 | 54 | isMissingOperatorReadScopeError, |
53 | 55 | } from "./scope-errors.ts"; |
54 | 56 | |
| 57 | +export { isGatewayMethodAdvertised } from "../gateway-methods.ts"; |
| 58 | + |
55 | 59 | const SILENT_REPLY_PATTERN = /^\s*NO_REPLY\s*$/; |
56 | 60 | const SYNTHETIC_TRANSCRIPT_REPAIR_RESULT = |
57 | 61 | "[openclaw] missing tool result in session history; inserted synthetic error result for transcript repair."; |
@@ -241,18 +245,6 @@ function messageDisplaySignature(message: unknown): string | null {
|
241 | 245 | } |
242 | 246 | } |
243 | 247 | |
244 | | -function messageTimestampMs(message: unknown): number | null { |
245 | | -if (!message || typeof message !== "object") { |
246 | | -return null; |
247 | | -} |
248 | | -const timestamp = (message as { timestamp?: unknown; ts?: unknown }).timestamp; |
249 | | -if (typeof timestamp === "number" && Number.isFinite(timestamp)) { |
250 | | -return timestamp; |
251 | | -} |
252 | | -const ts = (message as { timestamp?: unknown; ts?: unknown }).ts; |
253 | | -return typeof ts === "number" && Number.isFinite(ts) ? ts : null; |
254 | | -} |
255 | | - |
256 | 248 | function historyHasSameOrNewerDisplayMessage( |
257 | 249 | historyMessages: unknown[], |
258 | 250 | signature: string, |
@@ -375,14 +367,6 @@ function isUnknownGatewayMethodError(err: unknown, method: string): err is Gatew
|
375 | 367 | ); |
376 | 368 | } |
377 | 369 | |
378 | | -export function isGatewayMethodAdvertised(state: ChatState, method: string): boolean | null { |
379 | | -const methods = state.hello?.features?.methods; |
380 | | -if (!Array.isArray(methods)) { |
381 | | -return null; |
382 | | -} |
383 | | -return methods.includes(method); |
384 | | -} |
385 | | - |
386 | 370 | function resolveStartupRetryDelayMs(err: GatewayRequestError): number { |
387 | 371 | const retryAfterMs = |
388 | 372 | typeof err.retryAfterMs === "number" ? err.retryAfterMs : STARTUP_CHAT_HISTORY_DEFAULT_RETRY_MS; |
|