@opentiny/next-sdk 0.1.7 → 0.1.8

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.
@@ -24889,6 +24889,8 @@
24889
24889
  img.src = await this.toDataURL();
24890
24890
  }
24891
24891
  }
24892
+ const DEFAULT_REMOTE_URL = "https://agent.opentiny.design/tiny-robot";
24893
+ const DEFAULT_QR_CODE_URL = "https://ai.opentiny.design/next-remoter";
24892
24894
  const getDefaultMenuItems = (options) => {
24893
24895
  return [
24894
24896
  {
@@ -24937,8 +24939,8 @@
24937
24939
  {
24938
24940
  action: "remote-url",
24939
24941
  show: true,
24940
- text: `${options.qrCodeUrl}`,
24941
- tip: options.qrCodeUrl,
24942
+ text: `${options.remoteUrl}`,
24943
+ tip: options.remoteUrl,
24942
24944
  showCopyIcon: true,
24943
24945
  icon: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
24944
24946
  <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
@@ -24954,8 +24956,9 @@
24954
24956
  throw new Error("sessionId is required");
24955
24957
  }
24956
24958
  this.options = {
24957
- qrCodeUrl: options.qrCodeUrl || "https://ai.opentiny.design/next-remoter",
24958
- ...options
24959
+ ...options,
24960
+ qrCodeUrl: options.qrCodeUrl || DEFAULT_QR_CODE_URL,
24961
+ remoteUrl: options.remoteUrl || DEFAULT_REMOTE_URL
24959
24962
  };
24960
24963
  this.menuItems = this.mergeMenuItems(options.menuItems);
24961
24964
  this.init();
@@ -24999,7 +25002,7 @@
24999
25002
  this.floatingBlock.className = "tiny-remoter-floating-block";
25000
25003
  this.floatingBlock.innerHTML = `
25001
25004
  <div class="tiny-remoter-floating-block__icon">
25002
- <img style="display: block; width: 56px;" src="https://ai.opentiny.design/next-remoter/svgs/logo-next-no-bg-left.svg" alt="icon" />
25005
+ <img style="display: block; width: 56px;" src="${DEFAULT_QR_CODE_URL}/svgs/logo-next-no-bg-left.svg" alt="icon" />
25003
25006
  </div>
25004
25007
  `;
25005
25008
  document.body.appendChild(this.floatingBlock);
@@ -25099,7 +25102,7 @@
25099
25102
  this.copyToClipboard(this.options.sessionId.slice(-6));
25100
25103
  }
25101
25104
  copyRemoteURL() {
25102
- this.copyToClipboard((this.options.qrCodeUrl || "") + this.sessionPrefix + this.options.sessionId);
25105
+ this.copyToClipboard((this.options.remoteUrl || DEFAULT_REMOTE_URL) + this.sessionPrefix + this.options.sessionId);
25103
25106
  }
25104
25107
  // 实现复制到剪贴板功能
25105
25108
  async copyToClipboard(text2) {
@@ -43204,7 +43207,6 @@ ${user}:`]
43204
43207
  this.mcpClients = [];
43205
43208
  this.mcpTools = [];
43206
43209
  this.ignoreToolnames = [];
43207
- this.autoUpdateTools = true;
43208
43210
  this.messages = [];
43209
43211
  this.mcpServers = mcpServers || [];
43210
43212
  if (llm) {
@@ -43272,7 +43274,7 @@ ${user}:`]
43272
43274
  await Promise.all(
43273
43275
  this.mcpClients.map(async (client) => {
43274
43276
  try {
43275
- await client.close();
43277
+ await (client == null ? void 0 : client.close());
43276
43278
  } catch (error2) {
43277
43279
  if (this.onError) {
43278
43280
  this.onError((error2 == null ? void 0 : error2.message) || `Failed to close client`, error2);
@@ -43322,7 +43324,7 @@ ${user}:`]
43322
43324
  }
43323
43325
  }
43324
43326
  /** 创建临时允许调用的tools集合 */
43325
- tempMergeTools(extraTool = {}) {
43327
+ _tempMergeTools(extraTool = {}) {
43326
43328
  const toolsResult = this.mcpTools.reduce((acc, curr) => ({ ...acc, ...curr }), {});
43327
43329
  Object.assign(toolsResult, extraTool);
43328
43330
  this.ignoreToolnames.forEach((name16) => {
@@ -43335,16 +43337,14 @@ ${user}:`]
43335
43337
  if (!this.llm) {
43336
43338
  throw new Error("LLM is not initialized");
43337
43339
  }
43338
- if (this.autoUpdateTools) {
43339
- await this._createMpcTools();
43340
- (_a16 = this.onUpdatedTools) == null ? void 0 : _a16.call(this);
43341
- }
43340
+ await this.initClientsAndTools();
43341
+ (_a16 = this.onUpdatedTools) == null ? void 0 : _a16.call(this);
43342
43342
  const chatOptions = {
43343
43343
  // @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
43344
43344
  model: this.llm(model),
43345
43345
  stopWhen: stepCountIs(maxSteps),
43346
43346
  ...options,
43347
- tools: this.tempMergeTools(options.tools)
43347
+ tools: this._tempMergeTools(options.tools)
43348
43348
  };
43349
43349
  if (options.message && !options.messages) {
43350
43350
  this.messages.push({ role: "user", content: options.message });