@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.
@@ -1,4 +1,4 @@
1
- import { ThreadManager, isConsoleCaptureActive, startConsoleCapture, isNetworkCaptureActive, startNetworkCapture, stopConsoleCapture, stopNetworkCapture, isScreenshotSupported, captureScreenshot, getConsoleLogs, getNetworkRequests, clearConsoleLogs, clearNetworkRequests, formatLogsForAI, formatRequestsForAI, detectIntent, streamSSE, zodObjectToInputSchema } from './chunk-VFV5FVVI.js';
1
+ import { ThreadManager, isConsoleCaptureActive, startConsoleCapture, isNetworkCaptureActive, startNetworkCapture, stopConsoleCapture, stopNetworkCapture, isScreenshotSupported, captureScreenshot, getConsoleLogs, getNetworkRequests, clearConsoleLogs, clearNetworkRequests, formatLogsForAI, formatRequestsForAI, detectIntent, zodToJsonSchema, streamSSE, zodObjectToInputSchema } from './chunk-37KEHUCE.js';
2
2
  import { createMCPClient, MCPToolAdapter } from './chunk-EWVQWTNV.js';
3
3
  import { createContext, useRef, useState, useCallback, useEffect, useMemo, useContext, useSyncExternalStore } from 'react';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
@@ -3159,16 +3159,27 @@ function useAITools(options = {}) {
3159
3159
  ]
3160
3160
  );
3161
3161
  }
3162
+ function isZodSchema(value) {
3163
+ if (value === null || typeof value !== "object") return false;
3164
+ const obj = value;
3165
+ return "_def" in obj && typeof obj._def === "object" || "_zod" in obj && typeof obj._zod === "object" || "~standard" in obj;
3166
+ }
3162
3167
  function useTool(config, dependencies = []) {
3163
3168
  const { registerTool, unregisterTool } = useCopilot();
3164
3169
  const configRef = useRef(config);
3165
3170
  configRef.current = config;
3171
+ const inputSchema = useMemo(() => {
3172
+ if (isZodSchema(config.inputSchema)) {
3173
+ return zodToJsonSchema(config.inputSchema);
3174
+ }
3175
+ return config.inputSchema;
3176
+ }, [config.inputSchema]);
3166
3177
  useEffect(() => {
3167
3178
  const tool2 = {
3168
3179
  name: config.name,
3169
3180
  description: config.description,
3170
3181
  location: "client",
3171
- inputSchema: config.inputSchema,
3182
+ inputSchema,
3172
3183
  handler: async (params, context) => {
3173
3184
  return configRef.current.handler(params, context);
3174
3185
  },
@@ -3182,7 +3193,7 @@ function useTool(config, dependencies = []) {
3182
3193
  return () => {
3183
3194
  unregisterTool(config.name);
3184
3195
  };
3185
- }, [config.name, ...dependencies]);
3196
+ }, [config.name, inputSchema, ...dependencies]);
3186
3197
  }
3187
3198
  function useTools(tools) {
3188
3199
  const { registerTool, unregisterTool } = useCopilot();
@@ -4658,5 +4669,5 @@ function useChat(config) {
4658
4669
  }
4659
4670
 
4660
4671
  export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPClient, useMCPTools, useMCPUIIntents, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema };
4661
- //# sourceMappingURL=chunk-DMBFN7KO.js.map
4662
- //# sourceMappingURL=chunk-DMBFN7KO.js.map
4672
+ //# sourceMappingURL=chunk-7PKGRYHY.js.map
4673
+ //# sourceMappingURL=chunk-7PKGRYHY.js.map