@xiongtao.xt/tau-plugins 0.49.0 → 0.51.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 (33) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/client/{chunk-CQ3UMKDY.js → chunk-5GHRRBYH.js} +1 -0
  3. package/client/{chunk-MNFXOBPW.js → chunk-TCJBY6GL.js} +85 -16
  4. package/docs/ai.md +4 -4
  5. package/docs/editor.md +2 -0
  6. package/docs/flashcards.md +2 -0
  7. package/docs/mcp.md +4 -7
  8. package/docs/plugin-basics.md +1 -0
  9. package/docs/portability.md +34 -21
  10. package/docs/skills.md +14 -6
  11. package/docs/storage-and-network.md +1 -1
  12. package/docs/ui.md +46 -10
  13. package/docs/user-data.md +32 -7
  14. package/package.js +1 -1
  15. package/package.json +1 -1
  16. package/portable.js +14 -2
  17. package/publish-artifacts.js +2 -2
  18. package/types/packages/asr/src/refinement.d.ts +5 -0
  19. package/types/packages/plugins/src/contract.d.ts +3 -2
  20. package/types/packages/plugins/src/data.d.ts +2 -0
  21. package/types/packages/plugins/src/editor.d.ts +0 -14
  22. package/types/packages/plugins/src/home.d.ts +16 -0
  23. package/types/packages/plugins/src/index.d.ts +1 -0
  24. package/types/packages/plugins/src/package-targets.d.ts +11 -0
  25. package/types/packages/plugins/src/permissions.d.ts +1 -1
  26. package/types/packages/plugins/src/portable.d.ts +10 -4
  27. package/types/packages/plugins/src/speech.d.ts +23 -0
  28. package/types/packages/shared/src/chat-core/askQuestion.d.ts +71 -0
  29. package/types/packages/shared/src/chat-core/index.d.ts +1 -0
  30. package/types/packages/shared/src/chat-core/messages.d.ts +14 -3
  31. package/types/packages/shared/src/chat-core/thinkingLevels.d.ts +15 -0
  32. package/types/packages/ui/src/primitives/Toast.d.ts +18 -2
  33. package/types/packages/shared/src/components/ChatInputArea/types.d.ts +0 -126
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.51.0
4
+
5
+ - 新增 `context.speech` 语音输入:`unavailableReason()` 判断能否录音,`start({ signal, onPreview })` 返回 `{ result, stop, cancel }`,识别方式沿用应用的语音输入设置。需要在 manifest 声明新权限 `speech:input`,首次调用时询问用户;宿主未接入时 `start` 抛 `SPEECH_UNAVAILABLE`。新增宿主接口 `SpeechAdapter`。
6
+ - `PluginHomePanelProps` 新增可选 `registerDismiss(dismiss)`:面板里打开的浮层登记后,系统返回先关浮层(用法同 `pageContext.registerDismiss`)。
7
+ - 移动端开放 `home` 首页面板(「今天」页问答条下,`compact` 为两列小卡)与功能入口宫格;`speech:input` 在移动端要求最低客户端版本 0.2.16(`MOBILE_SPEECH_MIN_VERSION`)。
8
+
9
+ ## 0.50.0
10
+
11
+ - 首页面板新增可选 `action: { title, run }`:宿主画在面板标题行右侧(如「查看账本」),点击调用 `run`,出错只弹通知。`HomeAdapter` 收到的定义改为 `RegisteredHomePanelDefinition`,未声明时 `action` 为 `null`。
12
+
3
13
  ## 0.49.0
4
14
 
5
15
  - 新增 `context.embeddings` 嵌入提供方:`register({ id: context.pluginId, name, maxBatchSize?, create(config, modelId) })`,`create` 返回 `{ embed(texts, signal) }`(与输入等长、同序的向量数组);`maxBatchSize` 为单次 embed 可接受的最大文本条数,宿主据此分批。
@@ -180,6 +180,7 @@ var PLUGIN_PERMISSIONS = [
180
180
  "chats:read",
181
181
  "flashcards:read",
182
182
  "flashcards:write",
183
+ "speech:input",
183
184
  ...aiPermissions
184
185
  ];
185
186
  var permissionIds = new Set(PLUGIN_PERMISSIONS);
@@ -1,12 +1,86 @@
1
1
  import {
2
+ PLUGIN_AI_CAPABILITIES,
2
3
  comparePluginVersions,
3
4
  readPluginFilePath,
4
5
  readPluginFiles,
5
6
  readPluginMetadata
6
- } from "./chunk-CQ3UMKDY.js";
7
+ } from "./chunk-5GHRRBYH.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
+ }
7
27
 
8
28
  // packages/plugins/src/portable.ts
