chore: redact long texts in web logs
parent
0da3f84a2e
commit
29dfe89137
|
|
@ -27,7 +27,8 @@ export const DEFAULT_IDLE_MINUTES = 60;
|
||||||
|
|
||||||
export function resolveStorePath(store?: string) {
|
export function resolveStorePath(store?: string) {
|
||||||
if (!store) return SESSION_STORE_DEFAULT;
|
if (!store) return SESSION_STORE_DEFAULT;
|
||||||
if (store.startsWith("~")) return path.resolve(store.replace("~", os.homedir()));
|
if (store.startsWith("~"))
|
||||||
|
return path.resolve(store.replace("~", os.homedir()));
|
||||||
return path.resolve(store);
|
return path.resolve(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ const DEFAULT_REPLY_HEARTBEAT_MINUTES = 30;
|
||||||
export const HEARTBEAT_TOKEN = "HEARTBEAT_OK";
|
export const HEARTBEAT_TOKEN = "HEARTBEAT_OK";
|
||||||
export const HEARTBEAT_PROMPT = "HEARTBEAT /think:high";
|
export const HEARTBEAT_PROMPT = "HEARTBEAT /think:high";
|
||||||
|
|
||||||
|
function elide(text?: string, limit = 400) {
|
||||||
|
if (!text) return text;
|
||||||
|
if (text.length <= limit) return text;
|
||||||
|
return `${text.slice(0, limit)}… (truncated ${text.length - limit} chars)`;
|
||||||
|
}
|
||||||
|
|
||||||
type MentionConfig = {
|
type MentionConfig = {
|
||||||
requireMention: boolean;
|
requireMention: boolean;
|
||||||
mentionRegexes: RegExp[];
|
mentionRegexes: RegExp[];
|
||||||
|
|
@ -337,7 +343,12 @@ export async function runWebHeartbeatOnce(opts: {
|
||||||
|
|
||||||
const sendResult = await sender(to, finalText, { verbose });
|
const sendResult = await sender(to, finalText, { verbose });
|
||||||
heartbeatLogger.info(
|
heartbeatLogger.info(
|
||||||
{ to, messageId: sendResult.messageId, chars: finalText.length },
|
{
|
||||||
|
to,
|
||||||
|
messageId: sendResult.messageId,
|
||||||
|
chars: finalText.length,
|
||||||
|
preview: elide(finalText, 140),
|
||||||
|
},
|
||||||
"heartbeat sent",
|
"heartbeat sent",
|
||||||
);
|
);
|
||||||
console.log(success(`heartbeat: alert sent to ${to}`));
|
console.log(success(`heartbeat: alert sent to ${to}`));
|
||||||
|
|
@ -479,7 +490,7 @@ async function deliverWebReply(params: {
|
||||||
connectionId: connectionId ?? null,
|
connectionId: connectionId ?? null,
|
||||||
to: msg.from,
|
to: msg.from,
|
||||||
from: msg.to,
|
from: msg.to,
|
||||||
text: replyResult.text,
|
text: elide(replyResult.text, 240),
|
||||||
mediaUrl: null,
|
mediaUrl: null,
|
||||||
mediaSizeBytes: null,
|
mediaSizeBytes: null,
|
||||||
mediaKind: null,
|
mediaKind: null,
|
||||||
|
|
@ -748,7 +759,7 @@ export async function monitorWebProvider(
|
||||||
correlationId,
|
correlationId,
|
||||||
from: latest.chatType === "group" ? conversationId : latest.from,
|
from: latest.chatType === "group" ? conversationId : latest.from,
|
||||||
to: latest.to,
|
to: latest.to,
|
||||||
body: combinedBody,
|
body: elide(combinedBody, 240),
|
||||||
mediaType: latest.mediaType ?? null,
|
mediaType: latest.mediaType ?? null,
|
||||||
mediaPath: latest.mediaPath ?? null,
|
mediaPath: latest.mediaPath ?? null,
|
||||||
batchSize: messages.length,
|
batchSize: messages.length,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue