modality-kit 0.11.2 → 0.12.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.
@@ -91,12 +91,12 @@ declare const fileEntrySchema: z.ZodObject<{
91
91
  type: z.ZodEnum<["file", "directory"]>;
92
92
  lastModified: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
93
93
  }, "strip", z.ZodTypeAny, {
94
- type: "file" | "directory";
95
94
  path: string;
95
+ type: "file" | "directory";
96
96
  lastModified?: number | null | undefined;
97
97
  }, {
98
- type: "file" | "directory";
99
98
  path: string;
99
+ type: "file" | "directory";
100
100
  lastModified?: number | null | undefined;
101
101
  }>;
102
102
  export type FileEntryType = z.infer<typeof fileEntrySchema>;
@@ -1,19 +1,22 @@
1
1
  /**
2
2
  * TypeScript interfaces for tool configuration objects
3
3
  */
4
- export type AIToolExecutor = (...args: any[]) => Promise<string>;
4
+ import { z } from "zod";
5
5
  /**
6
6
  * Tool interface for AI SDK compatibility
7
7
  */
8
- export interface AITool {
8
+ export interface AITool<T extends z.ZodSchema = z.ZodSchema> {
9
9
  name?: string;
10
10
  annotations?: any;
11
11
  description: string;
12
- inputSchema: any;
13
- execute: AIToolExecutor;
12
+ inputSchema: T;
13
+ execute: (args: z.infer<T>) => Promise<string>;
14
14
  }
15
15
  /**
16
- * Type for a collection of AI tools
17
- * @template T - The key type for the tools record, defaults to string
16
+ * Type for a collection of AI tools with preserved schema types
17
+ * @template T - Record mapping tool names to their inputSchema types
18
+ * @example AITools<{getUserById: z.object({id: z.string()}), createUser: z.object({name: z.string()})}>
18
19
  */
19
- export type AITools<T extends string | number | symbol = string> = Record<T, AITool>;
20
+ export type AITools<T extends Record<string, z.ZodSchema> = Record<string, z.ZodSchema>> = {
21
+ [K in keyof T]: AITool<T[K]>;
22
+ };
@@ -1,9 +1,11 @@
1
1
  import type { FastMCP } from "fastmcp";
2
2
  import type { AITools } from "./schemas/schemas_tool_config.ts";
3
+ import type { z } from "zod";
3
4
  /**
4
5
  * Setup function that optionally registers AITools with MCP server
5
- * @param aiTools - The AITools object to optionally register
6
+ * Automatically infers and preserves schema types from the input
7
+ * @param aiTools - The AITools object with schema mapping
6
8
  * @param mcpServer - Optional MCP server to register tools with
7
- * @returns The AITools object
9
+ * @returns The same AITools object with preserved types
8
10
  */
9
- export declare const setupAITools: (aiTools: AITools, mcpServer?: FastMCP) => AITools;
11
+ export declare const setupAITools: <T extends Record<string, z.ZodSchema>>(aiTools: AITools<T>, mcpServer?: FastMCP) => AITools<T>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.11.2",
2
+ "version": "0.12.0",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "scripts": {
25
25
  "update-compile-sh": "yo reshow:compile-sh",
26
26
  "build:clean": "find ./dist -name '*.*' | xargs rm -rf",
27
- "build:types": "bunx tsc -p ./",
27
+ "build:types": "bun tsc -p ./",
28
28
  "build:src": "bun build src/index.ts --outdir dist",
29
29
  "build": "bun run build:clean && bun run build:src && bun run build:types",
30
30
  "dev": "bunx concurrently 'bunx --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",