@copilotkit/runtime 1.50.0-beta.8 → 1.50.0-beta.9
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 +11 -0
- package/dist/chunk-2OZAGFV3.mjs +43 -0
- package/dist/chunk-2OZAGFV3.mjs.map +1 -0
- package/dist/chunk-62NE5S6M.mjs +226 -0
- package/dist/chunk-62NE5S6M.mjs.map +1 -0
- package/dist/chunk-6XRUR5UK.mjs +1 -0
- package/dist/chunk-6XRUR5UK.mjs.map +1 -0
- package/dist/chunk-AMUJQ6IR.mjs +50 -0
- package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
- package/dist/chunk-BJEYMRDD.mjs +25 -0
- package/dist/chunk-BJEYMRDD.mjs.map +1 -0
- package/dist/chunk-DZV4ZIAR.mjs +3063 -0
- package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
- package/dist/chunk-FHD4JECV.mjs +33 -0
- package/dist/chunk-FHD4JECV.mjs.map +1 -0
- package/dist/chunk-FMU55SEU.mjs +25 -0
- package/dist/chunk-FMU55SEU.mjs.map +1 -0
- package/dist/chunk-OWIGJONH.mjs +275 -0
- package/dist/chunk-OWIGJONH.mjs.map +1 -0
- package/dist/chunk-SBCOROE4.mjs +1112 -0
- package/dist/chunk-SBCOROE4.mjs.map +1 -0
- package/dist/chunk-TTUAEJLD.mjs +617 -0
- package/dist/chunk-TTUAEJLD.mjs.map +1 -0
- package/dist/chunk-XWBDEXDA.mjs +153 -0
- package/dist/chunk-XWBDEXDA.mjs.map +1 -0
- package/dist/chunk-Z752VE75.mjs +74 -0
- package/dist/chunk-Z752VE75.mjs.map +1 -0
- package/dist/graphql/message-conversion/index.d.ts +18 -0
- package/dist/graphql/message-conversion/index.js +725 -0
- package/dist/graphql/message-conversion/index.js.map +1 -0
- package/dist/graphql/message-conversion/index.mjs +245 -0
- package/dist/graphql/message-conversion/index.mjs.map +1 -0
- package/dist/graphql/types/base/index.d.ts +6 -0
- package/dist/graphql/types/base/index.js +63 -0
- package/dist/graphql/types/base/index.js.map +1 -0
- package/dist/graphql/types/base/index.mjs +8 -0
- package/dist/graphql/types/base/index.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +2 -0
- package/dist/graphql/types/converted/index.js +294 -0
- package/dist/graphql/types/converted/index.js.map +1 -0
- package/dist/graphql/types/converted/index.mjs +20 -0
- package/dist/graphql/types/converted/index.mjs.map +1 -0
- package/dist/groq-adapter-50bc6e4a.d.ts +326 -0
- package/dist/index-adbd78f1.d.ts +154 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/langserve-74a52292.d.ts +242 -0
- package/dist/lib/cloud/index.d.ts +6 -0
- package/dist/lib/cloud/index.js +18 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/index.mjs +1 -0
- package/dist/lib/cloud/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +266 -0
- package/dist/lib/index.js +4944 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +74 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/integrations/index.d.ts +28 -0
- package/dist/lib/integrations/index.js +3024 -0
- package/dist/lib/integrations/index.js.map +1 -0
- package/dist/lib/integrations/index.mjs +36 -0
- package/dist/lib/integrations/index.mjs.map +1 -0
- package/dist/lib/integrations/nest/index.d.ts +16 -0
- package/dist/lib/integrations/nest/index.js +2937 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +13 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +16 -0
- package/dist/lib/integrations/node-express/index.js +2937 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +13 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +16 -0
- package/dist/lib/integrations/node-http/index.js +2923 -0
- package/dist/lib/integrations/node-http/index.js.map +1 -0
- package/dist/lib/integrations/node-http/index.mjs +12 -0
- package/dist/lib/integrations/node-http/index.mjs.map +1 -0
- package/dist/service-adapters/index.d.ts +166 -0
- package/dist/service-adapters/index.js +1800 -0
- package/dist/service-adapters/index.js.map +1 -0
- package/dist/service-adapters/index.mjs +36 -0
- package/dist/service-adapters/index.mjs.map +1 -0
- package/dist/service-adapters/shared/index.d.ts +9 -0
- package/dist/service-adapters/shared/index.js +72 -0
- package/dist/service-adapters/shared/index.js.map +1 -0
- package/dist/service-adapters/shared/index.mjs +8 -0
- package/dist/service-adapters/shared/index.mjs.map +1 -0
- package/dist/shared-f6d43ef8.d.ts +446 -0
- package/dist/utils/index.d.ts +65 -0
- package/dist/utils/index.js +175 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-FHD4JECV.mjs";
|
|
4
|
+
|
|
5
|
+
// src/graphql/types/base/index.ts
|
|
6
|
+
import { Field, InputType } from "type-graphql";
|
|
7
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
10
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
else
|
|
12
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
13
|
+
if (d = decorators[i])
|
|
14
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
}
|
|
17
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
18
|
+
function _ts_metadata(k, v) {
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
20
|
+
return Reflect.metadata(k, v);
|
|
21
|
+
}
|
|
22
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
23
|
+
var BaseMessageInput = class {
|
|
24
|
+
id;
|
|
25
|
+
createdAt;
|
|
26
|
+
};
|
|
27
|
+
__name(BaseMessageInput, "BaseMessageInput");
|
|
28
|
+
_ts_decorate([
|
|
29
|
+
Field(() => String),
|
|
30
|
+
_ts_metadata("design:type", String)
|
|
31
|
+
], BaseMessageInput.prototype, "id", void 0);
|
|
32
|
+
_ts_decorate([
|
|
33
|
+
Field(() => Date),
|
|
34
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
35
|
+
], BaseMessageInput.prototype, "createdAt", void 0);
|
|
36
|
+
BaseMessageInput = _ts_decorate([
|
|
37
|
+
InputType()
|
|
38
|
+
], BaseMessageInput);
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
BaseMessageInput
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=chunk-2OZAGFV3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,SAASA,OAAOC,iBAAiB;;;;;;;;;;;;;;;;;AAG1B,IAAMC,mBAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;EACVG,MAAM,MAAMC,MAAAA;;GADFJ,iBAAAA,WAAAA,MAAAA,MAAAA;;EAIVG,MAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,iBAAAA,WAAAA,aAAAA,MAAAA;AAAAA,mBAAAA,aAAAA;EADZM,UAAAA;GACYN,gBAAAA;","names":["Field","InputType","BaseMessageInput","id","createdAt","Field","String","Date","InputType"]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionExecutionMessage,
|
|
3
|
+
AgentStateMessage,
|
|
4
|
+
ImageMessage,
|
|
5
|
+
ResultMessage,
|
|
6
|
+
Role,
|
|
7
|
+
TextMessage
|
|
8
|
+
} from "./chunk-OWIGJONH.mjs";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-FHD4JECV.mjs";
|
|
12
|
+
|
|
13
|
+
// src/graphql/message-conversion/agui-to-gql.ts
|
|
14
|
+
function extractAgentName(message) {
|
|
15
|
+
if (message.role !== "assistant") {
|
|
16
|
+
throw new Error(`Cannot extract agent name from message with role ${message.role}`);
|
|
17
|
+
}
|
|
18
|
+
return message.agentName || "unknown";
|
|
19
|
+
}
|
|
20
|
+
__name(extractAgentName, "extractAgentName");
|
|
21
|
+
function isAgentStateMessage(message) {
|
|
22
|
+
return message.role === "assistant" && "agentName" in message && "state" in message;
|
|
23
|
+
}
|
|
24
|
+
__name(isAgentStateMessage, "isAgentStateMessage");
|
|
25
|
+
function hasImageProperty(message) {
|
|
26
|
+
const canContainImage = message.role === "assistant" || message.role === "user";
|
|
27
|
+
if (!canContainImage || message.image === void 0) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const isMalformed = message.image.format === void 0 || message.image.bytes === void 0;
|
|
31
|
+
if (isMalformed) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
__name(hasImageProperty, "hasImageProperty");
|
|
37
|
+
function aguiToGQL(messages, actions, coAgentStateRenders) {
|
|
38
|
+
const gqlMessages = [];
|
|
39
|
+
messages = Array.isArray(messages) ? messages : [
|
|
40
|
+
messages
|
|
41
|
+
];
|
|
42
|
+
const toolCallNames = {};
|
|
43
|
+
for (const message of messages) {
|
|
44
|
+
if (isAgentStateMessage(message)) {
|
|
45
|
+
const agentName = extractAgentName(message);
|
|
46
|
+
const state = "state" in message && message.state ? message.state : {};
|
|
47
|
+
gqlMessages.push(new AgentStateMessage({
|
|
48
|
+
id: message.id,
|
|
49
|
+
agentName,
|
|
50
|
+
state,
|
|
51
|
+
role: Role.assistant
|
|
52
|
+
}));
|
|
53
|
+
if ("generativeUI" in message && message.generativeUI && coAgentStateRenders) {
|
|
54
|
+
coAgentStateRenders[agentName] = {
|
|
55
|
+
name: agentName,
|
|
56
|
+
render: message.generativeUI
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (hasImageProperty(message)) {
|
|
62
|
+
gqlMessages.push(aguiMessageWithImageToGQLMessage(message));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (message.role === "assistant" && message.toolCalls) {
|
|
66
|
+
gqlMessages.push(aguiTextMessageToGQLMessage(message));
|
|
67
|
+
for (const toolCall of message.toolCalls) {
|
|
68
|
+
toolCallNames[toolCall.id] = toolCall.function.name;
|
|
69
|
+
const actionExecMsg = aguiToolCallToGQLActionExecution(toolCall, message.id);
|
|
70
|
+
if ("generativeUI" in message && message.generativeUI && actions) {
|
|
71
|
+
const actionName = toolCall.function.name;
|
|
72
|
+
const specificAction = Object.values(actions).find((action) => action.name === actionName);
|
|
73
|
+
const wildcardAction = Object.values(actions).find((action) => action.name === "*");
|
|
74
|
+
if (specificAction) {
|
|
75
|
+
specificAction.render = message.generativeUI;
|
|
76
|
+
} else if (wildcardAction) {
|
|
77
|
+
wildcardAction.render = message.generativeUI;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
gqlMessages.push(actionExecMsg);
|
|
81
|
+
}
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (message.role === "developer" || message.role === "system" || message.role === "assistant" || message.role === "user") {
|
|
85
|
+
gqlMessages.push(aguiTextMessageToGQLMessage(message));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (message.role === "tool") {
|
|
89
|
+
gqlMessages.push(aguiToolMessageToGQLResultMessage(message, toolCallNames));
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Unknown message role: "${message.role}" in message with id: ${message.id}`);
|
|
93
|
+
}
|
|
94
|
+
return gqlMessages;
|
|
95
|
+
}
|
|
96
|
+
__name(aguiToGQL, "aguiToGQL");
|
|
97
|
+
function aguiTextMessageToGQLMessage(message) {
|
|
98
|
+
if (message.role !== "developer" && message.role !== "system" && message.role !== "assistant" && message.role !== "user") {
|
|
99
|
+
throw new Error(`Cannot convert message with role ${message.role} to TextMessage`);
|
|
100
|
+
}
|
|
101
|
+
let roleValue;
|
|
102
|
+
if (message.role === "developer") {
|
|
103
|
+
roleValue = Role.developer;
|
|
104
|
+
} else if (message.role === "system") {
|
|
105
|
+
roleValue = Role.system;
|
|
106
|
+
} else if (message.role === "assistant") {
|
|
107
|
+
roleValue = Role.assistant;
|
|
108
|
+
} else {
|
|
109
|
+
roleValue = Role.user;
|
|
110
|
+
}
|
|
111
|
+
return new TextMessage({
|
|
112
|
+
id: message.id,
|
|
113
|
+
content: message.content || "",
|
|
114
|
+
role: roleValue
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
__name(aguiTextMessageToGQLMessage, "aguiTextMessageToGQLMessage");
|
|
118
|
+
function aguiToolCallToGQLActionExecution(toolCall, parentMessageId) {
|
|
119
|
+
if (toolCall.type !== "function") {
|
|
120
|
+
throw new Error(`Unsupported tool call type: ${toolCall.type}`);
|
|
121
|
+
}
|
|
122
|
+
let argumentsObj;
|
|
123
|
+
if (typeof toolCall.function.arguments === "string") {
|
|
124
|
+
try {
|
|
125
|
+
argumentsObj = JSON.parse(toolCall.function.arguments);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);
|
|
128
|
+
argumentsObj = {};
|
|
129
|
+
}
|
|
130
|
+
} else if (typeof toolCall.function.arguments === "object" && toolCall.function.arguments !== null) {
|
|
131
|
+
argumentsObj = toolCall.function.arguments;
|
|
132
|
+
} else {
|
|
133
|
+
console.warn(`Invalid tool call arguments type for ${toolCall.function.name}:`, typeof toolCall.function.arguments);
|
|
134
|
+
argumentsObj = {};
|
|
135
|
+
}
|
|
136
|
+
return new ActionExecutionMessage({
|
|
137
|
+
id: toolCall.id,
|
|
138
|
+
name: toolCall.function.name,
|
|
139
|
+
arguments: argumentsObj,
|
|
140
|
+
parentMessageId
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
__name(aguiToolCallToGQLActionExecution, "aguiToolCallToGQLActionExecution");
|
|
144
|
+
function aguiToolMessageToGQLResultMessage(message, toolCallNames) {
|
|
145
|
+
if (message.role !== "tool") {
|
|
146
|
+
throw new Error(`Cannot convert message with role ${message.role} to ResultMessage`);
|
|
147
|
+
}
|
|
148
|
+
if (!message.toolCallId) {
|
|
149
|
+
throw new Error("Tool message must have a toolCallId");
|
|
150
|
+
}
|
|
151
|
+
const actionName = toolCallNames[message.toolCallId] || "unknown";
|
|
152
|
+
let resultContent;
|
|
153
|
+
const messageContent = message.content || "";
|
|
154
|
+
if (typeof messageContent === "string") {
|
|
155
|
+
resultContent = messageContent;
|
|
156
|
+
} else if (typeof messageContent === "object" && messageContent !== null) {
|
|
157
|
+
try {
|
|
158
|
+
resultContent = JSON.stringify(messageContent);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.warn(`Failed to stringify tool result for ${actionName}:`, error);
|
|
161
|
+
resultContent = String(messageContent);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
resultContent = String(messageContent);
|
|
165
|
+
}
|
|
166
|
+
return new ResultMessage({
|
|
167
|
+
id: message.id,
|
|
168
|
+
result: resultContent,
|
|
169
|
+
actionExecutionId: message.toolCallId,
|
|
170
|
+
actionName: message.toolName || actionName
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
__name(aguiToolMessageToGQLResultMessage, "aguiToolMessageToGQLResultMessage");
|
|
174
|
+
function aguiMessageWithRenderToGQL(message, actions, coAgentStateRenders) {
|
|
175
|
+
if (message.role === "assistant" && "generativeUI" in message && message.generativeUI && !message.toolCalls) {
|
|
176
|
+
const gqlMessages = [];
|
|
177
|
+
gqlMessages.push(new AgentStateMessage({
|
|
178
|
+
id: message.id,
|
|
179
|
+
agentName: "unknown",
|
|
180
|
+
state: {},
|
|
181
|
+
role: Role.assistant
|
|
182
|
+
}));
|
|
183
|
+
if (coAgentStateRenders) {
|
|
184
|
+
coAgentStateRenders.unknown = {
|
|
185
|
+
name: "unknown",
|
|
186
|
+
render: message.generativeUI
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return gqlMessages;
|
|
190
|
+
}
|
|
191
|
+
return aguiToGQL([
|
|
192
|
+
message
|
|
193
|
+
], actions, coAgentStateRenders);
|
|
194
|
+
}
|
|
195
|
+
__name(aguiMessageWithRenderToGQL, "aguiMessageWithRenderToGQL");
|
|
196
|
+
function aguiMessageWithImageToGQLMessage(message) {
|
|
197
|
+
if (!hasImageProperty(message)) {
|
|
198
|
+
throw new Error(`Cannot convert message to ImageMessage: missing format or bytes`);
|
|
199
|
+
}
|
|
200
|
+
let roleValue;
|
|
201
|
+
if (message.role === "assistant") {
|
|
202
|
+
roleValue = Role.assistant;
|
|
203
|
+
} else {
|
|
204
|
+
roleValue = Role.user;
|
|
205
|
+
}
|
|
206
|
+
if (message.role !== "assistant" && message.role !== "user") {
|
|
207
|
+
throw new Error(`Cannot convert message with role ${message.role} to ImageMessage`);
|
|
208
|
+
}
|
|
209
|
+
return new ImageMessage({
|
|
210
|
+
id: message.id,
|
|
211
|
+
format: message.image.format,
|
|
212
|
+
bytes: message.image.bytes,
|
|
213
|
+
role: roleValue
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
__name(aguiMessageWithImageToGQLMessage, "aguiMessageWithImageToGQLMessage");
|
|
217
|
+
|
|
218
|
+
export {
|
|
219
|
+
aguiToGQL,
|
|
220
|
+
aguiTextMessageToGQLMessage,
|
|
221
|
+
aguiToolCallToGQLActionExecution,
|
|
222
|
+
aguiToolMessageToGQLResultMessage,
|
|
223
|
+
aguiMessageWithRenderToGQL,
|
|
224
|
+
aguiMessageWithImageToGQLMessage
|
|
225
|
+
};
|
|
226
|
+
//# sourceMappingURL=chunk-62NE5S6M.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graphql/message-conversion/agui-to-gql.ts"],"sourcesContent":["import * as gql from \"../types/converted/index\";\nimport { MessageRole } from \"../types/enums\";\nimport agui from \"@copilotkit/shared\"; // named agui for clarity, but this only includes agui message types\n\n// Helper function to extract agent name from message\nfunction extractAgentName(message: agui.Message): string {\n if (message.role !== \"assistant\") {\n throw new Error(`Cannot extract agent name from message with role ${message.role}`);\n }\n\n return message.agentName || \"unknown\";\n}\n\n// Type guard for agent state message\nfunction isAgentStateMessage(message: agui.Message): boolean {\n return message.role === \"assistant\" && \"agentName\" in message && \"state\" in message;\n}\n\n// Type guard for messages with image property\nfunction hasImageProperty(message: agui.Message): boolean {\n const canContainImage = message.role === \"assistant\" || message.role === \"user\";\n if (!canContainImage || message.image === undefined) {\n return false;\n }\n\n const isMalformed = message.image.format === undefined || message.image.bytes === undefined;\n if (isMalformed) {\n return false;\n }\n\n return true;\n}\n\n/*\n ----------------------------\n AGUI Message -> GQL Message\n ----------------------------\n*/\nexport function aguiToGQL(\n messages: agui.Message[] | agui.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): gql.Message[] {\n const gqlMessages: gql.Message[] = [];\n messages = Array.isArray(messages) ? messages : [messages];\n\n // Track tool call names by their IDs for use in result messages\n const toolCallNames: Record<string, string> = {};\n\n for (const message of messages) {\n // Agent state message support\n if (isAgentStateMessage(message)) {\n const agentName = extractAgentName(message);\n const state = \"state\" in message && message.state ? message.state : {};\n gqlMessages.push(\n new gql.AgentStateMessage({\n id: message.id,\n agentName,\n state,\n role: gql.Role.assistant,\n }),\n );\n // Optionally preserve render function\n if (\"generativeUI\" in message && message.generativeUI && coAgentStateRenders) {\n coAgentStateRenders[agentName] = {\n name: agentName,\n render: message.generativeUI,\n };\n }\n continue;\n }\n\n if (hasImageProperty(message)) {\n gqlMessages.push(aguiMessageWithImageToGQLMessage(message));\n continue;\n }\n\n // Action execution message support\n if (message.role === \"assistant\" && message.toolCalls) {\n gqlMessages.push(aguiTextMessageToGQLMessage(message));\n for (const toolCall of message.toolCalls) {\n // Track the tool call name by its ID\n toolCallNames[toolCall.id] = toolCall.function.name;\n\n const actionExecMsg = aguiToolCallToGQLActionExecution(toolCall, message.id);\n // Preserve render function in actions context\n if (\"generativeUI\" in message && message.generativeUI && actions) {\n const actionName = toolCall.function.name;\n // Check for specific action first, then wild card action\n const specificAction = Object.values(actions).find(\n (action: any) => action.name === actionName,\n );\n const wildcardAction = Object.values(actions).find((action: any) => action.name === \"*\");\n\n // Assign render function to the matching action (specific takes priority)\n if (specificAction) {\n specificAction.render = message.generativeUI;\n } else if (wildcardAction) {\n wildcardAction.render = message.generativeUI;\n }\n }\n gqlMessages.push(actionExecMsg);\n }\n continue;\n }\n // Regular text messages\n if (\n message.role === \"developer\" ||\n message.role === \"system\" ||\n message.role === \"assistant\" ||\n message.role === \"user\"\n ) {\n gqlMessages.push(aguiTextMessageToGQLMessage(message));\n continue;\n }\n // Tool result message\n if (message.role === \"tool\") {\n gqlMessages.push(aguiToolMessageToGQLResultMessage(message, toolCallNames));\n continue;\n }\n throw new Error(\n `Unknown message role: \"${(message as any).role}\" in message with id: ${(message as any).id}`,\n );\n }\n\n return gqlMessages;\n}\n\nexport function aguiTextMessageToGQLMessage(message: agui.Message): gql.TextMessage {\n if (\n message.role !== \"developer\" &&\n message.role !== \"system\" &&\n message.role !== \"assistant\" &&\n message.role !== \"user\"\n ) {\n throw new Error(`Cannot convert message with role ${message.role} to TextMessage`);\n }\n\n let roleValue: MessageRole;\n\n if (message.role === \"developer\") {\n roleValue = gql.Role.developer;\n } else if (message.role === \"system\") {\n roleValue = gql.Role.system;\n } else if (message.role === \"assistant\") {\n roleValue = gql.Role.assistant;\n } else {\n roleValue = gql.Role.user;\n }\n\n return new gql.TextMessage({\n id: message.id,\n content: message.content || \"\",\n role: roleValue,\n });\n}\n\nexport function aguiToolCallToGQLActionExecution(\n toolCall: agui.ToolCall,\n parentMessageId: string,\n): gql.ActionExecutionMessage {\n if (toolCall.type !== \"function\") {\n throw new Error(`Unsupported tool call type: ${toolCall.type}`);\n }\n\n // Handle arguments - they should be a JSON string in AGUI format,\n // but we need to convert them to an object for GQL format\n let argumentsObj: any;\n\n if (typeof toolCall.function.arguments === \"string\") {\n // Expected case: arguments is a JSON string\n try {\n argumentsObj = JSON.parse(toolCall.function.arguments);\n } catch (error) {\n console.warn(`Failed to parse tool call arguments for ${toolCall.function.name}:`, error);\n // Provide fallback empty object to prevent application crash\n argumentsObj = {};\n }\n } else if (\n typeof toolCall.function.arguments === \"object\" &&\n toolCall.function.arguments !== null\n ) {\n // Backward compatibility: arguments is already an object\n argumentsObj = toolCall.function.arguments;\n } else {\n // Fallback for undefined, null, or other types\n console.warn(\n `Invalid tool call arguments type for ${toolCall.function.name}:`,\n typeof toolCall.function.arguments,\n );\n argumentsObj = {};\n }\n\n // Always include name and arguments\n return new gql.ActionExecutionMessage({\n id: toolCall.id,\n name: toolCall.function.name,\n arguments: argumentsObj,\n parentMessageId: parentMessageId,\n });\n}\n\nexport function aguiToolMessageToGQLResultMessage(\n message: agui.Message,\n toolCallNames: Record<string, string>,\n): gql.ResultMessage {\n if (message.role !== \"tool\") {\n throw new Error(`Cannot convert message with role ${message.role} to ResultMessage`);\n }\n\n if (!message.toolCallId) {\n throw new Error(\"Tool message must have a toolCallId\");\n }\n\n const actionName = toolCallNames[message.toolCallId] || \"unknown\";\n\n // Handle result content - it could be a string or an object that needs serialization\n let resultContent: string;\n const messageContent = message.content || \"\";\n\n if (typeof messageContent === \"string\") {\n // Expected case: content is already a string\n resultContent = messageContent;\n } else if (typeof messageContent === \"object\" && messageContent !== null) {\n // Handle case where content is an object that needs to be serialized\n try {\n resultContent = JSON.stringify(messageContent);\n } catch (error) {\n console.warn(`Failed to stringify tool result for ${actionName}:`, error);\n resultContent = String(messageContent);\n }\n } else {\n // Handle other types (number, boolean, etc.)\n resultContent = String(messageContent);\n }\n\n return new gql.ResultMessage({\n id: message.id,\n result: resultContent,\n actionExecutionId: message.toolCallId,\n actionName: message.toolName || actionName,\n });\n}\n\n// New function to handle AGUI messages with render functions\nexport function aguiMessageWithRenderToGQL(\n message: agui.Message,\n actions?: Record<string, any>,\n coAgentStateRenders?: Record<string, any>,\n): gql.Message[] {\n // Handle the special case: assistant messages with render function but no tool calls\n if (\n message.role === \"assistant\" &&\n \"generativeUI\" in message &&\n message.generativeUI &&\n !message.toolCalls\n ) {\n const gqlMessages: gql.Message[] = [];\n gqlMessages.push(\n new gql.AgentStateMessage({\n id: message.id,\n agentName: \"unknown\",\n state: {},\n role: gql.Role.assistant,\n }),\n );\n if (coAgentStateRenders) {\n coAgentStateRenders.unknown = {\n name: \"unknown\",\n render: message.generativeUI,\n };\n }\n return gqlMessages;\n }\n\n // For all other cases, delegate to aguiToGQL\n return aguiToGQL([message], actions, coAgentStateRenders);\n}\n\nexport function aguiMessageWithImageToGQLMessage(message: agui.Message): gql.ImageMessage {\n if (!hasImageProperty(message)) {\n throw new Error(`Cannot convert message to ImageMessage: missing format or bytes`);\n }\n\n let roleValue: MessageRole;\n if (message.role === \"assistant\") {\n roleValue = gql.Role.assistant;\n } else {\n roleValue = gql.Role.user;\n }\n\n if (message.role !== \"assistant\" && message.role !== \"user\") {\n throw new Error(`Cannot convert message with role ${message.role} to ImageMessage`);\n }\n\n return new gql.ImageMessage({\n id: message.id,\n format: message.image!.format,\n bytes: message.image!.bytes,\n role: roleValue,\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAASA,iBAAiBC,SAAqB;A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;EACvB,OAAO;AACLmB,gBAAgBpB,KAAKuB;EACvB;AAEA,MAAI/C,QAAQC,SAAS,eAAeD,QAAQC,SAAS,QAAQ;AAC3D,UAAM,IAAIC,MAAM,oCAAoCF,QAAQC,sBAAsB;EACpF;AAEA,SAAO,IAAQsE,aAAa;IAC1BhD,IAAIvB,QAAQuB;IACZb,QAAQV,QAAQO,MAAOG;IACvBC,OAAOX,QAAQO,MAAOI;IACtBV,MAAM2C;EACR,CAAA;AACF;AAtBgBf;","names":["extractAgentName","message","role","Error","agentName","isAgentStateMessage","hasImageProperty","canContainImage","image","undefined","isMalformed","format","bytes","aguiToGQL","messages","actions","coAgentStateRenders","gqlMessages","Array","isArray","toolCallNames","state","push","AgentStateMessage","id","Role","assistant","generativeUI","name","render","aguiMessageWithImageToGQLMessage","toolCalls","aguiTextMessageToGQLMessage","toolCall","function","actionExecMsg","aguiToolCallToGQLActionExecution","actionName","specificAction","Object","values","find","action","wildcardAction","aguiToolMessageToGQLResultMessage","roleValue","developer","system","user","TextMessage","content","parentMessageId","type","argumentsObj","arguments","JSON","parse","error","console","warn","ActionExecutionMessage","toolCallId","resultContent","messageContent","stringify","String","ResultMessage","result","actionExecutionId","toolName","aguiMessageWithRenderToGQL","unknown","ImageMessage"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-6XRUR5UK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-FHD4JECV.mjs";
|
|
4
|
+
|
|
5
|
+
// src/service-adapters/shared/error-utils.ts
|
|
6
|
+
import { CopilotKitLowLevelError, CopilotKitErrorCode } from "@copilotkit/shared";
|
|
7
|
+
function convertServiceAdapterError(error, adapterName) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
const errorName = ((_a = error == null ? void 0 : error.constructor) == null ? void 0 : _a.name) || error.name;
|
|
10
|
+
const errorMessage = (error == null ? void 0 : error.message) || String(error);
|
|
11
|
+
const statusCode = error.status || error.statusCode || ((_b = error.response) == null ? void 0 : _b.status);
|
|
12
|
+
const responseData = error.error || ((_c = error.response) == null ? void 0 : _c.data) || error.data;
|
|
13
|
+
const structuredError = new CopilotKitLowLevelError({
|
|
14
|
+
error: error instanceof Error ? error : new Error(errorMessage),
|
|
15
|
+
url: `${adapterName} service adapter`,
|
|
16
|
+
message: `${adapterName} API error: ${errorMessage}`
|
|
17
|
+
});
|
|
18
|
+
if (statusCode) {
|
|
19
|
+
structuredError.statusCode = statusCode;
|
|
20
|
+
}
|
|
21
|
+
if (responseData) {
|
|
22
|
+
structuredError.responseData = responseData;
|
|
23
|
+
}
|
|
24
|
+
if (errorName) {
|
|
25
|
+
structuredError.originalErrorType = errorName;
|
|
26
|
+
}
|
|
27
|
+
let newCode;
|
|
28
|
+
if (statusCode === 401) {
|
|
29
|
+
newCode = CopilotKitErrorCode.AUTHENTICATION_ERROR;
|
|
30
|
+
} else if (statusCode >= 400 && statusCode < 500) {
|
|
31
|
+
newCode = CopilotKitErrorCode.CONFIGURATION_ERROR;
|
|
32
|
+
} else if (statusCode >= 500) {
|
|
33
|
+
newCode = CopilotKitErrorCode.NETWORK_ERROR;
|
|
34
|
+
} else if (statusCode) {
|
|
35
|
+
newCode = CopilotKitErrorCode.CONFIGURATION_ERROR;
|
|
36
|
+
} else {
|
|
37
|
+
newCode = CopilotKitErrorCode.NETWORK_ERROR;
|
|
38
|
+
}
|
|
39
|
+
structuredError.code = newCode;
|
|
40
|
+
if (structuredError.extensions) {
|
|
41
|
+
structuredError.extensions.code = newCode;
|
|
42
|
+
}
|
|
43
|
+
return structuredError;
|
|
44
|
+
}
|
|
45
|
+
__name(convertServiceAdapterError, "convertServiceAdapterError");
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
convertServiceAdapterError
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-AMUJQ6IR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/service-adapters/shared/error-utils.ts"],"sourcesContent":["import { CopilotKitLowLevelError, CopilotKitErrorCode } from \"@copilotkit/shared\";\n\n/**\n * Converts service adapter errors to structured CopilotKitError format using HTTP status codes.\n * This provides consistent error classification across all service adapters.\n */\nexport function convertServiceAdapterError(\n error: any,\n adapterName: string,\n): CopilotKitLowLevelError {\n const errorName = error?.constructor?.name || error.name;\n const errorMessage = error?.message || String(error);\n const statusCode = error.status || error.statusCode || error.response?.status;\n const responseData = error.error || error.response?.data || error.data;\n\n // Create the base error with the constructor signature\n const structuredError = new CopilotKitLowLevelError({\n error: error instanceof Error ? error : new Error(errorMessage),\n url: `${adapterName} service adapter`,\n message: `${adapterName} API error: ${errorMessage}`,\n });\n\n // Add additional properties after construction\n if (statusCode) {\n (structuredError as any).statusCode = statusCode;\n }\n if (responseData) {\n (structuredError as any).responseData = responseData;\n }\n if (errorName) {\n (structuredError as any).originalErrorType = errorName;\n }\n\n // Classify error based on HTTP status codes (reliable and provider-agnostic)\n let newCode: CopilotKitErrorCode;\n\n if (statusCode === 401) {\n // 401 = Authentication/API key issues\n newCode = CopilotKitErrorCode.AUTHENTICATION_ERROR;\n } else if (statusCode >= 400 && statusCode < 500) {\n // 4xx = Client errors (bad request, invalid params, etc.) - these are configuration issues\n newCode = CopilotKitErrorCode.CONFIGURATION_ERROR;\n } else if (statusCode >= 500) {\n // 5xx = Server errors - keep as NETWORK_ERROR since it's infrastructure related\n newCode = CopilotKitErrorCode.NETWORK_ERROR;\n } else if (statusCode) {\n // Any other HTTP status with an error - likely configuration\n newCode = CopilotKitErrorCode.CONFIGURATION_ERROR;\n } else {\n // No status code - likely a genuine network/connection error\n newCode = CopilotKitErrorCode.NETWORK_ERROR;\n }\n\n // Update both the instance property and the extensions\n (structuredError as any).code = newCode;\n if ((structuredError as any).extensions) {\n (structuredError as any).extensions.code = newCode;\n }\n\n return structuredError;\n}\n"],"mappings":";;;;;AAAA,SAASA,yBAAyBC,2BAA2B;AAMtD,SAASC,2BACdC,OACAC,aAAmB;AARrB;AAUE,QAAMC,cAAYF,oCAAOG,gBAAPH,mBAAoBI,SAAQJ,MAAMI;AACpD,QAAMC,gBAAeL,+BAAOM,YAAWC,OAAOP,KAAAA;AAC9C,QAAMQ,aAAaR,MAAMS,UAAUT,MAAMQ,gBAAcR,WAAMU,aAANV,mBAAgBS;AACvE,QAAME,eAAeX,MAAMA,WAASA,WAAMU,aAANV,mBAAgBY,SAAQZ,MAAMY;AAGlE,QAAMC,kBAAkB,IAAIC,wBAAwB;IAClDd,OAAOA,iBAAiBe,QAAQf,QAAQ,IAAIe,MAAMV,YAAAA;IAClDW,KAAK,GAAGf;IACRK,SAAS,GAAGL,0BAA0BI;EACxC,CAAA;AAGA,MAAIG,YAAY;AACbK,oBAAwBL,aAAaA;EACxC;AACA,MAAIG,cAAc;AACfE,oBAAwBF,eAAeA;EAC1C;AACA,MAAIT,WAAW;AACZW,oBAAwBI,oBAAoBf;EAC/C;AAGA,MAAIgB;AAEJ,MAAIV,eAAe,KAAK;AAEtBU,cAAUC,oBAAoBC;EAChC,WAAWZ,cAAc,OAAOA,aAAa,KAAK;AAEhDU,cAAUC,oBAAoBE;EAChC,WAAWb,cAAc,KAAK;AAE5BU,cAAUC,oBAAoBG;EAChC,WAAWd,YAAY;AAErBU,cAAUC,oBAAoBE;EAChC,OAAO;AAELH,cAAUC,oBAAoBG;EAChC;AAGCT,kBAAwBU,OAAOL;AAChC,MAAKL,gBAAwBW,YAAY;AACtCX,oBAAwBW,WAAWD,OAAOL;EAC7C;AAEA,SAAOL;AACT;AAtDgBd;","names":["CopilotKitLowLevelError","CopilotKitErrorCode","convertServiceAdapterError","error","adapterName","errorName","constructor","name","errorMessage","message","String","statusCode","status","response","responseData","data","structuredError","CopilotKitLowLevelError","Error","url","originalErrorType","newCode","CopilotKitErrorCode","AUTHENTICATION_ERROR","CONFIGURATION_ERROR","NETWORK_ERROR","code","extensions"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
copilotRuntimeNodeHttpEndpoint,
|
|
3
|
+
getRuntimeInstanceTelemetryInfo,
|
|
4
|
+
telemetry_client_default
|
|
5
|
+
} from "./chunk-DZV4ZIAR.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-FHD4JECV.mjs";
|
|
9
|
+
|
|
10
|
+
// src/lib/integrations/node-express/index.ts
|
|
11
|
+
function copilotRuntimeNodeExpressEndpoint(options) {
|
|
12
|
+
telemetry_client_default.setGlobalProperties({
|
|
13
|
+
runtime: {
|
|
14
|
+
framework: "node-express"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
18
|
+
return copilotRuntimeNodeHttpEndpoint(options);
|
|
19
|
+
}
|
|
20
|
+
__name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
copilotRuntimeNodeExpressEndpoint
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-BJEYMRDD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/integrations/node-express/index.ts"],"sourcesContent":["import { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, { getRuntimeInstanceTelemetryInfo } from \"../../telemetry-client\";\nimport { createCopilotEndpoint } from \"@copilotkitnext/runtime\";\n\nexport function copilotRuntimeNodeExpressEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n): ReturnType<typeof createCopilotEndpoint> {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n telemetry.capture(\"oss.runtime.instance_created\", getRuntimeInstanceTelemetryInfo(options));\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;;;;;;AAKO,SAASA,kCACdC,SAA0C;AAE1CC,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEAH,2BAAUI,QAAQ,gCAAgCC,gCAAgCN,OAAAA,CAAAA;AAClF,SAAOO,+BAA+BP,OAAAA;AACxC;AAXgBD;","names":["copilotRuntimeNodeExpressEndpoint","options","telemetry","setGlobalProperties","runtime","framework","capture","getRuntimeInstanceTelemetryInfo","copilotRuntimeNodeHttpEndpoint"]}
|