MCPcopy
hub / github.com/7836246/cursor2api / isIdentityProbe

Function isIdentityProbe

src/handler.ts:156–174  ·  view source on GitHub ↗
(body: AnthropicRequest)

Source from the content-addressed store, hash-verified

154// ==================== 身份探针拦截 ====================
155
156export function isIdentityProbe(body: AnthropicRequest): boolean {
157 if (!body.messages || body.messages.length === 0) return false;
158 const lastMsg = body.messages[body.messages.length - 1];
159 if (lastMsg.role !== 'user') return false;
160
161 let text = '';
162 if (typeof lastMsg.content === 'string') {
163 text = lastMsg.content;
164 } else if (Array.isArray(lastMsg.content)) {
165 for (const block of lastMsg.content) {
166 if (block.type === 'text' && block.text) text += block.text;
167 }
168 }
169
170 // 如果有工具定义(agent模式),不拦截身份探针(让agent正常工作)
171 if (body.tools && body.tools.length > 0) return false;
172
173 return IDENTITY_PROBE_PATTERNS.some(p => p.test(text));
174}
175
176export function isToolCapabilityQuestion(body: AnthropicRequest): boolean {
177 if (!body.messages || body.messages.length === 0) return false;

Callers 3

handleOpenAIResponsesFunction · 0.85
handleMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected