@yourgpt/copilot-sdk 2.1.5-alpha.3 → 2.1.5-alpha.5

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 (106) hide show
  1. package/dist/{MessageTree-CoIt_4nB.d.cts → MessageTree-Clhiv_k2.d.ts} +5 -4
  2. package/dist/{MessageTree-CzaN9Eul.d.ts → MessageTree-Dt9qfJ55.d.cts} +5 -4
  3. package/dist/{ThreadManager-BEAECB7Y.d.ts → ThreadManager-D7KwT2FJ.d.ts} +3 -1
  4. package/dist/{ThreadManager-Cw5fwyCN.d.cts → ThreadManager-DK46fVl3.d.cts} +3 -1
  5. package/dist/{chunk-NUXLAZOE.cjs → chunk-3ZDRX7J2.cjs} +2 -2
  6. package/dist/{chunk-NUXLAZOE.cjs.map → chunk-3ZDRX7J2.cjs.map} +1 -1
  7. package/dist/{chunk-RKGRQRZU.js → chunk-533K2Z7C.js} +4 -4
  8. package/dist/{chunk-RKGRQRZU.js.map → chunk-533K2Z7C.js.map} +1 -1
  9. package/dist/chunk-5EGBIQYS.cjs +292 -0
  10. package/dist/chunk-5EGBIQYS.cjs.map +1 -0
  11. package/dist/chunk-5UGWLGFS.cjs +2039 -0
  12. package/dist/chunk-5UGWLGFS.cjs.map +1 -0
  13. package/dist/{chunk-3AONOZLY.js → chunk-AIVXGTWS.js} +2 -2
  14. package/dist/chunk-AIVXGTWS.js.map +1 -0
  15. package/dist/{chunk-LLM7AHMO.js → chunk-DDZLRCVX.js} +2 -2
  16. package/dist/{chunk-LLM7AHMO.js.map → chunk-DDZLRCVX.js.map} +1 -1
  17. package/dist/{chunk-PT2TOHG5.js → chunk-DH6EO6NW.js} +1337 -3049
  18. package/dist/chunk-DH6EO6NW.js.map +1 -0
  19. package/dist/{chunk-WIXFZUEZ.cjs → chunk-KGYDGK3U.cjs} +84 -30
  20. package/dist/chunk-KGYDGK3U.cjs.map +1 -0
  21. package/dist/{chunk-TCPAT3WG.cjs → chunk-LHLVTGIP.cjs} +1339 -3101
  22. package/dist/chunk-LHLVTGIP.cjs.map +1 -0
  23. package/dist/{chunk-TPB7XED6.cjs → chunk-TPDMBDQX.cjs} +2 -2
  24. package/dist/chunk-TPDMBDQX.cjs.map +1 -0
  25. package/dist/chunk-TXQ37MAO.js +287 -0
  26. package/dist/chunk-TXQ37MAO.js.map +1 -0
  27. package/dist/{chunk-MDS23G2S.cjs → chunk-Y2A6AMGO.cjs} +10 -10
  28. package/dist/{chunk-MDS23G2S.cjs.map → chunk-Y2A6AMGO.cjs.map} +1 -1
  29. package/dist/{chunk-WZ2TOZ7M.js → chunk-YLZCTR4O.js} +65 -11
  30. package/dist/chunk-YLZCTR4O.js.map +1 -0
  31. package/dist/chunk-ZAOTYA5L.js +1983 -0
  32. package/dist/chunk-ZAOTYA5L.js.map +1 -0
  33. package/dist/core/index.cjs +93 -93
  34. package/dist/core/index.d.cts +7 -7
  35. package/dist/core/index.d.ts +7 -7
  36. package/dist/core/index.js +5 -5
  37. package/dist/experimental/index.cjs +644 -0
  38. package/dist/experimental/index.cjs.map +1 -0
  39. package/dist/experimental/index.d.cts +924 -0
  40. package/dist/experimental/index.d.ts +924 -0
  41. package/dist/experimental/index.js +611 -0
  42. package/dist/experimental/index.js.map +1 -0
  43. package/dist/{index-D7169xuR.d.ts → index-D8zza1Q8.d.ts} +1 -1
  44. package/dist/{index-CzJB8Ddo.d.cts → index-DCVjTdIZ.d.cts} +1 -1
  45. package/dist/mcp/index.d.cts +3 -3
  46. package/dist/mcp/index.d.ts +3 -3
  47. package/dist/react/index.cjs +136 -123
  48. package/dist/react/index.d.cts +178 -12
  49. package/dist/react/index.d.ts +178 -12
  50. package/dist/react/index.js +7 -6
  51. package/dist/styles.css +45 -0
  52. package/dist/tools/anthropic/index.cjs +3 -3
  53. package/dist/tools/anthropic/index.d.cts +1 -1
  54. package/dist/tools/anthropic/index.d.ts +1 -1
  55. package/dist/tools/anthropic/index.js +2 -2
  56. package/dist/tools/brave/index.cjs +6 -6
  57. package/dist/tools/brave/index.d.cts +1 -1
  58. package/dist/tools/brave/index.d.ts +1 -1
  59. package/dist/tools/brave/index.js +3 -3
  60. package/dist/tools/exa/index.cjs +6 -6
  61. package/dist/tools/exa/index.d.cts +1 -1
  62. package/dist/tools/exa/index.d.ts +1 -1
  63. package/dist/tools/exa/index.js +3 -3
  64. package/dist/tools/google/index.cjs +6 -6
  65. package/dist/tools/google/index.d.cts +1 -1
  66. package/dist/tools/google/index.d.ts +1 -1
  67. package/dist/tools/google/index.js +4 -4
  68. package/dist/tools/openai/index.cjs +6 -6
  69. package/dist/tools/openai/index.d.cts +1 -1
  70. package/dist/tools/openai/index.d.ts +1 -1
  71. package/dist/tools/openai/index.js +3 -3
  72. package/dist/tools/searxng/index.cjs +6 -6
  73. package/dist/tools/searxng/index.d.cts +1 -1
  74. package/dist/tools/searxng/index.d.ts +1 -1
  75. package/dist/tools/searxng/index.js +3 -3
  76. package/dist/tools/serper/index.cjs +6 -6
  77. package/dist/tools/serper/index.d.cts +1 -1
  78. package/dist/tools/serper/index.d.ts +1 -1
  79. package/dist/tools/serper/index.js +3 -3
  80. package/dist/tools/tavily/index.cjs +6 -6
  81. package/dist/tools/tavily/index.d.cts +1 -1
  82. package/dist/tools/tavily/index.d.ts +1 -1
  83. package/dist/tools/tavily/index.js +3 -3
  84. package/dist/tools/web-search/index.cjs +7 -7
  85. package/dist/tools/web-search/index.d.cts +2 -2
  86. package/dist/tools/web-search/index.d.ts +2 -2
  87. package/dist/tools/web-search/index.js +4 -4
  88. package/dist/{tools-tmksfhUo.d.cts → tools-DcS6Aeao.d.cts} +7 -3
  89. package/dist/{tools-tmksfhUo.d.ts → tools-DcS6Aeao.d.ts} +7 -3
  90. package/dist/{types-BqwW3Baj.d.ts → types-BUYni9B8.d.ts} +1 -1
  91. package/dist/{types-BLw7mxtW.d.cts → types-Cvg4DUoc.d.cts} +1 -1
  92. package/dist/{types-BeFBBZ5i.d.ts → types-waEqyE4K.d.cts} +5 -0
  93. package/dist/{types-BeFBBZ5i.d.cts → types-waEqyE4K.d.ts} +5 -0
  94. package/dist/ui/index.cjs +354 -524
  95. package/dist/ui/index.cjs.map +1 -1
  96. package/dist/ui/index.d.cts +22 -4
  97. package/dist/ui/index.d.ts +22 -4
  98. package/dist/ui/index.js +197 -372
  99. package/dist/ui/index.js.map +1 -1
  100. package/package.json +6 -1
  101. package/dist/chunk-3AONOZLY.js.map +0 -1
  102. package/dist/chunk-PT2TOHG5.js.map +0 -1
  103. package/dist/chunk-TCPAT3WG.cjs.map +0 -1
  104. package/dist/chunk-TPB7XED6.cjs.map +0 -1
  105. package/dist/chunk-WIXFZUEZ.cjs.map +0 -1
  106. package/dist/chunk-WZ2TOZ7M.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkMDS23G2S_cjs = require('./chunk-MDS23G2S.cjs');
4
- var chunkTPB7XED6_cjs = require('./chunk-TPB7XED6.cjs');
3
+ var chunkY2A6AMGO_cjs = require('./chunk-Y2A6AMGO.cjs');
4
+ var chunkTPDMBDQX_cjs = require('./chunk-TPDMBDQX.cjs');
5
5
 
6
6
  // src/core/tools/screenshot.ts
7
7
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
@@ -1036,7 +1036,7 @@ function createCustomDetector(customKeywords) {
1036
1036
  }
1037
1037
 
1038
1038
  // src/core/tools/builtin/screenshot.ts
1039
- var screenshotTool = chunkTPB7XED6_cjs.tool({
1039
+ var screenshotTool = chunkTPDMBDQX_cjs.tool({
1040
1040
  description: "Capture a screenshot of the user's current screen/viewport. Use this when the user asks you to look at their screen, see what they're seeing, help with visual issues, or debug UI problems.",
1041
1041
  location: "client",
1042
1042
  inputSchema: {
@@ -1055,7 +1055,7 @@ var screenshotTool = chunkTPB7XED6_cjs.tool({
1055
1055
  approvalMessage: "Allow AI to capture a screenshot of your screen?",
1056
1056
  handler: async (params) => {
1057
1057
  if (!isScreenshotSupported()) {
1058
- return chunkTPB7XED6_cjs.failure("Screenshot capture is not supported in this environment");
1058
+ return chunkTPDMBDQX_cjs.failure("Screenshot capture is not supported in this environment");
1059
1059
  }
1060
1060
  try {
1061
1061
  const options = {};
@@ -1081,20 +1081,20 @@ var screenshotTool = chunkTPB7XED6_cjs.tool({
1081
1081
  }
1082
1082
  };
1083
1083
  } catch (error) {
1084
- return chunkTPB7XED6_cjs.failure(
1084
+ return chunkTPDMBDQX_cjs.failure(
1085
1085
  error instanceof Error ? error.message : "Screenshot capture failed"
1086
1086
  );
1087
1087
  }
1088
1088
  }
1089
1089
  });
1090
1090
  function createScreenshotTool(options) {
1091
- return chunkTPB7XED6_cjs.tool({
1091
+ return chunkTPDMBDQX_cjs.tool({
1092
1092
  ...screenshotTool,
1093
1093
  needsApproval: options?.needsApproval ?? true,
1094
1094
  approvalMessage: options?.approvalMessage ?? "Allow AI to capture a screenshot of your screen?",
1095
1095
  handler: async (params) => {
1096
1096
  if (!isScreenshotSupported()) {
1097
- return chunkTPB7XED6_cjs.failure(
1097
+ return chunkTPDMBDQX_cjs.failure(
1098
1098
  "Screenshot capture is not supported in this environment"
1099
1099
  );
1100
1100
  }
@@ -1120,7 +1120,7 @@ function createScreenshotTool(options) {
1120
1120
  }
1121
1121
  };
1122
1122
  } catch (error) {
1123
- return chunkTPB7XED6_cjs.failure(
1123
+ return chunkTPDMBDQX_cjs.failure(
1124
1124
  error instanceof Error ? error.message : "Screenshot capture failed"
1125
1125
  );
1126
1126
  }
@@ -1133,7 +1133,7 @@ var isBrowser4 = typeof window !== "undefined" && typeof console !== "undefined"
1133
1133
  if (isBrowser4 && !isConsoleCaptureActive()) {
1134
1134
  startConsoleCapture();
1135
1135
  }
1136
- var consoleLogsTool = chunkTPB7XED6_cjs.tool({
1136
+ var consoleLogsTool = chunkTPDMBDQX_cjs.tool({
1137
1137
  description: "Get recent console logs from the browser. Use this when debugging JavaScript errors, checking for warnings, or understanding what's happening in the application.",
1138
1138
  location: "client",
1139
1139
  inputSchema: {
@@ -1166,7 +1166,7 @@ var consoleLogsTool = chunkTPB7XED6_cjs.tool({
1166
1166
  types: params.types
1167
1167
  });
1168
1168
  const formattedLogs = formatLogsForAI(logs.logs);
1169
- return chunkTPB7XED6_cjs.success(
1169
+ return chunkTPDMBDQX_cjs.success(
1170
1170
  {
1171
1171
  logs: formattedLogs,
1172
1172
  count: logs.logs.length,
@@ -1175,14 +1175,14 @@ var consoleLogsTool = chunkTPB7XED6_cjs.tool({
1175
1175
  `Retrieved ${logs.logs.length} console logs`
1176
1176
  );
1177
1177
  } catch (error) {
1178
- return chunkTPB7XED6_cjs.failure(
1178
+ return chunkTPDMBDQX_cjs.failure(
1179
1179
  error instanceof Error ? error.message : "Failed to get console logs"
1180
1180
  );
1181
1181
  }
1182
1182
  }
1183
1183
  });
1184
1184
  function createConsoleLogsTool(options) {
1185
- return chunkTPB7XED6_cjs.tool({
1185
+ return chunkTPDMBDQX_cjs.tool({
1186
1186
  ...consoleLogsTool,
1187
1187
  needsApproval: options?.needsApproval ?? true,
1188
1188
  approvalMessage: options?.approvalMessage ?? "Allow AI to access browser console logs?",
@@ -1196,7 +1196,7 @@ function createConsoleLogsTool(options) {
1196
1196
  types: params.types
1197
1197
  });
1198
1198
  const formattedLogs = formatLogsForAI(logs.logs);
1199
- return chunkTPB7XED6_cjs.success(
1199
+ return chunkTPDMBDQX_cjs.success(
1200
1200
  {
1201
1201
  logs: formattedLogs,
1202
1202
  count: logs.logs.length,
@@ -1205,7 +1205,7 @@ function createConsoleLogsTool(options) {
1205
1205
  `Retrieved ${logs.logs.length} console logs`
1206
1206
  );
1207
1207
  } catch (error) {
1208
- return chunkTPB7XED6_cjs.failure(
1208
+ return chunkTPDMBDQX_cjs.failure(
1209
1209
  error instanceof Error ? error.message : "Failed to get console logs"
1210
1210
  );
1211
1211
  }
@@ -1214,7 +1214,7 @@ function createConsoleLogsTool(options) {
1214
1214
  }
1215
1215
 
1216
1216
  // src/core/tools/builtin/network.ts
1217
- var networkRequestsTool = chunkTPB7XED6_cjs.tool({
1217
+ var networkRequestsTool = chunkTPDMBDQX_cjs.tool({
1218
1218
  description: "Get recent network requests from the browser. Use this when debugging API calls, checking for failed requests, analyzing network activity, or troubleshooting connectivity issues.",
1219
1219
  location: "client",
1220
1220
  inputSchema: {
@@ -1243,7 +1243,7 @@ var networkRequestsTool = chunkTPB7XED6_cjs.tool({
1243
1243
  failedOnly: params.failedOnly
1244
1244
  });
1245
1245
  const formattedRequests = formatRequestsForAI(requests.requests);
1246
- return chunkTPB7XED6_cjs.success(
1246
+ return chunkTPDMBDQX_cjs.success(
1247
1247
  {
1248
1248
  requests: formattedRequests,
1249
1249
  count: requests.requests.length,
@@ -1252,14 +1252,14 @@ var networkRequestsTool = chunkTPB7XED6_cjs.tool({
1252
1252
  `Retrieved ${requests.requests.length} network requests`
1253
1253
  );
1254
1254
  } catch (error) {
1255
- return chunkTPB7XED6_cjs.failure(
1255
+ return chunkTPDMBDQX_cjs.failure(
1256
1256
  error instanceof Error ? error.message : "Failed to get network requests"
1257
1257
  );
1258
1258
  }
1259
1259
  }
1260
1260
  });
1261
1261
  function createNetworkRequestsTool(options) {
1262
- return chunkTPB7XED6_cjs.tool({
1262
+ return chunkTPDMBDQX_cjs.tool({
1263
1263
  ...networkRequestsTool,
1264
1264
  needsApproval: options?.needsApproval ?? true,
1265
1265
  approvalMessage: options?.approvalMessage ?? "Allow AI to access network request history?",
@@ -1273,7 +1273,7 @@ function createNetworkRequestsTool(options) {
1273
1273
  failedOnly: params.failedOnly
1274
1274
  });
1275
1275
  const formattedRequests = formatRequestsForAI(requests.requests);
1276
- return chunkTPB7XED6_cjs.success(
1276
+ return chunkTPDMBDQX_cjs.success(
1277
1277
  {
1278
1278
  requests: formattedRequests,
1279
1279
  count: requests.requests.length,
@@ -1282,7 +1282,7 @@ function createNetworkRequestsTool(options) {
1282
1282
  `Retrieved ${requests.requests.length} network requests`
1283
1283
  );
1284
1284
  } catch (error) {
1285
- return chunkTPB7XED6_cjs.failure(
1285
+ return chunkTPDMBDQX_cjs.failure(
1286
1286
  error instanceof Error ? error.message : "Failed to get network requests"
1287
1287
  );
1288
1288
  }
@@ -1306,7 +1306,7 @@ var builtinTools = {
1306
1306
  },
1307
1307
  web_search: {
1308
1308
  name: "web_search",
1309
- ...chunkMDS23G2S_cjs.webSearchTool
1309
+ ...chunkY2A6AMGO_cjs.webSearchTool
1310
1310
  }
1311
1311
  };
1312
1312
 
@@ -1694,6 +1694,12 @@ function getZodEnumValues(schema) {
1694
1694
  }
1695
1695
  function zodToJsonSchema(schema) {
1696
1696
  const result = _zodToJsonSchemaInternal(schema);
1697
+ if (!result.type && (result.oneOf || result.anyOf)) {
1698
+ return {
1699
+ type: "object",
1700
+ ...result.oneOf ? { oneOf: result.oneOf } : { anyOf: result.anyOf }
1701
+ };
1702
+ }
1697
1703
  return result;
1698
1704
  }
1699
1705
  function _zodToJsonSchemaInternal(schema) {
@@ -1802,6 +1808,28 @@ function _zodToJsonSchemaInternal(schema) {
1802
1808
  }
1803
1809
  return { type: "string", description };
1804
1810
  }
1811
+ case "ZodDiscriminatedUnion": {
1812
+ const obj = schema;
1813
+ let options;
1814
+ if ("_zod" in obj) {
1815
+ const zod = obj._zod;
1816
+ const def = zod.def;
1817
+ const raw = def?.options;
1818
+ options = raw instanceof Map ? Array.from(raw.values()) : raw;
1819
+ }
1820
+ if (!options) {
1821
+ const def = obj._def;
1822
+ const raw = def?.options;
1823
+ options = raw instanceof Map ? Array.from(raw.values()) : raw;
1824
+ }
1825
+ if (options && options.length > 0) {
1826
+ const oneOf = options.map((opt) => _zodToJsonSchemaInternal(opt));
1827
+ const result2 = { oneOf };
1828
+ if (description) result2.description = description;
1829
+ return result2;
1830
+ }
1831
+ return { type: "object", description };
1832
+ }
1805
1833
  case "ZodUnion": {
1806
1834
  const obj = schema;
1807
1835
  let options;
@@ -1815,7 +1843,10 @@ function _zodToJsonSchemaInternal(schema) {
1815
1843
  options = def?.options;
1816
1844
  }
1817
1845
  if (options && options.length > 0) {
1818
- return _zodToJsonSchemaInternal(options[0]);
1846
+ const oneOf = options.map((opt) => _zodToJsonSchemaInternal(opt));
1847
+ const result2 = { oneOf };
1848
+ if (description) result2.description = description;
1849
+ return result2;
1819
1850
  }
1820
1851
  return { type: "string", description };
1821
1852
  }
@@ -2114,6 +2145,7 @@ function serializeThread(thread) {
2114
2145
  createdAt: thread.createdAt.toISOString(),
2115
2146
  updatedAt: thread.updatedAt.toISOString(),
2116
2147
  sources: thread.sources || [],
2148
+ activeLeafId: thread.activeLeafId,
2117
2149
  messages: thread.messages.map((m) => ({
2118
2150
  id: m.id,
2119
2151
  role: m.role,
@@ -2121,7 +2153,9 @@ function serializeThread(thread) {
2121
2153
  created_at: m.created_at instanceof Date ? m.created_at.toISOString() : m.created_at,
2122
2154
  tool_calls: m.tool_calls,
2123
2155
  tool_call_id: m.tool_call_id,
2124
- metadata: m.metadata
2156
+ metadata: m.metadata,
2157
+ parent_id: m.parent_id,
2158
+ children_ids: m.children_ids
2125
2159
  }))
2126
2160
  };
2127
2161
  }
@@ -2134,6 +2168,7 @@ function deserializeThread(data) {
2134
2168
  createdAt: new Date(data.createdAt),
2135
2169
  updatedAt: new Date(data.updatedAt),
2136
2170
  sources: data.sources || [],
2171
+ activeLeafId: data.activeLeafId,
2137
2172
  messages: (data.messages || []).map((m) => ({
2138
2173
  id: m.id,
2139
2174
  role: m.role,
@@ -2141,7 +2176,9 @@ function deserializeThread(data) {
2141
2176
  created_at: new Date(m.created_at),
2142
2177
  tool_calls: m.tool_calls,
2143
2178
  tool_call_id: m.tool_call_id,
2144
- metadata: m.metadata
2179
+ metadata: m.metadata,
2180
+ parent_id: m.parent_id,
2181
+ children_ids: m.children_ids
2145
2182
  }))
2146
2183
  };
2147
2184
  }
@@ -2181,9 +2218,25 @@ function writeStore(storageKey, store) {
2181
2218
  localStorage.setItem(storageKey, serialized);
2182
2219
  } catch (e) {
2183
2220
  if (e instanceof DOMException && e.name === "QuotaExceededError") {
2184
- console.error(
2185
- "[CopilotSDK] localStorage quota exceeded. Consider clearing old threads."
2186
- );
2221
+ if (store.threads.length > 1) {
2222
+ const evicted = [...store.threads].sort(
2223
+ (a, b) => new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime()
2224
+ );
2225
+ const trimmed = { ...store, threads: evicted.slice(1) };
2226
+ console.warn(
2227
+ "[CopilotSDK] localStorage quota exceeded \u2014 evicting oldest thread:",
2228
+ evicted[0].id
2229
+ );
2230
+ try {
2231
+ localStorage.setItem(storageKey, JSON.stringify(trimmed));
2232
+ } catch {
2233
+ console.error("[CopilotSDK] localStorage still full after eviction.");
2234
+ }
2235
+ } else {
2236
+ console.error(
2237
+ "[CopilotSDK] localStorage quota exceeded and only one thread remains. Cannot evict."
2238
+ );
2239
+ }
2187
2240
  } else {
2188
2241
  console.warn("[CopilotSDK] Failed to write store:", e);
2189
2242
  }
@@ -2625,7 +2678,8 @@ var ThreadManager = class {
2625
2678
  preview: options?.messages?.[0]?.content ? generatePreview(
2626
2679
  typeof options.messages[0].content === "string" ? options.messages[0].content : ""
2627
2680
  ) : void 0,
2628
- messageCount: options?.messages?.length ?? 0
2681
+ messageCount: options?.messages?.length ?? 0,
2682
+ activeLeafId: options?.activeLeafId
2629
2683
  };
2630
2684
  const asyncAdapter = this.adapter;
2631
2685
  if (asyncAdapter.createThread) {
@@ -2939,5 +2993,5 @@ exports.stopNetworkCapture = stopNetworkCapture;
2939
2993
  exports.streamSSE = streamSSE;
2940
2994
  exports.zodObjectToInputSchema = zodObjectToInputSchema;
2941
2995
  exports.zodToJsonSchema = zodToJsonSchema;
2942
- //# sourceMappingURL=chunk-WIXFZUEZ.cjs.map
2943
- //# sourceMappingURL=chunk-WIXFZUEZ.cjs.map
2996
+ //# sourceMappingURL=chunk-KGYDGK3U.cjs.map
2997
+ //# sourceMappingURL=chunk-KGYDGK3U.cjs.map