mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
fix: 修正 channel permission relay 路由与能力判定
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -5,6 +5,7 @@ mock.module("src/services/analytics/growthbook.js", () => ({
|
||||
}));
|
||||
|
||||
const {
|
||||
filterPermissionRelayClients,
|
||||
shortRequestId,
|
||||
truncateForPreview,
|
||||
PERMISSION_REPLY_RE,
|
||||
@@ -160,3 +161,34 @@ describe("createChannelPermissionCallbacks", () => {
|
||||
expect(received?.behavior).toBe("deny");
|
||||
});
|
||||
});
|
||||
|
||||
describe("filterPermissionRelayClients", () => {
|
||||
test("requires truthy permission capability", () => {
|
||||
const clients = [
|
||||
{
|
||||
type: "connected",
|
||||
name: "plugin:weixin:weixin",
|
||||
capabilities: {
|
||||
experimental: {
|
||||
"claude/channel": {},
|
||||
"claude/channel/permission": false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "connected",
|
||||
name: "plugin:telegram:telegram",
|
||||
capabilities: {
|
||||
experimental: {
|
||||
"claude/channel": {},
|
||||
"claude/channel/permission": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
expect(
|
||||
filterPermissionRelayClients(clients, () => true).map(client => client.name),
|
||||
).toEqual(["plugin:telegram:telegram"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,8 +91,33 @@ export type ChannelPermissionRequestParams = {
|
||||
* input is in the local terminal dialog; this is a phone-sized
|
||||
* preview. Server decides whether/how to show it. */
|
||||
input_preview: string
|
||||
/** Optional source-channel routing hint for servers that support
|
||||
* multi-chat routing. Backwards compatible: servers that don't care can
|
||||
* ignore it and keep their existing fallback behavior. */
|
||||
channel_context?: {
|
||||
source_server?: string
|
||||
chat_id?: string
|
||||
}
|
||||
}
|
||||
|
||||
export const ChannelPermissionRequestNotificationSchema = lazySchema(() =>
|
||||
z.object({
|
||||
method: z.literal(CHANNEL_PERMISSION_REQUEST_METHOD),
|
||||
params: z.object({
|
||||
request_id: z.string(),
|
||||
tool_name: z.string(),
|
||||
description: z.string(),
|
||||
input_preview: z.string(),
|
||||
channel_context: z
|
||||
.object({
|
||||
source_server: z.string().optional(),
|
||||
chat_id: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* Meta keys become XML attribute NAMES — a crafted key like
|
||||
* `x="" injected="y` would break out of the attribute structure. Only
|
||||
|
||||
@@ -34,7 +34,7 @@ import { getFeatureValue_CACHED_MAY_BE_STALE } from '../analytics/growthbook.js'
|
||||
* don't apply until restart.
|
||||
*/
|
||||
export function isChannelPermissionRelayEnabled(): boolean {
|
||||
return getFeatureValue_CACHED_MAY_BE_STALE('tengu_harbor_permissions', false)
|
||||
return getFeatureValue_CACHED_MAY_BE_STALE('tengu_harbor_permissions', true)
|
||||
}
|
||||
|
||||
export type ChannelPermissionResponse = {
|
||||
@@ -188,8 +188,8 @@ export function filterPermissionRelayClients<
|
||||
(c): c is T & { type: 'connected' } =>
|
||||
c.type === 'connected' &&
|
||||
isInAllowlist(c.name) &&
|
||||
c.capabilities?.experimental?.['claude/channel'] !== undefined &&
|
||||
c.capabilities?.experimental?.['claude/channel/permission'] !== undefined,
|
||||
Boolean(c.capabilities?.experimental?.['claude/channel']) &&
|
||||
Boolean(c.capabilities?.experimental?.['claude/channel/permission']),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ export function useManageMCPConnections(
|
||||
if (
|
||||
client.capabilities?.experimental?.[
|
||||
'claude/channel/permission'
|
||||
] !== undefined
|
||||
]
|
||||
) {
|
||||
client.client.setNotificationHandler(
|
||||
ChannelPermissionNotificationSchema(),
|
||||
|
||||
Reference in New Issue
Block a user