mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
refactor: trim auto reply helper exports
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export type AgentTraceBase = {
|
||||
type AgentTraceBase = {
|
||||
runId?: string;
|
||||
sessionId?: string;
|
||||
sessionKey?: string;
|
||||
|
||||
@@ -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])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,
|
||||
|
||||
@@ -11,10 +11,10 @@ import { resolveUserPath } from "../utils.js";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "./agent-scope.js";
|
||||
import { sanitizeForPromptLiteral } from "./sanitize-for-prompt.js";
|
||||
|
||||
export type WorkspaceFallbackReason = "missing" | "blank" | "invalid_type";
|
||||
type WorkspaceFallbackReason = "missing" | "blank" | "invalid_type";
|
||||
type AgentIdSource = "explicit" | "session_key" | "default";
|
||||
|
||||
export type ResolveRunWorkspaceResult = {
|
||||
type ResolveRunWorkspaceResult = {
|
||||
workspaceDir: string;
|
||||
usedFallback: boolean;
|
||||
fallbackReason?: WorkspaceFallbackReason;
|
||||
|
||||
@@ -25,8 +25,6 @@ function defineDockCommand(plugin: ChannelPlugin): ChatCommandDefinition {
|
||||
|
||||
let cachedCommands: ChatCommandDefinition[] | null = null;
|
||||
let cachedRegistryVersion = -1;
|
||||
let cachedNativeCommandSurfaces: Set<string> | 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<string> {
|
||||
const registryVersion = getActivePluginChannelRegistryVersionFromState();
|
||||
if (cachedNativeCommandSurfaces && registryVersion === cachedNativeRegistryVersion) {
|
||||
return cachedNativeCommandSurfaces;
|
||||
}
|
||||
cachedNativeCommandSurfaces = new Set(
|
||||
listLoadedChannelPlugins()
|
||||
.filter(supportsNativeCommands)
|
||||
.map((plugin) => plugin.id),
|
||||
);
|
||||
cachedNativeRegistryVersion = registryVersion;
|
||||
return cachedNativeCommandSurfaces;
|
||||
}
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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)),
|
||||
);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user