mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:18:25 +00:00
chore: Enable typescript/no-explicit-any rule.
This commit is contained in:
@@ -73,7 +73,7 @@ const applyPatchSchema = Type.Object({
|
||||
|
||||
export function createApplyPatchTool(
|
||||
options: { cwd?: string; sandboxRoot?: string } = {},
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
): AgentTool<any, ApplyPatchToolDetails> {
|
||||
const cwd = options.cwd ?? process.cwd();
|
||||
const sandboxRoot = options.sandboxRoot;
|
||||
|
||||
@@ -20,8 +20,7 @@ const OAUTH_PROVIDER_IDS = new Set<OAuthProvider>(
|
||||
);
|
||||
|
||||
function isOAuthProvider(provider: string): provider is OAuthProvider {
|
||||
// biome-ignore lint/suspicious/noExplicitAny: type guard needs runtime check
|
||||
return OAUTH_PROVIDER_IDS.has(provider as any);
|
||||
return OAUTH_PROVIDER_IDS.has(provider);
|
||||
}
|
||||
|
||||
const resolveOAuthProvider = (provider: string): OAuthProvider | null =>
|
||||
|
||||
@@ -799,7 +799,7 @@ async function runExecProcess(opts: {
|
||||
|
||||
export function createExecTool(
|
||||
defaults?: ExecToolDefaults,
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
): AgentTool<any, ExecToolDetails> {
|
||||
const defaultBackgroundMs = clampNumber(
|
||||
defaults?.backgroundMs ?? readEnvInt("PI_BASH_YIELD_MS"),
|
||||
|
||||
@@ -43,7 +43,7 @@ const processSchema = Type.Object({
|
||||
|
||||
export function createProcessTool(
|
||||
defaults?: ProcessToolDefaults,
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
): AgentTool<any> {
|
||||
if (defaults?.cleanupMs !== undefined) {
|
||||
setJobTtlMs(defaults.cleanupMs);
|
||||
|
||||
@@ -17,6 +17,7 @@ describe("downgradeOpenAIReasoningBlocks", () => {
|
||||
},
|
||||
];
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
expect(downgradeOpenAIReasoningBlocks(input as any)).toEqual(input);
|
||||
});
|
||||
|
||||
@@ -34,6 +35,7 @@ describe("downgradeOpenAIReasoningBlocks", () => {
|
||||
{ role: "user", content: "next" },
|
||||
];
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
expect(downgradeOpenAIReasoningBlocks(input as any)).toEqual([
|
||||
{ role: "user", content: "next" },
|
||||
]);
|
||||
@@ -52,6 +54,7 @@ describe("downgradeOpenAIReasoningBlocks", () => {
|
||||
},
|
||||
];
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
expect(downgradeOpenAIReasoningBlocks(input as any)).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -69,6 +72,7 @@ describe("downgradeOpenAIReasoningBlocks", () => {
|
||||
},
|
||||
];
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
expect(downgradeOpenAIReasoningBlocks(input as any)).toEqual(input);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ import { runBeforeToolCallHook } from "./pi-tools.before-tool-call.js";
|
||||
import { normalizeToolName } from "./tool-policy.js";
|
||||
import { jsonResult } from "./tools/common.js";
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
@@ -36,7 +36,6 @@ export function toToolDefinitions(tools: AnyAgentTool[]): ToolDefinition[] {
|
||||
name,
|
||||
label: tool.label ?? name,
|
||||
description: tool.description ?? "",
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema from pi-agent-core uses a different module instance.
|
||||
parameters: tool.parameters,
|
||||
execute: async (
|
||||
toolCallId,
|
||||
@@ -87,6 +86,7 @@ export function toClientToolDefinitions(
|
||||
name: func.name,
|
||||
label: func.name,
|
||||
description: func.description ?? "",
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
parameters: func.parameters as any,
|
||||
execute: async (
|
||||
toolCallId,
|
||||
|
||||
@@ -18,12 +18,14 @@ describe("before_tool_call hook integration", () => {
|
||||
hasHooks: vi.fn(),
|
||||
runBeforeToolCall: vi.fn(),
|
||||
};
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
mockGetGlobalHookRunner.mockReturnValue(hookRunner as any);
|
||||
});
|
||||
|
||||
it("executes tool normally when no hook is registered", async () => {
|
||||
hookRunner.hasHooks.mockReturnValue(false);
|
||||
const execute = vi.fn().mockResolvedValue({ content: [], details: { ok: true } });
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const tool = wrapToolWithBeforeToolCallHook({ name: "Read", execute } as any, {
|
||||
agentId: "main",
|
||||
sessionKey: "main",
|
||||
@@ -39,6 +41,7 @@ describe("before_tool_call hook integration", () => {
|
||||
hookRunner.hasHooks.mockReturnValue(true);
|
||||
hookRunner.runBeforeToolCall.mockResolvedValue({ params: { mode: "safe" } });
|
||||
const execute = vi.fn().mockResolvedValue({ content: [], details: { ok: true } });
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const tool = wrapToolWithBeforeToolCallHook({ name: "exec", execute } as any);
|
||||
|
||||
await tool.execute("call-2", { cmd: "ls" }, undefined, undefined);
|
||||
@@ -58,6 +61,7 @@ describe("before_tool_call hook integration", () => {
|
||||
blockReason: "blocked",
|
||||
});
|
||||
const execute = vi.fn().mockResolvedValue({ content: [], details: { ok: true } });
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const tool = wrapToolWithBeforeToolCallHook({ name: "exec", execute } as any);
|
||||
|
||||
await expect(tool.execute("call-3", { cmd: "rm -rf /" }, undefined, undefined)).rejects.toThrow(
|
||||
@@ -70,6 +74,7 @@ describe("before_tool_call hook integration", () => {
|
||||
hookRunner.hasHooks.mockReturnValue(true);
|
||||
hookRunner.runBeforeToolCall.mockRejectedValue(new Error("boom"));
|
||||
const execute = vi.fn().mockResolvedValue({ content: [], details: { ok: true } });
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const tool = wrapToolWithBeforeToolCallHook({ name: "read", execute } as any);
|
||||
|
||||
await tool.execute("call-4", { path: "/tmp/file" }, undefined, undefined);
|
||||
@@ -81,6 +86,7 @@ describe("before_tool_call hook integration", () => {
|
||||
hookRunner.hasHooks.mockReturnValue(true);
|
||||
hookRunner.runBeforeToolCall.mockResolvedValue(undefined);
|
||||
const execute = vi.fn().mockResolvedValue({ content: [], details: { ok: true } });
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const tool = wrapToolWithBeforeToolCallHook({ name: "ReAd", execute } as any, {
|
||||
agentId: "main",
|
||||
sessionKey: "main",
|
||||
@@ -113,6 +119,7 @@ describe("before_tool_call hook integration for client tools", () => {
|
||||
hasHooks: vi.fn(),
|
||||
runBeforeToolCall: vi.fn(),
|
||||
};
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
mockGetGlobalHookRunner.mockReturnValue(hookRunner as any);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
export type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
@@ -25,7 +25,8 @@ export function guardSessionManager(
|
||||
|
||||
const hookRunner = getGlobalHookRunner();
|
||||
const transform = hookRunner?.hasHooks("tool_result_persist")
|
||||
? (message: any, meta: { toolCallId?: string; toolName?: string; isSynthetic?: boolean }) => {
|
||||
? // oxlint-disable-next-line typescript/no-explicit-any
|
||||
(message: any, meta: { toolCallId?: string; toolName?: string; isSynthetic?: boolean }) => {
|
||||
const out = hookRunner.runToolResultPersist(
|
||||
{
|
||||
toolName: meta.toolName,
|
||||
|
||||
@@ -52,6 +52,7 @@ describe("tool_result_persist hook", () => {
|
||||
isError: false,
|
||||
content: [{ type: "text", text: "ok" }],
|
||||
details: { big: "x".repeat(10_000) },
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
} as any);
|
||||
|
||||
const messages = sm
|
||||
@@ -59,6 +60,7 @@ describe("tool_result_persist hook", () => {
|
||||
.filter((e) => e.type === "message")
|
||||
.map((e) => (e as { message: AgentMessage }).message);
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const toolResult = messages.find((m) => (m as any).role === "toolResult") as any;
|
||||
expect(toolResult).toBeTruthy();
|
||||
expect(toolResult.details).toBeTruthy();
|
||||
@@ -121,6 +123,7 @@ describe("tool_result_persist hook", () => {
|
||||
isError: false,
|
||||
content: [{ type: "text", text: "ok" }],
|
||||
details: { big: "x".repeat(10_000) },
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
} as any);
|
||||
|
||||
const messages = sm
|
||||
@@ -128,6 +131,7 @@ describe("tool_result_persist hook", () => {
|
||||
.filter((e) => e.type === "message")
|
||||
.map((e) => (e as { message: AgentMessage }).message);
|
||||
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
const toolResult = messages.find((m) => (m as any).role === "toolResult") as any;
|
||||
expect(toolResult).toBeTruthy();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
|
||||
import { detectMime } from "../../media/mime.js";
|
||||
import { sanitizeToolResultImages } from "../tool-images.js";
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: TypeBox schema type from pi-agent-core uses a different module instance.
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
export type AnyAgentTool = AgentTool<any, unknown>;
|
||||
|
||||
export type StringParamOptions = {
|
||||
|
||||
Reference in New Issue
Block a user