@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 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)。端侧宿主是内嵌此页面、负责读写本地工程并启动 `@glodon-aiot/workspace-sandbox` 的桌面程序,见[宿主通道](#宿主通道)。
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` 或 `localPython` 任一启用后,SDK 把同一套内置工具注册到 `pluginCode` `builtin_tools`。`client.localWorkspace` 只在 `localFiles.enabled === true` 时存在。
157
+ `localFiles` 启用后,SDK 把内置工具注册到 `pluginCode` `builtin_tools`。`client.localWorkspace` 只在 `localFiles.enabled === true` 时存在。
160
158
 
161
- `shell` / `run_file` / `run_skill_script` 按[命令和脚本](#命令和脚本)选择执行器:注入的 `commandRunner` → 宿主声明 `sandbox-exec`(协议一致)→ 浏览器 just-bash / Pyodide(默认开启)→ 否则 501。
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 pluginCodes = [getRegisteredLocalFilesPluginCode(), getRegisteredLocalPythonPluginCode()];
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` 仍可供旧的上传下载实现使用。当前注册的内置工具不走这套传输。宿主沙箱是否启用由宿主 `capabilities` 声明决定,不在 `commandRuntime` 里配置。
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
- | `run_python` 结束 | `[]`,表示重读根目录和当前已经展开的每一层 |
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` 时说明正在启动;失败说明用 `sandbox.message`。协议不是 2 时另记一次 `error`。没有宿主 WebView 时才用注入的 `commandRunner` 或浏览器运行时。
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、需要时问 status、shutdown(3 秒后结束进程组)、把退出告诉页面
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
- 端侧宿主(下文简称宿主)是内嵌此页面的桌面程序,例如用 WebView2 加载页面的客户端。
508
+ 端侧宿主是内嵌此页面的桌面程序。页面由哪种内核显示没有要求。
513
509
 
514
- `localFiles.backend` 为 `host-bridge` 时,页面通过 `window.chrome.webview` 和宿主说话。通道名固定 `glodon-workspace`。消息里只有相对路径和文件夹名,绝对路径留在宿主内。页面上不再出现「选择工作文件夹」。宿主还没推送目录时,`status` 为 `unsupported`。
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
 
@@ -1,21 +1,21 @@
1
- var R = Object.defineProperty, _ = Object.defineProperties;
1
+ var C = Object.defineProperty, L = Object.defineProperties;
2
2
  var B = Object.getOwnPropertyDescriptors;
3
- var P = Object.getOwnPropertySymbols;
4
- var w = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
5
- var C = (e, i, n) => i in e ? R(e, i, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[i] = n, r = (e, i) => {
6
- for (var n in i || (i = {}))
7
- w.call(i, n) && C(e, n, i[n]);
8
- if (P)
9
- for (var n of P(i))
10
- O.call(i, n) && C(e, n, i[n]);
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
- }, L = (e, i) => _(e, B(i));
12
+ }, P = (e, i) => L(e, B(i));
13
13
  import g from "./Logger.mjs";
14
- import { LOCAL_FILES_PLUGIN_CODES as k, LOCAL_PYTHON_PLUGIN_CODES as E } from "./localFiles/constants.mjs";
15
- import { createBuiltinToolsPlugin as I } from "./builtinTools/createBuiltinToolsPlugin.mjs";
16
- const S = new g("[Config] ");
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 o = {
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
- }, d, l;
34
- const c = /* @__PURE__ */ new Set();
35
- function Q(e) {
36
- d !== e && (d = e, l = void 0, c.clear());
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 Y() {
39
- if (!l)
38
+ function F() {
39
+ if (!s)
40
40
  return;
41
41
  const {
42
42
  pluginCode: e,
43
43
  table: i
44
- } = l, n = o.plugins[e], t = i[e];
45
- if (!(!n || n.shell !== t.shell))
44
+ } = s, o = n.plugins[e], t = i[e];
45
+ if (!(!o || o.shell !== t.shell))
46
46
  return e;
47
47
  }
48
- function j() {
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 N(e, i, n) {
62
- return (e == null ? void 0 : e.pluginCode) || n || E[i];
63
- }
64
- function D() {
65
- var v, b, p;
66
- const e = (v = o.businessPlugins) != null ? v : {}, i = (b = o.builtinPlugins) == null ? void 0 : b.localFiles, n = (p = o.builtinPlugins) == null ? void 0 : p.localPython, t = [], u = r({}, e);
67
- if (!!!(i != null && i.enabled || n != null && n.enabled))
68
- return o.plugins = u, t;
69
- if (!d)
70
- return t.push("[BuiltinTools] 内置工具依赖已启用的本地工作区。工具未注册。"), o.plugins = u, t;
71
- const f = i != null && i.enabled ? T(i, o.env) : void 0, s = f || (n != null && n.enabled ? N(n, o.env, f) : void 0);
72
- return s ? e[s] ? t.push(`[BuiltinTools] 业务插件中已存在 pluginCode「${s}」,已保留业务插件,内置工具未注册。`) : (((l == null ? void 0 : l.workspace) !== d || l.pluginCode !== s) && (l = {
73
- workspace: d,
74
- pluginCode: s,
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
- }), u[s] = l.table[s]) : t.push(`[BuiltinTools] 当前环境(env: ${o.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置工具未注册。`), o.plugins = u, t;
66
+ }), t[l] = s.table[l]) : o.push(`[BuiltinTools] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置工具未注册。`), n.plugins = t, o;
80
67
  }
81
- function G() {
82
- return D().filter((e) => !c.has(e)).map((e) => (c.add(e), console.error(e), new Error(e)));
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 q(e, i = {}) {
85
- var n, t, u;
86
- g.debug = (e == null ? void 0 : e.debug) || !1, o = L(r(r({}, o), e), {
87
- apiRoot: (e == null ? void 0 : e.apiRoot) || o.apiRoot || (e != null && e.env ? h[e.env || "prod"] : o.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 = (n = e == null ? void 0 : e.plugins) != null ? n : o.businessPlugins) != null ? t : {},
90
- builtinPlugins: (u = e == null ? void 0 : e.builtinPlugins) != null ? u : o.builtinPlugins
91
- }), i.refreshBuiltinPlugins !== !1 && G(), g.debug && S.log("updated", o);
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
- o as configuration,
96
- q as configure,
97
- Y as getRegisteredLocalFilesPluginCode,
98
- j as getRegisteredLocalPythonPluginCode,
99
- G as refreshBuiltinPlugins,
100
- T as resolveLocalFilesPluginCode,
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 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";
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 P } from "./localFiles/workspace/LocalWorkspace.mjs";
10
- import { createIndexedDbStore as H, createMemoryStore as n } from "./localFiles/workspace/handleStore.mjs";
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 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";
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
- 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,
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
- 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,
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
- D as ToolError,
57
- l_ as WORKSPACE_GRANT_ID,
58
- D_ as WRITE_FUNCTION_CODES,
53
+ N as ToolError,
54
+ Oo as WORKSPACE_GRANT_ID,
55
+ Co as WRITE_FUNCTION_CODES,
59
56
  e as configuration,
60
- T as configure,
61
- u as createDefaultSessionFileTransfer,
62
- H as createIndexedDbStore,
57
+ r as configure,
58
+ G as createDefaultSessionFileTransfer,
59
+ x as createIndexedDbStore,
63
60
  s as createLocalFilesPlugin,
64
- n as createMemoryStore,
61
+ H as createMemoryStore,
65
62
  Y as getDownloadUrlAllowlist,
66
63
  E as getRegisteredLocalFilesPluginCode,
67
- r as getRegisteredLocalPythonPluginCode,
68
- G as isDownloadUrlAllowed,
69
- L as resolveLocalFilesPluginCode,
70
- R as toToolError
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 u = (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) => (u(r, typeof t != "symbol" ? t + "" : t, e), e);
9
- var n = (r, t, e) => new Promise((s, a) => {
10
- var o = (i) => {
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(o, d);
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] = (o) => new Promise((d, y, i) => (o = a.call(r, o), i = o.done, Promise.resolve(o.value).then((c) => d({ value: c, done: i }), y)))), e("next"), e("return"), t);
26
- import { throwIfAborted as g } from "../errors.mjs";
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 n(this, null, function* () {
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 n(this, null, function* () {
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((o) => x(o, ""));
72
+ return (Array.isArray(s.entries) ? s.entries : []).map((n) => x(n, ""));
73
73
  });
74
74
  }
75
75
  readFile(t, e) {
76
- return n(this, null, function* () {
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 n(this, null, function* () {
83
+ return o(this, null, function* () {
84
84
  yield this.sandbox.mkdir(t);
85
85
  });
86
86
  }
87
87
  remove(s) {
88
- return n(this, arguments, function* (t, e = {}) {
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 n(this, null, function* () {
93
+ return o(this, null, function* () {
94
94
  yield this.sandbox.move(t, e);
95
95
  });
96
96
  }
97
97
  exec(t) {
98
- return n(this, null, function* () {
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
- runPython(t, e, s, a) {
112
- return n(this, null, function* () {
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
- g(s.signal), d.push(b);
125
+ u(s.signal), d.push(b);
136
126
  }
137
127
  } catch (L) {
138
128
  F = [L];
@@ -1,47 +1,42 @@
1
- const s = ["list_directory", "read_file", "stat_file", "search_files", "search_text", "apply_patch", "write_file", "upload_file", "download_file"], _ = "builtin_tools", t = {
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
- }, E = t, c = "run_python", I = t, n = 2e4, O = 12e4, L = 16, S = "current-workspace", o = 1024, e = 1024 * 1024, T = 50, A = Object.freeze({
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: T * e,
11
+ maxTransferBytes: s * e,
12
12
  toolTimeoutMs: 3e4,
13
13
  searchTimeoutMs: 6e4,
14
14
  transferTimeoutMs: 10 * 6e4,
15
15
  approvalTimeoutMs: 5 * 6e4
16
- }), N = 200, C = 1e3, a = 8, l = 16, R = 2e3, r = 1 * e, i = 500, D = 3, F = 8 * o, M = Object.freeze(["glodon.com"]), U = Object.freeze([".git", "node_modules", ".svn", ".idea", ".vscode"]), d = Object.freeze(["~$*", ".~lock*", "*.tmp"]), f = ["apply_patch", "write_file", "upload_file", "download_file"], p = ["search_files", "search_text"], H = ["upload_file", "download_file"];
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
- F as BINARY_SNIFF_BYTES,
18
+ r as BINARY_SNIFF_BYTES,
19
19
  _ as BUILTIN_TOOLS_PLUGIN_CODE,
20
20
  t as BUILTIN_TOOLS_PLUGIN_CODES,
21
- M as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
22
- U as DEFAULT_IGNORED_DIRECTORIES,
23
- d as DEFAULT_IGNORED_FILE_PATTERNS,
24
- A as DEFAULT_LIMITS,
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
- N as LIST_DIRECTORY_DEFAULT_LIMIT,
27
- C as LIST_DIRECTORY_MAX_LIMIT,
28
- s as LOCAL_FILES_FUNCTION_CODES,
29
- E as LOCAL_FILES_PLUGIN_CODES,
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
- n as PYTHON_DEFAULT_TIMEOUT_MS,
34
- L as PYTHON_MAX_ARGS,
35
- O as PYTHON_MAX_TIMEOUT_MS,
36
- a as SEARCH_DEFAULT_DEPTH,
37
- p as SEARCH_FUNCTION_CODES,
38
- l as SEARCH_MAX_DEPTH,
39
- D as TEXT_SEARCH_MAX_CONTEXT_LINES,
40
- R as TEXT_SEARCH_MAX_FILES,
41
- r as TEXT_SEARCH_MAX_FILE_BYTES,
42
- i as TEXT_SEARCH_MAX_LINE_CHARS,
43
- T as TRANSFER_FILE_SIZE_LIMIT_MB,
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 { getHostWebView as g, HOST_CHANNEL as l, parseHostMessage as y } from "./protocol.mjs";
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 n = "glodon-workspace", i = 2;
2
- function s(t) {
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 (r) {
7
+ } catch (s) {
8
8
  return;
9
9
  }
10
10
  if (!e || typeof e != "object")
11
11
  return;
12
- const o = e;
13
- if (o.channel === n)
14
- return o;
12
+ const n = e;
13
+ if (n.channel === i)
14
+ return n;
15
15
  }
16
- function c() {
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 = (e = globalThis.chrome) == null ? void 0 : e.webview;
19
- if (!(!t || typeof t.postMessage != "function" || typeof t.addEventListener != "function"))
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
- n as HOST_CHANNEL,
24
- i as SANDBOX_PROTOCOL,
25
- c as getHostWebView,
26
- s as parseHostMessage
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
  };