215 Commits

Author SHA1 Message Date
Aqr-K
fc0eed08cc fix: preserve directed messaging and channel interaction contracts (#7148)
* fix: retain plugin lifecycle ownership and recover installation state

* fix: preserve directed messaging and channel interaction contracts

* test: cover plugin rollback and uninstall lifecycle boundaries

---------

Co-authored-by: jxxghp <jxxghp@gmail.com>
2026-10-23 07:49:53 +08:00
jxxghp
cc2e02793e fix(telegram): wait for final streaming edit interval
Wait once for the remaining message edit interval during Agent finalization, without bypassing Telegram 429 cooldown or replaying confirmed text.

Refs #7124
2026-10-22 08:25:25 +08:00
jxxghp
6d4ce83837 fix(types): clear host mypy debt and prevent typing regressions
严格检查全部宿主源码,清零类型错误预算并移除按模块类型豁免。
按原因、所属方法、错误码及语法指纹锁定必要兼容例外和站点类型桩,
CI 阻断新增忽略、检查范围退化、本地桩替代真实接口及新的类型错误。

修复空值、异步和供应方类型边界,保持插件与 API 兼容合同,
并补充存储、订阅、通知、Agent 和工作流边界的回归覆盖。
2026-10-21 22:03:18 +08:00
jxxghp
9e02d26292 fix(telegram): omit buttons without valid actions (#7074) 2026-10-19 15:47:28 +08:00
DDSRem
e0642eafa7 chore(types): reduce v3 host mypy debt (#7057)
* chore(types): clear AniList endpoint mypy debt

* chore(types): clear Douban endpoint mypy debt

* chore(types): clear recommendation endpoint mypy debt

* chore(types): clear subscription notification mypy debt

* chore(types): clear SDK string compatibility mypy debt

* chore(types): ratchet v3 host mypy across remaining files

* chore(types): reduce v3 host mypy debt and retire ledger

* chore(types): reconcile host snapshot with upstream HTTP pool

* test(types): cover host paths exposed by mypy cleanup
2026-10-18 09:37:49 +08:00
DDSRem
2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00
jxxghp
00645938d2 fix: isolate durable notification recovery 2026-10-17 13:11:15 +08:00
jxxghp
346a8b8288 fix(telegram): satisfy type debt ratchet 2026-10-17 09:55:50 +08:00
jxxghp
5344191455 refactor(telegram): keep streaming send within complexity budget 2026-10-17 09:45:25 +08:00
jxxghp
f2c986c007 fix(telegram): honor rate limits during agent streaming 2026-10-17 09:40:56 +08:00
ranzhigg
ea251b193e fix(telegram): rebuild polling session after network errors (#7016) 2026-10-16 12:17:35 +08:00
jxxghp
90754e06ba fix(telegram): preserve notification hierarchy and render detail links 2026-10-16 07:06:17 +08:00
@huluohu
76a4e33e44 fix(telegram): Rich Message 失败时保留原始错误并降级纯文本 (#6993)
* fix(telegram): Rich Message 失败时保留原始错误并降级纯文本

Telegram Rich Message 发送失败时存在三个叠加问题:

1. `__send_rich_message` 用固定文本 `RetryException("发送 Telegram Rich
   Message 失败")` 包装异常,`str(e)` 里没有 Telegram 返回的 description,
   日志只剩“发送失败”四个字,无法判断是内容非法、方法不存在还是格式问题。

2. 内容非法这类确定性失败(400)同样走满3 次退避重试(3s、6s),
   期间同一条坏消息反复阻塞,且最终报错仍无有效信息。

3. 失败即丢失通知:Rich Message 发不出去时没有任何降级路径,
   整条通知直接消失。

改动:

- 异常文本改为 f"...失败:{err}",保留 Telegram 原始 description 与错误码。
- 新增 `NonRetryableTelegramError`(继承 `ImmediateException`)与
  `_is_non_retryable_api_error`,400 立即抛出以跳过 retry 退避;
  5xx 与网络异常保持原有重试策略。
- `send_msg` / `edit_msg` 增加纯文本降级出口,Rich Message 失败时
  用不带格式解析的纯文本重发,保证通知内容不丢失。
- 降级路径显式传 `parse_mode=""`:`TelegramBotApi._parse_mode` 在参数为
  `None` 时会回落到客户端默认的 MarkdownV2,那正是 Rich Message 已经
  失败过的解析路径,漏传会让降级重演同一个错误。

新增 tests/test_telegram_rich_message_fallback.py(14 项)覆盖错误信息保留、
400 免重试、5xx 仍重试、发送与编辑两条降级路径,以及 parse_mode 回落陷阱的
回归防护。

* fix(telegram): 修正 Rich Message 降级路径的 mypy 与架构基线

上一提交引入的两处门禁失败:

1. `__send_plain_fallback` 用 `**self._topic_kwargs(chat_id)` 展开参数,mypy
   把 `**` 匹配到 `send_message` 第 5 个形参 `disable_web_page_preview`
   (Optional[bool]),判定 `dict[str, int]` 不兼容,arg-type 由 1 增至 2。
   改为显式传 `message_thread_id`,`_topic_kwargs` 只可能产出该键。

2. 新增 `app.schemas.exception` 导入带来 2 条依赖边,宿主基线由 9542 变为
   9544。已用 `baseline.py --write-host` 固化,其余 3 个基线文件字节不变。

   连带影响:docs/architecture-overview.md 与 docs/refactor/
   optimization-checklist.md 硬编码了边数,`test_architecture_documents_
   match_generated_quality_metrics` 断言两处必须与基线一致,同步为 9,544。

门禁与测试验证:

- scripts/architecture/mypy_ratchet.py          exit 0(9163 个类型错误)
- scripts/architecture/baseline.py --check-host exit 0
- pytest(fallback + contract + telegram)      75 passed

---------

Co-authored-by: jxxghp <jxxghp@gmail.com>
2026-10-15 07:32:16 +08:00
jxxghp
13a58be2a6 feat(notifications): render structured results by channel capabilities 2026-10-14 08:05:41 +08:00
freeman
f3ad81b39e style: apply safe ruff auto-fixes and exempt startup late imports
Run `ruff check app tests scripts --fix` with the configured rule set
(E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders
(F541), lambda/variable/unused-import cleanups that ruff marks safe.
Nine files whose only ruff debt sits next to pre-existing pylint
import-resolution errors (lazy exports, sys.path script imports) or
whose "unused" imports are reached through attribute access by tests are
left untouched so the changed-file pylint gate and the benchmark tests
stay green; their diagnostics remain in the baseline.

app/startup/lifecycle/__init__.py and app/main.py import business
modules after cache composition, import-path and stdio setup on purpose
(the source comments document the contract), so declare E402
per-file-ignores for them instead of adding per-line noqa.

Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture
and the optimization checklist figure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 13:29:09 +08:00
jxxghp
cf889ba7a0 fix(telegram): report persistent polling failures 2026-10-08 13:23:58 +08:00
jxxghp
118e2ef933 fix(notification): align scoped recipient routing 2026-10-03 01:00:21 +08:00
InfinityPacer
fb9d0204b6 perf(telegram): replace pyTelegramBotAPI with a lightweight Bot API client
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 11:36:30 +08:00
jxxghp
e98e92e208 feat(telegram): route channel notifications to configured topic 2026-09-29 07:02:24 +08:00
jxxghp
4e9a64c0f0 refactor(application): 按模块子目录统一文件命名 2026-09-15 23:57:06 +08:00
jxxghp
61b0ae951f refactor(application): 拆分消息渠道权限 2026-09-15 23:57:06 +08:00
jxxghp
d32d17568a fix(runtime): apply configuration changes without restart 2026-09-11 00:12:05 +08:00
jxxghp
b4b5f82511 refactor(modules): narrow package root exports 2026-08-29 21:19:00 +08:00
jxxghp
9dbe424c3d refactor(config): retire RuntimeSettingsCompat host usage 2026-08-26 15:55:21 +08:00
InfinityPacer
be7dfd77a3 fix(runtime): 收敛模块关闭线程所有权 (#6443)
* fix(runtime): bound module shutdown owners

* fix(runtime): declare blocking shutdown owners

---------

Co-authored-by: jxxghp <jxxghp@gmail.com>
2026-08-25 06:58:31 +08:00
jxxghp
415335b215 refactor: unify message channel shutdown convergence 2026-08-24 14:08:06 +08:00
jxxghp
009631b8ee refactor: unify capability shutdown convergence 2026-08-24 13:48:11 +08:00
jxxghp
ecbd39a0bb fix: isolate telegram typing lifecycle 2026-08-24 08:51:49 +08:00
jxxghp
e1230c0277 refactor: unify message ingress forwarding 2026-08-24 03:01:17 +08:00
jxxghp
061a92eab0 refactor: route chat and subtitle settings through runtime 2026-08-23 03:17:40 +08:00
jxxghp
9273d68aa7 feat(telegram): support rich Agent messages 2026-08-22 10:11:18 +08:00
jxxghp
8472bcff43 refactor: 收口 V3 分层架构与插件兼容边界 2026-08-18 13:22:02 +08:00
jxxghp
5128ae9e1e refactor: 推进后端分层架构治理 2026-08-18 00:29:14 +08:00
jxxghp
54f093a099 Merge remote-tracking branch 'origin/v3' into v3
# Conflicts:
#	app/api/endpoints/agent.py
#	app/api/endpoints/anthropic.py
#	app/api/endpoints/openai.py
#	app/chain/__init__.py
#	app/chain/message.py
#	app/chain/site.py
#	app/chain/subscribe.py
#	app/chain/transfer.py
#	app/modules/discord/__init__.py
#	app/modules/qqbot/__init__.py
#	app/modules/slack/__init__.py
#	app/modules/telegram/__init__.py
#	app/modules/wechat/__init__.py
#	app/runtime/extensions/module_manager.py
#	app/runtime/extensions/service_registry.py
#	tests/test_agent_interaction.py
#	tests/test_slash_command_interactions.py
#	tests/test_web_agent_stream.py
2026-08-16 19:44:43 +08:00
jxxghp
240a4dffe6 refactor(schemas): 统一 message/notification 命名边界,旧名收敛至兼容映射表
- notification 域:渠道能力(MessageChannel→NotificationChannel、ChannelCapability* 迁入 notification.py)
- message 域:消息收发(Notification→Message、NotificationType→MessageType、CommingMessage→IncomingMessage、NotificationHistoryItem→MessageHistoryItem、NotificationClear*→MessageClear*)
- Agent 工具契约:send_notification_message→send_message、notification_callback→message_callback
- 源码不保留旧名物理别名,旧导入经 app/runtime/compat/manifest.py SYMBOL_ALIASES 惰性解析
- API 路径与持久化键冻结不变,前端零改动
- 新增兼容守护测试与 docs/rules/07 命名边界规范
2026-08-16 19:32:20 +08:00
jxxghp
7e851dbfa7 refactor(chain): 处理链功能域 mixin 化,清理未使用导入并根治兼容层循环导入
- ChainBase 拆分为 RecognitionMixin/MessageProcessingMixin/NotificationMixin
- TransferChain 拆分为 7 个功能 mixin(_mixins.py),SubscribeChain 音乐订阅域拆出 _music.py
- 斜杠命令交互四件套收敛为 InteractionChainMixin 委托,会话管理器移至 application 层,chain 层不再 re-export
- 模块基础类收敛到 app/modules/_base(notification/mediaserver 语义重命名)
- 清理 app/chain/__init__.py 24 个未使用导入,修正 49 处测试 patch 目标到实际命名空间
- 兼容层 legacy 符号不再并入 __all__,根治 schemas 初始化反向拉起 application.transfer 的循环导入
- 修复 bangumi 集数为字符串时 set_bangumi_info 抛 TypeError
- 新增重复代码等架构门禁测试;capability 清单校验排除下划线内部目录
2026-08-16 16:30:16 +08:00
InfinityPacer
24671f8f18 refactor(runtime): lazily activate host modules (#6331) 2026-08-16 16:07:38 +08:00
jxxghp
96118e73e7 refactor(string): split utilities by responsibility 2026-08-15 08:03:55 +08:00
jxxghp
369d7d6448 refactor: reorganize backend module boundaries 2026-08-14 19:53:33 +08:00
jxxghp
7b3444c366 refactor backend module architecture 2026-08-14 15:45:38 +08:00
jxxghp
87b1caf3ff fix(agent): grant channel owners admin access 2026-08-14 00:01:37 +08:00
InfinityPacer
3aed078bbb fix(agent): bind channel admin identity (#6294) 2026-08-13 14:53:59 +08:00
InfinityPacer
591a1d420d fix(agent): close secret confirmation delivery gaps (#6285) 2026-08-13 08:20:14 +08:00
InfinityPacer
893269f8c1 fix(modules): serialize configuration reload lifecycle (#6122) 2026-07-15 17:28:49 +08:00
InfinityPacer
f814c271cc refactor(runtime): tighten resource cleanup and test isolation (#6116) 2026-07-14 16:03:29 +08:00
qqcomeup
8c0afac5d1 feat: support prompt-bound plugin input replies (#6087) 2026-07-09 12:52:22 +08:00
qqcomeup
0fbf05d72f fix: handle Telegram urllib3 header formatter compatibility (#6074) 2026-07-07 19:58:49 +08:00
qqcomeup
827ed8330c feat: add plugin-scoped text input sessions (#6068) 2026-07-07 05:15:18 +08:00
jxxghp
73d5c95f4e Fix Telegram edit fallback 2026-06-29 22:48:13 +08:00
jxxghp
f9ea0118d9 Handle Telegramify 1.2 compatibility 2026-06-22 20:16:37 +08:00