-
-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
TanStack AI version
0.2.0
Framework/Library version
TypeScript, Node
Describe the bug and the steps to reproduce it
Hi,
I have come across a small type related issue when assigning JSON Schema to tool definitions via factory function. The issue appears to be caused by the JSONSchema type used to constrain toolDefinition signature. Reproduction code below.
import { toolDefinition } from '@tanstack/ai'
// ---------------------------------------------------------
// Case A: Error
// ---------------------------------------------------------
export interface XString {
type: 'string'
}
function string(): XString {
return { type: 'string' }
}
const A = toolDefinition({ // 'XString' is not assignable to type 'SchemaInput | undefined'.
inputSchema: string(),
name: 'A string',
description: 'A string',
})
// ---------------------------------------------------------
// Case B: Ok
// ---------------------------------------------------------
const B = toolDefinition({
inputSchema: { type: 'string' },
name: 'A string',
description: 'A string',
})
// ---------------------------------------------------------
// Case C: Ok
// ---------------------------------------------------------
import * as z from 'zod'
const C = toolDefinition({
inputSchema: z.string(),
name: 'A string',
description: 'A string',
})The issue appears to be caused by the indexer property on the JSONSchema (used for property extension)
https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L63
{
[key: string]: unknown // Allow additional properties for extensibility
}... where unknown can be substituted for any to resolve the issue.
{
[key: string]: any // Allow additional properties for extensibility
}Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels