@dickpy/dsh-imagegen 1.2.1 → 1.2.2
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/README.md +7 -7
- package/docs/images/agent-chat-poster-workflow.png +0 -0
- package/lib/client.js +407 -226
- package/lib/client.js.map +1 -1
- package/lib/index.js +71 -40
- package/package.json +3 -2
- package/src/agent-image-tools.ts +68 -41
- package/src/client/image-toolview.module.css +73 -0
- package/src/client/image-toolview.tsx +158 -0
- package/src/client/index.ts +13 -9
- package/src/index.ts +3 -2
- package/src/protocol.ts +1 -1
package/src/client/index.ts
CHANGED
|
@@ -23,8 +23,9 @@ import { tt } from './helpers.ts'
|
|
|
23
23
|
import { en, zh, type ImageGenKey } from './locales.ts'
|
|
24
24
|
import { mountPanel } from './mount.tsx'
|
|
25
25
|
import { mountSidebarEntry } from './sidebar-entry.ts'
|
|
26
|
-
import { ImageGenSettingsCard, ImageGenSettingsCardController } from './SettingsCard.tsx'
|
|
27
|
-
import { bindImageGenScope, type ImageGenScope } from './settings-scope.ts'
|
|
26
|
+
import { ImageGenSettingsCard, ImageGenSettingsCardController } from './SettingsCard.tsx'
|
|
27
|
+
import { bindImageGenScope, type ImageGenScope } from './settings-scope.ts'
|
|
28
|
+
import { registerImageToolviews, type ImageToolViewOwnerProps } from './image-toolview.tsx'
|
|
28
29
|
|
|
29
30
|
/** Locale namespace this plugin owns. */
|
|
30
31
|
const NS = 'dsh-imagegen'
|
|
@@ -35,7 +36,7 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
35
36
|
'dsh-imagegen': ImageGenKey
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
interface SlotMap {
|
|
39
|
+
interface SlotMap {
|
|
39
40
|
/**
|
|
40
41
|
* The official plugin-configuration slot the Settings → Plugins →
|
|
41
42
|
* Configurable tab declares and renders. This card registers there as its
|
|
@@ -44,9 +45,11 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
44
45
|
* same shape so this package can register without depending on the
|
|
45
46
|
* sibling UI package.
|
|
46
47
|
*/
|
|
47
|
-
'settings.plugin.item': { kind: 'keyed'; scope: 'root'; owner: ImageGenPluginItemOwnerProps }
|
|
48
|
-
|
|
49
|
-
}
|
|
48
|
+
'settings.plugin.item': { kind: 'keyed'; scope: 'root'; owner: ImageGenPluginItemOwnerProps }
|
|
49
|
+
/** Image-generation results render their durable image blocks inline. */
|
|
50
|
+
'tool.call.toolview': { kind: 'keyed'; scope: 'session'; owner: ImageToolViewOwnerProps }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
50
53
|
|
|
51
54
|
/** Owner share of a plugin card (the section supplies nothing). */
|
|
52
55
|
export interface ImageGenPluginItemOwnerProps {
|
|
@@ -55,14 +58,15 @@ export interface ImageGenPluginItemOwnerProps {
|
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/** Required services (fiber inject waiting — the runtime must be up first). */
|
|
58
|
-
export const inject = ['slots', 'locale', 'connection']
|
|
61
|
+
export const inject = ['slots', 'locale', 'connection', 'sessions']
|
|
59
62
|
|
|
60
63
|
/**
|
|
61
64
|
* Mount the studio, its sidebar entry, and the settings card.
|
|
62
65
|
* @param ctx - client root context (services: slots, locale, connection).
|
|
63
66
|
*/
|
|
64
|
-
export function apply(ctx: ClientContext): void {
|
|
65
|
-
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-imagegen: dictionaries')
|
|
67
|
+
export function apply(ctx: ClientContext): void {
|
|
68
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-imagegen: dictionaries')
|
|
69
|
+
registerImageToolviews(ctx)
|
|
66
70
|
|
|
67
71
|
const connection = ctx.get('connection') as ConnectionHandle | undefined
|
|
68
72
|
const loopback = connection?.isLoopback === true
|
package/src/index.ts
CHANGED
|
@@ -83,7 +83,7 @@ const DEFAULT_ALLOW_AGENT_IMAGE_GENERATION = true
|
|
|
83
83
|
const SECTION_ORDER = 150
|
|
84
84
|
|
|
85
85
|
/** Model-facing announcement: plugin presence, capabilities, and limits. */
|
|
86
|
-
export const IMAGEGEN_GUIDANCE = '本机已安装 dsh-imagegen 插件(DSH AI 生图):侧边栏「AI 生图」入口。能力:对接 OpenAI 兼容图像生成 API,模型由用户在「设置 → 插件 → AI 生图」中检测或手动配置的生图模型列表决定;支持文生图(/images/generations)与图生图(/images/edits,上传参考图,grok-imagine 模型按官方 JSON image_url 协议发送)。API 地址与密钥在 GUI 设置中配置,密钥仅存于本机设置文档;生成请求由本地宿主代理转发,结果以 base64 返回面板,可预览与下载。模型只能使用已配置的生图模型;模型出现在 /models 中不等于其网关原生支持生图协议,遇到 Qwen、Gemini 等非 OpenAI 生图协议时应如实说明上游兼容性。可一键把满意的图片加入「画廊」。内置「提示词模板库」(面板提示词框左下角「模板库」按钮):打包 awesome-gpt-image-2 的数百条提示词案例,可搜索、筛选与复用。Agent 可直接调用 `generate_image` 提交文生图,也可用 `edit_image`
|
|
86
|
+
export const IMAGEGEN_GUIDANCE = '本机已安装 dsh-imagegen 插件(DSH AI 生图):侧边栏「AI 生图」入口。能力:对接 OpenAI 兼容图像生成 API,模型由用户在「设置 → 插件 → AI 生图」中检测或手动配置的生图模型列表决定;支持文生图(/images/generations)与图生图(/images/edits,上传参考图,grok-imagine 模型按官方 JSON image_url 协议发送)。API 地址与密钥在 GUI 设置中配置,密钥仅存于本机设置文档;生成请求由本地宿主代理转发,结果以 base64 返回面板,可预览与下载。模型只能使用已配置的生图模型;模型出现在 /models 中不等于其网关原生支持生图协议,遇到 Qwen、Gemini 等非 OpenAI 生图协议时应如实说明上游兼容性。可一键把满意的图片加入「画廊」。内置「提示词模板库」(面板提示词框左下角「模板库」按钮):打包 awesome-gpt-image-2 的数百条提示词案例,可搜索、筛选与复用。Agent 可直接调用 `generate_image` 提交文生图,也可用 `edit_image` 图生图;默认保持工具调用等待直到任务完成,完成图片直接作为工具结果附件返回,不会额外伪造用户消息。若明确需要后台执行,可传 `wait_for_completion: false`,之后再用 `get_image_generation_task` 查询;不要反复轮询。限制:生成消耗上游 API 额度;图片内容由上游模型生成,可能不符合预期或包含不适宜内容;api_key 以明文存储在设置文档中;参考图会发送至所配置的 API 服务;模板库在线刷新与参考图首次加载需要访问 vibeui.top。用户提到「生图 / 绘画 / 生成图片 / 文生图 / 图生图 / 画廊 / 提示词模板」时即指本插件,请据此协作。'
|
|
87
87
|
|
|
88
88
|
/** Add the live allow-list so an Agent can honor a user's model choice. */
|
|
89
89
|
function guidanceFor(imageModels: string[]): string {
|
|
@@ -129,7 +129,8 @@ export function apply(ctx: Context, config?: Config): void {
|
|
|
129
129
|
|
|
130
130
|
// Browser endpoints and Agent tools share the exact same serial queue. This
|
|
131
131
|
// keeps image persistence, cancellation, and retries coherent across both
|
|
132
|
-
// entry points
|
|
132
|
+
// entry points; Agent tools wait for their task result by default and render
|
|
133
|
+
// images in the tool result instead of injecting a synthetic user message.
|
|
133
134
|
const runtime = new ImageGenerationRuntime(() => {
|
|
134
135
|
const value = resolve()
|
|
135
136
|
return { apiUrl: value.apiUrl, apiKey: value.apiKey }
|
package/src/protocol.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export const IMAGEGEN_SETTINGS_NAMESPACE = 'dsh-imagegen'
|
|
9
9
|
|
|
10
10
|
/** Published package version shared by the host updater and the client UI. */
|
|
11
|
-
export const PLUGIN_VERSION = '1.2.
|
|
11
|
+
export const PLUGIN_VERSION = '1.2.2'
|
|
12
12
|
|
|
13
13
|
/** Same-origin route family (loopback-only, mirroring the dsh-ssh fence). */
|
|
14
14
|
export const SETTINGS_API = {
|