@bitkyc08/opencodex
Version:
Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code
12 lines (10 loc) • 647 B
text/typescript
import { isAllowedToolChoice, toolChoiceToolPredicate, type OcxParsedRequest } from "../types";
import { rejectsForcedToolChoice } from "./anthropic-model-contract";
/** The catalog actually advertised on the wire, independently of whether calling it is enabled. */
export function anthropicDeclaredTools(parsed: OcxParsedRequest) {
const tools = parsed.context.tools ?? [];
const choice = parsed.options.toolChoice;
return isAllowedToolChoice(choice)
|| (rejectsForcedToolChoice(parsed.modelId) && typeof choice === "object" && choice !== null && "name" in choice)
? tools.filter(toolChoiceToolPredicate(choice, tools)) : tools;
}