@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.
Files changed (73) hide show
  1. package/README.md +271 -225
  2. package/dist/es/AgentSession.mjs +301 -228
  3. package/dist/es/BotClient.mjs +200 -123
  4. package/dist/es/Config.mjs +56 -67
  5. package/dist/es/DialogSession.mjs +123 -118
  6. package/dist/es/EventBus.mjs +38 -34
  7. package/dist/es/Logger.mjs +19 -21
  8. package/dist/es/PayloadTypes.mjs +13 -2
  9. package/dist/es/Session.mjs +405 -312
  10. package/dist/es/api/index.mjs +31 -30
  11. package/dist/es/builtinTools/constants.mjs +12 -5
  12. package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +182 -160
  13. package/dist/es/builtinTools/paths.mjs +34 -27
  14. package/dist/es/builtinTools/platformSkills.mjs +248 -0
  15. package/dist/es/builtinTools/schemas.mjs +63 -18
  16. package/dist/es/builtinTools/tools.mjs +368 -244
  17. package/dist/es/index.mjs +73 -67
  18. package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +160 -0
  19. package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -131
  20. package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +60 -55
  21. package/dist/es/localFiles/constants.mjs +24 -28
  22. package/dist/es/localFiles/createLocalFilesPlugin.mjs +53 -52
  23. package/dist/es/localFiles/errors.mjs +44 -35
  24. package/dist/es/localFiles/host/connectHostBridge.mjs +20 -15
  25. package/dist/es/localFiles/host/protocol.mjs +27 -14
  26. package/dist/es/localFiles/host/sandboxClient.mjs +297 -127
  27. package/dist/es/localFiles/preview.mjs +33 -0
  28. package/dist/es/localFiles/schemas.mjs +22 -53
  29. package/dist/es/localFiles/workspace/LocalWorkspace.mjs +156 -89
  30. package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +246 -0
  31. package/dist/es/localMcp/client.mjs +234 -0
  32. package/dist/es/localMcp/endpoints.mjs +94 -0
  33. package/dist/es/localMcp/register.mjs +207 -0
  34. package/dist/es/localMcp/registry.mjs +43 -0
  35. package/dist/es/package.json.mjs +34 -54
  36. package/dist/es/sessionUpload.mjs +49 -0
  37. package/dist/es/utils.mjs +24 -11
  38. package/dist/lib/index.js +48 -40
  39. package/dist/src/AgentSession.d.ts +13 -0
  40. package/dist/src/BotClient.d.ts +13 -1
  41. package/dist/src/Config.d.ts +6 -7
  42. package/dist/src/EventBus.d.ts +3 -0
  43. package/dist/src/Logger.d.ts +15 -8
  44. package/dist/src/PayloadTypes.d.ts +20 -0
  45. package/dist/src/Session.d.ts +24 -3
  46. package/dist/src/api/index.d.ts +2 -2
  47. package/dist/src/builtinTools/command.d.ts +7 -0
  48. package/dist/src/builtinTools/constants.d.ts +10 -2
  49. package/dist/src/builtinTools/paths.d.ts +3 -2
  50. package/dist/src/builtinTools/platformSkills.d.ts +92 -0
  51. package/dist/src/builtinTools/tools.d.ts +13 -0
  52. package/dist/src/constant.d.ts +1 -1
  53. package/dist/src/index.d.ts +6 -3
  54. package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +24 -0
  55. package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +7 -4
  56. package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +8 -0
  57. package/dist/src/localFiles/constants.d.ts +4 -13
  58. package/dist/src/localFiles/errors.d.ts +1 -1
  59. package/dist/src/localFiles/host/protocol.d.ts +14 -3
  60. package/dist/src/localFiles/host/sandboxClient.d.ts +50 -0
  61. package/dist/src/localFiles/index.d.ts +9 -5
  62. package/dist/src/localFiles/preview.d.ts +2 -0
  63. package/dist/src/localFiles/schemas.d.ts +0 -2
  64. package/dist/src/localFiles/types.d.ts +2 -22
  65. package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +25 -3
  66. package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +63 -0
  67. package/dist/src/localMcp/client.d.ts +15 -0
  68. package/dist/src/localMcp/endpoints.d.ts +19 -0
  69. package/dist/src/localMcp/register.d.ts +34 -0
  70. package/dist/src/localMcp/registry.d.ts +27 -0
  71. package/dist/src/sessionUpload.d.ts +14 -0
  72. package/dist/src/utils.d.ts +6 -0
  73. package/package.json +4 -24
