@copilotkit/runtime 0.0.0-fix-debug-infosys-20251107151227 → 0.0.0-fix-restore-handle-method-node-http-20251222114321

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 (142) hide show
  1. package/CHANGELOG.md +259 -3
  2. package/dist/index.d.ts +1493 -28
  3. package/dist/index.js +2568 -5467
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +5429 -99
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/{lib/index.d.ts → langgraph.d.ts} +104 -32
  8. package/dist/langgraph.js +211 -0
  9. package/dist/langgraph.js.map +1 -0
  10. package/dist/{chunk-XPALJ76U.mjs → langgraph.mjs} +57 -26
  11. package/dist/langgraph.mjs.map +1 -0
  12. package/dist/v2/index.d.ts +2 -0
  13. package/dist/v2/index.js +22 -0
  14. package/dist/v2/index.js.map +1 -0
  15. package/dist/v2/index.mjs +5 -0
  16. package/dist/v2/index.mjs.map +1 -0
  17. package/package.json +64 -20
  18. package/src/graphql/message-conversion/agui-to-gql.test.ts +1263 -0
  19. package/src/graphql/message-conversion/agui-to-gql.ts +333 -0
  20. package/src/graphql/message-conversion/gql-to-agui.test.ts +1580 -0
  21. package/src/graphql/message-conversion/gql-to-agui.ts +278 -0
  22. package/src/graphql/message-conversion/index.ts +2 -0
  23. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +526 -0
  24. package/src/graphql/resolvers/copilot.resolver.ts +3 -51
  25. package/src/graphql/resolvers/state.resolver.ts +3 -2
  26. package/src/graphql/types/converted/index.ts +32 -6
  27. package/src/graphql/types/enums.ts +2 -2
  28. package/src/graphql/types/message-status.type.ts +3 -1
  29. package/src/langgraph.ts +1 -0
  30. package/src/lib/index.ts +42 -1
  31. package/src/lib/integrations/nextjs/app-router.ts +12 -11
  32. package/src/lib/integrations/nextjs/pages-router.ts +4 -11
  33. package/src/lib/integrations/node-http/index.ts +10 -5
  34. package/src/lib/integrations/shared.ts +1 -1
  35. package/src/lib/observability.ts +87 -0
  36. package/src/lib/runtime/{langgraph/langgraph-agent.ts → agent-integrations/langgraph/agent.ts} +10 -30
  37. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +34 -0
  38. package/src/lib/runtime/agent-integrations/langgraph/index.ts +2 -0
  39. package/src/lib/runtime/copilot-runtime.ts +387 -1360
  40. package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
  41. package/src/lib/runtime/types.ts +49 -0
  42. package/src/lib/runtime/utils.ts +87 -0
  43. package/src/lib/telemetry-client.ts +6 -5
  44. package/src/service-adapters/anthropic/anthropic-adapter.ts +21 -4
  45. package/src/service-adapters/bedrock/bedrock-adapter.ts +10 -2
  46. package/src/service-adapters/empty/empty-adapter.ts +3 -0
  47. package/src/service-adapters/events.ts +0 -254
  48. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +7 -2
  49. package/src/service-adapters/google/google-genai-adapter.ts +33 -7
  50. package/src/service-adapters/groq/groq-adapter.ts +21 -4
  51. package/src/service-adapters/langchain/langchain-adapter.ts +8 -3
  52. package/src/service-adapters/langchain/langserve.ts +2 -1
  53. package/src/service-adapters/openai/openai-adapter.ts +22 -4
  54. package/src/service-adapters/openai/openai-assistant-adapter.ts +30 -11
  55. package/src/service-adapters/service-adapter.ts +3 -0
  56. package/src/service-adapters/unify/unify-adapter.ts +9 -2
  57. package/src/v2/index.ts +3 -0
  58. package/tsup.config.ts +6 -2
  59. package/dist/chunk-27JKTS6P.mjs +0 -1704
  60. package/dist/chunk-27JKTS6P.mjs.map +0 -1
  61. package/dist/chunk-2DHC2YFK.mjs +0 -6026
  62. package/dist/chunk-2DHC2YFK.mjs.map +0 -1
  63. package/dist/chunk-2OZAGFV3.mjs +0 -43
  64. package/dist/chunk-2OZAGFV3.mjs.map +0 -1
  65. package/dist/chunk-5HHH4SZ3.mjs +0 -25
  66. package/dist/chunk-5HHH4SZ3.mjs.map +0 -1
  67. package/dist/chunk-AMUJQ6IR.mjs +0 -50
  68. package/dist/chunk-AMUJQ6IR.mjs.map +0 -1
  69. package/dist/chunk-FHD4JECV.mjs +0 -33
  70. package/dist/chunk-FHD4JECV.mjs.map +0 -1
  71. package/dist/chunk-FVG3IQG7.mjs +0 -25
  72. package/dist/chunk-FVG3IQG7.mjs.map +0 -1
  73. package/dist/chunk-QU2FLIQB.mjs +0 -80
  74. package/dist/chunk-QU2FLIQB.mjs.map +0 -1
  75. package/dist/chunk-SHBDMA63.mjs +0 -141
  76. package/dist/chunk-SHBDMA63.mjs.map +0 -1
  77. package/dist/chunk-XPALJ76U.mjs.map +0 -1
  78. package/dist/chunk-XWBDEXDA.mjs +0 -153
  79. package/dist/chunk-XWBDEXDA.mjs.map +0 -1
  80. package/dist/graphql/types/base/index.d.ts +0 -6
  81. package/dist/graphql/types/base/index.js +0 -63
  82. package/dist/graphql/types/base/index.js.map +0 -1
  83. package/dist/graphql/types/base/index.mjs +0 -8
  84. package/dist/graphql/types/base/index.mjs.map +0 -1
  85. package/dist/graphql/types/converted/index.d.ts +0 -2
  86. package/dist/graphql/types/converted/index.js +0 -200
  87. package/dist/graphql/types/converted/index.js.map +0 -1
  88. package/dist/graphql/types/converted/index.mjs +0 -19
  89. package/dist/graphql/types/converted/index.mjs.map +0 -1
  90. package/dist/groq-adapter-c8aec5c5.d.ts +0 -321
  91. package/dist/index-96b330da.d.ts +0 -119
  92. package/dist/langserve-0c6100e3.d.ts +0 -257
  93. package/dist/lib/cloud/index.d.ts +0 -6
  94. package/dist/lib/cloud/index.js +0 -18
  95. package/dist/lib/cloud/index.js.map +0 -1
  96. package/dist/lib/cloud/index.mjs +0 -1
  97. package/dist/lib/cloud/index.mjs.map +0 -1
  98. package/dist/lib/index.js +0 -7849
  99. package/dist/lib/index.js.map +0 -1
  100. package/dist/lib/index.mjs +0 -76
  101. package/dist/lib/index.mjs.map +0 -1
  102. package/dist/lib/integrations/index.d.ts +0 -34
  103. package/dist/lib/integrations/index.js +0 -3055
  104. package/dist/lib/integrations/index.js.map +0 -1
  105. package/dist/lib/integrations/index.mjs +0 -37
  106. package/dist/lib/integrations/index.mjs.map +0 -1
  107. package/dist/lib/integrations/nest/index.d.ts +0 -15
  108. package/dist/lib/integrations/nest/index.js +0 -2962
  109. package/dist/lib/integrations/nest/index.js.map +0 -1
  110. package/dist/lib/integrations/nest/index.mjs +0 -14
  111. package/dist/lib/integrations/nest/index.mjs.map +0 -1
  112. package/dist/lib/integrations/node-express/index.d.ts +0 -15
  113. package/dist/lib/integrations/node-express/index.js +0 -2962
  114. package/dist/lib/integrations/node-express/index.js.map +0 -1
  115. package/dist/lib/integrations/node-express/index.mjs +0 -14
  116. package/dist/lib/integrations/node-express/index.mjs.map +0 -1
  117. package/dist/lib/integrations/node-http/index.d.ts +0 -15
  118. package/dist/lib/integrations/node-http/index.js +0 -2948
  119. package/dist/lib/integrations/node-http/index.js.map +0 -1
  120. package/dist/lib/integrations/node-http/index.mjs +0 -13
  121. package/dist/lib/integrations/node-http/index.mjs.map +0 -1
  122. package/dist/service-adapters/index.d.ts +0 -162
  123. package/dist/service-adapters/index.js +0 -1787
  124. package/dist/service-adapters/index.js.map +0 -1
  125. package/dist/service-adapters/index.mjs +0 -34
  126. package/dist/service-adapters/index.mjs.map +0 -1
  127. package/dist/service-adapters/shared/index.d.ts +0 -9
  128. package/dist/service-adapters/shared/index.js +0 -72
  129. package/dist/service-adapters/shared/index.js.map +0 -1
  130. package/dist/service-adapters/shared/index.mjs +0 -8
  131. package/dist/service-adapters/shared/index.mjs.map +0 -1
  132. package/dist/shared-0a7346ce.d.ts +0 -466
  133. package/dist/utils/index.d.ts +0 -65
  134. package/dist/utils/index.js +0 -175
  135. package/dist/utils/index.js.map +0 -1
  136. package/dist/utils/index.mjs +0 -12
  137. package/dist/utils/index.mjs.map +0 -1
  138. package/src/lib/runtime/__tests__/remote-action-constructors.test.ts +0 -246
  139. package/src/lib/runtime/agui-action.ts +0 -180
  140. package/src/lib/runtime/remote-action-constructors.ts +0 -331
  141. package/src/lib/runtime/remote-actions.ts +0 -217
  142. package/src/lib/runtime/remote-lg-action.ts +0 -1006
