@xiongtao.xt/tau-plugins 0.11.0 → 0.13.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/TTS.md +20 -0
- package/UPLOAD.md +35 -0
- package/package.json +1 -1
- package/types/packages/plugins/src/contract.d.ts +4 -0
- package/types/packages/plugins/src/index.d.ts +2 -0
- package/types/packages/plugins/src/settings.d.ts +19 -3
- package/types/packages/plugins/src/tts.d.ts +42 -0
- package/types/packages/plugins/src/upload.d.ts +20 -0
package/TTS.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# 语音提供方
|
|
2
|
+
|
|
3
|
+
需要 SDK 0.13.0 和包含语音插件能力的 Tau 0.59.0 客户端。
|
|
4
|
+
|
|
5
|
+
在activate中调用context.tts.register({id: context.pluginId, name, create})。create(config, modelId)同步创建任务实例,固定该账号配置和模型,不发送网络请求。每个插件可对应多个用户账号,不能用插件全局变量保存“当前API Key”。
|
|
6
|
+
|
|
7
|
+
| 方法或字段 | 职责 |
|
|
8
|
+
| -------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
9
|
+
| getVoices(signal) | 返回id、name、type(system/cloned/custom)、可选description组成的音色数组 |
|
|
10
|
+
| synthesize({text,voiceId,options},signal) | 返回{audio:Uint8Array,mime:string};options仅含speed、volume、pitch |
|
|
11
|
+
| cloneVoice({file,requestedId?,name?},signal),可选 | 每次一个{name,mimeType,content}参考文件,返回实际创建的音色;不返回上传文件ID或void |
|
|
12
|
+
| textInstructions,可选 | 当前模型的合成文本规则;供宿主播客脚本使用,缺省为纯文本 |
|
|
13
|
+
|
|
14
|
+
请求使用context.fetch并传入方法收到的signal。服务商超时用AbortSignal.any组合,不能覆盖取消信号;退避等待也须取消,不把AbortError当作可重试错误。
|
|
15
|
+
|
|
16
|
+
配置通过settings.register的target:"tts"挂载。组件接收ttsConfig.instanceId、value、models和save(value,models),只保存当前账号,不自动选为默认,不覆盖同插件其他账号。模型项为{id,label?};用户可填写自定义模型。保存失败保留表单并显示错误,不另存一份凭据到context.storage。
|
|
17
|
+
|
|
18
|
+
需要公开上传参考音频时调用context.upload.uploadRemote(file,{signal}),复用用户选定的远端上传配置。本地模式明确报错;MiniMax自有文件上传不需要图床。不要自行选择用户的上传插件、读取上传凭据或修改桶权限。
|
|
19
|
+
|
|
20
|
+
主进程只转发数据和提供宿主能力。插件在主窗口渲染进程执行,不使用Node后台入口。宿主负责音频播放、合并和保存;插件不直接写笔记或文件。
|
package/UPLOAD.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# 资源上传插件
|
|
2
|
+
|
|
3
|
+
需要 SDK 0.12.0 和包含资源上传插件能力的 Tau 0.59.0 客户端。上传返回正文可直接引用的 HTTP(S) 地址;数据库和资源目录同步使用 SYNC.md 的另一套接口。
|
|
4
|
+
|
|
5
|
+
SDK 0.13.0 增加第三个signal参数与context.upload.uploadRemote(file,{signal})。提供方应将signal合并进context.fetch请求;调用方使用uploadRemote时,本地目标明确报错,不自动更换存储。signal取消会结束等待并通知提供方,不代表撤回已经上传的远端对象。
|
|
6
|
+
|
|
7
|
+
在 activate 中注册提供方:
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
context.upload.register({
|
|
11
|
+
id: context.pluginId,
|
|
12
|
+
name: "我的资源存储",
|
|
13
|
+
async upload(file, config, signal) {
|
|
14
|
+
// 用 context.fetch 请求服务商,认证与路径由本次 config 决定。
|
|
15
|
+
// file.name 已唯一命名,file.mimeType 是 MIME,file.content 为 Uint8Array。
|
|
16
|
+
return uploadToStorage(context.fetch, file, config, signal);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
context.settings.register({
|
|
20
|
+
id: "upload",
|
|
21
|
+
title: "我的资源存储",
|
|
22
|
+
target: "upload",
|
|
23
|
+
component: UploadSettings,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
UploadSettings 接收 PluginSettingsProps。读取 uploadConfig.value,在用户保存时调用 await uploadConfig.save(config),宿主保存并选中该提供方;不要将同一份上传配置再存到 context.storage。配置是 JsonValue,读取时自行校验字段并给出错误提示。组件在资源存储设置页显示;插件详情页提供跳转入口。
|
|
28
|
+
|
|
29
|
+
每个插件只能注册一个上传提供方,id 必须等于 context.pluginId。宿主负责压缩、文件唯一命名、本地保存和跨窗口转发。插件只负责远端上传和返回资源地址,不读取用户文件路径,也不修改笔记内容。
|
|
30
|
+
|
|
31
|
+
请求通过 context.fetch 发送,失败抛出错误,不返回空地址或吞掉失败。停用插件会取消上下文请求并拒绝迟到结果。插件在渲染进程执行,不使用 Node 模块或额外后台入口。
|
|
32
|
+
|
|
33
|
+
返回地址必须长期可引用;不要返回短期签名 URL。桶或仓库的公开读取策略由用户配置,上传成功不等于匿名用户可以访问。不要自动修改用户桶权限。需要自定义公开域名时由插件设置提供,按对象路径返回完整 URL。
|
|
34
|
+
|
|
35
|
+
完成后验证:本地模式不调用插件、远端上传成功及失败、保存配置、停用、独立窗口上传、重启恢复。README.md 应说明如何配置公开访问和常见服务商错误。
|
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@ import type { PluginEditorExtension } from "./editor";
|
|
|
8
8
|
import type { MarkdownCodec } from "../../markdown/src/index";
|
|
9
9
|
import type { PluginSettings } from "./settings";
|
|
10
10
|
import type { PluginSync } from "./sync";
|
|
11
|
+
import type { PluginUpload } from "./upload";
|
|
12
|
+
import type { PluginTTS } from "./tts";
|
|
11
13
|
import type { PluginSidebar } from "./sidebar";
|
|
12
14
|
import type { PluginExcerpts, PluginMaterials } from "./excerpts";
|
|
13
15
|
import type { PluginMCP } from "./mcp";
|
|
@@ -39,6 +41,8 @@ export interface PluginContext {
|
|
|
39
41
|
readonly editor: PluginEditor;
|
|
40
42
|
readonly settings: PluginSettings;
|
|
41
43
|
readonly sync: PluginSync;
|
|
44
|
+
readonly upload: PluginUpload;
|
|
45
|
+
readonly tts: PluginTTS;
|
|
42
46
|
readonly sidebar: PluginSidebar;
|
|
43
47
|
readonly excerpts: PluginExcerpts;
|
|
44
48
|
readonly materials: PluginMaterials;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { PluginDefinition } from "./contract";
|
|
2
|
+
export type * from "./upload";
|
|
3
|
+
export type * from "./tts";
|
|
2
4
|
export type { JsonValue, Disposable, PluginStorage, PluginCommand, PluginContext, PluginInstance, PluginDefinition, } from "./contract";
|
|
3
5
|
export type { PluginSettings, PluginSettingsDefinition, PluginSettingsProps, PluginSettingsHandle, } from "./settings";
|
|
4
6
|
export * from "./editor";
|
|
@@ -3,6 +3,22 @@ import type { Disposable, PluginContext } from "./index";
|
|
|
3
3
|
import type { JsonValue } from "./json";
|
|
4
4
|
export interface PluginSettingsProps {
|
|
5
5
|
readonly context: PluginContext;
|
|
6
|
+
readonly ttsConfig?: {
|
|
7
|
+
readonly instanceId: string;
|
|
8
|
+
readonly value: JsonValue;
|
|
9
|
+
readonly models: readonly {
|
|
10
|
+
id: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
}[];
|
|
13
|
+
save(value: JsonValue, models: readonly {
|
|
14
|
+
id: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
}[]): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
readonly uploadConfig?: {
|
|
19
|
+
readonly value: JsonValue;
|
|
20
|
+
save(value: JsonValue): Promise<void>;
|
|
21
|
+
};
|
|
6
22
|
readonly syncConfig?: {
|
|
7
23
|
readonly value: JsonValue;
|
|
8
24
|
save(value: JsonValue): Promise<void>;
|
|
@@ -12,8 +28,8 @@ export interface PluginSettingsDefinition {
|
|
|
12
28
|
id: string;
|
|
13
29
|
title: string;
|
|
14
30
|
description?: string;
|
|
15
|
-
/**
|
|
16
|
-
target?: "sync";
|
|
31
|
+
/** 提供方配置表单挂载到对应宿主设置;普通插件设置省略。 */
|
|
32
|
+
target?: "sync" | "upload" | "tts";
|
|
17
33
|
component: ComponentType<PluginSettingsProps>;
|
|
18
34
|
}
|
|
19
35
|
export interface PluginSettingsHandle extends Disposable {
|
|
@@ -21,6 +37,6 @@ export interface PluginSettingsHandle extends Disposable {
|
|
|
21
37
|
open(): Promise<void>;
|
|
22
38
|
}
|
|
23
39
|
export interface PluginSettings {
|
|
24
|
-
/**
|
|
40
|
+
/** 分区随本次激活回收;提供方保存使用配置属性,普通设置使用 context.storage。 */
|
|
25
41
|
register(definition: PluginSettingsDefinition): PluginSettingsHandle;
|
|
26
42
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Disposable, JsonValue } from "./contract";
|
|
2
|
+
import type { UploadFile } from "./upload";
|
|
3
|
+
export interface TTSVoice {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: "system" | "cloned" | "custom";
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TTSSynthesizeOptions {
|
|
10
|
+
speed?: number;
|
|
11
|
+
volume?: number;
|
|
12
|
+
pitch?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface TTSSynthesizeRequest {
|
|
15
|
+
text: string;
|
|
16
|
+
voiceId: string;
|
|
17
|
+
options?: TTSSynthesizeOptions;
|
|
18
|
+
}
|
|
19
|
+
export interface TTSAudio {
|
|
20
|
+
audio: Uint8Array;
|
|
21
|
+
mime: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TTSCloneRequest {
|
|
24
|
+
file: UploadFile;
|
|
25
|
+
requestedId?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TTSInstance {
|
|
29
|
+
readonly textInstructions?: string;
|
|
30
|
+
getVoices(signal: AbortSignal): Promise<TTSVoice[]>;
|
|
31
|
+
synthesize(request: TTSSynthesizeRequest, signal: AbortSignal): Promise<TTSAudio>;
|
|
32
|
+
cloneVoice?(request: TTSCloneRequest, signal: AbortSignal): Promise<TTSVoice>;
|
|
33
|
+
}
|
|
34
|
+
export interface TTSProviderDefinition {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
/** 每次任务固定配置和模型,创建时不发网络请求。 */
|
|
38
|
+
create(config: JsonValue, modelId: string): TTSInstance;
|
|
39
|
+
}
|
|
40
|
+
export interface PluginTTS {
|
|
41
|
+
register(definition: TTSProviderDefinition): Disposable;
|
|
42
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Disposable, JsonValue } from "./contract";
|
|
2
|
+
export interface UploadFile {
|
|
3
|
+
/** 提供方收到宿主唯一命名后的文件;uploadRemote的调用者传原始文件名。 */
|
|
4
|
+
name: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
content: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
export interface UploadProviderDefinition {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
/** 返回可供正文直接引用的HTTP(S)地址,不返回临时签名URL。 */
|
|
12
|
+
upload(file: UploadFile, config: JsonValue, signal: AbortSignal): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
export interface PluginUpload {
|
|
15
|
+
register(definition: UploadProviderDefinition): Disposable;
|
|
16
|
+
/** 使用用户当前远端配置;本地模式明确失败,不自动选择其他存储。 */
|
|
17
|
+
uploadRemote(file: UploadFile, options?: {
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
}
|