@copilotkit/runtime 1.8.15-next.0 → 1.9.0-next.2

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 (47) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-M6Z4CLI6.mjs → chunk-6A27R7IP.mjs} +6 -3
  3. package/dist/chunk-6A27R7IP.mjs.map +1 -0
  4. package/dist/{chunk-272XZVAS.mjs → chunk-G4NOAQUA.mjs} +2 -2
  5. package/dist/{chunk-GEZX4PJT.mjs → chunk-IIXJVVTV.mjs} +23 -1
  6. package/dist/chunk-IIXJVVTV.mjs.map +1 -0
  7. package/dist/{chunk-OGEL67NA.mjs → chunk-S5TNKSNR.mjs} +2 -2
  8. package/dist/chunk-XB3TW5NJ.mjs +141 -0
  9. package/dist/chunk-XB3TW5NJ.mjs.map +1 -0
  10. package/dist/{chunk-MXITD3JG.mjs → chunk-XPTVSVNM.mjs} +2 -2
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.js +164 -6
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +13 -6
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/lib/index.d.ts +154 -2
  17. package/dist/lib/index.js +141 -6
  18. package/dist/lib/index.js.map +1 -1
  19. package/dist/lib/index.mjs +11 -6
  20. package/dist/lib/integrations/index.js +3 -1
  21. package/dist/lib/integrations/index.js.map +1 -1
  22. package/dist/lib/integrations/index.mjs +5 -5
  23. package/dist/lib/integrations/nest/index.js +3 -1
  24. package/dist/lib/integrations/nest/index.js.map +1 -1
  25. package/dist/lib/integrations/nest/index.mjs +3 -3
  26. package/dist/lib/integrations/node-express/index.js +3 -1
  27. package/dist/lib/integrations/node-express/index.js.map +1 -1
  28. package/dist/lib/integrations/node-express/index.mjs +3 -3
  29. package/dist/lib/integrations/node-http/index.js +3 -1
  30. package/dist/lib/integrations/node-http/index.js.map +1 -1
  31. package/dist/lib/integrations/node-http/index.mjs +2 -2
  32. package/dist/service-adapters/index.d.ts +47 -2
  33. package/dist/service-adapters/index.js +23 -0
  34. package/dist/service-adapters/index.js.map +1 -1
  35. package/dist/service-adapters/index.mjs +3 -1
  36. package/package.json +4 -2
  37. package/src/lib/index.ts +1 -0
  38. package/src/lib/runtime/langgraph/langgraph-agent.ts +190 -0
  39. package/src/service-adapters/bedrock/bedrock-adapter.ts +65 -0
  40. package/src/service-adapters/index.ts +1 -0
  41. package/dist/chunk-GEZX4PJT.mjs.map +0 -1
  42. package/dist/chunk-M6Z4CLI6.mjs.map +0 -1
  43. package/dist/chunk-Q6JA6YY3.mjs +0 -1
  44. package/dist/chunk-Q6JA6YY3.mjs.map +0 -1
  45. /package/dist/{chunk-272XZVAS.mjs.map → chunk-G4NOAQUA.mjs.map} +0 -0
  46. /package/dist/{chunk-OGEL67NA.mjs.map → chunk-S5TNKSNR.mjs.map} +0 -0
  47. /package/dist/{chunk-MXITD3JG.mjs.map → chunk-XPTVSVNM.mjs.map} +0 -0
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.8.15-next.0",
47
+ version: "1.9.0-next.2",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -85,10 +85,12 @@ 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:*",
91
92
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
93
+ "@langchain/aws": "^0.1.9",
92
94
  "@langchain/community": "^0.3.29",
93
95
  "@langchain/core": "^0.3.38",
94
96
  "@langchain/google-gauth": "^0.1.0",
