chore: fix lint after logging tweaks
This commit is contained in:
@@ -30,7 +30,10 @@ describe("resolveConfiguredModelRef", () => {
|
|||||||
defaultModel: DEFAULT_MODEL,
|
defaultModel: DEFAULT_MODEL,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(resolved).toEqual({ provider: "anthropic", model: "claude-opus-4-5" });
|
expect(resolved).toEqual({
|
||||||
|
provider: "anthropic",
|
||||||
|
model: "claude-opus-4-5",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to defaults when agent.model is missing", () => {
|
it("falls back to defaults when agent.model is missing", () => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import type { ClawdisConfig } from "../config/config.js";
|
|
||||||
import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js";
|
import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js";
|
||||||
|
import type { ClawdisConfig } from "../config/config.js";
|
||||||
import {
|
import {
|
||||||
resolveHeartbeatDeliveryTarget,
|
resolveHeartbeatDeliveryTarget,
|
||||||
resolveHeartbeatIntervalMs,
|
resolveHeartbeatIntervalMs,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { chunkText } from "../auto-reply/chunk.js";
|
import { chunkText } from "../auto-reply/chunk.js";
|
||||||
import { HEARTBEAT_PROMPT, stripHeartbeatToken } from "../auto-reply/heartbeat.js";
|
import {
|
||||||
|
HEARTBEAT_PROMPT,
|
||||||
|
stripHeartbeatToken,
|
||||||
|
} from "../auto-reply/heartbeat.js";
|
||||||
import { getReplyFromConfig } from "../auto-reply/reply.js";
|
import { getReplyFromConfig } from "../auto-reply/reply.js";
|
||||||
import type { ReplyPayload } from "../auto-reply/types.js";
|
import type { ReplyPayload } from "../auto-reply/types.js";
|
||||||
import { parseDurationMs } from "../cli/parse-duration.js";
|
import { parseDurationMs } from "../cli/parse-duration.js";
|
||||||
@@ -8,21 +11,21 @@ import { loadConfig } from "../config/config.js";
|
|||||||
import {
|
import {
|
||||||
loadSessionStore,
|
loadSessionStore,
|
||||||
resolveStorePath,
|
resolveStorePath,
|
||||||
saveSessionStore,
|
|
||||||
type SessionEntry,
|
type SessionEntry,
|
||||||
|
saveSessionStore,
|
||||||
} from "../config/sessions.js";
|
} from "../config/sessions.js";
|
||||||
import { formatErrorMessage } from "../infra/errors.js";
|
import { formatErrorMessage } from "../infra/errors.js";
|
||||||
import { createSubsystemLogger } from "../logging.js";
|
import { createSubsystemLogger } from "../logging.js";
|
||||||
import { getQueueSize } from "../process/command-queue.js";
|
import { getQueueSize } from "../process/command-queue.js";
|
||||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||||
import { normalizeE164 } from "../utils.js";
|
|
||||||
import { sendMessageTelegram } from "../telegram/send.js";
|
import { sendMessageTelegram } from "../telegram/send.js";
|
||||||
|
import { normalizeE164 } from "../utils.js";
|
||||||
import { sendMessageWhatsApp } from "../web/outbound.js";
|
import { sendMessageWhatsApp } from "../web/outbound.js";
|
||||||
import { emitHeartbeatEvent } from "./heartbeat-events.js";
|
import { emitHeartbeatEvent } from "./heartbeat-events.js";
|
||||||
import {
|
import {
|
||||||
|
type HeartbeatRunResult,
|
||||||
requestHeartbeatNow,
|
requestHeartbeatNow,
|
||||||
setHeartbeatWakeHandler,
|
setHeartbeatWakeHandler,
|
||||||
type HeartbeatRunResult,
|
|
||||||
} from "./heartbeat-wake.js";
|
} from "./heartbeat-wake.js";
|
||||||
|
|
||||||
export type HeartbeatTarget = "last" | "whatsapp" | "telegram" | "none";
|
export type HeartbeatTarget = "last" | "whatsapp" | "telegram" | "none";
|
||||||
@@ -93,7 +96,7 @@ function resolveHeartbeatSender(params: {
|
|||||||
lastTo?.trim(),
|
lastTo?.trim(),
|
||||||
lastChannel === "telegram" && lastTo ? `telegram:${lastTo}` : undefined,
|
lastChannel === "telegram" && lastTo ? `telegram:${lastTo}` : undefined,
|
||||||
lastChannel === "whatsapp" && lastTo ? `whatsapp:${lastTo}` : undefined,
|
lastChannel === "whatsapp" && lastTo ? `whatsapp:${lastTo}` : undefined,
|
||||||
].filter((val): val is string => Boolean(val && val.trim()));
|
].filter((val): val is string => Boolean(val?.trim()));
|
||||||
|
|
||||||
const allowList = allowFrom
|
const allowList = allowFrom
|
||||||
.map((entry) => String(entry))
|
.map((entry) => String(entry))
|
||||||
@@ -156,23 +159,8 @@ export function resolveHeartbeatDeliveryTarget(params: {
|
|||||||
(target === "last" ? lastTo : undefined);
|
(target === "last" ? lastTo : undefined);
|
||||||
|
|
||||||
if (!channel || !to) {
|
if (!channel || !to) {
|
||||||
return { channel: "none", reason: "no-target" };
|
return { channel: "none", reason: "no-target" };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restoreHeartbeatUpdatedAt(params: {
|
|
||||||
storePath: string;
|
|
||||||
sessionKey: string;
|
|
||||||
updatedAt?: number;
|
|
||||||
}) {
|
|
||||||
const { storePath, sessionKey, updatedAt } = params;
|
|
||||||
if (typeof updatedAt !== "number") return;
|
|
||||||
const store = loadSessionStore(storePath);
|
|
||||||
const entry = store[sessionKey];
|
|
||||||
if (!entry) return;
|
|
||||||
if (entry.updatedAt === updatedAt) return;
|
|
||||||
store[sessionKey] = { ...entry, updatedAt };
|
|
||||||
await saveSessionStore(storePath, store);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel !== "whatsapp") {
|
if (channel !== "whatsapp") {
|
||||||
return { channel, to };
|
return { channel, to };
|
||||||
@@ -190,6 +178,21 @@ async function restoreHeartbeatUpdatedAt(params: {
|
|||||||
return { channel, to: allowFrom[0], reason: "allowFrom-fallback" };
|
return { channel, to: allowFrom[0], reason: "allowFrom-fallback" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function restoreHeartbeatUpdatedAt(params: {
|
||||||
|
storePath: string;
|
||||||
|
sessionKey: string;
|
||||||
|
updatedAt?: number;
|
||||||
|
}) {
|
||||||
|
const { storePath, sessionKey, updatedAt } = params;
|
||||||
|
if (typeof updatedAt !== "number") return;
|
||||||
|
const store = loadSessionStore(storePath);
|
||||||
|
const entry = store[sessionKey];
|
||||||
|
if (!entry) return;
|
||||||
|
if (entry.updatedAt === updatedAt) return;
|
||||||
|
store[sessionKey] = { ...entry, updatedAt };
|
||||||
|
await saveSessionStore(storePath, store);
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeHeartbeatReply(
|
function normalizeHeartbeatReply(
|
||||||
payload: ReplyPayload,
|
payload: ReplyPayload,
|
||||||
responsePrefix?: string,
|
responsePrefix?: string,
|
||||||
@@ -334,7 +337,8 @@ export async function runHeartbeatOnce(opts: {
|
|||||||
|
|
||||||
const delivery = resolveHeartbeatDeliveryTarget({ cfg, entry });
|
const delivery = resolveHeartbeatDeliveryTarget({ cfg, entry });
|
||||||
const mediaUrls =
|
const mediaUrls =
|
||||||
replyPayload.mediaUrls ?? (replyPayload.mediaUrl ? [replyPayload.mediaUrl] : []);
|
replyPayload.mediaUrls ??
|
||||||
|
(replyPayload.mediaUrl ? [replyPayload.mediaUrl] : []);
|
||||||
|
|
||||||
if (delivery.channel === "none" || !delivery.to) {
|
if (delivery.channel === "none" || !delivery.to) {
|
||||||
emitHeartbeatEvent({
|
emitHeartbeatEvent({
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ export function setHeartbeatWakeHandler(next: HeartbeatWakeHandler | null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function requestHeartbeatNow(opts?: { reason?: string; coalesceMs?: number }) {
|
export function requestHeartbeatNow(opts?: {
|
||||||
|
reason?: string;
|
||||||
|
coalesceMs?: number;
|
||||||
|
}) {
|
||||||
pendingReason = opts?.reason ?? pendingReason ?? "requested";
|
pendingReason = opts?.reason ?? pendingReason ?? "requested";
|
||||||
schedule(opts?.coalesceMs ?? DEFAULT_COALESCE_MS);
|
schedule(opts?.coalesceMs ?? DEFAULT_COALESCE_MS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import {
|
|||||||
normalizeGroupActivation,
|
normalizeGroupActivation,
|
||||||
parseActivationCommand,
|
parseActivationCommand,
|
||||||
} from "../auto-reply/group-activation.js";
|
} from "../auto-reply/group-activation.js";
|
||||||
import { getReplyFromConfig } from "../auto-reply/reply.js";
|
|
||||||
import {
|
import {
|
||||||
HEARTBEAT_PROMPT,
|
HEARTBEAT_PROMPT,
|
||||||
stripHeartbeatToken,
|
stripHeartbeatToken,
|
||||||
} from "../auto-reply/heartbeat.js";
|
} from "../auto-reply/heartbeat.js";
|
||||||
|
import { getReplyFromConfig } from "../auto-reply/reply.js";
|
||||||
import { HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
|
import { HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
|
||||||
import type { ReplyPayload } from "../auto-reply/types.js";
|
import type { ReplyPayload } from "../auto-reply/types.js";
|
||||||
import { waitForever } from "../cli/wait.js";
|
import { waitForever } from "../cli/wait.js";
|
||||||
@@ -876,7 +876,7 @@ export async function monitorWebProvider(
|
|||||||
let watchdogTimer: NodeJS.Timeout | null = null;
|
let watchdogTimer: NodeJS.Timeout | null = null;
|
||||||
let lastMessageAt: number | null = null;
|
let lastMessageAt: number | null = null;
|
||||||
let handledMessages = 0;
|
let handledMessages = 0;
|
||||||
let lastInboundMsg: WebInboundMsg | null = null;
|
let _lastInboundMsg: WebInboundMsg | null = null;
|
||||||
|
|
||||||
// Watchdog to detect stuck message processing (e.g., event emitter died)
|
// Watchdog to detect stuck message processing (e.g., event emitter died)
|
||||||
// Should be significantly longer than the reply heartbeat interval to avoid false positives
|
// Should be significantly longer than the reply heartbeat interval to avoid false positives
|
||||||
@@ -1184,7 +1184,7 @@ export async function monitorWebProvider(
|
|||||||
status.lastMessageAt = lastMessageAt;
|
status.lastMessageAt = lastMessageAt;
|
||||||
status.lastEventAt = lastMessageAt;
|
status.lastEventAt = lastMessageAt;
|
||||||
emitStatus();
|
emitStatus();
|
||||||
lastInboundMsg = msg;
|
_lastInboundMsg = msg;
|
||||||
const conversationId = msg.conversationId ?? msg.from;
|
const conversationId = msg.conversationId ?? msg.from;
|
||||||
|
|
||||||
// Same-phone mode logging retained
|
// Same-phone mode logging retained
|
||||||
|
|||||||
Reference in New Issue
Block a user