@yourgpt/copilot-sdk 1.4.1 → 1.4.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-T6W2Y3D6.js → chunk-55EABH45.js} +127 -68
- package/dist/chunk-55EABH45.js.map +1 -0
- package/dist/{chunk-I623CRO4.cjs → chunk-CVKN4H62.cjs} +127 -68
- package/dist/chunk-CVKN4H62.cjs.map +1 -0
- package/dist/{chunk-7JQ5GJSK.js → chunk-ILVX5S3Y.js} +21 -5
- package/dist/chunk-ILVX5S3Y.js.map +1 -0
- package/dist/{chunk-KRZXN5KV.cjs → chunk-N24PPVNQ.cjs} +45 -29
- package/dist/chunk-N24PPVNQ.cjs.map +1 -0
- package/dist/core/index.cjs +76 -76
- package/dist/core/index.d.cts +8 -6
- package/dist/core/index.d.ts +8 -6
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +42 -42
- package/dist/react/index.d.cts +3 -2
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +2 -2
- package/dist/ui/index.cjs +7 -7
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/index.js.map +1 -1
- package/package.json +7 -6
- package/dist/chunk-7JQ5GJSK.js.map +0 -1
- package/dist/chunk-I623CRO4.cjs.map +0 -1
- package/dist/chunk-KRZXN5KV.cjs.map +0 -1
- package/dist/chunk-T6W2Y3D6.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCVKN4H62_cjs = require('./chunk-CVKN4H62.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var z = require('zod');
|
|
@@ -438,6 +438,7 @@ var AbstractChat = class {
|
|
|
438
438
|
* Dynamic context from useAIContext hook
|
|
439
439
|
*/
|
|
440
440
|
this.dynamicContext = "";
|
|
441
|
+
this.isDisposed = false;
|
|
441
442
|
this.config = {
|
|
442
443
|
runtimeUrl: init.runtimeUrl,
|
|
443
444
|
llm: init.llm,
|
|
@@ -674,6 +675,10 @@ var AbstractChat = class {
|
|
|
674
675
|
*/
|
|
675
676
|
emit(type, data) {
|
|
676
677
|
const event = { type, ...data };
|
|
678
|
+
const handlers = this.eventHandlers.get(type);
|
|
679
|
+
if (type === "toolCalls") {
|
|
680
|
+
this.debug(`emit(toolCalls): ${handlers?.size || 0} handlers registered`);
|
|
681
|
+
}
|
|
677
682
|
this.eventHandlers.get(type)?.forEach((handler) => handler(event));
|
|
678
683
|
}
|
|
679
684
|
// ============================================
|
|
@@ -716,7 +721,7 @@ var AbstractChat = class {
|
|
|
716
721
|
* Build the request payload
|
|
717
722
|
*/
|
|
718
723
|
buildRequest() {
|
|
719
|
-
const tools = this.config.tools?.map((tool) => ({
|
|
724
|
+
const tools = this.config.tools?.filter((tool) => tool.available !== false).map((tool) => ({
|
|
720
725
|
name: tool.name,
|
|
721
726
|
description: tool.description,
|
|
722
727
|
inputSchema: tool.inputSchema
|
|
@@ -905,6 +910,12 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
|
|
|
905
910
|
* Dispose and cleanup
|
|
906
911
|
*/
|
|
907
912
|
dispose() {
|
|
913
|
+
if (this.isDisposed) {
|
|
914
|
+
this.debug("dispose() called but already disposed - ignoring");
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
this.debug("dispose() - clearing event handlers");
|
|
918
|
+
this.isDisposed = true;
|
|
908
919
|
this.stop();
|
|
909
920
|
this.eventHandlers.clear();
|
|
910
921
|
}
|
|
@@ -1339,9 +1350,14 @@ var ChatWithTools = class {
|
|
|
1339
1350
|
* Wire up internal events between chat and agent loop
|
|
1340
1351
|
*/
|
|
1341
1352
|
wireEvents() {
|
|
1353
|
+
this.debug("Wiring up toolCalls event handler");
|
|
1342
1354
|
this.chat.on("toolCalls", async (event) => {
|
|
1355
|
+
this.debug("\u{1F3AF} toolCalls event handler FIRED", event);
|
|
1343
1356
|
const toolCalls = event.toolCalls;
|
|
1344
|
-
if (!toolCalls?.length)
|
|
1357
|
+
if (!toolCalls?.length) {
|
|
1358
|
+
this.debug("No tool calls in event");
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1345
1361
|
this.debug("Tool calls received:", toolCalls);
|
|
1346
1362
|
const toolCallInfos = toolCalls.map((tc) => {
|
|
1347
1363
|
const tcAny = tc;
|
|
@@ -2148,17 +2164,17 @@ function useAITools(options = {}) {
|
|
|
2148
2164
|
const rememberedConsentRef = react.useRef(/* @__PURE__ */ new Set());
|
|
2149
2165
|
react.useEffect(() => {
|
|
2150
2166
|
if (!autoStart || !isEnabled) return;
|
|
2151
|
-
if (consoleCapture && !
|
|
2152
|
-
|
|
2167
|
+
if (consoleCapture && !chunkCVKN4H62_cjs.isConsoleCaptureActive()) {
|
|
2168
|
+
chunkCVKN4H62_cjs.startConsoleCapture(consoleOptions);
|
|
2153
2169
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2154
2170
|
}
|
|
2155
|
-
if (network && !
|
|
2156
|
-
|
|
2171
|
+
if (network && !chunkCVKN4H62_cjs.isNetworkCaptureActive()) {
|
|
2172
|
+
chunkCVKN4H62_cjs.startNetworkCapture(networkOptions);
|
|
2157
2173
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2158
2174
|
}
|
|
2159
2175
|
return () => {
|
|
2160
|
-
|
|
2161
|
-
|
|
2176
|
+
chunkCVKN4H62_cjs.stopConsoleCapture();
|
|
2177
|
+
chunkCVKN4H62_cjs.stopNetworkCapture();
|
|
2162
2178
|
};
|
|
2163
2179
|
}, [
|
|
2164
2180
|
autoStart,
|
|
@@ -2173,12 +2189,12 @@ function useAITools(options = {}) {
|
|
|
2173
2189
|
if (!screenshot) {
|
|
2174
2190
|
throw new Error("Screenshot capture is not enabled");
|
|
2175
2191
|
}
|
|
2176
|
-
if (!
|
|
2192
|
+
if (!chunkCVKN4H62_cjs.isScreenshotSupported()) {
|
|
2177
2193
|
throw new Error(
|
|
2178
2194
|
"Screenshot capture is not supported in this environment"
|
|
2179
2195
|
);
|
|
2180
2196
|
}
|
|
2181
|
-
return
|
|
2197
|
+
return chunkCVKN4H62_cjs.captureScreenshot({ ...screenshotOptions, ...opts });
|
|
2182
2198
|
},
|
|
2183
2199
|
[screenshot, screenshotOptions]
|
|
2184
2200
|
);
|
|
@@ -2187,7 +2203,7 @@ function useAITools(options = {}) {
|
|
|
2187
2203
|
if (!consoleCapture) {
|
|
2188
2204
|
return { logs: [], totalCaptured: 0 };
|
|
2189
2205
|
}
|
|
2190
|
-
return
|
|
2206
|
+
return chunkCVKN4H62_cjs.getConsoleLogs({ ...consoleOptions, ...opts });
|
|
2191
2207
|
},
|
|
2192
2208
|
[consoleCapture, consoleOptions]
|
|
2193
2209
|
);
|
|
@@ -2196,7 +2212,7 @@ function useAITools(options = {}) {
|
|
|
2196
2212
|
if (!network) {
|
|
2197
2213
|
return { requests: [], totalCaptured: 0 };
|
|
2198
2214
|
}
|
|
2199
|
-
return
|
|
2215
|
+
return chunkCVKN4H62_cjs.getNetworkRequests({ ...networkOptions, ...opts });
|
|
2200
2216
|
},
|
|
2201
2217
|
[network, networkOptions]
|
|
2202
2218
|
);
|
|
@@ -2289,23 +2305,23 @@ function useAITools(options = {}) {
|
|
|
2289
2305
|
]
|
|
2290
2306
|
);
|
|
2291
2307
|
const startCapturing = react.useCallback(() => {
|
|
2292
|
-
if (consoleCapture && !
|
|
2293
|
-
|
|
2308
|
+
if (consoleCapture && !chunkCVKN4H62_cjs.isConsoleCaptureActive()) {
|
|
2309
|
+
chunkCVKN4H62_cjs.startConsoleCapture(consoleOptions);
|
|
2294
2310
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2295
2311
|
}
|
|
2296
|
-
if (network && !
|
|
2297
|
-
|
|
2312
|
+
if (network && !chunkCVKN4H62_cjs.isNetworkCaptureActive()) {
|
|
2313
|
+
chunkCVKN4H62_cjs.startNetworkCapture(networkOptions);
|
|
2298
2314
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2299
2315
|
}
|
|
2300
2316
|
}, [consoleCapture, network, consoleOptions, networkOptions]);
|
|
2301
2317
|
const stopCapturing = react.useCallback(() => {
|
|
2302
|
-
|
|
2303
|
-
|
|
2318
|
+
chunkCVKN4H62_cjs.stopConsoleCapture();
|
|
2319
|
+
chunkCVKN4H62_cjs.stopNetworkCapture();
|
|
2304
2320
|
setActiveCaptures({ console: false, network: false });
|
|
2305
2321
|
}, []);
|
|
2306
2322
|
const clearCaptured = react.useCallback(() => {
|
|
2307
|
-
|
|
2308
|
-
|
|
2323
|
+
chunkCVKN4H62_cjs.clearConsoleLogs();
|
|
2324
|
+
chunkCVKN4H62_cjs.clearNetworkRequests();
|
|
2309
2325
|
}, []);
|
|
2310
2326
|
const formatForAI = react.useCallback((context) => {
|
|
2311
2327
|
const parts = [];
|
|
@@ -2315,16 +2331,16 @@ function useAITools(options = {}) {
|
|
|
2315
2331
|
);
|
|
2316
2332
|
}
|
|
2317
2333
|
if (context.consoleLogs && context.consoleLogs.logs.length > 0) {
|
|
2318
|
-
parts.push(
|
|
2334
|
+
parts.push(chunkCVKN4H62_cjs.formatLogsForAI(context.consoleLogs.logs));
|
|
2319
2335
|
}
|
|
2320
2336
|
if (context.networkRequests && context.networkRequests.requests.length > 0) {
|
|
2321
|
-
parts.push(
|
|
2337
|
+
parts.push(chunkCVKN4H62_cjs.formatRequestsForAI(context.networkRequests.requests));
|
|
2322
2338
|
}
|
|
2323
2339
|
return parts.length > 0 ? parts.join("\n\n---\n\n") : "No context captured.";
|
|
2324
2340
|
}, []);
|
|
2325
2341
|
const detectIntentFn = react.useCallback(
|
|
2326
2342
|
(message) => {
|
|
2327
|
-
const result =
|
|
2343
|
+
const result = chunkCVKN4H62_cjs.detectIntent(message);
|
|
2328
2344
|
result.suggestedTools = result.suggestedTools.filter((tool) => {
|
|
2329
2345
|
if (tool === "screenshot") return screenshot;
|
|
2330
2346
|
if (tool === "console") return consoleCapture;
|
|
@@ -2448,7 +2464,7 @@ function convertZodSchema(schema, _toolName) {
|
|
|
2448
2464
|
}
|
|
2449
2465
|
} catch {
|
|
2450
2466
|
}
|
|
2451
|
-
return
|
|
2467
|
+
return chunkCVKN4H62_cjs.zodObjectToInputSchema(schema);
|
|
2452
2468
|
}
|
|
2453
2469
|
function useToolWithSchema(config, dependencies = []) {
|
|
2454
2470
|
const { registerTool, unregisterTool } = useCopilotContext();
|
|
@@ -2746,7 +2762,7 @@ function useAgent(options) {
|
|
|
2746
2762
|
if (!response.ok) {
|
|
2747
2763
|
throw new Error(`Agent error: ${response.status}`);
|
|
2748
2764
|
}
|
|
2749
|
-
for await (const event of
|
|
2765
|
+
for await (const event of chunkCVKN4H62_cjs.streamSSE(response)) {
|
|
2750
2766
|
handleAgentEvent(event);
|
|
2751
2767
|
}
|
|
2752
2768
|
} catch (err) {
|
|
@@ -3240,7 +3256,7 @@ function createReactThreadManagerState(initialThreads) {
|
|
|
3240
3256
|
}
|
|
3241
3257
|
|
|
3242
3258
|
// src/react/internal/ReactThreadManager.ts
|
|
3243
|
-
var _ReactThreadManager = class _ReactThreadManager extends
|
|
3259
|
+
var _ReactThreadManager = class _ReactThreadManager extends chunkCVKN4H62_cjs.ThreadManager {
|
|
3244
3260
|
constructor(config = {}, callbacks = {}) {
|
|
3245
3261
|
const reactState = new ReactThreadManagerState();
|
|
3246
3262
|
super({ ...config, state: reactState }, callbacks);
|
|
@@ -3800,5 +3816,5 @@ exports.useToolExecutor = useToolExecutor;
|
|
|
3800
3816
|
exports.useToolWithSchema = useToolWithSchema;
|
|
3801
3817
|
exports.useTools = useTools;
|
|
3802
3818
|
exports.useToolsWithSchema = useToolsWithSchema;
|
|
3803
|
-
//# sourceMappingURL=chunk-
|
|
3804
|
-
//# sourceMappingURL=chunk-
|
|
3819
|
+
//# sourceMappingURL=chunk-N24PPVNQ.cjs.map
|
|
3820
|
+
//# sourceMappingURL=chunk-N24PPVNQ.cjs.map
|