@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/dist/src/Config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuiltinPluginsConfig, LocalFilesConfig
|
|
1
|
+
import { BuiltinPluginsConfig, LocalFilesConfig } from './localFiles/types';
|
|
2
2
|
import { LocalWorkspace } from './localFiles/workspace/LocalWorkspace';
|
|
3
3
|
export interface McpServer {
|
|
4
4
|
type: 'sse';
|
|
@@ -53,12 +53,8 @@ export declare function setActiveLocalWorkspace(workspace?: LocalWorkspace): voi
|
|
|
53
53
|
export declare function getActiveLocalWorkspace(): LocalWorkspace | undefined;
|
|
54
54
|
/** 当前已注册到 configuration.plugins 的内置文件工具编码;未注册时返回 undefined。 */
|
|
55
55
|
export declare function getRegisteredLocalFilesPluginCode(): string | undefined;
|
|
56
|
-
/** 当前已注册到 configuration.plugins 的脚本工具所在插件编码;未注册时返回 undefined。 */
|
|
57
|
-
export declare function getRegisteredLocalPythonPluginCode(): string | undefined;
|
|
58
56
|
/** 显式配置优先,其次按 env 取默认值;都没有时返回 undefined。 */
|
|
59
57
|
export declare function resolveLocalFilesPluginCode(config: LocalFilesConfig | undefined, env: string): string;
|
|
60
|
-
/** 显式配置优先,其次跟随文件工具编码,最后按 env 取默认值。 */
|
|
61
|
-
export declare function resolveLocalPythonPluginCode(config: LocalPythonConfig | undefined, env: string, filesPluginCode?: string): string;
|
|
62
58
|
/**
|
|
63
59
|
* 重新计算 configuration.plugins,返回本次新出现的问题(相同问题只报告一次)。
|
|
64
60
|
*/
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { AgentPluginRegistor, AgentPluginMap, BotClientConfig, MCPConfig, McpServer } from './Config';
|
|
2
|
-
export { configure, configuration, getRegisteredLocalFilesPluginCode,
|
|
2
|
+
export { configure, configuration, getRegisteredLocalFilesPluginCode, resolveLocalFilesPluginCode, } from './Config';
|
|
3
3
|
export type { ISessionArtifact } from '@glodon-aiot/apis';
|
|
4
4
|
export { default as BotClient } from './BotClient';
|
|
5
5
|
export { default as Session } from './Session';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandRequest, CommandResult } from '../../builtinTools/command';
|
|
2
2
|
import { SandboxClient, SandboxNotice } from '../host/sandboxClient';
|
|
3
|
-
import { HostCapability,
|
|
3
|
+
import { HostCapability, HostBridge } from '../host/protocol';
|
|
4
4
|
import { WorkspaceEntry, WorkspaceFileAdapter, WriteOptions, WriteSource } from './WorkspaceFileAdapter';
|
|
5
5
|
/**
|
|
6
6
|
* 工作区原语走沙箱 WebSocket。页面只向宿主发 hello,不转发文件字节和命令输出。
|
|
@@ -11,7 +11,7 @@ export declare class HostBridgeAdapter implements WorkspaceFileAdapter {
|
|
|
11
11
|
sandboxVersion?: string;
|
|
12
12
|
sandboxProtocol?: number;
|
|
13
13
|
readonly sandbox: SandboxClient;
|
|
14
|
-
constructor(view:
|
|
14
|
+
constructor(view: HostBridge, displayName?: string, sandbox?: SandboxClient);
|
|
15
15
|
setCapabilities(value: unknown, sandbox?: {
|
|
16
16
|
version?: unknown;
|
|
17
17
|
}): void;
|
|
@@ -32,6 +32,5 @@ export declare class HostBridgeAdapter implements WorkspaceFileAdapter {
|
|
|
32
32
|
}): Promise<void>;
|
|
33
33
|
move(from: string, to: string): Promise<void>;
|
|
34
34
|
exec(request: CommandRequest): Promise<CommandResult>;
|
|
35
|
-
runPython(path: string, args: string[], timeoutMs: number, signal?: AbortSignal): Promise<import('../host/sandboxClient').SandboxExecResult>;
|
|
36
35
|
writeFile(path: string, source: WriteSource, options?: WriteOptions): Promise<void>;
|
|
37
36
|
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { Env } from '../Config';
|
|
2
2
|
export declare const LOCAL_FILES_FUNCTION_CODES: readonly ["list_directory", "read_file", "stat_file", "search_files", "search_text", "apply_patch", "write_file", "upload_file", "download_file"];
|
|
3
3
|
export type LocalFilesFunctionCode = (typeof LOCAL_FILES_FUNCTION_CODES)[number];
|
|
4
|
-
/**
|
|
5
|
-
* 平台上的内置工具插件。本地文件工具和 `run_python` 都在这一个插件里。
|
|
6
|
-
* dev、test、prod、local 使用同一个 pluginCode。
|
|
7
|
-
*/
|
|
8
|
-
/** 平台插件编码。与内置工具 OpenAPI 的 pluginCode 一致。 */
|
|
4
|
+
/** 平台插件编码。与内置工具 OpenAPI 的 pluginCode 一致。dev、test、prod、local 使用同一个 pluginCode。 */
|
|
9
5
|
export declare const BUILTIN_TOOLS_PLUGIN_CODE = "builtin_tools";
|
|
10
6
|
export declare const BUILTIN_TOOLS_PLUGIN_CODES: Record<Env, string>;
|
|
11
|
-
/** 与 `BUILTIN_TOOLS_PLUGIN_CODES`
|
|
7
|
+
/** 与 `BUILTIN_TOOLS_PLUGIN_CODES` 相同。 */
|
|
12
8
|
export declare const LOCAL_FILES_PLUGIN_CODES: Record<Env, string>;
|
|
13
|
-
/** 本地 Python 脚本。与文件工具注册在同一个插件里。 */
|
|
14
|
-
export declare const LOCAL_PYTHON_FUNCTION_CODE = "run_python";
|
|
15
|
-
/** 与 `BUILTIN_TOOLS_PLUGIN_CODES` 相同。未单独配置时跟随文件工具的 pluginCode。 */
|
|
16
|
-
export declare const LOCAL_PYTHON_PLUGIN_CODES: Record<Env, string>;
|
|
17
|
-
export declare const PYTHON_DEFAULT_TIMEOUT_MS = 20000;
|
|
18
|
-
export declare const PYTHON_MAX_TIMEOUT_MS = 120000;
|
|
19
|
-
export declare const PYTHON_MAX_ARGS = 16;
|
|
20
9
|
export declare const WORKSPACE_GRANT_ID = "current-workspace";
|
|
21
10
|
export declare const KiB = 1024;
|
|
22
11
|
export declare const MiB: number;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** 宿主与页面之间的通道名。根目录只由宿主设置,消息里不能带绝对路径。 */
|
|
2
2
|
export declare const HOST_CHANNEL = "glodon-workspace";
|
|
3
|
-
|
|
3
|
+
/** 宿主在页面脚本运行前挂上的消息桥。不对应某一种 WebView 或浏览器内核。 */
|
|
4
|
+
export declare const HOST_BRIDGE_GLOBAL = "__glodonHostBridge";
|
|
5
|
+
/** 页面与宿主之间的双向消息桥。消息正文是普通 JSON。 */
|
|
6
|
+
export interface HostBridge {
|
|
4
7
|
postMessage(message: unknown): void;
|
|
5
8
|
addEventListener(type: 'message', listener: (event: {
|
|
6
9
|
data: unknown;
|
|
@@ -37,4 +40,10 @@ export interface HostWorkspaceMessage {
|
|
|
37
40
|
sandbox?: HostSandboxState;
|
|
38
41
|
}
|
|
39
42
|
export declare function parseHostMessage(data: unknown): Record<string, unknown> | undefined;
|
|
40
|
-
|
|
43
|
+
/** 挂上当前页面的宿主消息桥。传入空值时移除。 */
|
|
44
|
+
export declare function registerHostBridge(bridge?: HostBridge): void;
|
|
45
|
+
/**
|
|
46
|
+
* 优先使用宿主注册的消息桥。没有注册时,接受已经具备同样三个方法的 `chrome.webview`,
|
|
47
|
+
* 让自带该对象的嵌入环境不必再包一层。
|
|
48
|
+
*/
|
|
49
|
+
export declare function getHostBridge(): HostBridge | undefined;
|
|
@@ -2,21 +2,23 @@ export * from './constants';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export { ToolCode, ToolError, toToolError } from './errors';
|
|
4
4
|
export type { ToolErrorData, ToolErrorReason } from './errors';
|
|
5
|
-
export { LOCAL_FILE_TOOL_SCHEMAS
|
|
5
|
+
export { LOCAL_FILE_TOOL_SCHEMAS } from './schemas';
|
|
6
6
|
export { BUILTIN_TOOL_SCHEMAS } from '../builtinTools/schemas';
|
|
7
|
-
export type { BuiltinToolSchema, JsonSchema, LocalFileToolSchema } from './schemas';
|
|
7
|
+
export type { BuiltinToolSchema, JsonSchema, LocalFileToolSchema, } from './schemas';
|
|
8
8
|
export { createLocalFilesPlugin } from './createLocalFilesPlugin';
|
|
9
9
|
export type { CreateLocalFilesPluginOptions, LocalFilesHandler, LocalFilesPluginTable, } from './createLocalFilesPlugin';
|
|
10
10
|
export { LocalWorkspace } from './workspace/LocalWorkspace';
|
|
11
11
|
export type { LocalWorkspaceOptions } from './workspace/LocalWorkspace';
|
|
12
|
-
export { createIndexedDbStore, createMemoryStore } from './workspace/handleStore';
|
|
12
|
+
export { createIndexedDbStore, createMemoryStore, } from './workspace/handleStore';
|
|
13
13
|
export type { KeyValueStore } from './workspace/handleStore';
|
|
14
14
|
export type { RemoveOptions, WorkspaceEntry, WorkspaceFileAdapter, WriteOptions, WriteSource, } from './adapters/WorkspaceFileAdapter';
|
|
15
15
|
export { FileSystemAccessAdapter } from './adapters/FileSystemAccessAdapter';
|
|
16
16
|
export { MemoryWorkspaceAdapter } from './adapters/MemoryWorkspaceAdapter';
|
|
17
|
-
export type { FsaDirectoryHandle, ShowDirectoryPicker } from './adapters/fsaTypes';
|
|
17
|
+
export type { FsaDirectoryHandle, ShowDirectoryPicker, } from './adapters/fsaTypes';
|
|
18
|
+
export { HOST_BRIDGE_GLOBAL, HOST_CHANNEL, registerHostBridge, } from './host/protocol';
|
|
19
|
+
export type { HostBridge } from './host/protocol';
|
|
18
20
|
export { createDefaultSessionFileTransfer } from './transfer/SessionFileTransfer';
|
|
19
21
|
export type { ResolvedDownload, SessionFileTransfer, UploadProgress, } from './transfer/SessionFileTransfer';
|
|
20
22
|
export { getDownloadUrlAllowlist, isDownloadUrlAllowed, } from './security/downloadUrlPolicy';
|
|
21
23
|
export { SDK_SENSITIVE_BASELINE } from './security/sensitiveFiles';
|
|
22
|
-
export type { SensitiveRule, SensitiveRuleInput } from './security/sensitiveFiles';
|
|
24
|
+
export type { SensitiveRule, SensitiveRuleInput, } from './security/sensitiveFiles';
|
|
@@ -25,5 +25,3 @@ export interface LocalFileToolSchema extends BuiltinToolSchema {
|
|
|
25
25
|
}
|
|
26
26
|
/** 9 个工具的参数 Schema,同时作为平台注册时的草案。 */
|
|
27
27
|
export declare const LOCAL_FILE_TOOL_SCHEMAS: Record<LocalFilesFunctionCode, LocalFileToolSchema>;
|
|
28
|
-
/** run_python 的参数 Schema。与文件工具一起注册到同一个插件。 */
|
|
29
|
-
export declare const LOCAL_PYTHON_TOOL_SCHEMA: BuiltinToolSchema;
|
|
@@ -63,11 +63,11 @@ export interface LocalFilesConfig {
|
|
|
63
63
|
enabled?: boolean;
|
|
64
64
|
/**
|
|
65
65
|
* `file-system-access`:网页里由用户选择目录。
|
|
66
|
-
* `host-bridge
|
|
66
|
+
* `host-bridge`:目录由宿主消息桥推送,页面不弹选择框。
|
|
67
67
|
*/
|
|
68
68
|
backend?: 'file-system-access' | 'host-bridge';
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* 平台上的内置工具插件编码。
|
|
71
71
|
* 未配置时按 env 取 BUILTIN_TOOLS_PLUGIN_CODES。
|
|
72
72
|
*/
|
|
73
73
|
pluginCode?: string;
|
|
@@ -96,28 +96,8 @@ export interface CommandRuntimeConfig {
|
|
|
96
96
|
pyodideIndexURL?: string;
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
export interface PythonApprovalRequest {
|
|
100
|
-
requestId: string;
|
|
101
|
-
sessionId: string;
|
|
102
|
-
path: string;
|
|
103
|
-
args: string[];
|
|
104
|
-
workspaceName: string;
|
|
105
|
-
signal: AbortSignal;
|
|
106
|
-
}
|
|
107
|
-
export type PythonApprovalHandler = (request: PythonApprovalRequest) => boolean | Promise<boolean>;
|
|
108
|
-
export interface LocalPythonConfig {
|
|
109
|
-
enabled?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* 平台上的内置工具插件编码,须与文件工具相同。
|
|
112
|
-
* 未配置时跟随 localFiles.pluginCode,再按 env 取 BUILTIN_TOOLS_PLUGIN_CODES。
|
|
113
|
-
*/
|
|
114
|
-
pluginCode?: string;
|
|
115
|
-
/** 运行脚本前的确认。与文件写入确认分开;未配置时一律拒绝。 */
|
|
116
|
-
onApprovalRequired?: PythonApprovalHandler;
|
|
117
|
-
}
|
|
118
99
|
export interface BuiltinPluginsConfig {
|
|
119
100
|
localFiles?: LocalFilesConfig;
|
|
120
|
-
localPython?: LocalPythonConfig;
|
|
121
101
|
}
|
|
122
102
|
export interface WorkspaceGrantInput {
|
|
123
103
|
grantId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glodon-aiot/bot-client-sdk",
|
|
3
|
-
"version": "3.26.0-alpha.
|
|
3
|
+
"version": "3.26.0-alpha.12",
|
|
4
4
|
"author": "glodoncv",
|
|
5
5
|
"description": "aiot bot client js sdk",
|
|
6
6
|
"type": "module",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"registry": "https://registry.npmjs.org/"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@glodon-aiot/apis": "^3.26.0-alpha.
|
|
91
|
+
"@glodon-aiot/apis": "^3.26.0-alpha.12",
|
|
92
92
|
"axios": "0.24.0",
|
|
93
93
|
"buffer": "^6.0.3",
|
|
94
94
|
"dayjs": "^1.11.13",
|