@copilotkit/sdk-js 1.4.1-pre.5 → 1.4.1-pre.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/CHANGELOG.md +14 -0
- package/dist/langchain.d.ts +6 -2
- package/dist/langchain.js +21 -1
- package/dist/langchain.js.map +1 -1
- package/dist/langchain.mjs +20 -2
- package/dist/langchain.mjs.map +1 -1
- package/package.json +4 -4
- package/src/langchain.ts +18 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @copilotkit/sdk-js
|
|
2
2
|
|
|
3
|
+
## 1.4.1-pre.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1721cbd: lower case copilotkit property
|
|
8
|
+
- 1721cbd: add zod conversion
|
|
9
|
+
- 1721cbd: Add convertActionsToDynamicStructuredTools to sdk-js
|
|
10
|
+
- fix assistant message CSS and propagate actions to LG JS
|
|
11
|
+
- Updated dependencies [1721cbd]
|
|
12
|
+
- Updated dependencies [1721cbd]
|
|
13
|
+
- Updated dependencies [1721cbd]
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @copilotkit/shared@1.4.1-pre.6
|
|
16
|
+
|
|
3
17
|
## 1.4.1-pre.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
1
2
|
import * as _langchain_core_messages from '@langchain/core/messages';
|
|
2
3
|
import * as _langchain_langgraph from '@langchain/langgraph';
|
|
3
4
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
5
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
4
6
|
|
|
5
7
|
interface IntermediateStateConfig {
|
|
6
8
|
stateKey: string;
|
|
@@ -22,7 +24,7 @@ declare const CopilotKitPropertiesAnnotation: _langchain_langgraph._INTERNAL_ANN
|
|
|
22
24
|
}>;
|
|
23
25
|
declare const CopilotKitStateAnnotation: _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<{
|
|
24
26
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage[], _langchain_langgraph.Messages>;
|
|
25
|
-
|
|
27
|
+
copilotkit: {
|
|
26
28
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
27
29
|
actions: {
|
|
28
30
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
@@ -65,5 +67,7 @@ declare function copilotKitExit(config: RunnableConfig): Promise<void>;
|
|
|
65
67
|
declare function copilotKitEmitState(config: RunnableConfig, state: any): Promise<void>;
|
|
66
68
|
declare function copilotKitEmitMessage(config: RunnableConfig, message: string): Promise<void>;
|
|
67
69
|
declare function copilotKitEmitToolCall(config: RunnableConfig, name: string, args: any): Promise<void>;
|
|
70
|
+
declare function convertActionToDynamicStructuredTool(actionInput: any): DynamicStructuredTool<zod.ZodType<any, zod.ZodTypeDef, any>>;
|
|
71
|
+
declare function convertActionsToDynamicStructuredTools(actions: any[]): DynamicStructuredTool<zod.ZodType<any, zod.ZodTypeDef, any>>[];
|
|
68
72
|
|
|
69
|
-
export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, copilotKitCustomizeConfig, copilotKitEmitMessage, copilotKitEmitState, copilotKitEmitToolCall, copilotKitExit };
|
|
73
|
+
export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitCustomizeConfig, copilotKitEmitMessage, copilotKitEmitState, copilotKitEmitToolCall, copilotKitExit };
|
package/dist/langchain.js
CHANGED
|
@@ -22,6 +22,8 @@ var langchain_exports = {};
|
|
|
22
22
|
__export(langchain_exports, {
|
|
23
23
|
CopilotKitPropertiesAnnotation: () => CopilotKitPropertiesAnnotation,
|
|
24
24
|
CopilotKitStateAnnotation: () => CopilotKitStateAnnotation,
|
|
25
|
+
convertActionToDynamicStructuredTool: () => convertActionToDynamicStructuredTool,
|
|
26
|
+
convertActionsToDynamicStructuredTools: () => convertActionsToDynamicStructuredTools,
|
|
25
27
|
copilotKitCustomizeConfig: () => copilotKitCustomizeConfig,
|
|
26
28
|
copilotKitEmitMessage: () => copilotKitEmitMessage,
|
|
27
29
|
copilotKitEmitState: () => copilotKitEmitState,
|
|
@@ -32,11 +34,12 @@ module.exports = __toCommonJS(langchain_exports);
|
|
|
32
34
|
var import_dispatch = require("@langchain/core/callbacks/dispatch");
|
|
33
35
|
var import_shared = require("@copilotkit/shared");
|
|
34
36
|
var import_langgraph = require("@langchain/langgraph");
|
|
37
|
+
var import_tools = require("@langchain/core/tools");
|
|
35
38
|
var CopilotKitPropertiesAnnotation = import_langgraph.Annotation.Root({
|
|
36
39
|
actions: import_langgraph.Annotation
|
|
37
40
|
});
|
|
38
41
|
var CopilotKitStateAnnotation = import_langgraph.Annotation.Root({
|
|
39
|
-
|
|
42
|
+
copilotkit: import_langgraph.Annotation,
|
|
40
43
|
...import_langgraph.MessagesAnnotation.spec
|
|
41
44
|
});
|
|
42
45
|
function copilotKitCustomizeConfig(baseConfig, options) {
|
|
@@ -91,10 +94,27 @@ async function copilotKitEmitToolCall(config, name, args) {
|
|
|
91
94
|
}, config);
|
|
92
95
|
}
|
|
93
96
|
__name(copilotKitEmitToolCall, "copilotKitEmitToolCall");
|
|
97
|
+
function convertActionToDynamicStructuredTool(actionInput) {
|
|
98
|
+
return new import_tools.DynamicStructuredTool({
|
|
99
|
+
name: actionInput.name,
|
|
100
|
+
description: actionInput.description,
|
|
101
|
+
schema: (0, import_shared.convertJsonSchemaToZodSchema)(actionInput.parameters, true),
|
|
102
|
+
func: async () => {
|
|
103
|
+
return "";
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
__name(convertActionToDynamicStructuredTool, "convertActionToDynamicStructuredTool");
|
|
108
|
+
function convertActionsToDynamicStructuredTools(actions) {
|
|
109
|
+
return actions.map((action) => convertActionToDynamicStructuredTool(action));
|
|
110
|
+
}
|
|
111
|
+
__name(convertActionsToDynamicStructuredTools, "convertActionsToDynamicStructuredTools");
|
|
94
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
113
|
0 && (module.exports = {
|
|
96
114
|
CopilotKitPropertiesAnnotation,
|
|
97
115
|
CopilotKitStateAnnotation,
|
|
116
|
+
convertActionToDynamicStructuredTool,
|
|
117
|
+
convertActionsToDynamicStructuredTools,
|
|
98
118
|
copilotKitCustomizeConfig,
|
|
99
119
|
copilotKitEmitMessage,
|
|
100
120
|
copilotKitEmitState,
|
package/dist/langchain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport { randomId } from \"@copilotkit/shared\";\nimport { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\ninterface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\ninterface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n
|
|
1
|
+
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport { convertJsonSchemaToZodSchema, randomId } from \"@copilotkit/shared\";\nimport { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\nimport { DynamicStructuredTool } from \"@langchain/core/tools\";\n\ninterface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\ninterface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n\nexport function copilotKitCustomizeConfig(\n baseConfig: RunnableConfig,\n options?: OptionsConfig,\n): RunnableConfig {\n const metadata = baseConfig?.metadata || {};\n\n if (options?.emitAll) {\n metadata[\"copilotkit:emit-tool-calls\"] = true;\n metadata[\"copilotkit:emit-messages\"] = true;\n } else {\n if (options?.emitToolCalls !== undefined) {\n metadata[\"copilotkit:emit-tool-calls\"] = options.emitToolCalls;\n }\n if (options?.emitMessages !== undefined) {\n metadata[\"copilotkit:emit-messages\"] = options.emitMessages;\n }\n }\n\n if (options?.emitIntermediateState) {\n const snakeCaseIntermediateState = options.emitIntermediateState.map((state) => ({\n tool: state.tool,\n tool_argument: state.toolArgument,\n state_key: state.stateKey,\n }));\n\n metadata[\"copilotkit:emit-intermediate-state\"] = snakeCaseIntermediateState;\n }\n\n baseConfig = baseConfig || {};\n\n return {\n ...baseConfig,\n metadata: metadata,\n };\n}\n\nexport async function copilotKitExit(config: RunnableConfig) {\n await dispatchCustomEvent(\"copilotkit_exit\", {}, config);\n}\n\nexport async function copilotKitEmitState(config: RunnableConfig, state: any) {\n await dispatchCustomEvent(\"copilotkit_manually_emit_intermediate_state\", state, config);\n}\n\nexport async function copilotKitEmitMessage(config: RunnableConfig, message: string) {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_message\",\n { message, message_id: randomId(), role: \"assistant\" },\n config,\n );\n}\n\nexport async function copilotKitEmitToolCall(config: RunnableConfig, name: string, args: any) {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_tool_call\",\n { name, args, id: randomId() },\n config,\n );\n}\n\nexport function convertActionToDynamicStructuredTool(actionInput: any) {\n return new DynamicStructuredTool({\n name: actionInput.name,\n description: actionInput.description,\n schema: convertJsonSchemaToZodSchema(actionInput.parameters, true),\n func: async () => {\n return \"\";\n },\n });\n}\n\nexport function convertActionsToDynamicStructuredTools(actions: any[]) {\n return actions.map((action) => convertActionToDynamicStructuredTool(action));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;;sBAAoC;AACpC,oBAAuD;AACvD,uBAA+C;AAC/C,mBAAsC;AAe/B,IAAMA,iCAAiCC,4BAAWC,KAAK;EAC5DC,SAASF;AACX,CAAA;AAEO,IAAMG,4BAA4BH,4BAAWC,KAAK;EACvDG,YAAYJ;EACZ,GAAGK,oCAAmBC;AACxB,CAAA;AAKO,SAASC,0BACdC,YACAC,SAAuB;AAEvB,QAAMC,YAAWF,yCAAYE,aAAY,CAAC;AAE1C,MAAID,mCAASE,SAAS;AACpBD,aAAS,4BAAA,IAAgC;AACzCA,aAAS,0BAAA,IAA8B;EACzC,OAAO;AACL,SAAID,mCAASG,mBAAkBC,QAAW;AACxCH,eAAS,4BAAA,IAAgCD,QAAQG;IACnD;AACA,SAAIH,mCAASK,kBAAiBD,QAAW;AACvCH,eAAS,0BAAA,IAA8BD,QAAQK;IACjD;EACF;AAEA,MAAIL,mCAASM,uBAAuB;AAClC,UAAMC,6BAA6BP,QAAQM,sBAAsBE,IAAI,CAACC,WAAW;MAC/EC,MAAMD,MAAMC;MACZC,eAAeF,MAAMG;MACrBC,WAAWJ,MAAMK;IACnB,EAAA;AAEAb,aAAS,oCAAA,IAAwCM;EACnD;AAEAR,eAAaA,cAAc,CAAC;AAE5B,SAAO;IACL,GAAGA;IACHE;EACF;AACF;AAlCgBH;AAoChB,eAAsBiB,eAAeC,QAAsB;AACzD,YAAMC,qCAAoB,mBAAmB,CAAC,GAAGD,MAAAA;AACnD;AAFsBD;AAItB,eAAsBG,oBAAoBF,QAAwBP,OAAU;AAC1E,YAAMQ,qCAAoB,+CAA+CR,OAAOO,MAAAA;AAClF;AAFsBE;AAItB,eAAsBC,sBAAsBH,QAAwBI,SAAe;AACjF,YAAMH,qCACJ,oCACA;IAAEG;IAASC,gBAAYC,wBAAAA;IAAYC,MAAM;EAAY,GACrDP,MAAAA;AAEJ;AANsBG;AAQtB,eAAsBK,uBAAuBR,QAAwBS,MAAcC,MAAS;AAC1F,YAAMT,qCACJ,sCACA;IAAEQ;IAAMC;IAAMC,QAAIL,wBAAAA;EAAW,GAC7BN,MAAAA;AAEJ;AANsBQ;AAQf,SAASI,qCAAqCC,aAAgB;AACnE,SAAO,IAAIC,mCAAsB;IAC/BL,MAAMI,YAAYJ;IAClBM,aAAaF,YAAYE;IACzBC,YAAQC,4CAA6BJ,YAAYK,YAAY,IAAA;IAC7DC,MAAM,YAAA;AACJ,aAAO;IACT;EACF,CAAA;AACF;AATgBP;AAWT,SAASQ,uCAAuC3C,SAAc;AACnE,SAAOA,QAAQe,IAAI,CAAC6B,WAAWT,qCAAqCS,MAAAA,CAAAA;AACtE;AAFgBD;","names":["CopilotKitPropertiesAnnotation","Annotation","Root","actions","CopilotKitStateAnnotation","copilotkit","MessagesAnnotation","spec","copilotKitCustomizeConfig","baseConfig","options","metadata","emitAll","emitToolCalls","undefined","emitMessages","emitIntermediateState","snakeCaseIntermediateState","map","state","tool","tool_argument","toolArgument","state_key","stateKey","copilotKitExit","config","dispatchCustomEvent","copilotKitEmitState","copilotKitEmitMessage","message","message_id","randomId","role","copilotKitEmitToolCall","name","args","id","convertActionToDynamicStructuredTool","actionInput","DynamicStructuredTool","description","schema","convertJsonSchemaToZodSchema","parameters","func","convertActionsToDynamicStructuredTools","action"]}
|
package/dist/langchain.mjs
CHANGED
|
@@ -3,13 +3,14 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/langchain.ts
|
|
5
5
|
import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch";
|
|
6
|
-
import { randomId } from "@copilotkit/shared";
|
|
6
|
+
import { convertJsonSchemaToZodSchema, randomId } from "@copilotkit/shared";
|
|
7
7
|
import { Annotation, MessagesAnnotation } from "@langchain/langgraph";
|
|
8
|
+
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
8
9
|
var CopilotKitPropertiesAnnotation = Annotation.Root({
|
|
9
10
|
actions: Annotation
|
|
10
11
|
});
|
|
11
12
|
var CopilotKitStateAnnotation = Annotation.Root({
|
|
12
|
-
|
|
13
|
+
copilotkit: Annotation,
|
|
13
14
|
...MessagesAnnotation.spec
|
|
14
15
|
});
|
|
15
16
|
function copilotKitCustomizeConfig(baseConfig, options) {
|
|
@@ -64,9 +65,26 @@ async function copilotKitEmitToolCall(config, name, args) {
|
|
|
64
65
|
}, config);
|
|
65
66
|
}
|
|
66
67
|
__name(copilotKitEmitToolCall, "copilotKitEmitToolCall");
|
|
68
|
+
function convertActionToDynamicStructuredTool(actionInput) {
|
|
69
|
+
return new DynamicStructuredTool({
|
|
70
|
+
name: actionInput.name,
|
|
71
|
+
description: actionInput.description,
|
|
72
|
+
schema: convertJsonSchemaToZodSchema(actionInput.parameters, true),
|
|
73
|
+
func: async () => {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
__name(convertActionToDynamicStructuredTool, "convertActionToDynamicStructuredTool");
|
|
79
|
+
function convertActionsToDynamicStructuredTools(actions) {
|
|
80
|
+
return actions.map((action) => convertActionToDynamicStructuredTool(action));
|
|
81
|
+
}
|
|
82
|
+
__name(convertActionsToDynamicStructuredTools, "convertActionsToDynamicStructuredTools");
|
|
67
83
|
export {
|
|
68
84
|
CopilotKitPropertiesAnnotation,
|
|
69
85
|
CopilotKitStateAnnotation,
|
|
86
|
+
convertActionToDynamicStructuredTool,
|
|
87
|
+
convertActionsToDynamicStructuredTools,
|
|
70
88
|
copilotKitCustomizeConfig,
|
|
71
89
|
copilotKitEmitMessage,
|
|
72
90
|
copilotKitEmitState,
|
package/dist/langchain.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport { randomId } from \"@copilotkit/shared\";\nimport { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\ninterface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\ninterface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n
|
|
1
|
+
{"version":3,"sources":["../src/langchain.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport { convertJsonSchemaToZodSchema, randomId } from \"@copilotkit/shared\";\nimport { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\nimport { DynamicStructuredTool } from \"@langchain/core/tools\";\n\ninterface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\ninterface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n\nexport function copilotKitCustomizeConfig(\n baseConfig: RunnableConfig,\n options?: OptionsConfig,\n): RunnableConfig {\n const metadata = baseConfig?.metadata || {};\n\n if (options?.emitAll) {\n metadata[\"copilotkit:emit-tool-calls\"] = true;\n metadata[\"copilotkit:emit-messages\"] = true;\n } else {\n if (options?.emitToolCalls !== undefined) {\n metadata[\"copilotkit:emit-tool-calls\"] = options.emitToolCalls;\n }\n if (options?.emitMessages !== undefined) {\n metadata[\"copilotkit:emit-messages\"] = options.emitMessages;\n }\n }\n\n if (options?.emitIntermediateState) {\n const snakeCaseIntermediateState = options.emitIntermediateState.map((state) => ({\n tool: state.tool,\n tool_argument: state.toolArgument,\n state_key: state.stateKey,\n }));\n\n metadata[\"copilotkit:emit-intermediate-state\"] = snakeCaseIntermediateState;\n }\n\n baseConfig = baseConfig || {};\n\n return {\n ...baseConfig,\n metadata: metadata,\n };\n}\n\nexport async function copilotKitExit(config: RunnableConfig) {\n await dispatchCustomEvent(\"copilotkit_exit\", {}, config);\n}\n\nexport async function copilotKitEmitState(config: RunnableConfig, state: any) {\n await dispatchCustomEvent(\"copilotkit_manually_emit_intermediate_state\", state, config);\n}\n\nexport async function copilotKitEmitMessage(config: RunnableConfig, message: string) {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_message\",\n { message, message_id: randomId(), role: \"assistant\" },\n config,\n );\n}\n\nexport async function copilotKitEmitToolCall(config: RunnableConfig, name: string, args: any) {\n await dispatchCustomEvent(\n \"copilotkit_manually_emit_tool_call\",\n { name, args, id: randomId() },\n config,\n );\n}\n\nexport function convertActionToDynamicStructuredTool(actionInput: any) {\n return new DynamicStructuredTool({\n name: actionInput.name,\n description: actionInput.description,\n schema: convertJsonSchemaToZodSchema(actionInput.parameters, true),\n func: async () => {\n return \"\";\n },\n });\n}\n\nexport function convertActionsToDynamicStructuredTools(actions: any[]) {\n return actions.map((action) => convertActionToDynamicStructuredTool(action));\n}\n"],"mappings":";;;;AACA,SAASA,2BAA2B;AACpC,SAASC,8BAA8BC,gBAAgB;AACvD,SAASC,YAAYC,0BAA0B;AAC/C,SAASC,6BAA6B;AAe/B,IAAMC,iCAAiCC,WAAWC,KAAK;EAC5DC,SAASF;AACX,CAAA;AAEO,IAAMG,4BAA4BH,WAAWC,KAAK;EACvDG,YAAYJ;EACZ,GAAGK,mBAAmBC;AACxB,CAAA;AAKO,SAASC,0BACdC,YACAC,SAAuB;AAEvB,QAAMC,YAAWF,yCAAYE,aAAY,CAAC;AAE1C,MAAID,mCAASE,SAAS;AACpBD,aAAS,4BAAA,IAAgC;AACzCA,aAAS,0BAAA,IAA8B;EACzC,OAAO;AACL,SAAID,mCAASG,mBAAkBC,QAAW;AACxCH,eAAS,4BAAA,IAAgCD,QAAQG;IACnD;AACA,SAAIH,mCAASK,kBAAiBD,QAAW;AACvCH,eAAS,0BAAA,IAA8BD,QAAQK;IACjD;EACF;AAEA,MAAIL,mCAASM,uBAAuB;AAClC,UAAMC,6BAA6BP,QAAQM,sBAAsBE,IAAI,CAACC,WAAW;MAC/EC,MAAMD,MAAMC;MACZC,eAAeF,MAAMG;MACrBC,WAAWJ,MAAMK;IACnB,EAAA;AAEAb,aAAS,oCAAA,IAAwCM;EACnD;AAEAR,eAAaA,cAAc,CAAC;AAE5B,SAAO;IACL,GAAGA;IACHE;EACF;AACF;AAlCgBH;AAoChB,eAAsBiB,eAAeC,QAAsB;AACzD,QAAMC,oBAAoB,mBAAmB,CAAC,GAAGD,MAAAA;AACnD;AAFsBD;AAItB,eAAsBG,oBAAoBF,QAAwBP,OAAU;AAC1E,QAAMQ,oBAAoB,+CAA+CR,OAAOO,MAAAA;AAClF;AAFsBE;AAItB,eAAsBC,sBAAsBH,QAAwBI,SAAe;AACjF,QAAMH,oBACJ,oCACA;IAAEG;IAASC,YAAYC,SAAAA;IAAYC,MAAM;EAAY,GACrDP,MAAAA;AAEJ;AANsBG;AAQtB,eAAsBK,uBAAuBR,QAAwBS,MAAcC,MAAS;AAC1F,QAAMT,oBACJ,sCACA;IAAEQ;IAAMC;IAAMC,IAAIL,SAAAA;EAAW,GAC7BN,MAAAA;AAEJ;AANsBQ;AAQf,SAASI,qCAAqCC,aAAgB;AACnE,SAAO,IAAIC,sBAAsB;IAC/BL,MAAMI,YAAYJ;IAClBM,aAAaF,YAAYE;IACzBC,QAAQC,6BAA6BJ,YAAYK,YAAY,IAAA;IAC7DC,MAAM,YAAA;AACJ,aAAO;IACT;EACF,CAAA;AACF;AATgBP;AAWT,SAASQ,uCAAuC3C,SAAc;AACnE,SAAOA,QAAQe,IAAI,CAAC6B,WAAWT,qCAAqCS,MAAAA,CAAAA;AACtE;AAFgBD;","names":["dispatchCustomEvent","convertJsonSchemaToZodSchema","randomId","Annotation","MessagesAnnotation","DynamicStructuredTool","CopilotKitPropertiesAnnotation","Annotation","Root","actions","CopilotKitStateAnnotation","copilotkit","MessagesAnnotation","spec","copilotKitCustomizeConfig","baseConfig","options","metadata","emitAll","emitToolCalls","undefined","emitMessages","emitIntermediateState","snakeCaseIntermediateState","map","state","tool","tool_argument","toolArgument","state_key","stateKey","copilotKitExit","config","dispatchCustomEvent","copilotKitEmitState","copilotKitEmitMessage","message","message_id","randomId","role","copilotKitEmitToolCall","name","args","id","convertActionToDynamicStructuredTool","actionInput","DynamicStructuredTool","description","schema","convertJsonSchemaToZodSchema","parameters","func","convertActionsToDynamicStructuredTools","action"]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.4.1-pre.
|
|
12
|
+
"version": "1.4.1-pre.6",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"tsup": "^6.7.0",
|
|
50
50
|
"typescript": "^5.2.3",
|
|
51
51
|
"zod-to-json-schema": "^3.23.5",
|
|
52
|
-
"eslint-config-custom": "1.4.1-pre.
|
|
53
|
-
"tsconfig": "1.4.1-pre.
|
|
52
|
+
"eslint-config-custom": "1.4.1-pre.6",
|
|
53
|
+
"tsconfig": "1.4.1-pre.6"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@langchain/community": "^0.0.53",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@langchain/langgraph-sdk": "^0.0.16",
|
|
60
60
|
"langchain": "^0.3.3",
|
|
61
61
|
"zod": "^3.23.3",
|
|
62
|
-
"@copilotkit/shared": "1.4.1-pre.
|
|
62
|
+
"@copilotkit/shared": "1.4.1-pre.6"
|
|
63
63
|
},
|
|
64
64
|
"keywords": [
|
|
65
65
|
"copilotkit",
|
package/src/langchain.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
2
2
|
import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch";
|
|
3
|
-
import { randomId } from "@copilotkit/shared";
|
|
3
|
+
import { convertJsonSchemaToZodSchema, randomId } from "@copilotkit/shared";
|
|
4
4
|
import { Annotation, MessagesAnnotation } from "@langchain/langgraph";
|
|
5
|
+
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
5
6
|
|
|
6
7
|
interface IntermediateStateConfig {
|
|
7
8
|
stateKey: string;
|
|
@@ -21,7 +22,7 @@ export const CopilotKitPropertiesAnnotation = Annotation.Root({
|
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
export const CopilotKitStateAnnotation = Annotation.Root({
|
|
24
|
-
|
|
25
|
+
copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,
|
|
25
26
|
...MessagesAnnotation.spec,
|
|
26
27
|
});
|
|
27
28
|
|
|
@@ -87,3 +88,18 @@ export async function copilotKitEmitToolCall(config: RunnableConfig, name: strin
|
|
|
87
88
|
config,
|
|
88
89
|
);
|
|
89
90
|
}
|
|
91
|
+
|
|
92
|
+
export function convertActionToDynamicStructuredTool(actionInput: any) {
|
|
93
|
+
return new DynamicStructuredTool({
|
|
94
|
+
name: actionInput.name,
|
|
95
|
+
description: actionInput.description,
|
|
96
|
+
schema: convertJsonSchemaToZodSchema(actionInput.parameters, true),
|
|
97
|
+
func: async () => {
|
|
98
|
+
return "";
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function convertActionsToDynamicStructuredTools(actions: any[]) {
|
|
104
|
+
return actions.map((action) => convertActionToDynamicStructuredTool(action));
|
|
105
|
+
}
|