@glodon-aiot/bot-client-sdk 3.26.0-alpha.9 → 3.26.1
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 +271 -225
- package/dist/es/AgentSession.mjs +301 -228
- package/dist/es/BotClient.mjs +200 -123
- package/dist/es/Config.mjs +56 -67
- package/dist/es/DialogSession.mjs +123 -118
- package/dist/es/EventBus.mjs +38 -34
- package/dist/es/Logger.mjs +19 -21
- package/dist/es/PayloadTypes.mjs +13 -2
- package/dist/es/Session.mjs +405 -312
- 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 +73 -67
- 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 +34 -54
- 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 +6 -7
- package/dist/src/EventBus.d.ts +3 -0
- package/dist/src/Logger.d.ts +15 -8
- package/dist/src/PayloadTypes.d.ts +20 -0
- package/dist/src/Session.d.ts +24 -3
- 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 +6 -3
- 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
package/dist/es/index.mjs
CHANGED
|
@@ -1,71 +1,77 @@
|
|
|
1
|
-
import { configuration as e, configure as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { configuration as e, configure as _, getRegisteredLocalFilesPluginCode as E, resolveLocalFilesPluginCode as T } from "./Config.mjs";
|
|
2
|
+
import { default as L } from "./BotClient.mjs";
|
|
3
|
+
import { default as A, SessionErrors as t } from "./Session.mjs";
|
|
4
|
+
import { USAGE_ERROR_DEFAULT_MESSAGES as C, UsageErrorCode as l, isUsageErrorCode as D } from "./PayloadTypes.mjs";
|
|
5
|
+
import { default as R } from "./AgentPlugin.mjs";
|
|
6
|
+
import { ToolCode as F, ToolError as a, toToolError as i } from "./localFiles/errors.mjs";
|
|
7
|
+
import { LOCAL_FILE_TOOL_SCHEMAS as p } from "./localFiles/schemas.mjs";
|
|
8
|
+
import { BUILTIN_TOOL_SCHEMAS as U } from "./builtinTools/schemas.mjs";
|
|
9
|
+
import { createLocalFilesPlugin as M } from "./localFiles/createLocalFilesPlugin.mjs";
|
|
10
|
+
import { LocalWorkspace as n } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
11
|
+
import { WorkspaceFiles as H, normalizeFilePath as c } from "./localFiles/workspace/WorkspaceFiles.mjs";
|
|
12
|
+
import { createIndexedDbStore as X, createMemoryStore as P } from "./localFiles/workspace/handleStore.mjs";
|
|
13
|
+
import { FileSystemAccessAdapter as G } from "./localFiles/adapters/FileSystemAccessAdapter.mjs";
|
|
14
|
+
import { MemoryWorkspaceAdapter as Y } from "./localFiles/adapters/MemoryWorkspaceAdapter.mjs";
|
|
15
|
+
import { HOST_BRIDGE_GLOBAL as k, HOST_CHANNEL as y, SANDBOX_MAX_FILE_BYTES as K, registerHostBridge as b } from "./localFiles/host/protocol.mjs";
|
|
16
|
+
import { createDefaultSessionFileTransfer as v } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
17
|
+
import { getDownloadUrlAllowlist as V, isDownloadUrlAllowed as Z } from "./localFiles/security/downloadUrlPolicy.mjs";
|
|
18
|
+
import { SDK_SENSITIVE_BASELINE as q } from "./localFiles/security/sensitiveFiles.mjs";
|
|
19
|
+
import { BINARY_SNIFF_BYTES as Q, BUILTIN_TOOLS_PLUGIN_CODE as $, BUILTIN_TOOLS_PLUGIN_CODES as oo, DEFAULT_DOWNLOAD_URL_ALLOWLIST as ro, DEFAULT_IGNORED_DIRECTORIES as eo, DEFAULT_IGNORED_FILE_PATTERNS as _o, DEFAULT_LIMITS as Eo, KiB as To, LIST_DIRECTORY_DEFAULT_LIMIT as So, LIST_DIRECTORY_MAX_LIMIT as Lo, LOCAL_FILES_FUNCTION_CODES as Io, LOCAL_FILES_PLUGIN_CODES as Ao, MiB as to, SEARCH_DEFAULT_DEPTH as Oo, SEARCH_FUNCTION_CODES as Co, SEARCH_MAX_DEPTH as lo, TEXT_SEARCH_MAX_CONTEXT_LINES as Do, TEXT_SEARCH_MAX_FILES as No, TEXT_SEARCH_MAX_FILE_BYTES as Ro, TEXT_SEARCH_MAX_LINE_CHARS as so, TRANSFER_FILE_SIZE_LIMIT_MB as Fo, TRANSFER_FUNCTION_CODES as ao, WORKSPACE_GRANT_ID as io, WRITE_FUNCTION_CODES as fo } from "./localFiles/constants.mjs";
|
|
17
20
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
21
|
+
R as AgentPlugin,
|
|
22
|
+
Q as BINARY_SNIFF_BYTES,
|
|
23
|
+
$ as BUILTIN_TOOLS_PLUGIN_CODE,
|
|
24
|
+
oo as BUILTIN_TOOLS_PLUGIN_CODES,
|
|
25
|
+
U as BUILTIN_TOOL_SCHEMAS,
|
|
26
|
+
L as BotClient,
|
|
27
|
+
ro as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
|
|
28
|
+
eo as DEFAULT_IGNORED_DIRECTORIES,
|
|
29
|
+
_o as DEFAULT_IGNORED_FILE_PATTERNS,
|
|
30
|
+
Eo as DEFAULT_LIMITS,
|
|
31
|
+
G as FileSystemAccessAdapter,
|
|
32
|
+
k as HOST_BRIDGE_GLOBAL,
|
|
33
|
+
y as HOST_CHANNEL,
|
|
34
|
+
To as KiB,
|
|
35
|
+
So as LIST_DIRECTORY_DEFAULT_LIMIT,
|
|
36
|
+
Lo as LIST_DIRECTORY_MAX_LIMIT,
|
|
37
|
+
Io as LOCAL_FILES_FUNCTION_CODES,
|
|
38
|
+
Ao as LOCAL_FILES_PLUGIN_CODES,
|
|
39
|
+
p as LOCAL_FILE_TOOL_SCHEMAS,
|
|
40
|
+
n as LocalWorkspace,
|
|
41
|
+
Y as MemoryWorkspaceAdapter,
|
|
42
|
+
to as MiB,
|
|
43
|
+
K as SANDBOX_MAX_FILE_BYTES,
|
|
44
|
+
q as SDK_SENSITIVE_BASELINE,
|
|
45
|
+
Oo as SEARCH_DEFAULT_DEPTH,
|
|
46
|
+
Co as SEARCH_FUNCTION_CODES,
|
|
47
|
+
lo as SEARCH_MAX_DEPTH,
|
|
48
|
+
A as Session,
|
|
49
|
+
t as SessionErrors,
|
|
50
|
+
Do as TEXT_SEARCH_MAX_CONTEXT_LINES,
|
|
51
|
+
No as TEXT_SEARCH_MAX_FILES,
|
|
52
|
+
Ro as TEXT_SEARCH_MAX_FILE_BYTES,
|
|
53
|
+
so as TEXT_SEARCH_MAX_LINE_CHARS,
|
|
54
|
+
Fo as TRANSFER_FILE_SIZE_LIMIT_MB,
|
|
55
|
+
ao as TRANSFER_FUNCTION_CODES,
|
|
56
|
+
F as ToolCode,
|
|
57
|
+
a as ToolError,
|
|
58
|
+
C as USAGE_ERROR_DEFAULT_MESSAGES,
|
|
59
|
+
l as UsageErrorCode,
|
|
60
|
+
io as WORKSPACE_GRANT_ID,
|
|
61
|
+
fo as WRITE_FUNCTION_CODES,
|
|
62
|
+
H as WorkspaceFiles,
|
|
59
63
|
e as configuration,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
_ as configure,
|
|
65
|
+
v as createDefaultSessionFileTransfer,
|
|
66
|
+
X as createIndexedDbStore,
|
|
67
|
+
M as createLocalFilesPlugin,
|
|
68
|
+
P as createMemoryStore,
|
|
69
|
+
V as getDownloadUrlAllowlist,
|
|
66
70
|
E as getRegisteredLocalFilesPluginCode,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
Z as isDownloadUrlAllowed,
|
|
72
|
+
D as isUsageErrorCode,
|
|
73
|
+
c as normalizeFilePath,
|
|
74
|
+
b as registerHostBridge,
|
|
75
|
+
T as resolveLocalFilesPluginCode,
|
|
76
|
+
i as toToolError
|
|
71
77
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var y = (n, r) => {
|
|
3
|
+
if (r = Symbol[n])
|
|
4
|
+
return r;
|
|
5
|
+
throw Error("Symbol." + n + " is not defined");
|
|
6
|
+
};
|
|
7
|
+
var g = (n, r, e) => r in n ? M(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
|
|
8
|
+
var m = (n, r, e) => (g(n, typeof r != "symbol" ? r + "" : r, e), e);
|
|
9
|
+
var f = (n, r, e) => new Promise((t, o) => {
|
|
10
|
+
var i = (s) => {
|
|
11
|
+
try {
|
|
12
|
+
c(e.next(s));
|
|
13
|
+
} catch (d) {
|
|
14
|
+
o(d);
|
|
15
|
+
}
|
|
16
|
+
}, l = (s) => {
|
|
17
|
+
try {
|
|
18
|
+
c(e.throw(s));
|
|
19
|
+
} catch (d) {
|
|
20
|
+
o(d);
|
|
21
|
+
}
|
|
22
|
+
}, c = (s) => s.done ? t(s.value) : Promise.resolve(s.value).then(i, l);
|
|
23
|
+
c((e = e.apply(n, r)).next());
|
|
24
|
+
});
|
|
25
|
+
var u = (n, r, e) => (r = n[y("asyncIterator")]) ? r.call(n) : (n = n[y("iterator")](), r = {}, e = (t, o) => (o = n[t]) && (r[t] = (i) => new Promise((l, c, s) => (i = o.call(n, i), s = i.done, Promise.resolve(i.value).then((d) => l({ value: d, done: s }), c)))), e("next"), e("return"), r);
|
|
26
|
+
import { domError as a, toChunks as D } from "./WorkspaceFileAdapter.mjs";
|
|
27
|
+
import { throwIfAborted as w } from "../errors.mjs";
|
|
28
|
+
import { splitPath as h } from "../security/pathPolicy.mjs";
|
|
29
|
+
function k() {
|
|
30
|
+
return {
|
|
31
|
+
kind: "directory",
|
|
32
|
+
children: /* @__PURE__ */ new Map()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
class A {
|
|
36
|
+
constructor(r, e) {
|
|
37
|
+
m(this, "root", k());
|
|
38
|
+
var t;
|
|
39
|
+
this.displayName = e;
|
|
40
|
+
for (const o of r) {
|
|
41
|
+
const i = E(o, e);
|
|
42
|
+
i && this.writeNode(i, o.blob, (t = o.lastModified) != null ? t : Date.now());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
writeNode(r, e, t) {
|
|
46
|
+
const o = r.split("/").filter(Boolean), i = o.pop();
|
|
47
|
+
if (!i)
|
|
48
|
+
return;
|
|
49
|
+
this.resolveDirectory(o, !0).children.set(i, {
|
|
50
|
+
kind: "file",
|
|
51
|
+
blob: e,
|
|
52
|
+
lastModified: t
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
resolveDirectory(r, e = !1) {
|
|
56
|
+
let t = this.root;
|
|
57
|
+
for (const o of r) {
|
|
58
|
+
let i = t.children.get(o);
|
|
59
|
+
if (!i) {
|
|
60
|
+
if (!e)
|
|
61
|
+
throw a("NotFoundError");
|
|
62
|
+
i = k(), t.children.set(o, i);
|
|
63
|
+
}
|
|
64
|
+
if (i.kind !== "directory")
|
|
65
|
+
throw a("TypeMismatchError");
|
|
66
|
+
t = i;
|
|
67
|
+
}
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
resolveNode(r) {
|
|
71
|
+
const e = h(r), t = e.pop();
|
|
72
|
+
if (t === void 0)
|
|
73
|
+
return this.root;
|
|
74
|
+
const o = this.resolveDirectory(e).children.get(t);
|
|
75
|
+
if (!o)
|
|
76
|
+
throw a("NotFoundError");
|
|
77
|
+
return o;
|
|
78
|
+
}
|
|
79
|
+
stat(r) {
|
|
80
|
+
return f(this, null, function* () {
|
|
81
|
+
var o;
|
|
82
|
+
const e = this.resolveNode(r), t = (o = h(r).pop()) != null ? o : this.displayName;
|
|
83
|
+
return e.kind === "directory" ? {
|
|
84
|
+
name: t,
|
|
85
|
+
kind: "directory"
|
|
86
|
+
} : {
|
|
87
|
+
name: t,
|
|
88
|
+
kind: "file",
|
|
89
|
+
size: e.blob.size,
|
|
90
|
+
lastModified: e.lastModified
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
listEntries(r, e) {
|
|
95
|
+
return f(this, null, function* () {
|
|
96
|
+
w(e);
|
|
97
|
+
const t = this.resolveDirectory(h(r));
|
|
98
|
+
return Array.from(t.children.entries()).map(([o, i]) => i.kind === "directory" ? {
|
|
99
|
+
name: o,
|
|
100
|
+
kind: "directory"
|
|
101
|
+
} : {
|
|
102
|
+
name: o,
|
|
103
|
+
kind: "file",
|
|
104
|
+
size: i.blob.size,
|
|
105
|
+
lastModified: i.lastModified
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
readFile(r) {
|
|
110
|
+
return f(this, null, function* () {
|
|
111
|
+
const e = this.resolveNode(r);
|
|
112
|
+
if (e.kind !== "file")
|
|
113
|
+
throw a("TypeMismatchError");
|
|
114
|
+
return e.blob;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** 只更新内存中的快照,不会写回用户磁盘。 */
|
|
118
|
+
writeFile(o, i) {
|
|
119
|
+
return f(this, arguments, function* (r, e, t = {}) {
|
|
120
|
+
const l = h(r), c = l.pop();
|
|
121
|
+
if (!c)
|
|
122
|
+
throw a("TypeMismatchError");
|
|
123
|
+
const s = this.resolveDirectory(l, t.createDirectories), d = s.children.get(c);
|
|
124
|
+
if ((d == null ? void 0 : d.kind) === "directory")
|
|
125
|
+
throw a("TypeMismatchError");
|
|
126
|
+
const p = [];
|
|
127
|
+
try {
|
|
128
|
+
for (var B = u(D(e)), C, I, R; C = !(I = yield B.next()).done; C = !1) {
|
|
129
|
+
const v = I.value;
|
|
130
|
+
w(t.signal), p.push(v);
|
|
131
|
+
}
|
|
132
|
+
} catch (I) {
|
|
133
|
+
R = [I];
|
|
134
|
+
} finally {
|
|
135
|
+
try {
|
|
136
|
+
C && (I = B.return) && (yield I.call(B));
|
|
137
|
+
} finally {
|
|
138
|
+
if (R)
|
|
139
|
+
throw R[0];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const b = new Blob(p);
|
|
143
|
+
s.children.set(c, {
|
|
144
|
+
kind: "file",
|
|
145
|
+
blob: b,
|
|
146
|
+
lastModified: Date.now()
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function E(n, r) {
|
|
152
|
+
const e = (n.webkitRelativePath || n.name).replace(/\\/g, "/").replace(/^\/+/, "");
|
|
153
|
+
if (!e)
|
|
154
|
+
return "";
|
|
155
|
+
const t = `${r}/`;
|
|
156
|
+
return e.startsWith(t) ? e.slice(t.length) : e;
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
A as FileSnapshotAdapter
|
|
160
|
+
};
|