`tool` function FlexibleSchema type issues?

### Description

I am having TypeScript issues when compiling the following, despite the generic type parameters seeming to align appropriately. Is there a way to resolve this? It seems like the signatures aren't quite matching up for some reason, and it seems like FlexibleSchema is clashing with types in this instance for some reason.

Is there a way around type-casting? I ideally like to avoid it if necessary - especially since they're both zod types. Note: removed ToolOutput, outputSchema in this example.

```ts
import { JSONValue } from '@ai-sdk/provider';
import { tool } from 'ai';
import { z } from 'zod/v4';

export abstract class BaseTool<
  ToolInput extends JSONValue | unknown | never = any, // Uses the same type parameters as `tool<INPUT>(...)`
> {
  abstract getName(): string;
  abstract getDescription(): string;
  abstract getInputSchema(): z.ZodType<ToolInput>; // defines the inputSchema type for abstract class
  abstract execute(args: ToolInput): Promise<unknown>;

  toAITool() {
    return tool<ToolInput>({
      name: this.getName(),
      description: this.getDescription(),
      inputSchema: this.getInputSchema(), // doesnt align with FlexibleSchema? Both are zod/v4 compatible?
      execute: this.execute.bind(this),
    });
  }
}
```

Getting the following at the bottom of compilation errors which seems to point towards `inputSchema: FlexibleSchema<INPUT>;` on the `Tool` type definition. 

This isn't exposed, and I am a bit **uncertain how to ensure type safety without forcing as any/similar**. This abstract class does work safely enough in an example class I created, and works with the other inferencing types available (examples cited in code).

```
Types of property 'inputSchema' are incompatible.
            Type 'ZodType<ToolInput, unknown, $ZodTypeInternals<ToolInput, unknown>>' is not assignable to type 'undefined'.ts(2769)
```

```ts
import { Injectable } from '@nestjs/common';
import { InferToolInput, InferToolOutput, InferUITool, Tool } from 'ai';
import { z } from 'zod/v4';

import { BaseTool } from './base/base-tool';

const TestToolInputSchema = z.object({ foo: z.string() });
type TestToolInput = z.infer<typeof TestToolInputSchema>;

const TestToolOutputSchema = z.array(z.string());
type TestToolOutput = z.infer<typeof TestToolOutputSchema>;

// InferUITool is used to get the UI type for the tool
type InferTool<T> = T extends BaseTool<infer U> ? Tool<U> : never;

// Works to get the tool type for the tool w/ zod input schema
type TestToolType = InferTool<TestTool>;

// Works to get the UI type for the tool
type UIInput = InferToolInput<TestToolType>;
type UIOutput = InferToolOutput<TestToolType>;
type UITool = InferUITool<TestToolType>;

@Injectable()
export class TestTool extends BaseTool<TestToolInput, TestToolOutput> {
  constructor() {
    // Removed injection of Service for simplicity of the example
    super();
  }

  getName(): string {
    return 'test-tool';
  }

  getDescription(): string {
    return 'test example for github issue';
  }

  getInputSchema() {
    return TestToolInputSchema;
  }

  getOutputSchema() {
    return TestToolOutputSchema;
  }

  async execute(): Promise<string[]> {
    // Simulating a test execution, returning a static array for demonstration,
    // this would typically run a service call
    return ['test1', 'test2', 'test3'];
  }
}
```

### AI SDK Version

Just upgraded to v5, was in the midst of upgrading to beta (otherwise has been smooth) 
- "@ai-sdk/vue": "^2.0.0",
- "ai": "^5.0.0",
- "zod": "^3.25.76"

Labels: bug, ai/core, ai/provider
State: closed