@copilotkit/runtime 1.9.2-next.9 → 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 +169 -0
- package/dist/{chunk-UUXRYAB4.mjs → chunk-56ZNYBXV.mjs} +2 -2
- package/dist/{chunk-ALZ5H3VD.mjs → chunk-GB4M7WUE.mjs} +2 -2
- package/dist/{chunk-5YGKE5SN.mjs → chunk-HJYWUUFY.mjs} +2 -2
- package/dist/{chunk-SMDVD4VG.mjs → chunk-M35WOOEP.mjs} +2 -2
- package/dist/{chunk-4JBKY7XT.mjs → chunk-QLLV2QVK.mjs} +48 -28
- package/dist/chunk-QLLV2QVK.mjs.map +1 -0
- package/dist/{chunk-Z5GYTKMD.mjs → chunk-TE5QWP4H.mjs} +222 -146
- package/dist/chunk-TE5QWP4H.mjs.map +1 -0
- package/dist/{groq-adapter-172a2ca4.d.ts → groq-adapter-742818f2.d.ts} +5 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +267 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/{langserve-fc5cac89.d.ts → langserve-3e8d0e06.d.ts} +6 -0
- package/dist/lib/index.d.ts +155 -5
- package/dist/lib/index.js +221 -168
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +11 -11
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +11 -11
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +11 -11
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +11 -11
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.d.ts +5 -4
- package/dist/service-adapters/index.js +47 -27
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/dist/{shared-bd953ebf.d.ts → shared-96b46379.d.ts} +16 -18
- package/package.json +11 -11
- package/src/graphql/resolvers/copilot.resolver.ts +1 -2
- 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 +112 -124
- package/src/lib/runtime/mcp-tools-utils.ts +84 -18
- package/src/lib/runtime/remote-actions.ts +6 -0
- package/src/service-adapters/anthropic/anthropic-adapter.ts +64 -4
- package/src/service-adapters/anthropic/utils.ts +3 -8
- package/src/service-adapters/events.ts +40 -1
- package/src/service-adapters/google/google-genai-adapter.ts +5 -0
- package/src/service-adapters/openai/openai-adapter.ts +0 -14
- package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +172 -387
- package/dist/chunk-4JBKY7XT.mjs.map +0 -1
- package/dist/chunk-Z5GYTKMD.mjs.map +0 -1
- /package/dist/{chunk-UUXRYAB4.mjs.map → chunk-56ZNYBXV.mjs.map} +0 -0
- /package/dist/{chunk-ALZ5H3VD.mjs.map → chunk-GB4M7WUE.mjs.map} +0 -0
- /package/dist/{chunk-5YGKE5SN.mjs.map → chunk-HJYWUUFY.mjs.map} +0 -0
- /package/dist/{chunk-SMDVD4VG.mjs.map → chunk-M35WOOEP.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,174 @@
|
|
|
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
|
+
|
|
3
172
|
## 1.9.2-next.9
|
|
4
173
|
|
|
5
174
|
### 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
|
|
@@ -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
|
|
@@ -291,7 +291,6 @@ var OpenAIAdapter = class {
|
|
|
291
291
|
const { threadId: threadIdFromRequest, model = this.model, messages, actions, eventSource, forwardedParameters } = request;
|
|
292
292
|
const tools = actions.map(convertActionInputToOpenAITool);
|
|
293
293
|
const threadId = threadIdFromRequest ?? randomUUID();
|
|
294
|
-
console.log("messages", messages);
|
|
295
294
|
const validToolUseIds = /* @__PURE__ */ new Set();
|
|
296
295
|
for (const message of messages) {
|
|
297
296
|
if (message.isActionExecutionMessage()) {
|
|
@@ -321,29 +320,6 @@ var OpenAIAdapter = class {
|
|
|
321
320
|
}
|
|
322
321
|
};
|
|
323
322
|
}
|
|
324
|
-
console.log("INPUT", {
|
|
325
|
-
model,
|
|
326
|
-
stream: true,
|
|
327
|
-
messages: openaiMessages,
|
|
328
|
-
...tools.length > 0 && {
|
|
329
|
-
tools
|
|
330
|
-
},
|
|
331
|
-
...(forwardedParameters == null ? void 0 : forwardedParameters.maxTokens) && {
|
|
332
|
-
max_tokens: forwardedParameters.maxTokens
|
|
333
|
-
},
|
|
334
|
-
...(forwardedParameters == null ? void 0 : forwardedParameters.stop) && {
|
|
335
|
-
stop: forwardedParameters.stop
|
|
336
|
-
},
|
|
337
|
-
...toolChoice && {
|
|
338
|
-
tool_choice: toolChoice
|
|
339
|
-
},
|
|
340
|
-
...this.disableParallelToolCalls && {
|
|
341
|
-
parallel_tool_calls: false
|
|
342
|
-
},
|
|
343
|
-
...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
|
|
344
|
-
temperature: forwardedParameters.temperature
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
323
|
try {
|
|
348
324
|
const stream = this.openai.beta.chat.completions.stream({
|
|
349
325
|
model,
|
|
@@ -725,6 +701,7 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
|
725
701
|
return message.content && String(message.content).trim().length > 0 || message.tool_calls && message.tool_calls.length > 0;
|
|
726
702
|
});
|
|
727
703
|
const model = new ChatGoogle({
|
|
704
|
+
apiKey: (options == null ? void 0 : options.apiKey) ?? process.env.GOOGLE_API_KEY,
|
|
728
705
|
modelName: (options == null ? void 0 : options.model) ?? "gemini-1.5-pro",
|
|
729
706
|
apiVersion: "v1beta"
|
|
730
707
|
}).bindTools(tools);
|
|
@@ -1329,7 +1306,7 @@ function convertMessageToAnthropicMessage(message) {
|
|
|
1329
1306
|
content: [
|
|
1330
1307
|
{
|
|
1331
1308
|
type: "tool_result",
|
|
1332
|
-
content: message.result,
|
|
1309
|
+
content: message.result || "Action completed successfully",
|
|
1333
1310
|
tool_use_id: message.actionExecutionId
|
|
1334
1311
|
}
|
|
1335
1312
|
]
|
|
@@ -1353,6 +1330,22 @@ var AnthropicAdapter = class {
|
|
|
1353
1330
|
this.model = params.model;
|
|
1354
1331
|
}
|
|
1355
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
|
+
}
|
|
1356
1349
|
async process(request) {
|
|
1357
1350
|
const { threadId, model = this.model, messages: rawMessages, actions, eventSource, forwardedParameters } = request;
|
|
1358
1351
|
const tools = actions.map(convertActionInputToAnthropicTool);
|
|
@@ -1367,18 +1360,22 @@ var AnthropicAdapter = class {
|
|
|
1367
1360
|
validToolUseIds.add(message.id);
|
|
1368
1361
|
}
|
|
1369
1362
|
}
|
|
1363
|
+
const processedToolResultIds = /* @__PURE__ */ new Set();
|
|
1370
1364
|
const anthropicMessages = messages.map((message) => {
|
|
1371
1365
|
if (message.isResultMessage()) {
|
|
1372
1366
|
if (!validToolUseIds.has(message.actionExecutionId)) {
|
|
1373
1367
|
return null;
|
|
1374
1368
|
}
|
|
1375
|
-
|
|
1369
|
+
if (processedToolResultIds.has(message.actionExecutionId)) {
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
processedToolResultIds.add(message.actionExecutionId);
|
|
1376
1373
|
return {
|
|
1377
1374
|
role: "user",
|
|
1378
1375
|
content: [
|
|
1379
1376
|
{
|
|
1380
1377
|
type: "tool_result",
|
|
1381
|
-
content: message.result,
|
|
1378
|
+
content: message.result || "Action completed successfully",
|
|
1382
1379
|
tool_use_id: message.actionExecutionId
|
|
1383
1380
|
}
|
|
1384
1381
|
]
|
|
@@ -1424,11 +1421,13 @@ var AnthropicAdapter = class {
|
|
|
1424
1421
|
let currentMessageId = randomId3();
|
|
1425
1422
|
let currentToolCallId = randomId3();
|
|
1426
1423
|
let filterThinkingTextBuffer = new FilterThinkingTextBuffer();
|
|
1424
|
+
let hasReceivedContent = false;
|
|
1427
1425
|
try {
|
|
1428
1426
|
for await (const chunk of stream) {
|
|
1429
1427
|
if (chunk.type === "message_start") {
|
|
1430
1428
|
currentMessageId = chunk.message.id;
|
|
1431
1429
|
} else if (chunk.type === "content_block_start") {
|
|
1430
|
+
hasReceivedContent = true;
|
|
1432
1431
|
if (chunk.content_block.type === "text") {
|
|
1433
1432
|
didOutputText = false;
|
|
1434
1433
|
filterThinkingTextBuffer.reset();
|
|
@@ -1480,6 +1479,27 @@ var AnthropicAdapter = class {
|
|
|
1480
1479
|
} catch (error) {
|
|
1481
1480
|
throw convertServiceAdapterError(error, "Anthropic");
|
|
1482
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
|
+
});
|
|
1502
|
+
}
|
|
1483
1503
|
eventStream$.complete();
|
|
1484
1504
|
});
|
|
1485
1505
|
} catch (error) {
|
|
@@ -1615,4 +1635,4 @@ export {
|
|
|
1615
1635
|
EmptyAdapter,
|
|
1616
1636
|
ExperimentalEmptyAdapter
|
|
1617
1637
|
};
|
|
1618
|
-
//# sourceMappingURL=chunk-
|
|
1638
|
+
//# sourceMappingURL=chunk-QLLV2QVK.mjs.map
|