From f99189d410601a78fadcf90c4329172fdb131253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=82CHES?= Date: Wed, 18 Mar 2026 11:20:04 -0600 Subject: [PATCH] refactor: extract PER_REQUEST_TIMEOUT_MS to shared types (#1196) Co-authored-by: Claude Opus 4.6 (1M context) --- src/resources/extensions/remote-questions/discord-adapter.ts | 4 ++-- src/resources/extensions/remote-questions/notify.ts | 3 +-- src/resources/extensions/remote-questions/slack-adapter.ts | 3 +-- src/resources/extensions/remote-questions/telegram-adapter.ts | 3 +-- src/resources/extensions/remote-questions/types.ts | 3 +++ 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/resources/extensions/remote-questions/discord-adapter.ts b/src/resources/extensions/remote-questions/discord-adapter.ts index 199e00386..b0ea7fb46 100644 --- a/src/resources/extensions/remote-questions/discord-adapter.ts +++ b/src/resources/extensions/remote-questions/discord-adapter.ts @@ -2,11 +2,11 @@ * Remote Questions — Discord adapter */ -import type { ChannelAdapter, RemotePrompt, RemoteDispatchResult, RemoteAnswer, RemotePromptRef } from "./types.js"; +import { PER_REQUEST_TIMEOUT_MS, type ChannelAdapter, type RemotePrompt, type RemoteDispatchResult, type RemoteAnswer, type RemotePromptRef } from "./types.js"; import { formatForDiscord, parseDiscordResponse, DISCORD_NUMBER_EMOJIS } from "./format.js"; const DISCORD_API = "https://discord.com/api/v10"; -const PER_REQUEST_TIMEOUT_MS = 15_000; + export class DiscordAdapter implements ChannelAdapter { readonly name = "discord" as const; private botUserId: string | null = null; diff --git a/src/resources/extensions/remote-questions/notify.ts b/src/resources/extensions/remote-questions/notify.ts index 761ac881a..bdca4bdb0 100644 --- a/src/resources/extensions/remote-questions/notify.ts +++ b/src/resources/extensions/remote-questions/notify.ts @@ -9,8 +9,7 @@ import { resolveRemoteConfig } from "./config.js"; import type { ResolvedConfig } from "./config.js"; - -const PER_REQUEST_TIMEOUT_MS = 15_000; +import { PER_REQUEST_TIMEOUT_MS } from "./types.js"; /** * Send a one-way notification to the configured remote channel. diff --git a/src/resources/extensions/remote-questions/slack-adapter.ts b/src/resources/extensions/remote-questions/slack-adapter.ts index d56023bf9..c9e8cb811 100644 --- a/src/resources/extensions/remote-questions/slack-adapter.ts +++ b/src/resources/extensions/remote-questions/slack-adapter.ts @@ -2,11 +2,10 @@ * Remote Questions — Slack adapter */ -import type { ChannelAdapter, RemotePrompt, RemoteDispatchResult, RemoteAnswer, RemotePromptRef } from "./types.js"; +import { PER_REQUEST_TIMEOUT_MS, type ChannelAdapter, type RemotePrompt, type RemoteDispatchResult, type RemoteAnswer, type RemotePromptRef } from "./types.js"; import { formatForSlack, parseSlackReply, parseSlackReactionResponse, SLACK_NUMBER_REACTION_NAMES } from "./format.js"; const SLACK_API = "https://slack.com/api"; -const PER_REQUEST_TIMEOUT_MS = 15_000; const SLACK_ACK_REACTION = "white_check_mark"; export class SlackAdapter implements ChannelAdapter { diff --git a/src/resources/extensions/remote-questions/telegram-adapter.ts b/src/resources/extensions/remote-questions/telegram-adapter.ts index 65bc88b24..5108895a8 100644 --- a/src/resources/extensions/remote-questions/telegram-adapter.ts +++ b/src/resources/extensions/remote-questions/telegram-adapter.ts @@ -2,11 +2,10 @@ * Remote Questions — Telegram adapter */ -import type { ChannelAdapter, RemotePrompt, RemoteDispatchResult, RemoteAnswer, RemotePromptRef } from "./types.js"; +import { PER_REQUEST_TIMEOUT_MS, type ChannelAdapter, type RemotePrompt, type RemoteDispatchResult, type RemoteAnswer, type RemotePromptRef } from "./types.js"; import { formatForTelegram, parseTelegramResponse } from "./format.js"; const TELEGRAM_API = "https://api.telegram.org"; -const PER_REQUEST_TIMEOUT_MS = 15_000; export class TelegramAdapter implements ChannelAdapter { readonly name = "telegram" as const; diff --git a/src/resources/extensions/remote-questions/types.ts b/src/resources/extensions/remote-questions/types.ts index 6f13876fd..cb6e5ea19 100644 --- a/src/resources/extensions/remote-questions/types.ts +++ b/src/resources/extensions/remote-questions/types.ts @@ -2,6 +2,9 @@ * Remote Questions — shared types */ +/** Timeout applied to every outbound HTTP request across all channel adapters. */ +export const PER_REQUEST_TIMEOUT_MS = 15_000; + export type RemoteChannel = "slack" | "discord" | "telegram"; export interface RemoteQuestionOption {