@glodon-aiot/bot-client-sdk 3.26.0-alpha.10 → 3.26.0-alpha.11
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 +11 -9
- package/dist/es/index.mjs +56 -52
- package/dist/es/localFiles/host/connectHostBridge.mjs +1 -1
- package/dist/es/localFiles/host/protocol.mjs +26 -14
- package/dist/es/package.json.mjs +2 -2
- package/dist/lib/index.js +35 -35
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +2 -2
- package/dist/src/localFiles/host/protocol.d.ts +11 -2
- package/dist/src/localFiles/index.d.ts +6 -4
- package/dist/src/localFiles/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -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;
|
|
@@ -4,19 +4,21 @@ export { ToolCode, ToolError, toToolError } from './errors';
|
|
|
4
4
|
export type { ToolErrorData, ToolErrorReason } from './errors';
|
|
5
5
|
export { LOCAL_FILE_TOOL_SCHEMAS, LOCAL_PYTHON_TOOL_SCHEMA } 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';
|
|
@@ -63,7 +63,7 @@ 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
|
/**
|
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.11",
|
|
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.11",
|
|
92
92
|
"axios": "0.24.0",
|
|
93
93
|
"buffer": "^6.0.3",
|
|
94
94
|
"dayjs": "^1.11.13",
|