@jeffreycao/copilot-api 1.10.4 → 1.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,12 @@
1
1
  import { t as PATHS } from "./paths-DC-mqCY3.js";
2
2
  import { D as generateTraceId, E as prepareMessageProxyHeaders, I as state, M as compactMessageSections, O as requestContext, P as compactSystemPromptStarts, T as prepareInteractionHeaders, _ as copilotWebSocketHeaders, c as getUUID, d as sleep, f as getCopilotUsage, g as copilotHeaders, h as copilotBaseUrl, j as compactAutoContinuePromptStarts, k as resolveTraceId$1, l as isNullish, m as forwardError, n as cacheModels, o as generateRequestIdFromPayload, p as HTTPError, s as getRootSessionId, u as parseUserIdMetadata, w as prepareForCompact } from "./utils-jHLgqAq2.js";
3
- import { _ as setModelMappings, a as getConfig, c as getProviderConfig, d as isMessagesApiEnabled, f as isResponsesApiContextManagementModel, g as resolveMappedModel, i as getClaudeTokenMultiplier, l as getReasoningEffortForModel, m as isResponsesApiWebSocketEnabled, o as getExtraPromptForModel, p as isResponsesApiWebSearchEnabled, r as getAnthropicApiKey, s as getModelMappings, t as getProxyEnvDispatcher, u as getSmallModel } from "./proxy-DQLzdeq3.js";
3
+ import { a as isDeferredToolName, c as parseMcpToolSearchSentinel, d as shouldEnableResponsesToolSearch, i as isBridgeToolSearchName, l as resolveBridgeToolSearchName, o as listDeferredToolNames, r as formatToolSearchBridgeArguments, s as normalizeToolSearchBridgeArguments, t as BRIDGE_TOOL_SEARCH_NAME, u as selectDeferredToolsByNames } from "./tool-search-CKe6hqnv.js";
4
+ import { _ as setModelMappings, a as getConfig, c as getProviderConfig, d as isMessagesApiEnabled, f as isResponsesApiContextManagementModel, g as resolveMappedModel, i as getClaudeTokenMultiplier, l as getReasoningEffortForModel, m as isResponsesApiWebSocketEnabled, o as getExtraPromptForModel, p as isResponsesApiWebSearchEnabled, r as getAnthropicApiKey, s as getModelMappings, t as getProxyEnvDispatcher, u as getSmallModel } from "./proxy-CSO5SLia.js";
4
5
  import consola from "consola";
5
6
  import fs from "node:fs/promises";
6
7
  import path from "node:path";
7
8
  import { createHash } from "node:crypto";
9
+ import { z } from "zod";
8
10
  import { Hono } from "hono";
9
11
  import { cors } from "hono/cors";
10
12
  import { logger } from "hono/logger";
@@ -12,7 +14,6 @@ import fs$1, { readFileSync } from "node:fs";
12
14
  import { streamSSE } from "hono/streaming";
13
15
  import util from "node:util";
14
16
  import { events } from "fetch-event-stream";
15
- import { z } from "zod";
16
17
  import { WebSocket } from "undici";
17
18
  //#region src/lib/request-auth.ts
