@langgraph-js/sdk 1.6.3 → 1.7.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.
Files changed (42) hide show
  1. package/.env +0 -0
  2. package/.turbo/turbo-build.log +5 -0
  3. package/LICENSE +201 -201
  4. package/README.md +163 -163
  5. package/dist/LangGraphClient.d.ts +3 -0
  6. package/dist/LangGraphClient.js +19 -1
  7. package/dist/server/createState.d.ts +13 -0
  8. package/dist/server/createState.js +20 -0
  9. package/dist/server/feTools.d.ts +16 -0
  10. package/dist/server/feTools.js +37 -0
  11. package/dist/server/index.d.ts +3 -0
  12. package/dist/server/index.js +3 -0
  13. package/dist/server/interrupt/index.d.ts +23 -0
  14. package/dist/server/interrupt/index.js +36 -0
  15. package/dist/server/swarm/handoff.d.ts +11 -0
  16. package/dist/server/swarm/handoff.js +84 -0
  17. package/dist/server/swarm/keepState.d.ts +6 -0
  18. package/dist/server/swarm/keepState.js +21 -0
  19. package/dist/server/tools/index.d.ts +1 -0
  20. package/dist/server/tools/index.js +1 -0
  21. package/dist/server/tools/sequential-thinking.d.ts +52 -0
  22. package/dist/server/tools/sequential-thinking.js +69 -0
  23. package/dist/server/utils.d.ts +3 -0
  24. package/dist/server/utils.js +24 -0
  25. package/dist/ui-store/createChatStore.d.ts +1 -0
  26. package/dist/ui-store/createChatStore.js +4 -0
  27. package/package.json +1 -1
  28. package/src/LangGraphClient.ts +657 -638
  29. package/src/SpendTime.ts +60 -60
  30. package/src/ToolManager.ts +131 -131
  31. package/src/index.ts +5 -5
  32. package/src/tool/ToolUI.ts +41 -41
  33. package/src/tool/copilotkit-actions.ts +72 -72
  34. package/src/tool/createTool.ts +102 -102
  35. package/src/tool/index.ts +3 -3
  36. package/src/tool/utils.ts +158 -158
  37. package/src/ui-store/UnionStore.ts +29 -29
  38. package/src/ui-store/createChatStore.ts +298 -294
  39. package/src/ui-store/index.ts +2 -2
  40. package/src/ui-store/rafDebounce.ts +29 -29
  41. package/test/testResponse.json +5418 -5418
  42. package/tsconfig.json +112 -112
package/src/SpendTime.ts CHANGED
@@ -1,60 +1,60 @@
1
- /**
2
- * @zh SpendTime 类用于计算和记录操作的耗时。
3
- * @en The SpendTime class is used to calculate and record the time spent on operations.
4
- */
5
- export class SpendTime {
6
- private timeCounter = new Map<string, [Date, Date] | [Date]>();
7
-
8
- /**
9
- * @zh 开始计时。
10
- * @en Starts timing.
11
- */
12
- start(key: string) {
13
- this.timeCounter.set(key, [new Date()]);
14
- }
15
-
16
- /**
17
- * @zh 结束计时。
18
- * @en Ends timing.
19
- */
20
- end(key: string) {
21
- this.timeCounter.set(key, [this.timeCounter.get(key)?.[0] || new Date(), new Date()]);
22
- }
23
-
24
- /**
25
- * @zh 设置或更新指定键的耗时记录。如果键已存在,则更新结束时间;否则,开始新的计时。
26
- * @en Sets or updates the time spent record for the specified key. If the key already exists, updates the end time; otherwise, starts a new timing.
27
- */
28
- setSpendTime(key: string) {
29
- if (this.timeCounter.has(key)) {
30
- this.end(key);
31
- } else {
32
- this.start(key);
33
- }
34
- }
35
-
36
- /**
37
- * @zh 获取指定键的开始时间。
38
- * @en Gets the start time for the specified key.
39
- */
40
- getStartTime(key: string) {
41
- return this.timeCounter.get(key)?.[0] || new Date();
42
- }
43
-
44
- /**
45
- * @zh 获取指定键的结束时间。
46
- * @en Gets the end time for the specified key.
47
- */
48
- getEndTime(key: string) {
49
- return this.timeCounter.get(key)?.[1] || new Date();
50
- }
51
-
52
- /**
53
- * @zh 获取指定键的耗时(毫秒)。
54
- * @en Gets the time spent (in milliseconds) for the specified key.
55
- */
56
- getSpendTime(key: string) {
57
- const [start, end = new Date()] = this.timeCounter.get(key) || [new Date(), new Date()];
58
- return end.getTime() - start.getTime();
59
- }
60
- }
1
+ /**
2
+ * @zh SpendTime 类用于计算和记录操作的耗时。
3
+ * @en The SpendTime class is used to calculate and record the time spent on operations.
4
+ */
5
+ export class SpendTime {
6
+ private timeCounter = new Map<string, [Date, Date] | [Date]>();
7
+
8
+ /**
9
+ * @zh 开始计时。
10
+ * @en Starts timing.
11
+ */
12
+ start(key: string) {
13
+ this.timeCounter.set(key, [new Date()]);
14
+ }
15
+
16
+ /**
17
+ * @zh 结束计时。
18
+ * @en Ends timing.
19
+ */
20
+ end(key: string) {
21
+ this.timeCounter.set(key, [this.timeCounter.get(key)?.[0] || new Date(), new Date()]);
22
+ }
23
+
24
+ /**
25
+ * @zh 设置或更新指定键的耗时记录。如果键已存在,则更新结束时间;否则,开始新的计时。
26
+ * @en Sets or updates the time spent record for the specified key. If the key already exists, updates the end time; otherwise, starts a new timing.
27
+ */
28
+ setSpendTime(key: string) {
29
+ if (this.timeCounter.has(key)) {
30
+ this.end(key);
31
+ } else {
32
+ this.start(key);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * @zh 获取指定键的开始时间。
38
+ * @en Gets the start time for the specified key.
39
+ */
40
+ getStartTime(key: string) {
41
+ return this.timeCounter.get(key)?.[0] || new Date();
42
+ }
43
+
44
+ /**
45
+ * @zh 获取指定键的结束时间。
46
+ * @en Gets the end time for the specified key.
47
+ */
48
+ getEndTime(key: string) {
49
+ return this.timeCounter.get(key)?.[1] || new Date();
50
+ }
51
+
52
+ /**
53
+ * @zh 获取指定键的耗时(毫秒)。
54
+ * @en Gets the time spent (in milliseconds) for the specified key.
55
+ */
56
+ getSpendTime(key: string) {
57
+ const [start, end = new Date()] = this.timeCounter.get(key) || [new Date(), new Date()];
58
+ return end.getTime() - start.getTime();
59
+ }
60
+ }
@@ -1,131 +1,131 @@
1
- import { ToolMessage } from "@langchain/langgraph-sdk";
2
- import { LangGraphClient } from "./LangGraphClient.js";
3
- import { CallToolResult, createJSONDefineTool, UnionTool } from "./tool/createTool.js";
4
-
5
- /**
6
- * @zh ToolManager 类用于管理和执行工具。
7
- * @en The ToolManager class is used to manage and execute tools.
8
- */
9
- export class ToolManager {
10
- private tools: Map<string, UnionTool<any>> = new Map();
11
- // === 专门为前端设计的异步触发结构
12
- private waitingMap: Map<string, (value: CallToolResult) => void> = new Map();
13
-
14
- /**
15
- * @zh 注册一个工具。
16
- * @en Registers a tool.
17
- */
18
- bindTool(tool: UnionTool<any>) {
19
- if (this.tools.has(tool.name)) {
20
- throw new Error(`Tool with name ${tool.name} already exists`);
21
- }
22
- this.tools.set(tool.name, tool);
23
- }
24
-
25
- /**
26
- * @zh 注册多个工具。
27
- * @en Registers multiple tools.
28
- */
29
- bindTools(tools: UnionTool<any>[]) {
30
- tools.forEach((tool) => this.bindTool(tool));
31
- }
32
-
33
- /**
34
- * @zh 获取所有已注册的工具。
35
- * @en Gets all registered tools.
36
- */
37
- getAllTools(): UnionTool<any>[] {
38
- return Array.from(this.tools.values());
39
- }
40
-
41
- /**
42
- * @zh 获取指定名称的工具。
43
- * @en Gets the tool with the specified name.
44
- */
45
- getTool(name: string): UnionTool<any> | undefined {
46
- return this.tools.get(name);
47
- }
48
-
49
- /**
50
- * @zh 移除指定名称的工具。
51
- * @en Removes the tool with the specified name.
52
- */
53
- removeTool(name: string): boolean {
54
- return this.tools.delete(name);
55
- }
56
-
57
- /**
58
- * @zh 清空所有工具。
59
- * @en Clears all tools.
60
- */
61
- clearTools() {
62
- this.tools.clear();
63
- }
64
- reset() {
65
- this.clearTools();
66
- this.clearWaiting();
67
- }
68
- clearWaiting() {
69
- this.waitingMap.clear();
70
- }
71
-
72
- /**
73
- * @zh 调用指定名称的工具。
74
- * @en Calls the tool with the specified name.
75
- */
76
- async callTool(name: string, args: any, context: { client: LangGraphClient; message: ToolMessage }) {
77
- const tool = this.getTool(name);
78
- if (!tool) {
79
- throw new Error(`Tool with name ${name} not found`);
80
- }
81
- return await tool.execute(args, context);
82
- }
83
-
84
- /**
85
- * @zh 将所有工具转换为 JSON 定义格式。
86
- * @en Converts all tools to JSON definition format.
87
- */
88
- toJSON(remote = true) {
89
- return Array.from(this.tools.values())
90
- .filter((i) => (remote ? !i.onlyRender : true))
91
- .map((i) => createJSONDefineTool(i));
92
- }
93
-
94
- /**
95
- * @zh 标记指定 ID 的工具等待已完成,并传递结果。
96
- * @en Marks the tool waiting with the specified ID as completed and passes the result.
97
- */
98
- doneWaiting(id: string, value: CallToolResult) {
99
- if (this.waitingMap.has(id)) {
100
- this.waitingMap.get(id)!(value);
101
- this.waitingMap.delete(id);
102
- return true;
103
- } else {
104
- console.warn(`Waiting for tool ${id} not found`);
105
- return false;
106
- }
107
- }
108
-
109
- /**
110
- * @zh 等待指定 ID 的工具完成。
111
- * @en Waits for the tool with the specified ID to complete.
112
- */
113
- waitForDone(id: string) {
114
- if (this.waitingMap.has(id)) {
115
- return this.waitingMap.get(id);
116
- }
117
- const promise = new Promise((resolve, reject) => {
118
- this.waitingMap.set(id, resolve);
119
- });
120
- return promise;
121
- }
122
-
123
- /**
124
- * @zh 一个静态方法,用于在前端等待用户界面操作完成。
125
- * @en A static method used in the frontend to wait for user interface operations to complete.
126
- */
127
- static waitForUIDone<T>(_: T, context: { client: LangGraphClient; message: ToolMessage }) {
128
- // console.log(context.message);
129
- return context.client.tools.waitForDone(context.message.id!);
130
- }
131
- }
1
+ import { ToolMessage } from "@langchain/langgraph-sdk";
2
+ import { LangGraphClient } from "./LangGraphClient.js";
3
+ import { CallToolResult, createJSONDefineTool, UnionTool } from "./tool/createTool.js";
4
+
5
+ /**
6
+ * @zh ToolManager 类用于管理和执行工具。
7
+ * @en The ToolManager class is used to manage and execute tools.
8
+ */
9
+ export class ToolManager {
10
+ private tools: Map<string, UnionTool<any>> = new Map();
11
+ // === 专门为前端设计的异步触发结构
12
+ private waitingMap: Map<string, (value: CallToolResult) => void> = new Map();
13
+
14
+ /**
15
+ * @zh 注册一个工具。
16
+ * @en Registers a tool.
17
+ */
18
+ bindTool(tool: UnionTool<any>) {
19
+ if (this.tools.has(tool.name)) {
20
+ throw new Error(`Tool with name ${tool.name} already exists`);
21
+ }
22
+ this.tools.set(tool.name, tool);
23
+ }
24
+
25
+ /**
26
+ * @zh 注册多个工具。
27
+ * @en Registers multiple tools.
28
+ */
29
+ bindTools(tools: UnionTool<any>[]) {
30
+ tools.forEach((tool) => this.bindTool(tool));
31
+ }
32
+
33
+ /**
34
+ * @zh 获取所有已注册的工具。
35
+ * @en Gets all registered tools.
36
+ */
37
+ getAllTools(): UnionTool<any>[] {
38
+ return Array.from(this.tools.values());
39
+ }
40
+
41
+ /**
42
+ * @zh 获取指定名称的工具。
43
+ * @en Gets the tool with the specified name.
44
+ */
45
+ getTool(name: string): UnionTool<any> | undefined {
46
+ return this.tools.get(name);
47
+ }
48
+
49
+ /**
50
+ * @zh 移除指定名称的工具。
51
+ * @en Removes the tool with the specified name.
52
+ */
53
+ removeTool(name: string): boolean {
54
+ return this.tools.delete(name);
55
+ }
56
+
57
+ /**
58
+ * @zh 清空所有工具。
59
+ * @en Clears all tools.
60
+ */
61
+ clearTools() {
62
+ this.tools.clear();
63
+ }
64
+ reset() {
65
+ this.clearTools();
66
+ this.clearWaiting();
67
+ }
68
+ clearWaiting() {
69
+ this.waitingMap.clear();
70
+ }
71
+
72
+ /**
73
+ * @zh 调用指定名称的工具。
74
+ * @en Calls the tool with the specified name.
75
+ */
76
+ async callTool(name: string, args: any, context: { client: LangGraphClient; message: ToolMessage }) {
77
+ const tool = this.getTool(name);
78
+ if (!tool) {
79
+ throw new Error(`Tool with name ${name} not found`);
80
+ }
81
+ return await tool.execute(args, context);
82
+ }
83
+
84
+ /**
85
+ * @zh 将所有工具转换为 JSON 定义格式。
86
+ * @en Converts all tools to JSON definition format.
87
+ */
88
+ toJSON(remote = true) {
89
+ return Array.from(this.tools.values())
90
+ .filter((i) => (remote ? !i.onlyRender : true))
91
+ .map((i) => createJSONDefineTool(i));
92
+ }
93
+
94
+ /**
95
+ * @zh 标记指定 ID 的工具等待已完成,并传递结果。
96
+ * @en Marks the tool waiting with the specified ID as completed and passes the result.
97
+ */
98
+ doneWaiting(id: string, value: CallToolResult) {
99
+ if (this.waitingMap.has(id)) {
100
+ this.waitingMap.get(id)!(value);
101
+ this.waitingMap.delete(id);
102
+ return true;
103
+ } else {
104
+ console.warn(`Waiting for tool ${id} not found`);
105
+ return false;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * @zh 等待指定 ID 的工具完成。
111
+ * @en Waits for the tool with the specified ID to complete.
112
+ */
113
+ waitForDone(id: string) {
114
+ if (this.waitingMap.has(id)) {
115
+ return this.waitingMap.get(id);
116
+ }
117
+ const promise = new Promise((resolve, reject) => {
118
+ this.waitingMap.set(id, resolve);
119
+ });
120
+ return promise;
121
+ }
122
+
123
+ /**
124
+ * @zh 一个静态方法,用于在前端等待用户界面操作完成。
125
+ * @en A static method used in the frontend to wait for user interface operations to complete.
126
+ */
127
+ static waitForUIDone<T>(_: T, context: { client: LangGraphClient; message: ToolMessage }) {
128
+ // console.log(context.message);
129
+ return context.client.tools.waitForDone(context.message.id!);
130
+ }
131
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from "./LangGraphClient.js";
2
- export * from "./tool/index.js";
3
- export * from "@langchain/langgraph-sdk";
4
- export * from "./ui-store/index.js";
5
- export * from "./ToolManager.js";
1
+ export * from "./LangGraphClient.js";
2
+ export * from "./tool/index.js";
3
+ export * from "@langchain/langgraph-sdk";
4
+ export * from "./ui-store/index.js";
5
+ export * from "./ToolManager.js";
@@ -1,41 +1,41 @@
1
- import { RenderMessage } from "../LangGraphClient.js";
2
-
3
- import { LangGraphClient } from "../LangGraphClient.js";
4
- import { getMessageContent } from "../ui-store/createChatStore.js";
5
-
6
- export class ToolRenderData<D> {
7
- constructor(
8
- public message: RenderMessage,
9
- public client: LangGraphClient
10
- ) {}
11
- get state() {
12
- if (this.message.type === "tool" && this.message?.additional_kwargs?.done) {
13
- return "done";
14
- }
15
- return "idle";
16
- }
17
- get input() {
18
- try {
19
- return JSON.parse(this.message.tool_input!);
20
- } catch (e) {
21
- return null;
22
- }
23
- }
24
- get output() {
25
- return getMessageContent(this.message.content);
26
- }
27
- getJSONOutput() {
28
- return JSON.parse(this.output);
29
- }
30
- /** 如果解析失败,则返回 null */
31
- getJSONOutputSafe() {
32
- try {
33
- return JSON.parse(this.output);
34
- } catch (e) {
35
- return null;
36
- }
37
- }
38
- response(data: D) {
39
- this.client.doneFEToolWaiting(this.message.id!, JSON.stringify(data));
40
- }
41
- }
1
+ import { RenderMessage } from "../LangGraphClient.js";
2
+
3
+ import { LangGraphClient } from "../LangGraphClient.js";
4
+ import { getMessageContent } from "../ui-store/createChatStore.js";
5
+
6
+ export class ToolRenderData<D> {
7
+ constructor(
8
+ public message: RenderMessage,
9
+ public client: LangGraphClient
10
+ ) {}
11
+ get state() {
12
+ if (this.message.type === "tool" && this.message?.additional_kwargs?.done) {
13
+ return "done";
14
+ }
15
+ return "idle";
16
+ }
17
+ get input() {
18
+ try {
19
+ return JSON.parse(this.message.tool_input!);
20
+ } catch (e) {
21
+ return null;
22
+ }
23
+ }
24
+ get output() {
25
+ return getMessageContent(this.message.content);
26
+ }
27
+ getJSONOutput() {
28
+ return JSON.parse(this.output);
29
+ }
30
+ /** 如果解析失败,则返回 null */
31
+ getJSONOutputSafe() {
32
+ try {
33
+ return JSON.parse(this.output);
34
+ } catch (e) {
35
+ return null;
36
+ }
37
+ }
38
+ response(data: D) {
39
+ this.client.doneFEToolWaiting(this.message.id!, JSON.stringify(data));
40
+ }
41
+ }
@@ -1,72 +1,72 @@
1
- import { Message } from "@langchain/langgraph-sdk";
2
- /**
3
- * copy and modify from copilotkit
4
- * https://github.com/copilotkit/copilotkit
5
- *
6
- * MIT License
7
- */
8
- type TypeMap = {
9
- string: string;
10
- number: number;
11
- boolean: boolean;
12
- object: object;
13
- "string[]": string[];
14
- "number[]": number[];
15
- "boolean[]": boolean[];
16
- "object[]": object[];
17
- };
18
-
19
- type AbstractParameter = {
20
- name: string;
21
- type?: keyof TypeMap;
22
- description?: string;
23
- required?: boolean;
24
- };
25
-
26
- interface StringParameter extends AbstractParameter {
27
- type: "string";
28
- enum?: string[];
29
- }
30
-
31
- interface ObjectParameter extends AbstractParameter {
32
- type: "object";
33
- attributes?: Parameter[];
34
- }
35
-
36
- interface ObjectArrayParameter extends AbstractParameter {
37
- type: "object[]";
38
- attributes?: Parameter[];
39
- }
40
-
41
- type SpecialParameters = StringParameter | ObjectParameter | ObjectArrayParameter;
42
- interface BaseParameter extends AbstractParameter {
43
- type?: Exclude<AbstractParameter["type"], SpecialParameters["type"]>;
44
- }
45
-
46
- export type Parameter = BaseParameter | SpecialParameters;
47
-
48
- type OptionalParameterType<P extends AbstractParameter> = P["required"] extends false ? undefined : never;
49
-
50
- type StringParameterType<P> = P extends StringParameter ? (P extends { enum?: Array<infer E> } ? E : string) : never;
51
-
52
- type ObjectParameterType<P> = P extends ObjectParameter ? (P extends { attributes?: infer Attributes extends Parameter[] } ? MappedParameterTypes<Attributes> : object) : never;
53
-
54
- type ObjectArrayParameterType<P> = P extends ObjectArrayParameter ? (P extends { attributes?: infer Attributes extends Parameter[] } ? MappedParameterTypes<Attributes>[] : any[]) : never;
55
-
56
- type MappedTypeOrString<T> = T extends keyof TypeMap ? TypeMap[T] : string;
57
- type BaseParameterType<P extends AbstractParameter> = P extends { type: infer T } ? (T extends BaseParameter["type"] ? MappedTypeOrString<T> : never) : string;
58
-
59
- export type MappedParameterTypes<T extends Parameter[] | [] = []> = T extends []
60
- ? Record<string, any>
61
- : {
62
- [P in T[number] as P["name"]]: OptionalParameterType<P> | StringParameterType<P> | ObjectParameterType<P> | ObjectArrayParameterType<P> | BaseParameterType<P>;
63
- };
64
-
65
- export type Action<T extends Parameter[] | [] = []> = {
66
- name: string;
67
- description?: string;
68
- parameters?: T;
69
- handler?: T extends [] ? () => any | Promise<any> : (args: MappedParameterTypes<T>, context?: any) => any | Promise<any>;
70
- returnDirect?: boolean;
71
- callbackMessage?: () => Message[];
72
- };
1
+ import { Message } from "@langchain/langgraph-sdk";
2
+ /**
3
+ * copy and modify from copilotkit
4
+ * https://github.com/copilotkit/copilotkit
5
+ *
6
+ * MIT License
7
+ */
8
+ type TypeMap = {
9
+ string: string;
10
+ number: number;
11
+ boolean: boolean;
12
+ object: object;
13
+ "string[]": string[];
14
+ "number[]": number[];
15
+ "boolean[]": boolean[];
16
+ "object[]": object[];
17
+ };
18
+
19
+ type AbstractParameter = {
20
+ name: string;
21
+ type?: keyof TypeMap;
22
+ description?: string;
23
+ required?: boolean;
24
+ };
25
+
26
+ interface StringParameter extends AbstractParameter {
27
+ type: "string";
28
+ enum?: string[];
29
+ }
30
+
31
+ interface ObjectParameter extends AbstractParameter {
32
+ type: "object";
33
+ attributes?: Parameter[];
34
+ }
35
+
36
+ interface ObjectArrayParameter extends AbstractParameter {
37
+ type: "object[]";
38
+ attributes?: Parameter[];
39
+ }
40
+
41
+ type SpecialParameters = StringParameter | ObjectParameter | ObjectArrayParameter;
42
+ interface BaseParameter extends AbstractParameter {
43
+ type?: Exclude<AbstractParameter["type"], SpecialParameters["type"]>;
44
+ }
45
+
46
+ export type Parameter = BaseParameter | SpecialParameters;
47
+
48
+ type OptionalParameterType<P extends AbstractParameter> = P["required"] extends false ? undefined : never;
49
+
50
+ type StringParameterType<P> = P extends StringParameter ? (P extends { enum?: Array<infer E> } ? E : string) : never;
51
+
52
+ type ObjectParameterType<P> = P extends ObjectParameter ? (P extends { attributes?: infer Attributes extends Parameter[] } ? MappedParameterTypes<Attributes> : object) : never;
53
+
54
+ type ObjectArrayParameterType<P> = P extends ObjectArrayParameter ? (P extends { attributes?: infer Attributes extends Parameter[] } ? MappedParameterTypes<Attributes>[] : any[]) : never;
55
+
56
+ type MappedTypeOrString<T> = T extends keyof TypeMap ? TypeMap[T] : string;
57
+ type BaseParameterType<P extends AbstractParameter> = P extends { type: infer T } ? (T extends BaseParameter["type"] ? MappedTypeOrString<T> : never) : string;
58
+
59
+ export type MappedParameterTypes<T extends Parameter[] | [] = []> = T extends []
60
+ ? Record<string, any>
61
+ : {
62
+ [P in T[number] as P["name"]]: OptionalParameterType<P> | StringParameterType<P> | ObjectParameterType<P> | ObjectArrayParameterType<P> | BaseParameterType<P>;
63
+ };
64
+
65
+ export type Action<T extends Parameter[] | [] = []> = {
66
+ name: string;
67
+ description?: string;
68
+ parameters?: T;
69
+ handler?: T extends [] ? () => any | Promise<any> : (args: MappedParameterTypes<T>, context?: any) => any | Promise<any>;
70
+ returnDirect?: boolean;
71
+ callbackMessage?: () => Message[];
72
+ };