@tanstack/ai-anthropic 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
- import { Tool } from '@tanstack/ai';
2
- import { z } from 'zod';
1
+ import { SchemaInput, Tool } from '@tanstack/ai';
3
2
  import { CacheControl } from '../text/text-provider-options.js';
4
3
  export interface CustomTool {
5
4
  /**
@@ -22,4 +21,4 @@ export interface CustomTool {
22
21
  cache_control?: CacheControl | null;
23
22
  }
24
23
  export declare function convertCustomToolToAdapterFormat(tool: Tool): CustomTool;
25
- export declare function customTool(name: string, description: string, inputSchema: z.ZodType, cacheControl?: CacheControl | null): Tool;
24
+ export declare function customTool(name: string, description: string, inputSchema: SchemaInput, cacheControl?: CacheControl | null): Tool;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-tool.js","sources":["../../../src/tools/custom-tool.ts"],"sourcesContent":["import type { JSONSchema, Tool } from '@tanstack/ai'\nimport type { z } from 'zod'\nimport type { CacheControl } from '../text/text-provider-options'\n\nexport interface CustomTool {\n /**\n * The name of the tool.\n */\n name: string\n type: 'custom'\n /**\n * A brief description of what the tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.\n */\n description: string\n /**\n * This defines the shape of the input that your tool accepts and that the model will produce.\n */\n input_schema: {\n type: 'object'\n properties: Record<string, any> | null\n required?: Array<string> | null\n }\n\n cache_control?: CacheControl | null\n}\n\nexport function convertCustomToolToAdapterFormat(tool: Tool): CustomTool {\n const metadata =\n (tool.metadata as { cacheControl?: CacheControl | null } | undefined) || {}\n\n // Tool schemas are already converted to JSON Schema in the ai layer\n const jsonSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n const inputSchema = {\n type: 'object' as const,\n properties: jsonSchema.properties || null,\n required: jsonSchema.required || null,\n }\n\n return {\n name: tool.name,\n type: 'custom',\n description: tool.description,\n input_schema: inputSchema,\n cache_control: metadata.cacheControl || null,\n }\n}\n\nexport function customTool(\n name: string,\n description: string,\n inputSchema: z.ZodType,\n cacheControl?: CacheControl | null,\n): Tool {\n return {\n name,\n description,\n inputSchema,\n metadata: {\n cacheControl,\n },\n }\n}\n"],"names":[],"mappings":"AA0BO,SAAS,iCAAiC,MAAwB;AACvE,QAAM,WACH,KAAK,YAAmE,CAAA;AAG3E,QAAM,aAAc,KAAK,eAAe;AAAA,IAEtC,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,EAAC;AAGb,QAAM,cAAc;AAAA,IAClB,MAAM;AAAA,IACN,YAAY,WAAW,cAAc;AAAA,IACrC,UAAU,WAAW,YAAY;AAAA,EAAA;AAGnC,SAAO;AAAA,IACL,MAAM,KAAK;AAAA,IACX,MAAM;AAAA,IACN,aAAa,KAAK;AAAA,IAClB,cAAc;AAAA,IACd,eAAe,SAAS,gBAAgB;AAAA,EAAA;AAE5C;"}
1
+ {"version":3,"file":"custom-tool.js","sources":["../../../src/tools/custom-tool.ts"],"sourcesContent":["import type { JSONSchema, SchemaInput, Tool } from '@tanstack/ai'\nimport type { CacheControl } from '../text/text-provider-options'\n\nexport interface CustomTool {\n /**\n * The name of the tool.\n */\n name: string\n type: 'custom'\n /**\n * A brief description of what the tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.\n */\n description: string\n /**\n * This defines the shape of the input that your tool accepts and that the model will produce.\n */\n input_schema: {\n type: 'object'\n properties: Record<string, any> | null\n required?: Array<string> | null\n }\n\n cache_control?: CacheControl | null\n}\n\nexport function convertCustomToolToAdapterFormat(tool: Tool): CustomTool {\n const metadata =\n (tool.metadata as { cacheControl?: CacheControl | null } | undefined) || {}\n\n // Tool schemas are already converted to JSON Schema in the ai layer\n const jsonSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n const inputSchema = {\n type: 'object' as const,\n properties: jsonSchema.properties || null,\n required: jsonSchema.required || null,\n }\n\n return {\n name: tool.name,\n type: 'custom',\n description: tool.description,\n input_schema: inputSchema,\n cache_control: metadata.cacheControl || null,\n }\n}\n\nexport function customTool(\n name: string,\n description: string,\n inputSchema: SchemaInput,\n cacheControl?: CacheControl | null,\n): Tool {\n return {\n name,\n description,\n inputSchema,\n metadata: {\n cacheControl,\n },\n }\n}\n"],"names":[],"mappings":"AAyBO,SAAS,iCAAiC,MAAwB;AACvE,QAAM,WACH,KAAK,YAAmE,CAAA;AAG3E,QAAM,aAAc,KAAK,eAAe;AAAA,IAEtC,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,EAAC;AAGb,QAAM,cAAc;AAAA,IAClB,MAAM;AAAA,IACN,YAAY,WAAW,cAAc;AAAA,IACrC,UAAU,WAAW,YAAY;AAAA,EAAA;AAGnC,SAAO;AAAA,IACL,MAAM,KAAK;AAAA,IACX,MAAM;AAAA,IACN,aAAa,KAAK;AAAA,IAClB,cAAc;AAAA,IACd,eAAe,SAAS,gBAAgB;AAAA,EAAA;AAE5C;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-anthropic",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Anthropic Claude adapter for TanStack AI",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -30,15 +30,14 @@
30
30
  "src"
31
31
  ],
32
32
  "dependencies": {
33
- "@anthropic-ai/sdk": "^0.71.0",
34
- "@tanstack/ai": "0.1.0"
33
+ "@anthropic-ai/sdk": "^0.71.0"
35
34
  },
36
35
  "devDependencies": {
37
36
  "@vitest/coverage-v8": "4.0.14"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "zod": "^4.0.0",
41
- "@tanstack/ai": "0.1.0"
40
+ "@tanstack/ai": "^0.2.0"
42
41
  },
43
42
  "scripts": {
44
43
  "build": "vite build",
@@ -1,5 +1,4 @@
1
- import type { JSONSchema, Tool } from '@tanstack/ai'
2
- import type { z } from 'zod'
1
+ import type { JSONSchema, SchemaInput, Tool } from '@tanstack/ai'
3
2
  import type { CacheControl } from '../text/text-provider-options'
4
3
 
5
4
  export interface CustomTool {
@@ -53,7 +52,7 @@ export function convertCustomToolToAdapterFormat(tool: Tool): CustomTool {
53
52
  export function customTool(
54
53
  name: string,
55
54
  description: string,
56
- inputSchema: z.ZodType,
55
+ inputSchema: SchemaInput,
57
56
  cacheControl?: CacheControl | null,
58
57
  ): Tool {
59
58
  return {