@@ -137,7 +139,9 @@ var require_package = __commonJS({
137
139
  var src_exports = {};
138
140
  __export(src_exports, {
139
141
  AnthropicAdapter: () => AnthropicAdapter,
142
+ BedrockAdapter: () => BedrockAdapter,
140
143
  CopilotRuntime: () => CopilotRuntime,
144
+ CustomEventNames: () => CustomEventNames2,
141
145
  EmptyAdapter: () => EmptyAdapter,
142
146
  ExperimentalEmptyAdapter: () => ExperimentalEmptyAdapter,
143
147
  ExperimentalOllamaAdapter: () => ExperimentalOllamaAdapter,
@@ -145,6 +149,7 @@ __export(src_exports, {
145
149
  GroqAdapter: () => GroqAdapter,
146
150
  GuardrailsValidationFailureResponse: () => GuardrailsValidationFailureResponse,
147
151
  LangChainAdapter: () => LangChainAdapter,
152
+ LangGraphAgent: () => LangGraphAgent,
148
153
  MessageStreamInterruptedResponse: () => MessageStreamInterruptedResponse,
149
154
  OpenAIAdapter: () => OpenAIAdapter,
150
155
  OpenAIAssistantAdapter: () => OpenAIAssistantAdapter,
@@ -2778,11 +2783,11 @@ var MetaEventNames;
2778
2783
  MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
2779
2784
  })(MetaEventNames || (MetaEventNames = {}));
2780
2785
  var CustomEventNames;
2781
- (function(CustomEventNames2) {
2782
- CustomEventNames2["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
2783
- CustomEventNames2["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
2784
- CustomEventNames2["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
2785
- CustomEventNames2["CopilotKitExit"] = "copilotkit_exit";
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";
2786
2791
  })(CustomEventNames || (CustomEventNames = {}));
2787
2792
 
2788
2793
  // src/agents/langgraph/event-source.ts
@@ -4641,6 +4646,27 @@ var ExperimentalOllamaAdapter = class {
4641
4646
  };
4642
4647
  __name(ExperimentalOllamaAdapter, "ExperimentalOllamaAdapter");
4643
4648
 
4649
+ // src/service-adapters/bedrock/bedrock-adapter.ts
4650
+ var import_aws = require("@langchain/aws");
4651
+ var BedrockAdapter = class extends LangChainAdapter {
4652
+ constructor(options) {
4653
+ super({
4654
+ chainFn: async ({ messages, tools, threadId }) => {
4655
+ const model = new import_aws.ChatBedrockConverse({
4656
+ model: (options == null ? void 0 : options.model) ?? "amazon.nova-lite-v1:0",
4657
+ region: (options == null ? void 0 : options.region) ?? "us-east-1",
4658
+ credentials: (options == null ? void 0 : options.credentials) ? {
4659
+ accessKeyId: options.credentials.accessKeyId,
4660
+ secretAccessKey: options.credentials.secretAccessKey
4661
+ } : void 0
4662
+ }).bindTools(tools);
4663
+ return model.stream(messages);
4664
+ }
4665
+ });
4666
+ }
4667
+ };
4668
+ __name(BedrockAdapter, "BedrockAdapter");
4669
+
4644
4670
  // src/service-adapters/empty/empty-adapter.ts
4645
4671
  var import_shared18 = require("@copilotkit/shared");
4646
4672
  var EmptyAdapter = class {
@@ -7055,10 +7081,141 @@ function copilotRuntimeNestEndpoint(options) {
7055
7081
  return copilotRuntimeNodeHttpEndpoint(options);
7056
7082
  }
7057
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");
7058
7213
  // Annotate the CommonJS export names for ESM import in node:
7059
7214
  0 && (module.exports = {
7060
7215
  AnthropicAdapter,
7216
+ BedrockAdapter,
7061
7217
  CopilotRuntime,
7218
+ CustomEventNames,
7062
7219
  EmptyAdapter,
7063
7220
  ExperimentalEmptyAdapter,
7064
7221
  ExperimentalOllamaAdapter,
@@ -7066,6 +7223,7 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
7066
7223
  GroqAdapter,
7067
7224
  GuardrailsValidationFailureResponse,
7068
7225
  LangChainAdapter,
7226
+ LangGraphAgent,
7069
7227
  MessageStreamInterruptedResponse,
7070
7228
  OpenAIAdapter,
7071
7229
  OpenAIAssistantAdapter,