fix: satisfy discord and gateway typing

This commit is contained in:
Peter Steinberger
2026-01-03 02:52:04 +01:00
parent 3ec5ce8349
commit a9eb31e8fe
2 changed files with 11 additions and 6 deletions

View File

@@ -396,6 +396,11 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
MediaType: media?.contentType, MediaType: media?.contentType,
MediaUrl: media?.path, MediaUrl: media?.path,
}; };
const replyTarget = ctxPayload.To ?? undefined;
if (!replyTarget) {
runtime.error?.(danger("discord: missing reply target"));
return;
}
if (isDirectMessage) { if (isDirectMessage) {
const sessionCfg = cfg.session; const sessionCfg = cfg.session;
@@ -430,7 +435,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
.then(async () => { .then(async () => {
await deliverReplies({ await deliverReplies({
replies: [payload], replies: [payload],
target: ctxPayload.To, target: replyTarget,
token, token,
runtime, runtime,
replyToMode, replyToMode,
@@ -473,7 +478,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
await deliverReplies({ await deliverReplies({
replies, replies,
target: ctxPayload.To, target: replyTarget,
token, token,
runtime, runtime,
replyToMode, replyToMode,
@@ -482,7 +487,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
didSendReply = true; didSendReply = true;
if (isVerbose()) { if (isVerbose()) {
logVerbose( logVerbose(
`discord: delivered ${replies.length} reply${replies.length === 1 ? "" : "ies"} to ${ctxPayload.To}`, `discord: delivered ${replies.length} reply${replies.length === 1 ? "" : "ies"} to ${replyTarget}`,
); );
} }
if ( if (

View File

@@ -27,6 +27,7 @@ export async function callGateway<T = unknown>(
const config = loadConfig(); const config = loadConfig();
const isRemoteMode = config.gateway?.mode === "remote"; const isRemoteMode = config.gateway?.mode === "remote";
const remote = isRemoteMode ? config.gateway?.remote : undefined; const remote = isRemoteMode ? config.gateway?.remote : undefined;
const authToken = config.gateway?.auth?.token;
const url = const url =
(typeof opts.url === "string" && opts.url.trim().length > 0 (typeof opts.url === "string" && opts.url.trim().length > 0
? opts.url.trim() ? opts.url.trim()
@@ -44,9 +45,8 @@ export async function callGateway<T = unknown>(
? remote.token.trim() ? remote.token.trim()
: undefined : undefined
: process.env.CLAWDIS_GATEWAY_TOKEN?.trim() || : process.env.CLAWDIS_GATEWAY_TOKEN?.trim() ||
(typeof config.gateway?.auth?.token === "string" && (typeof authToken === "string" && authToken.trim().length > 0
config.gateway.auth.token.trim().length > 0 ? authToken.trim()
? config.gateway.auth.token.trim()
: undefined)); : undefined));
const password = const password =
(typeof opts.password === "string" && opts.password.trim().length > 0 (typeof opts.password === "string" && opts.password.trim().length > 0