package/dist/es/index.mjs CHANGED
@@ -1,71 +1,77 @@
1
- import { configuration as e, configure as T, getRegisteredLocalFilesPluginCode as E, getRegisteredLocalPythonPluginCode as r, resolveLocalFilesPluginCode as L } from "./Config.mjs";
2
- import { default as S } from "./BotClient.mjs";
3
- import { default as O } from "./Session.mjs";
4
- import { default as C } from "./AgentPlugin.mjs";
5
- import { ToolCode as l, ToolError as D, toToolError as R } from "./localFiles/errors.mjs";
6
- import { LOCAL_FILE_TOOL_SCHEMAS as a, LOCAL_PYTHON_TOOL_SCHEMA as U } from "./localFiles/schemas.mjs";
7
- import { BUILTIN_TOOL_SCHEMAS as M } from "./builtinTools/schemas.mjs";
8
- import { createLocalFilesPlugin as s } from "./localFiles/createLocalFilesPlugin.mjs";
9
- import { LocalWorkspace as P } from "./localFiles/workspace/LocalWorkspace.mjs";
10
- import { createIndexedDbStore as H, createMemoryStore as n } from "./localFiles/workspace/handleStore.mjs";
11
- import { FileSystemAccessAdapter as d } from "./localFiles/adapters/FileSystemAccessAdapter.mjs";
12
- import { MemoryWorkspaceAdapter as g } from "./localFiles/adapters/MemoryWorkspaceAdapter.mjs";
13
- import { createDefaultSessionFileTransfer as u } from "./localFiles/transfer/SessionFileTransfer.mjs";
14
- import { getDownloadUrlAllowlist as Y, isDownloadUrlAllowed as G } from "./localFiles/security/downloadUrlPolicy.mjs";
15
- import { SDK_SENSITIVE_BASELINE as w } from "./localFiles/security/sensitiveFiles.mjs";
16
- import { BINARY_SNIFF_BYTES as K, BUILTIN_TOOLS_PLUGIN_CODE as k, BUILTIN_TOOLS_PLUGIN_CODES as b, DEFAULT_DOWNLOAD_URL_ALLOWLIST as h, DEFAULT_IGNORED_DIRECTORIES as v, DEFAULT_IGNORED_FILE_PATTERNS as V, DEFAULT_LIMITS as Z, KiB as j, LIST_DIRECTORY_DEFAULT_LIMIT as q, LIST_DIRECTORY_MAX_LIMIT as z, LOCAL_FILES_FUNCTION_CODES as J, LOCAL_FILES_PLUGIN_CODES as Q, LOCAL_PYTHON_FUNCTION_CODE as $, LOCAL_PYTHON_PLUGIN_CODES as __, MiB as o_, PYTHON_DEFAULT_TIMEOUT_MS as e_, PYTHON_MAX_ARGS as T_, PYTHON_MAX_TIMEOUT_MS as E_, SEARCH_DEFAULT_DEPTH as r_, SEARCH_FUNCTION_CODES as L_, SEARCH_MAX_DEPTH as I_, TEXT_SEARCH_MAX_CONTEXT_LINES as S_, TEXT_SEARCH_MAX_FILES as A_, TEXT_SEARCH_MAX_FILE_BYTES as O_, TEXT_SEARCH_MAX_LINE_CHARS as t_, TRANSFER_FILE_SIZE_LIMIT_MB as C_, TRANSFER_FUNCTION_CODES as N_, WORKSPACE_GRANT_ID as l_, WRITE_FUNCTION_CODES as D_ } from "./localFiles/constants.mjs";
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
- C as AgentPlugin,
19
- K as BINARY_SNIFF_BYTES,
20
- k as BUILTIN_TOOLS_PLUGIN_CODE,
21
- b as BUILTIN_TOOLS_PLUGIN_CODES,
22
- M as BUILTIN_TOOL_SCHEMAS,
23
- S as BotClient,
24
- h as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
25
- v as DEFAULT_IGNORED_DIRECTORIES,
26
- V as DEFAULT_IGNORED_FILE_PATTERNS,
27
- Z as DEFAULT_LIMITS,
28
- d as FileSystemAccessAdapter,
29
- j as KiB,
30
- q as LIST_DIRECTORY_DEFAULT_LIMIT,
31
- z as LIST_DIRECTORY_MAX_LIMIT,
32
- J as LOCAL_FILES_FUNCTION_CODES,
33
- Q as LOCAL_FILES_PLUGIN_CODES,
34
- a as LOCAL_FILE_TOOL_SCHEMAS,
35
- $ as LOCAL_PYTHON_FUNCTION_CODE,
36
- __ as LOCAL_PYTHON_PLUGIN_CODES,
37
- U as LOCAL_PYTHON_TOOL_SCHEMA,
38
- P as LocalWorkspace,
39
- g as MemoryWorkspaceAdapter,
40
- o_ as MiB,
41
- e_ as PYTHON_DEFAULT_TIMEOUT_MS,
42
- T_ as PYTHON_MAX_ARGS,
43
- E_ as PYTHON_MAX_TIMEOUT_MS,
44
- w as SDK_SENSITIVE_BASELINE,
45
- r_ as SEARCH_DEFAULT_DEPTH,
46
- L_ as SEARCH_FUNCTION_CODES,
47
- I_ as SEARCH_MAX_DEPTH,
48
- O as Session,
49
- S_ as TEXT_SEARCH_MAX_CONTEXT_LINES,
50
- A_ as TEXT_SEARCH_MAX_FILES,
51
- O_ as TEXT_SEARCH_MAX_FILE_BYTES,
52
- t_ as TEXT_SEARCH_MAX_LINE_CHARS,
53
- C_ as TRANSFER_FILE_SIZE_LIMIT_MB,
54
- N_ as TRANSFER_FUNCTION_CODES,
55
- l as ToolCode,
56
- D as ToolError,
57
- l_ as WORKSPACE_GRANT_ID,
58
- D_ as WRITE_FUNCTION_CODES,
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
- T as configure,
61
- u as createDefaultSessionFileTransfer,
62
- H as createIndexedDbStore,
63
- s as createLocalFilesPlugin,
64
- n as createMemoryStore,
65
- Y as getDownloadUrlAllowlist,
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
- r as getRegisteredLocalPythonPluginCode,
68
- G as isDownloadUrlAllowed,
69
- L as resolveLocalFilesPluginCode,
70
- R as toToolError
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
+ };