@yourgpt/copilot-sdk 2.1.1 → 2.1.3
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/dist/{chunk-SNI7VN2U.js → chunk-DMBFN7KO.js} +311 -80
- package/dist/chunk-DMBFN7KO.js.map +1 -0
- package/dist/{chunk-7YZVSG62.js → chunk-LZMBBGWH.js} +3 -3
- package/dist/{chunk-7YZVSG62.js.map → chunk-LZMBBGWH.js.map} +1 -1
- package/dist/{chunk-HNRFRNMY.cjs → chunk-POZNNKNJ.cjs} +2 -2
- package/dist/{chunk-HNRFRNMY.cjs.map → chunk-POZNNKNJ.cjs.map} +1 -1
- package/dist/{chunk-BRUDSHCV.js → chunk-QLH6TSCC.js} +2 -2
- package/dist/{chunk-BRUDSHCV.js.map → chunk-QLH6TSCC.js.map} +1 -1
- package/dist/{chunk-5UMM5VYB.cjs → chunk-R6LKHKAI.cjs} +335 -104
- package/dist/chunk-R6LKHKAI.cjs.map +1 -0
- package/dist/{chunk-7PJ4GAJR.js → chunk-VFV5FVVI.js} +4 -4
- package/dist/{chunk-7PJ4GAJR.js.map → chunk-VFV5FVVI.js.map} +1 -1
- package/dist/{chunk-O33I4HBL.cjs → chunk-WAPGTQDR.cjs} +5 -5
- package/dist/{chunk-O33I4HBL.cjs.map → chunk-WAPGTQDR.cjs.map} +1 -1
- package/dist/{chunk-33JSFVGH.cjs → chunk-WQSK3Z4K.cjs} +23 -23
- package/dist/{chunk-33JSFVGH.cjs.map → chunk-WQSK3Z4K.cjs.map} +1 -1
- package/dist/core/index.cjs +80 -80
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +3 -3
- package/dist/{index-C261xY-B.d.cts → index-BHkRA0mM.d.cts} +1 -1
- package/dist/{index-25qIYJ21.d.ts → index-tB0qI8my.d.ts} +1 -1
- package/dist/mcp/index.d.cts +3 -3
- package/dist/mcp/index.d.ts +3 -3
- package/dist/react/index.cjs +53 -49
- package/dist/react/index.d.cts +69 -7
- package/dist/react/index.d.ts +69 -7
- package/dist/react/index.js +4 -4
- package/dist/tools/anthropic/index.d.cts +1 -1
- package/dist/tools/anthropic/index.d.ts +1 -1
- package/dist/tools/brave/index.cjs +2 -2
- package/dist/tools/brave/index.d.cts +1 -1
- package/dist/tools/brave/index.d.ts +1 -1
- package/dist/tools/brave/index.js +1 -1
- package/dist/tools/exa/index.cjs +2 -2
- package/dist/tools/exa/index.d.cts +1 -1
- package/dist/tools/exa/index.d.ts +1 -1
- package/dist/tools/exa/index.js +1 -1
- package/dist/tools/google/index.cjs +2 -2
- package/dist/tools/google/index.d.cts +1 -1
- package/dist/tools/google/index.d.ts +1 -1
- package/dist/tools/google/index.js +1 -1
- package/dist/tools/openai/index.cjs +2 -2
- package/dist/tools/openai/index.d.cts +1 -1
- package/dist/tools/openai/index.d.ts +1 -1
- package/dist/tools/openai/index.js +1 -1
- package/dist/tools/searxng/index.cjs +2 -2
- package/dist/tools/searxng/index.d.cts +1 -1
- package/dist/tools/searxng/index.d.ts +1 -1
- package/dist/tools/searxng/index.js +1 -1
- package/dist/tools/serper/index.cjs +2 -2
- package/dist/tools/serper/index.d.cts +1 -1
- package/dist/tools/serper/index.d.ts +1 -1
- package/dist/tools/serper/index.js +1 -1
- package/dist/tools/tavily/index.cjs +2 -2
- package/dist/tools/tavily/index.d.cts +1 -1
- package/dist/tools/tavily/index.d.ts +1 -1
- package/dist/tools/tavily/index.js +1 -1
- package/dist/tools/web-search/index.cjs +3 -3
- package/dist/tools/web-search/index.d.cts +2 -2
- package/dist/tools/web-search/index.d.ts +2 -2
- package/dist/tools/web-search/index.js +2 -2
- package/dist/{tools-Clyufshc.d.cts → tools-coIcskZ4.d.cts} +23 -4
- package/dist/{tools-Clyufshc.d.ts → tools-coIcskZ4.d.ts} +23 -4
- package/dist/{types-DM6M_pv_.d.cts → types-C8t4Ut8f.d.cts} +1 -1
- package/dist/{types-wudOhedT.d.ts → types-rjaSVmEF.d.ts} +1 -1
- package/dist/ui/index.cjs +39 -18
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +6 -1
- package/dist/ui/index.d.ts +6 -1
- package/dist/ui/index.js +35 -14
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-5UMM5VYB.cjs.map +0 -1
- package/dist/chunk-SNI7VN2U.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWQSK3Z4K_cjs = require('./chunk-WQSK3Z4K.cjs');
|
|
4
4
|
var chunkJGPDQDY4_cjs = require('./chunk-JGPDQDY4.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -183,7 +183,8 @@ function processStreamChunk(chunk, state) {
|
|
|
183
183
|
newResults.set(chunk.id, {
|
|
184
184
|
id: chunk.id,
|
|
185
185
|
name: chunk.name,
|
|
186
|
-
status: "executing"
|
|
186
|
+
status: "executing",
|
|
187
|
+
hidden: chunk.hidden
|
|
187
188
|
});
|
|
188
189
|
return { ...state, toolResults: newResults };
|
|
189
190
|
}
|
|
@@ -383,17 +384,11 @@ var HttpTransport = class {
|
|
|
383
384
|
this.abortController = new AbortController();
|
|
384
385
|
this.streaming = true;
|
|
385
386
|
try {
|
|
386
|
-
console.log(
|
|
387
|
-
"[HttpTransport] Config headers type:",
|
|
388
|
-
typeof this.config.headers
|
|
389
|
-
);
|
|
390
|
-
console.log("[HttpTransport] Config headers:", this.config.headers);
|
|
391
387
|
const resolved = await resolveValues({
|
|
392
388
|
url: this.config.url,
|
|
393
389
|
headers: this.config.headers ?? {},
|
|
394
390
|
configBody: this.config.body ?? {}
|
|
395
391
|
});
|
|
396
|
-
console.log("[HttpTransport] Resolved headers:", resolved.headers);
|
|
397
392
|
const response = await fetch(resolved.url, {
|
|
398
393
|
method: "POST",
|
|
399
394
|
headers: {
|
|
@@ -549,16 +544,16 @@ var HttpTransport = class {
|
|
|
549
544
|
};
|
|
550
545
|
|
|
551
546
|
// src/chat/classes/AbstractChat.ts
|
|
552
|
-
function buildToolResultContentForAI(result,
|
|
547
|
+
function buildToolResultContentForAI(result, tool2, args) {
|
|
553
548
|
if (typeof result === "string") return result;
|
|
554
549
|
const typedResult = result;
|
|
555
|
-
const responseMode = typedResult?._aiResponseMode ??
|
|
550
|
+
const responseMode = typedResult?._aiResponseMode ?? tool2?.aiResponseMode ?? "full";
|
|
556
551
|
if (typedResult?._aiContent) {
|
|
557
552
|
return JSON.stringify(typedResult._aiContent);
|
|
558
553
|
}
|
|
559
554
|
let aiContext = typedResult?._aiContext;
|
|
560
|
-
if (!aiContext &&
|
|
561
|
-
aiContext = typeof
|
|
555
|
+
if (!aiContext && tool2?.aiContext) {
|
|
556
|
+
aiContext = typeof tool2.aiContext === "function" ? tool2.aiContext(typedResult, args ?? {}) : tool2.aiContext;
|
|
562
557
|
}
|
|
563
558
|
switch (responseMode) {
|
|
564
559
|
case "none":
|
|
@@ -914,10 +909,10 @@ var AbstractChat = class {
|
|
|
914
909
|
* Build the request payload
|
|
915
910
|
*/
|
|
916
911
|
buildRequest() {
|
|
917
|
-
const tools = this.config.tools?.filter((
|
|
918
|
-
name:
|
|
919
|
-
description:
|
|
920
|
-
inputSchema:
|
|
912
|
+
const tools = this.config.tools?.filter((tool2) => tool2.available !== false).map((tool2) => ({
|
|
913
|
+
name: tool2.name,
|
|
914
|
+
description: tool2.description,
|
|
915
|
+
inputSchema: tool2.inputSchema
|
|
921
916
|
}));
|
|
922
917
|
const toolCallMap = /* @__PURE__ */ new Map();
|
|
923
918
|
for (const msg of this.state.messages) {
|
|
@@ -934,11 +929,11 @@ var AbstractChat = class {
|
|
|
934
929
|
}
|
|
935
930
|
const toolDefMap = /* @__PURE__ */ new Map();
|
|
936
931
|
if (this.config.tools) {
|
|
937
|
-
for (const
|
|
938
|
-
toolDefMap.set(
|
|
939
|
-
name:
|
|
940
|
-
aiResponseMode:
|
|
941
|
-
aiContext:
|
|
932
|
+
for (const tool2 of this.config.tools) {
|
|
933
|
+
toolDefMap.set(tool2.name, {
|
|
934
|
+
name: tool2.name,
|
|
935
|
+
aiResponseMode: tool2.aiResponseMode,
|
|
936
|
+
aiContext: tool2.aiContext
|
|
942
937
|
});
|
|
943
938
|
}
|
|
944
939
|
}
|
|
@@ -1010,7 +1005,70 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
|
|
|
1010
1005
|
this.handleError(error);
|
|
1011
1006
|
return;
|
|
1012
1007
|
}
|
|
1008
|
+
if (chunk.type === "message:end" && this.streamState?.content) {
|
|
1009
|
+
this.debug("message:end mid-stream - finalizing current turn");
|
|
1010
|
+
const turnMessage = streamStateToMessage(this.streamState);
|
|
1011
|
+
const toolCallsHidden = {};
|
|
1012
|
+
for (const [id, result] of this.streamState.toolResults) {
|
|
1013
|
+
if (result.hidden !== void 0) {
|
|
1014
|
+
toolCallsHidden[id] = result.hidden;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (turnMessage.toolCalls?.length && Object.keys(toolCallsHidden).length > 0) {
|
|
1018
|
+
turnMessage.metadata = {
|
|
1019
|
+
...turnMessage.metadata,
|
|
1020
|
+
toolCallsHidden
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
this.state.updateMessageById(
|
|
1024
|
+
this.streamState.messageId,
|
|
1025
|
+
() => turnMessage
|
|
1026
|
+
);
|
|
1027
|
+
this.callbacks.onMessageFinish?.(turnMessage);
|
|
1028
|
+
this.streamState = null;
|
|
1029
|
+
continue;
|
|
1030
|
+
}
|
|
1031
|
+
if (chunk.type === "message:start" && this.streamState === null) {
|
|
1032
|
+
this.debug("message:start after mid-stream end - creating new message");
|
|
1033
|
+
const newMessage = createEmptyAssistantMessage();
|
|
1034
|
+
this.state.pushMessage(newMessage);
|
|
1035
|
+
this.streamState = createStreamState(newMessage.id);
|
|
1036
|
+
this.callbacks.onMessageStart?.(newMessage.id);
|
|
1037
|
+
continue;
|
|
1038
|
+
}
|
|
1039
|
+
if (!this.streamState) {
|
|
1040
|
+
this.debug("warning", "streamState is null, skipping chunk");
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1013
1043
|
this.streamState = processStreamChunk(chunk, this.streamState);
|
|
1044
|
+
if (chunk.type === "action:start") {
|
|
1045
|
+
this.callbacks.onServerToolStart?.({
|
|
1046
|
+
id: chunk.id,
|
|
1047
|
+
name: chunk.name,
|
|
1048
|
+
hidden: chunk.hidden
|
|
1049
|
+
});
|
|
1050
|
+
} else if (chunk.type === "action:args") {
|
|
1051
|
+
let args = {};
|
|
1052
|
+
try {
|
|
1053
|
+
args = JSON.parse(chunk.args);
|
|
1054
|
+
} catch {
|
|
1055
|
+
}
|
|
1056
|
+
const existingResult = this.streamState?.toolResults.get(chunk.id);
|
|
1057
|
+
if (existingResult) {
|
|
1058
|
+
this.callbacks.onServerToolArgs?.({
|
|
1059
|
+
id: chunk.id,
|
|
1060
|
+
name: existingResult.name,
|
|
1061
|
+
args
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
} else if (chunk.type === "action:end") {
|
|
1065
|
+
this.callbacks.onServerToolEnd?.({
|
|
1066
|
+
id: chunk.id,
|
|
1067
|
+
name: chunk.name,
|
|
1068
|
+
result: chunk.result,
|
|
1069
|
+
error: chunk.error
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1014
1072
|
const updatedMessage = streamStateToMessage(this.streamState);
|
|
1015
1073
|
this.state.updateMessageById(
|
|
1016
1074
|
this.streamState.messageId,
|
|
@@ -1026,19 +1084,68 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
|
|
|
1026
1084
|
}
|
|
1027
1085
|
if (isStreamDone(chunk)) {
|
|
1028
1086
|
this.debug("streamDone", { chunk });
|
|
1087
|
+
if (chunk.type === "done" && chunk.messages?.length) {
|
|
1088
|
+
this.debug("processDoneMessages", {
|
|
1089
|
+
count: chunk.messages.length
|
|
1090
|
+
});
|
|
1091
|
+
const toolCallsHidden = {};
|
|
1092
|
+
if (this.streamState?.toolResults) {
|
|
1093
|
+
for (const [id, result] of this.streamState.toolResults) {
|
|
1094
|
+
if (result.hidden !== void 0) {
|
|
1095
|
+
toolCallsHidden[id] = result.hidden;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
for (const msg of chunk.messages) {
|
|
1100
|
+
if (msg.role === "assistant") {
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
let metadata;
|
|
1104
|
+
if (msg.role === "assistant" && msg.tool_calls?.length && Object.keys(toolCallsHidden).length > 0) {
|
|
1105
|
+
metadata = { toolCallsHidden };
|
|
1106
|
+
}
|
|
1107
|
+
const message = {
|
|
1108
|
+
id: generateMessageId(),
|
|
1109
|
+
role: msg.role,
|
|
1110
|
+
content: msg.content ?? "",
|
|
1111
|
+
toolCalls: msg.tool_calls,
|
|
1112
|
+
toolCallId: msg.tool_call_id,
|
|
1113
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1114
|
+
metadata
|
|
1115
|
+
};
|
|
1116
|
+
this.state.pushMessage(message);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1029
1119
|
break;
|
|
1030
1120
|
}
|
|
1031
1121
|
}
|
|
1032
1122
|
this.debug("handleStreamResponse", `Processed ${chunkCount} chunks`);
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1123
|
+
if (!this.streamState) {
|
|
1124
|
+
this.debug("streamState already finalized via message:end");
|
|
1125
|
+
} else {
|
|
1126
|
+
const toolCallsHidden = {};
|
|
1127
|
+
if (this.streamState.toolResults) {
|
|
1128
|
+
for (const [id, result] of this.streamState.toolResults) {
|
|
1129
|
+
if (result.hidden !== void 0) {
|
|
1130
|
+
toolCallsHidden[id] = result.hidden;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
const finalMessage = streamStateToMessage(this.streamState);
|
|
1135
|
+
if (finalMessage.toolCalls?.length && Object.keys(toolCallsHidden).length > 0) {
|
|
1136
|
+
finalMessage.metadata = {
|
|
1137
|
+
...finalMessage.metadata,
|
|
1138
|
+
toolCallsHidden
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
this.state.updateMessageById(
|
|
1142
|
+
this.streamState.messageId,
|
|
1143
|
+
() => finalMessage
|
|
1144
|
+
);
|
|
1145
|
+
if (!finalMessage.content && (!finalMessage.toolCalls || finalMessage.toolCalls.length === 0)) {
|
|
1146
|
+
this.debug("warning", "Empty response - no content and no tool calls");
|
|
1147
|
+
}
|
|
1040
1148
|
}
|
|
1041
|
-
this.callbacks.onMessageFinish?.(finalMessage);
|
|
1042
1149
|
this.callbacks.onMessagesChange?.(this.state.messages);
|
|
1043
1150
|
if (!toolCallsEmitted) {
|
|
1044
1151
|
this.state.status = "ready";
|
|
@@ -1052,13 +1159,37 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
|
|
|
1052
1159
|
* Handle JSON (non-streaming) response
|
|
1053
1160
|
*/
|
|
1054
1161
|
handleJsonResponse(response) {
|
|
1162
|
+
const toolCallHiddenMap = /* @__PURE__ */ new Map();
|
|
1163
|
+
if (response.toolCalls) {
|
|
1164
|
+
for (const tc of response.toolCalls) {
|
|
1165
|
+
if (tc.hidden !== void 0) {
|
|
1166
|
+
toolCallHiddenMap.set(tc.id, tc.hidden);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1055
1170
|
for (const msg of response.messages ?? []) {
|
|
1171
|
+
let metadata;
|
|
1172
|
+
if (msg.role === "assistant" && msg.tool_calls && toolCallHiddenMap.size > 0) {
|
|
1173
|
+
const toolCallsHidden = {};
|
|
1174
|
+
for (const tc of msg.tool_calls) {
|
|
1175
|
+
const hidden = toolCallHiddenMap.get(tc.id);
|
|
1176
|
+
if (hidden !== void 0) {
|
|
1177
|
+
toolCallsHidden[tc.id] = hidden;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
if (Object.keys(toolCallsHidden).length > 0) {
|
|
1181
|
+
metadata = { toolCallsHidden };
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1056
1184
|
const message = {
|
|
1057
1185
|
id: generateMessageId(),
|
|
1058
1186
|
role: msg.role,
|
|
1059
1187
|
content: msg.content ?? "",
|
|
1060
1188
|
toolCalls: msg.tool_calls,
|
|
1061
|
-
|
|
1189
|
+
// CRITICAL: Preserve toolCallId for tool messages (fixes Anthropic API errors)
|
|
1190
|
+
toolCallId: msg.tool_call_id,
|
|
1191
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1192
|
+
metadata
|
|
1062
1193
|
};
|
|
1063
1194
|
this.state.pushMessage(message);
|
|
1064
1195
|
}
|
|
@@ -1159,8 +1290,8 @@ var AbstractAgentLoop = class {
|
|
|
1159
1290
|
this._maxIterations = config.maxIterations ?? 20;
|
|
1160
1291
|
this._maxExecutionHistory = config.maxExecutionHistory ?? 100;
|
|
1161
1292
|
if (config.tools) {
|
|
1162
|
-
for (const
|
|
1163
|
-
this.registerTool(
|
|
1293
|
+
for (const tool2 of config.tools) {
|
|
1294
|
+
this.registerTool(tool2);
|
|
1164
1295
|
}
|
|
1165
1296
|
}
|
|
1166
1297
|
}
|
|
@@ -1219,6 +1350,12 @@ var AbstractAgentLoop = class {
|
|
|
1219
1350
|
this._isProcessing = processing;
|
|
1220
1351
|
}
|
|
1221
1352
|
addToolExecution(execution) {
|
|
1353
|
+
const existingIndex = this._toolExecutions.findIndex(
|
|
1354
|
+
(e) => e.id === execution.id
|
|
1355
|
+
);
|
|
1356
|
+
if (existingIndex !== -1) {
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1222
1359
|
this._toolExecutions = [...this._toolExecutions, execution];
|
|
1223
1360
|
if (this._toolExecutions.length > this._maxExecutionHistory) {
|
|
1224
1361
|
this._toolExecutions = this._toolExecutions.slice(
|
|
@@ -1227,6 +1364,9 @@ var AbstractAgentLoop = class {
|
|
|
1227
1364
|
}
|
|
1228
1365
|
this.callbacks.onExecutionsChange?.(this._toolExecutions);
|
|
1229
1366
|
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Update a tool execution with partial data
|
|
1369
|
+
*/
|
|
1230
1370
|
updateToolExecution(id, update) {
|
|
1231
1371
|
this._toolExecutions = this._toolExecutions.map(
|
|
1232
1372
|
(exec) => exec.id === id ? { ...exec, ...update } : exec
|
|
@@ -1240,15 +1380,15 @@ var AbstractAgentLoop = class {
|
|
|
1240
1380
|
* Register a tool (reference counted for React StrictMode compatibility)
|
|
1241
1381
|
* Tools are never fully removed - ref counting ensures StrictMode works correctly
|
|
1242
1382
|
*/
|
|
1243
|
-
registerTool(
|
|
1244
|
-
const existing = this.registeredTools.get(
|
|
1383
|
+
registerTool(tool2) {
|
|
1384
|
+
const existing = this.registeredTools.get(tool2.name);
|
|
1245
1385
|
if (existing) {
|
|
1246
|
-
existing.tool =
|
|
1386
|
+
existing.tool = tool2;
|
|
1247
1387
|
existing.refCount++;
|
|
1248
1388
|
existing.active = true;
|
|
1249
1389
|
} else {
|
|
1250
|
-
this.registeredTools.set(
|
|
1251
|
-
tool,
|
|
1390
|
+
this.registeredTools.set(tool2.name, {
|
|
1391
|
+
tool: tool2,
|
|
1252
1392
|
refCount: 1,
|
|
1253
1393
|
active: true
|
|
1254
1394
|
});
|
|
@@ -1314,7 +1454,7 @@ var AbstractAgentLoop = class {
|
|
|
1314
1454
|
* Execute a single tool
|
|
1315
1455
|
*/
|
|
1316
1456
|
async executeSingleTool(toolCall) {
|
|
1317
|
-
const
|
|
1457
|
+
const tool2 = this.getTool(toolCall.name);
|
|
1318
1458
|
const execution = {
|
|
1319
1459
|
id: toolCall.id,
|
|
1320
1460
|
toolCallId: toolCall.id,
|
|
@@ -1322,11 +1462,12 @@ var AbstractAgentLoop = class {
|
|
|
1322
1462
|
args: toolCall.args,
|
|
1323
1463
|
status: "pending",
|
|
1324
1464
|
approvalStatus: "none",
|
|
1325
|
-
startedAt: /* @__PURE__ */ new Date()
|
|
1465
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
1466
|
+
hidden: tool2?.hidden
|
|
1326
1467
|
};
|
|
1327
1468
|
this.addToolExecution(execution);
|
|
1328
1469
|
this.callbacks.onToolStart?.(execution);
|
|
1329
|
-
if (!
|
|
1470
|
+
if (!tool2) {
|
|
1330
1471
|
const errorResult = {
|
|
1331
1472
|
toolCallId: toolCall.id,
|
|
1332
1473
|
success: false,
|
|
@@ -1340,8 +1481,8 @@ var AbstractAgentLoop = class {
|
|
|
1340
1481
|
return errorResult;
|
|
1341
1482
|
}
|
|
1342
1483
|
let approvalData;
|
|
1343
|
-
if (
|
|
1344
|
-
const approvalMessage = typeof
|
|
1484
|
+
if (tool2.needsApproval && !this.config.autoApprove) {
|
|
1485
|
+
const approvalMessage = typeof tool2.approvalMessage === "function" ? tool2.approvalMessage(toolCall.args) : tool2.approvalMessage;
|
|
1345
1486
|
execution.approvalStatus = "required";
|
|
1346
1487
|
execution.approvalMessage = approvalMessage;
|
|
1347
1488
|
this.updateToolExecution(toolCall.id, {
|
|
@@ -1368,13 +1509,13 @@ var AbstractAgentLoop = class {
|
|
|
1368
1509
|
}
|
|
1369
1510
|
this.updateToolExecution(toolCall.id, { status: "executing" });
|
|
1370
1511
|
try {
|
|
1371
|
-
if (!
|
|
1512
|
+
if (!tool2.handler) {
|
|
1372
1513
|
throw new Error(`Tool "${toolCall.name}" has no handler`);
|
|
1373
1514
|
}
|
|
1374
1515
|
if (this._isCancelled || this.abortController?.signal.aborted) {
|
|
1375
1516
|
throw new Error("Tool execution cancelled");
|
|
1376
1517
|
}
|
|
1377
|
-
const result = await
|
|
1518
|
+
const result = await tool2.handler(toolCall.args, {
|
|
1378
1519
|
signal: this.abortController?.signal,
|
|
1379
1520
|
data: { toolCallId: toolCall.id },
|
|
1380
1521
|
approvalData
|
|
@@ -1458,6 +1599,43 @@ var AbstractAgentLoop = class {
|
|
|
1458
1599
|
this.setIteration(0);
|
|
1459
1600
|
this._maxIterationsReached = false;
|
|
1460
1601
|
}
|
|
1602
|
+
// ============================================
|
|
1603
|
+
// Server-Side Tool Tracking
|
|
1604
|
+
// ============================================
|
|
1605
|
+
/**
|
|
1606
|
+
* Add a server-side tool execution (from streaming action:start event)
|
|
1607
|
+
* Used to track tools executed on the server (not client-side)
|
|
1608
|
+
*/
|
|
1609
|
+
addServerToolExecution(info) {
|
|
1610
|
+
const execution = {
|
|
1611
|
+
id: info.id,
|
|
1612
|
+
toolCallId: info.id,
|
|
1613
|
+
name: info.name,
|
|
1614
|
+
args: {},
|
|
1615
|
+
status: "executing",
|
|
1616
|
+
approvalStatus: "none",
|
|
1617
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
1618
|
+
hidden: info.hidden
|
|
1619
|
+
};
|
|
1620
|
+
this.addToolExecution(execution);
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Update a server-side tool execution with args (from action:args event)
|
|
1624
|
+
*/
|
|
1625
|
+
updateServerToolArgs(id, args) {
|
|
1626
|
+
this.updateToolExecution(id, { args });
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Complete a server-side tool execution (from action:end event)
|
|
1630
|
+
*/
|
|
1631
|
+
completeServerToolExecution(info) {
|
|
1632
|
+
this.updateToolExecution(info.id, {
|
|
1633
|
+
status: info.error ? "failed" : "completed",
|
|
1634
|
+
result: info.result,
|
|
1635
|
+
error: info.error,
|
|
1636
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1461
1639
|
/**
|
|
1462
1640
|
* Cancel all pending and executing tools
|
|
1463
1641
|
* This will:
|
|
@@ -1599,7 +1777,59 @@ var ChatWithTools = class {
|
|
|
1599
1777
|
onMessageDelta: callbacks.onMessageDelta,
|
|
1600
1778
|
onMessageFinish: callbacks.onMessageFinish,
|
|
1601
1779
|
onToolCalls: callbacks.onToolCalls,
|
|
1602
|
-
onFinish: callbacks.onFinish
|
|
1780
|
+
onFinish: callbacks.onFinish,
|
|
1781
|
+
// Server-side tool callbacks - track in agentLoop for UI display
|
|
1782
|
+
// IMPORTANT: Only track tools that are NOT registered client-side
|
|
1783
|
+
// Client-side tools are tracked via executeToolCalls() path
|
|
1784
|
+
onServerToolStart: (info) => {
|
|
1785
|
+
const existingExecution = this.agentLoop.toolExecutions.find(
|
|
1786
|
+
(e) => e.id === info.id
|
|
1787
|
+
);
|
|
1788
|
+
if (existingExecution) {
|
|
1789
|
+
if (info.hidden !== void 0 && existingExecution.hidden !== info.hidden) {
|
|
1790
|
+
this.debug(
|
|
1791
|
+
"Updating hidden flag for existing execution:",
|
|
1792
|
+
info.name,
|
|
1793
|
+
info.hidden
|
|
1794
|
+
);
|
|
1795
|
+
this.agentLoop.updateToolExecution(info.id, {
|
|
1796
|
+
hidden: info.hidden
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
const isClientTool = this.agentLoop.tools.some(
|
|
1802
|
+
(t) => t.name === info.name && t.location === "client"
|
|
1803
|
+
);
|
|
1804
|
+
if (isClientTool) {
|
|
1805
|
+
this.debug("Skipping server tracking for client tool:", info.name);
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
this.debug("Server tool started:", info.name, {
|
|
1809
|
+
hidden: info.hidden,
|
|
1810
|
+
id: info.id
|
|
1811
|
+
});
|
|
1812
|
+
this.agentLoop.addServerToolExecution(info);
|
|
1813
|
+
},
|
|
1814
|
+
onServerToolArgs: (info) => {
|
|
1815
|
+
const isClientTool = this.agentLoop.tools.some(
|
|
1816
|
+
(t) => t.name === info.name && t.location === "client"
|
|
1817
|
+
);
|
|
1818
|
+
if (isClientTool) return;
|
|
1819
|
+
this.debug("Server tool args:", info.name, info.args);
|
|
1820
|
+
this.agentLoop.updateServerToolArgs(info.id, info.args ?? {});
|
|
1821
|
+
},
|
|
1822
|
+
onServerToolEnd: (info) => {
|
|
1823
|
+
const isClientTool = this.agentLoop.tools.some(
|
|
1824
|
+
(t) => t.name === info.name && t.location === "client"
|
|
1825
|
+
);
|
|
1826
|
+
if (isClientTool) return;
|
|
1827
|
+
this.debug("Server tool ended:", info.name, {
|
|
1828
|
+
error: info.error,
|
|
1829
|
+
hasResult: !!info.result
|
|
1830
|
+
});
|
|
1831
|
+
this.agentLoop.completeServerToolExecution(info);
|
|
1832
|
+
}
|
|
1603
1833
|
}
|
|
1604
1834
|
});
|
|
1605
1835
|
this.wireEvents();
|
|
@@ -1796,8 +2026,8 @@ var ChatWithTools = class {
|
|
|
1796
2026
|
/**
|
|
1797
2027
|
* Register a tool
|
|
1798
2028
|
*/
|
|
1799
|
-
registerTool(
|
|
1800
|
-
this.agentLoop.registerTool(
|
|
2029
|
+
registerTool(tool2) {
|
|
2030
|
+
this.agentLoop.registerTool(tool2);
|
|
1801
2031
|
this.chat.setTools(this.agentLoop.tools);
|
|
1802
2032
|
}
|
|
1803
2033
|
/**
|
|
@@ -2265,7 +2495,7 @@ function useMCPTools(config) {
|
|
|
2265
2495
|
return [];
|
|
2266
2496
|
}
|
|
2267
2497
|
return mcpClient.state.tools.map(
|
|
2268
|
-
(
|
|
2498
|
+
(tool2) => toolAdapter.toToolDefinition(tool2, {
|
|
2269
2499
|
prefix: prefixToolNames,
|
|
2270
2500
|
asServerTool: true,
|
|
2271
2501
|
// MCP tools execute remotely
|
|
@@ -2294,9 +2524,9 @@ function useMCPTools(config) {
|
|
|
2294
2524
|
}
|
|
2295
2525
|
registeredToolsRef.current = [];
|
|
2296
2526
|
if (mcpClient.isConnected && toolDefinitions.length > 0) {
|
|
2297
|
-
for (const
|
|
2298
|
-
registerTool(
|
|
2299
|
-
registeredToolsRef.current.push(
|
|
2527
|
+
for (const tool2 of toolDefinitions) {
|
|
2528
|
+
registerTool(tool2);
|
|
2529
|
+
registeredToolsRef.current.push(tool2.name);
|
|
2300
2530
|
}
|
|
2301
2531
|
}
|
|
2302
2532
|
return () => {
|
|
@@ -2453,8 +2683,8 @@ function CopilotProvider({
|
|
|
2453
2683
|
);
|
|
2454
2684
|
const error = errorFromChat ?? null;
|
|
2455
2685
|
const isLoading = status === "streaming" || status === "submitted";
|
|
2456
|
-
const registerTool = react.useCallback((
|
|
2457
|
-
chatRef.current?.registerTool(
|
|
2686
|
+
const registerTool = react.useCallback((tool2) => {
|
|
2687
|
+
chatRef.current?.registerTool(tool2);
|
|
2458
2688
|
}, []);
|
|
2459
2689
|
const unregisterTool = react.useCallback((name) => {
|
|
2460
2690
|
chatRef.current?.unregisterTool(name);
|
|
@@ -2729,17 +2959,17 @@ function useAITools(options = {}) {
|
|
|
2729
2959
|
const rememberedConsentRef = react.useRef(/* @__PURE__ */ new Set());
|
|
2730
2960
|
react.useEffect(() => {
|
|
2731
2961
|
if (!autoStart || !isEnabled) return;
|
|
2732
|
-
if (consoleCapture && !
|
|
2733
|
-
|
|
2962
|
+
if (consoleCapture && !chunkWQSK3Z4K_cjs.isConsoleCaptureActive()) {
|
|
2963
|
+
chunkWQSK3Z4K_cjs.startConsoleCapture(consoleOptions);
|
|
2734
2964
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2735
2965
|
}
|
|
2736
|
-
if (network && !
|
|
2737
|
-
|
|
2966
|
+
if (network && !chunkWQSK3Z4K_cjs.isNetworkCaptureActive()) {
|
|
2967
|
+
chunkWQSK3Z4K_cjs.startNetworkCapture(networkOptions);
|
|
2738
2968
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2739
2969
|
}
|
|
2740
2970
|
return () => {
|
|
2741
|
-
|
|
2742
|
-
|
|
2971
|
+
chunkWQSK3Z4K_cjs.stopConsoleCapture();
|
|
2972
|
+
chunkWQSK3Z4K_cjs.stopNetworkCapture();
|
|
2743
2973
|
};
|
|
2744
2974
|
}, [
|
|
2745
2975
|
autoStart,
|
|
@@ -2754,12 +2984,12 @@ function useAITools(options = {}) {
|
|
|
2754
2984
|
if (!screenshot) {
|
|
2755
2985
|
throw new Error("Screenshot capture is not enabled");
|
|
2756
2986
|
}
|
|
2757
|
-
if (!
|
|
2987
|
+
if (!chunkWQSK3Z4K_cjs.isScreenshotSupported()) {
|
|
2758
2988
|
throw new Error(
|
|
2759
2989
|
"Screenshot capture is not supported in this environment"
|
|
2760
2990
|
);
|
|
2761
2991
|
}
|
|
2762
|
-
return
|
|
2992
|
+
return chunkWQSK3Z4K_cjs.captureScreenshot({ ...screenshotOptions, ...opts });
|
|
2763
2993
|
},
|
|
2764
2994
|
[screenshot, screenshotOptions]
|
|
2765
2995
|
);
|
|
@@ -2768,7 +2998,7 @@ function useAITools(options = {}) {
|
|
|
2768
2998
|
if (!consoleCapture) {
|
|
2769
2999
|
return { logs: [], totalCaptured: 0 };
|
|
2770
3000
|
}
|
|
2771
|
-
return
|
|
3001
|
+
return chunkWQSK3Z4K_cjs.getConsoleLogs({ ...consoleOptions, ...opts });
|
|
2772
3002
|
},
|
|
2773
3003
|
[consoleCapture, consoleOptions]
|
|
2774
3004
|
);
|
|
@@ -2777,16 +3007,16 @@ function useAITools(options = {}) {
|
|
|
2777
3007
|
if (!network) {
|
|
2778
3008
|
return { requests: [], totalCaptured: 0 };
|
|
2779
3009
|
}
|
|
2780
|
-
return
|
|
3010
|
+
return chunkWQSK3Z4K_cjs.getNetworkRequests({ ...networkOptions, ...opts });
|
|
2781
3011
|
},
|
|
2782
3012
|
[network, networkOptions]
|
|
2783
3013
|
);
|
|
2784
3014
|
const requestConsent = react.useCallback(
|
|
2785
3015
|
async (tools, reason = "") => {
|
|
2786
|
-
const enabledTools = tools.filter((
|
|
2787
|
-
if (
|
|
2788
|
-
if (
|
|
2789
|
-
if (
|
|
3016
|
+
const enabledTools = tools.filter((tool2) => {
|
|
3017
|
+
if (tool2 === "screenshot") return screenshot;
|
|
3018
|
+
if (tool2 === "console") return consoleCapture;
|
|
3019
|
+
if (tool2 === "network") return network;
|
|
2790
3020
|
return false;
|
|
2791
3021
|
});
|
|
2792
3022
|
if (enabledTools.length === 0) {
|
|
@@ -2796,7 +3026,7 @@ function useAITools(options = {}) {
|
|
|
2796
3026
|
return { approved: enabledTools, denied: [] };
|
|
2797
3027
|
}
|
|
2798
3028
|
const needsConsent = enabledTools.filter(
|
|
2799
|
-
(
|
|
3029
|
+
(tool2) => !rememberedConsentRef.current.has(tool2)
|
|
2800
3030
|
);
|
|
2801
3031
|
if (needsConsent.length === 0) {
|
|
2802
3032
|
return { approved: enabledTools, denied: [] };
|
|
@@ -2810,7 +3040,7 @@ function useAITools(options = {}) {
|
|
|
2810
3040
|
const response = await onConsentRequest(request);
|
|
2811
3041
|
if (response.remember) {
|
|
2812
3042
|
response.approved.forEach(
|
|
2813
|
-
(
|
|
3043
|
+
(tool2) => rememberedConsentRef.current.add(tool2)
|
|
2814
3044
|
);
|
|
2815
3045
|
}
|
|
2816
3046
|
return response;
|
|
@@ -2820,7 +3050,7 @@ function useAITools(options = {}) {
|
|
|
2820
3050
|
consentResolverRef.current = (response) => {
|
|
2821
3051
|
if (response.remember) {
|
|
2822
3052
|
response.approved.forEach(
|
|
2823
|
-
(
|
|
3053
|
+
(tool2) => rememberedConsentRef.current.add(tool2)
|
|
2824
3054
|
);
|
|
2825
3055
|
}
|
|
2826
3056
|
resolve(response);
|
|
@@ -2870,23 +3100,23 @@ function useAITools(options = {}) {
|
|
|
2870
3100
|
]
|
|
2871
3101
|
);
|
|
2872
3102
|
const startCapturing = react.useCallback(() => {
|
|
2873
|
-
if (consoleCapture && !
|
|
2874
|
-
|
|
3103
|
+
if (consoleCapture && !chunkWQSK3Z4K_cjs.isConsoleCaptureActive()) {
|
|
3104
|
+
chunkWQSK3Z4K_cjs.startConsoleCapture(consoleOptions);
|
|
2875
3105
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2876
3106
|
}
|
|
2877
|
-
if (network && !
|
|
2878
|
-
|
|
3107
|
+
if (network && !chunkWQSK3Z4K_cjs.isNetworkCaptureActive()) {
|
|
3108
|
+
chunkWQSK3Z4K_cjs.startNetworkCapture(networkOptions);
|
|
2879
3109
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2880
3110
|
}
|
|
2881
3111
|
}, [consoleCapture, network, consoleOptions, networkOptions]);
|
|
2882
3112
|
const stopCapturing = react.useCallback(() => {
|
|
2883
|
-
|
|
2884
|
-
|
|
3113
|
+
chunkWQSK3Z4K_cjs.stopConsoleCapture();
|
|
3114
|
+
chunkWQSK3Z4K_cjs.stopNetworkCapture();
|
|
2885
3115
|
setActiveCaptures({ console: false, network: false });
|
|
2886
3116
|
}, []);
|
|
2887
3117
|
const clearCaptured = react.useCallback(() => {
|
|
2888
|
-
|
|
2889
|
-
|
|
3118
|
+
chunkWQSK3Z4K_cjs.clearConsoleLogs();
|
|
3119
|
+
chunkWQSK3Z4K_cjs.clearNetworkRequests();
|
|
2890
3120
|
}, []);
|
|
2891
3121
|
const formatForAI = react.useCallback((context) => {
|
|
2892
3122
|
const parts = [];
|
|
@@ -2896,20 +3126,20 @@ function useAITools(options = {}) {
|
|
|
2896
3126
|
);
|
|
2897
3127
|
}
|
|
2898
3128
|
if (context.consoleLogs && context.consoleLogs.logs.length > 0) {
|
|
2899
|
-
parts.push(
|
|
3129
|
+
parts.push(chunkWQSK3Z4K_cjs.formatLogsForAI(context.consoleLogs.logs));
|
|
2900
3130
|
}
|
|
2901
3131
|
if (context.networkRequests && context.networkRequests.requests.length > 0) {
|
|
2902
|
-
parts.push(
|
|
3132
|
+
parts.push(chunkWQSK3Z4K_cjs.formatRequestsForAI(context.networkRequests.requests));
|
|
2903
3133
|
}
|
|
2904
3134
|
return parts.length > 0 ? parts.join("\n\n---\n\n") : "No context captured.";
|
|
2905
3135
|
}, []);
|
|
2906
3136
|
const detectIntentFn = react.useCallback(
|
|
2907
3137
|
(message) => {
|
|
2908
|
-
const result =
|
|
2909
|
-
result.suggestedTools = result.suggestedTools.filter((
|
|
2910
|
-
if (
|
|
2911
|
-
if (
|
|
2912
|
-
if (
|
|
3138
|
+
const result = chunkWQSK3Z4K_cjs.detectIntent(message);
|
|
3139
|
+
result.suggestedTools = result.suggestedTools.filter((tool2) => {
|
|
3140
|
+
if (tool2 === "screenshot") return screenshot;
|
|
3141
|
+
if (tool2 === "console") return consoleCapture;
|
|
3142
|
+
if (tool2 === "network") return network;
|
|
2913
3143
|
return false;
|
|
2914
3144
|
});
|
|
2915
3145
|
return result;
|
|
@@ -2956,7 +3186,7 @@ function useTool(config, dependencies = []) {
|
|
|
2956
3186
|
const configRef = react.useRef(config);
|
|
2957
3187
|
configRef.current = config;
|
|
2958
3188
|
react.useEffect(() => {
|
|
2959
|
-
const
|
|
3189
|
+
const tool2 = {
|
|
2960
3190
|
name: config.name,
|
|
2961
3191
|
description: config.description,
|
|
2962
3192
|
location: "client",
|
|
@@ -2970,7 +3200,7 @@ function useTool(config, dependencies = []) {
|
|
|
2970
3200
|
approvalMessage: config.approvalMessage,
|
|
2971
3201
|
hidden: config.hidden
|
|
2972
3202
|
};
|
|
2973
|
-
registerTool(
|
|
3203
|
+
registerTool(tool2);
|
|
2974
3204
|
return () => {
|
|
2975
3205
|
unregisterTool(config.name);
|
|
2976
3206
|
};
|
|
@@ -3020,7 +3250,7 @@ function convertZodSchema(schema, _toolName) {
|
|
|
3020
3250
|
}
|
|
3021
3251
|
} catch {
|
|
3022
3252
|
}
|
|
3023
|
-
return
|
|
3253
|
+
return chunkWQSK3Z4K_cjs.zodObjectToInputSchema(schema);
|
|
3024
3254
|
}
|
|
3025
3255
|
function useToolWithSchema(config, dependencies = []) {
|
|
3026
3256
|
const { registerTool, unregisterTool } = useCopilot();
|
|
@@ -3041,7 +3271,7 @@ function useToolWithSchema(config, dependencies = []) {
|
|
|
3041
3271
|
}
|
|
3042
3272
|
}, [config.schema, config.name]);
|
|
3043
3273
|
react.useEffect(() => {
|
|
3044
|
-
const
|
|
3274
|
+
const tool2 = {
|
|
3045
3275
|
name: config.name,
|
|
3046
3276
|
description: config.description,
|
|
3047
3277
|
location: "client",
|
|
@@ -3052,7 +3282,7 @@ function useToolWithSchema(config, dependencies = []) {
|
|
|
3052
3282
|
render: config.render,
|
|
3053
3283
|
available: config.available ?? true
|
|
3054
3284
|
};
|
|
3055
|
-
registerTool(
|
|
3285
|
+
registerTool(tool2);
|
|
3056
3286
|
return () => {
|
|
3057
3287
|
unregisterTool(config.name);
|
|
3058
3288
|
};
|
|
@@ -3075,7 +3305,7 @@ function useToolsWithSchema(tools, dependencies = []) {
|
|
|
3075
3305
|
);
|
|
3076
3306
|
inputSchema = { type: "object", properties: {} };
|
|
3077
3307
|
}
|
|
3078
|
-
const
|
|
3308
|
+
const tool2 = {
|
|
3079
3309
|
name: config.name,
|
|
3080
3310
|
description: config.description,
|
|
3081
3311
|
location: "client",
|
|
@@ -3091,7 +3321,7 @@ function useToolsWithSchema(tools, dependencies = []) {
|
|
|
3091
3321
|
},
|
|
3092
3322
|
available: config.available ?? true
|
|
3093
3323
|
};
|
|
3094
|
-
registerTool(
|
|
3324
|
+
registerTool(tool2);
|
|
3095
3325
|
toolNames.push(config.name);
|
|
3096
3326
|
}
|
|
3097
3327
|
return () => {
|
|
@@ -3123,14 +3353,14 @@ function useToolExecutor() {
|
|
|
3123
3353
|
toolsRef.current = registeredTools;
|
|
3124
3354
|
const executeTool = react.useCallback(
|
|
3125
3355
|
async (toolCall) => {
|
|
3126
|
-
const
|
|
3127
|
-
if (!
|
|
3356
|
+
const tool2 = toolsRef.current.find((t) => t.name === toolCall.name);
|
|
3357
|
+
if (!tool2) {
|
|
3128
3358
|
return {
|
|
3129
3359
|
success: false,
|
|
3130
3360
|
error: `Unknown tool: ${toolCall.name}`
|
|
3131
3361
|
};
|
|
3132
3362
|
}
|
|
3133
|
-
if (!
|
|
3363
|
+
if (!tool2.handler) {
|
|
3134
3364
|
return {
|
|
3135
3365
|
success: false,
|
|
3136
3366
|
error: `Tool "${toolCall.name}" has no handler`
|
|
@@ -3142,12 +3372,13 @@ function useToolExecutor() {
|
|
|
3142
3372
|
args: toolCall.input,
|
|
3143
3373
|
status: "executing",
|
|
3144
3374
|
timestamp: Date.now(),
|
|
3145
|
-
approvalStatus: "none"
|
|
3375
|
+
approvalStatus: "none",
|
|
3376
|
+
hidden: tool2.hidden
|
|
3146
3377
|
};
|
|
3147
3378
|
addToolExecution?.(execution);
|
|
3148
3379
|
try {
|
|
3149
3380
|
const startTime = Date.now();
|
|
3150
|
-
const result = await
|
|
3381
|
+
const result = await tool2.handler(toolCall.input);
|
|
3151
3382
|
const duration = Date.now() - startTime;
|
|
3152
3383
|
updateToolExecution?.(toolCall.id, {
|
|
3153
3384
|
status: result.success ? "completed" : "error",
|
|
@@ -3328,7 +3559,7 @@ function useAgent(options) {
|
|
|
3328
3559
|
if (!response.ok) {
|
|
3329
3560
|
throw new Error(`Agent error: ${response.status}`);
|
|
3330
3561
|
}
|
|
3331
|
-
for await (const event of
|
|
3562
|
+
for await (const event of chunkWQSK3Z4K_cjs.streamSSE(response)) {
|
|
3332
3563
|
handleAgentEvent(event);
|
|
3333
3564
|
}
|
|
3334
3565
|
} catch (err) {
|
|
@@ -3622,9 +3853,9 @@ function useDevLogger() {
|
|
|
3622
3853
|
})
|
|
3623
3854
|
);
|
|
3624
3855
|
const pendingApprovalsCount = ctx.pendingApprovals?.length || 0;
|
|
3625
|
-
const registeredTools = (ctx.registeredTools || []).map((
|
|
3626
|
-
name:
|
|
3627
|
-
location:
|
|
3856
|
+
const registeredTools = (ctx.registeredTools || []).map((tool2) => ({
|
|
3857
|
+
name: tool2.name,
|
|
3858
|
+
location: tool2.location || "client"
|
|
3628
3859
|
}));
|
|
3629
3860
|
const registeredActions = (ctx.registeredActions || []).map((action) => ({
|
|
3630
3861
|
name: action.name
|
|
@@ -3822,7 +4053,7 @@ function createReactThreadManagerState(initialThreads) {
|
|
|
3822
4053
|
}
|
|
3823
4054
|
|
|
3824
4055
|
// src/react/internal/ReactThreadManager.ts
|
|
3825
|
-
var _ReactThreadManager = class _ReactThreadManager extends
|
|
4056
|
+
var _ReactThreadManager = class _ReactThreadManager extends chunkWQSK3Z4K_cjs.ThreadManager {
|
|
3826
4057
|
constructor(config = {}, callbacks = {}) {
|
|
3827
4058
|
const reactState = new ReactThreadManagerState();
|
|
3828
4059
|
super({ ...config, state: reactState }, callbacks);
|
|
@@ -4489,5 +4720,5 @@ exports.useToolExecutor = useToolExecutor;
|
|
|
4489
4720
|
exports.useToolWithSchema = useToolWithSchema;
|
|
4490
4721
|
exports.useTools = useTools;
|
|
4491
4722
|
exports.useToolsWithSchema = useToolsWithSchema;
|
|
4492
|
-
//# sourceMappingURL=chunk-
|
|
4493
|
-
//# sourceMappingURL=chunk-
|
|
4723
|
+
//# sourceMappingURL=chunk-R6LKHKAI.cjs.map
|
|
4724
|
+
//# sourceMappingURL=chunk-R6LKHKAI.cjs.map
|