@xiongtao.xt/tau-plugins 0.17.0 → 0.18.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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
- 新增 `context.images.register`,按账号配置与模型创建图片生成或编辑实例,返回图片字节和实际 MIME。
|
|
6
|
+
- 图片配置视图通过 `settings.register({ target: "images" })` 注册,接收当前账号的 `imageConfig`;保存按实例隔离,不使用共享凭据。
|
|
7
|
+
- 图片插件在主窗口渲染进程执行,跨窗口调用、上传、取消和停用共用任务生命周期;保留 TTS 与上传等既有接口。
|
|
8
|
+
|
|
3
9
|
## 0.17.0
|
|
4
10
|
|
|
5
11
|
- 新增通用行内源码 API:useInlineSource、insertInlineSource 和 InlineSourceBoundary,复用宿主 Slate 实例与浏览器行内边界处理。
|
package/IMAGES.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 图片生成与编辑提供方
|
|
2
|
+
|
|
3
|
+
需要 SDK 0.18.0 和支持图片插件接口的客户端。通过 `context.images.register({ id: context.pluginId, name, create })` 注册,每个插件一个提供方,可由用户配置多个账号实例。
|
|
4
|
+
|
|
5
|
+
`create(config, modelId)` 同步创建任务实例,不发网络请求。配置结构由插件解释和校验,不读取宿主 store,也不将账号凭据放进插件共享 storage。实例至少实现一个方法:
|
|
6
|
+
|
|
7
|
+
- `generate({ prompt, options? }, signal)`:文本生成图片。
|
|
8
|
+
- `edit({ prompt, options?, images }, signal)`:基于一张或多张参考图编辑。
|
|
9
|
+
|
|
10
|
+
输入图片为 `{ name, mimeType, content: Uint8Array }`。输出为相同结构的数组,可附加 `revisedPrompt`。宿主支持 PNG/JPEG/WebP,单次最多 16 张、输入和输出总大小分别不超过 128 MiB。提供方返回临时 URL 时自行下载为字节,下载时不要将 API 凭据自动传给其他域名。
|
|
11
|
+
|
|
12
|
+
`options` 包含 `size/quality/outputFormat/background/count`,仅在显式传入时映射到服务商请求。无法等价支持的参数应报告错误,不忽略、不隐式多次调用凑数量。协议、鉴权、超时、重试和轮询由插件负责;网络使用 `context.fetch` 并传入方法的 signal,轮询等待也响应取消。宿主负责文件解析、最终资源上传和正文插入。
|
|
13
|
+
|
|
14
|
+
配置视图通过 `context.settings.register({ id, title, target: "images", component })` 注册。组件接收 `PluginSettingsProps.imageConfig`:`instanceId`、`value`、`modelId`、`save(value, modelId)`。字段、布局、验证和错误提示由插件决定;保存失败保留草稿,成功后才提示已保存。模型标识也由插件表单填写。不要把正在编辑的账号误当成全局当前账号。
|
|
15
|
+
|
|
16
|
+
生成和编辑仍使用用户选择的同一个当前账号;不支持的方法不显示对应入口。停用、重载、切库或调用窗口退出会关闭任务,后续上传和保存不得接收迟到结果。取消不保证撤销远端已发生的任务或费用。图片插件不自动安装、启用或切换资源存储。
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import type { PluginSettings } from "./settings";
|
|
|
10
10
|
import type { PluginSync } from "./sync";
|
|
11
11
|
import type { PluginUpload } from "./upload";
|
|
12
12
|
import type { PluginTTS } from "./tts";
|
|
13
|
+
import type { PluginImages } from "./images";
|
|
13
14
|
import type { PluginSidebar } from "./sidebar";
|
|
14
15
|
import type { PluginExcerpts, PluginMaterials } from "./excerpts";
|
|
15
16
|
import type { PluginMCP } from "./mcp";
|
|
@@ -44,6 +45,7 @@ export interface PluginContext {
|
|
|
44
45
|
readonly sync: PluginSync;
|
|
45
46
|
readonly upload: PluginUpload;
|
|
46
47
|
readonly tts: PluginTTS;
|
|
48
|
+
readonly images: PluginImages;
|
|
47
49
|
readonly sidebar: PluginSidebar;
|
|
48
50
|
readonly excerpts: PluginExcerpts;
|
|
49
51
|
readonly materials: PluginMaterials;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Disposable, JsonValue } from "./contract";
|
|
2
|
+
export interface ImageFile {
|
|
3
|
+
name: string;
|
|
4
|
+
mimeType: string;
|
|
5
|
+
content: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
export interface ImageOptions {
|
|
8
|
+
size?: string;
|
|
9
|
+
quality?: string;
|
|
10
|
+
outputFormat?: "png" | "jpeg" | "webp";
|
|
11
|
+
background?: string;
|
|
12
|
+
count?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ImageGenerateRequest {
|
|
15
|
+
prompt: string;
|
|
16
|
+
options?: ImageOptions;
|
|
17
|
+
}
|
|
18
|
+
export interface ImageEditRequest extends ImageGenerateRequest {
|
|
19
|
+
images: readonly ImageFile[];
|
|
20
|
+
}
|
|
21
|
+
export interface GeneratedImage extends ImageFile {
|
|
22
|
+
revisedPrompt?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ImageInstance {
|
|
25
|
+
generate?(request: ImageGenerateRequest, signal: AbortSignal): Promise<GeneratedImage[]>;
|
|
26
|
+
edit?(request: ImageEditRequest, signal: AbortSignal): Promise<GeneratedImage[]>;
|
|
27
|
+
}
|
|
28
|
+
export interface ImageProviderDefinition {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
create(config: JsonValue, modelId: string): ImageInstance;
|
|
32
|
+
}
|
|
33
|
+
export interface PluginImages {
|
|
34
|
+
register(definition: ImageProviderDefinition): Disposable;
|
|
35
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PluginDefinition } from "./contract";
|
|
2
2
|
export type * from "./upload";
|
|
3
3
|
export type * from "./tts";
|
|
4
|
+
export type * from "./images";
|
|
4
5
|
export type { JsonValue, Disposable, PluginStorage, PluginCommand, PluginContext, PluginInstance, PluginDefinition, } from "./contract";
|
|
5
6
|
export type { PluginSettings, PluginSettingsDefinition, PluginSettingsProps, PluginSettingsHandle, } from "./settings";
|
|
6
7
|
export * from "./editor";
|
|
@@ -3,6 +3,12 @@ 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 imageConfig?: {
|
|
7
|
+
readonly instanceId: string;
|
|
8
|
+
readonly value: JsonValue;
|
|
9
|
+
readonly modelId: string;
|
|
10
|
+
save(value: JsonValue, modelId: string): Promise<void>;
|
|
11
|
+
};
|
|
6
12
|
readonly ttsConfig?: {
|
|
7
13
|
readonly instanceId: string;
|
|
8
14
|
readonly value: JsonValue;
|
|
@@ -29,7 +35,7 @@ export interface PluginSettingsDefinition {
|
|
|
29
35
|
title: string;
|
|
30
36
|
description?: string;
|
|
31
37
|
/** 提供方配置表单挂载到对应宿主设置;普通插件设置省略。 */
|
|
32
|
-
target?: "sync" | "upload" | "tts";
|
|
38
|
+
target?: "sync" | "upload" | "tts" | "images";
|
|
33
39
|
component: ComponentType<PluginSettingsProps>;
|
|
34
40
|
}
|
|
35
41
|
export interface PluginSettingsHandle extends Disposable {
|