@glodon-aiot/bot-client-sdk 3.26.0-alpha.10 → 3.26.0-alpha.12
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 +14 -16
- package/dist/es/Config.mjs +53 -68
- package/dist/es/index.mjs +58 -61
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +18 -28
- package/dist/es/localFiles/constants.mjs +24 -29
- package/dist/es/localFiles/host/connectHostBridge.mjs +1 -1
- package/dist/es/localFiles/host/protocol.mjs +26 -14
- package/dist/es/localFiles/schemas.mjs +22 -53
- package/dist/es/package.json.mjs +2 -2
- package/dist/lib/index.js +35 -35
- package/dist/src/Config.d.ts +1 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +2 -3
- package/dist/src/localFiles/constants.d.ts +2 -13
- package/dist/src/localFiles/host/protocol.d.ts +11 -2
- package/dist/src/localFiles/index.d.ts +7 -5
- package/dist/src/localFiles/schemas.d.ts +0 -2
- package/dist/src/localFiles/types.d.ts +2 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,9 +8,8 @@ AIoT 应用客户端 SDK,支持 Agent 应用和对话型应用。会话、消
|
|
|
8
8
|
| 会话产出物 | Agent、对话型 | 浏览器、端侧宿主 | [产出物](#产出物) |
|
|
9
9
|
| 业务插件、本地文件 | Agent | 浏览器、端侧宿主 | [Agent 插件](#agent-插件) |
|
|
10
10
|
| 命令与脚本(shell / run_file) | Agent | 浏览器运行时或端侧宿主沙箱 | [命令和脚本](#命令和脚本) |
|
|
11
|
-
| 本地 Python(`localPython` / `run_python`) | Agent | **优先端侧宿主**;浏览器可用 Pyodide | [命令和脚本](#命令和脚本) |
|
|
12
11
|
|
|
13
|
-
浏览器指现代浏览器(命令运行时另需能加载公司 OBS 上的 just-bash / Pyodide
|
|
12
|
+
浏览器指现代浏览器(命令运行时另需能加载公司 OBS 上的 just-bash / Pyodide)。端侧宿主是内嵌此页面、选择本地工程并管理 `@glodon-aiot/workspace-sandbox` 进程的桌面程序;文件和命令由页面直连沙箱,不经过宿主转发,见[宿主通道](#宿主通道)。
|
|
14
13
|
|
|
15
14
|
集成方总览见仓库内 [`bot-client-ui/docs/agent-integration-handbook.md`](../bot-client-ui/docs/agent-integration-handbook.md)。
|
|
16
15
|
|
|
@@ -137,7 +136,6 @@ const client = new BotClient(token, {
|
|
|
137
136
|
},
|
|
138
137
|
builtinPlugins: {
|
|
139
138
|
localFiles: { enabled: true },
|
|
140
|
-
localPython: { enabled: true },
|
|
141
139
|
},
|
|
142
140
|
});
|
|
143
141
|
```
|
|
@@ -156,9 +154,9 @@ const client = new BotClient(token, {
|
|
|
156
154
|
|
|
157
155
|
### 内置插件
|
|
158
156
|
|
|
159
|
-
`localFiles`
|
|
157
|
+
`localFiles` 启用后,SDK 把内置工具注册到 `pluginCode` `builtin_tools`。`client.localWorkspace` 只在 `localFiles.enabled === true` 时存在。
|
|
160
158
|
|
|
161
|
-
`shell` / `run_file` / `run_skill_script` 按[命令和脚本](#命令和脚本)选择执行器:注入的 `commandRunner` →
|
|
159
|
+
`shell` / `run_file` / `run_skill_script` 按[命令和脚本](#命令和脚本)选择执行器:注入的 `commandRunner` → 已就绪的协议 2 沙箱 → 无宿主页面中的 just-bash / Pyodide(默认开启)→ 否则 501。宿主工作区已授权但沙箱未就绪时直接失败,不降级到浏览器运行时。
|
|
162
160
|
|
|
163
161
|
业务 `plugins` 里如果已经有 `builtin_tools` 这个 key,内置工具不会注册,`error` 事件会带上原因。同一页面只支持一个启用了内置插件的 `BotClient`(插件表是全局配置)。
|
|
164
162
|
|
|
@@ -186,11 +184,9 @@ const client = new BotClient(token, {
|
|
|
186
184
|
import {
|
|
187
185
|
BUILTIN_TOOL_SCHEMAS,
|
|
188
186
|
getRegisteredLocalFilesPluginCode,
|
|
189
|
-
getRegisteredLocalPythonPluginCode,
|
|
190
187
|
} from '@glodon-aiot/bot-client-sdk';
|
|
191
188
|
|
|
192
|
-
const
|
|
193
|
-
const schema = pluginCodes.includes(pluginCode)
|
|
189
|
+
const schema = pluginCode === getRegisteredLocalFilesPluginCode()
|
|
194
190
|
? BUILTIN_TOOL_SCHEMAS[funcCode as keyof typeof BUILTIN_TOOL_SCHEMAS]
|
|
195
191
|
: undefined;
|
|
196
192
|
// schema 存在时,展示 schema.name 和参数里的 path / destPath
|
|
@@ -244,7 +240,7 @@ const client = new BotClient(token, {
|
|
|
244
240
|
const workspace = client.localWorkspace;
|
|
245
241
|
```
|
|
246
242
|
|
|
247
|
-
`transfer`
|
|
243
|
+
`transfer` 仍可供旧的上传下载实现使用。当前注册的内置工具不走这套传输。宿主沙箱由 `workspace.sandbox.state === "ready"` 且 `protocol === 2` 表示可用,不在 `commandRuntime` 里配置;`capabilities` 只用于兼容旧的 workspace 消息。
|
|
248
244
|
|
|
249
245
|
### 十一个工具
|
|
250
246
|
|
|
@@ -362,7 +358,7 @@ function isNotAllowed(error: unknown) {
|
|
|
362
358
|
| --- | --- |
|
|
363
359
|
| 浏览器 `FileSystemObserver`(Chrome / Edge) | 发生变化的那些目录。根目录是 `""` |
|
|
364
360
|
| 宿主推送 `fs-changed` | 宿主给的相对目录 |
|
|
365
|
-
| `
|
|
361
|
+
| `shell`、`run_file`、`run_skill_script` 结束 | `[]`,表示重读根目录和当前已经展开的每一层 |
|
|
366
362
|
|
|
367
363
|
```ts
|
|
368
364
|
const expanded = new Set<string>();
|
|
@@ -463,12 +459,12 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
|
|
|
463
459
|
|
|
464
460
|
### 执行器选择顺序
|
|
465
461
|
|
|
466
|
-
1. **注入的** `LocalWorkspace.commandRunner`(测试 /
|
|
462
|
+
1. **注入的** `LocalWorkspace.commandRunner`(测试 / 自定义,优先级最高)
|
|
467
463
|
2. **沙箱直连**:宿主工作区已授权,且 `sandbox.state` 为 `ready`、`protocol` 为 `2` → 页面对 `ws://127.0.0.1` 发 WebSocket,不经宿主转发文件和命令
|
|
468
464
|
3. **浏览器运行时**:没有宿主 WebView 时,`commandRuntime.browser.enabled` 默认为 `true` → just-bash + Pyodide Worker
|
|
469
465
|
4. 以上皆不可用 → **501**
|
|
470
466
|
|
|
471
|
-
宿主工作区已经授权时,沙箱没就绪不会改走浏览器运行时。`starting`
|
|
467
|
+
宿主工作区已经授权时,沙箱没就绪不会改走浏览器运行时。`starting` 时说明正在启动;失败说明使用 `sandbox.message`。协议不是 2 时另发一次 `error` 事件。收到 `bye`、`exited` 或 `failed` 后,在途调用以 `AbortError` 失败且不会重放;只有新的 `ready` 到达后才使用新地址和令牌连接。
|
|
472
468
|
|
|
473
469
|
参照宿主:`examples/qt-workspace-host`。
|
|
474
470
|
|
|
@@ -497,7 +493,7 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
|
|
|
497
493
|
### 宿主沙箱(摘要)
|
|
498
494
|
|
|
499
495
|
- 宿主把沙箱放进独立进程组,启动 `workspace-sandbox --listen --root <工程绝对路径> --origin <页面来源>`
|
|
500
|
-
- 宿主只做五件事:启动、读 ready
|
|
496
|
+
- 宿主只做五件事:启动、读 ready、可选地询问 status、shutdown(3 秒后结束进程组)、把退出告诉页面
|
|
501
497
|
- 页面从 `sandbox.url` / `sandbox.token` 直连。HTTPS 页面仍连 `ws://127.0.0.1`,不提供 `wss://`
|
|
502
498
|
- CSP 的 `connect-src` 要放行 `ws://127.0.0.1:*`。SDK 只加载在可信页面上,同页脚本能读到令牌
|
|
503
499
|
- 启动失败的 `reason` 对应固定说明,例如 `listen-failed` 是「沙箱没有监听到端口。」消息里没有令牌和绝对路径
|
|
@@ -509,9 +505,11 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
|
|
|
509
505
|
|
|
510
506
|
## 宿主通道
|
|
511
507
|
|
|
512
|
-
|
|
508
|
+
端侧宿主是内嵌此页面的桌面程序。页面由哪种内核显示没有要求。
|
|
513
509
|
|
|
514
|
-
`localFiles.backend` 为 `host-bridge`
|
|
510
|
+
`localFiles.backend` 为 `host-bridge` 时,宿主在页面脚本运行前提供消息桥 `globalThis.__glodonHostBridge`。它需要三个方法:`postMessage(message)`、`addEventListener('message', listener)` 和 `removeEventListener('message', listener)`。页面也可以调用 `registerHostBridge(bridge)` 挂上同一个对象。自带 `chrome.webview` 且方法一致的环境,没有注册时会直接使用它。
|
|
511
|
+
|
|
512
|
+
通道名固定 `glodon-workspace`。消息里只有相对路径和文件夹名,绝对路径留在宿主内。页面上不再出现「选择工作文件夹」。宿主还没推送目录时,`status` 为 `unsupported`。
|
|
515
513
|
|
|
516
514
|
页面加载后先发:
|
|
517
515
|
|
|
@@ -538,7 +536,7 @@ function openApprovalDialog(request: ApprovalRequest): Promise<boolean> {
|
|
|
538
536
|
}
|
|
539
537
|
```
|
|
540
538
|
|
|
541
|
-
`granted` 为 `false` 时页面断开工作区。`displayName` 只放文件夹名。`sandbox.state` 还可以是 `starting`、`failed`、`exited`。`failed` 带固定 `message
|
|
539
|
+
`granted` 为 `false` 时页面断开工作区。`displayName` 只放文件夹名。`sandbox.state` 还可以是 `starting`、`failed`、`exited`。`failed` 带固定 `message`,不带令牌和绝对路径。`capabilities` 和 `sandboxVersion` 是兼容/诊断字段,是否建立直连只取决于 `sandbox.state`、`url`、`token` 和 `protocol`。页面不向宿主发送文件或命令操作。
|
|
542
540
|
|
|
543
541
|
目录有增删时再推一条。`paths` 是发生变化的目录,相对工程根,根目录用 `""`。空数组表示让页面重读已展开的全部目录。短时间内多次变化可以合成一条。
|
|
544
542
|
|
package/dist/es/Config.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
1
|
+
var C = Object.defineProperty, L = Object.defineProperties;
|
|
2
2
|
var B = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
3
|
+
var p = Object.getOwnPropertySymbols;
|
|
4
|
+
var R = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var b = (e, i, o) => i in e ? C(e, i, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[i] = o, c = (e, i) => {
|
|
6
|
+
for (var o in i || (i = {}))
|
|
7
|
+
R.call(i, o) && b(e, o, i[o]);
|
|
8
|
+
if (p)
|
|
9
|
+
for (var o of p(i))
|
|
10
|
+
w.call(i, o) && b(e, o, i[o]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
12
|
+
}, P = (e, i) => L(e, B(i));
|
|
13
13
|
import g from "./Logger.mjs";
|
|
14
|
-
import { LOCAL_FILES_PLUGIN_CODES as k
|
|
15
|
-
import { createBuiltinToolsPlugin as
|
|
16
|
-
const
|
|
14
|
+
import { LOCAL_FILES_PLUGIN_CODES as k } from "./localFiles/constants.mjs";
|
|
15
|
+
import { createBuiltinToolsPlugin as E } from "./builtinTools/createBuiltinToolsPlugin.mjs";
|
|
16
|
+
const I = new g("[Config] ");
|
|
17
17
|
var h = /* @__PURE__ */ ((e) => (e.dev = "https://aiot-dev.glodon.com/api/cvforcepd", e.test = "https://aiot-dev.glodon.com/api/cvforce", e.prod = "https://copilot.glodon.com/api/cvforce", e.local = "http://localhost:3000/api/cvforcepd", e))(h || {});
|
|
18
|
-
let
|
|
18
|
+
let n = {
|
|
19
19
|
debug: !1,
|
|
20
20
|
env: "prod",
|
|
21
21
|
//AIoT 环境, 与apiRoot配对使用
|
|
@@ -30,74 +30,59 @@ let o = {
|
|
|
30
30
|
mcp: void 0,
|
|
31
31
|
loadRelatedQuesions: !0,
|
|
32
32
|
stream: !1
|
|
33
|
-
},
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
|
|
33
|
+
}, u, s;
|
|
34
|
+
const r = /* @__PURE__ */ new Set();
|
|
35
|
+
function D(e) {
|
|
36
|
+
u !== e && (u = e, s = void 0, r.clear());
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
if (!
|
|
38
|
+
function F() {
|
|
39
|
+
if (!s)
|
|
40
40
|
return;
|
|
41
41
|
const {
|
|
42
42
|
pluginCode: e,
|
|
43
43
|
table: i
|
|
44
|
-
} =
|
|
45
|
-
if (!(!
|
|
44
|
+
} = s, o = n.plugins[e], t = i[e];
|
|
45
|
+
if (!(!o || o.shell !== t.shell))
|
|
46
46
|
return e;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (!l)
|
|
50
|
-
return;
|
|
51
|
-
const {
|
|
52
|
-
pluginCode: e,
|
|
53
|
-
table: i
|
|
54
|
-
} = l, n = o.plugins[e], t = i[e];
|
|
55
|
-
if (!(!n || n.run_file !== t.run_file))
|
|
56
|
-
return e;
|
|
57
|
-
}
|
|
58
|
-
function T(e, i) {
|
|
48
|
+
function S(e, i) {
|
|
59
49
|
return (e == null ? void 0 : e.pluginCode) || k[i];
|
|
60
50
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
table: I({
|
|
76
|
-
pluginCode: s,
|
|
77
|
-
workspace: d
|
|
51
|
+
function T() {
|
|
52
|
+
var f, v;
|
|
53
|
+
const e = (f = n.businessPlugins) != null ? f : {}, i = (v = n.builtinPlugins) == null ? void 0 : v.localFiles, o = [], t = c({}, e);
|
|
54
|
+
if (!!!(i != null && i.enabled))
|
|
55
|
+
return n.plugins = t, o;
|
|
56
|
+
if (!u)
|
|
57
|
+
return o.push("[BuiltinTools] 内置工具依赖已启用的本地工作区。工具未注册。"), n.plugins = t, o;
|
|
58
|
+
const l = i != null && i.enabled ? S(i, n.env) : void 0;
|
|
59
|
+
return l ? e[l] ? o.push(`[BuiltinTools] 业务插件中已存在 pluginCode「${l}」,已保留业务插件,内置工具未注册。`) : (((s == null ? void 0 : s.workspace) !== u || s.pluginCode !== l) && (s = {
|
|
60
|
+
workspace: u,
|
|
61
|
+
pluginCode: l,
|
|
62
|
+
table: E({
|
|
63
|
+
pluginCode: l,
|
|
64
|
+
workspace: u
|
|
78
65
|
})
|
|
79
|
-
}),
|
|
66
|
+
}), t[l] = s.table[l]) : o.push(`[BuiltinTools] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置工具未注册。`), n.plugins = t, o;
|
|
80
67
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
68
|
+
function _() {
|
|
69
|
+
return T().filter((e) => !r.has(e)).map((e) => (r.add(e), console.error(e), new Error(e)));
|
|
83
70
|
}
|
|
84
|
-
function
|
|
85
|
-
var
|
|
86
|
-
g.debug = (e == null ? void 0 : e.debug) || !1,
|
|
87
|
-
apiRoot: (e == null ? void 0 : e.apiRoot) ||
|
|
71
|
+
function G(e, i = {}) {
|
|
72
|
+
var o, t, d;
|
|
73
|
+
g.debug = (e == null ? void 0 : e.debug) || !1, n = P(c(c({}, n), e), {
|
|
74
|
+
apiRoot: (e == null ? void 0 : e.apiRoot) || n.apiRoot || (e != null && e.env ? h[e.env || "prod"] : n.apiRoot),
|
|
88
75
|
// 应用未注册插件时 param.plugins 为 undefined,避免覆盖默认空表
|
|
89
|
-
businessPlugins: (t = (
|
|
90
|
-
builtinPlugins: (
|
|
91
|
-
}), i.refreshBuiltinPlugins !== !1 &&
|
|
76
|
+
businessPlugins: (t = (o = e == null ? void 0 : e.plugins) != null ? o : n.businessPlugins) != null ? t : {},
|
|
77
|
+
builtinPlugins: (d = e == null ? void 0 : e.builtinPlugins) != null ? d : n.builtinPlugins
|
|
78
|
+
}), i.refreshBuiltinPlugins !== !1 && _(), g.debug && I.log("updated", n);
|
|
92
79
|
}
|
|
93
80
|
export {
|
|
94
81
|
h as ApiUrl,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
N as resolveLocalPythonPluginCode,
|
|
102
|
-
Q as setActiveLocalWorkspace
|
|
82
|
+
n as configuration,
|
|
83
|
+
G as configure,
|
|
84
|
+
F as getRegisteredLocalFilesPluginCode,
|
|
85
|
+
_ as refreshBuiltinPlugins,
|
|
86
|
+
S as resolveLocalFilesPluginCode,
|
|
87
|
+
D as setActiveLocalWorkspace
|
|
103
88
|
};
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,71 +1,68 @@
|
|
|
1
|
-
import { configuration as e, configure as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { ToolCode as l, ToolError as
|
|
6
|
-
import { LOCAL_FILE_TOOL_SCHEMAS as
|
|
7
|
-
import { BUILTIN_TOOL_SCHEMAS as
|
|
1
|
+
import { configuration as e, configure as r, getRegisteredLocalFilesPluginCode as E, resolveLocalFilesPluginCode as T } from "./Config.mjs";
|
|
2
|
+
import { default as I } from "./BotClient.mjs";
|
|
3
|
+
import { default as A } from "./Session.mjs";
|
|
4
|
+
import { default as O } from "./AgentPlugin.mjs";
|
|
5
|
+
import { ToolCode as l, ToolError as N, toToolError as D } from "./localFiles/errors.mjs";
|
|
6
|
+
import { LOCAL_FILE_TOOL_SCHEMAS as F } from "./localFiles/schemas.mjs";
|
|
7
|
+
import { BUILTIN_TOOL_SCHEMAS as a } from "./builtinTools/schemas.mjs";
|
|
8
8
|
import { createLocalFilesPlugin as s } from "./localFiles/createLocalFilesPlugin.mjs";
|
|
9
|
-
import { LocalWorkspace as
|
|
10
|
-
import { createIndexedDbStore as
|
|
9
|
+
import { LocalWorkspace as m } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
10
|
+
import { createIndexedDbStore as x, createMemoryStore as H } from "./localFiles/workspace/handleStore.mjs";
|
|
11
11
|
import { FileSystemAccessAdapter as d } from "./localFiles/adapters/FileSystemAccessAdapter.mjs";
|
|
12
|
-
import { MemoryWorkspaceAdapter as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
12
|
+
import { MemoryWorkspaceAdapter as c } from "./localFiles/adapters/MemoryWorkspaceAdapter.mjs";
|
|
13
|
+
import { HOST_BRIDGE_GLOBAL as g, HOST_CHANNEL as P, registerHostBridge as X } from "./localFiles/host/protocol.mjs";
|
|
14
|
+
import { createDefaultSessionFileTransfer as G } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
15
|
+
import { getDownloadUrlAllowlist as Y, isDownloadUrlAllowed as w } from "./localFiles/security/downloadUrlPolicy.mjs";
|
|
16
|
+
import { SDK_SENSITIVE_BASELINE as K } from "./localFiles/security/sensitiveFiles.mjs";
|
|
17
|
+
import { BINARY_SNIFF_BYTES as b, BUILTIN_TOOLS_PLUGIN_CODE as v, BUILTIN_TOOLS_PLUGIN_CODES as V, DEFAULT_DOWNLOAD_URL_ALLOWLIST as Z, DEFAULT_IGNORED_DIRECTORIES as h, DEFAULT_IGNORED_FILE_PATTERNS as j, DEFAULT_LIMITS as q, KiB as z, LIST_DIRECTORY_DEFAULT_LIMIT as J, LIST_DIRECTORY_MAX_LIMIT as Q, LOCAL_FILES_FUNCTION_CODES as $, LOCAL_FILES_PLUGIN_CODES as oo, MiB as _o, SEARCH_DEFAULT_DEPTH as eo, SEARCH_FUNCTION_CODES as ro, SEARCH_MAX_DEPTH as Eo, TEXT_SEARCH_MAX_CONTEXT_LINES as To, TEXT_SEARCH_MAX_FILES as Lo, TEXT_SEARCH_MAX_FILE_BYTES as Io, TEXT_SEARCH_MAX_LINE_CHARS as So, TRANSFER_FILE_SIZE_LIMIT_MB as Ao, TRANSFER_FUNCTION_CODES as to, WORKSPACE_GRANT_ID as Oo, WRITE_FUNCTION_CODES as Co } from "./localFiles/constants.mjs";
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
O as AgentPlugin,
|
|
20
|
+
b as BINARY_SNIFF_BYTES,
|
|
21
|
+
v as BUILTIN_TOOLS_PLUGIN_CODE,
|
|
22
|
+
V as BUILTIN_TOOLS_PLUGIN_CODES,
|
|
23
|
+
a as BUILTIN_TOOL_SCHEMAS,
|
|
24
|
+
I as BotClient,
|
|
25
|
+
Z as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
|
|
26
|
+
h as DEFAULT_IGNORED_DIRECTORIES,
|
|
27
|
+
j as DEFAULT_IGNORED_FILE_PATTERNS,
|
|
28
|
+
q as DEFAULT_LIMITS,
|
|
28
29
|
d as FileSystemAccessAdapter,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
z as
|
|
32
|
-
J as
|
|
33
|
-
Q as
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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,
|
|
30
|
+
g as HOST_BRIDGE_GLOBAL,
|
|
31
|
+
P as HOST_CHANNEL,
|
|
32
|
+
z as KiB,
|
|
33
|
+
J as LIST_DIRECTORY_DEFAULT_LIMIT,
|
|
34
|
+
Q as LIST_DIRECTORY_MAX_LIMIT,
|
|
35
|
+
$ as LOCAL_FILES_FUNCTION_CODES,
|
|
36
|
+
oo as LOCAL_FILES_PLUGIN_CODES,
|
|
37
|
+
F as LOCAL_FILE_TOOL_SCHEMAS,
|
|
38
|
+
m as LocalWorkspace,
|
|
39
|
+
c as MemoryWorkspaceAdapter,
|
|
40
|
+
_o as MiB,
|
|
41
|
+
K as SDK_SENSITIVE_BASELINE,
|
|
42
|
+
eo as SEARCH_DEFAULT_DEPTH,
|
|
43
|
+
ro as SEARCH_FUNCTION_CODES,
|
|
44
|
+
Eo as SEARCH_MAX_DEPTH,
|
|
45
|
+
A as Session,
|
|
46
|
+
To as TEXT_SEARCH_MAX_CONTEXT_LINES,
|
|
47
|
+
Lo as TEXT_SEARCH_MAX_FILES,
|
|
48
|
+
Io as TEXT_SEARCH_MAX_FILE_BYTES,
|
|
49
|
+
So as TEXT_SEARCH_MAX_LINE_CHARS,
|
|
50
|
+
Ao as TRANSFER_FILE_SIZE_LIMIT_MB,
|
|
51
|
+
to as TRANSFER_FUNCTION_CODES,
|
|
55
52
|
l as ToolCode,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
N as ToolError,
|
|
54
|
+
Oo as WORKSPACE_GRANT_ID,
|
|
55
|
+
Co as WRITE_FUNCTION_CODES,
|
|
59
56
|
e as configuration,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
r as configure,
|
|
58
|
+
G as createDefaultSessionFileTransfer,
|
|
59
|
+
x as createIndexedDbStore,
|
|
63
60
|
s as createLocalFilesPlugin,
|
|
64
|
-
|
|
61
|
+
H as createMemoryStore,
|
|
65
62
|
Y as getDownloadUrlAllowlist,
|
|
66
63
|
E as getRegisteredLocalFilesPluginCode,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
w as isDownloadUrlAllowed,
|
|
65
|
+
X as registerHostBridge,
|
|
66
|
+
T as resolveLocalFilesPluginCode,
|
|
67
|
+
D as toToolError
|
|
71
68
|
};
|
|
@@ -4,10 +4,10 @@ var m = (r, t) => {
|
|
|
4
4
|
return t;
|
|
5
5
|
throw Error("Symbol." + r + " is not defined");
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
var l = (r, t, e) => (
|
|
9
|
-
var
|
|
10
|
-
var
|
|
7
|
+
var g = (r, t, e) => t in r ? p(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
8
|
+
var l = (r, t, e) => (g(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
9
|
+
var o = (r, t, e) => new Promise((s, a) => {
|
|
10
|
+
var n = (i) => {
|
|
11
11
|
try {
|
|
12
12
|
y(e.next(i));
|
|
13
13
|
} catch (c) {
|
|
@@ -19,11 +19,11 @@ var n = (r, t, e) => new Promise((s, a) => {
|
|
|
19
19
|
} catch (c) {
|
|
20
20
|
a(c);
|
|
21
21
|
}
|
|
22
|
-
}, y = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(
|
|
22
|
+
}, y = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(n, d);
|
|
23
23
|
y((e = e.apply(r, t)).next());
|
|
24
24
|
});
|
|
25
|
-
var f = (r, t, e) => (t = r[m("asyncIterator")]) ? t.call(r) : (r = r[m("iterator")](), t = {}, e = (s, a) => (a = r[s]) && (t[s] = (
|
|
26
|
-
import { throwIfAborted as
|
|
25
|
+
var f = (r, t, e) => (t = r[m("asyncIterator")]) ? t.call(r) : (r = r[m("iterator")](), t = {}, e = (s, a) => (a = r[s]) && (t[s] = (n) => new Promise((d, y, i) => (n = a.call(r, n), i = n.done, Promise.resolve(n.value).then((c) => d({ value: c, done: i }), y)))), e("next"), e("return"), t);
|
|
26
|
+
import { throwIfAborted as u } from "../errors.mjs";
|
|
27
27
|
import { SandboxClient as v } from "../host/sandboxClient.mjs";
|
|
28
28
|
import { SANDBOX_PROTOCOL as A } from "../host/protocol.mjs";
|
|
29
29
|
import { domError as w, toChunks as M } from "./WorkspaceFileAdapter.mjs";
|
|
@@ -61,41 +61,41 @@ class S {
|
|
|
61
61
|
return this.sandbox.unavailableMessage();
|
|
62
62
|
}
|
|
63
63
|
stat(t) {
|
|
64
|
-
return
|
|
64
|
+
return o(this, null, function* () {
|
|
65
65
|
const e = yield this.sandbox.stat(t);
|
|
66
66
|
return x(e.entry, t.split("/").pop() || this.displayName);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
listEntries(t, e) {
|
|
70
|
-
return
|
|
70
|
+
return o(this, null, function* () {
|
|
71
71
|
const s = yield this.sandbox.list(t, e);
|
|
72
|
-
return (Array.isArray(s.entries) ? s.entries : []).map((
|
|
72
|
+
return (Array.isArray(s.entries) ? s.entries : []).map((n) => x(n, ""));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
readFile(t, e) {
|
|
76
|
-
return
|
|
76
|
+
return o(this, null, function* () {
|
|
77
77
|
var a;
|
|
78
78
|
const s = yield this.sandbox.read(t, (a = e == null ? void 0 : e.offset) != null ? a : 0, e == null ? void 0 : e.maxBytes);
|
|
79
79
|
return new Blob([s]);
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
createDirectory(t) {
|
|
83
|
-
return
|
|
83
|
+
return o(this, null, function* () {
|
|
84
84
|
yield this.sandbox.mkdir(t);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
remove(s) {
|
|
88
|
-
return
|
|
88
|
+
return o(this, arguments, function* (t, e = {}) {
|
|
89
89
|
yield this.sandbox.remove(t, e.recursive === !0);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
move(t, e) {
|
|
93
|
-
return
|
|
93
|
+
return o(this, null, function* () {
|
|
94
94
|
yield this.sandbox.move(t, e);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
exec(t) {
|
|
98
|
-
return
|
|
98
|
+
return o(this, null, function* () {
|
|
99
99
|
const e = yield this.sandbox.exec({
|
|
100
100
|
op: "exec",
|
|
101
101
|
cwd: t.cwd,
|
|
@@ -108,18 +108,8 @@ class S {
|
|
|
108
108
|
return e;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
return this.sandbox.exec({
|
|
114
|
-
op: "run_python",
|
|
115
|
-
path: t,
|
|
116
|
-
args: e,
|
|
117
|
-
timeoutMs: s
|
|
118
|
-
}, a);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
writeFile(a, o) {
|
|
122
|
-
return n(this, arguments, function* (t, e, s = {}) {
|
|
111
|
+
writeFile(a, n) {
|
|
112
|
+
return o(this, arguments, function* (t, e, s = {}) {
|
|
123
113
|
if (typeof e == "string") {
|
|
124
114
|
yield this.sandbox.write(t, new TextEncoder().encode(e), s.createDirectories === !0, s.signal);
|
|
125
115
|
return;
|
|
@@ -132,7 +122,7 @@ class S {
|
|
|
132
122
|
try {
|
|
133
123
|
for (var N = f(M(e)), z, L, F; z = !(L = yield N.next()).done; z = !1) {
|
|
134
124
|
const b = L.value;
|
|
135
|
-
|
|
125
|
+
u(s.signal), d.push(b);
|
|
136
126
|
}
|
|
137
127
|
} catch (L) {
|
|
138
128
|
F = [L];
|
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E = ["list_directory", "read_file", "stat_file", "search_files", "search_text", "apply_patch", "write_file", "upload_file", "download_file"], _ = "builtin_tools", t = {
|
|
2
2
|
dev: _,
|
|
3
3
|
test: _,
|
|
4
4
|
prod: _,
|
|
5
5
|
local: _
|
|
6
|
-
},
|
|
6
|
+
}, T = t, c = "current-workspace", o = 1024, e = 1024 * 1024, s = 50, I = Object.freeze({
|
|
7
7
|
maxReadBytes: 1 * e,
|
|
8
8
|
maxWriteBytes: 5 * e,
|
|
9
9
|
maxSearchResults: 200,
|
|
10
10
|
maxConcurrentRequests: 4,
|
|
11
|
-
maxTransferBytes:
|
|
11
|
+
maxTransferBytes: s * e,
|
|
12
12
|
toolTimeoutMs: 3e4,
|
|
13
13
|
searchTimeoutMs: 6e4,
|
|
14
14
|
transferTimeoutMs: 10 * 6e4,
|
|
15
15
|
approvalTimeoutMs: 5 * 6e4
|
|
16
|
-
}),
|
|
16
|
+
}), n = 200, L = 1e3, S = 8, a = 16, l = 2e3, O = 1 * e, A = 500, R = 3, r = 8 * o, i = Object.freeze(["glodon.com"]), C = Object.freeze([".git", "node_modules", ".svn", ".idea", ".vscode"]), N = Object.freeze(["~$*", ".~lock*", "*.tmp"]), D = ["apply_patch", "write_file", "upload_file", "download_file"], F = ["search_files", "search_text"], d = ["upload_file", "download_file"];
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
r as BINARY_SNIFF_BYTES,
|
|
19
19
|
_ as BUILTIN_TOOLS_PLUGIN_CODE,
|
|
20
20
|
t as BUILTIN_TOOLS_PLUGIN_CODES,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
i as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
|
|
22
|
+
C as DEFAULT_IGNORED_DIRECTORIES,
|
|
23
|
+
N as DEFAULT_IGNORED_FILE_PATTERNS,
|
|
24
|
+
I as DEFAULT_LIMITS,
|
|
25
25
|
o as KiB,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
c as LOCAL_PYTHON_FUNCTION_CODE,
|
|
31
|
-
I as LOCAL_PYTHON_PLUGIN_CODES,
|
|
26
|
+
n as LIST_DIRECTORY_DEFAULT_LIMIT,
|
|
27
|
+
L as LIST_DIRECTORY_MAX_LIMIT,
|
|
28
|
+
E as LOCAL_FILES_FUNCTION_CODES,
|
|
29
|
+
T as LOCAL_FILES_PLUGIN_CODES,
|
|
32
30
|
e as MiB,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
H as TRANSFER_FUNCTION_CODES,
|
|
45
|
-
S as WORKSPACE_GRANT_ID,
|
|
46
|
-
f as WRITE_FUNCTION_CODES
|
|
31
|
+
S as SEARCH_DEFAULT_DEPTH,
|
|
32
|
+
F as SEARCH_FUNCTION_CODES,
|
|
33
|
+
a as SEARCH_MAX_DEPTH,
|
|
34
|
+
R as TEXT_SEARCH_MAX_CONTEXT_LINES,
|
|
35
|
+
l as TEXT_SEARCH_MAX_FILES,
|
|
36
|
+
O as TEXT_SEARCH_MAX_FILE_BYTES,
|
|
37
|
+
A as TEXT_SEARCH_MAX_LINE_CHARS,
|
|
38
|
+
s as TRANSFER_FILE_SIZE_LIMIT_MB,
|
|
39
|
+
d as TRANSFER_FUNCTION_CODES,
|
|
40
|
+
c as WORKSPACE_GRANT_ID,
|
|
41
|
+
D as WRITE_FUNCTION_CODES
|
|
47
42
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HostBridgeAdapter as f } from "../adapters/HostBridgeAdapter.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { getHostBridge as g, HOST_CHANNEL as l, parseHostMessage as y } from "./protocol.mjs";
|
|
3
3
|
function m(o) {
|
|
4
4
|
if (!o || typeof o != "object")
|
|
5
5
|
return;
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const i = "glodon-workspace", o = "__glodonHostBridge", c = 2;
|
|
2
|
+
function f(t) {
|
|
3
3
|
let e = t;
|
|
4
4
|
if (typeof e == "string")
|
|
5
5
|
try {
|
|
6
6
|
e = JSON.parse(e);
|
|
7
|
-
} catch (
|
|
7
|
+
} catch (s) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
if (!e || typeof e != "object")
|
|
11
11
|
return;
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
12
|
+
const n = e;
|
|
13
|
+
if (n.channel === i)
|
|
14
|
+
return n;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function r(t) {
|
|
17
|
+
if (!t || typeof t != "object")
|
|
18
|
+
return;
|
|
19
|
+
const e = t;
|
|
20
|
+
if (!(typeof e.postMessage != "function" || typeof e.addEventListener != "function" || typeof e.removeEventListener != "function"))
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
function d(t) {
|
|
24
|
+
const e = globalThis;
|
|
25
|
+
t ? e[o] = t : delete e[o];
|
|
26
|
+
}
|
|
27
|
+
function g() {
|
|
17
28
|
var e;
|
|
18
|
-
const t = (
|
|
19
|
-
|
|
20
|
-
return t;
|
|
29
|
+
const t = r(globalThis[o]);
|
|
30
|
+
return t || r((e = globalThis.chrome) == null ? void 0 : e.webview);
|
|
21
31
|
}
|
|
22
32
|
export {
|
|
23
|
-
|
|
24
|
-
i as
|
|
25
|
-
c as
|
|
26
|
-
|
|
33
|
+
o as HOST_BRIDGE_GLOBAL,
|
|
34
|
+
i as HOST_CHANNEL,
|
|
35
|
+
c as SANDBOX_PROTOCOL,
|
|
36
|
+
g as getHostBridge,
|
|
37
|
+
f as parseHostMessage,
|
|
38
|
+
d as registerHostBridge
|
|
27
39
|
};
|