"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
Merge PR #1520: feat(channels): web-based channel configuration with connection test and hot apply
Haozhe Wu1bf0bd62d423
diff --cc agent/src/channels/dingtalk.pyindex b1cf140e9,52c3b1636..50ed594dd--- a/agent/src/channels/dingtalk.py+++ b/agent/src/channels/dingtalk.py@@@ -333,10 -338,10 +338,10 @@@ class DingTalkChannel(BaseChannel)ext = Path(filename).suffix.lower()if ext in self._ZIP_BEFORE_UPLOAD_EXTS or content_type == "text/html":self.logger.info(- "does not accept raw HTML attachments, zipping {} before upload",+ "does not accept raw HTML attachments, zipping %s before upload",filename,)- return self._zip_bytes(filename, data)+ return dingtalk_media.zip_bytes(filename, data)return data, filename, content_typedef _validate_remote_media_url(self, media_ref: str) -> bool:@@@ -629,10 -635,10 +635,10 @@@data, filename, content_type = await self._read_media_bytes(media_ref)if not data:- self.logger.error("media read failed: {}", media_ref)+ self.logger.error("media read failed: %s", media_ref)return False- filename = filename or self._guess_filename(media_ref, upload_type)+ filename = filename or dingtalk_media.guess_filename(media_ref, upload_type)data, filename, content_type = self._normalize_upload_payload(filename, data, content_type)file_type = Path(filename).suffix.lower().lstrip(".")if not file_type:@@@ -683,9 -689,10 +689,10 @@@ok = await self._send_media_ref(token, msg.chat_id, media_ref)if ok:continue- self.logger.error("media send failed for {}", media_ref)+ self.logger.error("media send failed for %s", media_ref)# Send visible fallback so failures are observable by the user.- filename = self._guess_filename(media_ref, self._guess_upload_type(media_ref))+ upload_type = dingtalk_media.guess_upload_type(media_ref)+ filename = dingtalk_media.guess_filename(media_ref, upload_type)await self._send_markdown_text(token,msg.chat_id,diff --cc agent/src/channels/manager.pyindex ca142dc5c,f413b85a4..77b6bc022--- a/agent/src/channels/manager.py+++ b/agent/src/channels/manager.py@@@ -32,11 -32,10 +32,14 @@@ _BOOL_CAMEL_ALIASES: dict[str, str] ="show_reasoning": "showReasoning",}+ # Bound the reload stop wait so a wedged adapter cannot stall a hot swap.+ _RELOAD_STOP_TIMEOUT_S = 10.0++# Inbound messages whose reply fingerprint is kept for duplicate suppression.+_MAX_REPLY_FINGERPRINTS = 4096++class ChannelManager:"""Manages chat channels and coordinates message routing.diff --cc frontend/src/pages/Settings.tsxindex 2a70d6c59,2bc85b5c6..a4fa09d60--- a/frontend/src/pages/Settings.tsx+++ b/frontend/src/pages/Settings.tsx@@@ -372,124 -323,7 +335,10 @@@ export function Settings()const tushareStatus = dataSettings.tushare_token_configured? t("settings.configured"): t("settings.keepCurrentToken");+ const gildataStatus = dataSettings.gildata_token_configured+ ? t("settings.configured")+ : t("settings.keepCurrentToken");- const channelRows = channelStatus- ? Object.entries(channelStatus.channels ?? {}).sort(([a], [b]) => a.localeCompare(b))- : [];- const channelEnabledCount = channelRows.filter(([, item]) => item.enabled).length;- const channelLoadedCount = channelRows.filter(([, item]) => item.loaded).length;- const channelUnavailableCount = channelRows.filter(([, item]) => item.available === false).length;- const channelBusy = channelRefreshing || channelAction !== null;- const channelsSection = (- <section className="rounded-lg border bg-card p-5 shadow-sm">- <div className="mb-5 flex flex-col gap-4 md:flex-row md:items-start md:justify-between">- <div className="space-y-1">- <div className="flex items-center gap-2">- <MessageSquareMore className="h-4 w-4 text-primary" />- <h2 className="text-base font-semibold">{t("settings.channels.title")}</h2>- </div>- <p className="max-w-3xl text-sm text-muted-foreground">{t("settings.channels.description")}</p>- </div>- <div className="flex flex-wrap gap-2">- <button- type="button"- onClick={refreshChannelStatus}- disabled={channelBusy}- className="inline-flex items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm text-muted-foreground transition hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60"- >- {channelRefreshing ? <Loader2 className="h-4 w-4 animate-spin" /> : <RefreshCw className="h-4 w-4" />}- {t("settings.channels.refresh")}- </button>- <button- type="button"- onClick={() => setChannelsRunning("start")}- disabled={channelBusy || !channelStatus}- className="inline-flex items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60"- >- {channelAction === "start" ? <Loader2 className="h-4 w-4 animate-spin" /> : <Play className="h-4 w-4" />}- {t("settings.channels.start")}- </button>- <button- type="button"- onClick={() => setChannelsRunning("stop")}- disabled={channelBusy || !channelStatus}- className="inline-flex items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm text-muted-foreground transition hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60"- >- {channelAction === "stop" ? <Loader2 className="h-4 w-4 animate-spin" /> : <Square className="h-4 w-4" />}- {t("settings.channels.stop")}- </button>- </div>- </div>-- {channelStatus ? (- <>- <div className="mb-4 grid gap-3 md:grid-cols-4">- <div className="rounded-md border bg-muted/20 px-3 py-2">- <div className="text-xs text-muted-foreground">{t("settings.channels.runtime")}</div>- <div className="text-sm font-medium">{channelStatus.running ? t("settings.channels.running") : t("settings.channels.stopped")}</div>- </div>- <div className="rounded-md border bg-muted/20 px-3 py-2">- <div className="text-xs text-muted-foreground">{t("settings.channels.enabled")}</div>- <div className="text-sm font-medium">{channelEnabledCount}</div>- </div>- <div className="rounded-md border bg-muted/20 px-3 py-2">- <div className="text-xs text-muted-foreground">{t("settings.channels.loaded")}</div>- <div className="text-sm font-medium">{channelLoadedCount}</div>- </div>- <div className="rounded-md border bg-muted/20 px-3 py-2">- <div className="text-xs text-muted-foreground">{t("settings.channels.unavailable")}</div>- <div className="text-sm font-medium">{channelUnavailableCount}</div>- </div>- </div>-- <div className="overflow-hidden rounded-md border">- <table className="w-full text-sm">- <thead className="bg-muted/40 text-xs text-muted-foreground">- <tr>- <th className="px-3 py-2 text-start font-medium">{t("settings.channels.channel")}</th>- <th className="px-3 py-2 text-start font-medium">{t("settings.channels.state")}</th>- <th className="px-3 py-2 text-start font-medium">{t("settings.channels.recovery")}</th>- </tr>- </thead>- <tbody>- {channelRows.map(([name, item]) => (- <tr key={name} className="border-t">- <td className="px-3 py-2 align-top">- <div className="font-medium">{item.display_name || name}</div>- <div className="text-xs text-muted-foreground">{name}</div>- </td>- <td className="px-3 py-2 align-top">- <div className="flex flex-wrap gap-1.5">- <span className={`rounded-full px-2 py-0.5 text-xs ${item.enabled ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"}`}>- {item.enabled ? t("settings.channels.enabled") : t("settings.channels.disabled")}- </span>- <span className={`rounded-full px-2 py-0.5 text-xs ${item.loaded ? "bg-success/10 text-success" : "bg-muted text-muted-foreground"}`}>- {item.loaded ? t("settings.channels.loaded") : t("settings.channels.notLoaded")}- </span>- <span className={`rounded-full px-2 py-0.5 text-xs ${item.running ? "bg-success/10 text-success" : "bg-muted text-muted-foreground"}`}>- {item.running ? t("settings.channels.running") : t("settings.channels.stopped")}- </span>- </div>- </td>- <td className="max-w-md px-3 py-2 align-top text-xs text-muted-foreground">- {item.install_hint || item.error || t("settings.channels.noRecovery")}- </td>- </tr>- ))}- </tbody>- </table>- </div>- </>- ) : (- <div className="rounded-md border bg-muted/20 px-4 py-6 text-center text-sm text-muted-foreground">- {t("settings.channels.refreshFailed")}- </div>- )}- </section>- );return (<div className="mx-auto max-w-5xl space-y-6 p-6"><div className="space-y-2">