@xiongtao.xt/tau-plugins 0.60.0 → 0.62.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/client/chunk-UGYIAPAN.js +869 -0
  3. package/docs/README.md +1 -0
  4. package/docs/backend.md +4 -10
  5. package/docs/blog-templates.md +7 -6
  6. package/docs/document-body.md +2 -0
  7. package/docs/getting-started.md +2 -14
  8. package/docs/plugin-basics.md +1 -1
  9. package/docs/portability.md +25 -2
  10. package/docs/skills.md +10 -12
  11. package/docs/task-data.md +389 -0
  12. package/docs/user-data.md +31 -24
  13. package/package.js +1 -1
  14. package/package.json +5 -1
  15. package/portable.js +3 -2
  16. package/publish-artifacts.js +36 -19
  17. package/types/packages/plugins/src/data-changes.d.ts +51 -0
  18. package/types/packages/plugins/src/data.d.ts +122 -7
  19. package/types/packages/plugins/src/errors.d.ts +7 -0
  20. package/types/packages/plugins/src/events.d.ts +17 -12
  21. package/types/packages/plugins/src/index.d.ts +2 -2
  22. package/types/packages/plugins/src/package.d.ts +7 -2
  23. package/types/packages/plugins/src/portable.d.ts +5 -2
  24. package/types/packages/plugins/src/skills.d.ts +16 -0
  25. package/types/packages/plugins/src/template.d.ts +101 -0
  26. package/types/packages/plugins/src/unified.d.ts +60 -0
  27. package/types/packages/plugins/src/version.d.ts +5 -0
  28. package/types/packages/shared/src/task-assistant/contracts.d.ts +15 -0
  29. package/types/packages/shared/src/task-assistant/directories.d.ts +15 -0
  30. package/types/packages/shared/src/task-assistant/directory-colors.d.ts +2 -0
  31. package/types/packages/shared/src/task-assistant/occurrence-state.d.ts +7 -0
  32. package/types/packages/shared/src/task-assistant/schema.d.ts +3 -0
  33. package/types/packages/shared/task-assistant.d.ts +2 -0
  34. package/types/packages/ui/src/hooks/useEdgeFade.d.ts +1 -1
  35. package/types/packages/ui/src/primitives/AnchoredPanel.d.ts +3 -1
  36. package/types/packages/ui/src/primitives/anchoredPosition.d.ts +8 -0
  37. package/unified.js +21 -0
  38. package/client/chunk-6XAEU7BJ.js +0 -330
  39. package/client/chunk-PRE35AOA.js +0 -185