18
19
  function normalizeApiKeys(apiKeys) {
@@ -2993,10 +2994,19 @@ const buildPromptCacheKey = (basePromptCacheKey, subagentAgentId) => {
2993
2994
  const translateAnthropicMessagesToResponsesPayload = (payload, subagentAgentId) => {
2994
2995
  const input = [];
2995
2996
  const applyPhase = shouldApplyPhase(payload.model);
2996
- for (const message of payload.messages) input.push(...translateMessage(message, payload.model, applyPhase));
2997
+ const toolSearchEnabled = shouldEnableResponsesToolSearch({
2998
+ model: payload.model,
2999
+ tools: payload.tools
3000
+ });
3001
+ const translationState = {
3002
+ originalTools: payload.tools ?? [],
3003
+ toolSearchEnabled,
3004
+ toolUseNameById: /* @__PURE__ */ new Map()
3005
+ };
3006
+ for (const message of payload.messages) input.push(...translateMessage(message, payload.model, applyPhase, translationState));
2997
3007
  const hasOriginalTools = Array.isArray(payload.tools) && payload.tools.length > 0;
2998
- const translatedTools = convertAnthropicTools(payload.tools);
2999
- const toolChoice = convertAnthropicToolChoice(payload.tool_choice);
3008
+ const translatedTools = convertAnthropicTools(payload.tools, toolSearchEnabled);
3009
+ const toolChoice = convertAnthropicToolChoice(payload.tool_choice, toolSearchEnabled);
3000
3010
  const { sessionId: metadataPromptCacheKey } = parseUserIdMetadata(payload.metadata?.user_id);
3001
3011
  const sessionAffinity = requestContext.getStore()?.sessionAffinity?.trim() || null;
3002
3012
  const promptCacheKey = buildPromptCacheKey(metadataPromptCacheKey ?? sessionAffinity, subagentAgentId);
@@ -3039,11 +3049,11 @@ const decodeCompactionCarrierSignature = (signature) => {
3039
3049
  };
3040
3050
  }
3041
3051
  };
3042
- const translateMessage = (message, model, applyPhase) => {
3043
- if (message.role === "user") return translateUserMessage(message);
3044
- return translateAssistantMessage(message, model, applyPhase);
3052
+ const translateMessage = (message, model, applyPhase, state) => {
3053
+ if (message.role === "user") return translateUserMessage(message, state);
3054
+ return translateAssistantMessage(message, model, applyPhase, state);
3045
3055
  };
3046
- const translateUserMessage = (message) => {
3056
+ const translateUserMessage = (message, state) => {
3047
3057
  if (typeof message.content === "string") return [createMessage("user", message.content)];
3048
3058
  if (!Array.isArray(message.content)) return [];
3049
3059
  const items = [];
@@ -3051,7 +3061,7 @@ const translateUserMessage = (message) => {
3051
3061
  for (const block of message.content) {
3052
3062
  if (block.type === "tool_result") {
3053
3063
  flushPendingContent(pendingContent, items, { role: "user" });
3054
- items.push(createFunctionCallOutput(block));
3064
+ items.push(createToolCallOutput(block, state));
3055
3065
  continue;
3056
3066
  }
3057
3067
  const converted = translateUserContentBlock(block);
@@ -3060,7 +3070,7 @@ const translateUserMessage = (message) => {
3060
3070
  flushPendingContent(pendingContent, items, { role: "user" });
3061
3071
  return items;
3062
3072
  };
3063
- const translateAssistantMessage = (message, model, applyPhase) => {
3073
+ const translateAssistantMessage = (message, model, applyPhase, state) => {
3064
3074
  const assistantPhase = resolveAssistantPhase(model, message.content, applyPhase);
3065
3075
  if (typeof message.content === "string") return [createMessage("assistant", message.content, assistantPhase)];
3066
3076
  if (!Array.isArray(message.content)) return [];
@@ -3068,11 +3078,12 @@ const translateAssistantMessage = (message, model, applyPhase) => {
3068
3078
  const pendingContent = [];
3069
3079
  for (const block of message.content) {
3070
3080
  if (block.type === "tool_use") {
3081
+ state.toolUseNameById.set(block.id, block.name);
3071
3082
  flushPendingContent(pendingContent, items, {
3072
3083
  role: "assistant",
3073
3084
  phase: assistantPhase
3074
3085
  });
3075
- items.push(createFunctionToolCall(block));
3086
+ items.push(createToolCall(block, state));
3076
3087
  continue;
3077
3088
  }
3078
3089
  if (block.type === "thinking" && block.signature) {
@@ -3190,19 +3201,79 @@ const parseReasoningSignature = (signature) => {
3190
3201
  id: signature.slice(splitIndex + 1)
3191
3202
  };
3192
3203
  };
3193
- const createFunctionToolCall = (block) => ({
3204
+ const createFunctionToolCall = (block, state) => ({
3194
3205
  type: "function_call",
3195
3206
  call_id: block.id,
3196
3207
  name: block.name,
3197
3208
  arguments: JSON.stringify(block.input),
3209
+ status: "completed",
3210
+ ...state.toolSearchEnabled && isDeferredToolName(block.name) ? { namespace: block.name } : {}
3211
+ });
3212
+ const createToolSearchCall = (block) => ({
3213
+ type: "tool_search_call",
3214
+ call_id: block.id,
3215
+ arguments: normalizeToolSearchBridgeArguments(block.input),
3216
+ execution: "client",
3198
3217
  status: "completed"
3199
3218
  });
3219
+ const createToolCall = (block, state) => {
3220
+ if (state.toolSearchEnabled && isBridgeToolSearchName(block.name)) return createToolSearchCall(block);
3221
+ return createFunctionToolCall(block, state);
3222
+ };
3200
3223
  const createFunctionCallOutput = (block) => ({
3201
3224
  type: "function_call_output",
3202
3225
  call_id: block.tool_use_id,
3203
3226
  output: convertToolResultContent(block.content),
3204
3227
  status: block.is_error ? "incomplete" : "completed"
3205
3228
  });
3229
+ const createToolCallOutput = (block, state) => {
3230
+ const toolUseName = state.toolUseNameById.get(block.tool_use_id);
3231
+ if (state.toolSearchEnabled && isBridgeToolSearchName(toolUseName ?? "")) return createToolSearchOutput(block, state.originalTools);
3232
+ return createFunctionCallOutput(block);
3233
+ };
3234
+ const createToolSearchOutput = (block, originalTools) => {
3235
+ const referencedToolNames = resolveToolSearchReferencedToolNames(block.content, originalTools);
3236
+ return {
3237
+ type: "tool_search_output",
3238
+ call_id: block.tool_use_id,
3239
+ tools: referencedToolNames.map((toolName) => convertDeferredToolToNamespace(resolveDeferredTool(toolName, originalTools))),
3240
+ execution: "client",
3241
+ status: block.is_error ? "incomplete" : "completed"
3242
+ };
3243
+ };
3244
+ const resolveToolSearchReferencedToolNames = (content, originalTools) => {
3245
+ const explicitReferences = extractToolReferenceNames(content);
3246
+ if (explicitReferences.length > 0) return uniqueToolNames(explicitReferences);
3247
+ const sentinel = extractMcpToolSearchSentinel(content);
3248
+ if (sentinel) return selectDeferredToolsByNames(sentinel.names, originalTools).map((tool) => tool.name);
3249
+ return [];
3250
+ };
3251
+ const extractToolReferenceNames = (content) => {
3252
+ if (!Array.isArray(content)) return [];
3253
+ return content.flatMap((block) => block.type === "tool_reference" ? [block.tool_name] : []);
3254
+ };
3255
+ const extractMcpToolSearchSentinel = (content) => {
3256
+ if (typeof content === "string") return parseMcpToolSearchSentinel(content);
3257
+ for (const block of content) {
3258
+ if (block.type !== "text") continue;
3259
+ const sentinel = parseMcpToolSearchSentinel(block.text);
3260
+ if (sentinel) return sentinel;
3261
+ }
3262
+ return null;
3263
+ };
3264
+ const resolveDeferredTool = (toolName, originalTools) => {
3265
+ const tool = originalTools.find((candidate) => candidate.name === toolName);
3266
+ if (tool && isDeferredToolName(tool.name)) return tool;
3267
+ throw createInvalidRequestError(`Tool reference '${toolName}' has no corresponding deferred tool definition`);
3268
+ };
3269
+ const uniqueToolNames = (toolNames) => [...new Set(toolNames)];
3270
+ const createInvalidRequestError = (message) => new HTTPError(message, new Response(JSON.stringify({ error: {
3271
+ message,
3272
+ type: "invalid_request_error"
3273
+ } }), {
3274
+ status: 400,
3275
+ headers: { "content-type": "application/json" }
3276
+ }));
3206
3277
  const translateSystemPrompt = (system, model) => {
3207
3278
  if (!system) return null;
3208
3279
  const extraPrompt = getExtraPromptForModel(model);
@@ -3213,31 +3284,83 @@ const translateSystemPrompt = (system, model) => {
3213
3284
  }).join(" ");
3214
3285
  return text.length > 0 ? text : null;
3215
3286
  };
3216
- const convertAnthropicTools = (tools) => {
3287
+ const convertAnthropicTools = (tools, toolSearchEnabled) => {
3217
3288
  if (!tools || tools.length === 0) return null;
3218
- return tools.map((tool) => ({
3289
+ const converted = [];
3290
+ let addedToolSearch = false;
3291
+ const searchableToolNames = toolSearchEnabled ? listDeferredToolNames(tools) : [];
3292
+ for (const tool of tools) {
3293
+ if (isBridgeToolSearchName(tool.name)) {
3294
+ if (toolSearchEnabled && !addedToolSearch) {
3295
+ converted.push(createResponsesToolSearchDefinition(searchableToolNames));
3296
+ addedToolSearch = true;
3297
+ }
3298
+ continue;
3299
+ }
3300
+ if (toolSearchEnabled && isDeferredToolName(tool.name)) {
3301
+ converted.push(convertDeferredToolToNamespace(tool));
3302
+ continue;
3303
+ }
3304
+ converted.push(convertToolToFunction(tool));
3305
+ }
3306
+ return converted;
3307
+ };
3308
+ const createResponsesToolSearchDefinition = (searchableToolNames) => ({
3309
+ type: "tool_search",
3310
+ execution: "client",
3311
+ description: "Load deferred tools by exact name before using them. Return only the searchable tool names you need for the next step.",
3312
+ parameters: {
3313
+ type: "object",
3314
+ properties: { names: {
3315
+ type: "array",
3316
+ description: "Exact deferred tool names to load.",
3317
+ items: {
3318
+ type: "string",
3319
+ enum: searchableToolNames
3320
+ },
3321
+ minItems: 1
3322
+ } },
3323
+ required: ["names"],
3324
+ additionalProperties: false
3325
+ }
3326
+ });
3327
+ const convertToolToFunction = (tool) => ({
3328
+ type: "function",
3329
+ name: tool.name,
3330
+ parameters: normalizeToolSchema(tool.input_schema),
3331
+ strict: false,
3332
+ ...tool.description ? { description: tool.description } : {}
3333
+ });
3334
+ const convertDeferredToolToNamespace = (tool) => ({
3335
+ type: "namespace",
3336
+ name: tool.name,
3337
+ ...tool.description ? { description: tool.description } : {},
3338
+ tools: [{
3219
3339
  type: "function",
3220
3340
  name: tool.name,
3221
3341
  parameters: normalizeToolSchema(tool.input_schema),
3222
3342
  strict: false,
3343
+ defer_loading: true,
3223
3344
  ...tool.description ? { description: tool.description } : {}
3224
- }));
3225
- };
3226
- const convertAnthropicToolChoice = (choice) => {
3345
+ }]
3346
+ });
3347
+ const convertAnthropicToolChoice = (choice, toolSearchEnabled) => {
3227
3348
  if (!choice) return "auto";
3228
3349
  switch (choice.type) {
3229
3350
  case "auto": return "auto";
3230
3351
  case "any": return "required";
3231
- case "tool": return choice.name ? {
3232
- type: "function",
3233
- name: choice.name
3234
- } : "auto";
3352
+ case "tool":
3353
+ if (toolSearchEnabled && choice.name && isBridgeToolSearchName(choice.name)) return "auto";
3354
+ return choice.name ? {
3355
+ type: "function",
3356
+ name: choice.name
3357
+ } : "auto";
3235
3358
  case "none": return "none";
3236
3359
  default: return "auto";
3237
3360
  }
3238
3361
  };
3239
- const translateResponsesResultToAnthropic = (response) => {
3240
- const contentBlocks = mapOutputToAnthropicContent(response.output);
3362
+ const translateResponsesResultToAnthropic = (response, options) => {
3363
+ const contentBlocks = mapOutputToAnthropicContent(response.output, options);
3241
3364
  const usage = mapResponsesUsage(response);
3242
3365
  let anthropicContent = fallbackContentBlocks(response.output_text);
3243
3366
  if (contentBlocks.length > 0) anthropicContent = contentBlocks;
@@ -3253,7 +3376,7 @@ const translateResponsesResultToAnthropic = (response) => {
3253
3376
  usage
3254
3377
  };
3255
3378
  };
3256
- const mapOutputToAnthropicContent = (output) => {
3379
+ const mapOutputToAnthropicContent = (output, options) => {
3257
3380
  const contentBlocks = [];
3258
3381
  for (const item of output) switch (item.type) {
3259
3382
  case "reasoning": {
@@ -3270,6 +3393,12 @@ const mapOutputToAnthropicContent = (output) => {
3270
3393
  if (toolUseBlock) contentBlocks.push(toolUseBlock);
3271
3394
  break;
3272
3395
  }
3396
+ case "tool_search_call": {
3397
+ const toolUseBlock = createToolSearchUseContentBlock(item, options?.toolSearchName);
3398
+ if (toolUseBlock) contentBlocks.push(toolUseBlock);
3399
+ break;
3400
+ }
3401
+ case "tool_search_output": break;
3273
3402
  case "message": {
3274
3403
  const combinedText = combineMessageTextContent(item.content);
3275
3404
  if (combinedText.length > 0) contentBlocks.push({
@@ -3331,15 +3460,29 @@ const extractReasoningText = (item) => {
3331
3460
  };
3332
3461
  const createToolUseContentBlock = (call) => {
3333
3462
  const toolId = call.call_id;
3334
- if (!call.name || !toolId) return null;
3335
- const input = parseFunctionCallArguments(call.arguments);
3463
+ const toolName = resolveToolUseName(call);
3464
+ if (!toolName || !toolId) return null;
3465
+ return {
3466
+ type: "tool_use",
3467
+ id: toolId,
3468
+ name: toolName,
3469
+ input: parseFunctionCallArguments(call.arguments)
3470
+ };
3471
+ };
3472
+ const createToolSearchUseContentBlock = (call, toolSearchName = BRIDGE_TOOL_SEARCH_NAME) => {
3473
+ const toolId = call.call_id;
3474
+ if (!toolId) return null;
3336
3475
  return {
3337
3476
  type: "tool_use",
3338
3477
  id: toolId,
3339
- name: call.name,
3340
- input
3478
+ name: toolSearchName,
3479
+ input: parseToolSearchArguments(call.arguments)
3341
3480
  };
3342
3481
  };
3482
+ const resolveToolUseName = (call) => {
3483
+ if (typeof call.namespace === "string" && call.namespace.length > 0) return call.namespace;
3484
+ return call.name;
3485
+ };
3343
3486
  const createCompactionThinkingBlock = (item) => {
3344
3487
  if (!item.id || !item.encrypted_content) return null;
3345
3488
  return {
@@ -3365,6 +3508,9 @@ const parseFunctionCallArguments = (rawArguments) => {
3365
3508
  }
3366
3509
  return { raw_arguments: rawArguments };
3367
3510
  };
3511
+ const parseToolSearchArguments = (argumentsValue) => {
3512
+ return formatToolSearchBridgeArguments(argumentsValue);
3513
+ };
3368
3514
  const fallbackContentBlocks = (outputText) => {
3369
3515
  if (!outputText) return [];
3370
3516
  return [{
@@ -3375,7 +3521,7 @@ const fallbackContentBlocks = (outputText) => {
3375
3521
  const mapResponsesStopReason = (response) => {
3376
3522
  const { status, incomplete_details: incompleteDetails } = response;
3377
3523
  if (status === "completed") {
3378
- if (response.output.some((item) => item.type === "function_call")) return "tool_use";
3524
+ if (response.output.some((item) => item.type === "function_call" || item.type === "tool_search_call")) return "tool_use";
3379
3525
  return "end_turn";
3380
3526
  }
3381
3527
  if (status === "incomplete") {
@@ -3446,14 +3592,15 @@ const updateWhitespaceRunState = (previousCount, chunk) => {
3446
3592
  exceeded: false
3447
3593
  };
3448
3594
  };
3449
- const createResponsesStreamState = () => ({
3595
+ const createResponsesStreamState = (options) => ({
3450
3596
  messageStartSent: false,
3451
3597
  messageCompleted: false,
3452
3598
  nextContentBlockIndex: 0,
3453
3599
  blockIndexByKey: /* @__PURE__ */ new Map(),
3454
3600
  openBlocks: /* @__PURE__ */ new Set(),
3455
3601
  blockHasDelta: /* @__PURE__ */ new Set(),
3456
- functionCallStateByOutputIndex: /* @__PURE__ */ new Map()
3602
+ functionCallStateByOutputIndex: /* @__PURE__ */ new Map(),
3603
+ toolSearchName: options?.toolSearchName ?? "mcp__tool_search__search"
3457
3604
  });
3458
3605
  const translateResponsesStreamEvent = (rawEvent, state) => {
3459
3606
  switch (rawEvent.type) {
@@ -3478,7 +3625,7 @@ const handleResponseCreated = (rawEvent, state) => {
3478
3625
  };
3479
3626
  const handleOutputItemAdded$1 = (rawEvent, state) => {
3480
3627
  const events = new Array();
3481
- const functionCallDetails = extractFunctionCallDetails(rawEvent);
3628
+ const functionCallDetails = extractFunctionCallDetails(rawEvent, state);
3482
3629
  if (!functionCallDetails) return events;
3483
3630
  const { outputIndex, toolCallId, name, initialArguments } = functionCallDetails;
3484
3631
  const blockIndex = openFunctionCallBlock(state, {
@@ -3505,6 +3652,28 @@ const handleOutputItemDone$1 = (rawEvent, state) => {
3505
3652
  const item = rawEvent.item;
3506
3653
  const itemType = item.type;
3507
3654
  const outputIndex = rawEvent.output_index;
3655
+ if (itemType === "tool_search_call") {
3656
+ const blockIndex = openFunctionCallBlock(state, {
3657
+ outputIndex,
3658
+ toolCallId: item.call_id,
3659
+ name: state.toolSearchName,
3660
+ events
3661
+ });
3662
+ const finalArguments = stringifyToolSearchArguments(item.arguments);
3663
+ if (!state.blockHasDelta.has(blockIndex) && finalArguments) {
3664
+ events.push({
3665
+ type: "content_block_delta",
3666
+ index: blockIndex,
3667
+ delta: {
3668
+ type: "input_json_delta",
3669
+ partial_json: finalArguments
3670
+ }
3671
+ });
3672
+ state.blockHasDelta.add(blockIndex);
3673
+ }
3674
+ state.functionCallStateByOutputIndex.delete(outputIndex);
3675
+ return events;
3676
+ }
3508
3677
  if (itemType === "compaction") {
3509
3678
  if (!item.id || !item.encrypted_content) return events;
3510
3679
  const blockIndex = openThinkingBlockIfNeeded(state, outputIndex, events);
@@ -3833,16 +4002,30 @@ const openFunctionCallBlock = (state, params) => {
3833
4002
  }
3834
4003
  return blockIndex;
3835
4004
  };
3836
- const extractFunctionCallDetails = (rawEvent) => {
4005
+ const extractFunctionCallDetails = (rawEvent, state) => {
3837
4006
  const item = rawEvent.item;
3838
- if (item.type !== "function_call") return;
4007
+ const itemType = item.type;
4008
+ if (itemType === "tool_search_call") return {
4009
+ outputIndex: rawEvent.output_index,
4010
+ toolCallId: item.call_id,
4011
+ name: state.toolSearchName,
4012
+ initialArguments: ""
4013
+ };
4014
+ if (itemType !== "function_call") return;
3839
4015
  return {
3840
4016
  outputIndex: rawEvent.output_index,
3841
4017
  toolCallId: item.call_id,
3842
- name: item.name,
4018
+ name: resolveToolUseName(item),
3843
4019
  initialArguments: item.arguments
3844
4020
  };
3845
4021
  };
4022
+ const stringifyToolSearchArguments = (argumentsValue) => {
4023
+ try {
4024
+ return JSON.stringify(formatToolSearchBridgeArguments(argumentsValue));
4025
+ } catch {
4026
+ return;
4027
+ }
4028
+ };
3846
4029
  //#endregion
3847
4030
  //#region src/services/copilot/create-messages.ts
3848
4031
  const INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-14";
@@ -4226,7 +4409,7 @@ const handleWithResponsesApi = async (c, anthropicPayload, options) => {
4226
4409
  if (responsesPayload.stream && isAsyncIterable$1(response)) {
4227
4410
  logger.debug("Streaming response from Copilot (Responses API)");
4228
4411
  return streamSSE(c, async (stream) => {
4229
- const streamState = createResponsesStreamState();
4412
+ const streamState = createResponsesStreamState({ toolSearchName: resolveBridgeToolSearchName(anthropicPayload.tools) });
4230
4413
  let usage = {};
4231
4414
  for await (const chunk of response) {
4232
4415
  if (chunk.event === "ping") {
@@ -4270,7 +4453,7 @@ const handleWithResponsesApi = async (c, anthropicPayload, options) => {
4270
4453
  value: response,
4271
4454
  tailLength: 400
4272
4455
  });
4273
- const anthropicResponse = translateResponsesResultToAnthropic(response);
4456
+ const anthropicResponse = translateResponsesResultToAnthropic(response, { toolSearchName: resolveBridgeToolSearchName(anthropicPayload.tools) });
4274
4457
  recordUsage(normalizeResponsesUsage(response.usage));
4275
4458
  debugJson(logger, "Translated Anthropic response:", anthropicResponse);
4276
4459
  return c.json(anthropicResponse);
@@ -4836,4 +5019,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
4836
5019
  //#endregion
4837
5020
  export { server };
4838
5021
 
4839
- //# sourceMappingURL=server-D2zjqsEM.js.map
5022
+ //# sourceMappingURL=server-DsfYz_GE.js.map