@yourgpt/copilot-sdk 2.0.2-beta.1 → 2.1.0

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.
Files changed (86) hide show
  1. package/README.md +0 -42
  2. package/dist/{chunk-DUPNYVBP.cjs → chunk-33JSFVGH.cjs} +23 -23
  3. package/dist/{chunk-DUPNYVBP.cjs.map → chunk-33JSFVGH.cjs.map} +1 -1
  4. package/dist/{chunk-3YKHVLNP.js → chunk-3SP6V22Y.js} +246 -219
  5. package/dist/chunk-3SP6V22Y.js.map +1 -0
  6. package/dist/{chunk-Z7PHGSJT.js → chunk-7PJ4GAJR.js} +4 -4
  7. package/dist/{chunk-Z7PHGSJT.js.map → chunk-7PJ4GAJR.js.map} +1 -1
  8. package/dist/{chunk-6BXQFCK3.js → chunk-7YZVSG62.js} +3 -3
  9. package/dist/{chunk-6BXQFCK3.js.map → chunk-7YZVSG62.js.map} +1 -1
  10. package/dist/{chunk-J4OMGO5O.js → chunk-BRUDSHCV.js} +3 -2
  11. package/dist/chunk-BRUDSHCV.js.map +1 -0
  12. package/dist/{chunk-4WWWMNUA.js → chunk-EWVQWTNV.js} +26 -6
  13. package/dist/chunk-EWVQWTNV.js.map +1 -0
  14. package/dist/{chunk-W74OTXXX.cjs → chunk-HNRFRNMY.cjs} +3 -2
  15. package/dist/chunk-HNRFRNMY.cjs.map +1 -0
  16. package/dist/{chunk-DVC63PGD.cjs → chunk-JGPDQDY4.cjs} +26 -6
  17. package/dist/chunk-JGPDQDY4.cjs.map +1 -0
  18. package/dist/{chunk-RBZXLBGI.cjs → chunk-MUZ2RYS2.cjs} +268 -241
  19. package/dist/chunk-MUZ2RYS2.cjs.map +1 -0
  20. package/dist/{chunk-TX7CGITI.cjs → chunk-O33I4HBL.cjs} +5 -5
  21. package/dist/{chunk-TX7CGITI.cjs.map → chunk-O33I4HBL.cjs.map} +1 -1
  22. package/dist/core/index.cjs +80 -80
  23. package/dist/core/index.d.cts +3 -3
  24. package/dist/core/index.d.ts +3 -3
  25. package/dist/core/index.js +3 -3
  26. package/dist/{index-DBNh0jhE.d.ts → index-25qIYJ21.d.ts} +1 -1
  27. package/dist/{index-DOlhSb79.d.cts → index-C261xY-B.d.cts} +1 -1
  28. package/dist/mcp/index.cjs +47 -47
  29. package/dist/mcp/index.d.cts +13 -3
  30. package/dist/mcp/index.d.ts +13 -3
  31. package/dist/mcp/index.js +2 -2
  32. package/dist/react/index.cjs +50 -50
  33. package/dist/react/index.d.cts +18 -5
  34. package/dist/react/index.d.ts +18 -5
  35. package/dist/react/index.js +5 -5
  36. package/dist/tools/anthropic/index.d.cts +1 -1
  37. package/dist/tools/anthropic/index.d.ts +1 -1
  38. package/dist/tools/brave/index.cjs +2 -2
  39. package/dist/tools/brave/index.d.cts +1 -1
  40. package/dist/tools/brave/index.d.ts +1 -1
  41. package/dist/tools/brave/index.js +1 -1
  42. package/dist/tools/exa/index.cjs +2 -2
  43. package/dist/tools/exa/index.d.cts +1 -1
  44. package/dist/tools/exa/index.d.ts +1 -1
  45. package/dist/tools/exa/index.js +1 -1
  46. package/dist/tools/google/index.cjs +2 -2
  47. package/dist/tools/google/index.d.cts +1 -1
  48. package/dist/tools/google/index.d.ts +1 -1
  49. package/dist/tools/google/index.js +1 -1
  50. package/dist/tools/openai/index.cjs +2 -2
  51. package/dist/tools/openai/index.d.cts +1 -1
  52. package/dist/tools/openai/index.d.ts +1 -1
  53. package/dist/tools/openai/index.js +1 -1
  54. package/dist/tools/searxng/index.cjs +2 -2
  55. package/dist/tools/searxng/index.d.cts +1 -1
  56. package/dist/tools/searxng/index.d.ts +1 -1
  57. package/dist/tools/searxng/index.js +1 -1
  58. package/dist/tools/serper/index.cjs +2 -2
  59. package/dist/tools/serper/index.d.cts +1 -1
  60. package/dist/tools/serper/index.d.ts +1 -1
  61. package/dist/tools/serper/index.js +1 -1
  62. package/dist/tools/tavily/index.cjs +2 -2
  63. package/dist/tools/tavily/index.d.cts +1 -1
  64. package/dist/tools/tavily/index.d.ts +1 -1
  65. package/dist/tools/tavily/index.js +1 -1
  66. package/dist/tools/web-search/index.cjs +3 -3
  67. package/dist/tools/web-search/index.d.cts +2 -2
  68. package/dist/tools/web-search/index.d.ts +2 -2
  69. package/dist/tools/web-search/index.js +2 -2
  70. package/dist/{tools-EiPWA9Ay.d.ts → tools-Clyufshc.d.cts} +23 -1
  71. package/dist/{tools-EiPWA9Ay.d.cts → tools-Clyufshc.d.ts} +23 -1
  72. package/dist/{types-CKA6U74u.d.cts → types-DM6M_pv_.d.cts} +43 -2
  73. package/dist/{types-iBkPICvQ.d.ts → types-wudOhedT.d.ts} +43 -2
  74. package/dist/ui/index.cjs +63 -29
  75. package/dist/ui/index.cjs.map +1 -1
  76. package/dist/ui/index.d.cts +37 -3
  77. package/dist/ui/index.d.ts +37 -3
  78. package/dist/ui/index.js +59 -25
  79. package/dist/ui/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/dist/chunk-3YKHVLNP.js.map +0 -1
  82. package/dist/chunk-4WWWMNUA.js.map +0 -1
  83. package/dist/chunk-DVC63PGD.cjs.map +0 -1
  84. package/dist/chunk-J4OMGO5O.js.map +0 -1
  85. package/dist/chunk-RBZXLBGI.cjs.map +0 -1
  86. package/dist/chunk-W74OTXXX.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { T as ToolDefinition } from './tools-EiPWA9Ay.js';
