@copilotkit/runtime 1.9.2-next.8 → 1.9.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.
- package/CHANGELOG.md +177 -0
- package/dist/{chunk-4TLMVLU4.mjs → chunk-56ZNYBXV.mjs} +2 -2
- package/dist/chunk-AMUJQ6IR.mjs +50 -0
- package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
- package/dist/{chunk-5SG4WWXH.mjs → chunk-GB4M7WUE.mjs} +2 -2
- package/dist/{chunk-JWPSIGSA.mjs → chunk-HJYWUUFY.mjs} +2 -2
- package/dist/{chunk-KYCDL2KX.mjs → chunk-M35WOOEP.mjs} +2 -2
- package/dist/{chunk-IIXJVVTV.mjs → chunk-QLLV2QVK.mjs} +132 -78
- package/dist/chunk-QLLV2QVK.mjs.map +1 -0
- package/dist/{chunk-WIXS6EG7.mjs → chunk-TE5QWP4H.mjs} +2401 -2055
- package/dist/chunk-TE5QWP4H.mjs.map +1 -0
- package/dist/{chunk-5BIEM2UU.mjs → chunk-XWBDEXDA.mjs} +4 -3
- package/dist/{chunk-5BIEM2UU.mjs.map → chunk-XWBDEXDA.mjs.map} +1 -1
- package/dist/{groq-adapter-25a2bd35.d.ts → groq-adapter-742818f2.d.ts} +5 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3747 -3303
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{langserve-4a5c9217.d.ts → langserve-3e8d0e06.d.ts} +13 -7
- package/dist/lib/index.d.ts +155 -5
- package/dist/lib/index.js +2808 -2407
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -8
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +151 -96
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +7 -6
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +151 -96
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +5 -4
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +151 -96
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +5 -4
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +151 -96
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +4 -3
- package/dist/service-adapters/index.d.ts +6 -4
- package/dist/service-adapters/index.js +202 -107
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +6 -2
- 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-941d59dc.d.ts → shared-96b46379.d.ts} +23 -21
- package/dist/utils/index.d.ts +17 -1
- package/dist/utils/index.js +3 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +11 -11
- package/src/agents/langgraph/event-source.ts +36 -38
- package/src/agents/langgraph/events.ts +19 -1
- package/src/graphql/resolvers/copilot.resolver.ts +85 -42
- package/src/lib/error-messages.ts +200 -0
- package/src/lib/integrations/shared.ts +43 -0
- package/src/lib/runtime/__tests__/{copilot-runtime-trace.test.ts → copilot-runtime-error.test.ts} +27 -27
- package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +464 -0
- package/src/lib/runtime/agui-action.ts +9 -3
- package/src/lib/runtime/copilot-runtime.ts +156 -160
- package/src/lib/runtime/mcp-tools-utils.ts +84 -18
- package/src/lib/runtime/remote-action-constructors.ts +28 -3
- package/src/lib/runtime/remote-actions.ts +6 -0
- package/src/lib/runtime/remote-lg-action.ts +85 -3
- package/src/lib/streaming.ts +125 -36
- package/src/service-adapters/anthropic/anthropic-adapter.ts +67 -8
- package/src/service-adapters/anthropic/utils.ts +3 -8
- package/src/service-adapters/events.ts +75 -80
- package/src/service-adapters/google/google-genai-adapter.ts +5 -0
- package/src/service-adapters/groq/groq-adapter.ts +66 -56
- package/src/service-adapters/index.ts +1 -0
- package/src/service-adapters/openai/openai-adapter.ts +4 -3
- package/src/service-adapters/shared/error-utils.ts +61 -0
- package/src/service-adapters/shared/index.ts +1 -0
- package/src/utils/failed-response-status-reasons.ts +23 -1
- package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +172 -387
- package/dist/chunk-IIXJVVTV.mjs.map +0 -1
- package/dist/chunk-WIXS6EG7.mjs.map +0 -1
- /package/dist/{chunk-4TLMVLU4.mjs.map → chunk-56ZNYBXV.mjs.map} +0 -0
- /package/dist/{chunk-5SG4WWXH.mjs.map → chunk-GB4M7WUE.mjs.map} +0 -0
- /package/dist/{chunk-JWPSIGSA.mjs.map → chunk-HJYWUUFY.mjs.map} +0 -0
- /package/dist/{chunk-KYCDL2KX.mjs.map → chunk-M35WOOEP.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,182 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
+
## 1.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f3f0181: - fix: connect streaming errors to runtime onError handler
|
|
8
|
+
- remove request logging
|
|
9
|
+
- 3a7f45f: - fix: resolve agui agents only after all other endpoints
|
|
10
|
+
- fac89c2: - refactor: rename onTrace to onError throughout codebase
|
|
11
|
+
|
|
12
|
+
- Rename CopilotTraceEvent to CopilotErrorEvent and CopilotTraceHandler to CopilotErrorHandler
|
|
13
|
+
|
|
14
|
+
- 7ca7023: - feat: send node name to agui agent
|
|
15
|
+
- 54b62f0: - fix: add default schema keys for input and output of agui langgraph
|
|
16
|
+
- 4fd92d1: - fix: enable resolving of langgraph agents when cpk starts
|
|
17
|
+
- 1f4949a: - fix: remove agent discovery for agui agents
|
|
18
|
+
- 9169ad7: - feat: add onTrace handler for runtime and UI error/event tracking
|
|
19
|
+
- f3f0181: - fix: connect streaming errors to runtime onError handler
|
|
20
|
+
- 8e67158: - fixes gemini adapter
|
|
21
|
+
- 83822d2: - fix: do not show error on state loading if thread does not exist
|
|
22
|
+
- fe9009c: - feat(langgraph): new thread metadata
|
|
23
|
+
- f295375: - fix: remove all agents as tools when there is an active agent session
|
|
24
|
+
- fix formatting
|
|
25
|
+
- 9b986ba: - fix: use active interrupt from thread instead of saving to global state
|
|
26
|
+
- 1d1c51d: - feat: surface all errors in structured format
|
|
27
|
+
- dec5527: - fix: only fetch agent state for langgraph agents
|
|
28
|
+
- 9b81464: - fix: use latest langgraph agui
|
|
29
|
+
- 10345a5: - feat: structured error visibility system for streaming errors
|
|
30
|
+
- 8ef8199: - fix: use latest agui dependencies to include required fixes
|
|
31
|
+
- 20e8c3c: - fix(anthropic-adapter): resolve infinite loop caused by duplicate result messages
|
|
32
|
+
- 9169ad7: - feat: add onTrace handler for comprehensive debugging and observability - Add CopilotTraceEvent interfaces with rich debugging context, implement runtime-side tracing with publicApiKey gating, add UI-side error tracing, include comprehensive test coverage, and fix tsup build config to exclude test files
|
|
33
|
+
- fix: extract publicApiKey for all requests + trace GraphQL errors
|
|
34
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
35
|
+
- Ensures consistency in how parameters are passed to the execute function across the codebase.
|
|
36
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
37
|
+
- Fixed generateMcpToolInstructions to properly extract parameters from schema.parameters.properties
|
|
38
|
+
- fix: enhance MCP schema support for complex types and remove duplicate headers
|
|
39
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
40
|
+
- Updated dependencies [fac89c2]
|
|
41
|
+
- Updated dependencies [9169ad7]
|
|
42
|
+
- Updated dependencies [1d1c51d]
|
|
43
|
+
- Updated dependencies [10345a5]
|
|
44
|
+
- Updated dependencies [9169ad7]
|
|
45
|
+
- @copilotkit/shared@1.9.2
|
|
46
|
+
|
|
47
|
+
## 1.9.2-next.26
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- 83822d2: - fix: do not show error on state loading if thread does not exist
|
|
52
|
+
- @copilotkit/shared@1.9.2-next.26
|
|
53
|
+
|
|
54
|
+
## 1.9.2-next.25
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- f3f0181: - fix: connect streaming errors to runtime onError handler
|
|
59
|
+
- remove request logging
|
|
60
|
+
- f3f0181: - fix: connect streaming errors to runtime onError handler
|
|
61
|
+
- @copilotkit/shared@1.9.2-next.25
|
|
62
|
+
|
|
63
|
+
## 1.9.2-next.24
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 8ef8199: - fix: use latest agui dependencies to include required fixes
|
|
68
|
+
- @copilotkit/shared@1.9.2-next.24
|
|
69
|
+
|
|
70
|
+
## 1.9.2-next.23
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
75
|
+
- Ensures consistency in how parameters are passed to the execute function across the codebase.
|
|
76
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
77
|
+
- Fixed generateMcpToolInstructions to properly extract parameters from schema.parameters.properties
|
|
78
|
+
- fix: enhance MCP schema support for complex types and remove duplicate headers
|
|
79
|
+
- fc6b653: - Fix extract toolParameters in extractParametersFromSchema
|
|
80
|
+
- @copilotkit/shared@1.9.2-next.23
|
|
81
|
+
|
|
82
|
+
## 1.9.2-next.22
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- @copilotkit/shared@1.9.2-next.22
|
|
87
|
+
|
|
88
|
+
## 1.9.2-next.21
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- @copilotkit/shared@1.9.2-next.21
|
|
93
|
+
|
|
94
|
+
## 1.9.2-next.20
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- @copilotkit/shared@1.9.2-next.20
|
|
99
|
+
|
|
100
|
+
## 1.9.2-next.19
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- 8e67158: - fixes gemini adapter
|
|
105
|
+
- @copilotkit/shared@1.9.2-next.19
|
|
106
|
+
|
|
107
|
+
## 1.9.2-next.18
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- fac89c2: - refactor: rename onTrace to onError throughout codebase
|
|
112
|
+
|
|
113
|
+
- Rename CopilotTraceEvent to CopilotErrorEvent and CopilotTraceHandler to CopilotErrorHandler
|
|
114
|
+
|
|
115
|
+
- Updated dependencies [fac89c2]
|
|
116
|
+
- @copilotkit/shared@1.9.2-next.18
|
|
117
|
+
|
|
118
|
+
## 1.9.2-next.17
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- 7ca7023: - feat: send node name to agui agent
|
|
123
|
+
- @copilotkit/shared@1.9.2-next.17
|
|
124
|
+
|
|
125
|
+
## 1.9.2-next.16
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- fe9009c: - feat(langgraph): new thread metadata
|
|
130
|
+
- @copilotkit/shared@1.9.2-next.16
|
|
131
|
+
|
|
132
|
+
## 1.9.2-next.15
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- @copilotkit/shared@1.9.2-next.15
|
|
137
|
+
|
|
138
|
+
## 1.9.2-next.14
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- 3a7f45f: - fix: resolve agui agents only after all other endpoints
|
|
143
|
+
- @copilotkit/shared@1.9.2-next.14
|
|
144
|
+
|
|
145
|
+
## 1.9.2-next.13
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- dec5527: - fix: only fetch agent state for langgraph agents
|
|
150
|
+
- @copilotkit/shared@1.9.2-next.13
|
|
151
|
+
|
|
152
|
+
## 1.9.2-next.12
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- @copilotkit/shared@1.9.2-next.12
|
|
157
|
+
|
|
158
|
+
## 1.9.2-next.11
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- 1f4949a: - fix: remove agent discovery for agui agents
|
|
163
|
+
- @copilotkit/shared@1.9.2-next.11
|
|
164
|
+
|
|
165
|
+
## 1.9.2-next.10
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- 20e8c3c: - fix(anthropic-adapter): resolve infinite loop caused by duplicate result messages
|
|
170
|
+
- @copilotkit/shared@1.9.2-next.10
|
|
171
|
+
|
|
172
|
+
## 1.9.2-next.9
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- 1d1c51d: - feat: surface all errors in structured format
|
|
177
|
+
- Updated dependencies [1d1c51d]
|
|
178
|
+
- @copilotkit/shared@1.9.2-next.9
|
|
179
|
+
|
|
3
180
|
## 1.9.2-next.8
|
|
4
181
|
|
|
5
182
|
### Patch Changes
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TE5QWP4H.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
22
22
|
export {
|
|
23
23
|
copilotRuntimeNestEndpoint
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-56ZNYBXV.mjs.map
|
|
@@ -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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LangGraphEventTypes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TE5QWP4H.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -155,4 +155,4 @@ export {
|
|
|
155
155
|
CustomEventNames,
|
|
156
156
|
LangGraphAgent
|
|
157
157
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
//# sourceMappingURL=chunk-GB4M7WUE.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getCommonConfig,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TE5QWP4H.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
config,
|
|
78
78
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-HJYWUUFY.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TE5QWP4H.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
|
22
22
|
export {
|
|
23
23
|
copilotRuntimeNodeExpressEndpoint
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-M35WOOEP.mjs.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertServiceAdapterError
|
|
3
|
+
} from "./chunk-AMUJQ6IR.mjs";
|
|
1
4
|
import {
|
|
2
5
|
__name
|
|
3
6
|
} from "./chunk-FHD4JECV.mjs";
|
|
@@ -403,14 +406,14 @@ var OpenAIAdapter = class {
|
|
|
403
406
|
});
|
|
404
407
|
}
|
|
405
408
|
} catch (error) {
|
|
406
|
-
console.error("[OpenAI] Error
|
|
407
|
-
throw error;
|
|
409
|
+
console.error("[OpenAI] Error during API call:", error);
|
|
410
|
+
throw convertServiceAdapterError(error, "OpenAI");
|
|
408
411
|
}
|
|
409
412
|
eventStream$.complete();
|
|
410
413
|
});
|
|
411
414
|
} catch (error) {
|
|
412
415
|
console.error("[OpenAI] Error during API call:", error);
|
|
413
|
-
throw error;
|
|
416
|
+
throw convertServiceAdapterError(error, "OpenAI");
|
|
414
417
|
}
|
|
415
418
|
return {
|
|
416
419
|
threadId
|
|
@@ -698,6 +701,7 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
|
698
701
|
return message.content && String(message.content).trim().length > 0 || message.tool_calls && message.tool_calls.length > 0;
|
|
699
702
|
});
|
|
700
703
|
const model = new ChatGoogle({
|
|
704
|
+
apiKey: (options == null ? void 0 : options.apiKey) ?? process.env.GOOGLE_API_KEY,
|
|
701
705
|
modelName: (options == null ? void 0 : options.model) ?? "gemini-1.5-pro",
|
|
702
706
|
apiVersion: "v1beta"
|
|
703
707
|
}).bindTools(tools);
|
|
@@ -1064,85 +1068,94 @@ var GroqAdapter = class {
|
|
|
1064
1068
|
}
|
|
1065
1069
|
};
|
|
1066
1070
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
stream
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1071
|
+
let stream;
|
|
1072
|
+
try {
|
|
1073
|
+
stream = await this.groq.chat.completions.create({
|
|
1074
|
+
model,
|
|
1075
|
+
stream: true,
|
|
1076
|
+
messages: openaiMessages,
|
|
1077
|
+
...tools.length > 0 && {
|
|
1078
|
+
tools
|
|
1079
|
+
},
|
|
1080
|
+
...(forwardedParameters == null ? void 0 : forwardedParameters.maxTokens) && {
|
|
1081
|
+
max_tokens: forwardedParameters.maxTokens
|
|
1082
|
+
},
|
|
1083
|
+
...(forwardedParameters == null ? void 0 : forwardedParameters.stop) && {
|
|
1084
|
+
stop: forwardedParameters.stop
|
|
1085
|
+
},
|
|
1086
|
+
...toolChoice && {
|
|
1087
|
+
tool_choice: toolChoice
|
|
1088
|
+
},
|
|
1089
|
+
...this.disableParallelToolCalls && {
|
|
1090
|
+
parallel_tool_calls: false
|
|
1091
|
+
},
|
|
1092
|
+
...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
|
|
1093
|
+
temperature: forwardedParameters.temperature
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
} catch (error) {
|
|
1097
|
+
throw convertServiceAdapterError(error, "Groq");
|
|
1098
|
+
}
|
|
1090
1099
|
eventSource.stream(async (eventStream$) => {
|
|
1091
1100
|
var _a, _b;
|
|
1092
1101
|
let mode = null;
|
|
1093
1102
|
let currentMessageId;
|
|
1094
1103
|
let currentToolCallId;
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
mode
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
});
|
|
1103
|
-
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1104
|
-
mode = null;
|
|
1105
|
-
eventStream$.sendActionExecutionEnd({
|
|
1106
|
-
actionExecutionId: currentToolCallId
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
if (mode === null) {
|
|
1110
|
-
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1111
|
-
mode = "function";
|
|
1112
|
-
currentToolCallId = toolCall.id;
|
|
1113
|
-
eventStream$.sendActionExecutionStart({
|
|
1114
|
-
actionExecutionId: currentToolCallId,
|
|
1115
|
-
actionName: toolCall.function.name,
|
|
1116
|
-
parentMessageId: chunk.id
|
|
1117
|
-
});
|
|
1118
|
-
} else if (content) {
|
|
1119
|
-
mode = "message";
|
|
1120
|
-
currentMessageId = chunk.id;
|
|
1121
|
-
eventStream$.sendTextMessageStart({
|
|
1104
|
+
try {
|
|
1105
|
+
for await (const chunk of stream) {
|
|
1106
|
+
const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
|
|
1107
|
+
const content = chunk.choices[0].delta.content;
|
|
1108
|
+
if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
|
|
1109
|
+
mode = null;
|
|
1110
|
+
eventStream$.sendTextMessageEnd({
|
|
1122
1111
|
messageId: currentMessageId
|
|
1123
1112
|
});
|
|
1113
|
+
} else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
|
|
1114
|
+
mode = null;
|
|
1115
|
+
eventStream$.sendActionExecutionEnd({
|
|
1116
|
+
actionExecutionId: currentToolCallId
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
if (mode === null) {
|
|
1120
|
+
if (toolCall == null ? void 0 : toolCall.id) {
|
|
1121
|
+
mode = "function";
|
|
1122
|
+
currentToolCallId = toolCall.id;
|
|
1123
|
+
eventStream$.sendActionExecutionStart({
|
|
1124
|
+
actionExecutionId: currentToolCallId,
|
|
1125
|
+
actionName: toolCall.function.name,
|
|
1126
|
+
parentMessageId: chunk.id
|
|
1127
|
+
});
|
|
1128
|
+
} else if (content) {
|
|
1129
|
+
mode = "message";
|
|
1130
|
+
currentMessageId = chunk.id;
|
|
1131
|
+
eventStream$.sendTextMessageStart({
|
|
1132
|
+
messageId: currentMessageId
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (mode === "message" && content) {
|
|
1137
|
+
eventStream$.sendTextMessageContent({
|
|
1138
|
+
messageId: currentMessageId,
|
|
1139
|
+
content
|
|
1140
|
+
});
|
|
1141
|
+
} else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
|
|
1142
|
+
eventStream$.sendActionExecutionArgs({
|
|
1143
|
+
actionExecutionId: currentToolCallId,
|
|
1144
|
+
args: toolCall.function.arguments
|
|
1145
|
+
});
|
|
1124
1146
|
}
|
|
1125
1147
|
}
|
|
1126
|
-
if (mode === "message"
|
|
1127
|
-
eventStream$.
|
|
1128
|
-
messageId: currentMessageId
|
|
1129
|
-
content
|
|
1148
|
+
if (mode === "message") {
|
|
1149
|
+
eventStream$.sendTextMessageEnd({
|
|
1150
|
+
messageId: currentMessageId
|
|
1130
1151
|
});
|
|
1131
|
-
} else if (mode === "function"
|
|
1132
|
-
eventStream$.
|
|
1133
|
-
actionExecutionId: currentToolCallId
|
|
1134
|
-
args: toolCall.function.arguments
|
|
1152
|
+
} else if (mode === "function") {
|
|
1153
|
+
eventStream$.sendActionExecutionEnd({
|
|
1154
|
+
actionExecutionId: currentToolCallId
|
|
1135
1155
|
});
|
|
1136
1156
|
}
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
eventStream$.sendTextMessageEnd({
|
|
1140
|
-
messageId: currentMessageId
|
|
1141
|
-
});
|
|
1142
|
-
} else if (mode === "function") {
|
|
1143
|
-
eventStream$.sendActionExecutionEnd({
|
|
1144
|
-
actionExecutionId: currentToolCallId
|
|
1145
|
-
});
|
|
1157
|
+
} catch (error) {
|
|
1158
|
+
throw convertServiceAdapterError(error, "Groq");
|
|
1146
1159
|
}
|
|
1147
1160
|
eventStream$.complete();
|
|
1148
1161
|
});
|
|
@@ -1293,7 +1306,7 @@ function convertMessageToAnthropicMessage(message) {
|
|
|
1293
1306
|
content: [
|
|
1294
1307
|
{
|
|
1295
1308
|
type: "tool_result",
|
|
1296
|
-
content: message.result,
|
|
1309
|
+
content: message.result || "Action completed successfully",
|
|
1297
1310
|
tool_use_id: message.actionExecutionId
|
|
1298
1311
|
}
|
|
1299
1312
|
]
|
|
@@ -1317,6 +1330,22 @@ var AnthropicAdapter = class {
|
|
|
1317
1330
|
this.model = params.model;
|
|
1318
1331
|
}
|
|
1319
1332
|
}
|
|
1333
|
+
shouldGenerateFallbackResponse(messages) {
|
|
1334
|
+
var _a, _b, _c;
|
|
1335
|
+
if (messages.length === 0)
|
|
1336
|
+
return false;
|
|
1337
|
+
const lastMessage = messages[messages.length - 1];
|
|
1338
|
+
const endsWithToolResult = lastMessage.role === "user" && Array.isArray(lastMessage.content) && lastMessage.content.some((content) => content.type === "tool_result");
|
|
1339
|
+
if (messages.length >= 3 && endsWithToolResult) {
|
|
1340
|
+
const lastThree = messages.slice(-3);
|
|
1341
|
+
const hasRecentToolPattern = ((_a = lastThree[0]) == null ? void 0 : _a.role) === "user" && // Initial user message
|
|
1342
|
+
((_b = lastThree[1]) == null ? void 0 : _b.role) === "assistant" && // Assistant tool use
|
|
1343
|
+
Array.isArray(lastThree[1].content) && lastThree[1].content.some((content) => content.type === "tool_use") && ((_c = lastThree[2]) == null ? void 0 : _c.role) === "user" && // Tool result
|
|
1344
|
+
Array.isArray(lastThree[2].content) && lastThree[2].content.some((content) => content.type === "tool_result");
|
|
1345
|
+
return hasRecentToolPattern;
|
|
1346
|
+
}
|
|
1347
|
+
return endsWithToolResult;
|
|
1348
|
+
}
|
|
1320
1349
|
async process(request) {
|
|
1321
1350
|
const { threadId, model = this.model, messages: rawMessages, actions, eventSource, forwardedParameters } = request;
|
|
1322
1351
|
const tools = actions.map(convertActionInputToAnthropicTool);
|
|
@@ -1331,18 +1360,22 @@ var AnthropicAdapter = class {
|
|
|
1331
1360
|
validToolUseIds.add(message.id);
|
|
1332
1361
|
}
|
|
1333
1362
|
}
|
|
1363
|
+
const processedToolResultIds = /* @__PURE__ */ new Set();
|
|
1334
1364
|
const anthropicMessages = messages.map((message) => {
|
|
1335
1365
|
if (message.isResultMessage()) {
|
|
1336
1366
|
if (!validToolUseIds.has(message.actionExecutionId)) {
|
|
1337
1367
|
return null;
|
|
1338
1368
|
}
|
|
1339
|
-
|
|
1369
|
+
if (processedToolResultIds.has(message.actionExecutionId)) {
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
processedToolResultIds.add(message.actionExecutionId);
|
|
1340
1373
|
return {
|
|
1341
1374
|
role: "user",
|
|
1342
1375
|
content: [
|
|
1343
1376
|
{
|
|
1344
1377
|
type: "tool_result",
|
|
1345
|
-
content: message.result,
|
|
1378
|
+
content: message.result || "Action completed successfully",
|
|
1346
1379
|
tool_use_id: message.actionExecutionId
|
|
1347
1380
|
}
|
|
1348
1381
|
]
|
|
@@ -1388,11 +1421,13 @@ var AnthropicAdapter = class {
|
|
|
1388
1421
|
let currentMessageId = randomId3();
|
|
1389
1422
|
let currentToolCallId = randomId3();
|
|
1390
1423
|
let filterThinkingTextBuffer = new FilterThinkingTextBuffer();
|
|
1424
|
+
let hasReceivedContent = false;
|
|
1391
1425
|
try {
|
|
1392
1426
|
for await (const chunk of stream) {
|
|
1393
1427
|
if (chunk.type === "message_start") {
|
|
1394
1428
|
currentMessageId = chunk.message.id;
|
|
1395
1429
|
} else if (chunk.type === "content_block_start") {
|
|
1430
|
+
hasReceivedContent = true;
|
|
1396
1431
|
if (chunk.content_block.type === "text") {
|
|
1397
1432
|
didOutputText = false;
|
|
1398
1433
|
filterThinkingTextBuffer.reset();
|
|
@@ -1442,14 +1477,33 @@ var AnthropicAdapter = class {
|
|
|
1442
1477
|
}
|
|
1443
1478
|
}
|
|
1444
1479
|
} catch (error) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1480
|
+
throw convertServiceAdapterError(error, "Anthropic");
|
|
1481
|
+
}
|
|
1482
|
+
if (!hasReceivedContent && this.shouldGenerateFallbackResponse(limitedMessages)) {
|
|
1483
|
+
let fallbackContent = "Task completed successfully.";
|
|
1484
|
+
const lastMessage = limitedMessages[limitedMessages.length - 1];
|
|
1485
|
+
if ((lastMessage == null ? void 0 : lastMessage.role) === "user" && Array.isArray(lastMessage.content)) {
|
|
1486
|
+
const toolResult = lastMessage.content.find((c) => c.type === "tool_result");
|
|
1487
|
+
if ((toolResult == null ? void 0 : toolResult.content) && toolResult.content !== "Action completed successfully") {
|
|
1488
|
+
fallbackContent = toolResult.content;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
currentMessageId = randomId3();
|
|
1492
|
+
eventStream$.sendTextMessageStart({
|
|
1493
|
+
messageId: currentMessageId
|
|
1494
|
+
});
|
|
1495
|
+
eventStream$.sendTextMessageContent({
|
|
1496
|
+
messageId: currentMessageId,
|
|
1497
|
+
content: fallbackContent
|
|
1498
|
+
});
|
|
1499
|
+
eventStream$.sendTextMessageEnd({
|
|
1500
|
+
messageId: currentMessageId
|
|
1501
|
+
});
|
|
1447
1502
|
}
|
|
1448
1503
|
eventStream$.complete();
|
|
1449
1504
|
});
|
|
1450
1505
|
} catch (error) {
|
|
1451
|
-
|
|
1452
|
-
throw error;
|
|
1506
|
+
throw convertServiceAdapterError(error, "Anthropic");
|
|
1453
1507
|
}
|
|
1454
1508
|
return {
|
|
1455
1509
|
threadId: threadId || randomUUID5()
|
|
@@ -1581,4 +1635,4 @@ export {
|
|
|
1581
1635
|
EmptyAdapter,
|
|
1582
1636
|
ExperimentalEmptyAdapter
|
|
1583
1637
|
};
|
|
1584
|
-
//# sourceMappingURL=chunk-
|
|
1638
|
+
//# sourceMappingURL=chunk-QLLV2QVK.mjs.map
|