@copilotkit/sdk-js 1.3.16-mme-sdk-js.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.
- package/CHANGELOG.md +17 -0
- package/README.md +46 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +61 -0
- package/dist/index.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +67 -0
- package/src/index.ts +1 -0
- package/src/langchain.ts +70 -0
- package/tsconfig.json +11 -0
- package/tsup.config.ts +16 -0
- package/typedoc.json +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @copilotkit/sdk-js
|
|
2
|
+
|
|
3
|
+
## 1.3.16-mme-sdk-js.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update lockfile
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @copilotkit/shared@1.3.16-mme-sdk-js.1
|
|
10
|
+
|
|
11
|
+
## 1.3.16-mme-sdk-js.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Export LangGraph functions
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @copilotkit/shared@1.3.16-mme-sdk-js.0
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://copilotkit.ai" target="_blank">
|
|
3
|
+
<img src="https://github.com/copilotkit/copilotkit/raw/main/assets/banner.png" alt="CopilotKit Logo">
|
|
4
|
+
</a>
|
|
5
|
+
|
|
6
|
+
<br/>
|
|
7
|
+
|
|
8
|
+
<strong>
|
|
9
|
+
CopilotKit is the open-source framework for integrating powerful AI Copilots into any application. Easily implement custom AI Chatbots, AI Agents, AI Textareas, and more.
|
|
10
|
+
</strong>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<div align="center">
|
|
16
|
+
<a href="https://www.npmjs.com/package/@copilotkit/react-core" target="_blank">
|
|
17
|
+
<img src="https://img.shields.io/npm/v/%40copilotkit%2Freact-core?logo=npm&logoColor=%23FFFFFF&label=Version&color=%236963ff" alt="NPM">
|
|
18
|
+
</a>
|
|
19
|
+
<img src="https://img.shields.io/github/license/copilotkit/copilotkit?color=%236963ff&label=License" alt="MIT">
|
|
20
|
+
<a href="https://discord.gg/6dffbvGU3D" target="_blank">
|
|
21
|
+
<img src="https://img.shields.io/discord/1122926057641742418?logo=discord&logoColor=%23FFFFFF&label=Discord&color=%236963ff" alt="Discord">
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
<br/>
|
|
25
|
+
|
|
26
|
+
<div align="center">
|
|
27
|
+
<a href="https://discord.gg/6dffbvGU3D?ref=github_readme" target="_blank">
|
|
28
|
+
<img src="https://github.com/copilotkit/copilotkit/raw/main/assets/btn_discord.png" alt="CopilotKit Discord" height="40px">
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://docs.copilotkit.ai?ref=github_readme" target="_blank">
|
|
31
|
+
<img src="https://github.com/copilotkit/copilotkit/raw/main/assets/btn_docs.png" alt="CopilotKit GitHub" height="40px">
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://cloud.copilotkit.ai?ref=github_readme" target="_blank">
|
|
34
|
+
<img src="https://github.com/copilotkit/copilotkit/raw/main/assets/btn_cloud.png" alt="CopilotKit GitHub" height="40px">
|
|
35
|
+
</a>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<br />
|
|
39
|
+
|
|
40
|
+
<div align="center">
|
|
41
|
+
<img src="https://github.com/CopilotKit/CopilotKit/raw/main/assets/animated-banner.gif" alt="CopilotKit Screenshot" style="border-radius: 15px;" />
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
# Documentation
|
|
45
|
+
|
|
46
|
+
To get started with CopilotKit, please check out the [documentation](https://docs.copilotkit.ai).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RunnableConfig } from '@langchain/core/runnables';
|
|
2
|
+
|
|
3
|
+
interface IntermediateStateConfig {
|
|
4
|
+
stateKey: string;
|
|
5
|
+
tool: string;
|
|
6
|
+
toolArgument?: string;
|
|
7
|
+
}
|
|
8
|
+
interface OptionsConfig {
|
|
9
|
+
emitToolCalls?: boolean | string | string[];
|
|
10
|
+
emitMessages?: boolean;
|
|
11
|
+
emitAll?: boolean;
|
|
12
|
+
emitIntermediateState?: IntermediateStateConfig[];
|
|
13
|
+
}
|
|
14
|
+
declare function copilotKitCustomizeConfig(baseConfig?: RunnableConfig, options?: OptionsConfig): RunnableConfig;
|
|
15
|
+
declare function copilotKitExit(config: RunnableConfig): Promise<void>;
|
|
16
|
+
declare function copilotKitEmitState(config: RunnableConfig, state: any): Promise<void>;
|
|
17
|
+
declare function copilotKitEmitMessage(config: RunnableConfig, message: string): Promise<void>;
|
|
18
|
+
declare function copilotKitEmitToolCall(config: RunnableConfig, name: string, args: any): Promise<void>;
|
|
19
|
+
|
|
20
|
+
export { copilotKitCustomizeConfig, copilotKitEmitMessage, copilotKitEmitState, copilotKitEmitToolCall, copilotKitExit };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
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/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
copilotKitCustomizeConfig: () => copilotKitCustomizeConfig,
|
|
24
|
+
copilotKitEmitMessage: () => copilotKitEmitMessage,
|
|
25
|
+
copilotKitEmitState: () => copilotKitEmitState,
|
|
26
|
+
copilotKitEmitToolCall: () => copilotKitEmitToolCall,
|
|
27
|
+
copilotKitExit: () => copilotKitExit
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
|
|
31
|
+
// src/langchain.ts
|
|
32
|
+
var import_dispatch = require("@langchain/core/callbacks/dispatch");
|
|
33
|
+
var import_shared = require("@copilotkit/shared");
|
|
34
|
+
function copilotKitCustomizeConfig(baseConfig, options) {
|
|
35
|
+
const metadata = (baseConfig == null ? void 0 : baseConfig.metadata) || {};
|
|
36
|
+
if (options == null ? void 0 : options.emitAll) {
|
|
37
|
+
metadata["copilotkit:emit-tool-calls"] = true;
|
|
38
|
+
metadata["copilotkit:emit-messages"] = true;
|
|
39
|
+
} else {
|
|
40
|
+
if ((options == null ? void 0 : options.emitToolCalls) !== void 0) {
|
|
41
|
+
metadata["copilotkit:emit-tool-calls"] = options.emitToolCalls;
|
|
42
|
+
}
|
|
43
|
+
if ((options == null ? void 0 : options.emitMessages) !== void 0) {
|
|
44
|
+
metadata["copilotkit:emit-messages"] = options.emitMessages;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (options == null ? void 0 : options.emitIntermediateState) {
|
|
48
|
+
metadata["copilotkit:emit-intermediate-state"] = options.emitIntermediateState;
|
|
49
|
+
}
|
|
50
|
+
baseConfig = baseConfig || {};
|
|
51
|
+
return {
|
|
52
|
+
...baseConfig,
|
|
53
|
+
metadata
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
__name(copilotKitCustomizeConfig, "copilotKitCustomizeConfig");
|
|
57
|
+
async function copilotKitExit(config) {
|
|
58
|
+
await (0, import_dispatch.dispatchCustomEvent)("copilotkit_exit", {}, config);
|
|
59
|
+
}
|
|
60
|
+
__name(copilotKitExit, "copilotKitExit");
|
|
61
|
+
async function copilotKitEmitState(config, state) {
|
|
62
|
+
await (0, import_dispatch.dispatchCustomEvent)("copilotkit_manually_emit_intermediate_state", state, config);
|
|
63
|
+
}
|
|
64
|
+
__name(copilotKitEmitState, "copilotKitEmitState");
|
|
65
|
+
async function copilotKitEmitMessage(config, message) {
|
|
66
|
+
await (0, import_dispatch.dispatchCustomEvent)("copilotkit_manually_emit_message", {
|
|
67
|
+
message,
|
|
68
|
+
message_id: (0, import_shared.randomId)(),
|
|
69
|
+
role: "assistant"
|
|
70
|
+
}, config);
|
|
71
|
+
}
|
|
72
|
+
__name(copilotKitEmitMessage, "copilotKitEmitMessage");
|
|
73
|
+
async function copilotKitEmitToolCall(config, name, args) {
|
|
74
|
+
await (0, import_dispatch.dispatchCustomEvent)("copilotkit_manually_emit_tool_call", {
|
|
75
|
+
name,
|
|
76
|
+
args,
|
|
77
|
+
id: (0, import_shared.randomId)()
|
|
78
|
+
}, config);
|
|
79
|
+
}
|
|
80
|
+
__name(copilotKitEmitToolCall, "copilotKitEmitToolCall");
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
copilotKitCustomizeConfig,
|
|
84
|
+
copilotKitEmitMessage,
|
|
85
|
+
copilotKitEmitState,
|
|
86
|
+
copilotKitEmitToolCall,
|
|
87
|
+
copilotKitExit
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/langchain.ts"],"sourcesContent":["export * from \"./langchain\";\n","import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { dispatchCustomEvent } from \"@langchain/core/callbacks/dispatch\";\nimport { randomId } from \"@copilotkit/shared\";\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 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 metadata[\"copilotkit:emit-intermediate-state\"] = options.emitIntermediateState;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;ACCA,sBAAoC;AACpC,oBAAyB;AAelB,SAASA,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;AAClCL,aAAS,oCAAA,IAAwCD,QAAQM;EAC3D;AAEAP,eAAaA,cAAc,CAAC;AAE5B,SAAO;IACL,GAAGA;IACHE;EACF;AACF;AA5BgBH;AA8BhB,eAAsBS,eAAeC,QAAsB;AACzD,YAAMC,qCAAoB,mBAAmB,CAAC,GAAGD,MAAAA;AACnD;AAFsBD;AAItB,eAAsBG,oBAAoBF,QAAwBG,OAAU;AAC1E,YAAMF,qCAAoB,+CAA+CE,OAAOH,MAAAA;AAClF;AAFsBE;AAItB,eAAsBE,sBAAsBJ,QAAwBK,SAAe;AACjF,YAAMJ,qCACJ,oCACA;IAAEI;IAASC,gBAAYC,wBAAAA;IAAYC,MAAM;EAAY,GACrDR,MAAAA;AAEJ;AANsBI;AAQtB,eAAsBK,uBAAuBT,QAAwBU,MAAcC,MAAS;AAC1F,YAAMV,qCACJ,sCACA;IAAES;IAAMC;IAAMC,QAAIL,wBAAAA;EAAW,GAC7BP,MAAAA;AAEJ;AANsBS;","names":["copilotKitCustomizeConfig","baseConfig","options","metadata","emitAll","emitToolCalls","undefined","emitMessages","emitIntermediateState","copilotKitExit","config","dispatchCustomEvent","copilotKitEmitState","state","copilotKitEmitMessage","message","message_id","randomId","role","copilotKitEmitToolCall","name","args","id"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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 { randomId } from "@copilotkit/shared";
|
|
7
|
+
function copilotKitCustomizeConfig(baseConfig, options) {
|
|
8
|
+
const metadata = (baseConfig == null ? void 0 : baseConfig.metadata) || {};
|
|
9
|
+
if (options == null ? void 0 : options.emitAll) {
|
|
10
|
+
metadata["copilotkit:emit-tool-calls"] = true;
|
|
11
|
+
metadata["copilotkit:emit-messages"] = true;
|
|
12
|
+
} else {
|
|
13
|
+
if ((options == null ? void 0 : options.emitToolCalls) !== void 0) {
|
|
14
|
+
metadata["copilotkit:emit-tool-calls"] = options.emitToolCalls;
|
|
15
|
+
}
|
|
16
|
+
if ((options == null ? void 0 : options.emitMessages) !== void 0) {
|
|
17
|
+
metadata["copilotkit:emit-messages"] = options.emitMessages;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (options == null ? void 0 : options.emitIntermediateState) {
|
|
21
|
+
metadata["copilotkit:emit-intermediate-state"] = options.emitIntermediateState;
|
|
22
|
+
}
|
|
23
|
+
baseConfig = baseConfig || {};
|
|
24
|
+
return {
|
|
25
|
+
...baseConfig,
|
|
26
|
+
metadata
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
__name(copilotKitCustomizeConfig, "copilotKitCustomizeConfig");
|
|
30
|
+
async function copilotKitExit(config) {
|
|
31
|
+
await dispatchCustomEvent("copilotkit_exit", {}, config);
|
|
32
|
+
}
|
|
33
|
+
__name(copilotKitExit, "copilotKitExit");
|
|
34
|
+
async function copilotKitEmitState(config, state) {
|
|
35
|
+
await dispatchCustomEvent("copilotkit_manually_emit_intermediate_state", state, config);
|
|
36
|
+
}
|
|
37
|
+
__name(copilotKitEmitState, "copilotKitEmitState");
|
|
38
|
+
async function copilotKitEmitMessage(config, message) {
|
|
39
|
+
await dispatchCustomEvent("copilotkit_manually_emit_message", {
|
|
40
|
+
message,
|
|
41
|
+
message_id: randomId(),
|
|
42
|
+
role: "assistant"
|
|
43
|
+
}, config);
|
|
44
|
+
}
|
|
45
|
+
__name(copilotKitEmitMessage, "copilotKitEmitMessage");
|
|
46
|
+
async function copilotKitEmitToolCall(config, name, args) {
|
|
47
|
+
await dispatchCustomEvent("copilotkit_manually_emit_tool_call", {
|
|
48
|
+
name,
|
|
49
|
+
args,
|
|
50
|
+
id: randomId()
|
|
51
|
+
}, config);
|
|
52
|
+
}
|
|
53
|
+
__name(copilotKitEmitToolCall, "copilotKitEmitToolCall");
|
|
54
|
+
export {
|
|
55
|
+
copilotKitCustomizeConfig,
|
|
56
|
+
copilotKitEmitMessage,
|
|
57
|
+
copilotKitEmitState,
|
|
58
|
+
copilotKitEmitToolCall,
|
|
59
|
+
copilotKitExit
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.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 { randomId } from \"@copilotkit/shared\";\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 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 metadata[\"copilotkit:emit-intermediate-state\"] = options.emitIntermediateState;\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"],"mappings":";;;;AACA,SAASA,2BAA2B;AACpC,SAASC,gBAAgB;AAelB,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;AAClCL,aAAS,oCAAA,IAAwCD,QAAQM;EAC3D;AAEAP,eAAaA,cAAc,CAAC;AAE5B,SAAO;IACL,GAAGA;IACHE;EACF;AACF;AA5BgBH;AA8BhB,eAAsBS,eAAeC,QAAsB;AACzD,QAAMC,oBAAoB,mBAAmB,CAAC,GAAGD,MAAAA;AACnD;AAFsBD;AAItB,eAAsBG,oBAAoBF,QAAwBG,OAAU;AAC1E,QAAMF,oBAAoB,+CAA+CE,OAAOH,MAAAA;AAClF;AAFsBE;AAItB,eAAsBE,sBAAsBJ,QAAwBK,SAAe;AACjF,QAAMJ,oBACJ,oCACA;IAAEI;IAASC,YAAYC,SAAAA;IAAYC,MAAM;EAAY,GACrDR,MAAAA;AAEJ;AANsBI;AAQtB,eAAsBK,uBAAuBT,QAAwBU,MAAcC,MAAS;AAC1F,QAAMV,oBACJ,sCACA;IAAES;IAAMC;IAAMC,IAAIL,SAAAA;EAAW,GAC7BP,MAAAA;AAEJ;AANsBS;","names":["dispatchCustomEvent","randomId","copilotKitCustomizeConfig","baseConfig","options","metadata","emitAll","emitToolCalls","undefined","emitMessages","emitIntermediateState","copilotKitExit","config","dispatchCustomEvent","copilotKitEmitState","state","copilotKitEmitMessage","message","message_id","randomId","role","copilotKitEmitToolCall","name","args","id"]}
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@copilotkit/sdk-js",
|
|
3
|
+
"private": false,
|
|
4
|
+
"homepage": "https://github.com/CopilotKit/CopilotKit",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/CopilotKit/CopilotKit.git"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"version": "1.3.16-mme-sdk-js.1",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.mjs",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@swc/core": "1.5.28",
|
|
23
|
+
"@types/express": "^4.17.21",
|
|
24
|
+
"@types/jest": "^29.5.4",
|
|
25
|
+
"@types/node": "^18.11.17",
|
|
26
|
+
"@whatwg-node/server": "^0.9.34",
|
|
27
|
+
"eslint": "^8.56.0",
|
|
28
|
+
"jest": "^29.6.4",
|
|
29
|
+
"nodemon": "^3.1.3",
|
|
30
|
+
"ts-jest": "^29.1.1",
|
|
31
|
+
"ts-node": "^10.9.2",
|
|
32
|
+
"tsup": "^6.7.0",
|
|
33
|
+
"typescript": "^5.2.3",
|
|
34
|
+
"zod-to-json-schema": "^3.23.5",
|
|
35
|
+
"eslint-config-custom": "1.3.16-mme-sdk-js.1",
|
|
36
|
+
"tsconfig": "1.3.16-mme-sdk-js.1"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@langchain/community": "^0.0.53",
|
|
40
|
+
"@langchain/core": "^0.3.13",
|
|
41
|
+
"@langchain/langgraph-sdk": "^0.0.16",
|
|
42
|
+
"langchain": "^0.3.3",
|
|
43
|
+
"zod": "^3.23.3",
|
|
44
|
+
"@copilotkit/shared": "1.3.16-mme-sdk-js.1"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"copilotkit",
|
|
48
|
+
"copilot",
|
|
49
|
+
"react",
|
|
50
|
+
"nextjs",
|
|
51
|
+
"nodejs",
|
|
52
|
+
"ai",
|
|
53
|
+
"assistant",
|
|
54
|
+
"javascript",
|
|
55
|
+
"automation",
|
|
56
|
+
"textarea"
|
|
57
|
+
],
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup --clean",
|
|
60
|
+
"dev": "tsup --watch --no-splitting",
|
|
61
|
+
"test": "jest --passWithNoTests",
|
|
62
|
+
"check-types": "tsc --noEmit",
|
|
63
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
64
|
+
"link:global": "pnpm link --global",
|
|
65
|
+
"unlink:global": "pnpm unlink --global"
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./langchain";
|
package/src/langchain.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RunnableConfig } from "@langchain/core/runnables";
|
|
2
|
+
import { dispatchCustomEvent } from "@langchain/core/callbacks/dispatch";
|
|
3
|
+
import { randomId } from "@copilotkit/shared";
|
|
4
|
+
|
|
5
|
+
interface IntermediateStateConfig {
|
|
6
|
+
stateKey: string;
|
|
7
|
+
tool: string;
|
|
8
|
+
toolArgument?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface OptionsConfig {
|
|
12
|
+
emitToolCalls?: boolean | string | string[];
|
|
13
|
+
emitMessages?: boolean;
|
|
14
|
+
emitAll?: boolean;
|
|
15
|
+
emitIntermediateState?: IntermediateStateConfig[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function copilotKitCustomizeConfig(
|
|
19
|
+
baseConfig?: RunnableConfig,
|
|
20
|
+
options?: OptionsConfig,
|
|
21
|
+
): RunnableConfig {
|
|
22
|
+
const metadata = baseConfig?.metadata || {};
|
|
23
|
+
|
|
24
|
+
if (options?.emitAll) {
|
|
25
|
+
metadata["copilotkit:emit-tool-calls"] = true;
|
|
26
|
+
metadata["copilotkit:emit-messages"] = true;
|
|
27
|
+
} else {
|
|
28
|
+
if (options?.emitToolCalls !== undefined) {
|
|
29
|
+
metadata["copilotkit:emit-tool-calls"] = options.emitToolCalls;
|
|
30
|
+
}
|
|
31
|
+
if (options?.emitMessages !== undefined) {
|
|
32
|
+
metadata["copilotkit:emit-messages"] = options.emitMessages;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (options?.emitIntermediateState) {
|
|
37
|
+
metadata["copilotkit:emit-intermediate-state"] = options.emitIntermediateState;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
baseConfig = baseConfig || {};
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
...baseConfig,
|
|
44
|
+
metadata: metadata,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function copilotKitExit(config: RunnableConfig) {
|
|
49
|
+
await dispatchCustomEvent("copilotkit_exit", {}, config);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function copilotKitEmitState(config: RunnableConfig, state: any) {
|
|
53
|
+
await dispatchCustomEvent("copilotkit_manually_emit_intermediate_state", state, config);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function copilotKitEmitMessage(config: RunnableConfig, message: string) {
|
|
57
|
+
await dispatchCustomEvent(
|
|
58
|
+
"copilotkit_manually_emit_message",
|
|
59
|
+
{ message, message_id: randomId(), role: "assistant" },
|
|
60
|
+
config,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function copilotKitEmitToolCall(config: RunnableConfig, name: string, args: any) {
|
|
65
|
+
await dispatchCustomEvent(
|
|
66
|
+
"copilotkit_manually_emit_tool_call",
|
|
67
|
+
{ name, args, id: randomId() },
|
|
68
|
+
config,
|
|
69
|
+
);
|
|
70
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../utilities/tsconfig/base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["es2017", "dom"],
|
|
5
|
+
"emitDecoratorMetadata": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"strict": false
|
|
8
|
+
},
|
|
9
|
+
"include": ["./src/**/*.ts"],
|
|
10
|
+
"exclude": ["dist", "build", "node_modules", "**/*.test.ts", "**/*.test.tsx", "**/__tests__/*"]
|
|
11
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig, Options } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig((options: Options) => ({
|
|
4
|
+
...options,
|
|
5
|
+
entry: ["src/**/index.ts"],
|
|
6
|
+
format: ["esm", "cjs"],
|
|
7
|
+
dts: true,
|
|
8
|
+
minify: false,
|
|
9
|
+
external: [],
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
exclude: [
|
|
12
|
+
"**/*.test.ts", // Exclude TypeScript test files
|
|
13
|
+
"**/*.test.tsx", // Exclude TypeScript React test files
|
|
14
|
+
"**/__tests__/*", // Exclude any files inside a __tests__ directory
|
|
15
|
+
],
|
|
16
|
+
}));
|
package/typedoc.json
ADDED