@yourgpt/copilot-sdk 2.1.3 → 2.1.4
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-VFV5FVVI.js → chunk-37KEHUCE.js} +12 -8
- package/dist/chunk-37KEHUCE.js.map +1 -0
- package/dist/{chunk-DMBFN7KO.js → chunk-7PKGRYHY.js} +16 -5
- package/dist/chunk-7PKGRYHY.js.map +1 -0
- package/dist/{chunk-R6LKHKAI.cjs → chunk-N6VZ7FOW.cjs} +40 -29
- package/dist/chunk-N6VZ7FOW.cjs.map +1 -0
- package/dist/{chunk-WQSK3Z4K.cjs → chunk-OQPRIB73.cjs} +12 -8
- package/dist/chunk-OQPRIB73.cjs.map +1 -0
- package/dist/core/index.cjs +70 -70
- package/dist/core/index.d.cts +16 -5
- package/dist/core/index.d.ts +16 -5
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +47 -47
- package/dist/react/index.d.cts +30 -13
- package/dist/react/index.d.ts +30 -13
- 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-DMBFN7KO.js.map +0 -1
- package/dist/chunk-R6LKHKAI.cjs.map +0 -1
- package/dist/chunk-VFV5FVVI.js.map +0 -1
- package/dist/chunk-WQSK3Z4K.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOQPRIB73_cjs = require('./chunk-OQPRIB73.cjs');
|
|
4
4
|
var chunkJGPDQDY4_cjs = require('./chunk-JGPDQDY4.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -2959,17 +2959,17 @@ function useAITools(options = {}) {
|
|
|
2959
2959
|
const rememberedConsentRef = react.useRef(/* @__PURE__ */ new Set());
|
|
2960
2960
|
react.useEffect(() => {
|
|
2961
2961
|
if (!autoStart || !isEnabled) return;
|
|
2962
|
-
if (consoleCapture && !
|
|
2963
|
-
|
|
2962
|
+
if (consoleCapture && !chunkOQPRIB73_cjs.isConsoleCaptureActive()) {
|
|
2963
|
+
chunkOQPRIB73_cjs.startConsoleCapture(consoleOptions);
|
|
2964
2964
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
2965
2965
|
}
|
|
2966
|
-
if (network && !
|
|
2967
|
-
|
|
2966
|
+
if (network && !chunkOQPRIB73_cjs.isNetworkCaptureActive()) {
|
|
2967
|
+
chunkOQPRIB73_cjs.startNetworkCapture(networkOptions);
|
|
2968
2968
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
2969
2969
|
}
|
|
2970
2970
|
return () => {
|
|
2971
|
-
|
|
2972
|
-
|
|
2971
|
+
chunkOQPRIB73_cjs.stopConsoleCapture();
|
|
2972
|
+
chunkOQPRIB73_cjs.stopNetworkCapture();
|
|
2973
2973
|
};
|
|
2974
2974
|
}, [
|
|
2975
2975
|
autoStart,
|
|
@@ -2984,12 +2984,12 @@ function useAITools(options = {}) {
|
|
|
2984
2984
|
if (!screenshot) {
|
|
2985
2985
|
throw new Error("Screenshot capture is not enabled");
|
|
2986
2986
|
}
|
|
2987
|
-
if (!
|
|
2987
|
+
if (!chunkOQPRIB73_cjs.isScreenshotSupported()) {
|
|
2988
2988
|
throw new Error(
|
|
2989
2989
|
"Screenshot capture is not supported in this environment"
|
|
2990
2990
|
);
|
|
2991
2991
|
}
|
|
2992
|
-
return
|
|
2992
|
+
return chunkOQPRIB73_cjs.captureScreenshot({ ...screenshotOptions, ...opts });
|
|
2993
2993
|
},
|
|
2994
2994
|
[screenshot, screenshotOptions]
|
|
2995
2995
|
);
|
|
@@ -2998,7 +2998,7 @@ function useAITools(options = {}) {
|
|
|
2998
2998
|
if (!consoleCapture) {
|
|
2999
2999
|
return { logs: [], totalCaptured: 0 };
|
|
3000
3000
|
}
|
|
3001
|
-
return
|
|
3001
|
+
return chunkOQPRIB73_cjs.getConsoleLogs({ ...consoleOptions, ...opts });
|
|
3002
3002
|
},
|
|
3003
3003
|
[consoleCapture, consoleOptions]
|
|
3004
3004
|
);
|
|
@@ -3007,7 +3007,7 @@ function useAITools(options = {}) {
|
|
|
3007
3007
|
if (!network) {
|
|
3008
3008
|
return { requests: [], totalCaptured: 0 };
|
|
3009
3009
|
}
|
|
3010
|
-
return
|
|
3010
|
+
return chunkOQPRIB73_cjs.getNetworkRequests({ ...networkOptions, ...opts });
|
|
3011
3011
|
},
|
|
3012
3012
|
[network, networkOptions]
|
|
3013
3013
|
);
|
|
@@ -3100,23 +3100,23 @@ function useAITools(options = {}) {
|
|
|
3100
3100
|
]
|
|
3101
3101
|
);
|
|
3102
3102
|
const startCapturing = react.useCallback(() => {
|
|
3103
|
-
if (consoleCapture && !
|
|
3104
|
-
|
|
3103
|
+
if (consoleCapture && !chunkOQPRIB73_cjs.isConsoleCaptureActive()) {
|
|
3104
|
+
chunkOQPRIB73_cjs.startConsoleCapture(consoleOptions);
|
|
3105
3105
|
setActiveCaptures((prev) => ({ ...prev, console: true }));
|
|
3106
3106
|
}
|
|
3107
|
-
if (network && !
|
|
3108
|
-
|
|
3107
|
+
if (network && !chunkOQPRIB73_cjs.isNetworkCaptureActive()) {
|
|
3108
|
+
chunkOQPRIB73_cjs.startNetworkCapture(networkOptions);
|
|
3109
3109
|
setActiveCaptures((prev) => ({ ...prev, network: true }));
|
|
3110
3110
|
}
|
|
3111
3111
|
}, [consoleCapture, network, consoleOptions, networkOptions]);
|
|
3112
3112
|
const stopCapturing = react.useCallback(() => {
|
|
3113
|
-
|
|
3114
|
-
|
|
3113
|
+
chunkOQPRIB73_cjs.stopConsoleCapture();
|
|
3114
|
+
chunkOQPRIB73_cjs.stopNetworkCapture();
|
|
3115
3115
|
setActiveCaptures({ console: false, network: false });
|
|
3116
3116
|
}, []);
|
|
3117
3117
|
const clearCaptured = react.useCallback(() => {
|
|
3118
|
-
|
|
3119
|
-
|
|
3118
|
+
chunkOQPRIB73_cjs.clearConsoleLogs();
|
|
3119
|
+
chunkOQPRIB73_cjs.clearNetworkRequests();
|
|
3120
3120
|
}, []);
|
|
3121
3121
|
const formatForAI = react.useCallback((context) => {
|
|
3122
3122
|
const parts = [];
|
|
@@ -3126,16 +3126,16 @@ function useAITools(options = {}) {
|
|
|
3126
3126
|
);
|
|
3127
3127
|
}
|
|
3128
3128
|
if (context.consoleLogs && context.consoleLogs.logs.length > 0) {
|
|
3129
|
-
parts.push(
|
|
3129
|
+
parts.push(chunkOQPRIB73_cjs.formatLogsForAI(context.consoleLogs.logs));
|
|
3130
3130
|
}
|
|
3131
3131
|
if (context.networkRequests && context.networkRequests.requests.length > 0) {
|
|
3132
|
-
parts.push(
|
|
3132
|
+
parts.push(chunkOQPRIB73_cjs.formatRequestsForAI(context.networkRequests.requests));
|
|
3133
3133
|
}
|
|
3134
3134
|
return parts.length > 0 ? parts.join("\n\n---\n\n") : "No context captured.";
|
|
3135
3135
|
}, []);
|
|
3136
3136
|
const detectIntentFn = react.useCallback(
|
|
3137
3137
|
(message) => {
|
|
3138
|
-
const result =
|
|
3138
|
+
const result = chunkOQPRIB73_cjs.detectIntent(message);
|
|
3139
3139
|
result.suggestedTools = result.suggestedTools.filter((tool2) => {
|
|
3140
3140
|
if (tool2 === "screenshot") return screenshot;
|
|
3141
3141
|
if (tool2 === "console") return consoleCapture;
|
|
@@ -3181,16 +3181,27 @@ function useAITools(options = {}) {
|
|
|
3181
3181
|
]
|
|
3182
3182
|
);
|
|
3183
3183
|
}
|
|
3184
|
+
function isZodSchema(value) {
|
|
3185
|
+
if (value === null || typeof value !== "object") return false;
|
|
3186
|
+
const obj = value;
|
|
3187
|
+
return "_def" in obj && typeof obj._def === "object" || "_zod" in obj && typeof obj._zod === "object" || "~standard" in obj;
|
|
3188
|
+
}
|
|
3184
3189
|
function useTool(config, dependencies = []) {
|
|
3185
3190
|
const { registerTool, unregisterTool } = useCopilot();
|
|
3186
3191
|
const configRef = react.useRef(config);
|
|
3187
3192
|
configRef.current = config;
|
|
3193
|
+
const inputSchema = react.useMemo(() => {
|
|
3194
|
+
if (isZodSchema(config.inputSchema)) {
|
|
3195
|
+
return chunkOQPRIB73_cjs.zodToJsonSchema(config.inputSchema);
|
|
3196
|
+
}
|
|
3197
|
+
return config.inputSchema;
|
|
3198
|
+
}, [config.inputSchema]);
|
|
3188
3199
|
react.useEffect(() => {
|
|
3189
3200
|
const tool2 = {
|
|
3190
3201
|
name: config.name,
|
|
3191
3202
|
description: config.description,
|
|
3192
3203
|
location: "client",
|
|
3193
|
-
inputSchema
|
|
3204
|
+
inputSchema,
|
|
3194
3205
|
handler: async (params, context) => {
|
|
3195
3206
|
return configRef.current.handler(params, context);
|
|
3196
3207
|
},
|
|
@@ -3204,7 +3215,7 @@ function useTool(config, dependencies = []) {
|
|
|
3204
3215
|
return () => {
|
|
3205
3216
|
unregisterTool(config.name);
|
|
3206
3217
|
};
|
|
3207
|
-
}, [config.name, ...dependencies]);
|
|
3218
|
+
}, [config.name, inputSchema, ...dependencies]);
|
|
3208
3219
|
}
|
|
3209
3220
|
function useTools(tools) {
|
|
3210
3221
|
const { registerTool, unregisterTool } = useCopilot();
|
|
@@ -3250,7 +3261,7 @@ function convertZodSchema(schema, _toolName) {
|
|
|
3250
3261
|
}
|
|
3251
3262
|
} catch {
|
|
3252
3263
|
}
|
|
3253
|
-
return
|
|
3264
|
+
return chunkOQPRIB73_cjs.zodObjectToInputSchema(schema);
|
|
3254
3265
|
}
|
|
3255
3266
|
function useToolWithSchema(config, dependencies = []) {
|
|
3256
3267
|
const { registerTool, unregisterTool } = useCopilot();
|
|
@@ -3559,7 +3570,7 @@ function useAgent(options) {
|
|
|
3559
3570
|
if (!response.ok) {
|
|
3560
3571
|
throw new Error(`Agent error: ${response.status}`);
|
|
3561
3572
|
}
|
|
3562
|
-
for await (const event of
|
|
3573
|
+
for await (const event of chunkOQPRIB73_cjs.streamSSE(response)) {
|
|
3563
3574
|
handleAgentEvent(event);
|
|
3564
3575
|
}
|
|
3565
3576
|
} catch (err) {
|
|
@@ -4053,7 +4064,7 @@ function createReactThreadManagerState(initialThreads) {
|
|
|
4053
4064
|
}
|
|
4054
4065
|
|
|
4055
4066
|
// src/react/internal/ReactThreadManager.ts
|
|
4056
|
-
var _ReactThreadManager = class _ReactThreadManager extends
|
|
4067
|
+
var _ReactThreadManager = class _ReactThreadManager extends chunkOQPRIB73_cjs.ThreadManager {
|
|
4057
4068
|
constructor(config = {}, callbacks = {}) {
|
|
4058
4069
|
const reactState = new ReactThreadManagerState();
|
|
4059
4070
|
super({ ...config, state: reactState }, callbacks);
|
|
@@ -4720,5 +4731,5 @@ exports.useToolExecutor = useToolExecutor;
|
|
|
4720
4731
|
exports.useToolWithSchema = useToolWithSchema;
|
|
4721
4732
|
exports.useTools = useTools;
|
|
4722
4733
|
exports.useToolsWithSchema = useToolsWithSchema;
|
|
4723
|
-
//# sourceMappingURL=chunk-
|
|
4724
|
-
//# sourceMappingURL=chunk-
|
|
4734
|
+
//# sourceMappingURL=chunk-N6VZ7FOW.cjs.map
|
|
4735
|
+
//# sourceMappingURL=chunk-N6VZ7FOW.cjs.map
|