@limina_ai/plugin-sdk 0.0.0-stage → 1.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/index.d.ts ADDED
@@ -0,0 +1,168 @@
1
+ /** 中文:插件契约 v3 的开发类型;后端校验是最终权限边界。
2
+ * English: Development types for contract v3; backend validation is the final permission boundary. */
3
+ export type Caller = 'ui' | 'ai';
4
+ export type Surface = 'page' | 'session';
5
+ /** 中文:auto 表示插件面板选定的节点(按账号、插件、会话保存在后端,界面调用和 AI 调用都使用它;默认会话主节点,独立页默认第一个可用节点);session 表示会话节点(只运行会话所有者自己的调用);device 表示用户自己的节点;platform 表示平台运行池。
6
+ * English: auto is the node chosen in the plugin panel (stored per account, plugin and session; view and AI calls both use it; default: the session's primary node, or the first node in a standalone view); session: the session node (only the session owner's own calls); device: the user's own node; platform: the platform pool. */
7
+ export type Target = 'auto' | 'session' | 'device' | 'platform';
8
+ export type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };
9
+ export type JSONObject = { [key: string]: JSONValue };
10
+
11
+ export interface OperationDefinition {
12
+ /** 中文:AI 可调用(callers 含 ai)时必填。 English: Required when callers include "ai". */
13
+ description?: string;
14
+ callers: Caller[];
15
+ input_schema: Record<string, unknown>;
16
+ /** 中文:code(默认)表示在执行节点运行插件代码;hsm 表示受控加密机通信,需要 hsm 权限。 English: code (default) runs plugin code on the execution node; hsm performs controlled HSM communication and requires the hsm permission. */
17
+ executor?: 'code' | 'hsm';
18
+ /** 中文:覆盖 runtime.target。 English: Overrides runtime.target. */
19
+ target?: Target;
20
+ /** 中文:默认 write。 English: Default "write". */
21
+ effect?: 'read' | 'write';
22
+ /** 中文:该操作对插件空间的访问级别,默认 write。 English: Plugin-space access of this operation, default "write". */
23
+ files?: 'none' | 'read' | 'write';
24
+ /** 中文:超时时间,1000–110000 毫秒,默认 10000。 English: Timeout in milliseconds between 1000 and 110000, default 10000. */
25
+ timeout_ms?: number;
26
+ /** 中文:AI 只收到这些结果字段;省略时收到完整结果。 English: AI receives only these result fields, and every field when omitted. */
27
+ model_fields?: string[];
28
+ }
29
+ export interface Manifest {
30
+ schema: 3; id: string; name: string; version: string; description?: string;
31
+ permissions?: Array<'hsm' | 'sessions' | 'background' | 'models'>;
32
+ runtime?: { target?: Target };
33
+ operations?: Record<string, OperationDefinition>;
34
+ ui?: { views: Record<string, { title?: string; surfaces: Surface[] }>; control?: 1 };
35
+ }
36
+
37
+ /** 中文:插件空间内的文件或文件夹;path 相对本插件文件夹。 English: A file or folder in the plugin space; path is relative to this plugin's folder. */
38
+ export interface FileEntry { name: string; path: string; type: 'file' | 'dir'; size: number; modified_at: string | null; etag: string }
39
+ export interface FileContent { entry: FileEntry; encoding: 'utf8' | 'base64'; content: string }
40
+ export interface WriteOptions { /** 中文:仅当文件当前 etag 相同才写入;传 null 表示仅在文件不存在时创建,冲突时抛出 code=CONFLICT。 English: Write only when the file's current etag matches; null means create only when absent, and a conflict raises code=CONFLICT. */ ifMatch?: string | null }
41
+
42
+ /** 中文:界面与执行代码共用的插件空间文件接口。 English: File API shared by views and runtime code. */
43
+ export interface Files {
44
+ list(dir?: string, options?: { recursive?: boolean }): Promise<FileEntry[]>;
45
+ stat(path: string): Promise<FileEntry | null>;
46
+ exists(path: string): Promise<boolean>;
47
+ readText(path: string): Promise<string>;
48
+ readBytes(path: string): Promise<Uint8Array>;
49
+ /** 中文:文件不存在且提供了 fallback 时返回 fallback。 English: Returns fallback when the file is missing and a fallback is given. */
50
+ readJSON<T = JSONValue>(path: string, fallback?: T): Promise<T>;
51
+ read(path: string, options?: { encoding?: 'utf8' | 'base64' }): Promise<FileContent>;
52
+ writeText(path: string, text: string, options?: WriteOptions): Promise<FileEntry>;
53
+ writeBytes(path: string, data: Uint8Array | ArrayBuffer, options?: WriteOptions): Promise<FileEntry>;
54
+ writeJSON(path: string, value: JSONValue, options?: WriteOptions & { indent?: number }): Promise<FileEntry>;
55
+ remove(path: string, options?: { recursive?: boolean }): Promise<number>;
56
+ move(from: string, to: string, options?: { overwrite?: boolean }): Promise<FileEntry>;
57
+ }
58
+ /** 中文:仅界面可用,与用户设备交换文件,必须由人工点击触发。 English: Views only: exchange files with the user's device after a user click. */
59
+ export interface ViewFiles extends Files {
60
+ import(options?: { dir?: string; accept?: string; multiple?: boolean }): Promise<FileEntry[]>;
61
+ export(path: string, options?: { name?: string }): Promise<{ status: string }>;
62
+ }
63
+
64
+ export interface Invocation {
65
+ id: string; plugin_id: string; operation: string; caller: Caller; task_id: string;
66
+ status: 'succeeded' | 'failed'; result: JSONObject | null; error: string; node: string;
67
+ duration_ms: number; created_at: string;
68
+ }
69
+ export interface RuntimeNode { id: string; name: string; kind: 'session' | 'device' | 'platform'; platform: string }
70
+ export interface LiminaError extends Error {
71
+ /** 中文:可能的错误码为 NOT_FOUND | CONFLICT | INVALID_ARGUMENTS | FORBIDDEN | QUOTA_EXCEEDED | NO_RUNTIME_NODE | NODE_UNAVAILABLE | TIMEOUT | OPERATION_FAILED | RESULT_UNKNOWN | ERROR。 English: Possible error codes are NOT_FOUND | CONFLICT | INVALID_ARGUMENTS | FORBIDDEN | QUOTA_EXCEEDED | NO_RUNTIME_NODE | NODE_UNAVAILABLE | TIMEOUT | OPERATION_FAILED | RESULT_UNKNOWN | ERROR. */
72
+ code: string;
73
+ }
74
+ export interface LocaleContext { readonly locale: string; readonly direction: 'ltr' | 'rtl'; readonly source?: Readonly<Record<string,string>>; readonly messages?: Readonly<Record<string,string>> }
75
+ export interface LocalizationOptions { fallbackLocale: string; messages: Record<string, Record<string,string>> }
76
+ export interface Translator {
77
+ readonly locale: string; readonly resolvedLocale: string; readonly direction: 'ltr' | 'rtl';
78
+ t(key: string, params?: Record<string, string | number | boolean>): string;
79
+ number(value: number | bigint, options?: Intl.NumberFormatOptions): string;
80
+ date(value: number | Date, options?: Intl.DateTimeFormatOptions): string;
81
+ subscribe(listener: (translator: Translator) => void): () => void;
82
+ dispose(): void;
83
+ }
84
+ export interface UIControlSnapshot {
85
+ view: string; revision: number; controls: Array<Record<string, unknown>>;
86
+ offset: number; next: number | null; matched: number;
87
+ coverage: {total: number; supported: number; visible: number; unsupported: Array<{id:string;label:string}>};
88
+ feedback: string[]; errors: string[]; text: string; text_length: number;
89
+ }
90
+
91
+ /** 中文:界面桥 window.limina。 English: The view bridge, window.limina. */
92
+ export interface Client {
93
+ readonly sdkVersion: string;
94
+ readonly context: { readonly plugin: { id: string; version: string; name: string }; readonly surface: Surface; readonly view: string; readonly taskId: string };
95
+ /** 中文:调用清单声明的操作;后端校验参数与权限,调度到执行节点并返回结果,失败时 Promise 以 LiminaError 拒绝。
96
+ * English: Invoke a manifest operation; the backend validates and schedules it to a runtime node, and failures reject with LiminaError. */
97
+ invoke<T extends JSONObject = JSONObject>(operation: string, args?: JSONObject, options?: { /** 中文:target 为 device 时用于指定节点。 English: Names the node when target is device. */ node?: string }): Promise<T>;
98
+ readonly files: ViewFiles;
99
+ readonly nodes: { list(): Promise<RuntimeNode[]> };
100
+ readonly invocations: {
101
+ list(options?: { limit?: number; before?: string; operation?: string }): Promise<{ items: Invocation[]; next: string | null }>;
102
+ read(id: string): Promise<Invocation>;
103
+ };
104
+ /** 中文:invocation 表示本上下文有操作完成(含 AI 与其他客户端);files 表示插件空间有变更;返回取消订阅函数。 English: invocation fires when an operation finishes in this context (including AI and other clients); files fires when the plugin space changes; returns an unsubscribe function. */
105
+ on(event: 'invocation', listener: (value: Invocation) => void): () => void;
106
+ on(event: 'files', listener: (value: { paths: string[] }) => void): () => void;
107
+ copy(text: string): Promise<void>;
108
+ openWindow(viewState?: JSONValue): Promise<{opened: boolean}>;
109
+ onWindowContext(listener: (value: {canDetach: boolean}) => void): () => void;
110
+ setViewState(value: JSONValue): void;
111
+ onViewState(listener: (value: JSONValue) => void): () => void;
112
+ getLocale(): LocaleContext | null;
113
+ onLocale(listener: (value: LocaleContext) => void): () => void;
114
+ createI18n(options: LocalizationOptions): Translator;
115
+ readonly ui: {
116
+ register(element: Element, adapter: {kind:'field'|'action'|'select'|'toggle'|'file';label:string;sensitive?:boolean;read?:()=>{value?:string|number|boolean;disabled?:boolean;readonly?:boolean};set?:(value:string|number|boolean)=>void|Promise<void>;activate?:()=>void|Promise<void>;upload?:(files:Array<{name:string;content:string;encoding:'utf8'|'base64';type?:string}>)=>void|Promise<void>;key?:(event:{key:string;alt:boolean})=>void|Promise<void>}):()=>void;
117
+ snapshot(options?: {offset?:number;limit?:number;include_hidden?:boolean}): UIControlSnapshot;
118
+ bindFile(button: HTMLButtonElement, options: {accept?:string;multiple?:boolean}, handler: (files: File[]) => void | Promise<void>): void;
119
+ };
120
+ }
121
+
122
+ /** 中文:执行代码收到的上下文;身份由后端构造,插件不能覆盖。 English: Context for runtime code; identity is built by the backend. */
123
+ export interface OperationContext {
124
+ readonly plugin: { id: string; version: string };
125
+ readonly operation: string;
126
+ readonly caller: Caller;
127
+ readonly taskId: string;
128
+ readonly invocationId: string;
129
+ readonly locale: string;
130
+ /** 中文:与界面相同的插件空间,受操作的 files 级别限制。 English: The same plugin space as views, limited by the operation's files level. */
131
+ readonly files: Files;
132
+ /** 中文:操作超时或取消时触发。 English: Aborted on timeout or cancel. */
133
+ readonly signal: AbortSignal;
134
+ /** 中文:通用宿主调用,例如 call('files.stat', {path})。 English: Generic host call, for example call('files.stat', {path}). */
135
+ call<T = JSONValue>(service: string, args?: JSONObject): Promise<T>;
136
+ /** 中文:日志随调用结果返回并记录,最多 50 条。 English: Logs return with the result, up to 50 entries. */
137
+ log(...values: unknown[]): void;
138
+ }
139
+ export type OperationHandler = (args: JSONObject, context: OperationContext) => JSONObject | Promise<JSONObject>;
140
+
141
+ /** 中文:后台生命周期上下文(声明 background 权限的插件)。call 以 node 来源到达后端,身份由已认证的节点连接决定;会话相关调用需额外声明 sessions 权限。
142
+ * English: Background lifecycle context (plugins that declare the background permission). call reaches the backend as the node origin, with identity bound to the authenticated node connection; session calls also require the sessions permission. */
143
+ export interface BackgroundContext {
144
+ readonly plugin: { id: string; version: string };
145
+ /** 中文:节点停止、切换账号或卸载时触发。 English: Aborted when the node stops, the account switches or the plugin is uninstalled. */
146
+ readonly signal: AbortSignal;
147
+ readonly files: Files;
148
+ call<T = JSONValue>(service: string, args?: JSONObject): Promise<T>;
149
+ log(...values: unknown[]): void;
150
+ }
151
+ /** 中文:本机节点连上平台后调用一次;节点重启后再次调用。掉线期间插件继续运行,call 以 NODE_UNAVAILABLE 失败,重连后恢复。 English: Called once after the local node reaches the platform, and again after a node restart. While offline the plugin keeps running and call fails with NODE_UNAVAILABLE until the link returns. */
152
+ export type BackgroundStartHandler = (context: BackgroundContext) => void | Promise<void>;
153
+ /** 中文:节点停止、切换账号或卸载时调用,用于释放资源。 English: Called when the node stops, the account switches or the plugin is uninstalled, to release resources. */
154
+ export type BackgroundStopHandler = (info: { reason: 'stop' | 'update' | 'uninstall' }, context: BackgroundContext) => void | Promise<void>;
155
+
156
+ export const SDK_VERSION: string;
157
+ export const PACKAGE_FORMAT: string;
158
+ export const MANIFEST_SCHEMA: number;
159
+ export const limits: Readonly<Record<string, number>>;
160
+ export function toolName(pluginId: string, operation: string): string;
161
+ export function normalizePath(path: string, options?: { allowRoot?: boolean }): string;
162
+ export function viewFor(manifest: Manifest, surface: Surface): ({ name: string; title?: string; surfaces: Surface[] }) | null;
163
+ /** 中文:取得界面桥;未在 LIMINA 宿主中打开时抛错。 English: Get the view bridge; throws when not opened inside a LIMINA host. */
164
+ export function getClient(): Client;
165
+ export function createI18n(options: LocalizationOptions): Translator;
166
+ /** 中文:执行代码的类型辅助:export const operations = defineOperations({...});执行代码在节点进程内运行,可使用完整的 Node 能力。 English: Type helper for runtime code: export const operations = defineOperations({...}); runtime code runs inside the node process with full Node capabilities. */
167
+ export function defineOperations<T extends Record<string, OperationHandler>>(handlers: T): T;
168
+ declare global { var limina: Client; var liminaLocalization: LocalizationOptions; }
package/index.js ADDED
@@ -0,0 +1,17 @@
1
+ // 中文:开发者入口。界面代码通过 getClient() 取得宿主注入的桥;执行代码导出 operations 对象,由节点直接加载运行。
2
+ // English: Developer entry. Views get the host-injected bridge with getClient(); runtime code exports an operations object that nodes load and run directly.
3
+ export { SDK_VERSION, PACKAGE_FORMAT, MANIFEST_SCHEMA, limits, toolName, normalizePath, viewFor } from './contract.js'
4
+ // 中文:取得宿主注入的界面桥;不在 LIMINA 宿主内时抛错。
5
+ // English: Get the host-injected view bridge; throws outside a LIMINA host.
6
+ export function getClient() {
7
+ if (!globalThis.limina?.invoke) throw new Error('请在 LIMINA 客户端安装后打开此界面')
8
+ return globalThis.limina
9
+ }
10
+ // 中文:使用宿主注入的同一翻译实现。 English: Use the host-injected translator implementation.
11
+ export function createI18n(options) { return getClient().createI18n(options) }
12
+ // 中文:为执行代码提供类型入口;执行代码是标准 ES 模块,导出 operations 对象:export const operations = defineOperations({...})。
13
+ // English: Typed helper for runtime code, a standard ES module exporting an operations object: export const operations = defineOperations({...}).
14
+ export function defineOperations(handlers) {
15
+ if (!handlers || typeof handlers !== 'object') throw new TypeError('操作表必须是对象')
16
+ return handlers
17
+ }
@@ -0,0 +1,31 @@
1
+ import {readFileSync} from 'node:fs'
2
+ const supportedLocales = JSON.parse(readFileSync(new URL('./supported-locales.json', import.meta.url), 'utf8'))
3
+ // Build-time checks for plugin-owned language packs. No host catalog dependency.
4
+ // 中文:校验插件自带语言包的语言代码、必需语言、键和占位符一致性,不依赖宿主文案表。
5
+ // English: Validate plugin-owned locale codes, required languages, keys and placeholders independently of host messages.
6
+ export function validateLocales(config) {
7
+ if (!config || typeof config !== 'object' || Array.isArray(config)) throw new Error('Invalid localization config')
8
+ const {fallbackLocale, messages} = config
9
+ const canonical = value => {
10
+ if (typeof value !== 'string' || Intl.getCanonicalLocales(value)[0] !== value) throw new Error(`Use canonical BCP 47 locale: ${value}`)
11
+ return value
12
+ }
13
+ canonical(fallbackLocale)
14
+ if (!messages || typeof messages !== 'object' || Array.isArray(messages) || !Object.hasOwn(messages, fallbackLocale)) throw new Error('Missing fallback language pack')
15
+ const base = messages[fallbackLocale]
16
+ if (!base || typeof base !== 'object' || Array.isArray(base) || !Object.keys(base).length) throw new Error('Empty fallback language pack')
17
+ const keys = Object.keys(base).sort()
18
+ const params = text => [...new Set([...text.matchAll(/\{([a-zA-Z_][\w]*)\}/g)].map(match => match[1]))].sort().join(',')
19
+ for (const [locale, pack] of Object.entries(messages)) {
20
+ canonical(locale)
21
+ if (!pack || typeof pack !== 'object' || Array.isArray(pack) || Object.keys(pack).sort().join('\0') !== keys.join('\0')) throw new Error(`Translation keys differ: ${locale}`)
22
+ for (const key of keys) {
23
+ if (!/^[a-zA-Z][\w.-]*$/.test(key)) throw new Error(`Invalid translation key: ${key}`)
24
+ if (typeof pack[key] !== 'string' || !pack[key].trim()) throw new Error(`Empty translation: ${locale}.${key}`)
25
+ if (typeof base[key] !== 'string' || params(pack[key]) !== params(base[key])) throw new Error(`Placeholder mismatch: ${locale}.${key}`)
26
+ }
27
+ }
28
+ const missing = supportedLocales.filter(locale => !Object.hasOwn(messages, locale))
29
+ if (missing.length) throw new Error(`Missing required LIMINA languages: ${missing.join(', ')}`)
30
+ return config
31
+ }
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@limina_ai/plugin-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "LIMINA plugin SDK: types, UI bridge, package validator and the limina-plugin build CLI",
5
+ "homepage": "https://www.limina.cc/plugin-guide",
6
+ "author": "LIMINA",
7
+ "license": "UNLICENSED",
8
+ "keywords": ["limina", "plugin", "sdk", "ai-tools"],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./index.d.ts",
13
+ "default": "./index.js"
14
+ },
15
+ "./validate": "./validation.js",
16
+ "./archive": "./archive.js",
17
+ "./execution": {
18
+ "types": "./execution.d.ts",
19
+ "default": "./execution.js"
20
+ },
21
+ "./contract": "./contract.js",
22
+ "./localization": "./localization.js",
23
+ "./hsm-analysis": "./hsm-analysis.mjs",
24
+ "./hsm-codec": "./hsm-codec.mjs",
25
+ "./supported-locales.json": "./supported-locales.json",
26
+ "./schema": "./schema/manifest.schema.json",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "*.js",
31
+ "*.mjs",
32
+ "*.d.ts",
33
+ "schema/",
34
+ "supported-locales.json",
35
+ "THIRD_PARTY_LICENSES.txt",
36
+ "README.md"
37
+ ],
38
+ "bin": {
39
+ "limina-plugin": "./cli.js"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "dependencies": {
45
+ "@zip.js/zip.js": "2.7.57",
46
+ "ajv": "8.20.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=22"
50
+ }
51
+ }
@@ -0,0 +1,207 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://www.limina.cc/schemas/plugin-manifest-3.json",
4
+ "title": "LIMINA plugin manifest v3",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema",
9
+ "id",
10
+ "name",
11
+ "version"
12
+ ],
13
+ "properties": {
14
+ "schema": {
15
+ "const": 3
16
+ },
17
+ "id": {
18
+ "$ref": "#/$defs/name"
19
+ },
20
+ "name": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "maxLength": 80,
24
+ "pattern": "\\S"
25
+ },
26
+ "version": {
27
+ "type": "string",
28
+ "pattern": "^\\d+\\.\\d+\\.\\d+$",
29
+ "maxLength": 32
30
+ },
31
+ "description": {
32
+ "type": "string",
33
+ "maxLength": 500
34
+ },
35
+ "author": {
36
+ "type": "string",
37
+ "maxLength": 80
38
+ },
39
+ "permissions": {
40
+ "type": "array",
41
+ "uniqueItems": true,
42
+ "maxItems": 16,
43
+ "items": {
44
+ "enum": [
45
+ "hsm",
46
+ "sessions",
47
+ "background",
48
+ "models"
49
+ ]
50
+ }
51
+ },
52
+ "runtime": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "properties": {
56
+ "target": {
57
+ "$ref": "#/$defs/target"
58
+ }
59
+ }
60
+ },
61
+ "operations": {
62
+ "type": "object",
63
+ "maxProperties": 64,
64
+ "propertyNames": {
65
+ "$ref": "#/$defs/name"
66
+ },
67
+ "additionalProperties": {
68
+ "$ref": "#/$defs/operation"
69
+ }
70
+ },
71
+ "ui": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": [
75
+ "views"
76
+ ],
77
+ "properties": {
78
+ "views": {
79
+ "type": "object",
80
+ "minProperties": 1,
81
+ "maxProperties": 8,
82
+ "propertyNames": {
83
+ "$ref": "#/$defs/name"
84
+ },
85
+ "additionalProperties": {
86
+ "$ref": "#/$defs/view"
87
+ }
88
+ },
89
+ "control": {
90
+ "const": 1
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "$defs": {
96
+ "name": {
97
+ "type": "string",
98
+ "maxLength": 40,
99
+ "pattern": "^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$"
100
+ },
101
+ "target": {
102
+ "enum": [
103
+ "auto",
104
+ "session",
105
+ "device",
106
+ "platform"
107
+ ]
108
+ },
109
+ "operation": {
110
+ "type": "object",
111
+ "additionalProperties": false,
112
+ "required": [
113
+ "callers",
114
+ "input_schema"
115
+ ],
116
+ "properties": {
117
+ "description": {
118
+ "type": "string",
119
+ "maxLength": 1024
120
+ },
121
+ "callers": {
122
+ "type": "array",
123
+ "minItems": 1,
124
+ "uniqueItems": true,
125
+ "items": {
126
+ "enum": [
127
+ "ui",
128
+ "ai"
129
+ ]
130
+ }
131
+ },
132
+ "input_schema": {
133
+ "type": "object",
134
+ "required": [
135
+ "type"
136
+ ],
137
+ "properties": {
138
+ "type": {
139
+ "const": "object"
140
+ }
141
+ }
142
+ },
143
+ "executor": {
144
+ "enum": [
145
+ "code",
146
+ "hsm"
147
+ ]
148
+ },
149
+ "target": {
150
+ "$ref": "#/$defs/target"
151
+ },
152
+ "effect": {
153
+ "enum": [
154
+ "read",
155
+ "write"
156
+ ]
157
+ },
158
+ "files": {
159
+ "enum": [
160
+ "none",
161
+ "read",
162
+ "write"
163
+ ]
164
+ },
165
+ "timeout_ms": {
166
+ "type": "integer",
167
+ "minimum": 1000,
168
+ "maximum": 110000
169
+ },
170
+ "model_fields": {
171
+ "type": "array",
172
+ "uniqueItems": true,
173
+ "maxItems": 64,
174
+ "items": {
175
+ "type": "string",
176
+ "minLength": 1,
177
+ "maxLength": 80
178
+ }
179
+ }
180
+ }
181
+ },
182
+ "view": {
183
+ "type": "object",
184
+ "additionalProperties": false,
185
+ "required": [
186
+ "surfaces"
187
+ ],
188
+ "properties": {
189
+ "title": {
190
+ "type": "string",
191
+ "maxLength": 80
192
+ },
193
+ "surfaces": {
194
+ "type": "array",
195
+ "minItems": 1,
196
+ "uniqueItems": true,
197
+ "items": {
198
+ "enum": [
199
+ "page",
200
+ "session"
201
+ ]
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
@@ -0,0 +1,32 @@
1
+ [
2
+ "zh-CN",
3
+ "zh-TW",
4
+ "en",
5
+ "es",
6
+ "fr",
7
+ "de",
8
+ "pt-BR",
9
+ "it",
10
+ "nl",
11
+ "pl",
12
+ "cs",
13
+ "ro",
14
+ "hu",
15
+ "uk",
16
+ "ru",
17
+ "tr",
18
+ "ar",
19
+ "he",
20
+ "fa",
21
+ "hi",
22
+ "bn",
23
+ "ur",
24
+ "id",
25
+ "ms",
26
+ "vi",
27
+ "th",
28
+ "ja",
29
+ "ko",
30
+ "sv",
31
+ "el"
32
+ ]
@@ -0,0 +1,21 @@
1
+ // 中文:UI 控制属于宿主能力,不是业务 Worker 操作;控件引用只能来自当前快照。
2
+ // English: UI control is a host capability rather than a business Worker operation, and control references may only come from the current snapshot.
3
+ export const uiControlSchema = {
4
+ type:'object',additionalProperties:false,
5
+ properties:{
6
+ action:{type:'string',enum:['inspect','read','set','activate','upload','key']},
7
+ view:{type:'string'},revision:{type:'integer',minimum:0},target:{type:'string'},
8
+ offset:{type:'integer',minimum:0},limit:{type:'integer',minimum:1,maximum:20},include_hidden:{type:'boolean'},
9
+ start:{type:'integer',minimum:0},length:{type:'integer',minimum:1,maximum:4096},
10
+ key:{type:'string',enum:['Enter','Escape','ArrowLeft','ArrowRight','ArrowUp','ArrowDown','Home','End']},alt:{type:'boolean'},
11
+ value:{type:['string','number','boolean']},
12
+ files:{type:'array',minItems:1,items:{type:'object',additionalProperties:false,properties:{name:{type:'string',minLength:1},content:{type:'string'},encoding:{type:'string',enum:['utf8','base64']},type:{type:'string'}},required:['name','content','encoding']}},
13
+ },required:['action'],
14
+ allOf:[
15
+ {if:{properties:{action:{type:'string',enum:['read','set','activate','upload','key']}}},then:{required:['view','revision','target']}},
16
+ {if:{properties:{action:{type:'string',const:'set'}}},then:{required:['value']}},
17
+ {if:{properties:{action:{type:'string',const:'key'}}},then:{required:['key']}},
18
+ {if:{properties:{action:{type:'string',const:'upload'}}},then:{required:['files']}},
19
+ ],
20
+ }
21
+ export const uiControlDescription='操作当前会话插件的真实工作台。inspect 按 offset 分页,next 非空时继续读取;默认只列可见控件,include_hidden 可审计全部控件。read 的 target=page 读取当前可见界面文本;key 仅用于返回 actions 含 key 的控件。长字段快照仅含预览,可用 read 分段完整读取;coverage 会明确列出不支持的控件。先 inspect 获取当前控件、view 和 revision,再按返回的 target 执行 set、activate 或 upload;不要猜控件 ID。set 只修改输入,不执行运算。activate 调用与人工按钮相同的处理器。upload 传入用户提供的文件内容,不传本机路径。每次操作返回更新后的快照与执行反馈;状态冲突需重新检查,不盲目重试。隐藏、禁用控件不可操作,敏感字段只返回是否已填写。'