@@ -1,6 +0,0 @@
1
- declare class BaseMessageInput {
2
- id: string;
3
- createdAt: Date;
4
- }
5
-
6
- export { BaseMessageInput };
@@ -1,63 +0,0 @@
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/graphql/types/base/index.ts
21
- var base_exports = {};
22
- __export(base_exports, {
23
- BaseMessageInput: () => BaseMessageInput
24
- });
25
- module.exports = __toCommonJS(base_exports);
26
- var import_type_graphql = require("type-graphql");
27
- function _ts_decorate(decorators, target, key, desc) {
28
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
30
- r = Reflect.decorate(decorators, target, key, desc);
31
- else
32
- for (var i = decorators.length - 1; i >= 0; i--)
33
- if (d = decorators[i])
34
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
35
- return c > 3 && r && Object.defineProperty(target, key, r), r;
36
- }
37
- __name(_ts_decorate, "_ts_decorate");
38
- function _ts_metadata(k, v) {
39
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
40
- return Reflect.metadata(k, v);
41
- }
42
- __name(_ts_metadata, "_ts_metadata");
43
- var BaseMessageInput = class {
44
- id;
45
- createdAt;
46
- };
47
- __name(BaseMessageInput, "BaseMessageInput");
48
- _ts_decorate([
49
- (0, import_type_graphql.Field)(() => String),
50
- _ts_metadata("design:type", String)
51
- ], BaseMessageInput.prototype, "id", void 0);
52
- _ts_decorate([
53
- (0, import_type_graphql.Field)(() => Date),
54
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
55
- ], BaseMessageInput.prototype, "createdAt", void 0);
56
- BaseMessageInput = _ts_decorate([
57
- (0, import_type_graphql.InputType)()
58
- ], BaseMessageInput);
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- BaseMessageInput
62
- });
63
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/graphql/types/base/index.ts"],"sourcesContent":["import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class BaseMessageInput {\n @Field(() => String)\n id: string;\n\n @Field(() => Date)\n createdAt: Date;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAAiC;;;;;;;;;;;;;;;;;AAG1B,IAAMA,mBAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;MACVG,2BAAM,MAAMC,MAAAA;;GADFJ,iBAAAA,WAAAA,MAAAA,MAAAA;;MAIVG,2BAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,iBAAAA,WAAAA,aAAAA,MAAAA;AAAAA,mBAAAA,aAAAA;MADZM,+BAAAA;GACYN,gBAAAA;","names":["BaseMessageInput","id","createdAt","Field","String","Date","InputType"]}
@@ -1,8 +0,0 @@
1
- import {
2
- BaseMessageInput
3
- } from "../../../chunk-2OZAGFV3.mjs";
4
- import "../../../chunk-FHD4JECV.mjs";
5
- export {
6
- BaseMessageInput
7
- };
8
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +0,0 @@
1
- export { a as ActionExecutionMessage, d as AgentStateMessage, I as ImageMessage, M as Message, c as MessageType, R as ResultMessage, T as TextMessage } from '../../../index-96b330da.js';
2
- import '../base/index.js';
@@ -1,200 +0,0 @@
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/graphql/types/converted/index.ts
21
- var converted_exports = {};
22
- __export(converted_exports, {
23
- ActionExecutionMessage: () => ActionExecutionMessage,
24
- AgentStateMessage: () => AgentStateMessage,
25
- ImageMessage: () => ImageMessage,
26
- Message: () => Message,
27
- ResultMessage: () => ResultMessage,
28
- TextMessage: () => TextMessage
29
- });
30
- module.exports = __toCommonJS(converted_exports);
31
-
32
- // src/graphql/types/base/index.ts
33
- var import_type_graphql = require("type-graphql");
34
- function _ts_decorate(decorators, target, key, desc) {
35
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
36
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
37
- r = Reflect.decorate(decorators, target, key, desc);
38
- else
39
- for (var i = decorators.length - 1; i >= 0; i--)
40
- if (d = decorators[i])
41
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
42
- return c > 3 && r && Object.defineProperty(target, key, r), r;
43
- }
44
- __name(_ts_decorate, "_ts_decorate");
45
- function _ts_metadata(k, v) {
46
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
47
- return Reflect.metadata(k, v);
48
- }
49
- __name(_ts_metadata, "_ts_metadata");
50
- var BaseMessageInput = class {
51
- id;
52
- createdAt;
53
- };
54
- __name(BaseMessageInput, "BaseMessageInput");
55
- _ts_decorate([
56
- (0, import_type_graphql.Field)(() => String),
57
- _ts_metadata("design:type", String)
58
- ], BaseMessageInput.prototype, "id", void 0);
59
- _ts_decorate([
60
- (0, import_type_graphql.Field)(() => Date),
61
- _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
62
- ], BaseMessageInput.prototype, "createdAt", void 0);
63
- BaseMessageInput = _ts_decorate([
64
- (0, import_type_graphql.InputType)()
65
- ], BaseMessageInput);
66
-
67
- // src/graphql/types/converted/index.ts
68
- var Message = class extends BaseMessageInput {
69
- type;
70
- isTextMessage() {
71
- return this.type === "TextMessage";
72
- }
73
- isActionExecutionMessage() {
74
- return this.type === "ActionExecutionMessage";
75
- }
76
- isResultMessage() {
77
- return this.type === "ResultMessage";
78
- }
79
- isAgentStateMessage() {
80
- return this.type === "AgentStateMessage";
81
- }
82
- isImageMessage() {
83
- return this.type === "ImageMessage";
84
- }
85
- };
86
- __name(Message, "Message");
87
- var TextMessage = class extends Message {
88
- type = "TextMessage";
89
- content;
90
- role;
91
- parentMessageId;
92
- };
93
- __name(TextMessage, "TextMessage");
94
- var ActionExecutionMessage = class extends Message {
95
- type = "ActionExecutionMessage";
96
- name;
97
- arguments;
98
- parentMessageId;
99
- };
100
- __name(ActionExecutionMessage, "ActionExecutionMessage");
101
- var ResultMessage = class extends Message {
102
- type = "ResultMessage";
103
- actionExecutionId;
104
- actionName;
105
- result;
106
- static encodeResult(result, error) {
107
- const errorObj = error ? typeof error === "string" ? {
108
- code: "ERROR",
109
- message: error
110
- } : error instanceof Error ? {
111
- code: "ERROR",
112
- message: error.message
113
- } : error : void 0;
114
- if (errorObj) {
115
- return JSON.stringify({
116
- error: errorObj,
117
- result: result || ""
118
- });
119
- }
120
- if (result === void 0) {
121
- return "";
122
- }
123
- return typeof result === "string" ? result : JSON.stringify(result);
124
- }
125
- static decodeResult(result) {
126
- if (!result) {
127
- return {
128
- result: ""
129
- };
130
- }
131
- try {
132
- const parsed = JSON.parse(result);
133
- if (parsed && typeof parsed === "object") {
134
- if ("error" in parsed) {
135
- return {
136
- error: parsed.error,
137
- result: parsed.result || ""
138
- };
139
- }
140
- return {
141
- result: JSON.stringify(parsed)
142
- };
143
- }
144
- return {
145
- result
146
- };
147
- } catch (e) {
148
- return {
149
- result
150
- };
151
- }
152
- }
153
- hasError() {
154
- try {
155
- const { error } = ResultMessage.decodeResult(this.result);
156
- return !!error;
157
- } catch {
158
- return false;
159
- }
160
- }
161
- getError() {
162
- try {
163
- const { error } = ResultMessage.decodeResult(this.result);
164
- return error;
165
- } catch {
166
- return void 0;
167
- }
168
- }
169
- };
170
- __name(ResultMessage, "ResultMessage");
171
- var AgentStateMessage = class extends Message {
172
- type = "AgentStateMessage";
173
- threadId;
174
- agentName;
175
- nodeName;
176
- runId;
177
- active;
178
- role;
179
- state;
180
- running;
181
- };
182
- __name(AgentStateMessage, "AgentStateMessage");
183
- var ImageMessage = class extends Message {
184
- type = "ImageMessage";
185
- format;
186
- bytes;
187
- role;
188
- parentMessageId;
189
- };
190
- __name(ImageMessage, "ImageMessage");
191
- // Annotate the CommonJS export names for ESM import in node:
192
- 0 && (module.exports = {
193
- ActionExecutionMessage,
194
- AgentStateMessage,
195
- ImageMessage,
196
- Message,
197
- ResultMessage,
198
- TextMessage
199
- });
200
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/graphql/types/converted/index.ts","../../../../src/graphql/types/base/index.ts"],"sourcesContent":["import {\n ActionExecutionMessageInput,\n ResultMessageInput,\n TextMessageInput,\n AgentStateMessageInput,\n ImageMessageInput,\n} from \"../../inputs/message.input\";\nimport { BaseMessageInput } from \"../base\";\nimport { MessageRole } from \"../enums\";\n\nexport type MessageType =\n | \"TextMessage\"\n | \"ActionExecutionMessage\"\n | \"ResultMessage\"\n | \"AgentStateMessage\"\n | \"ImageMessage\";\n\nexport class Message extends BaseMessageInput {\n type: MessageType;\n\n isTextMessage(): this is TextMessage {\n return this.type === \"TextMessage\";\n }\n\n isActionExecutionMessage(): this is ActionExecutionMessage {\n return this.type === \"ActionExecutionMessage\";\n }\n\n isResultMessage(): this is ResultMessage {\n return this.type === \"ResultMessage\";\n }\n\n isAgentStateMessage(): this is AgentStateMessage {\n return this.type === \"AgentStateMessage\";\n }\n\n isImageMessage(): this is ImageMessage {\n return this.type === \"ImageMessage\";\n }\n}\n\nexport class TextMessage extends Message implements TextMessageInput {\n type: MessageType = \"TextMessage\";\n content: string;\n role: MessageRole;\n parentMessageId?: string;\n}\n\nexport class ActionExecutionMessage\n extends Message\n implements Omit<ActionExecutionMessageInput, \"arguments\" | \"scope\">\n{\n type: MessageType = \"ActionExecutionMessage\";\n name: string;\n arguments: Record<string, any>;\n parentMessageId?: string;\n}\n\nexport class ResultMessage extends Message implements ResultMessageInput {\n type: MessageType = \"ResultMessage\";\n actionExecutionId: string;\n actionName: string;\n result: string;\n\n static encodeResult(\n result: any,\n error?: { code: string; message: string } | string | Error,\n ): string {\n const errorObj = error\n ? typeof error === \"string\"\n ? { code: \"ERROR\", message: error }\n : error instanceof Error\n ? { code: \"ERROR\", message: error.message }\n : error\n : undefined;\n\n if (errorObj) {\n return JSON.stringify({\n error: errorObj,\n result: result || \"\",\n });\n }\n if (result === undefined) {\n return \"\";\n }\n return typeof result === \"string\" ? result : JSON.stringify(result);\n }\n\n static decodeResult(result: string): {\n error?: { code: string; message: string };\n result: string;\n } {\n if (!result) {\n return { result: \"\" };\n }\n try {\n const parsed = JSON.parse(result);\n if (parsed && typeof parsed === \"object\") {\n if (\"error\" in parsed) {\n return {\n error: parsed.error,\n result: parsed.result || \"\",\n };\n }\n return { result: JSON.stringify(parsed) };\n }\n return { result };\n } catch (e) {\n return { result };\n }\n }\n\n hasError(): boolean {\n try {\n const { error } = ResultMessage.decodeResult(this.result);\n return !!error;\n } catch {\n return false;\n }\n }\n\n getError(): { code: string; message: string } | undefined {\n try {\n const { error } = ResultMessage.decodeResult(this.result);\n return error;\n } catch {\n return undefined;\n }\n }\n}\n\nexport class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, \"state\"> {\n type: MessageType = \"AgentStateMessage\";\n threadId: string;\n agentName: string;\n nodeName: string;\n runId: string;\n active: boolean;\n role: MessageRole;\n state: any;\n running: boolean;\n}\n\nexport class ImageMessage extends Message implements ImageMessageInput {\n type: MessageType = \"ImageMessage\";\n format: string;\n bytes: string;\n role: MessageRole;\n parentMessageId?: string;\n}\n","import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class BaseMessageInput {\n @Field(() => String)\n id: string;\n\n @Field(() => Date)\n createdAt: Date;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOA;;;;;;;;;;;;ACPA,0BAAiC;;;;;;;;;;;;;;;;;AAG1B,IAAMA,mBAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;MACVG,2BAAM,MAAMC,MAAAA;;GADFJ,iBAAAA,WAAAA,MAAAA,MAAAA;;MAIVG,2BAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,iBAAAA,WAAAA,aAAAA,MAAAA;AAAAA,mBAAAA,aAAAA;MADZM,+BAAAA;GACYN,gBAAAA;;;ADcN,IAAMO,UAAN,cAAsBC,iBAAAA;EAC3BC;EAEAC,gBAAqC;AACnC,WAAO,KAAKD,SAAS;EACvB;EAEAE,2BAA2D;AACzD,WAAO,KAAKF,SAAS;EACvB;EAEAG,kBAAyC;AACvC,WAAO,KAAKH,SAAS;EACvB;EAEAI,sBAAiD;AAC/C,WAAO,KAAKJ,SAAS;EACvB;EAEAK,iBAAuC;AACrC,WAAO,KAAKL,SAAS;EACvB;AACF;AAtBaF;AAwBN,IAAMQ,cAAN,cAA0BR,QAAAA;EAC/BE,OAAoB;EACpBO;EACAC;EACAC;AACF;AALaH;AAON,IAAMI,yBAAN,cACGZ,QAAAA;EAGRE,OAAoB;EACpBW;EACAC;EACAH;AACF;AARaC;AAUN,IAAMG,gBAAN,cAA4Bf,QAAAA;EACjCE,OAAoB;EACpBc;EACAC;EACAC;EAEA,OAAOC,aACLD,QACAE,OACQ;AACR,UAAMC,WAAWD,QACb,OAAOA,UAAU,WACf;MAAEE,MAAM;MAASC,SAASH;IAAM,IAChCA,iBAAiBI,QACf;MAAEF,MAAM;MAASC,SAASH,MAAMG;IAAQ,IACxCH,QACJK;AAEJ,QAAIJ,UAAU;AACZ,aAAOK,KAAKC,UAAU;QACpBP,OAAOC;QACPH,QAAQA,UAAU;MACpB,CAAA;IACF;AACA,QAAIA,WAAWO,QAAW;AACxB,aAAO;IACT;AACA,WAAO,OAAOP,WAAW,WAAWA,SAASQ,KAAKC,UAAUT,MAAAA;EAC9D;EAEA,OAAOU,aAAaV,QAGlB;AACA,QAAI,CAACA,QAAQ;AACX,aAAO;QAAEA,QAAQ;MAAG;IACtB;AACA,QAAI;AACF,YAAMW,SAASH,KAAKI,MAAMZ,MAAAA;AAC1B,UAAIW,UAAU,OAAOA,WAAW,UAAU;AACxC,YAAI,WAAWA,QAAQ;AACrB,iBAAO;YACLT,OAAOS,OAAOT;YACdF,QAAQW,OAAOX,UAAU;UAC3B;QACF;AACA,eAAO;UAAEA,QAAQQ,KAAKC,UAAUE,MAAAA;QAAQ;MAC1C;AACA,aAAO;QAAEX;MAAO;IAClB,SAASa,GAAP;AACA,aAAO;QAAEb;MAAO;IAClB;EACF;EAEAc,WAAoB;AAClB,QAAI;AACF,YAAM,EAAEZ,MAAK,IAAKL,cAAca,aAAa,KAAKV,MAAM;AACxD,aAAO,CAAC,CAACE;IACX,QAAE;AACA,aAAO;IACT;EACF;EAEAa,WAA0D;AACxD,QAAI;AACF,YAAM,EAAEb,MAAK,IAAKL,cAAca,aAAa,KAAKV,MAAM;AACxD,aAAOE;IACT,QAAE;AACA,aAAOK;IACT;EACF;AACF;AAvEaV;AAyEN,IAAMmB,oBAAN,cAAgClC,QAAAA;EACrCE,OAAoB;EACpBiC;EACAC;EACAC;EACAC;EACAC;EACA7B;EACA8B;EACAC;AACF;AAVaP;AAYN,IAAMQ,eAAN,cAA2B1C,QAAAA;EAChCE,OAAoB;EACpByC;EACAC;EACAlC;EACAC;AACF;AANa+B;","names":["BaseMessageInput","id","createdAt","Field","String","Date","InputType","Message","BaseMessageInput","type","isTextMessage","isActionExecutionMessage","isResultMessage","isAgentStateMessage","isImageMessage","TextMessage","content","role","parentMessageId","ActionExecutionMessage","name","arguments","ResultMessage","actionExecutionId","actionName","result","encodeResult","error","errorObj","code","message","Error","undefined","JSON","stringify","decodeResult","parsed","parse","e","hasError","getError","AgentStateMessage","threadId","agentName","nodeName","runId","active","state","running","ImageMessage","format","bytes"]}
@@ -1,19 +0,0 @@
1
- import {
2
- ActionExecutionMessage,
3
- AgentStateMessage,
4
- ImageMessage,
5
- Message,
6
- ResultMessage,
7
- TextMessage
8
- } from "../../../chunk-SHBDMA63.mjs";
9
- import "../../../chunk-2OZAGFV3.mjs";
10
- import "../../../chunk-FHD4JECV.mjs";
11
- export {
12
- ActionExecutionMessage,
13
- AgentStateMessage,
14
- ImageMessage,
15
- Message,
16
- ResultMessage,
17
- TextMessage
18
- };
19
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,321 +0,0 @@
1
- import OpenAI from 'openai';
2
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from './langserve-0c6100e3.js';
3
- import { BaseMessageChunk, AIMessage, AIMessageChunk, BaseMessage } from '@langchain/core/messages';
4
- import { DynamicStructuredTool } from '@langchain/core/tools';
5
- import { IterableReadableStream, IterableReadableStreamInterface } from '@langchain/core/utils/stream';
6
- import { Groq } from 'groq-sdk';
7
-
8
- /**
9
- * Copilot Runtime adapter for OpenAI.
10
- *
11
- * ## Example
12
- *
13
- * ```ts
14
- * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
15
- * import OpenAI from "openai";
16
- *
17
- * const copilotKit = new CopilotRuntime();
18
- *
19
- * const openai = new OpenAI({
20
- * organization: "<your-organization-id>", // optional
21
- * apiKey: "<your-api-key>",
22
- * });
23
- *
24
- * return new OpenAIAdapter({ openai });
25
- * ```
26
- *
27
- * ## Example with Azure OpenAI
28
- *
29
- * ```ts
30
- * import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/runtime";
31
- * import OpenAI from "openai";
32
- *
33
- * // The name of your Azure OpenAI Instance.
34
- * // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
35
- * const instance = "<your instance name>";
36
- *
37
- * // Corresponds to your Model deployment within your OpenAI resource, e.g. my-gpt35-16k-deployment
38
- * // Navigate to the Azure OpenAI Studio to deploy a model.
39
- * const model = "<your model>";
40
- *
41
- * const apiKey = process.env["AZURE_OPENAI_API_KEY"];
42
- * if (!apiKey) {
43
- * throw new Error("The AZURE_OPENAI_API_KEY environment variable is missing or empty.");
44
- * }
45
- *
46
- * const copilotKit = new CopilotRuntime();
47
- *
48
- * const openai = new OpenAI({
49
- * apiKey,
50
- * baseURL: `https://${instance}.openai.azure.com/openai/deployments/${model}`,
51
- * defaultQuery: { "api-version": "2024-04-01-preview" },
52
- * defaultHeaders: { "api-key": apiKey },
53
- * });
54
- *
55
- * return new OpenAIAdapter({ openai });
56
- * ```
57
- */
58
-
59
- interface OpenAIAdapterParams {
60
- /**
61
- * An optional OpenAI instance to use. If not provided, a new instance will be
62
- * created.
63
- */
64
- openai?: OpenAI;
65
- /**
66
- * The model to use.
67
- */
68
- model?: string;
69
- /**
70
- * Whether to disable parallel tool calls.
71
- * You can disable parallel tool calls to force the model to execute tool calls sequentially.
72
- * This is useful if you want to execute tool calls in a specific order so that the state changes
73
- * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
74
- *
75
- * @default false
76
- */
77
- disableParallelToolCalls?: boolean;
78
- /**
79
- * Whether to keep the role in system messages as "System".
80
- * By default, it is converted to "developer", which is used by newer OpenAI models
81
- *
82
- * @default false
83
- */
84
- keepSystemRole?: boolean;
85
- }
86
- declare class OpenAIAdapter implements CopilotServiceAdapter {
87
- private model;
88
- private disableParallelToolCalls;
89
- private _openai;
90
- private keepSystemRole;
91
- get openai(): OpenAI;
92
- constructor(params?: OpenAIAdapterParams);
93
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
94
- }
95
-
96
- type LangChainBaseMessageChunkStream = IterableReadableStream<BaseMessageChunk>;
97
- type LangChainAIMessageChunkStream = IterableReadableStreamInterface<AIMessageChunk>;
98
- type LangChainReturnType = LangChainBaseMessageChunkStream | LangChainAIMessageChunkStream | BaseMessageChunk | string | AIMessage;
99
-
100
- /**
101
- * Copilot Runtime adapter for LangChain.
102
- *
103
- * ## Example
104
- *
105
- * ```ts
106
- * import { CopilotRuntime, LangChainAdapter } from "@copilotkit/runtime";
107
- * import { ChatOpenAI } from "@langchain/openai";
108
- *
109
- * const copilotKit = new CopilotRuntime();
110
- *
111
- * const model = new ChatOpenAI({
112
- * model: "gpt-4o",
113
- * apiKey: "<your-api-key>",
114
- * });
115
- *
116
- * return new LangChainAdapter({
117
- * chainFn: async ({ messages, tools }) => {
118
- * return model.bindTools(tools).stream(messages);
119
- * // or optionally enable strict mode
120
- * // return model.bindTools(tools, { strict: true }).stream(messages);
121
- * }
122
- * });
123
- * ```
124
- *
125
- * The asynchronous handler function (`chainFn`) can return any of the following:
126
- *
127
- * - A simple `string` response
128
- * - A LangChain stream (`IterableReadableStream`)
129
- * - A LangChain `BaseMessageChunk` object
130
- * - A LangChain `AIMessage` object
131
- */
132
-
133
- interface ChainFnParameters {
134
- model: string;
135
- messages: BaseMessage[];
136
- tools: DynamicStructuredTool[];
137
- threadId?: string;
138
- runId?: string;
139
- }
140
- interface LangChainAdapterOptions {
141
- /**
142
- * A function that uses the LangChain API to generate a response.
143
- */
144
- chainFn: (parameters: ChainFnParameters) => Promise<LangChainReturnType>;
145
- }
146
- declare class LangChainAdapter implements CopilotServiceAdapter {
147
- private options;
148
- /**
149
- * To use LangChain as a backend, provide a handler function to the adapter with your custom LangChain logic.
150
- */
151
- constructor(options: LangChainAdapterOptions);
152
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
153
- }
154
-
155
- interface GoogleGenerativeAIAdapterOptions {
156
- /**
157
- * A custom Google Generative AI model to use.
158
- */
159
- model?: string;
160
- /**
161
- * The API key to use.
162
- */
163
- apiKey?: string;
164
- }
165
- declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
166
- constructor(options?: GoogleGenerativeAIAdapterOptions);
167
- }
168
-
169
- /**
170
- * Copilot Runtime adapter for the OpenAI Assistant API.
171
- *
172
- * ## Example
173
- *
174
- * ```ts
175
- * import { CopilotRuntime, OpenAIAssistantAdapter } from "@copilotkit/runtime";
176
- * import OpenAI from "openai";
177
- *
178
- * const copilotKit = new CopilotRuntime();
179
- *
180
- * const openai = new OpenAI({
181
- * organization: "<your-organization-id>",
182
- * apiKey: "<your-api-key>",
183
- * });
184
- *
185
- * return new OpenAIAssistantAdapter({
186
- * openai,
187
- * assistantId: "<your-assistant-id>",
188
- * codeInterpreterEnabled: true,
189
- * fileSearchEnabled: true,
190
- * });
191
- * ```
192
- */
193
-
194
- interface OpenAIAssistantAdapterParams {
195
- /**
196
- * The ID of the assistant to use.
197
- */
198
- assistantId: string;
199
- /**
200
- * An optional OpenAI instance to use. If not provided, a new instance will be created.
201
- */
202
- openai?: OpenAI;
203
- /**
204
- * Whether to enable code interpretation.
205
- * @default true
206
- */
207
- codeInterpreterEnabled?: boolean;
208
- /**
209
- * Whether to enable file search.
210
- * @default true
211
- */
212
- fileSearchEnabled?: boolean;
213
- /**
214
- * Whether to disable parallel tool calls.
215
- * You can disable parallel tool calls to force the model to execute tool calls sequentially.
216
- * This is useful if you want to execute tool calls in a specific order so that the state changes
217
- * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
218
- *
219
- * @default false
220
- */
221
- disableParallelToolCalls?: boolean;
222
- /**
223
- * Whether to keep the role in system messages as "System".
224
- * By default, it is converted to "developer", which is used by newer OpenAI models
225
- *
226
- * @default false
227
- */
228
- keepSystemRole?: boolean;
229
- }
230
- declare class OpenAIAssistantAdapter implements CopilotServiceAdapter {
231
- private openai;
232
- private codeInterpreterEnabled;
233
- private assistantId;
234
- private fileSearchEnabled;
235
- private disableParallelToolCalls;
236
- private keepSystemRole;
237
- constructor(params: OpenAIAssistantAdapterParams);
238
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
239
- private submitToolOutputs;
240
- private submitUserMessage;
241
- private streamResponse;
242
- }
243
-
244
- /**
245
- * CopilotKit Adapter for Unify
246
- *
247
- * <RequestExample>
248
- * ```jsx CopilotRuntime Example
249
- * const copilotKit = new CopilotRuntime();
250
- * return copilotKit.response(req, new UnifyAdapter());
251
- * ```
252
- * </RequestExample>
253
- *
254
- * You can easily set the model to use by passing it to the constructor.
255
- * ```jsx
256
- * const copilotKit = new CopilotRuntime();
257
- * return copilotKit.response(
258
- * req,
259
- * new UnifyAdapter({ model: "llama-3-8b-chat@fireworks-ai" }),
260
- * );
261
- * ```
262
- */
263
-
264
- interface UnifyAdapterParams {
265
- apiKey?: string;
266
- model: string;
267
- }
268
- declare class UnifyAdapter implements CopilotServiceAdapter {
269
- private apiKey;
270
- private model;
271
- private start;
272
- constructor(options?: UnifyAdapterParams);
273
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
274
- }
275
-
276
- /**
277
- * Copilot Runtime adapter for Groq.
278
- *
279
- * ## Example
280
- *
281
- * ```ts
282
- * import { CopilotRuntime, GroqAdapter } from "@copilotkit/runtime";
283
- * import { Groq } from "groq-sdk";
284
- *
285
- * const groq = new Groq({ apiKey: process.env["GROQ_API_KEY"] });
286
- *
287
- * const copilotKit = new CopilotRuntime();
288
- *
289
- * return new GroqAdapter({ groq, model: "<model-name>" });
290
- * ```
291
- */
292
-
293
- interface GroqAdapterParams {
294
- /**
295
- * An optional Groq instance to use.
296
- */
297
- groq?: Groq;
298
- /**
299
- * The model to use.
300
- */
301
- model?: string;
302
- /**
303
- * Whether to disable parallel tool calls.
304
- * You can disable parallel tool calls to force the model to execute tool calls sequentially.
305
- * This is useful if you want to execute tool calls in a specific order so that the state changes
306
- * introduced by one tool call are visible to the next tool call. (i.e. new actions or readables)
307
- *
308
- * @default false
309
- */
310
- disableParallelToolCalls?: boolean;
311
- }
312
- declare class GroqAdapter implements CopilotServiceAdapter {
313
- private model;
314
- private disableParallelToolCalls;
315
- private _groq;
316
- get groq(): Groq;
317
- constructor(params?: GroqAdapterParams);
318
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
319
- }
320
-
321
- export { GoogleGenerativeAIAdapter as G, LangChainAdapter as L, OpenAIAdapterParams as O, UnifyAdapterParams as U, OpenAIAdapter as a, OpenAIAssistantAdapterParams as b, OpenAIAssistantAdapter as c, UnifyAdapter as d, GroqAdapterParams as e, GroqAdapter as f };