mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
chore(deadcode): remove duplicate Gemini schema helper
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
wrapToolWithBeforeToolCallHook,
|
||||
} from "./agent-tools.before-tool-call.js";
|
||||
import {
|
||||
cleanToolSchemaForGemini,
|
||||
normalizeToolParameterSchema,
|
||||
normalizeToolParameters,
|
||||
} from "./agent-tools.schema.js";
|
||||
@@ -136,15 +135,18 @@ describe("normalizeToolParameterSchema", () => {
|
||||
});
|
||||
|
||||
it("inlines local $ref before removing unsupported keywords", () => {
|
||||
const cleaned = cleanToolSchemaForGemini({
|
||||
type: "object",
|
||||
properties: {
|
||||
foo: { $ref: "#/$defs/Foo" },
|
||||
const cleaned = normalizeToolParameterSchema(
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
foo: { $ref: "#/$defs/Foo" },
|
||||
},
|
||||
$defs: {
|
||||
Foo: { type: "string", enum: ["a", "b"] },
|
||||
},
|
||||
},
|
||||
$defs: {
|
||||
Foo: { type: "string", enum: ["a", "b"] },
|
||||
},
|
||||
}) as {
|
||||
{ modelProvider: "gemini" },
|
||||
) as {
|
||||
$defs?: unknown;
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
@@ -600,18 +602,21 @@ describe("normalizeToolParameterSchema", () => {
|
||||
});
|
||||
|
||||
it("cleans tuple items schemas", () => {
|
||||
const cleaned = cleanToolSchemaForGemini({
|
||||
type: "object",
|
||||
properties: {
|
||||
tuples: {
|
||||
type: "array",
|
||||
items: [
|
||||
{ type: "string", format: "uuid" },
|
||||
{ type: "number", minimum: 1 },
|
||||
],
|
||||
const cleaned = normalizeToolParameterSchema(
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
tuples: {
|
||||
type: "array",
|
||||
items: [
|
||||
{ type: "string", format: "uuid" },
|
||||
{ type: "number", minimum: 1 },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}) as {
|
||||
{ modelProvider: "gemini" },
|
||||
) as {
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
@@ -625,13 +630,16 @@ describe("normalizeToolParameterSchema", () => {
|
||||
});
|
||||
|
||||
it("drops null-only union variants without flattening other unions", () => {
|
||||
const cleaned = cleanToolSchemaForGemini({
|
||||
type: "object",
|
||||
properties: {
|
||||
parentId: { anyOf: [{ type: "string" }, { type: "null" }] },
|
||||
count: { oneOf: [{ type: "string" }, { type: "number" }] },
|
||||
const cleaned = normalizeToolParameterSchema(
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
parentId: { anyOf: [{ type: "string" }, { type: "null" }] },
|
||||
count: { oneOf: [{ type: "string" }, { type: "number" }] },
|
||||
},
|
||||
},
|
||||
}) as {
|
||||
{ modelProvider: "gemini" },
|
||||
) as {
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
|
||||
@@ -92,11 +92,3 @@ export function normalizeToolParameters(
|
||||
parameters,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use normalizeToolParameters with modelProvider instead.
|
||||
* This function should only be used for Gemini providers.
|
||||
*/
|
||||
export function cleanToolSchemaForGemini(schema: Record<string, unknown>): unknown {
|
||||
return normalizeToolParameterSchema(schema, { modelProvider: "gemini" });
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
wrapToolWorkspaceRootGuardWithOptions,
|
||||
wrapToolParamValidation,
|
||||
} from "./agent-tools.read.js";
|
||||
import { cleanToolSchemaForGemini, normalizeToolParameters } from "./agent-tools.schema.js";
|
||||
import { normalizeToolParameters } from "./agent-tools.schema.js";
|
||||
import type { AnyAgentTool } from "./agent-tools.types.js";
|
||||
import { createApplyPatchTool } from "./apply-patch.js";
|
||||
import type { AuthProfileStore } from "./auth-profiles/types.js";
|
||||
@@ -409,7 +409,6 @@ export { resolveToolLoopDetectionConfig } from "./tool-loop-detection-config.js"
|
||||
|
||||
/** Test-only access to internal tool assembly helpers. */
|
||||
export const testing = {
|
||||
cleanToolSchemaForGemini,
|
||||
getToolParamsRecord,
|
||||
wrapToolParamValidation,
|
||||
assertRequiredParams,
|
||||
|
||||
Reference in New Issue
Block a user