@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.
- package/agent/AgentModelProvider.ts +9 -11
- package/dist/agent/AgentModelProvider.d.ts +3 -9
- package/dist/agent/AgentModelProvider.js +6 -9
- package/dist/index.es.dev.js +14 -14
- package/dist/index.es.js +2630 -2629
- package/dist/index.umd.dev.js +14 -14
- package/dist/index.umd.js +24 -24
- package/dist/mcpsdk@1.17.0.es.js +6297 -6312
- package/dist/mcpsdk@1.17.0.js +16 -16
- package/dist/remoter/createRemoter.d.ts +2 -0
- package/dist/remoter/createRemoter.js +7 -5
- package/dist/webagent.dev.js +14 -14
- package/dist/webagent.es.dev.js +14 -14
- package/dist/webagent.es.js +1596 -1595
- package/dist/webagent.js +22 -22
- package/dist/webmcp-full.dev.js +958 -922
- package/dist/webmcp-full.es.dev.js +958 -922
- package/package.json +1 -1
- package/remoter/createRemoter.ts +12 -6
|
@@ -8,6 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { QrCode } from './QrCode';
|
|
11
|
+
const DEFAULT_REMOTE_URL = 'https://agent.opentiny.design/tiny-robot';
|
|
12
|
+
const DEFAULT_QR_CODE_URL = 'https://ai.opentiny.design/next-remoter';
|
|
11
13
|
const getDefaultMenuItems = (options) => {
|
|
12
14
|
return [
|
|
13
15
|
{
|
|
@@ -56,8 +58,8 @@ const getDefaultMenuItems = (options) => {
|
|
|
56
58
|
{
|
|
57
59
|
action: 'remote-url',
|
|
58
60
|
show: true,
|
|
59
|
-
text: `${options.
|
|
60
|
-
tip: options.
|
|
61
|
+
text: `${options.remoteUrl}`,
|
|
62
|
+
tip: options.remoteUrl,
|
|
61
63
|
showCopyIcon: true,
|
|
62
64
|
icon: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
63
65
|
<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"/>
|
|
@@ -77,7 +79,7 @@ class FloatingBlock {
|
|
|
77
79
|
if (!options.sessionId) {
|
|
78
80
|
throw new Error('sessionId is required');
|
|
79
81
|
}
|
|
80
|
-
this.options = Object.assign({ qrCodeUrl: options.qrCodeUrl ||
|
|
82
|
+
this.options = Object.assign(Object.assign({}, options), { qrCodeUrl: options.qrCodeUrl || DEFAULT_QR_CODE_URL, remoteUrl: options.remoteUrl || DEFAULT_REMOTE_URL });
|
|
81
83
|
// 合并默认菜单项配置和用户配置
|
|
82
84
|
this.menuItems = this.mergeMenuItems(options.menuItems);
|
|
83
85
|
this.init();
|
|
@@ -113,7 +115,7 @@ class FloatingBlock {
|
|
|
113
115
|
this.floatingBlock.className = 'tiny-remoter-floating-block';
|
|
114
116
|
this.floatingBlock.innerHTML = `
|
|
115
117
|
<div class="tiny-remoter-floating-block__icon">
|
|
116
|
-
<img style="display: block; width: 56px;" src="
|
|
118
|
+
<img style="display: block; width: 56px;" src="${DEFAULT_QR_CODE_URL}/svgs/logo-next-no-bg-left.svg" alt="icon" />
|
|
117
119
|
</div>
|
|
118
120
|
`;
|
|
119
121
|
document.body.appendChild(this.floatingBlock);
|
|
@@ -224,7 +226,7 @@ class FloatingBlock {
|
|
|
224
226
|
this.copyToClipboard(this.options.sessionId.slice(-6));
|
|
225
227
|
}
|
|
226
228
|
copyRemoteURL() {
|
|
227
|
-
this.copyToClipboard((this.options.
|
|
229
|
+
this.copyToClipboard((this.options.remoteUrl || DEFAULT_REMOTE_URL) + this.sessionPrefix + this.options.sessionId);
|
|
228
230
|
}
|
|
229
231
|
// 实现复制到剪贴板功能
|
|
230
232
|
copyToClipboard(text) {
|
package/dist/webagent.dev.js
CHANGED
|
@@ -24644,7 +24644,6 @@ ${user}:`]
|
|
|
24644
24644
|
this.mcpClients = [];
|
|
24645
24645
|
this.mcpTools = [];
|
|
24646
24646
|
this.ignoreToolnames = [];
|
|
24647
|
-
this.autoUpdateTools = true;
|
|
24648
24647
|
this.messages = [];
|
|
24649
24648
|
this.mcpServers = mcpServers || [];
|
|
24650
24649
|
if (llm) {
|
|
@@ -24712,7 +24711,7 @@ ${user}:`]
|
|
|
24712
24711
|
await Promise.all(
|
|
24713
24712
|
this.mcpClients.map(async (client) => {
|
|
24714
24713
|
try {
|
|
24715
|
-
await client.close();
|
|
24714
|
+
await (client == null ? void 0 : client.close());
|
|
24716
24715
|
} catch (error) {
|
|
24717
24716
|
if (this.onError) {
|
|
24718
24717
|
this.onError((error == null ? void 0 : error.message) || `Failed to close client`, error);
|
|
@@ -24762,7 +24761,7 @@ ${user}:`]
|
|
|
24762
24761
|
}
|
|
24763
24762
|
}
|
|
24764
24763
|
/** 创建临时允许调用的tools集合 */
|
|
24765
|
-
|
|
24764
|
+
_tempMergeTools(extraTool = {}) {
|
|
24766
24765
|
const toolsResult = this.mcpTools.reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
24767
24766
|
Object.assign(toolsResult, extraTool);
|
|
24768
24767
|
this.ignoreToolnames.forEach((name16) => {
|
|
@@ -24775,16 +24774,14 @@ ${user}:`]
|
|
|
24775
24774
|
if (!this.llm) {
|
|
24776
24775
|
throw new Error("LLM is not initialized");
|
|
24777
24776
|
}
|
|
24778
|
-
|
|
24779
|
-
|
|
24780
|
-
(_a16 = this.onUpdatedTools) == null ? void 0 : _a16.call(this);
|
|
24781
|
-
}
|
|
24777
|
+
await this.initClientsAndTools();
|
|
24778
|
+
(_a16 = this.onUpdatedTools) == null ? void 0 : _a16.call(this);
|
|
24782
24779
|
const chatOptions = {
|
|
24783
24780
|
// @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
|
|
24784
24781
|
model: this.llm(model),
|
|
24785
24782
|
stopWhen: stepCountIs(maxSteps),
|
|
24786
24783
|
...options,
|
|
24787
|
-
tools: this.
|
|
24784
|
+
tools: this._tempMergeTools(options.tools)
|
|
24788
24785
|
};
|
|
24789
24786
|
if (options.message && !options.messages) {
|
|
24790
24787
|
this.messages.push({ role: "user", content: options.message });
|
|
@@ -26785,6 +26782,8 @@ ${user}:`]
|
|
|
26785
26782
|
img.src = await this.toDataURL();
|
|
26786
26783
|
}
|
|
26787
26784
|
}
|
|
26785
|
+
const DEFAULT_REMOTE_URL = "https://agent.opentiny.design/tiny-robot";
|
|
26786
|
+
const DEFAULT_QR_CODE_URL = "https://ai.opentiny.design/next-remoter";
|
|
26788
26787
|
const getDefaultMenuItems = (options) => {
|
|
26789
26788
|
return [
|
|
26790
26789
|
{
|
|
@@ -26833,8 +26832,8 @@ ${user}:`]
|
|
|
26833
26832
|
{
|
|
26834
26833
|
action: "remote-url",
|
|
26835
26834
|
show: true,
|
|
26836
|
-
text: `${options.
|
|
26837
|
-
tip: options.
|
|
26835
|
+
text: `${options.remoteUrl}`,
|
|
26836
|
+
tip: options.remoteUrl,
|
|
26838
26837
|
showCopyIcon: true,
|
|
26839
26838
|
icon: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
26840
26839
|
<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"/>
|
|
@@ -26850,8 +26849,9 @@ ${user}:`]
|
|
|
26850
26849
|
throw new Error("sessionId is required");
|
|
26851
26850
|
}
|
|
26852
26851
|
this.options = {
|
|
26853
|
-
|
|
26854
|
-
|
|
26852
|
+
...options,
|
|
26853
|
+
qrCodeUrl: options.qrCodeUrl || DEFAULT_QR_CODE_URL,
|
|
26854
|
+
remoteUrl: options.remoteUrl || DEFAULT_REMOTE_URL
|
|
26855
26855
|
};
|
|
26856
26856
|
this.menuItems = this.mergeMenuItems(options.menuItems);
|
|
26857
26857
|
this.init();
|
|
@@ -26895,7 +26895,7 @@ ${user}:`]
|
|
|
26895
26895
|
this.floatingBlock.className = "tiny-remoter-floating-block";
|
|
26896
26896
|
this.floatingBlock.innerHTML = `
|
|
26897
26897
|
<div class="tiny-remoter-floating-block__icon">
|
|
26898
|
-
<img style="display: block; width: 56px;" src="
|
|
26898
|
+
<img style="display: block; width: 56px;" src="${DEFAULT_QR_CODE_URL}/svgs/logo-next-no-bg-left.svg" alt="icon" />
|
|
26899
26899
|
</div>
|
|
26900
26900
|
`;
|
|
26901
26901
|
document.body.appendChild(this.floatingBlock);
|
|
@@ -26995,7 +26995,7 @@ ${user}:`]
|
|
|
26995
26995
|
this.copyToClipboard(this.options.sessionId.slice(-6));
|
|
26996
26996
|
}
|
|
26997
26997
|
copyRemoteURL() {
|
|
26998
|
-
this.copyToClipboard((this.options.
|
|
26998
|
+
this.copyToClipboard((this.options.remoteUrl || DEFAULT_REMOTE_URL) + this.sessionPrefix + this.options.sessionId);
|
|
26999
26999
|
}
|
|
27000
27000
|
// 实现复制到剪贴板功能
|
|
27001
27001
|
async copyToClipboard(text2) {
|
package/dist/webagent.es.dev.js
CHANGED
|
@@ -24250,7 +24250,6 @@ class AgentModelProvider {
|
|
|
24250
24250
|
this.mcpClients = [];
|
|
24251
24251
|
this.mcpTools = [];
|
|
24252
24252
|
this.ignoreToolnames = [];
|
|
24253
|
-
this.autoUpdateTools = true;
|
|
24254
24253
|
this.messages = [];
|
|
24255
24254
|
this.mcpServers = mcpServers || [];
|
|
24256
24255
|
if (llm) {
|
|
@@ -24318,7 +24317,7 @@ class AgentModelProvider {
|
|
|
24318
24317
|
await Promise.all(
|
|
24319
24318
|
this.mcpClients.map(async (client) => {
|
|
24320
24319
|
try {
|
|
24321
|
-
await client.close();
|
|
24320
|
+
await (client == null ? void 0 : client.close());
|
|
24322
24321
|
} catch (error) {
|
|
24323
24322
|
if (this.onError) {
|
|
24324
24323
|
this.onError((error == null ? void 0 : error.message) || `Failed to close client`, error);
|
|
@@ -24368,7 +24367,7 @@ class AgentModelProvider {
|
|
|
24368
24367
|
}
|
|
24369
24368
|
}
|
|
24370
24369
|
/** 创建临时允许调用的tools集合 */
|
|
24371
|
-
|
|
24370
|
+
_tempMergeTools(extraTool = {}) {
|
|
24372
24371
|
const toolsResult = this.mcpTools.reduce((acc, curr) => ({ ...acc, ...curr }), {});
|
|
24373
24372
|
Object.assign(toolsResult, extraTool);
|
|
24374
24373
|
this.ignoreToolnames.forEach((name16) => {
|
|
@@ -24381,16 +24380,14 @@ class AgentModelProvider {
|
|
|
24381
24380
|
if (!this.llm) {
|
|
24382
24381
|
throw new Error("LLM is not initialized");
|
|
24383
24382
|
}
|
|
24384
|
-
|
|
24385
|
-
|
|
24386
|
-
(_a16 = this.onUpdatedTools) == null ? void 0 : _a16.call(this);
|
|
24387
|
-
}
|
|
24383
|
+
await this.initClientsAndTools();
|
|
24384
|
+
(_a16 = this.onUpdatedTools) == null ? void 0 : _a16.call(this);
|
|
24388
24385
|
const chatOptions = {
|
|
24389
24386
|
// @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
|
|
24390
24387
|
model: this.llm(model),
|
|
24391
24388
|
stopWhen: stepCountIs(maxSteps),
|
|
24392
24389
|
...options,
|
|
24393
|
-
tools: this.
|
|
24390
|
+
tools: this._tempMergeTools(options.tools)
|
|
24394
24391
|
};
|
|
24395
24392
|
if (options.message && !options.messages) {
|
|
24396
24393
|
this.messages.push({ role: "user", content: options.message });
|
|
@@ -26391,6 +26388,8 @@ class QrCode {
|
|
|
26391
26388
|
img.src = await this.toDataURL();
|
|
26392
26389
|
}
|
|
26393
26390
|
}
|
|
26391
|
+
const DEFAULT_REMOTE_URL = "https://agent.opentiny.design/tiny-robot";
|
|
26392
|
+
const DEFAULT_QR_CODE_URL = "https://ai.opentiny.design/next-remoter";
|
|
26394
26393
|
const getDefaultMenuItems = (options) => {
|
|
26395
26394
|
return [
|
|
26396
26395
|
{
|
|
@@ -26439,8 +26438,8 @@ const getDefaultMenuItems = (options) => {
|
|
|
26439
26438
|
{
|
|
26440
26439
|
action: "remote-url",
|
|
26441
26440
|
show: true,
|
|
26442
|
-
text: `${options.
|
|
26443
|
-
tip: options.
|
|
26441
|
+
text: `${options.remoteUrl}`,
|
|
26442
|
+
tip: options.remoteUrl,
|
|
26444
26443
|
showCopyIcon: true,
|
|
26445
26444
|
icon: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
26446
26445
|
<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"/>
|
|
@@ -26456,8 +26455,9 @@ class FloatingBlock {
|
|
|
26456
26455
|
throw new Error("sessionId is required");
|
|
26457
26456
|
}
|
|
26458
26457
|
this.options = {
|
|
26459
|
-
|
|
26460
|
-
|
|
26458
|
+
...options,
|
|
26459
|
+
qrCodeUrl: options.qrCodeUrl || DEFAULT_QR_CODE_URL,
|
|
26460
|
+
remoteUrl: options.remoteUrl || DEFAULT_REMOTE_URL
|
|
26461
26461
|
};
|
|
26462
26462
|
this.menuItems = this.mergeMenuItems(options.menuItems);
|
|
26463
26463
|
this.init();
|
|
@@ -26501,7 +26501,7 @@ class FloatingBlock {
|
|
|
26501
26501
|
this.floatingBlock.className = "tiny-remoter-floating-block";
|
|
26502
26502
|
this.floatingBlock.innerHTML = `
|
|
26503
26503
|
<div class="tiny-remoter-floating-block__icon">
|
|
26504
|
-
<img style="display: block; width: 56px;" src="
|
|
26504
|
+
<img style="display: block; width: 56px;" src="${DEFAULT_QR_CODE_URL}/svgs/logo-next-no-bg-left.svg" alt="icon" />
|
|
26505
26505
|
</div>
|
|
26506
26506
|
`;
|
|
26507
26507
|
document.body.appendChild(this.floatingBlock);
|
|
@@ -26601,7 +26601,7 @@ class FloatingBlock {
|
|
|
26601
26601
|
this.copyToClipboard(this.options.sessionId.slice(-6));
|
|
26602
26602
|
}
|
|
26603
26603
|
copyRemoteURL() {
|
|
26604
|
-
this.copyToClipboard((this.options.
|
|
26604
|
+
this.copyToClipboard((this.options.remoteUrl || DEFAULT_REMOTE_URL) + this.sessionPrefix + this.options.sessionId);
|
|
26605
26605
|
}
|
|
26606
26606
|
// 实现复制到剪贴板功能
|
|
26607
26607
|
async copyToClipboard(text2) {
|