clickgo 6.11.0 → 7.0.0
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/dist/app/demo.cga +0 -0
- package/dist/app/task.cga +0 -0
- package/dist/control/desktop.cgc +0 -0
- package/dist/index.js +1 -1
- package/dist/lib/command/data.d.ts +27 -0
- package/dist/lib/command/webmcp.d.ts +84 -0
- package/dist/lib/command.d.ts +2 -3
- package/dist/lib/core/package.d.ts +23 -0
- package/dist/lib/core.d.ts +8 -2
- package/dist/lib/dom.d.ts +8 -3
- package/dist/lib/native/secret.d.ts +29 -0
- package/dist/lib/native/storage.d.ts +30 -0
- package/dist/lib/native.d.ts +15 -0
- package/dist/lib/task.d.ts +2 -0
- package/dist/lib/tool.d.ts +15 -5
- package/doc/clickgo-rag.md +2326 -1959
- package/package.json +16 -16
- package/AGENTS.md +0 -36
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IDefinition, IMetadata, ISchema, TJson, TResult } from '../command';
|
|
2
|
+
/**
|
|
3
|
+
* --- 检查命令定义的字段、支持的 schema 和 JSON 元数据,并保存独立快照 ---
|
|
4
|
+
* @param definition 命令定义;名称为 1–128 位 ASCII 字母、数字、_、.、-,说明不能为空白
|
|
5
|
+
* @returns 元数据快照;字段、回调类型、权限列表、注解或 schema 不合法返回 false;不检查授权或所属实例
|
|
6
|
+
*/
|
|
7
|
+
export declare function readMetadata<T extends Record<string, TJson>>(definition: IDefinition<T>): IMetadata | false;
|
|
8
|
+
/**
|
|
9
|
+
* --- 按命令的输入 schema 校验 JSON 对象,并隔离调用方后续修改 ---
|
|
10
|
+
* @param args 输入数据,不转换类型、不补默认值、不删除额外字段
|
|
11
|
+
* @param schema 注册时已验证的输入 schema
|
|
12
|
+
* @returns 成功时 data 为独立参数;非 JSON 对象或约束不匹配返回 invalid-input
|
|
13
|
+
*/
|
|
14
|
+
export declare function readInput(args: unknown, schema: ISchema): TResult<Record<string, TJson>>;
|
|
15
|
+
/**
|
|
16
|
+
* --- 检查业务结果的 JSON 结构及输出约束,生成可跨入口传输的独立结果 ---
|
|
17
|
+
* @param result 业务回调结果;成功须有 data,失败须有非空错误码和字符串说明
|
|
18
|
+
* @param schema 可选输出 schema,只校验成功结果的 data
|
|
19
|
+
* @returns 合法业务错误保留 code/message;成功数据复制;结构或约束不匹配返回 invalid-output
|
|
20
|
+
*/
|
|
21
|
+
export declare function readResult(result: unknown, schema?: ISchema): TResult;
|
|
22
|
+
/**
|
|
23
|
+
* --- 复制已验证的 JSON,保持 JSON 往返语义,不与注册表共享对象 ---
|
|
24
|
+
* @param value 已通过 JSON 检查的元数据或业务数据
|
|
25
|
+
* @returns 独立快照
|
|
26
|
+
*/
|
|
27
|
+
export declare function copy<T>(value: T): T;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { IMetadata, ISchema, TJson, TResult, TWebMcpRegistrationStatus } from '../command';
|
|
2
|
+
/** --- 浏览器发布所需的命令身份与元数据,不持有业务执行函数 --- */
|
|
3
|
+
export interface ICommand {
|
|
4
|
+
/** --- 每次注册使用不同标识,旧工具不能转向同名的新命令 --- */
|
|
5
|
+
'id': number;
|
|
6
|
+
'metadata': IMetadata;
|
|
7
|
+
}
|
|
8
|
+
/** --- 浏览器提供的工具注册能力;撤销信号只作用于本次工具发布 --- */
|
|
9
|
+
export interface IContext {
|
|
10
|
+
'registerTool': (tool: {
|
|
11
|
+
'name': string;
|
|
12
|
+
'description': string;
|
|
13
|
+
'inputSchema': ISchema;
|
|
14
|
+
'execute': (args: Record<string, TJson>, options?: {
|
|
15
|
+
'signal'?: AbortSignal;
|
|
16
|
+
}) => Promise<string>;
|
|
17
|
+
'annotations'?: {
|
|
18
|
+
'readOnlyHint'?: boolean;
|
|
19
|
+
'consequentialHint'?: boolean;
|
|
20
|
+
'untrustedContentHint'?: boolean;
|
|
21
|
+
};
|
|
22
|
+
}, options: {
|
|
23
|
+
'signal': AbortSignal;
|
|
24
|
+
}) => void | Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/** --- 灰箱提供的命令选择、注册身份判断和统一执行入口 --- */
|
|
27
|
+
export interface IRuntime<T extends ICommand> {
|
|
28
|
+
/** --- 当前允许代理发现的命令,由调用方按 exposed 筛选 --- */
|
|
29
|
+
'getCommands': (taskId: string) => T[];
|
|
30
|
+
/** --- 当前注册表仍持有同一个命令实例;不能只比较名称 --- */
|
|
31
|
+
'isCurrent': (taskId: string, command: T) => boolean;
|
|
32
|
+
/** --- 使用灰箱 executeAgent,重新检查权限、可用性、并发和取消 --- */
|
|
33
|
+
'execute': (taskId: string, command: T, args: Record<string, TJson>, options?: {
|
|
34
|
+
'signal'?: AbortSignal;
|
|
35
|
+
}) => Promise<TResult>;
|
|
36
|
+
}
|
|
37
|
+
/** --- 单个 App 的发布记录,与页面接入状态分开 --- */
|
|
38
|
+
export interface IPublication<T extends ICommand> {
|
|
39
|
+
'context': IContext;
|
|
40
|
+
'tools': Map<T, AbortController>;
|
|
41
|
+
/** --- 最新一次串行同步的结果;撤销或注册失败为 false --- */
|
|
42
|
+
'pending': Promise<boolean>;
|
|
43
|
+
'status': TWebMcpRegistrationStatus;
|
|
44
|
+
}
|
|
45
|
+
/** --- 所选 App 的发布诊断;不触发注册,不读取其他 App --- */
|
|
46
|
+
export interface IDiagnostics {
|
|
47
|
+
/** --- 失败优先于进行中,其余按已发布或空闲报告 --- */
|
|
48
|
+
'registrationStatus': TWebMcpRegistrationStatus;
|
|
49
|
+
'publishedTaskIds': string[];
|
|
50
|
+
}
|
|
51
|
+
/** --- 按 App 隔离并串行同步工具,撤销后拒绝迟到注册及旧工具调用 --- */
|
|
52
|
+
export interface IPublisher<T extends ICommand> {
|
|
53
|
+
/**
|
|
54
|
+
* --- 发布或重同步;浏览器接口改变时先撤销旧发布 ---
|
|
55
|
+
* @param taskId 灰箱已确认仍存活的 App
|
|
56
|
+
* @param context 当前浏览器注册能力
|
|
57
|
+
* @returns 发布记录,pending 表示本轮同步是否成功
|
|
58
|
+
*/
|
|
59
|
+
'publish': (taskId: string, context: IContext) => IPublication<T>;
|
|
60
|
+
/**
|
|
61
|
+
* --- 按注册表最新内容排队同步,失败工具可重试 ---
|
|
62
|
+
* @param taskId 所属 App
|
|
63
|
+
* @returns 无返回值;未发布过的 App 不处理
|
|
64
|
+
*/
|
|
65
|
+
'refresh': (taskId: string) => void;
|
|
66
|
+
/**
|
|
67
|
+
* --- 撤销 App 工具及待完成发布,不改变页面级接入状态 ---
|
|
68
|
+
* @param taskId 所属 App
|
|
69
|
+
* @returns 无返回值
|
|
70
|
+
*/
|
|
71
|
+
'disconnect': (taskId: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* --- 汇总所选 App 的工具发布状态 ---
|
|
74
|
+
* @param taskIds 所选 App 标识
|
|
75
|
+
* @returns 发布诊断
|
|
76
|
+
*/
|
|
77
|
+
'describe': (taskIds: string[]) => IDiagnostics;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* --- 创建浏览器发布器,内部组织同步队列、撤销信号和迟到结果处理 ---
|
|
81
|
+
* @param runtime 灰箱提供的公开命令选择、身份校验和执行能力
|
|
82
|
+
* @returns 独立发布器;不持有页面状态或决定业务授权
|
|
83
|
+
*/
|
|
84
|
+
export declare function create<T extends ICommand>(runtime: IRuntime<T>): IPublisher<T>;
|
package/dist/lib/command.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as lCore from './core';
|
|
2
|
+
import * as lTool from './tool';
|
|
2
3
|
import * as lNative from './native';
|
|
3
4
|
export { showPalette } from './command/palette';
|
|
4
5
|
/** --- 命令输入与输出可跨浏览器、Native 和协议传输的 JSON 值 --- */
|
|
5
|
-
export type TJson =
|
|
6
|
-
[key: string]: TJson;
|
|
7
|
-
};
|
|
6
|
+
export type TJson = lTool.TJson;
|
|
8
7
|
/** --- JSON Schema 2020-12 的命令校验子集;不支持的关键字在注册时拒绝 --- */
|
|
9
8
|
export interface ISchema {
|
|
10
9
|
'$schema'?: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as lZip from '../zip.js';
|
|
2
|
+
import * as lTool from '../tool.js';
|
|
3
|
+
import type { IAppPackage } from '../core.js';
|
|
4
|
+
/** --- CGA 读取器所需的框架能力,供黑箱调用 --- */
|
|
5
|
+
export interface IPackageIO {
|
|
6
|
+
/** --- 打开已解密的 ZIP 内容块,供读取器访问文件;失败返回 null --- */
|
|
7
|
+
'getZip': typeof lZip.get;
|
|
8
|
+
/** --- 将包内图标 Blob 转为可展示的 data URL --- */
|
|
9
|
+
'blob2DataUrl': typeof lTool.blob2DataUrl;
|
|
10
|
+
/** --- 按包内路径识别 MIME 类型,用于构造二进制文件 Blob --- */
|
|
11
|
+
'getMimeByPath': typeof lTool.getMimeByPath;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* --- 校验 CGA 应用包并创建按需读取器,统一接入框架的 ZIP、图标和文件类型能力 ---
|
|
15
|
+
* @param blob CGA 应用包的二进制内容
|
|
16
|
+
* @returns 图标 data URL 和包读取器;包格式、认证或图标读取失败返回 false
|
|
17
|
+
*/
|
|
18
|
+
export declare function createPackage(blob: Blob): Promise<false | {
|
|
19
|
+
/** --- 无内嵌图标时为空字符串 --- */
|
|
20
|
+
'icon': string;
|
|
21
|
+
/** --- 按需读取文件,读取失败按 IAppPackage 契约返回 null --- */
|
|
22
|
+
'package': IAppPackage;
|
|
23
|
+
}>;
|
package/dist/lib/core.d.ts
CHANGED
|
@@ -135,8 +135,9 @@ export declare function setBoot(b: clickgo.AbstractBoot): void;
|
|
|
135
135
|
*/
|
|
136
136
|
export declare function trigger(name: TGlobalEvent, taskId?: string | boolean | KeyboardEvent, formId?: string | boolean | Record<string, any> | null, param1?: boolean | Error | string, param2?: string | Record<string, any>, param3?: boolean): Promise<void>;
|
|
137
137
|
/**
|
|
138
|
-
* ---
|
|
139
|
-
* @param blob
|
|
138
|
+
* --- 读取 CGA 应用包及其配置 ---
|
|
139
|
+
* @param blob CGA 应用包的二进制内容
|
|
140
|
+
* @returns 应用信息;包无法识别或缺少文本配置时返回 false
|
|
140
141
|
*/
|
|
141
142
|
export declare function readApp(blob: Blob): Promise<false | IApp>;
|
|
142
143
|
/**
|
|
@@ -303,6 +304,11 @@ export interface IAppPackage {
|
|
|
303
304
|
}
|
|
304
305
|
/** --- 应用文件包 config --- */
|
|
305
306
|
export interface IAppConfig {
|
|
307
|
+
/**
|
|
308
|
+
* --- 固定应用 ID,如 net.example.notepad;Native 持久存储必填,跨位置和版本保持不变 ---
|
|
309
|
+
* 1-128 位字母、数字、点、下划线或连字符,以字母或数字开头。
|
|
310
|
+
*/
|
|
311
|
+
'id'?: string;
|
|
306
312
|
/** --- 应用名 --- */
|
|
307
313
|
'name': string;
|
|
308
314
|
/** --- 发行版本 --- */
|
package/dist/lib/dom.d.ts
CHANGED
|
@@ -199,8 +199,14 @@ export declare function isWatch(el: HTMLElement): boolean;
|
|
|
199
199
|
* @param taskId 任务 id
|
|
200
200
|
*/
|
|
201
201
|
export declare function clearWatch(taskId: lCore.TCurrent): void;
|
|
202
|
-
/**
|
|
203
|
-
|
|
202
|
+
/**
|
|
203
|
+
* --- 样式变化通知回调 ---
|
|
204
|
+
* @param name CSS 属性名
|
|
205
|
+
* @param value 当前计算样式值
|
|
206
|
+
* @param old 上次记录的计算样式值
|
|
207
|
+
* @returns 无返回值,可异步完成
|
|
208
|
+
*/
|
|
209
|
+
export type TWatchStyleCallback = (name: string, value: string, old: string) => void | Promise<void>;
|
|
204
210
|
/**
|
|
205
211
|
* --- 监听一个标签的计算后样式的变化 ---
|
|
206
212
|
* @param el 对象
|
|
@@ -447,4 +453,3 @@ export interface IGetWatchInfoResult {
|
|
|
447
453
|
};
|
|
448
454
|
}>>;
|
|
449
455
|
}
|
|
450
|
-
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as lCore from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* --- 查询 Native 系统密钥服务,无需 root 权限 ---
|
|
4
|
+
* @param current 当前 App
|
|
5
|
+
* @returns 是否可以安全保存敏感字符串
|
|
6
|
+
*/
|
|
7
|
+
export declare function isAvailable(current: lCore.TCurrent): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* --- 读取当前 App 的加密字符串,按 config.id 隔离 ---
|
|
10
|
+
* @param current 当前 App
|
|
11
|
+
* @param key 非空 Unicode 存储键,最多 128 个 UTF-16 码元
|
|
12
|
+
* @returns 字符串,未找到为 null,缺少有效 App ID、宿主、密钥服务或读取失败为 false
|
|
13
|
+
*/
|
|
14
|
+
export declare function get(current: lCore.TCurrent, key: string): Promise<string | null | false>;
|
|
15
|
+
/**
|
|
16
|
+
* --- 加密后保存字符串,按 config.id 隔离,不退回明文 ---
|
|
17
|
+
* @param current 当前 App
|
|
18
|
+
* @param key 非空 Unicode 存储键,最多 128 个 UTF-16 码元
|
|
19
|
+
* @param value 敏感字符串
|
|
20
|
+
* @returns 是否保存成功,安全存储不可用为 false
|
|
21
|
+
*/
|
|
22
|
+
export declare function set(current: lCore.TCurrent, key: string, value: string): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* --- 删除加密记录,按 config.id 隔离 ---
|
|
25
|
+
* @param current 当前 App
|
|
26
|
+
* @param key 非空 Unicode 存储键,最多 128 个 UTF-16 码元
|
|
27
|
+
* @returns 是否删除成功,未找到时也返回成功
|
|
28
|
+
*/
|
|
29
|
+
export declare function remove(current: lCore.TCurrent, key: string): Promise<boolean>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as lCore from '../core';
|
|
2
|
+
import type * as lTool from '../tool';
|
|
3
|
+
/** --- 小型配置允许保存的 JSON 数据 --- */
|
|
4
|
+
export type TJson = lTool.TJson;
|
|
5
|
+
/** --- 包装实际值,false/null 数据不会与失败/未找到混淆 --- */
|
|
6
|
+
export interface IStoredValue<T extends TJson = TJson> {
|
|
7
|
+
'value': T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* --- 读取当前 App 的持久配置,按 config.id 隔离 ---
|
|
11
|
+
* @param current 当前 App
|
|
12
|
+
* @param key 非空 Unicode 存储键,最多 128 个 UTF-16 码元
|
|
13
|
+
* @returns JSON 值包装;未找到为 null,缺少有效 App ID、宿主或读取失败为 false
|
|
14
|
+
*/
|
|
15
|
+
export declare function get<T extends TJson = TJson>(current: lCore.TCurrent, key: string): Promise<IStoredValue<T> | null | false>;
|
|
16
|
+
/**
|
|
17
|
+
* --- 保存当前 App 的持久配置,按 config.id 隔离 ---
|
|
18
|
+
* @param current 当前 App
|
|
19
|
+
* @param key 非空 Unicode 存储键,最多 128 个 UTF-16 码元
|
|
20
|
+
* @param value JSON 配置值,完整记录最大 1 MiB
|
|
21
|
+
* @returns 是否保存成功,普通网页或不支持此接口的宿主为 false
|
|
22
|
+
*/
|
|
23
|
+
export declare function set(current: lCore.TCurrent, key: string, value: TJson): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* --- 删除当前 App 的持久配置,按 config.id 隔离 ---
|
|
26
|
+
* @param current 当前 App
|
|
27
|
+
* @param key 非空 Unicode 存储键,最多 128 个 UTF-16 码元
|
|
28
|
+
* @returns 是否删除成功,未找到时也返回成功
|
|
29
|
+
*/
|
|
30
|
+
export declare function remove(current: lCore.TCurrent, key: string): Promise<boolean>;
|
package/dist/lib/native.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as lCore from './core';
|
|
2
|
+
import type * as lNativeStorage from './native/storage';
|
|
3
|
+
export * as storage from './native/storage';
|
|
4
|
+
export * as secret from './native/secret';
|
|
2
5
|
/**
|
|
3
6
|
* --- 初始化系统级 ID,仅能设置一次 ---
|
|
4
7
|
* @param id 系统级 ID
|
|
@@ -33,6 +36,18 @@ export declare function getCommandEntry(): Promise<ICommandEntry | null>;
|
|
|
33
36
|
* @returns 连接设置;未启用为 null,无权限为 false
|
|
34
37
|
*/
|
|
35
38
|
export declare function getMcpInfo(current: lCore.TCurrent): Promise<IMcpInfo | null | false>;
|
|
39
|
+
/**
|
|
40
|
+
* --- 按当前 App 的固定 ID 访问独立的持久存储,无需 root 权限 ---
|
|
41
|
+
* @internal
|
|
42
|
+
* @hidden
|
|
43
|
+
* @param current 当前 App
|
|
44
|
+
* @param area 普通配置或敏感数据
|
|
45
|
+
* @param action 存储操作
|
|
46
|
+
* @param key 稳定存储键
|
|
47
|
+
* @param value 待存储值
|
|
48
|
+
* @returns 主进程结果;缺少有效 App ID、App 已退出、宿主不支持或通讯失败为 false
|
|
49
|
+
*/
|
|
50
|
+
export declare function callPersistence(current: lCore.TCurrent, area: 'storage' | 'secret', action: 'get' | 'set' | 'remove' | 'isAvailable', key?: string, value?: lNativeStorage.TJson): Promise<lNativeStorage.IStoredValue | string | boolean | null>;
|
|
36
51
|
/**
|
|
37
52
|
* --- 监听 native 传输过来的事件 ---
|
|
38
53
|
* @param current 当前任务 ID
|
package/dist/lib/task.d.ts
CHANGED
|
@@ -263,6 +263,8 @@ export interface ITask {
|
|
|
263
263
|
/** --- 已开始退出;框架释放异步资源期间拒绝新命令 --- */
|
|
264
264
|
'ending'?: boolean;
|
|
265
265
|
'id': string;
|
|
266
|
+
/** --- 启动时确定的固定 App ID,与运行实例 ID 和加载路径无关 --- */
|
|
267
|
+
readonly 'appId'?: string;
|
|
266
268
|
'app': lCore.IApp;
|
|
267
269
|
'class': lCore.AbstractApp;
|
|
268
270
|
'customTheme': boolean;
|
package/dist/lib/tool.d.ts
CHANGED
|
@@ -430,11 +430,11 @@ export declare enum ESTATE {
|
|
|
430
430
|
'COMMENT' = 4
|
|
431
431
|
}
|
|
432
432
|
/**
|
|
433
|
-
* ---
|
|
434
|
-
* @param code
|
|
435
|
-
* @param start
|
|
436
|
-
* @param process
|
|
437
|
-
* @returns
|
|
433
|
+
* --- 源码分段状态机,单词按 ASCII 字母、数字、_ 和 $ 识别 ---
|
|
434
|
+
* @param code 待扫描源码,CRLF 和 CR 统一为 LF
|
|
435
|
+
* @param start 归一化后的起始 UTF-16 索引
|
|
436
|
+
* @param process 片段回调,true 继续、false 停止;位置含首尾,bracket 是共享计数对象
|
|
437
|
+
* @returns 无返回值
|
|
438
438
|
*/
|
|
439
439
|
export declare function stateMachine(code: string, start: number, process: (event: {
|
|
440
440
|
'state': ESTATE;
|
|
@@ -497,6 +497,12 @@ export declare function loadAssets(urls: string[], opt?: {
|
|
|
497
497
|
* @param style css 字符串
|
|
498
498
|
*/
|
|
499
499
|
export declare function loadStyle(style: string): void;
|
|
500
|
+
/**
|
|
501
|
+
* --- 判断 JS 值是否符合 JSON 数据约束;字符串按数据值接受,不解析其内容 ---
|
|
502
|
+
* @param value 待检查值;仅接受 null、布尔值、有限数、字符串、连续且无额外属性的数组和普通对象
|
|
503
|
+
* @returns 符合约束返回 true;循环、访问器、Symbol/非枚举属性或深度超过 64(根为 0)返回 false
|
|
504
|
+
*/
|
|
505
|
+
export declare function isJson(value: unknown): value is TJson;
|
|
500
506
|
/**
|
|
501
507
|
* --- 判断一个值是否是虚假的(为 null/undefined/空字符串/false/0) ---
|
|
502
508
|
* @param val 要判断的值
|
|
@@ -570,5 +576,9 @@ export interface IRequestOptions {
|
|
|
570
576
|
'load'?: (res: any) => void | Promise<void>;
|
|
571
577
|
'error'?: () => void | Promise<void>;
|
|
572
578
|
}
|
|
579
|
+
/** --- JSON 数据值,不包含 undefined、BigInt、函数和非有限数 --- */
|
|
580
|
+
export type TJson = null | boolean | number | string | TJson[] | {
|
|
581
|
+
[key: string]: TJson;
|
|
582
|
+
};
|
|
573
583
|
/** --- 虚假值类型 --- */
|
|
574
584
|
export type TFalsy = false | '' | 0 | null | undefined | typeof NaN;
|