mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:20:43 +00:00
refactor: hide command helper internals
This commit is contained in:
@@ -15,7 +15,7 @@ export interface ExportCommandSessionTarget {
|
||||
sessionFile: string;
|
||||
}
|
||||
|
||||
export const MAX_EXPORT_COMMAND_OUTPUT_PATH_CHARS = 512;
|
||||
const MAX_EXPORT_COMMAND_OUTPUT_PATH_CHARS = 512;
|
||||
|
||||
function escapeRegExp(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
|
||||
@@ -78,7 +78,7 @@ function formatVisibleTask(task: TaskRecord, index: number): string {
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
export function buildTasksText(params: { sessionKey: string; agentId: string }): string {
|
||||
function buildTasksText(params: { sessionKey: string; agentId: string }): string {
|
||||
const sessionSnapshot = buildTaskStatusSnapshot(
|
||||
listTasksForSessionKeyForStatus(params.sessionKey),
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ export const formatDirectiveAck = (text: string): string => {
|
||||
return prefixSystemMessage(text);
|
||||
};
|
||||
|
||||
export const formatOptionsLine = (options: string) => `Options: ${options}.`;
|
||||
const formatOptionsLine = (options: string) => `Options: ${options}.`;
|
||||
export const withOptions = (line: string, options: string) =>
|
||||
`${line}\n${formatOptionsLine(options)}`;
|
||||
|
||||
@@ -41,7 +41,7 @@ function canPersistInternalDirective(params: {
|
||||
export const canPersistInternalExecDirective = canPersistInternalDirective;
|
||||
export const canPersistInternalVerboseDirective = canPersistInternalDirective;
|
||||
|
||||
export const formatElevatedEvent = (level: ElevatedLevel) => {
|
||||
const formatElevatedEvent = (level: ElevatedLevel) => {
|
||||
if (level === "full") {
|
||||
return "Elevated FULL - exec runs on host with auto-approval.";
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export const formatElevatedEvent = (level: ElevatedLevel) => {
|
||||
return "Elevated OFF - exec stays in sandbox.";
|
||||
};
|
||||
|
||||
export const formatReasoningEvent = (level: ReasoningLevel) => {
|
||||
const formatReasoningEvent = (level: ReasoningLevel) => {
|
||||
if (level === "stream") {
|
||||
return "Reasoning STREAM - emit live <think>.";
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export function withFullRuntimeReplyConfig<T extends OpenClawConfig>(config: T):
|
||||
return markCompleteReplyConfig(config, { runtimeMode: "full" });
|
||||
}
|
||||
|
||||
export function isCompleteReplyConfig(config: unknown): config is OpenClawConfig {
|
||||
function isCompleteReplyConfig(config: unknown): config is OpenClawConfig {
|
||||
return Boolean(
|
||||
config &&
|
||||
typeof config === "object" &&
|
||||
@@ -86,7 +86,7 @@ export function isCompleteReplyConfig(config: unknown): config is OpenClawConfig
|
||||
);
|
||||
}
|
||||
|
||||
export function usesFullReplyRuntime(config: unknown): boolean {
|
||||
function usesFullReplyRuntime(config: unknown): boolean {
|
||||
return Boolean(
|
||||
config &&
|
||||
typeof config === "object" &&
|
||||
|
||||
@@ -4,7 +4,7 @@ export const HISTORY_CONTEXT_MARKER = "[Chat messages since your last reply - fo
|
||||
export const DEFAULT_GROUP_HISTORY_LIMIT = 50;
|
||||
|
||||
/** Maximum number of group history keys to retain (LRU eviction when exceeded). */
|
||||
export const MAX_HISTORY_KEYS = 1000;
|
||||
const MAX_HISTORY_KEYS = 1000;
|
||||
|
||||
/**
|
||||
* Evict oldest keys from a history map when it exceeds MAX_HISTORY_KEYS.
|
||||
|
||||
@@ -18,7 +18,7 @@ export function normalizeCommandDescriptorName(name: string): string | null {
|
||||
return SAFE_COMMAND_NAME_PATTERN.test(normalized) ? normalized : null;
|
||||
}
|
||||
|
||||
export function assertSafeCommandDescriptorName(name: string): string {
|
||||
function assertSafeCommandDescriptorName(name: string): string {
|
||||
const normalized = normalizeCommandDescriptorName(name);
|
||||
if (!normalized) {
|
||||
throw new Error(`Invalid CLI command name: ${JSON.stringify(name.trim())}`);
|
||||
|
||||
@@ -43,10 +43,7 @@ export function setCommandJsonMode(command: Command, mode: JsonMode): Command {
|
||||
return command;
|
||||
}
|
||||
|
||||
export function getCommandJsonMode(
|
||||
command: Command,
|
||||
argv: string[] = process.argv,
|
||||
): JsonMode | null {
|
||||
function getCommandJsonMode(command: Command, argv: string[] = process.argv): JsonMode | null {
|
||||
if (!commandSelectedJsonFlag(command, argv)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user