From 82e8518bd7b57b559e40eb17ea3eed41907ccc00 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 1 May 2026 22:01:50 +0100 Subject: [PATCH] refactor: trim auto reply helper exports --- src/agents/trace-base.ts | 2 +- src/agents/transport-stream-shared.ts | 2 +- src/agents/workspace-run.ts | 4 ++-- src/auto-reply/commands-registry.data.ts | 17 ----------------- src/auto-reply/commands-registry.shared.ts | 6 +----- src/auto-reply/fallback-state.ts | 6 +++--- src/auto-reply/heartbeat-tool-response.ts | 4 ++-- src/auto-reply/send-policy.ts | 2 +- src/auto-reply/tokens.ts | 2 +- 9 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/agents/trace-base.ts b/src/agents/trace-base.ts index 5b6ecefac77..d19b2474311 100644 --- a/src/agents/trace-base.ts +++ b/src/agents/trace-base.ts @@ -1,4 +1,4 @@ -export type AgentTraceBase = { +type AgentTraceBase = { runId?: string; sessionId?: string; sessionKey?: string; diff --git a/src/agents/transport-stream-shared.ts b/src/agents/transport-stream-shared.ts index 08a72bb6a75..9133f6ba572 100644 --- a/src/agents/transport-stream-shared.ts +++ b/src/agents/transport-stream-shared.ts @@ -19,7 +19,7 @@ type TransportOutputShape = { errorMessage?: string; }; -export const EMPTY_TOOL_RESULT_TEXT = "(no output)"; +const EMPTY_TOOL_RESULT_TEXT = "(no output)"; export function sanitizeTransportPayloadText(text: string): string { return text.replace( /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(? | null = null; -let cachedNativeRegistryVersion = -1; function buildChatCommands(): ChatCommandDefinition[] { const commands: ChatCommandDefinition[] = [ @@ -48,20 +46,5 @@ export function getChatCommands(): ChatCommandDefinition[] { const commands = buildChatCommands(); cachedCommands = commands; cachedRegistryVersion = registryVersion; - cachedNativeCommandSurfaces = null; return commands; } - -export function getNativeCommandSurfaces(): Set { - const registryVersion = getActivePluginChannelRegistryVersionFromState(); - if (cachedNativeCommandSurfaces && registryVersion === cachedNativeRegistryVersion) { - return cachedNativeCommandSurfaces; - } - cachedNativeCommandSurfaces = new Set( - listLoadedChannelPlugins() - .filter(supportsNativeCommands) - .map((plugin) => plugin.id), - ); - cachedNativeRegistryVersion = registryVersion; - return cachedNativeCommandSurfaces; -} diff --git a/src/auto-reply/commands-registry.shared.ts b/src/auto-reply/commands-registry.shared.ts index fe20ade6ba0..3410e9ee7b6 100644 --- a/src/auto-reply/commands-registry.shared.ts +++ b/src/auto-reply/commands-registry.shared.ts @@ -49,11 +49,7 @@ export function defineChatCommand(command: DefineChatCommandInput): ChatCommandD }; } -export function registerAlias( - commands: ChatCommandDefinition[], - key: string, - ...aliases: string[] -): void { +function registerAlias(commands: ChatCommandDefinition[], key: string, ...aliases: string[]): void { const command = commands.find((entry) => entry.key === key); if (!command) { throw new Error(`registerAlias: unknown command key: ${key}`); diff --git a/src/auto-reply/fallback-state.ts b/src/auto-reply/fallback-state.ts index 8145c6abea3..53a7750463e 100644 --- a/src/auto-reply/fallback-state.ts +++ b/src/auto-reply/fallback-state.ts @@ -49,7 +49,7 @@ function formatFallbackAttemptErrorPreview(attempt: RuntimeFallbackAttempt): str return formatted; } -export function formatFallbackAttemptReason(attempt: RuntimeFallbackAttempt): string { +function formatFallbackAttemptReason(attempt: RuntimeFallbackAttempt): string { const errorPreview = formatFallbackAttemptErrorPreview(attempt); if (errorPreview) { return errorPreview; @@ -72,7 +72,7 @@ function formatFallbackAttemptSummary(attempt: RuntimeFallbackAttempt): string { return `${formatProviderModelRef(attempt.provider, attempt.model)} ${formatFallbackAttemptReason(attempt)}`; } -export function buildFallbackReasonSummary(attempts: RuntimeFallbackAttempt[]): string { +function buildFallbackReasonSummary(attempts: RuntimeFallbackAttempt[]): string { const firstAttempt = attempts[0]; const firstReason = firstAttempt ? formatFallbackAttemptReason(firstAttempt) @@ -81,7 +81,7 @@ export function buildFallbackReasonSummary(attempts: RuntimeFallbackAttempt[]): return `${truncateFallbackReasonPart(firstReason)}${moreAttempts}`; } -export function buildFallbackAttemptSummaries(attempts: RuntimeFallbackAttempt[]): string[] { +function buildFallbackAttemptSummaries(attempts: RuntimeFallbackAttempt[]): string[] { return attempts.map((attempt) => truncateFallbackReasonPart(formatFallbackAttemptSummary(attempt)), ); diff --git a/src/auto-reply/heartbeat-tool-response.ts b/src/auto-reply/heartbeat-tool-response.ts index 9cc9eda3603..3f28591b922 100644 --- a/src/auto-reply/heartbeat-tool-response.ts +++ b/src/auto-reply/heartbeat-tool-response.ts @@ -2,7 +2,7 @@ import type { ReplyPayload } from "./reply-payload.js"; import { HEARTBEAT_TOKEN } from "./tokens.js"; export const HEARTBEAT_RESPONSE_TOOL_NAME = "heartbeat_respond"; -export const HEARTBEAT_RESPONSE_CHANNEL_DATA_KEY = "openclawHeartbeatResponse"; +const HEARTBEAT_RESPONSE_CHANNEL_DATA_KEY = "openclawHeartbeatResponse"; export const HEARTBEAT_TOOL_OUTCOMES = [ "no_change", @@ -98,7 +98,7 @@ export function createHeartbeatToolResponsePayload(response: HeartbeatToolRespon }; } -export function getHeartbeatToolResponseFromPayload( +function getHeartbeatToolResponseFromPayload( payload: ReplyPayload | undefined, ): HeartbeatToolResponse | undefined { return normalizeHeartbeatToolResponse( diff --git a/src/auto-reply/send-policy.ts b/src/auto-reply/send-policy.ts index bf2e1671b64..7705e313b96 100644 --- a/src/auto-reply/send-policy.ts +++ b/src/auto-reply/send-policy.ts @@ -4,7 +4,7 @@ import { stripInboundMetadata } from "./reply/strip-inbound-meta.js"; export type SendPolicyOverride = "allow" | "deny"; -export function normalizeSendPolicyOverride(raw?: string | null): SendPolicyOverride | undefined { +function normalizeSendPolicyOverride(raw?: string | null): SendPolicyOverride | undefined { const value = normalizeOptionalLowercaseString(raw); if (!value) { return undefined; diff --git a/src/auto-reply/tokens.ts b/src/auto-reply/tokens.ts index d6f32fabeb6..c1fbbe2cf12 100644 --- a/src/auto-reply/tokens.ts +++ b/src/auto-reply/tokens.ts @@ -43,7 +43,7 @@ export function isSilentReplyText( type SilentReplyActionEnvelope = { action?: unknown }; -export function isSilentReplyEnvelopeText( +function isSilentReplyEnvelopeText( text: string | undefined, token: string = SILENT_REPLY_TOKEN, ): boolean {