1
+ import { T as ToolDefinition } from './tools-Clyufshc.js';
2
2
 
3
3
  /**
4
4
  * MCP (Model Context Protocol) Type Definitions
@@ -401,6 +401,47 @@ interface UseMCPToolsConfig extends UseMCPClientConfig {
401
401
  prefixToolNames?: boolean;
402
402
  /** Auto-register tools with CopilotProvider (default: true) */
403
403
  autoRegister?: boolean;
404
+ /**
405
+ * Hide all tools from this MCP server in the chat UI.
406
+ * Tools will still execute, but won't show in the tool execution display.
407
+ * @default false
408
+ */
409
+ hidden?: boolean;
410
+ /**
411
+ * Source label for tools from this MCP server.
412
+ * Used to identify MCP tools in the UI for custom rendering.
413
+ * @default "mcp"
414
+ */
415
+ source?: "mcp" | "native" | "custom";
416
+ }
417
+ /**
418
+ * MCP server configuration for CopilotProvider
419
+ */
420
+ interface MCPServerConfig {
421
+ /** Unique name for this server connection */
422
+ name: string;
423
+ /** Transport type */
424
+ transport: MCPTransportType;
425
+ /** Server URL (for http/sse transports) */
426
+ url: string;
427
+ /** Custom headers (for http/sse transports) */
428
+ headers?: Record<string, string>;
429
+ /** Request timeout in milliseconds (default: 30000) */
430
+ timeout?: number;
431
+ /** Prefix tool names with server name (default: true) */
432
+ prefixToolNames?: boolean;
433
+ /**
434
+ * Hide all tools from this MCP server in the chat UI.
435
+ * Tools will still execute, but won't show in the tool execution display.
436
+ * @default false
437
+ */
438
+ hidden?: boolean;
439
+ /**
440
+ * Source label for tools from this MCP server.
441
+ * Used to identify MCP tools in the UI for custom rendering.
442
+ * @default "mcp"
443
+ */
444
+ source?: "mcp" | "native" | "custom";
404
445
  }
