@xiongtao.xt/tau-plugins 0.54.0 → 0.55.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/CHANGELOG.md +4 -0
- package/docs/plugin-basics.md +1 -0
- package/docs/portability.md +1 -0
- package/docs/providers/video.md +1 -1
- package/docs/ui.md +51 -0
- package/package.json +1 -1
- package/types/packages/plugins/src/contract.d.ts +3 -0
- package/types/packages/plugins/src/index.d.ts +1 -0
- package/types/packages/plugins/src/notebooks.d.ts +98 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.55.0
|
|
4
|
+
|
|
5
|
+
- 新增 `context.notebooks.registerOutput({ id, title, icon?, description?, kind, options?, view, prepare, complete, fail? })`:在 Notebook 的生成菜单里加一种产物。对话框、资料勾选与 AI 生成由 Tau 负责(走 Notebook 已有的生成流程与资料检索);`prepare` 建好产物占位并返回任务说明 `{ entity, title, instructions, reminders? }`,`complete` 收到最终正文与 `task`(`phase` / `progress`),`fail` 在失败或停止时调用。Tau 自动建立产物到 Notebook 的 `output` 关联。新增宿主接口 `NotebooksAdapter`,贡献类型 `notebook-output`。目前只有桌面支持。
|
|
6
|
+
|
|
3
7
|
## 0.54.0
|
|
4
8
|
|
|
5
9
|
- 新增 `context.tts.open({ signal })` 朗读:沿用用户在「设置 › 语音」里选的服务与模型,返回会话 `{ providerName, textInstructions, getVoices, synthesize, close }`,插件停用时自动关闭;`unavailableReason()` 判断能否朗读。需要在 manifest 声明新权限 `tts:synthesize`,首次调用时询问用户;宿主未接入时 `open` 抛 `TTS_UNAVAILABLE`。新增宿主接口 `TTSSynthesisAdapter`。目前只有桌面支持。
|
package/docs/plugin-basics.md
CHANGED
|
@@ -141,6 +141,7 @@ create: () => ({
|
|
|
141
141
|
| `home` | 注册首页面板 | [界面](ui.md#首页面板) |
|
|
142
142
|
| `actions` | 在卡片、文章、项目文档的菜单里加动作 | [界面](ui.md#对象动作) |
|
|
143
143
|
| `views` | 在卡片、文章、项目文档详情里放区块 | [界面](ui.md#详情区块) |
|
|
144
|
+
| `notebooks` | 在 Notebook 的生成菜单里加产物 | [界面](ui.md#notebook-输出) |
|
|
144
145
|
| `settings` | 注册设置区域 | [界面](ui.md#设置) |
|
|
145
146
|
| `notifications` | 发送通知 | [界面](ui.md#通知) |
|
|
146
147
|
| `speech` | 语音输入,拿到识别文字 | [界面](ui.md#语音输入) |
|
package/docs/portability.md
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
| `speech` | | ✓ | 手机 0.2.16 起,见[界面 · 语音输入](ui.md#语音输入) |
|
|
40
40
|
| `tts.open`、`upload.save` | ✓ | | 见[界面 · 朗读](ui.md#朗读)与[用户数据 · 保存资源文件](user-data.md#保存资源文件) |
|
|
41
41
|
| `sidebar`、`views`、`notifications` | ✓ | | 跨平台的入口用 `navigation` |
|
|
42
|
+
| `notebooks` | ✓ | | 见[界面 · Notebook 输出](ui.md#notebook-输出) |
|
|
42
43
|
| `actions` | ✓ | 部分 | 手机只有卡片、文章、项目文档详情页的「更多」菜单,见[界面 · 对象动作](ui.md#对象动作) |
|
|
43
44
|
| `permissions`、`data`、`content`、`events` | ✓ | 部分 | 手机 0.2.13 起支持卡片、文章、项目、项目文档、待办、日程,见[用户数据](user-data.md) |
|
|
44
45
|
| `app` | ✓ | 部分 | 手机可以选择、描述和打开上述内容与插件内容;`run` 只有新建卡片、插入项目文档和协作共享,见[用户数据](user-data.md#选择并打开已有内容) |
|
package/docs/providers/video.md
CHANGED
|
@@ -107,7 +107,7 @@ const probe = await context.services.videoExtractor.probe(url, { signal });
|
|
|
107
107
|
|
|
108
108
|
根据 `formats` 组织清晰度,`getPlayback` 时返回 `{ kind: "extract", url, videoFormat, audioFormat }`。插件不能自己启动外部程序下载视频。
|
|
109
109
|
|
|
110
|
-
同一解析器可读取字幕:`context.services.videoExtractor.getCaptions(url, { proxy, signal })` 返回 `VideoCaptions | null
|
|
110
|
+
同一解析器可读取字幕:`context.services.videoExtractor.getCaptions(url, { proxy, signal })` 返回 `VideoCaptions | null`。它支持 JSON3、WebVTT(VTT)和 SubRip(SRT),只下载一条字幕轨:优先人工字幕、同类优先原语言,同一语言按 JSON3 → VTT → SRT 选择格式。结果统一为纯文本与毫秒起止时间;没有受支持的字幕轨或有效片段时返回 null,不下载视频或调用转录模型。代理与本次调用一致;只有接入该服务的桌面客户端支持,较早客户端不会调用新字幕接口。
|
|
111
111
|
|
|
112
112
|
## 配置表单
|
|
113
113
|
|
package/docs/ui.md
CHANGED
|
@@ -572,6 +572,57 @@ context.views.registerEntityPanel({
|
|
|
572
572
|
- 用户在详情页之间切换时,组件不会重新挂载,只换 `target`;按 `target` 取数据的 effect 要把它放进依赖。
|
|
573
573
|
- 渲染出错时这一块显示错误和「重试」,不影响详情页其他内容。只在主窗口出现,独立编辑窗口不显示。
|
|
574
574
|
|
|
575
|
+
## Notebook 输出
|
|
576
|
+
|
|
577
|
+
在 Notebook 的「生成」菜单(产物组的 + 与资料页的「基于这份资料」)里加一种产物,例如播客。对话框、资料勾选、AI 生成和执行过程页都由 Tau 负责:AI 走 Notebook 已有的生成流程,会按需检索、补读用户勾选的资料。插件只说明要什么,拿到生成的正文后自己处理。目前只有桌面支持。
|
|
578
|
+
|
|
579
|
+
```tsx
|
|
580
|
+
context.notebooks.registerOutput({
|
|
581
|
+
id: "podcast",
|
|
582
|
+
title: "播客",
|
|
583
|
+
icon: Podcast,
|
|
584
|
+
kind: "episode", // 产物对应的插件实体类型,须先 registerKind
|
|
585
|
+
options: PodcastOptions, // 放在对话框中间的选项区
|
|
586
|
+
view: EpisodeView, // 产物在 Notebook 阅读区里的显示
|
|
587
|
+
async prepare({ notebook, resources, userPrompt, options, signal }) {
|
|
588
|
+
const entity = await context.entities.create({ kind: "episode", key: crypto.randomUUID(), meta: {} });
|
|
589
|
+
return {
|
|
590
|
+
entity: entity.id,
|
|
591
|
+
title: "播客脚本",
|
|
592
|
+
instructions: "写一段约 5 分钟的双人对话……最终每行输出「说话人: 内容」",
|
|
593
|
+
reminders: ["不要输出标题或说明"],
|
|
594
|
+
};
|
|
595
|
+
},
|
|
596
|
+
async complete({ entity, text, task, signal }) {
|
|
597
|
+
task.phase("合成语音");
|
|
598
|
+
// …解析 text、合成、保存,task.progress(done, total) 更新进度
|
|
599
|
+
},
|
|
600
|
+
async fail({ entity, reason }) {
|
|
601
|
+
// 生成失败或用户停止:清理占位或标为失败
|
|
602
|
+
},
|
|
603
|
+
});
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
| 字段 | 说明 |
|
|
607
|
+
| ------------- | ---------------------------------------------------------------------------------------- |
|
|
608
|
+
| `id` | 局部 ID |
|
|
609
|
+
| `title` | 菜单、对话框与执行过程页里的名称 |
|
|
610
|
+
| `icon` | 可选。图标组件(同[侧边栏图标](#图标)) |
|
|
611
|
+
| `description` | 可选。对话框标题下的一句话 |
|
|
612
|
+
| `kind` | 产物对应的插件实体类型 |
|
|
613
|
+
| `options` | 可选。选项区组件,收到 `{ context, target, value, onChange, setBlocker }` |
|
|
614
|
+
| `view` | 阅读区组件,收到 `{ context, entity, notebook }` |
|
|
615
|
+
| `prepare` | 用户点「开始生成」时调用:建好产物占位,返回 `{ entity, title, instructions, reminders? }` |
|
|
616
|
+
| `complete` | 生成完成后调用:收到最终正文 `text` 与 `task`(`phase(text)`、`progress(done, total)`) |
|
|
617
|
+
| `fail` | 可选。生成失败、`complete` 抛错或用户停止时调用,`reason` 为 `failed` 或 `cancelled` |
|
|
618
|
+
|
|
619
|
+
- `instructions` 只写这一种产物的要求与输出格式。资料清单、检索工具的用法和「先读资料再写」等通用规则由 Tau 补上,不要重复。
|
|
620
|
+
- 选项区的 `value` 由插件定义(JSON),Tau 原样保存并在 `prepare` 时交回;`setBlocker(原因)` 让「开始生成」不可用,并在对话框底部显示原因。
|
|
621
|
+
- 插件读不到资料内容,只拿到资料名称和生成的正文。用户在对话框里勾选资料并点「开始」即视为同意,不需要另外申请权限。
|
|
622
|
+
- `prepare` 返回后,Tau 建一条从产物指向这个 Notebook 的关联(角色 `output`),并把 Notebook 登记为插件选择过的引用;产物据此出现在 Notebook 的产物列表里,点开时显示 `view`。插件停用后,它的产物不在列表里显示。
|
|
623
|
+
- 生成用 Notebook 的模型分配,用量单独记在「Notebook · 插件名」名下,不占插件 AI 额度。
|
|
624
|
+
- 失败或停止时,Tau 等待 `fail` 完成后才允许重试。「重新生成」在产物实体仍存在时沿用任务说明并重跑生成与 `complete`;若插件已删除占位,则重新调用 `prepare`、建立 Notebook 关联并打开新产物。
|
|
625
|
+
|
|
575
626
|
## 语音输入
|
|
576
627
|
|
|
577
628
|
插件可以让用户按住说话,拿到识别后的文字。目前只有手机支持(0.2.16 起)。识别方式沿用用户在 Tau「语音 › 语音输入」里的设置(系统识别或识别插件),插件不接触音频。在 manifest 的 `permissions` 里声明 `speech:input`,第一次调用 `start` 时 Tau 询问用户。
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ import type { PluginSidebar } from "./sidebar";
|
|
|
21
21
|
import type { PluginHome } from "./home";
|
|
22
22
|
import type { PluginActions } from "./actions";
|
|
23
23
|
import type { PluginViews } from "./views";
|
|
24
|
+
import type { PluginNotebooks } from "./notebooks";
|
|
24
25
|
import type { PluginExcerpts, PluginMaterials } from "./excerpts";
|
|
25
26
|
import type { PluginMCP } from "./mcp";
|
|
26
27
|
import type { PluginChat } from "./chat";
|
|
@@ -82,6 +83,8 @@ export interface PluginContext {
|
|
|
82
83
|
readonly actions: PluginActions;
|
|
83
84
|
/** 卡片、文章、项目文档详情里的区块 */
|
|
84
85
|
readonly views: PluginViews;
|
|
86
|
+
/** Notebook 的生成菜单里加产物;只在桌面主窗口 */
|
|
87
|
+
readonly notebooks: PluginNotebooks;
|
|
85
88
|
readonly excerpts: PluginExcerpts;
|
|
86
89
|
readonly materials: PluginMaterials;
|
|
87
90
|
readonly fetch: typeof globalThis.fetch;
|
|
@@ -31,6 +31,7 @@ export type * from "./home";
|
|
|
31
31
|
export type * from "./actions";
|
|
32
32
|
export { PLUGIN_ACTION_TARGET_KINDS } from "./actions";
|
|
33
33
|
export type * from "./views";
|
|
34
|
+
export type * from "./notebooks";
|
|
34
35
|
export { PLUGIN_ENTITY_PANEL_KINDS } from "./views";
|
|
35
36
|
export type * from "./excerpts";
|
|
36
37
|
export type * from "./data";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { Disposable, PluginContext } from "./contract";
|
|
3
|
+
import type { PluginIcon } from "./icons";
|
|
4
|
+
import type { JsonValue } from "./json";
|
|
5
|
+
import type { PluginOwnEntity } from "./entities";
|
|
6
|
+
/**
|
|
7
|
+
* Notebook 输出:插件在 Notebook 的「生成」菜单里加一种产物。对话框、资料勾选、AI 生成与执行过程页
|
|
8
|
+
* 都由 Tau 负责,AI 走 Notebook 已有的生成流程与资料检索;插件只说明要什么(prepare),
|
|
9
|
+
* 拿到生成的正文后自己处理(complete)。
|
|
10
|
+
*/
|
|
11
|
+
/** 用户勾选的一份资料(只有名称,插件读不到资料内容) */
|
|
12
|
+
export interface PluginNotebookOutputResource {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginNotebookOutputTarget {
|
|
17
|
+
notebook: {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
};
|
|
21
|
+
resources: readonly PluginNotebookOutputResource[];
|
|
22
|
+
}
|
|
23
|
+
/** 插件在对话框中间放的选项区:value 由插件定义,宿主原样保存并在 prepare 时交回 */
|
|
24
|
+
export interface PluginNotebookOutputOptionsProps {
|
|
25
|
+
readonly context: PluginContext;
|
|
26
|
+
readonly target: PluginNotebookOutputTarget;
|
|
27
|
+
readonly value: JsonValue | undefined;
|
|
28
|
+
onChange(value: JsonValue): void;
|
|
29
|
+
/** 传入原因时「开始生成」不可用,并在对话框底部显示原因;null 解除 */
|
|
30
|
+
setBlocker(reason: string | null): void;
|
|
31
|
+
}
|
|
32
|
+
export interface PluginNotebookOutputPrepareInput extends PluginNotebookOutputTarget {
|
|
33
|
+
/** 用户在「额外要求」里写的话,可能为空 */
|
|
34
|
+
userPrompt: string;
|
|
35
|
+
options: JsonValue | undefined;
|
|
36
|
+
signal: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
/** 交给 AI 的任务说明;资料清单、检索工具与通用生成规则由 Tau 补上 */
|
|
39
|
+
export interface PluginNotebookOutputPlan {
|
|
40
|
+
/** 这一次产物的插件实体 ID(插件先建好占位),类型须为 registerOutput 声明的 kind */
|
|
41
|
+
entity: string;
|
|
42
|
+
/** 执行过程页显示的标题 */
|
|
43
|
+
title: string;
|
|
44
|
+
/** 任务要求与输出格式:写什么、怎么写、最终只输出什么 */
|
|
45
|
+
instructions: string;
|
|
46
|
+
/** 补充提醒,按条列出 */
|
|
47
|
+
reminders?: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
/** complete 期间向执行过程页报告进度 */
|
|
50
|
+
export interface PluginNotebookOutputTask {
|
|
51
|
+
/** 当前阶段的一句话,如「合成语音」 */
|
|
52
|
+
phase(text: string): void;
|
|
53
|
+
/** 分步进度;total 为 0 时不显示进度条 */
|
|
54
|
+
progress(done: number, total: number): void;
|
|
55
|
+
}
|
|
56
|
+
export interface PluginNotebookOutputCompleteInput {
|
|
57
|
+
entity: string;
|
|
58
|
+
/** AI 最终输出的正文 */
|
|
59
|
+
text: string;
|
|
60
|
+
task: PluginNotebookOutputTask;
|
|
61
|
+
signal: AbortSignal;
|
|
62
|
+
}
|
|
63
|
+
export interface PluginNotebookOutputFailInput {
|
|
64
|
+
entity: string;
|
|
65
|
+
/** cancelled:用户停止;failed:生成或 complete 出错 */
|
|
66
|
+
reason: "cancelled" | "failed";
|
|
67
|
+
message: string;
|
|
68
|
+
}
|
|
69
|
+
/** 产物在 Notebook 阅读区里的显示 */
|
|
70
|
+
export interface PluginNotebookOutputViewProps {
|
|
71
|
+
readonly context: PluginContext;
|
|
72
|
+
readonly entity: PluginOwnEntity;
|
|
73
|
+
readonly notebook: {
|
|
74
|
+
id: string;
|
|
75
|
+
title: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface PluginNotebookOutputDefinition {
|
|
79
|
+
/** 插件内唯一 */
|
|
80
|
+
id: string;
|
|
81
|
+
/** 菜单与执行过程页里的名称,如「播客」 */
|
|
82
|
+
title: string;
|
|
83
|
+
icon?: PluginIcon;
|
|
84
|
+
/** 一句话说明,显示在对话框标题下 */
|
|
85
|
+
description?: string;
|
|
86
|
+
/** 产物对应的插件实体类型(须先 entities.registerKind) */
|
|
87
|
+
kind: string;
|
|
88
|
+
options?: ComponentType<PluginNotebookOutputOptionsProps>;
|
|
89
|
+
view: ComponentType<PluginNotebookOutputViewProps>;
|
|
90
|
+
prepare(input: PluginNotebookOutputPrepareInput): Promise<PluginNotebookOutputPlan>;
|
|
91
|
+
complete(input: PluginNotebookOutputCompleteInput): Promise<void>;
|
|
92
|
+
/** 生成失败、complete 抛错或用户停止时调用;插件据此清理占位或标为失败 */
|
|
93
|
+
fail?(input: PluginNotebookOutputFailInput): Promise<void> | void;
|
|
94
|
+
}
|
|
95
|
+
export interface PluginNotebooks {
|
|
96
|
+
/** 只在主窗口的 Notebook 里出现;目前只有桌面支持 */
|
|
97
|
+
registerOutput(definition: PluginNotebookOutputDefinition): Disposable;
|
|
98
|
+
}
|