@xiongtao.xt/tau-plugins 0.12.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 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 CHANGED
@@ -2,16 +2,18 @@
2
2
 
3
3
  需要 SDK 0.12.0 和包含资源上传插件能力的 Tau 0.59.0 客户端。上传返回正文可直接引用的 HTTP(S) 地址;数据库和资源目录同步使用 SYNC.md 的另一套接口。
4
4
 
5
+ SDK 0.13.0 增加第三个signal参数与context.upload.uploadRemote(file,{signal})。提供方应将signal合并进context.fetch请求;调用方使用uploadRemote时,本地目标明确报错,不自动更换存储。signal取消会结束等待并通知提供方,不代表撤回已经上传的远端对象。
6
+
5
7
  在 activate 中注册提供方:
6
8
 
7
9
  ```tsx
8
10
  context.upload.register({
9
11
  id: context.pluginId,
10
12
  name: "我的资源存储",
11
- async upload(file, config) {
13
+ async upload(file, config, signal) {
12
14
  // 用 context.fetch 请求服务商,认证与路径由本次 config 决定。
13
15
  // file.name 已唯一命名,file.mimeType 是 MIME,file.content 为 Uint8Array。
14
- return uploadToStorage(context.fetch, file, config);
16
+ return uploadToStorage(context.fetch, file, config, signal);
15
17
  },
16
18
  });
17
19
  context.settings.register({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@ import type { MarkdownCodec } from "../../markdown/src/index";
9
9
  import type { PluginSettings } from "./settings";
10
10
  import type { PluginSync } from "./sync";
11
11
  import type { PluginUpload } from "./upload";
12
+ import type { PluginTTS } from "./tts";
12
13
  import type { PluginSidebar } from "./sidebar";
13
14
  import type { PluginExcerpts, PluginMaterials } from "./excerpts";
14
15
  import type { PluginMCP } from "./mcp";
@@ -41,6 +42,7 @@ export interface PluginContext {
41
42
  readonly settings: PluginSettings;
42
43
  readonly sync: PluginSync;
43
44
  readonly upload: PluginUpload;
45
+ readonly tts: PluginTTS;
44
46
  readonly sidebar: PluginSidebar;
45
47
  readonly excerpts: PluginExcerpts;
46
48
  readonly materials: PluginMaterials;
@@ -1,5 +1,6 @@
1
1
  import type { PluginDefinition } from "./contract";
2
2
  export type * from "./upload";
3
+ export type * from "./tts";
3
4
  export type { JsonValue, Disposable, PluginStorage, PluginCommand, PluginContext, PluginInstance, PluginDefinition, } from "./contract";
4
5
  export type { PluginSettings, PluginSettingsDefinition, PluginSettingsProps, PluginSettingsHandle, } from "./settings";
5
6
  export * from "./editor";
@@ -3,6 +3,18 @@ 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
+ };
6
18
  readonly uploadConfig?: {
7
19
  readonly value: JsonValue;
8
20
  save(value: JsonValue): Promise<void>;
@@ -16,8 +28,8 @@ export interface PluginSettingsDefinition {
16
28
  id: string;
17
29
  title: string;
18
30
  description?: string;
19
- /** 同步提供方的配置表单挂载到宿主同步设置。 */
20
- target?: "sync" | "upload";
31
+ /** 提供方配置表单挂载到对应宿主设置;普通插件设置省略。 */
32
+ target?: "sync" | "upload" | "tts";
21
33
  component: ComponentType<PluginSettingsProps>;
22
34
  }
23
35
  export interface PluginSettingsHandle extends Disposable {
@@ -25,6 +37,6 @@ export interface PluginSettingsHandle extends Disposable {
25
37
  open(): Promise<void>;
26
38
  }
27
39
  export interface PluginSettings {
28
- /** 分区随本次激活回收,保存使用 context.storage。 */
40
+ /** 分区随本次激活回收;提供方保存使用配置属性,普通设置使用 context.storage。 */
29
41
  register(definition: PluginSettingsDefinition): PluginSettingsHandle;
30
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
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Disposable, JsonValue } from "./contract";
2
2
  export interface UploadFile {
3
- /** 宿主已完成压缩和唯一命名,插件只负责追加远端路径前缀。 */
3
+ /** 提供方收到宿主唯一命名后的文件;uploadRemote的调用者传原始文件名。 */
4
4
  name: string;
5
5
  mimeType: string;
6
6
  content: Uint8Array;
@@ -9,8 +9,12 @@ export interface UploadProviderDefinition {
9
9
  id: string;
10
10
  name: string;
11
11
  /** 返回可供正文直接引用的HTTP(S)地址,不返回临时签名URL。 */
12
- upload(file: UploadFile, config: JsonValue): Promise<string>;
12
+ upload(file: UploadFile, config: JsonValue, signal: AbortSignal): Promise<string>;
13
13
  }
14
14
  export interface PluginUpload {
15
15
  register(definition: UploadProviderDefinition): Disposable;
16
+ /** 使用用户当前远端配置;本地模式明确失败,不自动选择其他存储。 */
17
+ uploadRemote(file: UploadFile, options?: {
18
+ signal?: AbortSignal;
19
+ }): Promise<string>;
16
20
  }