Skip to content

Commit d85b2a0

Browse files
committed
refactor: simplify core conversions
1 parent 00837f0 commit d85b2a0

21 files changed

Lines changed: 26 additions & 25 deletions

File tree

extensions/imessage/src/config-accessors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export function resolveIMessageConfigDefaultTo(params: {
1616
if (defaultTo == null) {
1717
return undefined;
1818
}
19-
const normalized = String(defaultTo).trim();
19+
const normalized = defaultTo.trim();
2020
return normalized || undefined;
2121
}

extensions/imessage/src/monitor/monitor-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ export async function monitorIMessageProvider(opts: MonitorIMessageOpts = {}): P
385385
});
386386

387387
if (shouldLogVerbose()) {
388-
const preview = truncateUtf16Safe(String(ctxPayload.Body ?? ""), 200).replace(/\n/g, "\\n");
388+
const preview = truncateUtf16Safe(ctxPayload.Body ?? "", 200).replace(/\n/g, "\\n");
389389
logVerbose(
390390
`imessage inbound: chatId=${chatId ?? "unknown"} from=${ctxPayload.From} len=${
391-
String(ctxPayload.Body ?? "").length
391+
(ctxPayload.Body ?? "").length
392392
} preview="${preview}"`,
393393
);
394394
}

extensions/imessage/src/send.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function resolveMessageId(result: Record<string, unknown> | null | undefined): s
8080
(typeof result.guid === "string" && result.guid.trim()) ||
8181
(typeof result.message_id === "number" ? String(result.message_id) : null) ||
8282
(typeof result.id === "number" ? String(result.id) : null);
83-
return raw ? String(raw).trim() : null;
83+
return raw ? raw.trim() : null;
8484
}
8585

8686
function resolveDeliveredIMessageText(text: string, mediaContentType?: string): string {

extensions/nostr/src/gateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export const startNostrGatewayAccount: NostrGatewayStart = async (ctx) => {
169169
deliver: async (payload) => {
170170
const outboundText =
171171
payload && typeof payload === "object" && "text" in payload
172-
? String((payload as { text?: string }).text ?? "")
172+
? ((payload as { text?: string }).text ?? "")
173173
: "";
174174
if (!outboundText.trim()) {
175175
return;

extensions/qa-channel/src/inbound.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export async function handleQaInbound(params: {
9494
deliver: async (payload) => {
9595
const text =
9696
payload && typeof payload === "object" && "text" in payload
97-
? String((payload as { text?: string }).text ?? "")
97+
? ((payload as { text?: string }).text ?? "")
9898
: "";
9999
if (!text.trim()) {
100100
return;

src/agents/auth-profiles/oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ async function refreshOAuthTokenWithLock(params: {
308308

309309
const oauthCreds: Record<string, OAuthCredentials> = { [cred.provider]: cred };
310310
const result =
311-
String(cred.provider) === "chutes"
311+
cred.provider === "chutes"
312312
? await (async () => {
313313
const newCredentials = await refreshChutesTokens({
314314
credential: cred,

src/agents/pi-auth-credentials.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function convertAuthProfileCredentialToPi(cred: AuthProfileCredential): P
5757
export function resolvePiCredentialMapFromStore(store: AuthProfileStore): PiCredentialMap {
5858
const credentials: PiCredentialMap = {};
5959
for (const credential of Object.values(store.profiles)) {
60-
const provider = normalizeProviderId(String(credential.provider ?? ""));
60+
const provider = normalizeProviderId(credential.provider ?? "");
6161
if (!provider || credentials[provider]) {
6262
continue;
6363
}

src/agents/pi-embedded-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export function splitThinkingTaggedText(text: string): ThinkTaggedSplitBlock[] |
214214

215215
for (const match of text.matchAll(scanRe)) {
216216
const index = match.index ?? 0;
217-
const isClose = Boolean(match[1]?.includes("/"));
217+
const isClose = match[1]?.includes("/") ?? false;
218218

219219
if (!inThinking && !isClose) {
220220
pushText(text.slice(cursor, index));

src/agents/pi-tools.read.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ export function createOpenClawReadTool(
653653
signal,
654654
maxBytes: resolveAdaptiveReadMaxBytes(options),
655655
});
656-
const filePath = typeof record?.path === "string" ? String(record.path) : "<unknown>";
656+
const filePath = typeof record?.path === "string" ? record.path : "<unknown>";
657657
const strippedDetailsResult = stripReadTruncationContentDetails(result);
658658
const normalizedResult = await normalizeReadImageResult(strippedDetailsResult, filePath);
659659
return sanitizeToolResultImages(

src/agents/system-prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ export function buildAgentSystemPrompt(params: {
459459
const runtimeChannel = normalizeOptionalLowercaseString(runtimeInfo?.channel);
460460
const runtimeCapabilities = runtimeInfo?.capabilities ?? [];
461461
const runtimeCapabilitiesLower = new Set(
462-
runtimeCapabilities.map((cap) => normalizeLowercaseStringOrEmpty(String(cap))).filter(Boolean),
462+
runtimeCapabilities.map((cap) => normalizeLowercaseStringOrEmpty(cap)).filter(Boolean),
463463
);
464464
const inlineButtonsEnabled = runtimeCapabilitiesLower.has("inlinebuttons");
465465
const messageChannelOptions = listDeliverableMessageChannels().join("|");

0 commit comments

Comments
 (0)