405
446
  /**
406
447
  * Return type for useMCPClient hook
@@ -438,4 +479,4 @@ declare class MCPError extends Error {
438
479
  static fromJsonRpcError(error: JsonRpcError): MCPError;
439
480
  }
440
481
 
441
- export { type MCPElicitationRequest as A, type MCPElicitationResponse as B, type MCPElicitationOption as C, type UseMCPClientReturn as D, type UseMCPToolsConfig as E, type UseMCPToolsReturn as F, MCPError as G, MCP_PROTOCOL_VERSION as H, JSON_RPC_ERROR_CODES as I, type JsonRpcRequest as J, type MCPClientConfig as M, type UseMCPClientConfig as U, type MCPClientEvents as a, type MCPClientState as b, type MCPToolCallResult as c, type MCPToolDefinition as d, type MCPServerInfo as e, type MCPServerCapabilities as f, type MCPConnectionState as g, type JsonRpcNotification as h, type JsonRpcMessage as i, type JsonRpcResponse as j, type MCPClientInfo as k, type MCPClientCapabilities as l, type MCPInitializeParams as m, type MCPToolCallParams as n, type MCPTransportType as o, type MCPTransportConfig as p, type MCPHttpTransportConfig as q, type MCPSSETransportConfig as r, type MCPStdioTransportConfig as s, type JsonRpcError as t, type MCPToolInputSchema as u, type MCPToolResultContent as v, type MCPTextContent as w, type MCPImageContent as x, type MCPResourceContent as y, type MCPUIContent as z };
482
+ export { type MCPElicitationRequest as A, type MCPElicitationResponse as B, type MCPElicitationOption as C, type UseMCPClientReturn as D, type UseMCPToolsConfig as E, type UseMCPToolsReturn as F, type MCPServerConfig as G, MCPError as H, MCP_PROTOCOL_VERSION as I, type JsonRpcRequest as J, JSON_RPC_ERROR_CODES as K, type MCPClientConfig as M, type UseMCPClientConfig as U, type MCPClientEvents as a, type MCPClientState as b, type MCPToolCallResult as c, type MCPToolDefinition as d, type MCPServerInfo as e, type MCPServerCapabilities as f, type MCPConnectionState as g, type JsonRpcNotification as h, type JsonRpcMessage as i, type JsonRpcResponse as j, type MCPClientInfo as k, type MCPClientCapabilities as l, type MCPInitializeParams as m, type MCPToolCallParams as n, type MCPTransportType as o, type MCPTransportConfig as p, type MCPHttpTransportConfig as q, type MCPSSETransportConfig as r, type MCPStdioTransportConfig as s, type JsonRpcError as t, type MCPToolInputSchema as u, type MCPToolResultContent as v, type MCPTextContent as w, type MCPImageContent as x, type MCPResourceContent as y, type MCPUIContent as z };
package/dist/ui/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkRBZXLBGI_cjs = require('../chunk-RBZXLBGI.cjs');
4
- var chunkDUPNYVBP_cjs = require('../chunk-DUPNYVBP.cjs');
3
+ var chunkMUZ2RYS2_cjs = require('../chunk-MUZ2RYS2.cjs');
4
+ var chunk33JSFVGH_cjs = require('../chunk-33JSFVGH.cjs');
5
5
  var chunkJO4BHPAD_cjs = require('../chunk-JO4BHPAD.cjs');
6
- require('../chunk-DVC63PGD.cjs');
7
- require('../chunk-TX7CGITI.cjs');
8
- require('../chunk-W74OTXXX.cjs');
6
+ require('../chunk-JGPDQDY4.cjs');
7
+ require('../chunk-O33I4HBL.cjs');
8
+ require('../chunk-HNRFRNMY.cjs');
9
9
  require('../chunk-ASV6JLYG.cjs');
10
10
  require('../chunk-CBAHCI4R.cjs');
11
11
  require('../chunk-MEBXW75C.cjs');
@@ -351,7 +351,8 @@ var headingComponents = {
351
351
  function MarkdownComponent({
352
352
  children,
353
353
  className,
354
- isStreaming = false
354
+ isStreaming = false,
355
+ linkSafety = { enabled: false }
355
356
  }) {
356
357
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(
357
358
  streamdown.Streamdown,
@@ -359,6 +360,7 @@ function MarkdownComponent({
359
360
  plugins: { code: code.code },
360
361
  isAnimating: isStreaming,
361
362
  components: headingComponents,
363
+ linkSafety,
362
364
  children
363
365
  }
364
366
  ) });
@@ -1926,8 +1928,8 @@ function ToolStep({
1926
1928
  "aria-hidden": "true"
1927
1929
  }
1928
1930
  ),
1929
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
1930
- !isExecuting && /* @__PURE__ */ jsxRuntime.jsx(StatusIndicator, { status: step.status, className: "mt-0.5" }),
1931
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1932
+ !isExecuting && /* @__PURE__ */ jsxRuntime.jsx(StatusIndicator, { status: step.status }),
1931
1933
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
1932
1934
  /* @__PURE__ */ jsxRuntime.jsxs(
1933
1935
  "button",
@@ -4249,6 +4251,7 @@ function DefaultMessage({
4249
4251
  loaderVariant = "typing",
4250
4252
  registeredTools,
4251
4253
  toolRenderers,
4254
+ mcpToolRenderer,
4252
4255
  onApproveToolExecution,
4253
4256
  onRejectToolExecution,
4254
4257
  showFollowUps = true,
@@ -4360,23 +4363,29 @@ function DefaultMessage({
4360
4363
  }
4361
4364
  );
4362
4365
  }
4366
+ const isToolHidden = (toolName) => {
4367
+ const toolDef = registeredTools?.find((t) => t.name === toolName);
4368
+ return toolDef?.hidden === true;
4369
+ };
4363
4370
  const pendingApprovalTools = message.toolExecutions?.filter(
4364
- (exec) => exec.approvalStatus === "required"
4371
+ (exec) => exec.approvalStatus === "required" && !isToolHidden(exec.name)
4365
4372
  );
4366
4373
  const completedTools = message.toolExecutions?.filter(
4367
- (exec) => exec.approvalStatus !== "required"
4374
+ (exec) => exec.approvalStatus !== "required" && !isToolHidden(exec.name)
4368
4375
  );
4369
- const hasCustomRender = (toolName) => {
4376
+ const hasCustomRender = (toolName, execSource) => {
4370
4377
  if (toolRenderers?.[toolName]) return true;
4371
4378
  const toolDef = registeredTools?.find((t) => t.name === toolName);
4379
+ if (mcpToolRenderer && (execSource === "mcp" || toolDef?.source === "mcp"))
4380
+ return true;
4372
4381
  if (toolDef?.render) return true;
4373
4382
  return false;
4374
4383
  };
4375
4384
  const toolsWithCustomRender = completedTools?.filter(
4376
- (exec) => hasCustomRender(exec.name)
4385
+ (exec) => hasCustomRender(exec.name, exec.source)
4377
4386
  );
4378
4387
  const toolsWithoutCustomRender = completedTools?.filter(
4379
- (exec) => !hasCustomRender(exec.name)
4388
+ (exec) => !hasCustomRender(exec.name, exec.source)
4380
4389
  );
4381
4390
  const hasNativeCitations = !!message.metadata?.citations?.length;
4382
4391
  const toolSteps = toolsWithoutCustomRender?.filter((exec) => !(exec.name === "web_search" && hasNativeCitations)).map((exec) => ({
@@ -4426,7 +4435,7 @@ function DefaultMessage({
4426
4435
  children: cleanContent
4427
4436
  }
4428
4437
  ),
4429
- toolsWithCustomRender && toolsWithCustomRender.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 space-y-2", children: toolsWithCustomRender.map((exec) => {
4438
+ toolsWithCustomRender && toolsWithCustomRender.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("space-y-2", cleanContent?.trim() && "mt-2"), children: toolsWithCustomRender.map((exec) => {
4430
4439
  const Renderer = toolRenderers?.[exec.name];
4431
4440
  if (Renderer) {
4432
4441
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4439,7 +4448,8 @@ function DefaultMessage({
4439
4448
  status: exec.status,
4440
4449
  result: exec.result,
4441
4450
  error: exec.error,
4442
- approvalStatus: exec.approvalStatus
4451
+ approvalStatus: exec.approvalStatus,
4452
+ source: exec.source
4443
4453
  }
4444
4454
  },
4445
4455
  exec.id
@@ -4448,7 +4458,26 @@ function DefaultMessage({
4448
4458
  const toolDef = registeredTools?.find(
4449
4459
  (t) => t.name === exec.name
4450
4460
  );
4451
- if (toolDef?.render) {
4461
+ if (mcpToolRenderer && (exec.source === "mcp" || toolDef?.source === "mcp")) {
4462
+ const MCPRenderer = mcpToolRenderer;
4463
+ return /* @__PURE__ */ jsxRuntime.jsx(
4464
+ MCPRenderer,
4465
+ {
4466
+ execution: {
4467
+ id: exec.id,
4468
+ name: exec.name,
4469
+ args: exec.args,
4470
+ status: exec.status,
4471
+ result: exec.result,
4472
+ error: exec.error,
4473
+ source: exec.source || toolDef?.source
4474
+ }
4475
+ },
4476
+ exec.id
4477
+ );
4478
+ }
4479
+ const toolDefForRender = toolDef ?? registeredTools?.find((t) => t.name === exec.name);
4480
+ if (toolDefForRender?.render) {
4452
4481
  let status = "pending";
4453
4482
  if (exec.status === "executing") status = "executing";
4454
4483
  else if (exec.status === "completed") status = "completed";
@@ -4462,15 +4491,24 @@ function DefaultMessage({
4462
4491
  toolCallId: exec.id,
4463
4492
  toolName: exec.name
4464
4493
  };
4465
- const output = toolDef.render(
4494
+ const output = toolDefForRender.render(
4466
4495
  renderProps
4467
4496
  );
4468
4497
  return /* @__PURE__ */ jsxRuntime.jsx(React20__namespace.Fragment, { children: output }, exec.id);
4469
4498
  }
4470
4499
  return null;
4471
4500
  }) }),
4472
- toolSteps && toolSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 rounded-lg bg-muted/50 px-3 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(ToolSteps, { steps: toolSteps }) }),
4473
- message.toolExecutions?.map((exec) => {
4501
+ toolSteps && toolSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
4502
+ "div",
4503
+ {
4504
+ className: cn(
4505
+ "rounded-lg bg-muted/50 px-3 py-2",
4506
+ cleanContent?.trim() && "mt-2"
4507
+ ),
4508
+ children: /* @__PURE__ */ jsxRuntime.jsx(ToolSteps, { steps: toolSteps })
4509
+ }
4510
+ ),
4511
+ message.toolExecutions?.filter((exec) => !isToolHidden(exec.name)).map((exec) => {
4474
4512
  const uiResources = exec.result?._uiResources;
4475
4513
  if (!uiResources || uiResources.length === 0) return null;
4476
4514
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -5248,6 +5286,7 @@ function ChatComponent({
5248
5286
  isProcessing = false,
5249
5287
  registeredTools,
5250
5288
  toolRenderers,
5289
+ mcpToolRenderer,
5251
5290
  onApproveToolExecution,
5252
5291
  onRejectToolExecution,
5253
5292
  // Follow-up Questions
@@ -5575,6 +5614,7 @@ function ChatComponent({
5575
5614
  loaderVariant,
5576
5615
  registeredTools,
5577
5616
  toolRenderers,
5617
+ mcpToolRenderer,
5578
5618
  onApproveToolExecution,
5579
5619
  onRejectToolExecution,
5580
5620
  showFollowUps,
@@ -5904,7 +5944,7 @@ function useInternalThreadManager(config = {}) {
5904
5944
  saveDebounce,
5905
5945
  autoRestoreLastThread
5906
5946
  };
5907
- const threadManager = chunkRBZXLBGI_cjs.useThreadManager(threadManagerConfig);
5947
+ const threadManager = chunkMUZ2RYS2_cjs.useThreadManager(threadManagerConfig);
5908
5948
  const {
5909
5949
  currentThread,
5910
5950
  currentThreadId,
@@ -5914,7 +5954,7 @@ function useInternalThreadManager(config = {}) {
5914
5954
  clearCurrentThread,
5915
5955
  refreshThreads
5916
5956
  } = threadManager;
5917
- const { messages, setMessages, status, isLoading } = chunkRBZXLBGI_cjs.useCopilot();
5957
+ const { messages, setMessages, status, isLoading } = chunkMUZ2RYS2_cjs.useCopilot();
5918
5958
  const isLoadingMessagesRef = React20.useRef(false);
5919
5959
  const savingToThreadRef = React20.useRef(null);
5920
5960
  const lastSavedSnapshotRef = React20.useRef("");
@@ -5982,9 +6022,6 @@ function useInternalThreadManager(config = {}) {
5982
6022
  });
5983
6023
  }, [clearCurrentThread, setMessages, onThreadChange]);
5984
6024
  React20.useEffect(() => {
5985
- if (!adapter) {
5986
- return;
5987
- }
5988
6025
  if (hasInitializedRef.current || !currentThread) {
5989
6026
  return;
5990
6027
  }
@@ -6016,9 +6053,6 @@ function useInternalThreadManager(config = {}) {
6016
6053
  });
6017
6054
  }, [adapter, currentThread, setMessages, getMessageSnapshot, onThreadChange]);
6018
6055
  React20.useEffect(() => {
6019
- if (!adapter) {
6020
- return;
6021
- }
6022
6056
  if (isLoadingMessagesRef.current) {
6023
6057
  return;
6024
6058
  }
@@ -6087,7 +6121,7 @@ function parsePersistenceConfig(persistence, onThreadChange) {
6087
6121
  };
6088
6122
  case "server":
6089
6123
  return {
6090
- adapter: chunkDUPNYVBP_cjs.createServerAdapter({
6124
+ adapter: chunk33JSFVGH_cjs.createServerAdapter({
6091
6125
  endpoint: persistence.endpoint,
6092
6126
  headers: persistence.headers
6093
6127
  }),
@@ -6137,7 +6171,7 @@ function CopilotChatBase(props) {
6137
6171
  approveToolExecution,
6138
6172
  rejectToolExecution,
6139
6173
  registeredTools
6140
- } = chunkRBZXLBGI_cjs.useCopilot();
6174
+ } = chunkMUZ2RYS2_cjs.useCopilot();
6141
6175
  const toolExecutions = rawToolExecutions.map(
6142
6176
  (exec) => ({
6143
6177
  id: exec.id,