@glodon-aiot/bot-client-sdk 3.26.0-alpha.9 → 3.27.0-alpha.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.
- package/README.md +246 -225
- package/dist/es/AgentSession.mjs +275 -197
- package/dist/es/BotClient.mjs +200 -123
- package/dist/es/Config.mjs +58 -68
- package/dist/es/DialogSession.mjs +123 -118
- package/dist/es/EventBus.mjs +38 -34
- package/dist/es/Logger.mjs +19 -21
- package/dist/es/Session.mjs +338 -284
- package/dist/es/api/index.mjs +31 -30
- package/dist/es/builtinTools/constants.mjs +12 -5
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +182 -160
- package/dist/es/builtinTools/paths.mjs +34 -27
- package/dist/es/builtinTools/platformSkills.mjs +248 -0
- package/dist/es/builtinTools/schemas.mjs +63 -18
- package/dist/es/builtinTools/tools.mjs +368 -244
- package/dist/es/index.mjs +62 -61
- package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +160 -0
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -131
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +60 -55
- package/dist/es/localFiles/constants.mjs +24 -28
- package/dist/es/localFiles/createLocalFilesPlugin.mjs +53 -52
- package/dist/es/localFiles/errors.mjs +44 -35
- package/dist/es/localFiles/host/connectHostBridge.mjs +20 -15
- package/dist/es/localFiles/host/protocol.mjs +27 -14
- package/dist/es/localFiles/host/sandboxClient.mjs +297 -127
- package/dist/es/localFiles/preview.mjs +33 -0
- package/dist/es/localFiles/schemas.mjs +22 -53
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +156 -89
- package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +246 -0
- package/dist/es/localMcp/client.mjs +234 -0
- package/dist/es/localMcp/endpoints.mjs +94 -0
- package/dist/es/localMcp/register.mjs +207 -0
- package/dist/es/localMcp/registry.mjs +43 -0
- package/dist/es/package.json.mjs +29 -49
- package/dist/es/sessionUpload.mjs +49 -0
- package/dist/es/utils.mjs +24 -11
- package/dist/lib/index.js +48 -40
- package/dist/src/AgentSession.d.ts +13 -0
- package/dist/src/BotClient.d.ts +13 -1
- package/dist/src/Config.d.ts +14 -7
- package/dist/src/EventBus.d.ts +3 -0
- package/dist/src/Logger.d.ts +15 -8
- package/dist/src/PayloadTypes.d.ts +7 -0
- package/dist/src/Session.d.ts +19 -2
- package/dist/src/api/index.d.ts +2 -2
- package/dist/src/builtinTools/command.d.ts +7 -0
- package/dist/src/builtinTools/constants.d.ts +10 -2
- package/dist/src/builtinTools/paths.d.ts +3 -2
- package/dist/src/builtinTools/platformSkills.d.ts +92 -0
- package/dist/src/builtinTools/tools.d.ts +13 -0
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +24 -0
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +7 -4
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +8 -0
- package/dist/src/localFiles/constants.d.ts +4 -13
- package/dist/src/localFiles/errors.d.ts +1 -1
- package/dist/src/localFiles/host/protocol.d.ts +14 -3
- package/dist/src/localFiles/host/sandboxClient.d.ts +50 -0
- package/dist/src/localFiles/index.d.ts +9 -5
- package/dist/src/localFiles/preview.d.ts +2 -0
- package/dist/src/localFiles/schemas.d.ts +0 -2
- package/dist/src/localFiles/types.d.ts +2 -22
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +25 -3
- package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +63 -0
- package/dist/src/localMcp/client.d.ts +15 -0
- package/dist/src/localMcp/endpoints.d.ts +19 -0
- package/dist/src/localMcp/register.d.ts +34 -0
- package/dist/src/localMcp/registry.d.ts +27 -0
- package/dist/src/sessionUpload.d.ts +14 -0
- package/dist/src/utils.d.ts +6 -0
- package/package.json +4 -24
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var B = Object.getOwnPropertySymbols;
|
|
3
|
+
var T = Object.prototype.hasOwnProperty, k = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var P = (e, o, t) => o in e ? L(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t, $ = (e, o) => {
|
|
5
|
+
for (var t in o || (o = {}))
|
|
6
|
+
T.call(o, t) && P(e, t, o[t]);
|
|
7
|
+
if (B)
|
|
8
|
+
for (var t of B(o))
|
|
9
|
+
k.call(o, t) && P(e, t, o[t]);
|
|
10
|
+
return e;
|
|
11
|
+
};
|
|
12
|
+
var y = (e, o, t) => new Promise((r, n) => {
|
|
13
|
+
var l = (f) => {
|
|
14
|
+
try {
|
|
15
|
+
d(t.next(f));
|
|
16
|
+
} catch (u) {
|
|
17
|
+
n(u);
|
|
18
|
+
}
|
|
19
|
+
}, a = (f) => {
|
|
20
|
+
try {
|
|
21
|
+
d(t.throw(f));
|
|
22
|
+
} catch (u) {
|
|
23
|
+
n(u);
|
|
24
|
+
}
|
|
25
|
+
}, d = (f) => f.done ? r(f.value) : Promise.resolve(f.value).then(l, a);
|
|
26
|
+
d((t = t.apply(e, o)).next());
|
|
27
|
+
});
|
|
28
|
+
import { refreshBuiltinPlugins as z } from "../Config.mjs";
|
|
29
|
+
import H from "../Logger.mjs";
|
|
30
|
+
import { retainMcpSessions as A, listMcpTools as O, dropUnusedMcpSession as I, callMcpTool as U } from "./client.mjs";
|
|
31
|
+
import { currentLocalMcpEndpoints as b } from "./endpoints.mjs";
|
|
32
|
+
import { replaceLocalMcpTools as E, localMcpBindings as D, localMcpBinding as R } from "./registry.mjs";
|
|
33
|
+
const m = new H("[LocalMcp] ");
|
|
34
|
+
function Z(e) {
|
|
35
|
+
const o = e == null ? void 0 : e.mcps;
|
|
36
|
+
return Array.isArray(o) ? o.filter((t) => t && typeof t == "object" && t.runtime === "local" && t.id) : [];
|
|
37
|
+
}
|
|
38
|
+
function F(e, o, t) {
|
|
39
|
+
return e == null || e.includes(o) ? !0 : !!t && e.includes(t);
|
|
40
|
+
}
|
|
41
|
+
function V(e) {
|
|
42
|
+
if (!e || typeof e != "object")
|
|
43
|
+
return {};
|
|
44
|
+
const o = {};
|
|
45
|
+
for (const [t, r] of Object.entries(e))
|
|
46
|
+
typeof r == "string" && (o[t] = r);
|
|
47
|
+
return o;
|
|
48
|
+
}
|
|
49
|
+
function W(e) {
|
|
50
|
+
var a, d;
|
|
51
|
+
if (!e || typeof e != "object")
|
|
52
|
+
return null;
|
|
53
|
+
const o = e;
|
|
54
|
+
if (typeof o.code == "number" && o.code !== 200)
|
|
55
|
+
return null;
|
|
56
|
+
const t = o.data && typeof o.data == "object" ? o.data : o, r = typeof t.code == "string" ? t.code : "", n = r ? (a = t.mcpServers) == null ? void 0 : a[r] : void 0, l = typeof (n == null ? void 0 : n.url) == "string" ? n.url : void 0;
|
|
57
|
+
return {
|
|
58
|
+
code: r,
|
|
59
|
+
deployType: typeof ((d = t.deployConfig) == null ? void 0 : d.type) == "string" ? t.deployConfig.type : void 0,
|
|
60
|
+
url: l,
|
|
61
|
+
headers: V(n == null ? void 0 : n.headers)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function q(n, l, a) {
|
|
65
|
+
return y(this, arguments, function* (e, o, t, r = fetch) {
|
|
66
|
+
const d = e.replace(/\/$/, ""), f = o.startsWith("Bearer ") ? o : `Bearer ${o}`, u = yield r(`${d}/mcpmgr/v1/mcpserver/${encodeURIComponent(t)}`, {
|
|
67
|
+
headers: {
|
|
68
|
+
Authorization: f
|
|
69
|
+
}
|
|
70
|
+
}), g = yield u.json().catch(() => null);
|
|
71
|
+
if (!u.ok)
|
|
72
|
+
throw new Error(`MCP 详情 HTTP ${u.status}`);
|
|
73
|
+
const h = W(g);
|
|
74
|
+
if (!h)
|
|
75
|
+
throw new Error("MCP 详情不可用");
|
|
76
|
+
return h;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function G(e) {
|
|
80
|
+
return /^[A-Za-z][A-Za-z0-9.+-]* /.test(e) ? e : `Bearer ${e}`;
|
|
81
|
+
}
|
|
82
|
+
function J(e, o) {
|
|
83
|
+
if (!(o != null && o.token))
|
|
84
|
+
return $({}, e);
|
|
85
|
+
const t = {};
|
|
86
|
+
for (const [r, n] of Object.entries(e))
|
|
87
|
+
r.toLowerCase() !== "authorization" && (t[r] = n);
|
|
88
|
+
return t.Authorization = G(o.token), t;
|
|
89
|
+
}
|
|
90
|
+
function K(e, o, t) {
|
|
91
|
+
const r = e.find((n) => !o.has(n) && t(n));
|
|
92
|
+
return r && o.add(r), r;
|
|
93
|
+
}
|
|
94
|
+
function N(e, o, t) {
|
|
95
|
+
return K(e, o, (r) => r.code === t || r.id === t);
|
|
96
|
+
}
|
|
97
|
+
function Q(e, o, t) {
|
|
98
|
+
var l;
|
|
99
|
+
const r = e == null ? void 0 : e.mcpServers;
|
|
100
|
+
if (!r)
|
|
101
|
+
return;
|
|
102
|
+
const n = (l = r[t]) != null ? l : r[o];
|
|
103
|
+
return (n == null ? void 0 : n.url) || void 0;
|
|
104
|
+
}
|
|
105
|
+
function X(e, o) {
|
|
106
|
+
return (t, r, n) => {
|
|
107
|
+
const l = R(e);
|
|
108
|
+
if (!l) {
|
|
109
|
+
r({
|
|
110
|
+
code: 500,
|
|
111
|
+
message: "缺少 MCP 地址"
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
U(l, e, t, n == null ? void 0 : n.signal, o).then((a) => r({
|
|
116
|
+
code: 0,
|
|
117
|
+
message: "ok",
|
|
118
|
+
data: a
|
|
119
|
+
})).catch((a) => {
|
|
120
|
+
r({
|
|
121
|
+
code: 500,
|
|
122
|
+
message: a instanceof Error ? a.message : String(a)
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function ne(e) {
|
|
128
|
+
return y(this, null, function* () {
|
|
129
|
+
var h, _;
|
|
130
|
+
const o = (h = e.fetchImpl) != null ? h : fetch, t = e.initMcp ? Object.keys((_ = e.initMcp.mcpServers) != null ? _ : {}) : null, r = Z(e.arrange), n = b().revision, l = () => b().revision !== n || (e.isCurrent ? !e.isCurrent() : !1);
|
|
131
|
+
if (!r.length) {
|
|
132
|
+
if (l())
|
|
133
|
+
return;
|
|
134
|
+
m.log("编排里没有 runtime=local 的 MCP,不发送 register_client_mcp_tools"), E([]), A([]), z();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const a = [...b().servers], d = /* @__PURE__ */ new Set(), f = yield Promise.all(r.map((c) => y(this, null, function* () {
|
|
138
|
+
var j, w;
|
|
139
|
+
const s = c.id;
|
|
140
|
+
let p;
|
|
141
|
+
const v = () => {
|
|
142
|
+
p && (d.delete(p), p = void 0);
|
|
143
|
+
};
|
|
144
|
+
try {
|
|
145
|
+
const i = yield q(e.apiRoot, e.token, s, o);
|
|
146
|
+
if (!F(t, s, i.code))
|
|
147
|
+
return null;
|
|
148
|
+
p = i.code ? N(a, d, i.code) : void 0;
|
|
149
|
+
const C = (w = (j = p == null ? void 0 : p.url) != null ? j : Q(e.initMcp, s, i.code)) != null ? w : i.url;
|
|
150
|
+
if (i.deployType !== "streamableHttp" || !i.code || !C)
|
|
151
|
+
return m.log("skip local mcp", s), v(), null;
|
|
152
|
+
const M = {
|
|
153
|
+
code: i.code,
|
|
154
|
+
url: C,
|
|
155
|
+
headers: J(i.headers, p)
|
|
156
|
+
}, S = yield O(M, o);
|
|
157
|
+
return S.length ? {
|
|
158
|
+
code: i.code,
|
|
159
|
+
url: M.url,
|
|
160
|
+
binding: M,
|
|
161
|
+
tools: S
|
|
162
|
+
} : (v(), null);
|
|
163
|
+
} catch (i) {
|
|
164
|
+
return v(), m.report("local mcp failed", s, i instanceof Error ? i.message : String(i)), null;
|
|
165
|
+
}
|
|
166
|
+
})));
|
|
167
|
+
if (l()) {
|
|
168
|
+
const c = D();
|
|
169
|
+
for (const s of f)
|
|
170
|
+
s && I(s.binding, c);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const u = {}, g = [];
|
|
174
|
+
for (const c of f)
|
|
175
|
+
if (c) {
|
|
176
|
+
u[c.code] = {
|
|
177
|
+
type: "streamableHttp",
|
|
178
|
+
url: c.url,
|
|
179
|
+
tools: c.tools
|
|
180
|
+
};
|
|
181
|
+
for (const s of c.tools)
|
|
182
|
+
g.push({
|
|
183
|
+
name: s.name,
|
|
184
|
+
binding: c.binding,
|
|
185
|
+
handler: X(s.name, o)
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (E(g), A(g.map((c) => c.binding)), z(), !Object.keys(u).length || !e.socket) {
|
|
189
|
+
m.log("没有可注册的本地 MCP 工具,不发送 register_client_mcp_tools");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
m.log("发送 register_client_mcp_tools", Object.entries(u).map(([c, s]) => `${c}: ${s.tools.map((p) => p.name).join(", ")}`).join("; ")), e.socket.emit("register_client_mcp_tools", {
|
|
193
|
+
mcpServers: u
|
|
194
|
+
}, (c) => {
|
|
195
|
+
const s = c && typeof c == "object" ? c.code : void 0;
|
|
196
|
+
typeof s == "number" && s !== 200 && m.report("register_client_mcp_tools", s);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
F as detailMatchesInit,
|
|
202
|
+
q as fetchMcpDetail,
|
|
203
|
+
J as headersForEndpoint,
|
|
204
|
+
Z as listedLocalMcps,
|
|
205
|
+
W as parseMcpDetail,
|
|
206
|
+
ne as registerLocalMcp
|
|
207
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var f = Object.defineProperty, p = Object.defineProperties;
|
|
2
|
+
var s = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var i = Object.getOwnPropertySymbols;
|
|
4
|
+
var M = Object.prototype.hasOwnProperty, g = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var r = (l, n, c) => n in l ? f(l, n, { enumerable: !0, configurable: !0, writable: !0, value: c }) : l[n] = c, e = (l, n) => {
|
|
6
|
+
for (var c in n || (n = {}))
|
|
7
|
+
M.call(n, c) && r(l, c, n[c]);
|
|
8
|
+
if (i)
|
|
9
|
+
for (var c of i(n))
|
|
10
|
+
g.call(n, c) && r(l, c, n[c]);
|
|
11
|
+
return l;
|
|
12
|
+
}, u = (l, n) => p(l, s(n));
|
|
13
|
+
const a = "MCP", t = /* @__PURE__ */ new Map();
|
|
14
|
+
let o = null;
|
|
15
|
+
function b(l, n, c) {
|
|
16
|
+
t.set(l, n), o = u(e({}, o != null ? o : {}), {
|
|
17
|
+
[l]: c
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function L(l) {
|
|
21
|
+
t.clear(), o = null;
|
|
22
|
+
for (const n of l)
|
|
23
|
+
b(n.name, n.binding, n.handler);
|
|
24
|
+
o && !Object.keys(o).length && (o = null);
|
|
25
|
+
}
|
|
26
|
+
function P(l) {
|
|
27
|
+
return t.get(l);
|
|
28
|
+
}
|
|
29
|
+
function y() {
|
|
30
|
+
return [...t.values()];
|
|
31
|
+
}
|
|
32
|
+
function C(l) {
|
|
33
|
+
var n;
|
|
34
|
+
!o || !Object.keys(o).length || (l[a] = e(e({}, (n = l[a]) != null ? n : {}), o));
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
a as MCP_PLUGIN_CODE,
|
|
38
|
+
C as applyLocalMcpPlugins,
|
|
39
|
+
P as localMcpBinding,
|
|
40
|
+
y as localMcpBindings,
|
|
41
|
+
b as rememberLocalMcpTool,
|
|
42
|
+
L as replaceLocalMcpTools
|
|
43
|
+
};
|
package/dist/es/package.json.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const s = "@glodon-aiot/bot-client-sdk", t = "3.27.0-alpha.0", e = "glodoncv", i = "aiot bot client js sdk", n = "module", y = !1, d = [
|
|
2
2
|
"aiot",
|
|
3
3
|
"bot",
|
|
4
4
|
"bot client",
|
|
5
5
|
"sdk"
|
|
6
|
-
],
|
|
6
|
+
], o = [
|
|
7
7
|
"dist"
|
|
8
|
-
],
|
|
8
|
+
], c = "./dist/es/index.mjs", l = "./dist/lib/index.js", p = "./dist/src/index.d.ts", r = {
|
|
9
9
|
".": {
|
|
10
10
|
import: "./dist/es/index.mjs",
|
|
11
11
|
require: "./dist/lib/index.js",
|
|
@@ -13,21 +13,18 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.9", t = "glodoncv", i
|
|
|
13
13
|
}
|
|
14
14
|
}, a = "MIT", u = {
|
|
15
15
|
watch: "yarn build --watch",
|
|
16
|
-
example: "node ./example/server.js",
|
|
17
|
-
dev: "npm-run-all -p watch example",
|
|
18
|
-
start: "vite",
|
|
19
16
|
build: "tsc && vite build --mode prod && yarn build:cdn",
|
|
20
17
|
"build:npm": "tsc && vite build --mode prod",
|
|
21
18
|
"build:cdn": "tsc && vite build --mode prod --config ./vite.config.cdn.ts",
|
|
22
|
-
preview: "vite preview",
|
|
23
19
|
check: "yarn prettier --check .",
|
|
24
20
|
write: "yarn prettier --write .",
|
|
25
|
-
lint: "eslint --ext .
|
|
21
|
+
lint: "eslint --ext .ts src -c .eslintrc.cjs",
|
|
26
22
|
"build:just-bash": "node scripts/build-just-bash.mjs",
|
|
27
23
|
"upload:just-bash": "node scripts/build-just-bash.mjs && node scripts/upload-cdn-libs.cjs just-bash",
|
|
28
24
|
"build:pyodide": "node scripts/build-pyodide.mjs",
|
|
29
25
|
"upload:pyodide": "node scripts/build-pyodide.mjs && node scripts/upload-cdn-libs.cjs pyodide",
|
|
30
26
|
test: "vitest run",
|
|
27
|
+
"test:e2e": "vitest run -c vitest.e2e.config.ts",
|
|
31
28
|
"test:watch": "vitest"
|
|
32
29
|
}, b = {
|
|
33
30
|
"@babel/core": "^7.20.12",
|
|
@@ -35,58 +32,41 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.9", t = "glodoncv", i
|
|
|
35
32
|
"@commitlint/config-conventional": "^17.0.3",
|
|
36
33
|
"@rollup/plugin-babel": "^6.0.4",
|
|
37
34
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
38
|
-
"@types/express": "^4",
|
|
39
|
-
"@types/identity-obj-proxy": "^3",
|
|
40
35
|
"@typescript-eslint/eslint-plugin": "^5.35.1",
|
|
41
36
|
"@typescript-eslint/parser": "^5.35.1",
|
|
42
|
-
"babel-loader": "^8.3.0",
|
|
43
37
|
eslint: "^8.0.1",
|
|
44
38
|
"eslint-config-prettier": "^8.5.0",
|
|
45
|
-
"eslint-config-standard-with-typescript": "^22.0.0",
|
|
46
|
-
"eslint-plugin-import": "^2.25.2",
|
|
47
|
-
"eslint-plugin-n": "^15.0.0",
|
|
48
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
49
|
-
"eslint-plugin-react": "^7.31.0",
|
|
50
|
-
"eslint-plugin-storybook": "^0.6.10",
|
|
51
|
-
express: "4",
|
|
52
|
-
"http-proxy-middleware": "^3.0.0",
|
|
53
|
-
"identity-obj-proxy": "^3.0.0",
|
|
54
39
|
"just-bash": "3.6.0",
|
|
55
|
-
"npm-run-all": "^4.1.5",
|
|
56
40
|
prettier: "2.7.1",
|
|
57
41
|
pyodide: "314.0.7",
|
|
58
|
-
"rollup-plugin-visualizer": "^6.0.1",
|
|
59
42
|
"socket.io": "^4.7.5",
|
|
60
|
-
"ts-node": "^10.9.2",
|
|
61
43
|
typescript: "*",
|
|
62
44
|
vite: "^4.1.1",
|
|
63
45
|
"vite-plugin-dts": "^4.3.0",
|
|
64
46
|
"vite-plugin-externalize-deps": "^0.9.0",
|
|
65
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
66
47
|
vitest: "^0.34.6"
|
|
67
|
-
},
|
|
48
|
+
}, j = {
|
|
68
49
|
access: "public",
|
|
69
50
|
registry: "https://registry.npmjs.org/"
|
|
70
|
-
},
|
|
71
|
-
"@glodon-aiot/apis": "^3.
|
|
51
|
+
}, m = {
|
|
52
|
+
"@glodon-aiot/apis": "^3.27.0-alpha.0",
|
|
72
53
|
axios: "0.24.0",
|
|
73
|
-
buffer: "^6.0.3",
|
|
74
54
|
dayjs: "^1.11.13",
|
|
75
55
|
"js-base64": "^3.7.7",
|
|
76
56
|
"socket.io-client": "^4.7.5",
|
|
77
57
|
uuid: "^11.1.0"
|
|
78
|
-
},
|
|
79
|
-
name:
|
|
80
|
-
version:
|
|
81
|
-
author:
|
|
58
|
+
}, g = {
|
|
59
|
+
name: s,
|
|
60
|
+
version: t,
|
|
61
|
+
author: e,
|
|
82
62
|
description: i,
|
|
83
63
|
type: n,
|
|
84
64
|
sideEffects: !1,
|
|
85
|
-
keywords:
|
|
86
|
-
files:
|
|
87
|
-
module:
|
|
65
|
+
keywords: d,
|
|
66
|
+
files: o,
|
|
67
|
+
module: c,
|
|
88
68
|
main: l,
|
|
89
|
-
typings:
|
|
69
|
+
typings: p,
|
|
90
70
|
exports: r,
|
|
91
71
|
license: a,
|
|
92
72
|
scripts: u,
|
|
@@ -94,26 +74,26 @@ const e = "@glodon-aiot/bot-client-sdk", s = "3.26.0-alpha.9", t = "glodoncv", i
|
|
|
94
74
|
"lint-staged": {
|
|
95
75
|
"*.{js,css,md,jsx,less,ts,tsx,json}": "prettier --write"
|
|
96
76
|
},
|
|
97
|
-
publishConfig:
|
|
98
|
-
dependencies:
|
|
77
|
+
publishConfig: j,
|
|
78
|
+
dependencies: m
|
|
99
79
|
};
|
|
100
80
|
export {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
e as author,
|
|
82
|
+
g as default,
|
|
83
|
+
m as dependencies,
|
|
104
84
|
i as description,
|
|
105
85
|
b as devDependencies,
|
|
106
86
|
r as exports,
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
o as files,
|
|
88
|
+
d as keywords,
|
|
109
89
|
a as license,
|
|
110
90
|
l as main,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
c as module,
|
|
92
|
+
s as name,
|
|
93
|
+
j as publishConfig,
|
|
114
94
|
u as scripts,
|
|
115
|
-
|
|
95
|
+
y as sideEffects,
|
|
116
96
|
n as type,
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
p as typings,
|
|
98
|
+
t as version
|
|
119
99
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var l = (t, e, o) => new Promise((c, n) => {
|
|
2
|
+
var p = (i) => {
|
|
3
|
+
try {
|
|
4
|
+
s(o.next(i));
|
|
5
|
+
} catch (a) {
|
|
6
|
+
n(a);
|
|
7
|
+
}
|
|
8
|
+
}, r = (i) => {
|
|
9
|
+
try {
|
|
10
|
+
s(o.throw(i));
|
|
11
|
+
} catch (a) {
|
|
12
|
+
n(a);
|
|
13
|
+
}
|
|
14
|
+
}, s = (i) => i.done ? c(i.value) : Promise.resolve(i.value).then(p, r);
|
|
15
|
+
s((o = o.apply(t, e)).next());
|
|
16
|
+
});
|
|
17
|
+
import { v4 as u } from "uuid";
|
|
18
|
+
function $(t, e, o) {
|
|
19
|
+
return l(this, null, function* () {
|
|
20
|
+
var s;
|
|
21
|
+
if (!e)
|
|
22
|
+
throw new Error("session is not avalible. id is undefined");
|
|
23
|
+
const c = d(o.name), n = yield t.postUploadTicket({
|
|
24
|
+
files: [c],
|
|
25
|
+
isv: "minio",
|
|
26
|
+
knowledgeId: e,
|
|
27
|
+
type: 1
|
|
28
|
+
}), r = (yield t.uploadMinioFile(n.minio, o)) || ((s = n.minio.fileKeys) == null ? void 0 : s[0]);
|
|
29
|
+
return {
|
|
30
|
+
url: f(n.minio, r),
|
|
31
|
+
name: o.name || c,
|
|
32
|
+
size: o.size
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function d(t) {
|
|
37
|
+
const e = t.split(/[/\\]/).pop() || "", o = /\.([A-Za-z0-9]{1,16})$/.exec(e);
|
|
38
|
+
return o ? `${u()}.${o[1].toLowerCase()}` : u();
|
|
39
|
+
}
|
|
40
|
+
function f(t, e) {
|
|
41
|
+
var n;
|
|
42
|
+
const o = (n = t.endpoints) == null ? void 0 : n[0];
|
|
43
|
+
if (!o || !t.bucket || !e)
|
|
44
|
+
throw new Error("上传没有返回文件地址。");
|
|
45
|
+
return `${t.useSSL ? "https:" : typeof location != "undefined" && location.protocol ? location.protocol : "http:"}//${o}/${t.bucket}/${e}`;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
$ as uploadSessionFile
|
|
49
|
+
};
|
package/dist/es/utils.mjs
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import { decode as
|
|
2
|
-
const
|
|
3
|
-
const e =
|
|
1
|
+
import { decode as f } from "js-base64";
|
|
2
|
+
const i = (n) => JSON.parse(f(n.split(".")[1])), y = (n) => {
|
|
3
|
+
const e = i(n).exp;
|
|
4
4
|
return (/* @__PURE__ */ new Date()).valueOf() / 1e3 >= e;
|
|
5
|
-
}
|
|
5
|
+
};
|
|
6
|
+
function t(n) {
|
|
7
|
+
if (n === null || typeof n != "object")
|
|
8
|
+
return JSON.stringify(n);
|
|
9
|
+
if (Array.isArray(n))
|
|
10
|
+
return `[${n.map(t).join(",")}]`;
|
|
11
|
+
const e = n;
|
|
12
|
+
return `{${Object.keys(e).sort().map((r) => `${JSON.stringify(r)}:${t(e[r])}`).join(",")}}`;
|
|
13
|
+
}
|
|
14
|
+
const a = (n, e) => {
|
|
15
|
+
const s = i(n), r = i(e);
|
|
16
|
+
return s.rid === r.rid && s.ten === r.ten && t(s.ext) === t(r.ext) && t(s.label) === t(r.label);
|
|
17
|
+
}, g = (n) => n == null ? void 0 : n.replace(/[\r\n]+/gm, ""), d = (n) => n.replace(/\\|\\/g, ""), w = (n, e, s, r) => {
|
|
6
18
|
if (n !== !0)
|
|
7
19
|
return null;
|
|
8
|
-
const
|
|
9
|
-
return
|
|
20
|
+
const o = (e == null ? void 0 : e.includeUserQuestion) === !0, u = (e == null ? void 0 : e.includeAiAnswer) === !0 || !o, c = [];
|
|
21
|
+
return o && c.push(`问题:${r}`), u && c.push(`回答:${s}`), c.join(`
|
|
10
22
|
`);
|
|
11
23
|
};
|
|
12
24
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
y as isExpired,
|
|
26
|
+
i as parseJWT,
|
|
27
|
+
d as removeLeadingAndTrailingBackslashes,
|
|
28
|
+
g as removeNewlines,
|
|
29
|
+
w as resolveRelatedQuestionContent,
|
|
30
|
+
a as sameResourceTokenPayload
|
|
18
31
|
};
|