Skip to content

feat(v3-dev): 支持后台工具按请求续接,补齐会话安全边界 - #265

Draft
xhcz wants to merge 4 commits into
YesWeAreBot:v3-devfrom
xhcz:feat/v3-dev-background-continuations
Draft

xhcz wants to merge 4 commits into
YesWeAreBot:v3-devfrom
xhcz:feat/v3-dev-background-continuations

Conversation

@xhcz

@xhcz xhcz commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

后台工具完成后,核心会把结果交回原请求,由模型继续处理,无需经过群聊意愿值结算。支持静默预取、同会话顺序排队和跨会话轮转,也允许按原请求查看各项工具的独立结果。

  • 补充群管理及跨会话发送授权,按会话校验媒体归属,为公开资产链接增加有效期。
  • 限制外部媒体和静态网页下载,补充图片解码前的尺寸校验。
  • 隔离 MCP 工具注册失败,保留结构化响应,并校验自动下载的运行时。
  • 收紧 L3 自动日记和历史清理范围,修复 TTS 发送回执、贴纸导入和好感度并发更新。
  • 更新部分依赖并增加独立的依赖审计流程。

升级后,本地网页提取仅支持静态页面。旧媒体需要在原会话重新入库,定期历史清理需要显式启用 allowGlobalRetention。

已知限制:任务保留额度耗尽时,已完成但仍在等待续接的结果可能被淘汰。

xhcz and others added 3 commits November 24, 2026 02:33
Apply the locally validated fixes from the 09439a5 audit rounds and
PR264 review on baseline 2b51495.

- Enforce explicit group-action and cross-session destination grants.
- Harden TTS delivery receipts/cancellation and MCP execution/install boundaries.
- Preserve prompt/search data boundaries and disable global retention by default.
- Tighten asset responses, planner scope, favor CAS, and sticker import safety.
- Add regression coverage without weakening the new authorization checks.

Validation on Linux arm64:
- Node 22.23.5 and 24.22.3: clean builds; 222 files, 2312 passed, 2 skipped.
- All 13 packages pass isolated install/export/runtime smoke on both versions.
- Formatting passes; lint has 0 errors and 162 warnings.
- Exact source tree matches the delivered patch and source archive.

Scope: 35 audit findings fixed, 8 partially hardened, 4 pending,
1 already fixed in the baseline, and 9 refactors deferred.
Remaining risks include multi-tenant history ownership, asset ACLs,
media resource budgets, dependency advisories, and complete SSRF controls.
Runtime data and generated delivery artifacts are deliberately excluded.
Integrate the reviewed MCP, media, history, sticker and dependency follow-up patch.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9a5f40d9-bc40-440a-829b-3bf6d2a6cdfc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T20:20:52.617534Z 8923809 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b127f1b0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +264 to +267
const parameters = Schema.transform(Schema.any(), (value) => {
if (!validate(value)) throw new Error("MCP parameters do not satisfy the declared JSON Schema");
return value;
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve MCP input schemas in the native tool-calling path

With nativeToolCalling enabled, HeartbeatProcessor.performNativeHeartbeat still constructs tool schemas using toolJSONSchema(definition.parameters) rather than definition.parametersJSONSchema. The new Schema.transform(Schema.any(), ...) wrapper converts to {}, so every registered MCP tool loses its object type, properties, and required arguments in the native request. Providers requiring object-shaped tool schemas can reject the entire heartbeat, while permissive providers receive no parameter contract. Use the preserved JSON Schema in both native request construction and its budget estimation.

Useful? React with 👍 / 👎.

Comment thread packages/core/src/asset/download.ts Outdated
Comment on lines +95 to +96
const data = await readMediaStream(response, limit, response.headers["content-length"]);
const type = response.headers["content-type"]?.split(";")[0].trim().toLowerCase() || getMimeType(data);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Decode HTTP content encodings before returning media bytes

When a server returns Content-Encoding: gzip, deflate, or br, Node's http/https response stream contains compressed bytes, but this downloader returns them unchanged under the original MIME type. SearchExtension.extractStaticPage then converts those bytes directly to UTF-8 and passes them to page.setContent, producing garbled content instead of the webpage; image downloads can similarly fail decoding. Decode the declared content encoding before returning the payload, enforcing the size limit on the decompressed stream as well.

Useful? React with 👍 / 👎.

…edia

Address the two verified Codex findings on PR YesWeAreBot#265. Preserve supplied MCP JSON Schemas in native requests and budget estimates. Decode gzip, deflate and Brotli with cancellation and bounded wire, intermediate and decoded sizes. Add focused regression coverage.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89238092b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


function assetScope(session?: AssetSession): string | undefined {
if (!session?.bot?.selfId || !session.channelId) return;
return JSON.stringify([session.platform, session.bot.selfId, session.isDirect ? "private" : "channel", session.channelId]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the full conversation identity for asset ownership

When the same bot participates in two Telegram groups whose forum topics both have channelId: "7", this produces identical ownership scopes because it omits guildId. The repository's conversationChannelId() already handles these guild-local topic IDs. Consequently, the new read(), getInfo(), and getPublicUrl() checks accept a known asset ID from the other group, and identical media deduplicates across the two conversations. Build the asset scope from the fully qualified conversation identity.

Useful? React with 👍 / 👎.

Comment on lines +264 to +267
const parameters = Schema.transform(Schema.any(), (value) => {
if (!validate(value)) throw new Error("MCP parameters do not satisfy the declared JSON Schema");
return value;
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve typed command parameters for MCP tools

When an administrator invokes an MCP tool using a numeric, boolean, or structured key=value argument, such as tool.invoke remote limit=5, this wrapper breaks the existing conversion path. convertCommandParams() discovers property validators through the Schemastery schema, but traversing transform(any) yields no candidates, so it leaves "5" as a string and the new AJV validator rejects it. Preserve a per-property input view or make command conversion consult parametersJSONSchema, rather than requiring previously working invocations to switch to complete JSON objects.

Useful? React with 👍 / 👎.

private cacheStorage!: StorageDriver;

private assetEndpoint: string;
private readonly publicSigningKey = randomBytes(32);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route asset URLs to the instance that signed them

If two YesImBot instances share a Koishi HTTP server and the same configured assetEndpoint, each now generates a different signing key while registerHttpEndpoint() registers the same route for both. Even with shared asset storage and database, a valid URL issued by one instance fails the other handler's HMAC check and returns 404; the handler does not delegate on signature mismatch. Namespace signed URLs and routes by their issuing instance, or coordinate verification for a shared endpoint, so media links from both instances remain fetchable.

Useful? React with 👍 / 👎.

@MiaowFISH

Copy link
Copy Markdown
Collaborator

吓哭了

@xhcz
xhcz marked this pull request as draft November 29, 2026 11:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants