@langgraph-js/sdk 1.1.4 → 1.1.6

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.
package/ui/tool.ts CHANGED
@@ -1,55 +1,55 @@
1
- import { z } from "zod";
2
- import { createTool, createFETool } from "../src/tool/createTool";
3
-
4
- export function createTools() {
5
- // 文件操作工具
6
- const fileTool = createTool({
7
- name: "file_operation",
8
- description: "执行文件操作,包括读取和写入",
9
- parameters: {
10
- operation: z.enum(["read", "write"]).describe("操作类型:read-读取文件,write-写入文件"),
11
- filePath: z.string().describe("文件的完整路径"),
12
- content: z.string().optional().describe("写入文件时的内容,仅在 operation 为 write 时需要"),
13
- },
14
- async execute(args) {
15
- return [{ type: "text", text: "执行文件操作" }];
16
- },
17
- });
18
-
19
- // 用户交互工具
20
- const userInteractionTool = createFETool({
21
- name: "user_interaction",
22
- description: "与用户进行交互,包括确认和输入",
23
- parameters: [
24
- {
25
- name: "type",
26
- type: "string",
27
- description: "交互类型:confirm-确认,input-输入",
28
- },
29
- {
30
- name: "message",
31
- type: "string",
32
- description: "向用户展示的信息",
33
- },
34
- {
35
- name: "options",
36
- type: "string[]",
37
- description: "选项列表,仅在 type 为 confirm 时使用",
38
- optional: true,
39
- },
40
- ],
41
- handler: async (args) => {
42
- return {
43
- success: true,
44
- data: {
45
- type: args.type,
46
- message: args.message,
47
- options: args.options || ["确认", "取消"],
48
- },
49
- message: "等待用户响应",
50
- };
51
- },
52
- });
53
-
54
- return [fileTool, userInteractionTool];
55
- }
1
+ import { z } from "zod";
2
+ import { createTool, createFETool } from "../src/tool/createTool";
3
+
4
+ export function createTools() {
5
+ // 文件操作工具
6
+ const fileTool = createTool({
7
+ name: "file_operation",
8
+ description: "执行文件操作,包括读取和写入",
9
+ parameters: {
10
+ operation: z.enum(["read", "write"]).describe("操作类型:read-读取文件,write-写入文件"),
11
+ filePath: z.string().describe("文件的完整路径"),
12
+ content: z.string().optional().describe("写入文件时的内容,仅在 operation 为 write 时需要"),
13
+ },
14
+ async execute(args) {
15
+ return [{ type: "text", text: "执行文件操作" }];
16
+ },
17
+ });
18
+
19
+ // 用户交互工具
20
+ const userInteractionTool = createFETool({
21
+ name: "user_interaction",
22
+ description: "与用户进行交互,包括确认和输入",
23
+ parameters: [
24
+ {
25
+ name: "type",
26
+ type: "string",
27
+ description: "交互类型:confirm-确认,input-输入",
28
+ },
29
+ {
30
+ name: "message",
31
+ type: "string",
32
+ description: "向用户展示的信息",
33
+ },
34
+ {
35
+ name: "options",
36
+ type: "string[]",
37
+ description: "选项列表,仅在 type 为 confirm 时使用",
38
+ optional: true,
39
+ },
40
+ ],
41
+ handler: async (args) => {
42
+ return {
43
+ success: true,
44
+ data: {
45
+ type: args.type,
46
+ message: args.message,
47
+ options: args.options || ["确认", "取消"],
48
+ },
49
+ message: "等待用户响应",
50
+ };
51
+ },
52
+ });
53
+
54
+ return [fileTool, userInteractionTool];
55
+ }