mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:24:30 +00:00
refactor: consolidate duplicate utility functions (#12439)
* refactor: consolidate duplicate utility functions - Add escapeRegExp to src/utils.ts and remove 10 local duplicates - Rename bash-tools clampNumber to clampWithDefault (different signature) - Centralize formatError calls to use formatErrorMessage from infra/errors.ts - Re-export formatErrorMessage from cli/cli-utils.ts to preserve API * refactor: consolidate remaining escapeRegExp duplicates * refactor: consolidate sleep, stripAnsi, and clamp duplicates
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
type MSTeamsReplyStyle,
|
||||
type ReplyPayload,
|
||||
SILENT_REPLY_TOKEN,
|
||||
sleep,
|
||||
} from "openclaw/plugin-sdk";
|
||||
import type { MSTeamsAccessTokenProvider } from "./attachments/types.js";
|
||||
import type { StoredConversationReference } from "./conversation-store.js";
|
||||
@@ -166,16 +167,6 @@ function clampMs(value: number, maxMs: number): number {
|
||||
return Math.min(value, maxMs);
|
||||
}
|
||||
|
||||
async function sleep(ms: number): Promise<void> {
|
||||
const delay = Math.max(0, ms);
|
||||
if (delay === 0) {
|
||||
return;
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, delay);
|
||||
});
|
||||
}
|
||||
|
||||
function resolveRetryOptions(
|
||||
retry: false | MSTeamsSendRetryOptions | undefined,
|
||||
): Required<MSTeamsSendRetryOptions> & { enabled: boolean } {
|
||||
|
||||
Reference in New Issue
Block a user