clickgo 6.10.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/clickgo.d.ts +6 -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/guide.d.ts +7 -0
- package/dist/lib/command/webmcp.d.ts +84 -0
- package/dist/lib/command.d.ts +59 -7
- package/dist/lib/core/package.d.ts +23 -0
- package/dist/lib/core.d.ts +16 -3
- package/dist/lib/dom.d.ts +8 -3
- package/dist/lib/form.d.ts +7 -0
- package/dist/lib/native/secret.d.ts +29 -0
- package/dist/lib/native/storage.d.ts +30 -0
- package/dist/lib/native.d.ts +32 -0
- package/dist/lib/task.d.ts +2 -0
- package/dist/lib/tool.d.ts +15 -5
- package/doc/clickgo-rag.md +1739 -837
- package/package.json +16 -17
- package/AGENTS.md +0 -31
|
@@ -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,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as lCore from './core';
|
|
2
|
+
import * as lTool from './tool';
|
|
3
|
+
import * as lNative from './native';
|
|
2
4
|
export { showPalette } from './command/palette';
|
|
3
5
|
/** --- 命令输入与输出可跨浏览器、Native 和协议传输的 JSON 值 --- */
|
|
4
|
-
export type TJson =
|
|
5
|
-
[key: string]: TJson;
|
|
6
|
-
};
|
|
6
|
+
export type TJson = lTool.TJson;
|
|
7
7
|
/** --- JSON Schema 2020-12 的命令校验子集;不支持的关键字在注册时拒绝 --- */
|
|
8
8
|
export interface ISchema {
|
|
9
9
|
'$schema'?: string;
|
|
@@ -106,6 +106,8 @@ export interface IBridge {
|
|
|
106
106
|
}
|
|
107
107
|
/** --- 框架向网页发布的统一入口;按任务选择应用,只访问明确公开的命令 --- */
|
|
108
108
|
export interface IPageBridge {
|
|
109
|
+
'getAgentInfo': (taskId?: string) => Promise<IAgentInfo | null | false>;
|
|
110
|
+
'getAgentGuide': (taskId?: string) => Promise<string | null | false>;
|
|
109
111
|
'listTasks': () => Array<{
|
|
110
112
|
'id': string;
|
|
111
113
|
'name': string;
|
|
@@ -115,6 +117,42 @@ export interface IPageBridge {
|
|
|
115
117
|
'signal'?: AbortSignal;
|
|
116
118
|
}) => Promise<TResult>;
|
|
117
119
|
}
|
|
120
|
+
/** --- 统一接入说明的生成选项;默认不读取或包含 HTTP 凭据 --- */
|
|
121
|
+
export interface IAgentOptions {
|
|
122
|
+
/** --- 仅供应用主动导出 HTTP 连接设置,仍要求当前 App 已有 root 权限 --- */
|
|
123
|
+
'includeMcpCredentials'?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/** --- 页面级 WebMCP 接入状态;ready 表示浏览器接口可用,不表示某个 App 的工具已发布 --- */
|
|
126
|
+
export type TWebMcpStatus = 'unsupported' | 'ready';
|
|
127
|
+
/** --- 工具发布诊断状态,不参与页面级接入事件 --- */
|
|
128
|
+
export type TWebMcpRegistrationStatus = 'idle' | 'registering' | 'ready' | 'failed';
|
|
129
|
+
/** --- 可展示或导出的接入信息;命令列表始终从对应入口实时查询 --- */
|
|
130
|
+
export interface IAgentInfo {
|
|
131
|
+
'schemaVersion': 1;
|
|
132
|
+
'apps': ReturnType<typeof listTasks>;
|
|
133
|
+
'targetTaskId': string | null;
|
|
134
|
+
'browser': {
|
|
135
|
+
'url': string | null;
|
|
136
|
+
'api': string;
|
|
137
|
+
};
|
|
138
|
+
'webMcp': {
|
|
139
|
+
'supported': boolean;
|
|
140
|
+
/** --- 全页面共用的浏览器接入状态,不受目标 App 或工具数量影响 --- */
|
|
141
|
+
'status': TWebMcpStatus;
|
|
142
|
+
/** --- 所选 App 的发布诊断;多个 App 时优先报告失败及进行中的注册,不支持时为 null --- */
|
|
143
|
+
'registrationStatus': TWebMcpRegistrationStatus | null;
|
|
144
|
+
/** --- 已完成工具发布的 App,不表示这些 App 分别建立了浏览器连接 --- */
|
|
145
|
+
'publishedTaskIds': string[];
|
|
146
|
+
};
|
|
147
|
+
'native': lNative.ICommandEntry | null;
|
|
148
|
+
/** --- 只有显式导出且通过 root 检查时才包含 HTTP 凭据 --- */
|
|
149
|
+
'http': lNative.IMcpInfo | null;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* --- 初始化页面级 WebMCP 接入状态,由框架在执行 Boot.main 前自动调用 ---
|
|
153
|
+
* @returns 无返回值
|
|
154
|
+
*/
|
|
155
|
+
export declare function init(): void;
|
|
118
156
|
/**
|
|
119
157
|
* --- 构造成功结果 ---
|
|
120
158
|
* @param data 可跨入口传输的 JSON 数据
|
|
@@ -171,6 +209,20 @@ export declare function listTasks(): Array<{
|
|
|
171
209
|
'id': string;
|
|
172
210
|
'name': string;
|
|
173
211
|
}>;
|
|
212
|
+
/**
|
|
213
|
+
* --- 获取当前环境的统一接入信息,不另行维护命令清单或启用服务 ---
|
|
214
|
+
* @param current 限定目标 App;省略时由代理发现并选择 App
|
|
215
|
+
* @param options 是否主动导出 HTTP 连接凭据,默认不包含
|
|
216
|
+
* @returns 独立信息;目标已退出为 null,无权限导出凭据为 false
|
|
217
|
+
*/
|
|
218
|
+
export declare function getAgentInfo(current?: lCore.TCurrent, options?: IAgentOptions): Promise<IAgentInfo | null | false>;
|
|
219
|
+
/**
|
|
220
|
+
* --- 生成简短英文接入说明,不嵌入临时 App ID;代理通过接口实时发现 ---
|
|
221
|
+
* @param current 校验当前 App 生命周期与凭据导出权限;省略时生成页面通用说明
|
|
222
|
+
* @param options 是否主动导出 HTTP 连接凭据,默认不包含
|
|
223
|
+
* @returns Markdown 说明;目标已退出为 null,无权限导出凭据为 false
|
|
224
|
+
*/
|
|
225
|
+
export declare function getAgentGuide(current?: lCore.TCurrent, options?: IAgentOptions): Promise<string | null | false>;
|
|
174
226
|
/**
|
|
175
227
|
* --- 应用界面直接执行已注册的业务命令 ---
|
|
176
228
|
* @param current 所属任务/Form
|
|
@@ -205,13 +257,13 @@ export declare function createBridge(current: lCore.TCurrent): IBridge;
|
|
|
205
257
|
*/
|
|
206
258
|
export declare function createPageBridge(): IPageBridge;
|
|
207
259
|
/**
|
|
208
|
-
* ---
|
|
260
|
+
* --- 显式重同步或重试当前 App 的工具发布;页面接入由框架自动管理 ---
|
|
209
261
|
* @param current 所属应用
|
|
210
|
-
* @returns
|
|
262
|
+
* @returns 是否同步成功;浏览器不支持、App 已退出或注册失败时返回 false
|
|
211
263
|
*/
|
|
212
264
|
export declare function connectWebMcp(current: lCore.TCurrent): Promise<boolean>;
|
|
213
265
|
/**
|
|
214
|
-
* ---
|
|
266
|
+
* --- 撤销当前 App 的 WebMCP 工具;不改变页面级接入状态,下次公开命令注册时自动发布 ---
|
|
215
267
|
* @param current 所属应用
|
|
216
268
|
* @returns 无返回值
|
|
217
269
|
*/
|
|
@@ -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
|
@@ -18,6 +18,7 @@ import * as mpegts from 'mpegts.js';
|
|
|
18
18
|
import * as clickgo from '../clickgo';
|
|
19
19
|
import * as lForm from './form';
|
|
20
20
|
import * as lControl from './control';
|
|
21
|
+
import type * as lCommand from './command';
|
|
21
22
|
import * as lCore from './core';
|
|
22
23
|
/**
|
|
23
24
|
* --- 初始化系统级 ID,仅能设置一次 ---
|
|
@@ -107,6 +108,12 @@ export declare abstract class AbstractApp {
|
|
|
107
108
|
onTaskStarted(taskId: string): void | Promise<void>;
|
|
108
109
|
/** --- 任务结束事件 --- */
|
|
109
110
|
onTaskEnded(taskId: string): void | Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* --- 页面级 WebMCP 接入状态变化,所有 App 共用同一状态 ---
|
|
113
|
+
* @param status 浏览器接入状态,与 command.getAgentInfo 的 webMcp.status 一致
|
|
114
|
+
* @returns 无返回值
|
|
115
|
+
*/
|
|
116
|
+
onWebMcpStatusChanged(status: lCommand.TWebMcpStatus): void | Promise<void>;
|
|
110
117
|
/**
|
|
111
118
|
* --- Launcher 显示状态改变事件 ---
|
|
112
119
|
* @param state 是否显示
|
|
@@ -128,8 +135,9 @@ export declare function setBoot(b: clickgo.AbstractBoot): void;
|
|
|
128
135
|
*/
|
|
129
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>;
|
|
130
137
|
/**
|
|
131
|
-
* ---
|
|
132
|
-
* @param blob
|
|
138
|
+
* --- 读取 CGA 应用包及其配置 ---
|
|
139
|
+
* @param blob CGA 应用包的二进制内容
|
|
140
|
+
* @returns 应用信息;包无法识别或缺少文本配置时返回 false
|
|
133
141
|
*/
|
|
134
142
|
export declare function readApp(blob: Blob): Promise<false | IApp>;
|
|
135
143
|
/**
|
|
@@ -244,7 +252,7 @@ export interface IAvailArea {
|
|
|
244
252
|
'oheight': number;
|
|
245
253
|
}
|
|
246
254
|
/** --- 全局事件类型 --- */
|
|
247
|
-
export type TGlobalEvent = 'trayCreated' | 'trayChanged' | 'trayRemoved' | 'error' | 'screenResize' | 'configChanged' | 'formCreated' | 'formRemoved' | 'formTitleChanged' | 'formIconChanged' | 'formStateMinChanged' | 'formStateMaxChanged' | 'formShowChanged' | 'formFocused' | 'formBlurred' | 'formFlash' | 'formShowInSystemTaskChange' | 'formHashChange' | 'taskStarted' | 'taskEnded' | 'launcherShowChanged' | 'launcherFolderNameChanged' | 'hashChanged' | 'keydown' | 'keyup';
|
|
255
|
+
export type TGlobalEvent = 'trayCreated' | 'trayChanged' | 'trayRemoved' | 'error' | 'screenResize' | 'configChanged' | 'formCreated' | 'formRemoved' | 'formTitleChanged' | 'formIconChanged' | 'formStateMinChanged' | 'formStateMaxChanged' | 'formShowChanged' | 'formFocused' | 'formBlurred' | 'formFlash' | 'formShowInSystemTaskChange' | 'formHashChange' | 'taskStarted' | 'taskEnded' | 'webMcpStatusChanged' | 'launcherShowChanged' | 'launcherFolderNameChanged' | 'hashChanged' | 'keydown' | 'keyup';
|
|
248
256
|
/** --- 现场下载 app 的参数 --- */
|
|
249
257
|
export interface ICoreFetchAppOptions {
|
|
250
258
|
'notify'?: number | {
|
|
@@ -296,6 +304,11 @@ export interface IAppPackage {
|
|
|
296
304
|
}
|
|
297
305
|
/** --- 应用文件包 config --- */
|
|
298
306
|
export interface IAppConfig {
|
|
307
|
+
/**
|
|
308
|
+
* --- 固定应用 ID,如 net.example.notepad;Native 持久存储必填,跨位置和版本保持不变 ---
|
|
309
|
+
* 1-128 位字母、数字、点、下划线或连字符,以字母或数字开头。
|
|
310
|
+
*/
|
|
311
|
+
'id'?: string;
|
|
299
312
|
/** --- 应用名 --- */
|
|
300
313
|
'name': string;
|
|
301
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 {};
|
package/dist/lib/form.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as lCore from './core';
|
|
2
|
+
import * as lCommand from './command';
|
|
2
3
|
import * as lDom from './dom';
|
|
3
4
|
import * as lControl from './control';
|
|
4
5
|
/**
|
|
@@ -324,6 +325,12 @@ export declare abstract class AbstractForm extends AbstractCommon {
|
|
|
324
325
|
onTaskStarted(taskId: string): void | Promise<void>;
|
|
325
326
|
/** --- 任务结束事件 --- */
|
|
326
327
|
onTaskEnded(taskId: string): void | Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* --- 页面级 WebMCP 接入状态变化,所有 Form 共用同一状态 ---
|
|
330
|
+
* @param status 浏览器接入状态,与 command.getAgentInfo 的 webMcp.status 一致
|
|
331
|
+
* @returns 无返回值
|
|
332
|
+
*/
|
|
333
|
+
onWebMcpStatusChanged(status: lCommand.TWebMcpStatus): void | Promise<void>;
|
|
327
334
|
/**
|
|
328
335
|
* --- Launcher 显示状态改变事件 ---
|
|
329
336
|
* @param state 是否显示
|
|
@@ -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
|
|
@@ -10,12 +13,41 @@ export interface IMcpInfo {
|
|
|
10
13
|
'url': string;
|
|
11
14
|
'token': string;
|
|
12
15
|
}
|
|
16
|
+
/** --- 当前 Native 的公开进程入口,不包含 HTTP 连接凭据 --- */
|
|
17
|
+
export interface ICommandEntry {
|
|
18
|
+
'name': string;
|
|
19
|
+
'platform': string;
|
|
20
|
+
'command': string;
|
|
21
|
+
'args': string[];
|
|
22
|
+
'startup': 'existing' | 'auto';
|
|
23
|
+
'mcp': {
|
|
24
|
+
'enabled': boolean;
|
|
25
|
+
'discovery': boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* --- 取得软件自身的 CLI/stdio 入口和启动要求,无需读取连接凭据 ---
|
|
30
|
+
* @returns 公开入口信息;普通网页或尚未支持此接口的宿主为 null
|
|
31
|
+
*/
|
|
32
|
+
export declare function getCommandEntry(): Promise<ICommandEntry | null>;
|
|
13
33
|
/**
|
|
14
34
|
* --- 读取 Native 主进程启用的 MCP 连接设置 ---
|
|
15
35
|
* @param current 当前 App
|
|
16
36
|
* @returns 连接设置;未启用为 null,无权限为 false
|
|
17
37
|
*/
|
|
18
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>;
|
|
19
51
|
/**
|
|
20
52
|
* --- 监听 native 传输过来的事件 ---
|
|
21
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;
|