Docs: show --all heartbeat example
This commit is contained in:
@@ -194,7 +194,7 @@ Examples:
|
|||||||
warelay heartbeat # uses web session + first allowFrom contact
|
warelay heartbeat # uses web session + first allowFrom contact
|
||||||
warelay heartbeat --verbose # prints detailed heartbeat logs
|
warelay heartbeat --verbose # prints detailed heartbeat logs
|
||||||
warelay heartbeat --to +1555123 # override destination
|
warelay heartbeat --to +1555123 # override destination
|
||||||
warelay heartbeat --all # send to every active session recipient`,
|
warelay heartbeat --all # send to every active session recipient or allowFrom entry`,
|
||||||
)
|
)
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
setVerbose(Boolean(opts.verbose));
|
setVerbose(Boolean(opts.verbose));
|
||||||
|
|||||||
@@ -81,8 +81,9 @@ export async function runWebHeartbeatOnce(opts: {
|
|||||||
replyResolver?: typeof getReplyFromConfig;
|
replyResolver?: typeof getReplyFromConfig;
|
||||||
runtime?: RuntimeEnv;
|
runtime?: RuntimeEnv;
|
||||||
sender?: typeof sendMessageWeb;
|
sender?: typeof sendMessageWeb;
|
||||||
|
sessionId?: string;
|
||||||
}) {
|
}) {
|
||||||
const { cfg: cfgOverride, to, verbose = false } = opts;
|
const { cfg: cfgOverride, to, verbose = false, sessionId } = opts;
|
||||||
const _runtime = opts.runtime ?? defaultRuntime;
|
const _runtime = opts.runtime ?? defaultRuntime;
|
||||||
const replyResolver = opts.replyResolver ?? getReplyFromConfig;
|
const replyResolver = opts.replyResolver ?? getReplyFromConfig;
|
||||||
const sender = opts.sender ?? sendMessageWeb;
|
const sender = opts.sender ?? sendMessageWeb;
|
||||||
@@ -100,7 +101,7 @@ export async function runWebHeartbeatOnce(opts: {
|
|||||||
{
|
{
|
||||||
to,
|
to,
|
||||||
sessionKey: sessionSnapshot.key,
|
sessionKey: sessionSnapshot.key,
|
||||||
sessionId: sessionSnapshot.entry?.sessionId ?? null,
|
sessionId: sessionId ?? sessionSnapshot.entry?.sessionId ?? null,
|
||||||
sessionFresh: sessionSnapshot.fresh,
|
sessionFresh: sessionSnapshot.fresh,
|
||||||
idleMinutes: sessionSnapshot.idleMinutes,
|
idleMinutes: sessionSnapshot.idleMinutes,
|
||||||
},
|
},
|
||||||
@@ -114,7 +115,7 @@ export async function runWebHeartbeatOnce(opts: {
|
|||||||
Body: HEARTBEAT_PROMPT,
|
Body: HEARTBEAT_PROMPT,
|
||||||
From: to,
|
From: to,
|
||||||
To: to,
|
To: to,
|
||||||
MessageSid: sessionSnapshot.entry?.sessionId,
|
MessageSid: sessionId ?? sessionSnapshot.entry?.sessionId,
|
||||||
},
|
},
|
||||||
undefined,
|
undefined,
|
||||||
cfg,
|
cfg,
|
||||||
@@ -577,23 +578,40 @@ export async function monitorWebProvider(
|
|||||||
console.log(success("heartbeat: skipped (no recent inbound)"));
|
console.log(success("heartbeat: skipped (no recent inbound)"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const snapshot = getSessionSnapshot(cfg, fallbackTo, true);
|
||||||
|
if (!snapshot.entry) {
|
||||||
|
heartbeatLogger.info(
|
||||||
|
{ connectionId, to: fallbackTo, reason: "no-session-for-fallback" },
|
||||||
|
"reply heartbeat skipped",
|
||||||
|
);
|
||||||
|
console.log(success("heartbeat: skipped (no session to resume)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isVerbose()) {
|
if (isVerbose()) {
|
||||||
heartbeatLogger.info(
|
heartbeatLogger.info(
|
||||||
{ connectionId, to: fallbackTo, reason: "fallback-session" },
|
{
|
||||||
|
connectionId,
|
||||||
|
to: fallbackTo,
|
||||||
|
reason: "fallback-session",
|
||||||
|
sessionId: snapshot.entry?.sessionId ?? null,
|
||||||
|
sessionFresh: snapshot.fresh,
|
||||||
|
},
|
||||||
"reply heartbeat start",
|
"reply heartbeat start",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await runWebHeartbeatOnce({
|
await runWebHeartbeatOnce({
|
||||||
|
cfg,
|
||||||
to: fallbackTo,
|
to: fallbackTo,
|
||||||
verbose,
|
verbose,
|
||||||
replyResolver,
|
replyResolver,
|
||||||
runtime,
|
runtime,
|
||||||
|
sessionId: snapshot.entry.sessionId,
|
||||||
});
|
});
|
||||||
heartbeatLogger.info(
|
heartbeatLogger.info(
|
||||||
{
|
{
|
||||||
connectionId,
|
connectionId,
|
||||||
to: fallbackTo,
|
to: fallbackTo,
|
||||||
...getSessionSnapshot(cfg, fallbackTo),
|
...snapshot,
|
||||||
durationMs: Date.now() - tickStart,
|
durationMs: Date.now() - tickStart,
|
||||||
},
|
},
|
||||||
"reply heartbeat sent (fallback session)",
|
"reply heartbeat sent (fallback session)",
|
||||||
|
|||||||
Reference in New Issue
Block a user