@copilotkit/runtime 1.8.15-next.1 → 1.9.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 +26 -0
- package/dist/{chunk-76QVO5FK.mjs → chunk-FK4NZL4G.mjs} +2 -2
- package/dist/{chunk-XRKKSNLV.mjs → chunk-GI32PQX6.mjs} +2 -2
- package/dist/chunk-M3JAEGRU.mjs +141 -0
- package/dist/chunk-M3JAEGRU.mjs.map +1 -0
- package/dist/{chunk-2DM4G7DN.mjs → chunk-U74GJORZ.mjs} +2 -2
- package/dist/{chunk-WPALAYGE.mjs → chunk-YCN5NOAP.mjs} +4 -2
- package/dist/chunk-YCN5NOAP.mjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +140 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -5
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.d.ts +154 -2
- package/dist/lib/index.js +140 -6
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +10 -5
- package/dist/lib/integrations/index.js +2 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.js +2 -1
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +2 -2
- package/dist/lib/integrations/node-express/index.js +2 -1
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +2 -2
- package/dist/lib/integrations/node-http/index.js +2 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/package.json +5 -4
- package/src/lib/index.ts +1 -0
- package/src/lib/runtime/langgraph/langgraph-agent.ts +190 -0
- package/dist/chunk-Q6JA6YY3.mjs +0 -1
- package/dist/chunk-Q6JA6YY3.mjs.map +0 -1
- package/dist/chunk-WPALAYGE.mjs.map +0 -1
- /package/dist/{chunk-76QVO5FK.mjs.map → chunk-FK4NZL4G.mjs.map} +0 -0
- /package/dist/{chunk-XRKKSNLV.mjs.map → chunk-GI32PQX6.mjs.map} +0 -0
- /package/dist/{chunk-2DM4G7DN.mjs.map → chunk-U74GJORZ.mjs.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndp
|
|
|
4
4
|
export { copilotRuntimeNodeHttpEndpoint } from './lib/integrations/node-http/index.js';
|
|
5
5
|
export { copilotRuntimeNodeExpressEndpoint } from './lib/integrations/node-express/index.js';
|
|
6
6
|
export { copilotRuntimeNestEndpoint } from './lib/integrations/nest/index.js';
|
|
7
|
+
export { CustomEventNames, LangGraphAgent, PredictStateTool, State, TextMessageEvents, ToolCallEvents } from './lib/index.js';
|
|
7
8
|
export { GuardrailsValidationFailureResponse, MessageStreamInterruptedResponse, UnknownErrorResponse } from './utils/index.js';
|
|
8
9
|
export { C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse, b as CopilotServiceAdapter, c as RemoteChain, R as RemoteChainParameters } from './langserve-4a5c9217.js';
|
|
9
10
|
export { AnthropicAdapter, AnthropicAdapterParams, BedrockAdapter, BedrockAdapterParams, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter } from './service-adapters/index.js';
|
|
@@ -21,4 +22,6 @@ import './graphql/types/base/index.js';
|
|
|
21
22
|
import './lib/cloud/index.js';
|
|
22
23
|
import '@ag-ui/client';
|
|
23
24
|
import 'rxjs';
|
|
25
|
+
import '@ag-ui/langgraph';
|
|
26
|
+
import '@langchain/langgraph-sdk/dist/types.messages';
|
|
24
27
|
import '@anthropic-ai/sdk';
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.
|
|
47
|
+
version: "1.9.0",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -85,6 +85,7 @@ var require_package = __commonJS({
|
|
|
85
85
|
"@ag-ui/client": "0.0.28",
|
|
86
86
|
"@ag-ui/core": "0.0.28",
|
|
87
87
|
"@ag-ui/encoder": "0.0.28",
|
|
88
|
+
"@ag-ui/langgraph": "0.0.3",
|
|
88
89
|
"@ag-ui/proto": "0.0.28",
|
|
89
90
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
90
91
|
"@copilotkit/shared": "workspace:*",
|
|
@@ -140,6 +141,7 @@ __export(src_exports, {
|
|
|
140
141
|
AnthropicAdapter: () => AnthropicAdapter,
|
|
141
142
|
BedrockAdapter: () => BedrockAdapter,
|
|
142
143
|
CopilotRuntime: () => CopilotRuntime,
|
|
144
|
+
CustomEventNames: () => CustomEventNames2,
|
|
143
145
|
EmptyAdapter: () => EmptyAdapter,
|
|
144
146
|
ExperimentalEmptyAdapter: () => ExperimentalEmptyAdapter,
|
|
145
147
|
ExperimentalOllamaAdapter: () => ExperimentalOllamaAdapter,
|
|
@@ -147,6 +149,7 @@ __export(src_exports, {
|
|
|
147
149
|
GroqAdapter: () => GroqAdapter,
|
|
148
150
|
GuardrailsValidationFailureResponse: () => GuardrailsValidationFailureResponse,
|
|
149
151
|
LangChainAdapter: () => LangChainAdapter,
|
|
152
|
+
LangGraphAgent: () => LangGraphAgent,
|
|
150
153
|
MessageStreamInterruptedResponse: () => MessageStreamInterruptedResponse,
|
|
151
154
|
OpenAIAdapter: () => OpenAIAdapter,
|
|
152
155
|
OpenAIAssistantAdapter: () => OpenAIAssistantAdapter,
|
|
@@ -2780,11 +2783,11 @@ var MetaEventNames;
|
|
|
2780
2783
|
MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
|
|
2781
2784
|
})(MetaEventNames || (MetaEventNames = {}));
|
|
2782
2785
|
var CustomEventNames;
|
|
2783
|
-
(function(
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2786
|
+
(function(CustomEventNames3) {
|
|
2787
|
+
CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
2788
|
+
CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
2789
|
+
CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
2790
|
+
CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
|
|
2788
2791
|
})(CustomEventNames || (CustomEventNames = {}));
|
|
2789
2792
|
|
|
2790
2793
|
// src/agents/langgraph/event-source.ts
|
|
@@ -7078,11 +7081,141 @@ function copilotRuntimeNestEndpoint(options) {
|
|
|
7078
7081
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
7079
7082
|
}
|
|
7080
7083
|
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
7084
|
+
|
|
7085
|
+
// src/lib/runtime/langgraph/langgraph-agent.ts
|
|
7086
|
+
var import_client = require("@ag-ui/client");
|
|
7087
|
+
var import_rxjs5 = require("rxjs");
|
|
7088
|
+
var import_langgraph = require("@ag-ui/langgraph");
|
|
7089
|
+
var CustomEventNames2;
|
|
7090
|
+
(function(CustomEventNames3) {
|
|
7091
|
+
CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
|
|
7092
|
+
CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
|
|
7093
|
+
CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
|
|
7094
|
+
CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
|
|
7095
|
+
})(CustomEventNames2 || (CustomEventNames2 = {}));
|
|
7096
|
+
var LangGraphAgent = class extends import_langgraph.LangGraphAgent {
|
|
7097
|
+
constructor(config2) {
|
|
7098
|
+
super(config2);
|
|
7099
|
+
}
|
|
7100
|
+
dispatchEvent(event) {
|
|
7101
|
+
if (event.type === import_client.EventType.CUSTOM) {
|
|
7102
|
+
const customEvent = event;
|
|
7103
|
+
if (customEvent.name === "copilotkit_manually_emit_message") {
|
|
7104
|
+
this.subscriber.next({
|
|
7105
|
+
type: import_client.EventType.TEXT_MESSAGE_START,
|
|
7106
|
+
role: "assistant",
|
|
7107
|
+
messageId: customEvent.value.message_id,
|
|
7108
|
+
rawEvent: event
|
|
7109
|
+
});
|
|
7110
|
+
this.subscriber.next({
|
|
7111
|
+
type: import_client.EventType.TEXT_MESSAGE_CONTENT,
|
|
7112
|
+
messageId: customEvent.value.message_id,
|
|
7113
|
+
delta: customEvent.value.message,
|
|
7114
|
+
rawEvent: event
|
|
7115
|
+
});
|
|
7116
|
+
this.subscriber.next({
|
|
7117
|
+
type: import_client.EventType.TEXT_MESSAGE_END,
|
|
7118
|
+
messageId: customEvent.value.message_id,
|
|
7119
|
+
rawEvent: event
|
|
7120
|
+
});
|
|
7121
|
+
return true;
|
|
7122
|
+
}
|
|
7123
|
+
if (customEvent.name === "copilotkit_manually_emit_tool_call") {
|
|
7124
|
+
this.subscriber.next({
|
|
7125
|
+
type: import_client.EventType.TOOL_CALL_START,
|
|
7126
|
+
toolCallId: customEvent.value.id,
|
|
7127
|
+
toolCallName: customEvent.value.name,
|
|
7128
|
+
parentMessageId: customEvent.value.id,
|
|
7129
|
+
rawEvent: event
|
|
7130
|
+
});
|
|
7131
|
+
this.subscriber.next({
|
|
7132
|
+
type: import_client.EventType.TOOL_CALL_ARGS,
|
|
7133
|
+
toolCallId: customEvent.value.id,
|
|
7134
|
+
delta: customEvent.value.args,
|
|
7135
|
+
rawEvent: event
|
|
7136
|
+
});
|
|
7137
|
+
this.subscriber.next({
|
|
7138
|
+
type: import_client.EventType.TOOL_CALL_END,
|
|
7139
|
+
toolCallId: customEvent.value.id,
|
|
7140
|
+
rawEvent: event
|
|
7141
|
+
});
|
|
7142
|
+
return true;
|
|
7143
|
+
}
|
|
7144
|
+
if (customEvent.name === "copilotkit_manually_emit_intermediate_state") {
|
|
7145
|
+
this.activeRun.manuallyEmittedState = customEvent.value;
|
|
7146
|
+
this.dispatchEvent({
|
|
7147
|
+
type: import_client.EventType.STATE_SNAPSHOT,
|
|
7148
|
+
snapshot: this.getStateSnapshot(this.activeRun.manuallyEmittedState),
|
|
7149
|
+
rawEvent: event
|
|
7150
|
+
});
|
|
7151
|
+
return true;
|
|
7152
|
+
}
|
|
7153
|
+
if (customEvent.name === "copilotkit_exit") {
|
|
7154
|
+
this.subscriber.next({
|
|
7155
|
+
type: import_client.EventType.CUSTOM,
|
|
7156
|
+
name: "Exit",
|
|
7157
|
+
value: true
|
|
7158
|
+
});
|
|
7159
|
+
return true;
|
|
7160
|
+
}
|
|
7161
|
+
}
|
|
7162
|
+
const rawEvent = event.rawEvent;
|
|
7163
|
+
if (!rawEvent) {
|
|
7164
|
+
this.subscriber.next(event);
|
|
7165
|
+
return true;
|
|
7166
|
+
}
|
|
7167
|
+
const isMessageEvent = event.type === import_client.EventType.TEXT_MESSAGE_START || event.type === import_client.EventType.TEXT_MESSAGE_CONTENT || event.type === import_client.EventType.TEXT_MESSAGE_END;
|
|
7168
|
+
const isToolEvent = event.type === import_client.EventType.TOOL_CALL_START || event.type === import_client.EventType.TOOL_CALL_ARGS || event.type === import_client.EventType.TOOL_CALL_END;
|
|
7169
|
+
if ("copilotkit:emit-tool-calls" in (rawEvent.metadata || {})) {
|
|
7170
|
+
if (rawEvent.metadata["copilotkit:emit-tool-calls"] === false && isToolEvent) {
|
|
7171
|
+
return false;
|
|
7172
|
+
}
|
|
7173
|
+
}
|
|
7174
|
+
if ("copilotkit:emit-messages" in (rawEvent.metadata || {})) {
|
|
7175
|
+
if (rawEvent.metadata["copilotkit:emit-messages"] === false && isMessageEvent) {
|
|
7176
|
+
return false;
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
this.subscriber.next(event);
|
|
7180
|
+
return true;
|
|
7181
|
+
}
|
|
7182
|
+
// @ts-ignore
|
|
7183
|
+
run(input) {
|
|
7184
|
+
return super.run(input).pipe((0, import_rxjs5.map)((processedEvent) => {
|
|
7185
|
+
var _a, _b, _c, _d, _e;
|
|
7186
|
+
if (processedEvent.type === import_client.EventType.RAW) {
|
|
7187
|
+
const event = processedEvent.event ?? processedEvent.rawEvent;
|
|
7188
|
+
const eventType = event.event;
|
|
7189
|
+
const toolCallData = (_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.tool_call_chunks) == null ? void 0 : _c[0];
|
|
7190
|
+
const toolCallUsedToPredictState = (_e = (_d = event.metadata) == null ? void 0 : _d["copilotkit:emit-intermediate-state"]) == null ? void 0 : _e.some((predictStateTool) => predictStateTool.tool === (toolCallData == null ? void 0 : toolCallData.name));
|
|
7191
|
+
if (eventType === LangGraphEventTypes.OnChatModelStream && toolCallUsedToPredictState) {
|
|
7192
|
+
return {
|
|
7193
|
+
type: import_client.EventType.CUSTOM,
|
|
7194
|
+
name: "PredictState",
|
|
7195
|
+
value: event.metadata["copilotkit:emit-intermediate-state"]
|
|
7196
|
+
};
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
return processedEvent;
|
|
7200
|
+
}));
|
|
7201
|
+
}
|
|
7202
|
+
langGraphDefaultMergeState(state, messages, tools) {
|
|
7203
|
+
const { tools: returnedTools, ...rest } = super.langGraphDefaultMergeState(state, messages, tools);
|
|
7204
|
+
return {
|
|
7205
|
+
...rest,
|
|
7206
|
+
copilotkit: {
|
|
7207
|
+
actions: returnedTools
|
|
7208
|
+
}
|
|
7209
|
+
};
|
|
7210
|
+
}
|
|
7211
|
+
};
|
|
7212
|
+
__name(LangGraphAgent, "LangGraphAgent");
|
|
7081
7213
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7082
7214
|
0 && (module.exports = {
|
|
7083
7215
|
AnthropicAdapter,
|
|
7084
7216
|
BedrockAdapter,
|
|
7085
7217
|
CopilotRuntime,
|
|
7218
|
+
CustomEventNames,
|
|
7086
7219
|
EmptyAdapter,
|
|
7087
7220
|
ExperimentalEmptyAdapter,
|
|
7088
7221
|
ExperimentalOllamaAdapter,
|
|
@@ -7090,6 +7223,7 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
7090
7223
|
GroqAdapter,
|
|
7091
7224
|
GuardrailsValidationFailureResponse,
|
|
7092
7225
|
LangChainAdapter,
|
|
7226
|
+
LangGraphAgent,
|
|
7093
7227
|
MessageStreamInterruptedResponse,
|
|
7094
7228
|
OpenAIAdapter,
|
|
7095
7229
|
OpenAIAssistantAdapter,
|