@yourgpt/copilot-sdk 1.4.32 → 1.4.33
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/README.md +7 -1
- package/dist/{chunk-CVKN4H62.cjs → chunk-4PRWNAXQ.cjs} +161 -52
- package/dist/chunk-4PRWNAXQ.cjs.map +1 -0
- package/dist/{chunk-B7SF5SGS.cjs → chunk-BLSI67J6.cjs} +40 -40
- package/dist/chunk-BLSI67J6.cjs.map +1 -0
- package/dist/{chunk-VZ4RYZQT.js → chunk-CJ7UWN2Y.js} +16 -16
- package/dist/chunk-CJ7UWN2Y.js.map +1 -0
- package/dist/{chunk-55EABH45.js → chunk-JM7PB2LP.js} +161 -52
- package/dist/chunk-JM7PB2LP.js.map +1 -0
- package/dist/core/index.cjs +76 -76
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +42 -42
- package/dist/react/index.js +2 -2
- package/dist/ui/index.cjs +6 -6
- package/dist/ui/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-55EABH45.js.map +0 -1
- package/dist/chunk-B7SF5SGS.cjs.map +0 -1
- package/dist/chunk-CVKN4H62.cjs.map +0 -1
- package/dist/chunk-VZ4RYZQT.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4PRWNAXQ_cjs = require('./chunk-4PRWNAXQ.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var z = require('zod');
|
|
@@ -2258,17 +2258,17 @@ function useAITools(options = {}) {
|
|
|
2258
2258
|
const rememberedConsentRef = react.useRef(/* @__PURE__ */ new Set());
|
|
2259
2259
|
react.useEffect(() => {
|
|
2260
2260
|
if (!autoStart || !isEnabled) return;
|
|
2261
|
-
if (consoleCapture && !
|
|
2262
|
-
|
|
2261
|
+
if (consoleCapture && !chunk4PRWNAXQ_cjs.isConsoleCaptureActive()) {
|
|
2262
|
+
chunk4PRWNAXQ_cjs.startConsoleCapture(consoleOptions);
|
|
2263
2263
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2264
2264
|
}
|
|
2265
|
-
if (network && !
|
|
2266
|
-
|
|
2265
|
+
if (network && !chunk4PRWNAXQ_cjs.isNetworkCaptureActive()) {
|
|
2266
|
+
chunk4PRWNAXQ_cjs.startNetworkCapture(networkOptions);
|
|
2267
2267
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2268
2268
|
}
|
|
2269
2269
|
return () => {
|
|
2270
|
-
|
|
2271
|
-
|
|
2270
|
+
chunk4PRWNAXQ_cjs.stopConsoleCapture();
|
|
2271
|
+
chunk4PRWNAXQ_cjs.stopNetworkCapture();
|
|
2272
2272
|
};
|
|
2273
2273
|
}, [
|
|
2274
2274
|
autoStart,
|
|
@@ -2283,12 +2283,12 @@ function useAITools(options = {}) {
|
|
|
2283
2283
|
if (!screenshot) {
|
|
2284
2284
|
throw new Error("Screenshot capture is not enabled");
|
|
2285
2285
|
}
|
|
2286
|
-
if (!
|
|
2286
|
+
if (!chunk4PRWNAXQ_cjs.isScreenshotSupported()) {
|
|
2287
2287
|
throw new Error(
|
|
2288
2288
|
"Screenshot capture is not supported in this environment"
|
|
2289
2289
|
);
|
|
2290
2290
|
}
|
|
2291
|
-
return
|
|
2291
|
+
return chunk4PRWNAXQ_cjs.captureScreenshot({ ...screenshotOptions, ...opts });
|
|
2292
2292
|
},
|
|
2293
2293
|
[screenshot, screenshotOptions]
|
|
2294
2294
|
);
|
|
@@ -2297,7 +2297,7 @@ function useAITools(options = {}) {
|
|
|
2297
2297
|
if (!consoleCapture) {
|
|
2298
2298
|
return { logs: [], totalCaptured: 0 };
|
|
2299
2299
|
}
|
|
2300
|
-
return
|
|
2300
|
+
return chunk4PRWNAXQ_cjs.getConsoleLogs({ ...consoleOptions, ...opts });
|
|
2301
2301
|
},
|
|
2302
2302
|
[consoleCapture, consoleOptions]
|
|
2303
2303
|
);
|
|
@@ -2306,7 +2306,7 @@ function useAITools(options = {}) {
|
|
|
2306
2306
|
if (!network) {
|
|
2307
2307
|
return { requests: [], totalCaptured: 0 };
|
|
2308
2308
|
}
|
|
2309
|
-
return
|
|
2309
|
+
return chunk4PRWNAXQ_cjs.getNetworkRequests({ ...networkOptions, ...opts });
|
|
2310
2310
|
},
|
|
2311
2311
|
[network, networkOptions]
|
|
2312
2312
|
);
|
|
@@ -2399,23 +2399,23 @@ function useAITools(options = {}) {
|
|
|
2399
2399
|
]
|
|
2400
2400
|
);
|
|
2401
2401
|
const startCapturing = react.useCallback(() => {
|
|
2402
|
-
if (consoleCapture && !
|
|
2403
|
-
|
|
2402
|
+
if (consoleCapture && !chunk4PRWNAXQ_cjs.isConsoleCaptureActive()) {
|
|
2403
|
+
chunk4PRWNAXQ_cjs.startConsoleCapture(consoleOptions);
|
|
2404
2404
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2405
2405
|
}
|
|
2406
|
-
if (network && !
|
|
2407
|
-
|
|
2406
|
+
if (network && !chunk4PRWNAXQ_cjs.isNetworkCaptureActive()) {
|
|
2407
|
+
chunk4PRWNAXQ_cjs.startNetworkCapture(networkOptions);
|
|
2408
2408
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2409
2409
|
}
|
|
2410
2410
|
}, [consoleCapture, network, consoleOptions, networkOptions]);
|
|
2411
2411
|
const stopCapturing = react.useCallback(() => {
|
|
2412
|
-
|
|
2413
|
-
|
|
2412
|
+
chunk4PRWNAXQ_cjs.stopConsoleCapture();
|
|
2413
|
+
chunk4PRWNAXQ_cjs.stopNetworkCapture();
|
|
2414
2414
|
setActiveCaptures({ console: false, network: false });
|
|
2415
2415
|
}, []);
|
|
2416
2416
|
const clearCaptured = react.useCallback(() => {
|
|
2417
|
-
|
|
2418
|
-
|
|
2417
|
+
chunk4PRWNAXQ_cjs.clearConsoleLogs();
|
|
2418
|
+
chunk4PRWNAXQ_cjs.clearNetworkRequests();
|
|
2419
2419
|
}, []);
|
|
2420
2420
|
const formatForAI = react.useCallback((context) => {
|
|
2421
2421
|
const parts = [];
|
|
@@ -2425,16 +2425,16 @@ function useAITools(options = {}) {
|
|
|
2425
2425
|
);
|
|
2426
2426
|
}
|
|
2427
2427
|
if (context.consoleLogs && context.consoleLogs.logs.length > 0) {
|
|
2428
|
-
parts.push(
|
|
2428
|
+
parts.push(chunk4PRWNAXQ_cjs.formatLogsForAI(context.consoleLogs.logs));
|
|
2429
2429
|
}
|
|
2430
2430
|
if (context.networkRequests && context.networkRequests.requests.length > 0) {
|
|
2431
|
-
parts.push(
|
|
2431
|
+
parts.push(chunk4PRWNAXQ_cjs.formatRequestsForAI(context.networkRequests.requests));
|
|
2432
2432
|
}
|
|
2433
2433
|
return parts.length > 0 ? parts.join("\n\n---\n\n") : "No context captured.";
|
|
2434
2434
|
}, []);
|
|
2435
2435
|
const detectIntentFn = react.useCallback(
|
|
2436
2436
|
(message) => {
|
|
2437
|
-
const result =
|
|
2437
|
+
const result = chunk4PRWNAXQ_cjs.detectIntent(message);
|
|
2438
2438
|
result.suggestedTools = result.suggestedTools.filter((tool) => {
|
|
2439
2439
|
if (tool === "screenshot") return screenshot;
|
|
2440
2440
|
if (tool === "console") return consoleCapture;
|
|
@@ -2531,16 +2531,6 @@ function useTools(tools) {
|
|
|
2531
2531
|
};
|
|
2532
2532
|
}, [toolsKey]);
|
|
2533
2533
|
}
|
|
2534
|
-
var CopilotContext2 = react.createContext(null);
|
|
2535
|
-
function useCopilotContext() {
|
|
2536
|
-
const context = react.useContext(CopilotContext2);
|
|
2537
|
-
if (!context) {
|
|
2538
|
-
throw new Error("useCopilotContext must be used within a CopilotProvider");
|
|
2539
|
-
}
|
|
2540
|
-
return context;
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
// src/react/hooks/useToolWithSchema.ts
|
|
2544
2534
|
function convertZodSchema(schema, _toolName) {
|
|
2545
2535
|
try {
|
|
2546
2536
|
const zodWithJsonSchema = z__namespace;
|
|
@@ -2558,10 +2548,10 @@ function convertZodSchema(schema, _toolName) {
|
|
|
2558
2548
|
}
|
|
2559
2549
|
} catch {
|
|
2560
2550
|
}
|
|
2561
|
-
return
|
|
2551
|
+
return chunk4PRWNAXQ_cjs.zodObjectToInputSchema(schema);
|
|
2562
2552
|
}
|
|
2563
2553
|
function useToolWithSchema(config, dependencies = []) {
|
|
2564
|
-
const { registerTool, unregisterTool } =
|
|
2554
|
+
const { registerTool, unregisterTool } = useCopilot();
|
|
2565
2555
|
const configRef = react.useRef(config);
|
|
2566
2556
|
configRef.current = config;
|
|
2567
2557
|
const inputSchema = react.useMemo(() => {
|
|
@@ -2597,7 +2587,7 @@ function useToolWithSchema(config, dependencies = []) {
|
|
|
2597
2587
|
}, [config.name, inputSchema, ...dependencies]);
|
|
2598
2588
|
}
|
|
2599
2589
|
function useToolsWithSchema(tools, dependencies = []) {
|
|
2600
|
-
const { registerTool, unregisterTool } =
|
|
2590
|
+
const { registerTool, unregisterTool } = useCopilot();
|
|
2601
2591
|
const toolsRef = react.useRef(tools);
|
|
2602
2592
|
toolsRef.current = tools;
|
|
2603
2593
|
react.useEffect(() => {
|
|
@@ -2639,6 +2629,16 @@ function useToolsWithSchema(tools, dependencies = []) {
|
|
|
2639
2629
|
};
|
|
2640
2630
|
}, [tools.map((t) => t.name).join(","), ...dependencies]);
|
|
2641
2631
|
}
|
|
2632
|
+
var CopilotContext2 = react.createContext(null);
|
|
2633
|
+
function useCopilotContext() {
|
|
2634
|
+
const context = react.useContext(CopilotContext2);
|
|
2635
|
+
if (!context) {
|
|
2636
|
+
throw new Error("useCopilotContext must be used within a CopilotProvider");
|
|
2637
|
+
}
|
|
2638
|
+
return context;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
// src/react/hooks/useToolExecutor.ts
|
|
2642
2642
|
function useToolExecutor() {
|
|
2643
2643
|
const {
|
|
2644
2644
|
registeredTools,
|
|
@@ -2856,7 +2856,7 @@ function useAgent(options) {
|
|
|
2856
2856
|
if (!response.ok) {
|
|
2857
2857
|
throw new Error(`Agent error: ${response.status}`);
|
|
2858
2858
|
}
|
|
2859
|
-
for await (const event of
|
|
2859
|
+
for await (const event of chunk4PRWNAXQ_cjs.streamSSE(response)) {
|
|
2860
2860
|
handleAgentEvent(event);
|
|
2861
2861
|
}
|
|
2862
2862
|
} catch (err) {
|
|
@@ -2979,7 +2979,7 @@ function formatKnowledgeResultsForAI(results) {
|
|
|
2979
2979
|
|
|
2980
2980
|
// src/react/hooks/useKnowledgeBase.ts
|
|
2981
2981
|
function useKnowledgeBase(config) {
|
|
2982
|
-
const { registerTool, unregisterTool } =
|
|
2982
|
+
const { registerTool, unregisterTool } = useCopilot();
|
|
2983
2983
|
const configRef = react.useRef(config);
|
|
2984
2984
|
configRef.current = config;
|
|
2985
2985
|
const handleSearch = react.useCallback(
|
|
@@ -3350,7 +3350,7 @@ function createReactThreadManagerState(initialThreads) {
|
|
|
3350
3350
|
}
|
|
3351
3351
|
|
|
3352
3352
|
// src/react/internal/ReactThreadManager.ts
|
|
3353
|
-
var _ReactThreadManager = class _ReactThreadManager extends
|
|
3353
|
+
var _ReactThreadManager = class _ReactThreadManager extends chunk4PRWNAXQ_cjs.ThreadManager {
|
|
3354
3354
|
constructor(config = {}, callbacks = {}) {
|
|
3355
3355
|
const reactState = new ReactThreadManagerState();
|
|
3356
3356
|
super({ ...config, state: reactState }, callbacks);
|
|
@@ -3920,5 +3920,5 @@ exports.useToolExecutor = useToolExecutor;
|
|
|
3920
3920
|
exports.useToolWithSchema = useToolWithSchema;
|
|
3921
3921
|
exports.useTools = useTools;
|
|
3922
3922
|
exports.useToolsWithSchema = useToolsWithSchema;
|
|
3923
|
-
//# sourceMappingURL=chunk-
|
|
3924
|
-
//# sourceMappingURL=chunk-
|
|
3923
|
+
//# sourceMappingURL=chunk-BLSI67J6.cjs.map
|
|
3924
|
+
//# sourceMappingURL=chunk-BLSI67J6.cjs.map
|