@copilotkit/sdk-js 1.5.8 → 1.5.10-next.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @copilotkit/sdk-js
2
2
 
3
+ ## 1.5.10-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @copilotkit/shared@1.5.10-next.0
8
+
9
+ ## 1.5.9
10
+
11
+ ### Patch Changes
12
+
13
+ - @copilotkit/shared@1.5.9
14
+
3
15
  ## 1.5.8
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,73 @@
1
+ import * as zod from 'zod';
2
+ import * as _langchain_core_messages from '@langchain/core/messages';
3
+ import * as _langchain_langgraph from '@langchain/langgraph';
4
+ import { RunnableConfig } from '@langchain/core/runnables';
5
+ import { DynamicStructuredTool } from '@langchain/core/tools';
6
+
7
+ interface IntermediateStateConfig {
8
+ stateKey: string;
9
+ tool: string;
10
+ toolArgument?: string;
11
+ }
12
+ interface OptionsConfig {
13
+ emitToolCalls?: boolean | string | string[];
14
+ emitMessages?: boolean;
15
+ emitAll?: boolean;
16
+ emitIntermediateState?: IntermediateStateConfig[];
17
+ }
18
+ declare const CopilotKitPropertiesAnnotation: _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<{
19
+ actions: {
20
+ (): _langchain_langgraph.LastValue<any[]>;
21
+ (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
22
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
23
+ };
24
+ }>;
25
+ declare const CopilotKitStateAnnotation: _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<{
26
+ messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage[], _langchain_langgraph.Messages>;
27
+ copilotkit: {
28
+ (): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
29
+ actions: {
30
+ (): _langchain_langgraph.LastValue<any[]>;
31
+ (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
32
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
33
+ };
34
+ }>>;
35
+ (annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
36
+ actions: {
37
+ (): _langchain_langgraph.LastValue<any[]>;
38
+ (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
39
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
40
+ };
41
+ }>, _langchain_langgraph.StateType<{
42
+ actions: {
43
+ (): _langchain_langgraph.LastValue<any[]>;
44
+ (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
45
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
46
+ };
47
+ }>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
48
+ actions: {
49
+ (): _langchain_langgraph.LastValue<any[]>;
50
+ (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
51
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
52
+ };
53
+ }>, _langchain_langgraph.StateType<{
54
+ actions: {
55
+ (): _langchain_langgraph.LastValue<any[]>;
56
+ (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
57
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
58
+ };
59
+ }>>;
60
+ Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph._INTERNAL_ANNOTATION_ROOT<S>;
61
+ };
62
+ }>;
63
+ type CopilotKitState = typeof CopilotKitStateAnnotation.State;
64
+ type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;
65
+ declare function copilotKitCustomizeConfig(baseConfig: RunnableConfig, options?: OptionsConfig): RunnableConfig;
66
+ declare function copilotKitExit(config: RunnableConfig): Promise<void>;
67
+ declare function copilotKitEmitState(config: RunnableConfig, state: any): Promise<void>;
68
+ declare function copilotKitEmitMessage(config: RunnableConfig, message: string): Promise<void>;
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>>[];
72
+
73
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitCustomizeConfig, copilotKitEmitMessage, copilotKitEmitState, copilotKitEmitToolCall, copilotKitExit };
@@ -0,0 +1,124 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/langchain.ts
21
+ var langchain_exports = {};
22
+ __export(langchain_exports, {
23
+ CopilotKitPropertiesAnnotation: () => CopilotKitPropertiesAnnotation,
24
+ CopilotKitStateAnnotation: () => CopilotKitStateAnnotation,
25
+ convertActionToDynamicStructuredTool: () => convertActionToDynamicStructuredTool,
26
+ convertActionsToDynamicStructuredTools: () => convertActionsToDynamicStructuredTools,
27
+ copilotKitCustomizeConfig: () => copilotKitCustomizeConfig,
28
+ copilotKitEmitMessage: () => copilotKitEmitMessage,
29
+ copilotKitEmitState: () => copilotKitEmitState,
30
+ copilotKitEmitToolCall: () => copilotKitEmitToolCall,
31
+ copilotKitExit: () => copilotKitExit
32
+ });
33
+ module.exports = __toCommonJS(langchain_exports);
34
+ var import_dispatch = require("@langchain/core/callbacks/dispatch");
35
+ var import_shared = require("@copilotkit/shared");
36
+ var import_langgraph = require("@langchain/langgraph");
37
+ var import_tools = require("@langchain/core/tools");
38
+ var CopilotKitPropertiesAnnotation = import_langgraph.Annotation.Root({
39
+ actions: import_langgraph.Annotation
40
+ });
41
+ var CopilotKitStateAnnotation = import_langgraph.Annotation.Root({
42
+ copilotkit: import_langgraph.Annotation,
43
+ ...import_langgraph.MessagesAnnotation.spec
44
+ });
45
+ function copilotKitCustomizeConfig(baseConfig, options) {
46
+ const metadata = (baseConfig == null ? void 0 : baseConfig.metadata) || {};
47
+ if (options == null ? void 0 : options.emitAll) {
48
+ metadata["copilotkit:emit-tool-calls"] = true;
49
+ metadata["copilotkit:emit-messages"] = true;
50
+ } else {
51
+ if ((options == null ? void 0 : options.emitToolCalls) !== void 0) {
52
+ metadata["copilotkit:emit-tool-calls"] = options.emitToolCalls;
53
+ }
54
+ if ((options == null ? void 0 : options.emitMessages) !== void 0) {
55
+ metadata["copilotkit:emit-messages"] = options.emitMessages;
56
+ }
57
+ }
58
+ if (options == null ? void 0 : options.emitIntermediateState) {
59
+ const snakeCaseIntermediateState = options.emitIntermediateState.map((state) => ({
60
+ tool: state.tool,
61
+ tool_argument: state.toolArgument,
62
+ state_key: state.stateKey
63
+ }));
64
+ metadata["copilotkit:emit-intermediate-state"] = snakeCaseIntermediateState;
65
+ }
66
+ baseConfig = baseConfig || {};
67
+ return {
68
+ ...baseConfig,
69
+ metadata
70
+ };
71
+ }
72
+ __name(copilotKitCustomizeConfig, "copilotKitCustomizeConfig");
73
+ async function copilotKitExit(config) {
74
+ await (0, import_dispatch.dispatchCustomEvent)("copilotkit_exit", {}, config);
75
+ }
76
+ __name(copilotKitExit, "copilotKitExit");
77
+ async function copilotKitEmitState(config, state) {
78
+ await (0, import_dispatch.dispatchCustomEvent)("copilotkit_manually_emit_intermediate_state", state, config);
79
+ }
80
+ __name(copilotKitEmitState, "copilotKitEmitState");
81
+ async function copilotKitEmitMessage(config, message) {
82
+ await (0, import_dispatch.dispatchCustomEvent)("copilotkit_manually_emit_message", {
83
+ message,
84
+ message_id: (0, import_shared.randomId)(),
85
+ role: "assistant"
86
+ }, config);
87
+ }
88
+ __name(copilotKitEmitMessage, "copilotKitEmitMessage");
89
+ async function copilotKitEmitToolCall(config, name, args) {
90
+ await (0, import_dispatch.dispatchCustomEvent)("copilotkit_manually_emit_tool_call", {
91
+ name,
92
+ args,
93
+ id: (0, import_shared.randomId)()
94
+ }, config);
95
+ }
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");
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ CopilotKitPropertiesAnnotation,
115
+ CopilotKitStateAnnotation,
116
+ convertActionToDynamicStructuredTool,
117
+ convertActionsToDynamicStructuredTools,
118
+ copilotKitCustomizeConfig,
119
+ copilotKitEmitMessage,
120
+ copilotKitEmitState,
121
+ copilotKitEmitToolCall,
122
+ copilotKitExit
123
+ });
124
+ //# sourceMappingURL=langchain.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,94 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/langchain.ts
5
+ import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch";
6
+ import { convertJsonSchemaToZodSchema, randomId } from "@copilotkit/shared";
7
+ import { Annotation, MessagesAnnotation } from "@langchain/langgraph";
8
+ import { DynamicStructuredTool } from "@langchain/core/tools";
9
+ var CopilotKitPropertiesAnnotation = Annotation.Root({
10
+ actions: Annotation
11
+ });
12
+ var CopilotKitStateAnnotation = Annotation.Root({
13
+ copilotkit: Annotation,
14
+ ...MessagesAnnotation.spec
15
+ });
16
+ function copilotKitCustomizeConfig(baseConfig, options) {
17
+ const metadata = (baseConfig == null ? void 0 : baseConfig.metadata) || {};
18
+ if (options == null ? void 0 : options.emitAll) {
19
+ metadata["copilotkit:emit-tool-calls"] = true;
20
+ metadata["copilotkit:emit-messages"] = true;
21
+ } else {
22
+ if ((options == null ? void 0 : options.emitToolCalls) !== void 0) {
23
+ metadata["copilotkit:emit-tool-calls"] = options.emitToolCalls;
24
+ }
25
+ if ((options == null ? void 0 : options.emitMessages) !== void 0) {
26
+ metadata["copilotkit:emit-messages"] = options.emitMessages;
27
+ }
28
+ }
29
+ if (options == null ? void 0 : options.emitIntermediateState) {
30
+ const snakeCaseIntermediateState = options.emitIntermediateState.map((state) => ({
31
+ tool: state.tool,
32
+ tool_argument: state.toolArgument,
33
+ state_key: state.stateKey
34
+ }));
35
+ metadata["copilotkit:emit-intermediate-state"] = snakeCaseIntermediateState;
36
+ }
37
+ baseConfig = baseConfig || {};
38
+ return {
39
+ ...baseConfig,
40
+ metadata
41
+ };
42
+ }
43
+ __name(copilotKitCustomizeConfig, "copilotKitCustomizeConfig");
44
+ async function copilotKitExit(config) {
45
+ await dispatchCustomEvent("copilotkit_exit", {}, config);
46
+ }
47
+ __name(copilotKitExit, "copilotKitExit");
48
+ async function copilotKitEmitState(config, state) {
49
+ await dispatchCustomEvent("copilotkit_manually_emit_intermediate_state", state, config);
50
+ }
51
+ __name(copilotKitEmitState, "copilotKitEmitState");
52
+ async function copilotKitEmitMessage(config, message) {
53
+ await dispatchCustomEvent("copilotkit_manually_emit_message", {
54
+ message,
55
+ message_id: randomId(),
56
+ role: "assistant"
57
+ }, config);
58
+ }
59
+ __name(copilotKitEmitMessage, "copilotKitEmitMessage");
60
+ async function copilotKitEmitToolCall(config, name, args) {
61
+ await dispatchCustomEvent("copilotkit_manually_emit_tool_call", {
62
+ name,
63
+ args,
64
+ id: randomId()
65
+ }, config);
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");
83
+ export {
84
+ CopilotKitPropertiesAnnotation,
85
+ CopilotKitStateAnnotation,
86
+ convertActionToDynamicStructuredTool,
87
+ convertActionsToDynamicStructuredTools,
88
+ copilotKitCustomizeConfig,
89
+ copilotKitEmitMessage,
90
+ copilotKitEmitState,
91
+ copilotKitEmitToolCall,
92
+ copilotKitExit
93
+ };
94
+ //# sourceMappingURL=langchain.mjs.map
@@ -0,0 +1 @@
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.5.8",
12
+ "version": "1.5.10-next.0",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -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.5.8"
62
+ "@copilotkit/shared": "1.5.10-next.0"
63
63
  },
64
64
  "keywords": [
65
65
  "copilotkit",