@langgraph-js/sdk 3.4.0 → 3.4.1

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,6 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export declare const ArtifactCommandSchema: {
3
- command: z.ZodEnum<["create", "update", "rewrite"]>;
3
+ command: z.ZodEnum<{
4
+ create: "create";
5
+ update: "update";
6
+ rewrite: "rewrite";
7
+ }>;
4
8
  id: z.ZodString;
5
9
  title: z.ZodString;
6
10
  type: z.ZodString;
@@ -1,4 +1,4 @@
1
- import { z, ZodRawShape, ZodTypeAny } from "zod";
1
+ import { z, ZodRawShape } from "zod";
2
2
  import { Action, Parameter } from "./copilotkit-actions.js";
3
3
  import { Message } from "@langchain/langgraph-sdk";
4
4
  import { ToolRenderData } from "./ToolUI.js";
@@ -11,8 +11,8 @@ export interface UnionTool<Args extends ZodRawShape, Child extends Object = Obje
11
11
  execute?: ToolCallback<Args>;
12
12
  /** 工具执行成功后触发的附加消息 */
13
13
  callbackMessage?: (result: CallToolResult) => Message[];
14
- handler?: (args: z.objectOutputType<Args, ZodTypeAny>, context?: any) => ResponseType | Promise<ResponseType>;
15
- render?: (tool: ToolRenderData<z.objectOutputType<Args, ZodTypeAny>, ResponseType>) => Child;
14
+ handler?: (args: z.infer<z.ZodObject<Args>>, context?: any) => ResponseType | Promise<ResponseType>;
15
+ render?: (tool: ToolRenderData<z.infer<z.ZodObject<Args>>, ResponseType>) => Child;
16
16
  onlyRender?: boolean;
17
17
  /** 只允许指定的 agent 使用该工具,如果未指定,则所有 agent 都可以使用 */
18
18
  allowAgent?: string[];
@@ -21,7 +21,7 @@ export interface UnionTool<Args extends ZodRawShape, Child extends Object = Obje
21
21
  /** 是否是纯净的 json schema 参数,而不是 zod 参数 */
22
22
  isPureParams?: boolean;
23
23
  }
24
- export type ToolCallback<Args extends ZodRawShape> = (args: z.objectOutputType<Args, ZodTypeAny>, context?: any) => CallToolResult | Promise<CallToolResult>;
24
+ export type ToolCallback<Args extends ZodRawShape> = (args: z.infer<z.ZodObject<Args>>, context?: any) => CallToolResult | Promise<CallToolResult>;
25
25
  export type CallToolResult = string | {
26
26
  type: "text";
27
27
  text: string;
@@ -70,7 +70,7 @@ export declare const createJSONDefineTool: <Args extends ZodRawShape>(tool: Unio
70
70
  [key: string]: import("zod-to-json-schema").JsonSchema7Type;
71
71
  } | undefined;
72
72
  }) | ({
73
- type: ("string" | "number" | "boolean" | "integer" | "null") | ("string" | "number" | "boolean" | "integer" | "null")[];
73
+ type: ("string" | "number" | "boolean" | "null" | "integer") | ("string" | "number" | "boolean" | "null" | "integer")[];
74
74
  } & {
75
75
  title?: string;
76
76
  default?: any;
@@ -149,7 +149,7 @@ export declare const createJSONDefineTool: <Args extends ZodRawShape>(tool: Unio
149
149
  } | undefined;
150
150
  });
151
151
  };
152
- export declare const createMCPTool: <Args extends ZodRawShape>(tool: UnionTool<Args>) => (string | Args | ((args: z.objectOutputType<Args, ZodTypeAny>) => Promise<{
152
+ export declare const createMCPTool: <Args extends ZodRawShape>(tool: UnionTool<Args>) => (string | Args | ((args: z.infer<z.ZodObject<Args>>) => Promise<{
153
153
  content: {
154
154
  type: string;
155
155
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langgraph-js/sdk",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "The UI SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "jsonrepair": "^3.12.0",
50
50
  "nanostores": "^1.0.1",
51
51
  "ts-debounce": "^4.0.0",
52
- "zod": "^3.25.17",
52
+ "zod": "^4",
53
53
  "zod-to-json-schema": "^3.24.5"
54
54
  },
55
55
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
1
  import { actionParametersToJsonSchema, convertJsonSchemaToZodRawShape } from "./utils.js";
2
- import { z, ZodRawShape, ZodTypeAny } from "zod";
2
+ import { z, ZodRawShape } from "zod";
3
3
  import { Action, Parameter } from "./copilotkit-actions.js";
4
4
  import { zodToJsonSchema } from "zod-to-json-schema";
5
5
  import { Message } from "@langchain/langgraph-sdk";
@@ -14,8 +14,8 @@ export interface UnionTool<Args extends ZodRawShape, Child extends Object = Obje
14
14
  execute?: ToolCallback<Args>;
15
15
  /** 工具执行成功后触发的附加消息 */
16
16
  callbackMessage?: (result: CallToolResult) => Message[];
17
- handler?: (args: z.objectOutputType<Args, ZodTypeAny>, context?: any) => ResponseType | Promise<ResponseType>;
18
- render?: (tool: ToolRenderData<z.objectOutputType<Args, ZodTypeAny>, ResponseType>) => Child;
17
+ handler?: (args: z.infer<z.ZodObject<Args>>, context?: any) => ResponseType | Promise<ResponseType>;
18
+ render?: (tool: ToolRenderData<z.infer<z.ZodObject<Args>>, ResponseType>) => Child;
19
19
  onlyRender?: boolean;
20
20
  /** 只允许指定的 agent 使用该工具,如果未指定,则所有 agent 都可以使用 */
21
21
  allowAgent?: string[];
@@ -24,7 +24,7 @@ export interface UnionTool<Args extends ZodRawShape, Child extends Object = Obje
24
24
  /** 是否是纯净的 json schema 参数,而不是 zod 参数 */
25
25
  isPureParams?: boolean;
26
26
  }
27
- export type ToolCallback<Args extends ZodRawShape> = (args: z.objectOutputType<Args, ZodTypeAny>, context?: any) => CallToolResult | Promise<CallToolResult>;
27
+ export type ToolCallback<Args extends ZodRawShape> = (args: z.infer<z.ZodObject<Args>>, context?: any) => CallToolResult | Promise<CallToolResult>;
28
28
 
29
29
  export type CallToolResult = string | { type: "text"; text: string }[];
30
30
 
@@ -80,7 +80,7 @@ export const createFETool = <const T extends Parameter[], Args extends ZodRawSha
80
80
  allowGraph: tool.allowGraph,
81
81
  async execute(args, context) {
82
82
  try {
83
- const result = await tool.handler?.(args, context);
83
+ const result = await tool.handler?.(args as any, context);
84
84
  if (typeof result === "string") {
85
85
  return [{ type: "text", text: result }];
86
86
  }
@@ -106,7 +106,7 @@ export const createMCPTool = <Args extends ZodRawShape>(tool: UnionTool<Args>) =
106
106
  tool.name,
107
107
  tool.description,
108
108
  tool.parameters,
109
- async (args: z.objectOutputType<Args, ZodTypeAny>) => {
109
+ async (args: z.infer<z.ZodObject<Args>>) => {
110
110
  try {
111
111
  const result = await tool.execute?.(args);
112
112
  if (typeof result === "string") {