@@ -1,330 +0,0 @@
1
- // packages/plugins/src/ids.ts
2
- function assertLocalId(value) {
3
- if (typeof value !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(value)) {
4
- throw new Error("\u63D2\u4EF6\u6807\u8BC6\u5FC5\u987B\u4E3A 1 \u81F3 128 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u70B9\u3001\u6A2A\u7EBF\u6216\u4E0B\u5212\u7EBF");
5
- }
6
- }
7
-
8
- // packages/plugins/src/version.ts
9
- function parseVersion(value) {
10
- const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(
11
- value
12
- );
13
- if (!match) throw new Error(`\u7248\u672C\u53F7\u65E0\u6548\uFF1A${value}`);
14
- const pre = match[4]?.split(".") ?? [];
15
- if (pre.some((part) => /^\d+$/.test(part) && part.length > 1 && part.startsWith("0")))
16
- throw new Error(`\u7248\u672C\u53F7\u65E0\u6548\uFF1A${value}`);
17
- return { core: match.slice(1, 4), pre };
18
- }
19
- function comparePluginVersions(left, right) {
20
- const a = parseVersion(left);
21
- const b = parseVersion(right);
22
- const numeric = (x, y) => BigInt(x) === BigInt(y) ? 0 : BigInt(x) > BigInt(y) ? 1 : -1;
23
- for (let index = 0; index < 3; index++) {
24
- const result = numeric(a.core[index], b.core[index]);
25
- if (result) return result;
26
- }
27
- if (!a.pre.length || !b.pre.length)
28
- return a.pre.length === b.pre.length ? 0 : a.pre.length ? -1 : 1;
29
- for (let index = 0; index < Math.max(a.pre.length, b.pre.length); index++) {
30
- const x = a.pre[index], y = b.pre[index];
31
- if (x === void 0 || y === void 0) return x === void 0 ? -1 : 1;
32
- if (x === y) continue;
33
- const nx = /^\d+$/.test(x), ny = /^\d+$/.test(y);
34
- return nx && ny ? numeric(x, y) : nx !== ny ? nx ? -1 : 1 : x > y ? 1 : -1;
35
- }
36
- return 0;
37
- }
38
-
39
- // packages/plugins/src/backend-manifest.ts
40
- var PLUGIN_SYSTEM_ACCESS = ["filesystem", "network", "process"];
41
- function validateBackendManifest(value) {
42
- if (!value || typeof value !== "object" || Array.isArray(value))
43
- throw new Error("\u540E\u53F0\u58F0\u660E\u5FC5\u987B\u662F\u5BF9\u8C61");
44
- const item = value;
45
- if (typeof item.entry !== "string" || !/^[\w./-]+\.js$/.test(item.entry) || item.entry.split("/").some((part) => !part || part === "." || part === ".."))
46
- throw new Error("\u540E\u53F0\u5165\u53E3\u5FC5\u987B\u662F\u5305\u5185 JS \u6587\u4EF6");
47
- if (item.runtime !== "node" || item.apiVersion !== 1)
48
- throw new Error("\u540E\u53F0\u8FD0\u884C\u65F6\u6216\u534F\u8BAE\u7248\u672C\u4E0D\u517C\u5BB9");
49
- if (item.scope !== "application" && item.scope !== "workspace") throw new Error("\u540E\u53F0\u4F5C\u7528\u57DF\u65E0\u6548");
50
- if (item.activation !== "on-demand" && item.activation !== "app-ready" && item.activation !== "workspace-ready")
51
- throw new Error("\u540E\u53F0\u6FC0\u6D3B\u65F6\u673A\u65E0\u6548");
52
- if (item.activation !== "on-demand" && item.activation !== (item.scope === "application" ? "app-ready" : "workspace-ready"))
53
- throw new Error("\u540E\u53F0\u6FC0\u6D3B\u65F6\u673A\u4E0E\u4F5C\u7528\u57DF\u4E0D\u5339\u914D");
54
- if (item.lifetime !== "idle" && item.lifetime !== "persistent")
55
- throw new Error("\u540E\u53F0\u751F\u547D\u5468\u671F\u65E0\u6548");
56
- if (typeof item.reason !== "string" || !item.reason.trim()) throw new Error("\u540E\u53F0\u7528\u9014\u4E0D\u80FD\u4E3A\u7A7A");
57
- if (!Array.isArray(item.systemAccess) || item.systemAccess.some((value2) => !PLUGIN_SYSTEM_ACCESS.includes(value2)))
58
- throw new Error("\u540E\u53F0\u7CFB\u7EDF\u7528\u9014\u5206\u7C7B\u65E0\u6548");
59
- let tools;
60
- if (item.tools !== void 0) {
61
- if (!Array.isArray(item.tools) || !item.systemAccess.includes("process"))
62
- throw new Error("\u5916\u90E8\u5DE5\u5177\u987B\u58F0\u660E process \u7528\u9014");
63
- const ids = /* @__PURE__ */ new Set();
64
- tools = Object.freeze(
65
- item.tools.map((tool) => {
66
- if (!tool || typeof tool !== "object" || Array.isArray(tool))
67
- throw new Error("\u5916\u90E8\u5DE5\u5177\u58F0\u660E\u65E0\u6548");
68
- const value2 = tool;
69
- if (typeof value2.id !== "string" || !/^[a-z][\w.-]*$/.test(value2.id) || ids.has(value2.id) || typeof value2.command !== "string" || !value2.command.trim() || value2.command.includes("\0"))
70
- throw new Error("\u5916\u90E8\u5DE5\u5177\u8EAB\u4EFD\u6216\u547D\u4EE4\u65E0\u6548");
71
- ids.add(value2.id);
72
- if (value2.args !== void 0 && (!Array.isArray(value2.args) || value2.args.some((arg) => typeof arg !== "string" || arg.includes("\0"))))
73
- throw new Error("\u5916\u90E8\u5DE5\u5177\u53C2\u6570\u65E0\u6548");
74
- return Object.freeze({
75
- id: value2.id,
76
- command: value2.command,
77
- ...value2.args ? { args: Object.freeze([...value2.args]) } : {}
78
- });
79
- })
80
- );
81
- }
82
- return Object.freeze({
83
- ...tools ? { tools } : {},
84
- entry: item.entry,
85
- runtime: "node",
86
- apiVersion: 1,
87
- scope: item.scope,
88
- activation: item.activation,
89
- lifetime: item.lifetime,
90
- reason: item.reason.trim(),
91
- systemAccess: Object.freeze([...new Set(item.systemAccess)])
92
- });
93
- }
94
-
95
- // packages/plugins/src/categories.ts
96
- var PLUGIN_CATEGORIES = [
97
- { id: "sync", label: "\u540C\u6B65" },
98
- { id: "upload", label: "\u8D44\u6E90\u4E0A\u4F20" },
99
- { id: "editor", label: "\u7F16\u8F91\u5668" },
100
- { id: "whiteboard", label: "\u767D\u677F" },
101
- { id: "blog-template", label: "\u535A\u5BA2\u6A21\u677F" },
102
- { id: "blog-publish", label: "\u535A\u5BA2\u53D1\u5E03" },
103
- { id: "ai", label: "AI" },
104
- { id: "skill", label: "Skill" },
105
- { id: "voice", label: "\u8BED\u97F3" },
106
- { id: "video", label: "\u89C6\u9891" },
107
- { id: "page", label: "\u9875\u9762" }
108
- ];
109
- var categoryIds = new Set(PLUGIN_CATEGORIES.map((item) => item.id));
110
- var isPluginCategory = (value) => typeof value === "string" && categoryIds.has(value);
111
- function readCatalogFields(item) {
112
- const list = (value, name) => {
113
- if (value === void 0) return [];
114
- if (Array.isArray(value)) return value;
115
- throw new Error(`${name} \u5FC5\u987B\u662F\u6570\u7EC4`);
116
- };
117
- const categories = [];
118
- for (const value of list(item.categories, "categories")) {
119
- if (!isPluginCategory(value)) throw new Error(`\u672A\u77E5\u63D2\u4EF6\u5206\u7C7B\uFF1A${String(value)}`);
120
- else if (!categories.includes(value)) categories.push(value);
121
- }
122
- const keywords = [];
123
- for (const value of list(item.keywords, "keywords")) {
124
- const keyword = typeof value === "string" ? value.trim() : "";
125
- if (!keyword) throw new Error("\u5173\u952E\u8BCD\u5FC5\u987B\u662F\u975E\u7A7A\u6587\u672C");
126
- else if (!keywords.includes(keyword)) keywords.push(keyword);
127
- }
128
- return {
129
- ...categories.length ? { categories: Object.freeze(categories) } : {},
130
- ...keywords.length ? { keywords: Object.freeze(keywords) } : {}
131
- };
132
- }
133
-
134
- // packages/plugins/src/ai.ts
135
- var PLUGIN_AI_CAPABILITIES = {
136
- chat: { name: "\u5BF9\u8BDD\u529F\u80FD" },
137
- flashcardGeneration: { name: "\u95EA\u5361" }
138
- };
139
- var isPluginAICapability = (value) => typeof value === "string" && Object.hasOwn(PLUGIN_AI_CAPABILITIES, value);
140
-
141
- // packages/plugins/src/permissions.ts
142
- var aiPermissions = Object.keys(PLUGIN_AI_CAPABILITIES).map(
143
- (capability) => `ai:${capability}`
144
- );
145
- var PLUGIN_PERMISSIONS = [
146
- "cards:read",
147
- "cards:write",
148
- "cards:delete",
149
- "articles:read",
150
- "articles:write",
151
- "articles:delete",
152
- "documents:read",
153
- "documents:write",
154
- "documents:delete",
155
- "whiteboards:read",
156
- "whiteboards:write",
157
- "whiteboards:delete",
158
- "projects:read",
159
- "projects:write",
160
- "projects:delete",
161
- "todos:read",
162
- "todos:write",
163
- "todos:delete",
164
- "calendar:read",
165
- "calendar:write",
166
- "calendar:delete",
167
- "notebooks:read",
168
- "materials:read",
169
- "chats:read",
170
- "flashcards:read",
171
- "flashcards:write",
172
- "speech:input",
173
- "tts:synthesize",
174
- ...aiPermissions
175
- ];
176
- var permissionIds = new Set(PLUGIN_PERMISSIONS);
177
- var isPluginPermission = (value) => typeof value === "string" && permissionIds.has(value);
178
- function readPermissionsField(item) {
179
- if (item.permissions === void 0) return {};
180
- if (!Array.isArray(item.permissions)) {
181
- throw new Error("permissions \u5FC5\u987B\u662F\u6570\u7EC4");
182
- }
183
- const permissions = [];
184
- for (const value of item.permissions) {
185
- if (!isPluginPermission(value)) throw new Error(`\u672A\u77E5\u63D2\u4EF6\u6743\u9650\uFF1A${String(value)}`);
186
- else if (!permissions.includes(value)) permissions.push(value);
187
- }
188
- return permissions.length ? { permissions: Object.freeze(permissions) } : {};
189
- }
190
-
191
- // packages/plugins/src/skills.ts
192
- var SKILL_ROOT = "skills";
193
- var SKILL_README = "SKILL.md";
194
- var skillDirectory = (id) => `${SKILL_ROOT}/${id}`;
195
- function readSkillsField(value) {
196
- if (value === void 0) return void 0;
197
- if (!Array.isArray(value)) throw new Error("skills \u5FC5\u987B\u662F\u6570\u7EC4");
198
- const ids = /* @__PURE__ */ new Set();
199
- for (const id of value) {
200
- if (typeof id !== "string") throw new Error("Skill ID \u65E0\u6548");
201
- assertLocalId(id);
202
- ids.add(id);
203
- }
204
- return ids.size ? Object.freeze([...ids]) : void 0;
205
- }
206
- function readSkillFiles(skills, integrity) {
207
- const files = {};
208
- const declared = new Set(skills ?? []);
209
- for (const [name, hash] of Object.entries(integrity)) {
210
- if (!name.startsWith(SKILL_ROOT + "/")) continue;
211
- const [, id, ...rest] = name.split("/");
212
- if (!declared.has(id) || !rest.length || rest.some((part) => !part || part === "." || part === ".."))
213
- throw new Error(`Skill \u6587\u4EF6\u4E0D\u5C5E\u4E8E\u5DF2\u58F0\u660E\u7684 Skill\uFF1A${name}`);
214
- if (typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash))
215
- throw new Error("Skill \u6587\u4EF6\u7F3A\u5C11\u6709\u6548\u7684\u5B8C\u6574\u6027\u6458\u8981");
216
- files[name] = hash;
217
- }
218
- for (const id of declared)
219
- if (!files[`${skillDirectory(id)}/${SKILL_README}`])
220
- throw new Error(`Skill ${id} \u7F3A\u5C11 ${SKILL_README}`);
221
- return files;
222
- }
223
-
224
- // packages/plugins/src/package-fields.ts
225
- function readPluginIdentity(item) {
226
- const { id, name, version } = item;
227
- if (typeof id !== "string") throw new Error("\u63D2\u4EF6 ID \u65E0\u6548");
228
- assertLocalId(id);
229
- if (typeof name !== "string" || !name.trim() || typeof version !== "string")
230
- throw new Error("\u63D2\u4EF6\u540D\u79F0\u6216\u7248\u672C\u65E0\u6548");
231
- comparePluginVersions(version, version);
232
- return { id, name, version };
233
- }
234
- function readPluginMetadata(item) {
235
- return { ...readPluginIdentity(item), ...readCatalogFields(item), ...readPermissionsField(item) };
236
- }
237
- function readPluginFilePath(input, extension) {
238
- if (typeof input !== "string" || !/^[\w./-]+$/.test(input) || input.split("/").some((part) => !part || part === "." || part === "..") || !input.endsWith(extension))
239
- throw new Error("\u63D2\u4EF6\u5165\u53E3\u6216\u6837\u5F0F\u8DEF\u5F84\u65E0\u6548");
240
- return input;
241
- }
242
- function readPluginFiles(item, entries) {
243
- if (!item.integrity || typeof item.integrity !== "object" || Array.isArray(item.integrity))
244
- throw new Error("\u63D2\u4EF6\u4EA7\u7269\u7F3A\u5C11\u5B8C\u6574\u6027\u6458\u8981\u6E05\u5355");
245
- const source = item.integrity;
246
- const integrity = {};
247
- for (const name of entries) {
248
- const hash = source[name];
249
- if (typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash))
250
- throw new Error("\u63D2\u4EF6\u4EA7\u7269\u7F3A\u5C11\u6709\u6548\u7684\u5B8C\u6574\u6027\u6458\u8981");
251
- integrity[name] = hash;
252
- }
253
- const skills = readSkillsField(item.skills);
254
- Object.assign(integrity, readSkillFiles(skills, source));
255
- return {
256
- ...skills ? { skills } : {},
257
- integrity: Object.freeze(integrity)
258
- };
259
- }
260
-
261
- // packages/plugins/src/package.ts
262
- var PLUGIN_SHARED_MODULES = [
263
- "@tau/plugins",
264
- "@tau/plugins/whiteboard",
265
- "@tau/plugins/sync",
266
- "@tau/ui",
267
- "react",
268
- "react-dom",
269
- "react-dom/client",
270
- "react/jsx-runtime",
271
- "react/jsx-dev-runtime"
272
- ];
273
- function validatePluginManifest(value) {
274
- if (!value || typeof value !== "object" || Array.isArray(value))
275
- throw new Error("\u63D2\u4EF6\u6E05\u5355\u5FC5\u987B\u662F\u5BF9\u8C61");
276
- const item = value;
277
- if (item.formatVersion !== 2 || item.apiVersion !== 1 || item.platform !== "desktop" || item.format !== "cjs")
278
- throw new Error("\u63D2\u4EF6\u5305\u683C\u5F0F\u3001API \u7248\u672C\u6216\u5E73\u53F0\u4E0D\u517C\u5BB9");
279
- const metadata = readPluginMetadata(item);
280
- const main = readPluginFilePath(item.main, ".js");
281
- const backend = item.backend === void 0 ? void 0 : validateBackendManifest(item.backend);
282
- if (!backend) throw new Error("\u684C\u9762\u5305\u683C\u5F0F 2 \u5FC5\u987B\u58F0\u660E\u540E\u53F0\uFF0C\u666E\u901A\u63D2\u4EF6\u4F7F\u7528\u683C\u5F0F 3");
283
- if (backend?.entry === main) throw new Error("\u540E\u53F0\u5165\u53E3\u4E0D\u80FD\u4E0E\u6E32\u67D3\u5165\u53E3\u76F8\u540C");
284
- if (backend && typeof item.minAppVersion !== "string")
285
- throw new Error("\u540E\u53F0\u63D2\u4EF6\u5FC5\u987B\u58F0\u660E\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
286
- if (item.minAppVersion !== void 0) {
287
- if (typeof item.minAppVersion !== "string") throw new Error("\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C\u65E0\u6548");
288
- comparePluginVersions(item.minAppVersion, item.minAppVersion);
289
- }
290
- const styles = item.styles === void 0 ? void 0 : readPluginFilePath(item.styles, ".css");
291
- const files = readPluginFiles(item, [
292
- main,
293
- ...styles ? [styles] : [],
294
- ...backend ? [backend.entry] : []
295
- ]);
296
- return Object.freeze({
297
- formatVersion: item.formatVersion,
298
- ...metadata,
299
- ...typeof item.minAppVersion === "string" ? { minAppVersion: item.minAppVersion } : {},
300
- apiVersion: 1,
301
- platform: "desktop",
302
- format: "cjs",
303
- main,
304
- ...backend ? { backend } : {},
305
- ...item.editor === true ? { editor: true } : {},
306
- ...item.whiteboard === true ? { whiteboard: true } : {},
307
- ...files,
308
- ...styles === void 0 ? {} : { styles }
309
- });
310
- }
311
- var isContentPlugin = (manifest) => manifest.editor === true || manifest.whiteboard === true;
312
-
313
- export {
314
- assertLocalId,
315
- comparePluginVersions,
316
- PLUGIN_SYSTEM_ACCESS,
317
- validateBackendManifest,
318
- PLUGIN_CATEGORIES,
319
- isPluginCategory,
320
- PLUGIN_AI_CAPABILITIES,
321
- isPluginAICapability,
322
- PLUGIN_PERMISSIONS,
323
- isPluginPermission,
324
- readPluginMetadata,
325
- readPluginFilePath,
326
- readPluginFiles,
327
- PLUGIN_SHARED_MODULES,
328
- validatePluginManifest,
329
- isContentPlugin
330
- };
@@ -1,185 +0,0 @@
1
- import {
2
- PLUGIN_AI_CAPABILITIES,
3
- comparePluginVersions,
4
- readPluginFilePath,
5
- readPluginFiles,
6
- readPluginMetadata
7
- } from "./chunk-6XAEU7BJ.js";
8
-
9
- // packages/plugins/src/package-targets.ts
10
- var PACKAGE_PLATFORMS = ["desktop", "android", "ios"];
11
- function readPackageTargets(value) {
12
- if (!value || typeof value !== "object" || Array.isArray(value))
13
- throw new Error("\u76EE\u6807\u5E73\u53F0\u5FC5\u987B\u662F\u5BF9\u8C61");
14
- const targets = {};
15
- for (const platform of PACKAGE_PLATFORMS) {
16
- if (!Object.hasOwn(value, platform)) continue;
17
- const target = value[platform];
18
- if (!target || typeof target !== "object" || Array.isArray(target) || typeof target.minAppVersion !== "string")
19
- throw new Error("\u5E73\u53F0\u7F3A\u5C11\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
20
- const minimum = target.minAppVersion;
21
- comparePluginVersions(minimum, minimum);
22
- targets[platform] = Object.freeze({ minAppVersion: minimum });
23
- }
24
- if (!Object.keys(targets).length) throw new Error("\u9700\u8981\u81F3\u5C11\u4E00\u4E2A\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0");
25
- return Object.freeze(targets);
26
- }
27
-
28
- // packages/plugins/src/portable.ts
29
- var MOBILE_DATA_MIN_VERSION = "0.2.13";
30
- var MOBILE_AI_MIN_VERSION = "0.2.13";
31
- var MOBILE_AI_PERMISSIONS = Object.freeze(
32
- Object.keys(PLUGIN_AI_CAPABILITIES).map(
33
- (capability) => `ai:${capability}`
34
- )
35
- );
36
- var MOBILE_DATA_PERMISSIONS = [
37
- "cards:read",
38
- "cards:write",
39
- "cards:delete",
40
- "articles:read",
41
- "articles:write",
42
- "articles:delete",
43
- "projects:read",
44
- "projects:write",
45
- "projects:delete",
46
- "documents:read",
47
- "documents:write",
48
- "documents:delete",
49
- "todos:read",
50
- "todos:write",
51
- "todos:delete",
52
- "calendar:read",
53
- "calendar:write",
54
- "calendar:delete",
55
- "flashcards:read",
56
- "flashcards:write"
57
- ];
58
- var MOBILE_SPEECH_MIN_VERSION = "0.2.16";
59
- var MOBILE_SPEECH_PERMISSIONS = ["speech:input"];
60
- function assertMobilePermissions(manifest) {
61
- if (!manifest.permissions?.length) return;
62
- for (const platform of ["android", "ios"]) {
63
- const target = manifest.targets[platform];
64
- if (!target) continue;
65
- if (manifest.permissions.some(
66
- (permission) => !MOBILE_DATA_PERMISSIONS.includes(permission) && !MOBILE_AI_PERMISSIONS.includes(permission) && !MOBILE_SPEECH_PERMISSIONS.includes(permission)
67
- ))
68
- throw new Error("\u79FB\u52A8\u7AEF\u5C1A\u672A\u5F00\u653E\u6B64\u4E1A\u52A1\u6743\u9650");
69
- if (manifest.permissions.some(
70
- (permission) => MOBILE_DATA_PERMISSIONS.includes(permission)
71
- ) && comparePluginVersions(target.minAppVersion, MOBILE_DATA_MIN_VERSION) < 0)
72
- throw new Error(`\u79FB\u52A8\u7AEF\u4E1A\u52A1\u6570\u636E\u6388\u6743\u8981\u6C42\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C ${MOBILE_DATA_MIN_VERSION}`);
73
- if (manifest.permissions.some(
74
- (permission) => MOBILE_AI_PERMISSIONS.includes(permission)
75
- ) && comparePluginVersions(target.minAppVersion, MOBILE_AI_MIN_VERSION) < 0)
76
- throw new Error(`\u79FB\u52A8\u7AEF AI \u6388\u6743\u8981\u6C42\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C ${MOBILE_AI_MIN_VERSION}`);
77
- if (manifest.permissions.some(
78
- (permission) => MOBILE_SPEECH_PERMISSIONS.includes(permission)
79
- ) && comparePluginVersions(target.minAppVersion, MOBILE_SPEECH_MIN_VERSION) < 0)
80
- throw new Error(`\u79FB\u52A8\u7AEF\u8BED\u97F3\u8F93\u5165\u6388\u6743\u8981\u6C42\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C ${MOBILE_SPEECH_MIN_VERSION}`);
81
- }
82
- }
83
- var PORTABLE_PLATFORMS = PACKAGE_PLATFORMS;
84
- var PORTABLE_SHARED_MODULES = [
85
- "@tau/plugins",
86
- "@tau/plugins/whiteboard",
87
- "@tau/ui",
88
- "react",
89
- "react-dom",
90
- "react-dom/client",
91
- "react/jsx-runtime",
92
- "react/jsx-dev-runtime"
93
- ];
94
- function buildPortablePluginManifest(value, output) {
95
- const item = record(value, "\u4F5C\u8005\u6E05\u5355");
96
- const files = record(output, "\u6784\u5EFA\u6587\u4EF6\u4FE1\u606F");
97
- return validatePortableDistributionManifest({
98
- id: item.id,
99
- name: item.name,
100
- version: item.version,
101
- description: item.description,
102
- categories: item.categories,
103
- keywords: item.keywords,
104
- permissions: item.permissions,
105
- formatVersion: 3,
106
- apiVersion: 1,
107
- platform: "portable",
108
- profile: "web-v1",
109
- format: "cjs",
110
- main: files.main,
111
- styles: files.styles,
112
- skills: files.skills,
113
- integrity: files.integrity,
114
- targets: item.targets
115
- });
116
- }
117
- function record(value, label) {
118
- if (!value || typeof value !== "object" || Array.isArray(value))
119
- throw new Error(`${label}\u5FC5\u987B\u662F\u5BF9\u8C61`);
120
- return value;
121
- }
122
- function validatePortableDistributionManifest(value) {
123
- const manifest = validatePortablePluginManifest(value);
124
- assertMobilePermissions(manifest);
125
- return manifest;
126
- }
127
- function validatePortablePluginManifest(value) {
128
- const item = record(value, "\u8DE8\u7AEF\u6E05\u5355");
129
- if (item.formatVersion !== 3 || item.platform !== "portable" || item.profile !== "web-v1")
130
- throw new Error("\u8DE8\u7AEF\u5305\u683C\u5F0F\u6216\u8FD0\u884C\u914D\u7F6E\u4E0D\u517C\u5BB9");
131
- if (item.apiVersion !== 1 || item.format !== "cjs") throw new Error("\u63D2\u4EF6 API \u6216\u5165\u53E3\u683C\u5F0F\u4E0D\u517C\u5BB9");
132
- const metadata = readPluginMetadata(item);
133
- const main = readPluginFilePath(item.main, ".js");
134
- const styles = item.styles === void 0 ? void 0 : readPluginFilePath(item.styles, ".css");
135
- const files = readPluginFiles(item, [main, ...styles ? [styles] : []]);
136
- const targets = readPackageTargets(item.targets);
137
- const declaredFiles = item.integrity;
138
- if (Object.keys(declaredFiles).some((file) => !Object.hasOwn(files.integrity, file)))
139
- throw new Error("\u8DE8\u7AEF\u5305\u5305\u542B\u672A\u58F0\u660E\u6587\u4EF6");
140
- for (const file of Object.keys(files.integrity)) {
141
- if (file === main || file === styles) continue;
142
- if (!file.endsWith(".md") || file.split("/").includes("scripts") || file.includes("\\"))
143
- throw new Error("\u8DE8\u7AEF Skill \u4EC5\u652F\u6301\u7EAF Markdown \u6587\u6863\uFF0C\u4E0D\u652F\u6301\u811A\u672C\u6216\u9644\u4EF6");
144
- }
145
- return Object.freeze({
146
- ...metadata,
147
- apiVersion: 1,
148
- format: "cjs",
149
- main,
150
- ...styles ? { styles } : {},
151
- ...files,
152
- formatVersion: 3,
153
- platform: "portable",
154
- profile: "web-v1",
155
- ...typeof item.description === "string" ? { description: item.description } : {},
156
- targets: Object.freeze(targets)
157
- });
158
- }
159
- function assertPortablePluginCompatibility(manifest, host) {
160
- if (!host.profiles.includes(manifest.profile)) throw new Error("\u5BBF\u4E3B\u672A\u63A5\u5165\u8DE8\u7AEF\u8FD0\u884C\u914D\u7F6E");
161
- const platform = host.environment.platform;
162
- if (!PORTABLE_PLATFORMS.some((value) => value === platform))
163
- throw new Error("\u5F53\u524D\u5E73\u53F0\u4E0D\u80FD\u6FC0\u6D3B\u8DE8\u7AEF\u5E94\u7528\u63D2\u4EF6");
164
- const target = manifest.targets[platform];
165
- if (!target) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
166
- if (platform === "android" || platform === "ios") assertMobilePermissions(manifest);
167
- if (comparePluginVersions(host.appVersion, target.minAppVersion) < 0)
168
- throw new Error("\u5BA2\u6237\u7AEF\u7248\u672C\u4F4E\u4E8E\u63D2\u4EF6\u8981\u6C42");
169
- return target;
170
- }
171
-
172
- export {
173
- MOBILE_DATA_MIN_VERSION,
174
- MOBILE_AI_MIN_VERSION,
175
- MOBILE_AI_PERMISSIONS,
176
- MOBILE_DATA_PERMISSIONS,
177
- MOBILE_SPEECH_MIN_VERSION,
178
- MOBILE_SPEECH_PERMISSIONS,
179
- PORTABLE_PLATFORMS,
180
- PORTABLE_SHARED_MODULES,
181
- buildPortablePluginManifest,
182
- validatePortableDistributionManifest,
183
- validatePortablePluginManifest,
184
- assertPortablePluginCompatibility
185
- };