9
- var PORTABLE_PLATFORMS = ["desktop", "android", "ios"];
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;
10
84
  var PORTABLE_SHARED_MODULES = [
11
85
  "@tau/plugins",
12
86
  "@tau/plugins/whiteboard",
@@ -47,8 +121,7 @@ function record(value, label) {
47
121
  }
48
122
  function validatePortableDistributionManifest(value) {
49
123
  const manifest = validatePortablePluginManifest(value);
50
- if ((manifest.targets.android || manifest.targets.ios) && manifest.permissions?.length)
51
- throw new Error("\u79FB\u52A8\u7AEF\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743\uFF0C\u4E0D\u80FD\u53D1\u5E03\u58F0\u660E\u8FD9\u4E9B\u6743\u9650\u7684\u79FB\u52A8\u76EE\u6807");
124
+ assertMobilePermissions(manifest);
52
125
  return manifest;
53
126
  }
54
127
  function validatePortablePluginManifest(value) {
@@ -60,16 +133,7 @@ function validatePortablePluginManifest(value) {
60
133
  const main = readPluginFilePath(item.main, ".js");
61
134
  const styles = item.styles === void 0 ? void 0 : readPluginFilePath(item.styles, ".css");
62
135
  const files = readPluginFiles(item, [main, ...styles ? [styles] : []]);
63
- const rawTargets = record(item.targets, "\u76EE\u6807\u5E73\u53F0");
64
- const targets = {};
65
- for (const platform of PORTABLE_PLATFORMS) {
66
- if (!Object.hasOwn(rawTargets, platform)) continue;
67
- const target = record(rawTargets[platform], "\u5E73\u53F0\u914D\u7F6E");
68
- if (typeof target.minAppVersion !== "string") throw new Error("\u5E73\u53F0\u7F3A\u5C11\u6700\u4F4E\u5BA2\u6237\u7AEF\u7248\u672C");
69
- comparePluginVersions(target.minAppVersion, target.minAppVersion);
70
- targets[platform] = Object.freeze({ minAppVersion: target.minAppVersion });
71
- }
72
- if (!Object.keys(targets).length) throw new Error("\u9700\u8981\u81F3\u5C11\u4E00\u4E2A\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0");
136
+ const targets = readPackageTargets(item.targets);
73
137
  const declaredFiles = item.integrity;
74
138
  if (Object.keys(declaredFiles).some((file) => !Object.hasOwn(files.integrity, file)))
75
139
  throw new Error("\u8DE8\u7AEF\u5305\u5305\u542B\u672A\u58F0\u660E\u6587\u4EF6");
@@ -99,14 +163,19 @@ function assertPortablePluginCompatibility(manifest, host) {
99
163
  throw new Error("\u5F53\u524D\u5E73\u53F0\u4E0D\u80FD\u6FC0\u6D3B\u8DE8\u7AEF\u5E94\u7528\u63D2\u4EF6");
100
164
  const target = manifest.targets[platform];
101
165
  if (!target) throw new Error("\u63D2\u4EF6\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0");
102
- if ((platform === "android" || platform === "ios") && manifest.permissions?.length)
103
- throw new Error("\u79FB\u52A8\u5BBF\u4E3B\u5C1A\u672A\u63A5\u5165\u4E1A\u52A1\u6570\u636E\u6388\u6743");
166
+ if (platform === "android" || platform === "ios") assertMobilePermissions(manifest);
104
167
  if (comparePluginVersions(host.appVersion, target.minAppVersion) < 0)
105
168
  throw new Error("\u5BA2\u6237\u7AEF\u7248\u672C\u4F4E\u4E8E\u63D2\u4EF6\u8981\u6C42");
106
169
  return target;
107
170
  }
108
171
 
109
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,
110
179
  PORTABLE_PLATFORMS,
111
180
  PORTABLE_SHARED_MODULES,
112
181
  buildPortablePluginManifest,
package/docs/ai.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # AI
2
2
 
3
- 插件可以调用用户在 Tau 中配置好的大模型(仅桌面)。插件拿不到用户的 API Key 和服务地址:请求由 Tau 代为发出,用量记在插件名下,受用户设置的额度约束。
3
+ 插件可以调用用户在 Tau 中配置好的大模型。插件拿不到用户的 API Key 和服务地址:请求由 Tau 代为发出,用量记在插件名下,受用户设置的额度约束。移动端支持文本、图片和流式调用,具体边界见[多端适配](portability.md#各平台可用的接口)。
4
+
5
+ 移动端尚未提供自定义 AI 的配置界面及用量统计页面,由宿主管理接口配置和读取账本;未接入打开回调时,`openSettings()` 抛出 `AI_SETTINGS_UNAVAILABLE`。优先使用已有模型分配,不依赖手机上的配置入口完成首次设置。
4
6
 
5
7
  | 用法 | 适合 | 用户需要做什么 |
6
8
  | --------------------------------------------------- | ----------------------------------------------------- | -------------------------------- |
@@ -63,9 +65,7 @@ declare const __PLUGIN_META__: { id: string; name: string; version: string };
63
65
  export default definePlugin({
64
66
  ...__PLUGIN_META__,
65
67
  ai: {
66
- features: [
67
- { id: "summary", name: "文章摘要", description: "概括用户选择的文章" },
68
- ],
68
+ features: [{ id: "summary", name: "文章摘要", description: "概括用户选择的文章" }],
69
69
  },
70
70
  create: () => ({
71
71
  activate(context) {
package/docs/editor.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  在 Tau 的文档里加一种自己的块:图表、公式、乐谱、可交互的组件。块的数据随文档保存、同步和发布,桌面、手机和用户发布的博客使用同一份渲染代码。
4
4
 
5
+ 编辑器扩展在插件定义的 `editorExtensions` 中静态声明;命令、菜单、快捷键和节点交互也随静态扩展提供。SDK 不提供运行期动态注册编辑器扩展的接口。
6
+
5
7
  ## 第一个块:计数器
6
8
 
7
9
  ### 1. 定义节点和扩展
@@ -1,5 +1,7 @@
1
1
  # 闪卡
2
2
 
3
+ 移动端支持查询牌组、创建牌组和闪卡,以及 `openCreate({ mode: "manual" })`。手动流程可新建牌组、修改预填题干并保存一张闪卡,返回保存或取消结果;插件停用、切库后旧流程失效。`mode: "ai"`、`generate`、`generateAndSave` 仅桌面支持,移动插件不要声明 AI 制卡权限。
4
+
3
5
  插件可以帮用户创建闪卡(仅桌面)。按插件介入的多少,从轻到重有这些方式:
4
6
 
5
7
  | 方式 | 适合 | 需要的权限 |
package/docs/mcp.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # MCP 工具
2
2
 
3
- 通过 `context.mcp.register`,你可以给 Tau 的 AI 助手提供工具(仅桌面)。用户和 AI 对话时,AI 会按需调用这些工具,比如查询插件里的数据、在插件里执行操作。
3
+ 通过 `context.mcp.register`,你可以给 Tau 的 AI 助手提供工具。用户和 AI 对话时,AI 会按需调用这些工具,比如查询插件里的数据、在插件里执行操作。
4
4
 
5
- 注册的工具会出现在 Tau 的 MCP 页面和聊天的快捷面板里,用户可以整组或逐个开关工具。插件不需要自己做管理界面。
5
+ 桌面端注册的工具会出现在 Tau 的 MCP 页面和聊天的快捷面板里,用户可以整组或逐个开关工具。移动宿主支持内联工具与 HTTP MCP 注册、状态和工具渲染器声明,但尚无聊天和 MCP 管理界面,不支持本机进程;接口接入不代表已有用户入口。
6
6
 
7
7
  一个 MCP 有两种提供方式:
8
8
 
@@ -88,9 +88,7 @@ context.mcp.register({
88
88
  {
89
89
  "backend": {
90
90
  "systemAccess": ["process"],
91
- "tools": [
92
- { "id": "mcp", "command": "node", "args": ["/path/to/your-server.mjs"] }
93
- ]
91
+ "tools": [{ "id": "mcp", "command": "node", "args": ["/path/to/your-server.mjs"] }]
94
92
  }
95
93
  }
96
94
  ```
@@ -154,8 +152,7 @@ await context.chat.registerToolRenderer({
154
152
  mcpId: "books",
155
153
  toolName: "search_books",
156
154
  component: ({ execution, data, dataVersion, renderDefault }) => {
157
- if (execution.status !== "success" || dataVersion !== 1)
158
- return renderDefault();
155
+ if (execution.status !== "success" || dataVersion !== 1) return renderDefault();
159
156
  return <BookList books={(data as { books: Book[] }).books} />;
160
157
  },
161
158
  });
@@ -143,6 +143,7 @@ create: () => ({
143
143
  | `views` | 在卡片、文章、项目文档详情里放区块 | [界面](ui.md#详情区块) |
144
144
  | `settings` | 注册设置区域 | [界面](ui.md#设置) |
145
145
  | `notifications` | 发送通知 | [界面](ui.md#通知) |
146
+ | `speech` | 语音输入,拿到识别文字 | [界面](ui.md#语音输入) |
146
147
  | `storage` | 插件私有存储 | [存储与网络](storage-and-network.md) |
147
148
  | `fetch` | 网络请求 | [存储与网络](storage-and-network.md#网络请求) |
148
149
  | `websocket` | WebSocket 连接 | [存储与网络](storage-and-network.md#websocket) |
@@ -25,31 +25,44 @@
25
25
 
26
26
  ## 各平台可用的接口
27
27
 
28
- | 接口 | 桌面 | Android / iOS | 说明 |
29
- | -------------------------------------------------------------- | ---- | ------------- | ---------------------------------------------------------- |
30
- | `pages`、`navigation` | ✓ | ✓ | 桌面的功能入口在侧边栏,手机在「我的 › 插件功能」 |
31
- | `settings`、`storage`、`fetch`、`websocket` | ✓ | ✓ | |
32
- | `commands` | ✓ | 部分 | 手机上可以注册,但没有命令面板,主要功能要另外注册功能入口 |
33
- | `environment`、`register`、`signal`、`pluginId`、`workspaceId` | ✓ | ✓ | |
34
- | 编辑器块(`editorExtensions`、`editorCodecs`) | ✓ | ✓ | 见[编辑器块](#编辑器块) |
35
- | `sync`、`upload`、`tts`、`asr` 提供方 | ✓ | ✓ | 配置表单两端都由 Tau 渲染 |
36
- | `images`、`embeddings`、`video`、`publish` 提供方 | ✓ | | |
37
- | `sidebar`、`home`、`actions`、`views`、`notifications` | ✓ | | 跨平台的入口用 `navigation` |
38
- | `data`、`content`、`events`、`app`、`permissions` | ✓ | | 用户数据,见[用户数据](user-data.md) |
39
- | `entities`、`records`、`links`、`transaction` | ✓ | | 插件自己的内容也只在桌面可用 |
40
- | `ai`、`mcp`、`chat`、`flashcards` | ✓ | | |
41
- | `excerpts`、`materials`、`services` | ✓ | | |
42
- | 白板扩展(`whiteboardExtensions`) | ✓ | | |
43
- | 开发台编辑器扩展(`editor`) | ✓ | | |
44
- | `backend`(本机后台) | ✓ | | 需要单独的包格式,见[本机后台](backend.md) |
45
- | 随插件附带的 Skill | ✓ | | 手机上会保留,但不使用 |
46
-
47
- - 声明了 `android` 或 `ios` 的插件,`permissions` 必须为空。手机还不支持用户数据授权,构建和插件中心都会拒绝这样的包。
28
+ | 接口 | 桌面 | Android / iOS | 说明 |
29
+ | -------------------------------------------------------------- | ---- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30
+ | `pages`、`navigation` | ✓ | ✓ | 桌面的功能入口在侧边栏,手机在「我的」顶部功能宫格 |
31
+ | `settings`、`storage`、`fetch`、`websocket` | ✓ | ✓ | |
32
+ | `commands` | ✓ | 部分 | 手机上可以注册,但没有命令面板,主要功能要另外注册功能入口 |
33
+ | `environment`、`register`、`signal`、`pluginId`、`workspaceId` | ✓ | ✓ | |
34
+ | 编辑器块(`editorExtensions`、`editorCodecs`) | ✓ | ✓ | 见[编辑器块](#编辑器块) |
35
+ | `sync`、`upload`、`tts`、`asr` 提供方 | ✓ | ✓ | 配置表单两端都由 Tau 渲染 |
36
+ | `images`、`embeddings`、`video`、`publish` 提供方 | ✓ | | |
37
+ | `home` | ✓ | ✓ | 手机 0.2.16 起显示在「今天」页问答条下;`compact` 为两列小卡,`wide` 占整行 |
38
+ | `speech` | | ✓ | 手机 0.2.16 起支持,需要 `speech:input` 权限;识别方式沿用应用的语音输入设置。桌面暂不支持,`start` 抛 `SPEECH_UNAVAILABLE` |
39
+ | `sidebar`、`views`、`notifications` | ✓ | | 跨平台的入口用 `navigation` |
40
+ | `actions` | ✓ | 部分 | 移动支持卡片、文章和项目文档详情页的「更多」菜单;引用文档使用来源卡片或文章 |
41
+ | `permissions`、`data`、`content`、`events` | ✓ | 部分 | 移动 0.2.13 起支持卡片、文章、项目、项目文档、待办、日程及正文与变化事件,其他业务域尚未开放 |
42
+ | `app` | ✓ | 部分 | 支持卡片、文章、项目、项目文档、日记片段、待办、日程及插件实体的 pick/describe/open;正文可定位;run 支持新建卡片、插入项目文档、打开内容协作,独立窗口未开放 |
43
+ | `ContentEditor`、`ContentPreview`、`EntityRef` | ✓ | 部分 | 移动支持插件作用域内的 full/compact、权限与协作,引用类型以 app 支持范围为准 |
44
+ | `entities`、`records`、`links`、`transaction` | ✓ | 部分 | 移动 0.2.13 支持自有实体与正文、记录、有序关联、原子事务、检索及 @;关联目标限移动已开放类型 |
45
+ | `flashcards` | ✓ | 部分 | 查询牌组、创建牌组和闪卡、手动 openCreate;AI 生成未开放 |
46
+ | `ai` | ✓ | 部分 | 支持沿用宿主模型、自定义功能、文本/图片及流式请求;移动端未提供 AI 配置界面 |
47
+ | `mcp`、`chat` | ✓ | 部分 | 支持内联工具、HTTP MCP 与工具渲染器声明;移动端没有聊天及 MCP 管理界面,不支持 stdio |
48
+ | `excerpts`、`materials`、`services` | ✓ | | |
49
+ | 白板扩展(`whiteboardExtensions`) | ✓ | | |
50
+ | `backend`(本机后台) | ✓ | | 需要单独的包格式,见[本机后台](backend.md) |
51
+ | 随插件附带的 Skill | ✓ | 部分 | 活跃插件的 Markdown 正文与参考资料;移动端不执行脚本 |
52
+ | 独立 Skill 包 | ✓ | ✓ | 无代码入口,按 targets 安装;移动端保留脚本文件但不执行,说明与 Markdown 资料按需读取 |
53
+
54
+ - 移动业务数据与 AI 能力要求对应 `targets` 的最低版本不低于 `0.2.13`;`speech:input` 要求不低于 `0.2.16`。业务数据允许 `cards:read/write/delete`、`articles:read/write/delete`、`projects:read/write/delete`、`documents:read/write/delete`、`todos:read/write/delete`、`calendar:read/write/delete` 和 `flashcards:read/write` 共二十项权限;AI 允许 [AI 文档](ai.md)列出的 `ai:<能力名>`。斜杠表示各自独立的权限。其他权限仍在构建、中心和运行前拒绝。安装不等于授权,第一次访问由用户决定。
55
+ - AI、MCP 与包内 Skill 的移动宿主接口需要包含此接线的客户端构建;接口接入不代表已发布,也不替代真机适配。移动端尚无聊天、MCP 管理或自定义 AI 配置界面,不要让插件依赖这些入口完成首次配置。
56
+ - 项目目录支持多处挂载、创建与移动文档;只能删除空项目和无子项的非视频文档,七天内可恢复到仍有效的原位置。引用项的正文仍归原卡片或文章。
57
+ - 移动待办支持普通/截止任务与周期实例,正文勾选项仍保存在原文;系统日程标记只读。周期实例写入在移动 0.2.13 已接入,其他未接线宿主会明确拒绝,不会改动整系列。
58
+ - 移动正文支持读取 Markdown/节点及追加、前插、替换;修改检查版本,协作正文经服务端条件提交。移动 `shareOf` 可让新卡片、文章或项目文档共用本插件活跃实体的正文,不能用于实体创建或正文替换;协作附件仍受移动协作宿主的限制。
59
+ - 移动 `app.pick/describe/open` 支持卡片、文章、项目、普通正文项目文档、日记片段、待办、实体日程及插件实体;只能在 page 打开,虚拟日程改用其 todoId 打开待办。日记引用具体片段,用户选择后可描述其标题,打开直达原片段正文,不创建新记录;不开放日记正文读取权限。周期实例打开所属系列,正文待办定位原文勾选项。插件实体按拥有者注册的 open 页面打开,停用时保留展示但不能打开;选择只授权引用标题,不授予正文读取。公共正文组件需要插件页面/设置作用域,预览默认 3 块、最多 100 块;使用这些能力时最低移动版本至少 0.2.13。
60
+ - 移动自有数据按工作区、插件与激活租约隔离,不额外申请业务权限。记录删除不进恢复列表,实体删除可在七天内恢复。关联支持已开放原生引用及插件实体(自有或已选择),事务最多 500 项。registerKind 的类型名与图标随库保存,open 接入搜索、引用及脉络入口;@ 只列当前活跃且 mentionable 的类型。全文检索展示现存实体,停用后不执行旧打开回调。移动卸载保留实体/记录,不根据本机缺少插件自动清理同步数据。
48
61
  - 类型里能导入,不代表这个平台能用。以上表为准,不确定时在真机上试。
49
62
 
50
63
  ## 页面与入口
51
64
 
52
- 页面和入口分开注册。同一份代码在桌面上出现在侧边栏,在手机上出现在「我的 › 插件功能」:
65
+ 页面和入口分开注册。同一份代码在桌面上出现在侧边栏,在手机上出现在「我的」顶部的功能宫格:
53
66
 
54
67
  ```tsx
55
68
  const page = context.pages.register({
package/docs/skills.md CHANGED
@@ -58,6 +58,8 @@ description: 用户要在文档里插入或修改图表块时加载,说明图
58
58
 
59
59
  ### 附带文件与脚本
60
60
 
61
+ 脚本执行只在桌面开放。移动端允许安装和保留包内脚本文件,读取技能说明与 Markdown 参考资料,但不会运行 Node、Python 或 Shell。
62
+
61
63
  - **参考资料**:AI 加载 Skill 后,可以按需读取目录里的其他文件。在 SKILL.md 里写清楚什么情况下该读哪个文件,比把所有内容塞进 SKILL.md 更省上下文。
62
64
  - **脚本**:AI 可以执行目录里的脚本,工作目录就是这个 Skill 目录。按扩展名选择解释器:`.py` 用 python3,`.js`、`.mjs`、`.cjs` 用 Node.js,`.sh` 用 bash,`.ts` 用 tsx;其他文件需要有可执行权限。
63
65
  - 每次执行脚本前,Tau 都会请用户确认。单次执行最长 120 秒,输出最多保留 64 KiB。
@@ -82,7 +84,7 @@ my-plugin/
82
84
  - 插件启用后,Skill 出现在 Tau 的 Skill 页,标注「插件 · 插件名」;插件停用后自动消失。
83
85
  - 用户可以在 Skill 页调整它的调用方式(自动、仅手动、停用),或者复制一份到自己的 Skill 目录修改。
84
86
  - AI 引用它时使用 `插件ID:目录名`,例如 `yourname.chart:chart-authoring`。
85
- - 普通插件(manifest 里写了 `targets`)附带的 Skill 只能是 Markdown 文档,不能带脚本。需要脚本时,做成下文的独立 Skill 包。Skill 只在桌面的 AI 助手里使用。
87
+ - 应用插件附带的 Skill 只能是 Markdown 文档,不能带脚本。需要保留脚本时,做成下文的独立 Skill 包。移动 AI 宿主可读取活跃插件的 Skill 正文与 Markdown 参考资料,停用后撤销;独立包使用自己的安装与启用资格,不依赖应用插件激活。
86
88
  - 你的插件提供了 [MCP 工具](mcp.md)时,可以在 SKILL.md 里说明什么时候调用哪个工具、参数怎么填。
87
89
 
88
90
  ## 独立的 Skill 包
@@ -98,13 +100,19 @@ my-plugin/
98
100
  "categories": ["skill"],
99
101
  "keywords": ["写作", "风格"],
100
102
  "version": "1.0.0",
101
- "minAppVersion": "0.59.0",
102
103
  "apiVersion": 1,
103
- "platform": "desktop"
104
+ "platform": "portable",
105
+ "targets": {
106
+ "desktop": { "minAppVersion": "0.60.4" },
107
+ "android": { "minAppVersion": "0.2.13" },
108
+ "ios": { "minAppVersion": "0.2.13" }
109
+ }
104
110
  }
105
111
  ```
106
112
 
107
- 和代码插件相比,Skill 包**没有** `main`、`format`,也不能声明 `permissions`、`backend`、`editor`、`whiteboard`。构建脚本看到 manifest 里没有 `main`,就会跳过代码打包,只打包 `skills/` 目录。
113
+ Skill 包使用 `formatVersion: 1` 的文档目录协议,**没有** `main`、`format`、`profile`,也不声明 `permissions`、`backend`、`editor`、`whiteboard`。构建器识别独立包后只打包 `skills/`,不编译或执行代码入口。
114
+
115
+ `formatVersion` 表示清单与文件布局的解析方式;`version` 是这个 Skill 包自己的更新版本;`platform/targets` 决定支持哪些客户端。独立 Skill 的文件布局没有变化,因此支持移动端不需要把格式号改为 3。旧的 `platform: "desktop"` 加 `minAppVersion` 声明继续只用于桌面;要分发到手机,使用上面的跨端声明。最低客户端版本需填实际验证过、且包含此能力的版本。
108
116
 
109
117
  ```text
110
118
  writing-style/
@@ -115,8 +123,8 @@ writing-style/
115
123
  SKILL.md
116
124
  ```
117
125
 
118
- - `pnpm build` 构建后,运行 `pnpm install:local` 安装到本机的 Tau,再在插件页点「重新扫描」,Skill 就会出现在 Skill 页,标注「Skill 包 · 包名」。
119
- - Skill 包不参与插件启停,用户在 Skill 页逐个调整调用方式或停用。
126
+ - `pnpm build` 生成同一份跨端 ZIP,通过插件中心按 `targets` 分发。`install:local` 只用于既有桌面专用包,不向正式客户端手写跨端安装目录。
127
+ - 独立包不进入应用插件的代码激活链。桌面沿用 Skill 页的调用方式管理;移动端沿用已有包管理的启停、更新和卸载,来源随包资格回收,安全模式不自动启用。
120
128
  - 发布流程与代码插件完全相同,见[发布与更新](release.md)。分类建议填 `skill`。
121
129
  - README 照样是给用户看的:这套 Skill 能让 AI 做什么,用户怎么点名使用。
122
130
 
@@ -88,6 +88,6 @@ socket.addEventListener("close", (event) => finish(event.code, event.reason));
88
88
  - 连接由 Tau 代为建立,不携带浏览器 Cookie,不自动重连,不跟随重定向。不要用 `instanceof WebSocket` 判断它。
89
89
  - `send` 和 `close` 都是同步的,发送顺序和排队由 Tau 处理,不需要自己做流量控制。`bufferedAmount` 只表示还没发出去的字节,不代表服务器已经收到。
90
90
  - 插件停用或切换工作区时,所有连接自动关闭。这时未发完的数据会被丢弃,不保证送达;正常结束时,先按服务的协议发送结束消息、等到最终结果,再调用 `close()`。
91
- - 连接失败、断线或超出限制时,先触发 `error`,再触发一次 `close`(关闭码 1006)。错误信息里不会包含你的请求头。
91
+ - 连接失败、断线或超出限制时,先触发 `error`,再触发一次 `close`(关闭码 1006)。宿主桥的 `error` 事件携带 `message`,可包含握手 HTTP 状态码、TLS 失败、网络连接失败或超时;没有诊断时返回通用连接失败。只传递固定错误类别,不包含原始错误、请求头或响应正文。
92
92
 
93
93
  限制:单条消息最多 1 MiB;发送和接收各自最多排队 2 MiB、256 条;每个窗口最多同时 32 条连接;握手和关闭各最多等 10 秒。超出时连接失败,不会悄悄丢消息。
package/docs/ui.md CHANGED
@@ -10,7 +10,7 @@
10
10
  | [命令](#命令) | 桌面的 Ctrl+K 命令面板 | 桌面 |
11
11
  | [侧边栏](#侧边栏) | 侧边栏的分组、角标和子项 | 桌面 |
12
12
  | [首页面板](#首页面板) | 「今日」首页 | 桌面 |
13
- | [对象动作](#对象动作) | 卡片、文章等对象的「⋯」菜单 | 桌面 |
13
+ | [对象动作](#对象动作) | 卡片、文章等对象的「⋯」菜单 | 桌面、移动部分支持 |
14
14
  | [详情区块](#详情区块) | 卡片、文章、项目文档详情的正文上方 | 桌面 |
15
15
  | [通知](#通知) | 窗口内或独立的通知窗口 | 桌面 |
16
16
 
@@ -148,7 +148,7 @@ function BookPage({ pageContext }: PluginPageProps) {
148
148
 
149
149
  ## 功能入口
150
150
 
151
- 功能入口让用户找到你的页面。桌面上它出现在侧边栏,手机上出现在「我的 › 插件功能」;同一份代码,位置由 Tau 决定。
151
+ 功能入口让用户找到你的页面。桌面上它出现在侧边栏,手机上出现在「我的」顶部的功能宫格,和任务、文章等内置功能放在一起;同一份代码,位置由 Tau 决定。
152
152
 
153
153
  ```ts
154
154
  const page = context.pages.register({
@@ -172,7 +172,7 @@ context.navigation.registerEntry({
172
172
  | `params` | 可选。点击时传给页面的参数 |
173
173
  | `icon` | 可选。图标组件,见[图标](#图标);省略时使用默认图标 |
174
174
 
175
- 页面被撤销时,指向它的入口也会一起撤销。桌面上的功能入口放在侧边栏的「插件」分组;需要放进其他分组、显示角标或子项时,改用下一节的侧边栏接口(仅桌面)。
175
+ 页面被撤销时,指向它的入口也会一起撤销。桌面上的功能入口放在侧边栏的「插件」分组;需要放进其他分组、显示角标或子项时,改用下一节的侧边栏接口(仅桌面)。手机宫格里插件入口排在内置功能之后,按启用顺序排列,超过两行时收进「更多」;`icon` 在宫格里显示为图标,省略时显示插件名首字。
176
176
 
177
177
  ## 设置
178
178
 
@@ -419,23 +419,32 @@ context.home.registerPanel({
419
419
  title: "本周阅读",
420
420
  component: WeekPanel,
421
421
  size: "compact",
422
+ // page 为 context.pages.register 返回的页面句柄
423
+ action: { title: "查看书架", run: () => page.open() },
422
424
  });
423
425
  ```
424
426
 
425
- | 字段 | 说明 |
426
- | ----------- | ---------------------------------------------------------------------- |
427
- | `id` | 局部 ID |
428
- | `title` | 面板标题,由 Tau 显示在面板顶部 |
429
- | `component` | 面板正文,收到 `context`;返回 `null` 时整块不显示 |
430
- | `size` | 可选。`wide`(默认)占整行;`compact` 宽度足够时与其他紧凑面板并排显示 |
427
+ | 字段 | 说明 |
428
+ | ----------- | ---------------------------------------------------------------------------- |
429
+ | `id` | 局部 ID |
430
+ | `title` | 面板标题,由 Tau 显示在面板顶部 |
431
+ | `component` | 面板正文,收到 `context` 与可选的 `registerDismiss`;返回 `null` 时整块不显示 |
432
+ | `size` | 可选。`wide`(默认)占整行;`compact` 宽度足够时与其他紧凑面板并排显示 |
433
+ | `action` | 可选。`{ title, run }`,Tau 画在标题行右侧(如「查看书架」),点击调用 `run` |
431
434
 
432
- - Tau 画面板的外框和标题,组件只负责正文,不要再套一层卡片。
435
+ - Tau 画面板的外框、标题和标题行右侧的入口,组件只负责正文,不要再套一层卡片,也不要在正文里另放「查看全部」这类入口。
433
436
  - 新面板排在首页末尾。用户点首页右上角的「调整首页」后可以拖动面板调整位置或隐藏,布局随笔记库保存;插件停用后面板消失,重新启用后回到原来的位置。
434
437
  - 正文渲染出错时,这块面板显示错误和「重试」,不影响首页其他内容。
435
438
  - 首页只在主窗口显示,打开首页时组件才会渲染;需要随时更新的数据在组件里订阅(如 `context.events`),卸载时取消。
436
439
 
440
+ 手机上面板显示在「今天」页的问答条下面、日程上面,打开 App 第一屏就能看到。`compact` 面板两个一行排成小卡(约 160 × 130),`wide` 占整行;标题和 `action` 同样由 Tau 画在卡片顶部。小卡里放一个大数字加一两个按钮最合适,不要放输入框,记录类操作用按钮跳到插件页面。手机上没有「调整首页」,面板按插件启用顺序排列。
441
+
442
+ 需要按平台显示不同的正文时,在组件里读 `usePluginEnvironment()`,见[多端适配](portability.md#读取运行环境)。面板里自己画的底部面板这类浮层,用 props 里的 `registerDismiss(close)` 登记,系统返回会先关浮层;它与页面的 `pageContext.registerDismiss` 用法相同,宿主不支持时为 `undefined`。
443
+
437
444
  ## 对象动作
438
445
 
446
+ 移动端支持卡片、文章和项目文档详情页的「更多」菜单;引用卡片或文章的项目文档使用来源对象。下表中的其他菜单位置与 material、chat-message、text 目标仅桌面支持。移动端执行失败通过 Toast 提示。
447
+
439
448
  在卡片、文章、项目文档、材料(划线、PDF 标注、剪藏)、对话消息与命令面板里加一项操作,用户点击时插件收到这个对象:
440
449
 
441
450
  ```ts
@@ -514,6 +523,33 @@ context.views.registerEntityPanel({
514
523
  - 用户在详情页之间切换时,组件不会重新挂载,只换 `target`;按 `target` 取数据的 effect 要把它放进依赖。
515
524
  - 渲染出错时这一块显示错误和「重试」,不影响详情页其他内容。只在主窗口出现,独立编辑窗口不显示。
516
525
 
526
+ ## 语音输入
527
+
528
+ 插件可以让用户按住说话,拿到识别后的文字。识别方式沿用用户在 Tau「语音 › 语音输入」里的设置(系统识别或识别插件),插件不接触音频。在 manifest 的 `permissions` 里声明 `speech:input`,第一次调用 `start` 时 Tau 询问用户。
529
+
530
+ ```tsx
531
+ const reason = context.speech.unavailableReason();
532
+ if (reason) return toast.info(reason);
533
+ const session = await context.speech.start({
534
+ signal,
535
+ onPreview: text => setPreview(text),
536
+ });
537
+ // 用户松手时
538
+ await session.stop();
539
+ const text = await session.result;
540
+ ```
541
+
542
+ | 接口 | 说明 |
543
+ | --------------------------- | ---------------------------------------------------------------------------------------- |
544
+ | `unavailableReason()` | 当前不能录音的原因(如识别插件账号尚未配置),可以录音时为 `null`;不会询问授权 |
545
+ | `start({ signal, onPreview })` | 开始录音。`onPreview` 收到识别中的整段文字;同一时间只能有一次录音 |
546
+ | `session.stop()` | 停止录音,`result` 随后给出最终文字 |
547
+ | `session.cancel()` | 放弃这次录音,`result` 以 `AbortError` 失败 |
548
+
549
+ - 录音只在 `start` 与 `stop` / `cancel` 之间进行,最长 120 秒,到时自动停止。插件停用时录音随之中止。
550
+ - 「按住说话、上滑取消」这类手势由插件自己实现;`unavailableReason` 可以在按下前判断,给出提示。
551
+ - 目前只有手机支持(0.2.16 起)。桌面上 `start` 抛出以 `SPEECH_UNAVAILABLE` 开头的错误,`unavailableReason` 返回不可用原因。
552
+
517
553
  ## 通知
518
554
 
519
555
  ```ts
package/docs/user-data.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 用户数据
2
2
 
3
- 插件可以读取和修改用户在 Tau 中的内容:卡片、文章、项目文档、待办和日程,也可以创建属于插件自己的内容。这些接口目前只在桌面可用,用到它们的插件在 manifest 里只声明 `desktop`;手机上的插件保存数据用[私有存储](storage-and-network.md#私有存储)。
3
+ 插件可以读取和修改用户在 Tau 中的内容,也可以创建属于插件自己的内容。移动端支持卡片、文章、项目、项目文档、待办、日程及其正文的授权、读写与变化事件,以及插件自有实体、记录、关联和事务。移动 app.run 支持新建卡片、插入项目文档和打开内容协作;闪卡基础接口见[闪卡](flashcards.md)。平台支持范围、可声明权限与最低版本统一见[多端适配](portability.md#各平台可用的接口)。插件简单私有数据仍可用[私有存储](storage-and-network.md#私有存储)。
4
4
 
5
5
  只需要让用户挑一项内容来用时,不必申请权限,直接用[选择并打开已有内容](#选择并打开已有内容)。
6
6
 
@@ -169,6 +169,7 @@ await context.data.documents.move(
169
169
  ```
170
170
 
171
171
  - 同一篇文档可以挂在多处(多个父文档或多个项目下),这时它在目录里出现多次,`documentId` 相同。`move` 用 `from` 指明移动的是哪一处,`from`、`to` 为父文档 ID,`null` 表示根目录。
172
+ - 父文档本身跨项目共用时,其子目录也是共用的,修改该父子边会反映在所有挂载处;其他独立父子边仍保留。
172
173
  - `move` 只在同一项目内移动;不能移到自己或自己的子文档下。`index` 是移动后的序号,从 0 开始,省略时放在末尾。返回文档的新 `revision`。
173
174
  - 引用卡片或文章的条目带 `ref`,它的正文归被引用的卡片或文章,`documents.get` 读不到这一项,但可以移动。
174
175
  - 读目录需要 `projects:read`,新建与移动需要 `documents:write`。
@@ -213,6 +214,7 @@ const events = await context.data.calendar.query({
213
214
 
214
215
  | 参数 | 说明 |
215
216
  | ----------------- | ----------------------------------------------------------------- |
217
+ | `view` | `tasks`(默认)返回任务/系列;`occurrences` 返回周期实例,必须同时提供 `start` 和 `end` |
216
218
  | `source` | `all`(默认)、`todo`(独立的待办)、`document`(正文里的勾选项) |
217
219
  | `completed` | 按完成状态筛选 |
218
220
  | `keyword` | 按关键词筛选 |
@@ -221,6 +223,10 @@ const events = await context.data.calendar.query({
221
223
 
222
224
  来自正文勾选项的待办带有 `source`,指明它在哪篇卡片、文章、项目文档或日记里。
223
225
 
226
+ 周期实例的 `id` 保留原始日期身份,改期后也不变。移动 0.2.13 支持对实例完成、改期和删除(跳过本次);`dueAt: null` 取消实例改期。实例标题跟随系列;改系列标题使用系列视图返回的 ID。不要解析或自行构造实例 ID。未接实例写入的宿主会报错,不会截断日期改动整系列;依赖实例写入的插件目前应只声明已验证的移动目标。
227
+
228
+ 正文待办的修改回到原勾选项,不创建重复的独立待办;已排除或已提升的正文项不再收集。周期创建/修改规则未在此 SDK 开放。删除后的正文发生其他修改时,移动恢复会报告冲突并保留材料,不覆盖后续输入。共享操作遇到网络或关联恢复冲突时,先显示待确认状态,不能把请求超时当成删除或恢复成功。
229
+
224
230
  `calendar.query` 的 `start`、`end` 必填,可以是 `YYYY-MM-DD` 或带时区的 ISO 时间,每页最多 100 条。
225
231
 
226
232
  ## 修改与删除
@@ -259,6 +265,8 @@ try {
259
265
  | `calendar.create` / `calendar.update` | `title`、`start`、`end`、`allDay`、`calendarId`(省略时为默认日历) |
260
266
  | `*.delete(id, ...)` | 删除卡片、文章、白板、项目、项目文档、待办、日程,限制见下 |
261
267
 
268
+ 系统待办标记只能通过待办接口变更。关联日程的标题跟随原任务;普通日程接口不能单独改其标题,也不能把系统日程移动到用户日历。
269
+
262
270
  全天日程的 `start`、`end` 用 `YYYY-MM-DD`,且 `end` 不包含当天:一个只占 10 月 21 日的全天日程,`end` 是 `2026-10-22`。定时日程用带时区的 ISO 时间。
263
271
 
264
272
  ### 用 revision 避免覆盖别人的修改
@@ -384,6 +392,12 @@ context.events.on(["card.created", "card.updated", "card.deleted"], (event) => {
384
392
 
385
393
  ## 选择并打开已有内容
386
394
 
395
+ 移动 0.2.13 支持 `card/article/project/document/todo/event/plugin-entity` 七类引用,document 仅包含普通正文文档,event 仅包含实体日程;其他类型明确报不支持。移动选择窗口支持搜索、分页与多选,确认前取消返回空数组;确认提交期间等待结果,停用或切库终结旧请求但不撤销已经保存的选择授权。用户可停用插件后在插件管理中「清除此工作区数据」,同时清除其私有存储与已选择引用的标题访问授权。
396
+
397
+ 移动周期实例会打开所属系列详情,不能把详情页的普通操作当作对原实例的操作;正文待办打开原文并定位勾选项,折叠内容需要手动展开。日程查询的虚拟任务标记用返回的 todoId 调用 `app.open({kind: "todo", id: todoId})`,不直接打开虚拟 event ID。
398
+
399
+ 移动也支持下方 EntityRef 组件,但仅限上述七类引用;完整类型表中的其他类型仍以多端适配表为准。插件实体的声明外观经授权复验后显示,拥有者未启用时不能打开。
400
+
387
401
  插件的页面(如画布、看板)需要引用用户已有的卡片、日记、待办时,用 Tau 的搜索窗口让用户亲手挑选,显示时交给 `EntityRef`,点击时交给 Tau 打开。**这不需要任何权限**:用户亲手选择,就等于同意插件引用这些内容,之后也能随时读到它们的最新标题。
388
402
 
389
403
  ```tsx
@@ -409,7 +423,7 @@ function LinkChip({ link }: { link: { ref: PluginEntityRef } }) {
409
423
  | `card` | 卡片 | 卡片详情 |
410
424
  | `article` | 文章 | 文章详情 |
411
425
  | `document` | 项目文档 | 所在项目,并选中该文档 |
412
- | `diary` | 日记里的一条记录 | 当天的日记,并定位到这一条 |
426
+ | `diary` | 日记里的一条片段 | 桌面打开当天日记并定位该片段;移动直接打开该片段正文 |
413
427
  | `whiteboard` | 白板 | 白板 |
414
428
  | `todo` | 待办 | 待办详情;正文里的勾选项会打开所在文档并定位 |
415
429
  | `event` | 日程 | 日程详情 |
@@ -422,11 +436,14 @@ function LinkChip({ link }: { link: { ref: PluginEntityRef } }) {
422
436
  - `pick` 的 `kinds` 决定可选的类型,顺序就是弹窗里的分组顺序;`title` 可以自定义弹窗标题。
423
437
  - `pick` 和 `open` 都只能在用户操作(点击、按键)之后调用。在定时器或事件回调里调用会抛错。
424
438
  - 插件拿到的只有引用和选择时的标题,以及之后用 `describe` 读到的最新标题。要读取正文,仍然需要对应的读取权限。
439
+ - 日记的引用 ID 是片段 ID,同一天的多条日记可以分别选择。移动端可按摘要或日期检索;日记标题只对用户选过的具体片段开放,不授予日记正文读取能力。删除或编号复用后,旧选择授权不能读取新片段的标题,需要用户重新选择。
425
440
  - `ref` 是普通对象,可以存进插件自己的数据;它的 `id` 与 `context.data` 中同类内容的 `id` 一致。
426
441
  - 目标被删除后,`open` 会抛出「内容不存在」,可以据此提示用户移除这条关联。
427
442
 
428
443
  ### 打开位置与定位
429
444
 
445
+ 移动仅支持默认 `placement: "page"`;卡片、文章、普通项目文档和日记片段支持 `at.block`,等待正文与 DOM 就绪后滚动并短暂高亮对应顶层块,越界回到首块,不改变选区或唤起键盘。再次调用同一位置会重新定位。插件实体的 `at.block` 传给注册页面,页面接收的 `at` 可传给 ContentEditor,支持 JSON 中的 block/taskId;组件收到非法或越界位置时回到文首。其他类型的块序号定位及 `window/dock` 明确拒绝。
446
+
430
447
  `open` 的第二个参数可以指定打开在哪里、滚动到正文哪一处:
431
448
 
432
449
  ```ts
@@ -498,7 +515,11 @@ function CardRow({ card }: { card: PluginCard }) {
498
515
 
499
516
  ## Tau 的界面动作
500
517
 
501
- 导出、全屏演示、协作共享、新建卡片这类自带界面的功能,用 `context.app.run` 交给 Tau 完成,界面与 Tau 中的相同:
518
+ 导出、全屏演示、协作共享、新建卡片这类自带界面的功能,用 `context.app.run` 交给 Tau 完成。
519
+
520
+ 移动端支持 `card.create`、`project.insertDocument`、`content.share`。新建卡片允许用户修改预填正文和标签;插入项目文档由用户选择项目及父级位置,支持 `shareOf` 共用本插件内容;新建类操作确认保存后返回引用,取消返回 null。协作在用户确认后发布,已有协作打开成员管理。其他动作仍仅桌面支持。插件停用或切库后,未完成面板失效,已经提交的保存或远端请求不会回滚。
521
+
522
+ 例如,桌面端的导出操作:
502
523
 
503
524
  ```tsx
504
525
  <button
@@ -541,6 +562,8 @@ if (ref) await context.links.add(question.id, ref); // 用户取消时为 null
541
562
 
542
563
  ## 插件内容
543
564
 
565
+ 移动 0.2.13 支持下述实体数据接口、正文 API、七天恢复,以及原生搜索、注册的 open 页面和 @ 入口。搜索按标题及正文检索并显示持久类型外观;@ 候选只包含当前活跃且 mentionable 的类型,停用后仍保留原引用,但不执行打开回调。公共 ContentEditor/ContentPreview/EntityRef 在插件页面或设置中使用,挂载不会自动申请权限,授权由用户点击;撤权、隐藏、切库或停用后拒绝迟到写入。ContentEditor 与预览均支持 full/compact;预览默认 3 块、上限 100,协作附件沿用移动宿主限制。
566
+
544
567
  插件可以创建属于自己的内容,例如每周一篇周记、看板上的卡片。每一项都带一份正文,和卡片正文一样实时保存、随云同步。**读写自己的内容不需要任何权限。**
545
568
 
546
569
  ### 一个周记的例子
@@ -621,7 +644,7 @@ function NotePanel({ note, at }: { note: PluginOwnEntity; at?: string }) {
621
644
  - 正文用 `ContentEditor` 编辑,或用 `context.content` 读写,不需要权限。
622
645
  - `delete` 不会弹出确认,需要确认时由插件自己询问用户。删除后,用户可以在插件详情页的「最近删除」中 7 天内恢复,恢复后 ID、`key` 和正文都不变;如果这期间插件用同一个 `key` 新建了内容,则无法恢复。
623
646
  - `backlinks` 返回 `{ items: [{ ref, title, snippets }], omitted }`。它只列出插件已获准读取的类型(如有 `cards:read` 才列出卡片),不会弹窗询问,其余来源只计入 `omitted`。`ref` 可以直接交给 `context.app.open`。
624
- - 卸载插件后,它创建的内容保留 7 天,期间重新安装就能找回,超过 7 天后删除。
647
+ - 桌面卸载插件后,它创建的内容保留 7 天,期间重新安装就能找回,超过 7 天后删除。移动卸载保留实体及记录,不因当前设备未安装而删除其他设备同步的数据;插件再次显式使用时领取属于自己的孤立数据。主动调用 entities.delete 的七天恢复期限不受此差异影响。
625
648
 
626
649
  ### 按字段查询
627
650
 
@@ -697,13 +720,15 @@ await context.records.update(
697
720
  - 每条记录是 `{ id, collection, data, createdAt, updatedAt, revision }`。`data` 是不超过 64 KB 的 JSON 对象。
698
721
  - `indexes`、`where`、`orderBy` 的写法与「按字段查询」相同,字段取 `data` 的顶层键;自带的排序列是 `createdAt` 和 `updatedAt`。
699
722
  - 删除是直接删除,**不进「最近删除」**,用户无法恢复。删除插件内容时,与它相关的记录由插件自己删除,可以放进同一个[原子提交](#原子提交)。
700
- - 记录随笔记库保存与同步。卸载插件后和插件内容一样保留 7 天,期间重新安装就能找回,超过 7 天后删除。
723
+ - 记录随笔记库保存与同步。桌面卸载后与插件内容一样保留 7 天;移动卸载保留记录。记录 API 的 delete 不进最近删除,不能借实体恢复找回已删记录。
701
724
  - 变化时发 `record.created`、`record.updated`、`record.deleted` 事件,事件带 `collection`,只发给本插件,见「订阅变化」。
702
725
  - 设置、进度这类按键存取的小块数据,用[私有存储](storage-and-network.md#私有存储)更简单。
703
726
 
704
727
  ## 插件关联
705
728
 
706
- `context.links` 把插件内容连到其他内容上,例如问题关联的探究材料、问题与答案。关联是有序的,可以带角色。被关联的卡片、文章、项目文档会在脉络的「被关联」里列出你的内容,按你声明的类型名与图标显示,点击打开你的插件页面;插件停用后照样显示,插件卸载后不再显示。手机上的脉络也会列出(只显示,不能打开,手机不运行插件)。
729
+ 移动可关联已开放的原生引用(包括用户选择过的日记片段),以及本插件拥有或用户曾选择过的插件实体;未开放的引用类型明确拒绝。目标只因已获整类读取权限而可见时,每次写入仍复验该权限;事务在正文准备后再次复验。关联表保存目标创建身份,但公共引用 ID 不包含此字段:普通实体编号复用且插件有整类读取权限时,直接拿该引用调用 describe 仍按当前 ID 描述,此跨端限制不等于旧关联已重绑。
730
+
731
+ `context.links` 把插件内容连到其他内容上,例如问题关联的探究材料、问题与答案。关联是有序的,可以带角色。被关联的卡片、文章、项目文档会在脉络的「被关联」里列出你的内容,按你声明的类型名与图标显示,点击打开你的插件页面;插件停用后照样显示,插件卸载后不再显示。手机上的脉络也会列出;所属插件已启用且类型注册有效时,可进入其声明的页面。
707
732
 
708
733
  ```ts
709
734
  const picked = await context.app.pick({
@@ -731,7 +756,7 @@ for (const state of await context.app.describe(
731
756
  - `role` 由插件定义,与类型 ID 的写法相同,缺省为空字符串。`data` 是不超过 4 KB 的 JSON 对象,用来存少量附加信息,例如对话里的消息位置。一项内容最多 1000 条关联。
732
757
  - **能关联的目标**与 `describe` 能读到标题的范围相同:用户选择过的、请 Tau 新建的、本插件自己的内容,或插件已获准读取的类型。其余目标会抛错,错误里不透露它是否存在。关联不弹窗申请权限。
733
758
  - 目标被删除时关联保留,`describe` 返回 `missing`,`<EntityRef>` 显示为已删除;需要清理时由插件 `remove`。
734
- - 删除插件内容时,它的关联一起删除;用户从「最近删除」恢复后,关联一起恢复。卸载插件后与插件内容一样保留 7 天。
759
+ - 删除插件内容时,它的出边一起删除;用户从「最近删除」恢复后,出边一起恢复,冲突不覆盖。目标删除保留指向它的入边。卸载保留策略与本平台的插件内容一致。
735
760
  - 关联的增删和重排算作来源内容的变化,发 `entity.updated` 事件。
736
761
 
737
762
  ## 原子提交
package/package.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  isPluginPermission,
13
13
  validateBackendManifest,
14
14
  validatePluginManifest
15
- } from "./client/chunk-CQ3UMKDY.js";
15
+ } from "./client/chunk-5GHRRBYH.js";
16
16
  import "./client/chunk-UTVEXGFI.js";
17
17
  export {
18
18
  PLUGIN_AI_CAPABILITIES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/portable.js CHANGED
@@ -1,14 +1,26 @@
1
1
  import {
2
+ MOBILE_AI_MIN_VERSION,
3
+ MOBILE_AI_PERMISSIONS,
4
+ MOBILE_DATA_MIN_VERSION,
5
+ MOBILE_DATA_PERMISSIONS,
6
+ MOBILE_SPEECH_MIN_VERSION,
7
+ MOBILE_SPEECH_PERMISSIONS,
2
8
  PORTABLE_PLATFORMS,
3
9
  PORTABLE_SHARED_MODULES,
4
10
  assertPortablePluginCompatibility,
5
11
  buildPortablePluginManifest,
6
12
  validatePortableDistributionManifest,
7
13
  validatePortablePluginManifest
8
- } from "./client/chunk-MNFXOBPW.js";
9
- import "./client/chunk-CQ3UMKDY.js";
14
+ } from "./client/chunk-TCJBY6GL.js";
15
+ import "./client/chunk-5GHRRBYH.js";
10
16
  import "./client/chunk-UTVEXGFI.js";
11
17
  export {
18
+ MOBILE_AI_MIN_VERSION,
19
+ MOBILE_AI_PERMISSIONS,
20
+ MOBILE_DATA_MIN_VERSION,
21
+ MOBILE_DATA_PERMISSIONS,
22
+ MOBILE_SPEECH_MIN_VERSION,
23
+ MOBILE_SPEECH_PERMISSIONS,
12
24
  PORTABLE_PLATFORMS,
13
25
  PORTABLE_SHARED_MODULES,
14
26
  assertPortablePluginCompatibility,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  PORTABLE_SHARED_MODULES,
3
3
  validatePortablePluginManifest
4
- } from "./client/chunk-MNFXOBPW.js";
4
+ } from "./client/chunk-TCJBY6GL.js";
5
5
  import {
6
6
  PLUGIN_SHARED_MODULES,
7
7
  validatePluginManifest
8
- } from "./client/chunk-CQ3UMKDY.js";
8
+ } from "./client/chunk-5GHRRBYH.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __toESM
@@ -5,6 +5,11 @@ export interface SpeechRefinementPreferences {
5
5
  }
6
6
  export declare const DEFAULT_SPEECH_REFINEMENT: SpeechRefinementPreferences;
7
7
  export declare function validateSpeechRefinementPreferences(value: unknown): SpeechRefinementPreferences;
8
+ /** 语音整理提示词:转录作为 JSON 数据交给模型,system 约束只整理不执行其中指令 */
9
+ export declare function buildSpeechRefinementPrompt(preferences: SpeechRefinementPreferences): {
10
+ system: string;
11
+ user(text: string): string;
12
+ };
8
13
  export type SpeechRefiner = (text: string, options: {
9
14
  signal: AbortSignal;
10
15
  onPreview(text: string): void;
@@ -4,7 +4,6 @@ import type { PluginNavigation } from "./navigation";
4
4
  import type { PluginAI, PluginAIFeature } from "./ai";
5
5
  import type { WhiteboardExtension } from "./whiteboard";
6
6
  import type { PluginServices } from "./services";
7
- import type { PluginEditor } from "./editor";
8
7
  import type { PluginEditorExtension } from "./editor";
9
8
  import type { ContentMetricRule } from "../../db-schema/content-metrics";
10
9
  import type { MarkdownCodec } from "../../markdown/src/index";
@@ -36,6 +35,7 @@ import type { PluginLinks } from "./links";
36
35
  import type { PluginTransactionRunner } from "./transaction";
37
36
  import type { PluginFlashcards } from "./flashcards";
38
37
  import type { PluginNotifications } from "./notifications";
38
+ import type { PluginSpeech } from "./speech";
39
39
  import type { JsonValue } from "./json";
40
40
  export type { JsonValue } from "./json";
41
41
  export interface Disposable {
@@ -64,7 +64,6 @@ export interface PluginContext {
64
64
  };
65
65
  readonly storage: PluginStorage;
66
66
  readonly pages: PluginPages;
67
- readonly editor: PluginEditor;
68
67
  readonly settings: PluginSettings;
69
68
  readonly sync: PluginSync;
70
69
  readonly upload: PluginUpload;
@@ -110,6 +109,8 @@ export interface PluginContext {
110
109
  readonly transaction: PluginTransactionRunner;
111
110
  readonly flashcards: PluginFlashcards;
112
111
  readonly notifications: PluginNotifications;
112
+ /** 语音输入;需要 speech:input 权限 */
113
+ readonly speech: PluginSpeech;
113
114
  /** 将订阅等资源交给宿主,在停用或激活失败时逆序回收。 */
114
115
  register(resource: Disposable): Disposable;
115
116
  }
@@ -224,6 +224,8 @@ export interface PluginEntityWriter<T, Input, Patch> extends PluginEntityReader<
224
224
  delete(id: string, options: PluginWriteOptions): Promise<void>;
225
225
  }
226
226
  export interface PluginTodoQuery {
227
+ /** tasks 返回系列/普通任务;occurrences 返回原始日期标识的周期实例,须给 start/end。 */
228
+ view?: "tasks" | "occurrences";
227
229
  /** 缺省为全部:独立待办与正文里的勾选项 */
228
230
  source?: "all" | "todo" | "document";
229
231
  completed?: boolean;
@@ -1,7 +1,4 @@
1
- import type { ContentMetricRule } from "../../db-schema/content-metrics";
2
1
  import type { EditorExtension as InternalExtension } from "../../editor/contracts";
3
- import type { MarkdownCodec } from "../../markdown/src/index";
4
- import type { Disposable } from "./index";
5
2
  import { type OpenEditorExtensionField } from "./editor-fields";
6
3
  export { defineElement as defineEditorElement } from "../../editor/contracts";
7
4
  export type { ElementRenderProps as EditorElementRenderProps } from "../../editor/contracts";
@@ -41,14 +38,3 @@ export type PluginEditorExtension = Pick<InternalExtension, OpenEditorExtensionF
41
38
  }[];
42
39
  };
43
40
  export declare function defineEditorExtension(definition: Omit<PluginEditorExtension, "apiVersion">): PluginEditorExtension;
44
- export interface PluginEditorContribution {
45
- /** 目前只有开发台场景;其他场景需宿主明确接入后开放。 */
46
- scene: "workbench";
47
- extension: PluginEditorExtension;
48
- /** 纯函数定义可由主进程独立导入,本次只在开发台装配。 */
49
- codecs?: readonly MarkdownCodec[];
50
- metrics?: readonly ContentMetricRule[];
51
- }
52
- export interface PluginEditor {
53
- register(contribution: PluginEditorContribution): Disposable;
54
- }
@@ -4,6 +4,16 @@ import type { Disposable, PluginContext } from "./contract";
4
4
  export type PluginHomePanelSize = "compact" | "wide";
5
5
  export interface PluginHomePanelProps {
6
6
  readonly context: PluginContext;
7
+ /**
8
+ * 登记面板里打开的浮层(底部面板等)的关闭函数:系统返回 / Esc 先关最后登记的浮层。
9
+ * 宿主不支持时为 undefined;@tau/ui 的模态 Dialog / Drawer 已自带,不必登记。
10
+ */
11
+ readonly registerDismiss?: (dismiss: () => void) => Disposable;
12
+ }
13
+ /** 面板标题行右侧的入口,如「查看账本」 */
14
+ export interface PluginHomePanelAction {
15
+ title: string;
16
+ run(): void | Promise<void>;
7
17
  }
8
18
  export interface PluginHomePanelDefinition {
9
19
  id: string;
@@ -13,7 +23,13 @@ export interface PluginHomePanelDefinition {
13
23
  component: ComponentType<PluginHomePanelProps>;
14
24
  /** 缺省为 wide */
15
25
  size?: PluginHomePanelSize;
26
+ /** 可选,由宿主画在标题行右侧 */
27
+ action?: PluginHomePanelAction;
16
28
  }
29
+ /** 宿主收到的定义:size 已补成缺省值,action 缺省为 null */
30
+ export type RegisteredHomePanelDefinition = Readonly<Required<Omit<PluginHomePanelDefinition, "action">> & {
31
+ action: Readonly<PluginHomePanelAction> | null;
32
+ }>;
17
33
  export interface PluginHome {
18
34
  /** 面板出现在首页:新面板排在末尾,位置由用户调整;插件停用后消失,重新启用回到原位置 */
19
35
  registerPanel(definition: PluginHomePanelDefinition): Disposable;
@@ -42,6 +42,7 @@ export type { PluginFieldCondition, PluginIndexes, PluginIndexType, PluginIndexV
42
42
  export { PluginConflictError } from "./errors";
43
43
  export { PLUGIN_ENTITY_KINDS, PLUGIN_ENTITY_READ_PERMISSIONS, PLUGIN_APP_ACTIONS, PLUGIN_EXPORT_FORMATS, PLUGIN_NOTEBOOK_FROM_KINDS, PLUGIN_CHAT_CONTEXT_KINDS, } from "./app";
44
44
  export type { PluginNotifications, PluginNotificationOptions, PluginNotificationMode, PluginNotificationAction, } from "./notifications";
45
+ export type { PluginSpeech, PluginSpeechSession, PluginSpeechStartOptions } from "./speech";
45
46
  export type { PluginApp, PluginAppAction, PluginAppActions, PluginAppActionResults, PluginContentLocation, PluginOpenOptions, PluginExportFormat, PluginEntityKind, PluginEntityRef, PluginEntityDescription, PluginPickOptions, PluginPickedEntity, } from "./app";
46
47
  export { PLUGIN_EVENT_TYPES } from "./events";
47
48
  export type { PluginDomainEvent, PluginEventOrigin, PluginEventType, PluginEvents } from "./events";
@@ -0,0 +1,11 @@
1
+ export declare const PACKAGE_PLATFORMS: readonly ["desktop", "android", "ios"];
2
+ export type PackagePlatform = (typeof PACKAGE_PLATFORMS)[number];
3
+ export interface PackageTarget {
4
+ readonly minAppVersion: string;
5
+ }
6
+ export type PackageTargets = Readonly<Partial<Record<PackagePlatform, PackageTarget>>>;
7
+ export declare function readPackageTargets(value: unknown): PackageTargets;
8
+ export declare function assertPackageTargetCompatibility(targets: PackageTargets, host: {
9
+ platform: PackagePlatform;
10
+ appVersion: string;
11
+ }): PackageTarget;
@@ -1,4 +1,4 @@
1
- export declare const PLUGIN_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "documents:read", "documents:write", "documents:delete", "whiteboards:read", "whiteboards:write", "whiteboards:delete", "projects:read", "projects:write", "projects:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "notebooks:read", "materials:read", "chats:read", "flashcards:read", "flashcards:write", ...("ai:chat" | "ai:titleSummary" | "ai:webClip" | "ai:podcastGeneration" | "ai:flashcardGeneration" | "ai:aiJudgement" | "ai:transcriptionOptimization" | "ai:speechInputRefinement" | "ai:videoSummary" | "ai:videoEbookRewrite" | "ai:vibeLearningImageDescription" | "ai:contentMetadata" | "ai:contentInsights")[]];
1
+ export declare const PLUGIN_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "documents:read", "documents:write", "documents:delete", "whiteboards:read", "whiteboards:write", "whiteboards:delete", "projects:read", "projects:write", "projects:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "notebooks:read", "materials:read", "chats:read", "flashcards:read", "flashcards:write", "speech:input", ...("ai:chat" | "ai:titleSummary" | "ai:webClip" | "ai:podcastGeneration" | "ai:flashcardGeneration" | "ai:aiJudgement" | "ai:transcriptionOptimization" | "ai:speechInputRefinement" | "ai:videoSummary" | "ai:videoEbookRewrite" | "ai:vibeLearningImageDescription" | "ai:contentMetadata" | "ai:contentInsights")[]];
2
2
  export type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];
3
3
  export declare const isPluginPermission: (value: unknown) => value is PluginPermission;
4
4
  /** granted:可直接调用;prompt:调用时会询问用户;denied:本次运行已拒绝或已被阻止 */
@@ -1,11 +1,17 @@
1
1
  import { type PluginManifest } from "./package";
2
2
  import type { PluginEnvironment } from "./environment";
3
+ import { type PackagePlatform, type PackageTarget } from "./package-targets";
4
+ export declare const MOBILE_DATA_MIN_VERSION = "0.2.13";
5
+ export declare const MOBILE_AI_MIN_VERSION = "0.2.13";
6
+ export declare const MOBILE_AI_PERMISSIONS: readonly ("ai:chat" | "ai:titleSummary" | "ai:webClip" | "ai:podcastGeneration" | "ai:flashcardGeneration" | "ai:aiJudgement" | "ai:transcriptionOptimization" | "ai:speechInputRefinement" | "ai:videoSummary" | "ai:videoEbookRewrite" | "ai:vibeLearningImageDescription" | "ai:contentMetadata" | "ai:contentInsights")[];
7
+ export declare const MOBILE_DATA_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "projects:read", "projects:write", "projects:delete", "documents:read", "documents:write", "documents:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "flashcards:read", "flashcards:write"];
8
+ /** 语音输入与首页面板随同一客户端版本开放 */
9
+ export declare const MOBILE_SPEECH_MIN_VERSION = "0.2.16";
10
+ export declare const MOBILE_SPEECH_PERMISSIONS: readonly ["speech:input"];
3
11
  export declare const PORTABLE_PLATFORMS: readonly ["desktop", "android", "ios"];
4
- export type PortablePlatform = (typeof PORTABLE_PLATFORMS)[number];
12
+ export type PortablePlatform = PackagePlatform;
5
13
  export declare const PORTABLE_SHARED_MODULES: readonly ["@tau/plugins", "@tau/plugins/whiteboard", "@tau/ui", "react", "react-dom", "react-dom/client", "react/jsx-runtime", "react/jsx-dev-runtime"];
6
- export interface PortablePluginTarget {
7
- readonly minAppVersion: string;
8
- }
14
+ export type PortablePluginTarget = PackageTarget;
9
15
  export interface PortablePluginManifest extends Omit<PluginManifest, "formatVersion" | "platform" | "backend" | "minAppVersion" | "editor" | "whiteboard"> {
10
16
  readonly formatVersion: 3;
11
17
  readonly platform: "portable";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 语音输入:沿用用户在 Tau「语音 › 语音输入」里选的识别方式(系统识别或识别插件),插件拿到的是识别文字。
3
+ * 需要在 manifest 声明 speech:input,第一次 start 时 Tau 询问用户;录音只在 start 与 stop / cancel 之间进行。
4
+ */
5
+ export interface PluginSpeechSession {
6
+ /** 识别完成后的文字;cancel 或出错时 reject */
7
+ readonly result: Promise<string>;
8
+ /** 停止录音,等待最终结果 */
9
+ stop(): Promise<void>;
10
+ /** 放弃这次录音,result 以 AbortError reject */
11
+ cancel(): Promise<void>;
12
+ }
13
+ export interface PluginSpeechStartOptions {
14
+ signal?: AbortSignal;
15
+ /** 识别中的实时文字(整段,不是增量) */
16
+ onPreview?(text: string): void;
17
+ }
18
+ export interface PluginSpeech {
19
+ /** 当前不能录音的原因(如「识别插件账号尚未配置」),可用时为 null;不触发授权询问 */
20
+ unavailableReason(): string | null;
21
+ /** 开始录音;同一时间只能有一次。宿主不支持时抛 SPEECH_UNAVAILABLE 开头的错误 */
22
+ start(options?: PluginSpeechStartOptions): Promise<PluginSpeechSession>;
23
+ }
@@ -1,5 +1,76 @@
1
1
  /** ask-question 提问工具的载荷、作答与结果(纯数据,主进程、渲染端与浏览器扩展共用) */
2
2
  export declare const ASK_QUESTION_TOOL_NAME: "ask-question";
3
+ export declare const ASK_QUESTION_DESCRIPTION = "\u5F53\u9700\u8981\u8FDB\u4E00\u6B65\u6F84\u6E05\u7528\u6237\u610F\u56FE\u65F6\uFF0C\u5411\u7528\u6237\u53D1\u8D77\u7ED3\u6784\u5316\u95EE\u9898\u3002\u652F\u6301\u5355\u9009\u3001\u591A\u9009\u548C\u4E00\u6B21\u63D0\u51FA\u591A\u4E2A\u95EE\u9898\u3002";
4
+ /** ask-question 的模型入参 schema:桌面 pi 会话与移动运行时共用 */
5
+ export declare const ASK_QUESTION_PARAMETERS: {
6
+ type: string;
7
+ properties: {
8
+ title: {
9
+ type: string;
10
+ description: string;
11
+ };
12
+ description: {
13
+ type: string;
14
+ description: string;
15
+ };
16
+ submitLabel: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ questions: {
21
+ type: string;
22
+ description: string;
23
+ items: {
24
+ type: string;
25
+ properties: {
26
+ id: {
27
+ type: string;
28
+ description: string;
29
+ };
30
+ question: {
31
+ type: string;
32
+ description: string;
33
+ };
34
+ type: {
35
+ type: string;
36
+ enum: string[];
37
+ description: string;
38
+ };
39
+ required: {
40
+ type: string;
41
+ description: string;
42
+ };
43
+ options: {
44
+ type: string;
45
+ description: string;
46
+ items: {
47
+ anyOf: ({
48
+ type: string;
49
+ properties?: undefined;
50
+ } | {
51
+ type: string;
52
+ properties: {
53
+ label: {
54
+ type: string;
55
+ };
56
+ value: {
57
+ type: string;
58
+ };
59
+ description: {
60
+ type: string;
61
+ };
62
+ };
63
+ })[];
64
+ };
65
+ };
66
+ };
67
+ required: string[];
68
+ };
69
+ };
70
+ };
71
+ required: string[];
72
+ additionalProperties: boolean;
73
+ };
3
74
  export type AskQuestionType = "single" | "multiple";
4
75
  export interface AskQuestionOption {
5
76
  label: string;
@@ -5,3 +5,4 @@ export * from "./assistantBlocks";
5
5
  export * from "./streamEvents";
6
6
  export * from "./aiRunProtocol";
7
7
  export * from "./askQuestion";
8
+ export * from "./thinkingLevels";
@@ -3,7 +3,18 @@
3
3
  * 桌面 src/types/llm.ts、src/types/chat-message.ts、src/types/tool.ts 对本文件为 re-export 关系,
4
4
  * 两端禁止再各自定义同名类型。
5
5
  */
6
- import type { MentionRef } from "../components/ChatInputArea/types";
6
+ export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
7
+ export type ChatSessionSource = "desktop" | "mobile" | "browser";
8
+ export type MentionEntityType = "card" | "article" | "project-item" | "diary";
9
+ export interface MentionRef {
10
+ entityType: MentionEntityType;
11
+ entityId: number;
12
+ contentId: number;
13
+ title: string;
14
+ previewText: string;
15
+ /** previewText 是用户在正文里选中的原文(就近提问),而非整篇的摘要 */
16
+ quote?: boolean;
17
+ }
7
18
  export declare enum Role {
8
19
  User = "user",
9
20
  Assistant = "assistant",
@@ -166,8 +177,8 @@ export interface ChatSessionRecord {
166
177
  groupId?: number | null;
167
178
  archived?: boolean;
168
179
  orderNum?: number | null;
169
- /** 会话来源:desktop 为桌面端创建,browser 为浏览器插件创建 */
170
- source?: "desktop" | "browser";
180
+ /** 会话创建来源不限制其他设备继续读取或执行。 */
181
+ source?: ChatSessionSource;
171
182
  /** 相对会话目录的 JSONL 文件名;草稿(尚未登记)为空 */
172
183
  sessionFile?: string;
173
184
  /** 聊天场景(main-chat / pdf-chat / …)与所属对象 */
@@ -0,0 +1,15 @@
1
+ import type { ThinkingLevel } from "./messages";
2
+ export interface ThinkingLevelOption {
3
+ value: ThinkingLevel;
4
+ label: string;
5
+ /** 窄工具行上的两字短名 */
6
+ short: string;
7
+ description: string;
8
+ }
9
+ /** 全部档位的界面文案(桌面、移动同一套说法);实际可选项由模型能力决定 */
10
+ export declare const THINKING_LEVEL_OPTIONS: readonly ThinkingLevelOption[];
11
+ /** 模型能力未知时只给各家都有的几档 */
12
+ export declare const DEFAULT_THINKING_LEVEL_OPTIONS: readonly ThinkingLevel[];
13
+ export declare const isThinkingLevel: (value: unknown) => value is ThinkingLevel;
14
+ /** 选中的档位落到可选集合内:换模型后旧选择可能不被支持,界面显示要与实际发送一致 */
15
+ export declare const clampThinkingLevel: (picked: ThinkingLevel, options: readonly ThinkingLevel[]) => ThinkingLevel;
@@ -11,10 +11,14 @@
11
11
  *
12
12
  * 用法:app 壳层挂载 <ToastHost /> 一次;任意处调用 toast.success("已保存")、
13
13
  * toast.error("失败")、toast.loading → toast.resolve(id) 或 toast.promise(p, {...})。
14
+ * 外观两档:default 浅色胶囊(桌面)、inverse 深色胶囊(移动端);zoneClassName 覆盖停靠位置与层级。
15
+ * key:同 key 的新提示原位替换旧的一条并重新计时,用于「同一件事只留一条」(如反复轻点的说明)。
14
16
  */
15
17
  export type ToastType = "success" | "error" | "warning" | "info" | "loading";
16
18
  export type ToastPosition = "top-center" | "top-right" | "bottom-right" | "bottom-center";
17
19
  export interface ToastOptions {
20
+ /** 同 key 的提示只保留一条:新提示原位替换并重新计时 */
21
+ key?: string;
18
22
  /** 内联动作(如「撤销」),点击后 toast 关闭 */
19
23
  action?: {
20
24
  label: string;
@@ -32,6 +36,9 @@ export interface ToastOptions {
32
36
  */
33
37
  export interface ToastItem {
34
38
  id: number;
39
+ key?: string;
40
+ /** 原位替换时递增,重新开始计时 */
41
+ revision?: number;
35
42
  type: ToastType;
36
43
  message: string;
37
44
  action?: ToastOptions["action"];
@@ -55,6 +62,8 @@ export declare const toast: {
55
62
  loading(message: string, opts?: ToastOptions): number;
56
63
  resolve(id: number, message?: string): void;
57
64
  reject(id: number, message?: string): void;
65
+ /** 当前在显示的提示(按出现顺序),供宿主读取状态与测试断言 */
66
+ items(): readonly ToastItem[];
58
67
  dismiss(id?: number): void;
59
68
  /** promise 形态:loading → 成功/失败(文案支持按结果取值) */
60
69
  promise<T>(promise: Promise<T>, messages: {
@@ -63,8 +72,15 @@ export declare const toast: {
63
72
  error?: string | ((err: unknown) => string);
64
73
  }, opts?: ToastOptions): Promise<T>;
65
74
  };
66
- export declare function ToastHost(): import("react/jsx-runtime").JSX.Element;
67
- export declare function ToastPill({ item }: {
75
+ export type ToastVariant = "default" | "inverse";
76
+ export declare function ToastHost({ variant, zoneClassName, }?: {
77
+ /** default 浅色描边胶囊;inverse 深色胶囊(墨色底、反白字) */
78
+ variant?: ToastVariant;
79
+ /** 覆盖停靠区的位置与层级(如移动端顶栏下方、低于系统层) */
80
+ zoneClassName?: string;
81
+ }): import("react/jsx-runtime").JSX.Element;
82
+ export declare function ToastPill({ item, variant }: {
68
83
  item: ToastItem;
84
+ variant?: ToastVariant;
69
85
  }): import("react/jsx-runtime").JSX.Element;
70
86
  export {};
@@ -1,126 +0,0 @@
1
- import type { ReactNode } from "react";
2
- /**
3
- * 模型下拉菜单项(antd Dropdown 时代的结构子集;ChatInputArea 换 @tau/ui Menu 后收敛为原语协议)。
4
- * ext / desktop 侧构造的字段不超出此面,antd message 等 UI 库类型不得回流 shared 类型层。
5
- */
6
- export interface ChatDropdownItem {
7
- key: string;
8
- label: ReactNode;
9
- /** 分组小标题(非交互项,如模型菜单的 provider 名) */
10
- group?: boolean;
11
- danger?: boolean;
12
- disabled?: boolean;
13
- icon?: ReactNode;
14
- }
15
- /**
16
- * 思考档位——全仓唯一定义,取值与运行时(pi ThinkingLevel)逐项对齐。
17
- * 桌面端 `PiThinkingLevel` 即本类型;此前两侧各有一套(旧枚举用 "none" 且没有 "minimal"),
18
- * 导致 minimal 在界面上不可达、每处转换都要记得 none→off。
19
- */
20
- export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
21
- export type MentionEntityType = "card" | "article" | "project-item";
22
- /** 聊天 mention 引用 */
23
- export interface MentionRef {
24
- entityType: MentionEntityType;
25
- entityId: number;
26
- contentId: number;
27
- title: string;
28
- previewText: string;
29
- }
30
- /** 消息内容类型;resourceId 仅兼容历史数据,新附件只写入路径。 */
31
- export type MessageContentItem = {
32
- type: "text";
33
- text: string;
34
- mentions?: MentionRef[];
35
- skills?: string[];
36
- } | {
37
- type: "image";
38
- image: string;
39
- path?: string;
40
- resourceId?: number;
41
- } | {
42
- type: "file";
43
- file: string;
44
- resourceId?: number;
45
- fileName?: string;
46
- };
47
- /** ChatInputArea 需要的服务函数 */
48
- export interface ChatInputAreaServices {
49
- /** 上传文件,返回文件路径 */
50
- uploadFile: (file: File) => Promise<string | null>;
51
- /** 将本地文件路径转换为可访问的 URL */
52
- convertFileSrc: (path: string) => Promise<string>;
53
- /** 获取用户主目录 */
54
- getHomeDir: () => Promise<string>;
55
- /** 搜索可提及的内部内容 */
56
- searchMentionRefs?: (query: string) => Promise<MentionRef[]>;
57
- }
58
- /** ChatInputArea 的 ref handle */
59
- export interface ChatInputAreaHandle {
60
- getValue: () => MessageContentItem[];
61
- clear: () => void;
62
- setValue: (content: string) => void;
63
- appendMention?: (mention: MentionRef) => void;
64
- focusEnd: () => void;
65
- }
66
- export interface ChatContextUsage {
67
- inputTokens: number;
68
- outputTokens: number;
69
- cacheReadTokens: number;
70
- cacheWriteTokens: number;
71
- }
72
- /** ChatInputArea 的 props */
73
- export interface ChatInputAreaProps {
74
- /** 服务函数 */
75
- services: ChatInputAreaServices;
76
- /** 自定义类名 */
77
- className?: string;
78
- /** 是否可编辑 */
79
- contentEditable?: boolean;
80
- /** 按下回车时的回调 */
81
- onPressEnter?: () => void;
82
- /** 停止生成时的回调 */
83
- onStop?: () => void;
84
- /** 占位符 */
85
- placeholder?: string;
86
- /** 是否正在发送 */
87
- sendLoading?: boolean;
88
- /** 生成期间是否仍允许编辑并将消息加入发送队列 */
89
- allowSendWhileLoading?: boolean;
90
- /** 当前等待发送的消息数量 */
91
- queuedMessageCount?: number;
92
- /** 是否正在创建新消息 */
93
- createMessageLoading?: boolean;
94
- /** 创建新消息的回调 */
95
- onCreateNewMessage?: () => void;
96
- /** 模型选择菜单项 */
97
- modelSelectItems?: ChatDropdownItem[];
98
- /** 当前选中模型的菜单项 key,用于菜单勾选 */
99
- currentModelKey?: string;
100
- /** 模型选择回调 */
101
- onModelSelect?: ({ key }: {
102
- key: string;
103
- }) => void;
104
- /** 当前模型名称 */
105
- currentModelName?: string;
106
- /** 当前模型上下文窗口,单位为 k tokens */
107
- contextWindowK?: number;
108
- /** 当前聊天最近一次模型请求的 token 用量 */
109
- contextUsage?: ChatContextUsage | null;
110
- /** 是否支持图片上传 */
111
- isSupportImage?: boolean;
112
- /** 是否支持文件上传 */
113
- isSupportFile?: boolean;
114
- /** 思考档位 */
115
- thinkingLevel?: ThinkingLevel;
116
- /** 当前模型真实支持的档位(由模型能力决定,不是固定几档) */
117
- thinkingLevelOptions?: readonly ThinkingLevel[];
118
- /** 档位变化回调 */
119
- onThinkingLevelChange?: (level: ThinkingLevel) => void;
120
- /** 档位选择是否禁用 */
121
- thinkingLevelDisabled?: boolean;
122
- /** MCP 管理按钮点击回调(可选,不提供则不显示按钮) */
123
- onMcpManagerClick?: () => void;
124
- /** 额外的工具栏按钮(渲染在 + 右侧) */
125
- extraToolbarButtons?: ReactNode;
126
- }