dsh-model-think-level 2.2.0 → 2.3.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/README.md +7 -5
- package/lib/client/ConfigPane.d.ts +4 -2
- package/lib/client/image-config-client.d.ts +6 -0
- package/lib/client/injection/image-card.d.ts +19 -7
- package/lib/client/locales.d.ts +2 -0
- package/lib/client/order-sync.d.ts +15 -4
- package/lib/client/provider-enabled.d.ts +11 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client.js +16 -5
- package/lib/client.js.map +3 -3
- package/lib/image/deadline.d.ts +13 -0
- package/lib/image/generate.d.ts +8 -5
- package/lib/image/tool.d.ts +12 -3
- package/lib/index.js +348 -116
- package/lib/index.js.map +4 -4
- package/lib/order-store.d.ts +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,11 +36,13 @@ DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行
|
|
|
36
36
|
插件不拦截任何对话请求:被标记为「生图」的模型只用来**生图**,对话模型需要图片时调用插件注册的**原生工具** `generate_image`(参数:`prompt` 必填,可选 `model`、`size`、`quality`、`n`、`reference_images` 本地路径、`reference_attachments` 对话附件 ID、`path` 落盘位置)。工具随插件进程内注册,**无需安装、无需重启配置**:DSH 启动即注册,图片以附件形式直接出现在对话里,不经过聊天 API。若与其他插件注册的 `generate_image` 撞名,工具自动改名为 `dsh_image_generate` 并在日志里说明。
|
|
37
37
|
|
|
38
38
|
- 多图:上游按 `n` 返回的每一张都会落盘、存为附件并全部附到对话(上游少给就少收,不会编造)。
|
|
39
|
+
- 助手最终回复:工具描述、会话系统提示与成功结果都要求助手**逐张把图片直接嵌进最终回复**,不能只说「已生成」或依赖工具卡片。成功结果提供使用真实落盘路径、可直接复制的 Markdown 嵌图语句,Windows 路径转为 `/`,含空格的路径用尖括号包裹;无需重新寻找图片、无需修改尺寸/质量参数,也没有额外配置开关。
|
|
39
40
|
- 改图(图生图):`reference_images` 填本地路径,`reference_attachments` 填对话内图片的附件 ID(`sha256:…` 或裸摘要均可,两者可混用);任何参考图非空即走 `/images/edits`。
|
|
40
|
-
- 「生图服务」配置页负责:列出所有被标记的模型、逐个测试端点。第一行选**默认参数**(尺寸 / 质量 / 张数,以及**超时**——下拉 5 / 10 / 15 / 30 / 60 分钟,默认 5
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
41
|
+
- 「生图服务」配置页负责:列出所有被标记的模型、逐个测试端点。第一行选**默认参数**(尺寸 / 质量 / 张数,以及**超时**——下拉 5 / 10 / 15 / 30 / 60 分钟,默认 5 分钟,一次调用的凭据读取、参考图读取、全部参数回退、响应体/图片下载和附件保存共享这个总预算;重试不重新计时),第二行用下拉列表选**默认生图模型**(未设默认时显示「未设置」)。尺寸/质量/张数只在第一行选一处生效,模型行只保留「测试」和「试一张」两个动作。
|
|
42
|
+
- 超时或停止会结束插件自己的等待,并向支持取消的依赖传递信号;忽略信号的外部操作或已被上游接受的生图任务不保证撤销,同步解码/文件操作也不能被抢占。热重载只更新后续调用,不会替换已经运行中的旧调用。
|
|
43
|
+
- 「生图服务」配置页只负责默认参数与默认生图模型,不再有独立的工具状态卡;工具注册失败时卡片顶部会直接显示宿主给的那句原因(`GET /dsh-model-think-level/image-config` 的 `tool.error`),成功注册时不显示任何提示。
|
|
44
|
+
- 文本对话模型收到图片结果时会自动降级为一行占位文本(宿主行为),因此**对话模型不需要声明图片输入**也能安全调用;生成的图片始终在对话卡片里可见。卡片按 `generate_image` 这个名字立刻注册,之后若宿主报了别的名字(撞名回落到 fallback 的情况)再跟着改名——所以它不依赖「页面打开时工具已经注册成功」;但插件的前端 bundle 只在页面加载时取一次,改完插件要刷新页面(或重开窗口)才会加载新的卡片代码。
|
|
45
|
+
- 从 2.0.3 及更早版本升级:插件启动时会自动移除旧版「生图 MCP」在 `cordis.patch.yml` 里留下的条目(带 `.bak` 备份),重启后旧的 `dsh-image` MCP 服务不再被拉起。带旧版标记注释的块和没有标记的裸 `- insert:` / `- id: dsh-image-mcp` 条目都能清掉;同一块里还插着别人的插件条目时不动它。
|
|
44
46
|
|
|
45
47
|
### 指纹检测
|
|
46
48
|
|
|
@@ -70,7 +72,7 @@ DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行
|
|
|
70
72
|
- 每把密钥行首有一个圆形对勾开关:亮起表示参与路由,灰色表示暂停使用。停用只是把密钥移出分流池,别名、模型清单与协议指定全部保留,重新点亮即恢复;最后一把启用中的密钥不允许停用(否则请求会回落到适配器自身的单密钥路径,仍然用刚被停用的那把签名)。
|
|
71
73
|
- 「添加另一个密钥」会优先**填回已经列出、但凭据库里还没有值的引用**,而不是再铸一个新名字。这条是为跨机同步准备的:配置从另一台电脑同步过来时,点名的 `XXX_API_KEY_2` 在这台还没有值,直接填进去两台的名字就一致了;若改成铸 `XXX_API_KEY_3`,名字会分叉,旧名字还会在面板上留一行「未存储」的残行。填回时别名、模型清单与协议指定都保留(只补值,不改标签)。库里已有值的引用不会被顶掉——那种情况下仍然铸新名字。
|
|
72
74
|
- 插件自身元数据保存在 DSH 数据目录的 `dsh-model-think-level/key-index.json`,只记录引用、别名、模型清单、协议指定、各协议族地址与启停状态,绝不保存密钥值(密钥值始终由 DSH 凭据库保管)。
|
|
73
|
-
-
|
|
75
|
+
- 模型页拖出来的**供应商排序、各供应商的模型排序,以及供应商启用开关**也会镜像到同目录的 `ui-order.json`:页面上每次改动照旧即时生效(实时状态在 localStorage),插件在后台防抖写入这个文件,并按「最后写入者胜」与本地状态对齐(文件更新就采纳文件,本地更新就回写文件)。采纳文件里的停用集合时会**写回 localStorage**,所以刷新、重开浏览器之后仍是文件那一份,不会出现「这台机器看着同步好了、一刷新又变回去并把它推回文件」;每次改动都会拿到严格递增的时间戳,重启后同一毫秒内的多次改动也不会互相覆盖。文件比本页新时会立即采纳,本页的时间戳不更新时就**拒绝写入**(服务器回 409 并把赢得的那份文档带回来),旧标签页不会把别人的新顺序或新开关回滚回去。页面每分钟、以及切回标签页/窗口获得焦点时重新拉取一次,另一台电脑的改动不用重启就能出现。文件里只有供应商路由、模型 id 和停用名单,不含任何密钥,可以放心交给同步盘/网盘携带,实现多台机器的排序与启停同步。
|
|
74
76
|
- 新增供应商的表单在官方密钥输入框下方也带这套卡片式密钥列表:草稿密钥先暂存在本页,点「创建」供应商落库后自动写入,第一把草稿密钥自动成为启用密钥。挂载前已敲进官方输入框的值保留在原处——官方框保存的仍是那把密钥,下方的列表只收之后新增的。刷新页面会丢弃草稿,与表单自身行为一致;若 id 撞上已存在的供应商,草稿不会写入对方。
|
|
75
77
|
|
|
76
78
|
### 按密钥切换协议与多地址
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* One card today, 「生图」, per the design's card-list shape with room for
|
|
7
7
|
* more: the params row and the default-model select under it. The marked
|
|
8
8
|
* models surface as that select's options; marking itself lives on the Models
|
|
9
|
-
* page (展开模型行 → 输入模态 → 勾选「生图」), so the pane keeps no list
|
|
10
|
-
* no empty state
|
|
9
|
+
* page (展开模型行 → 输入模态 → 勾选「生图」), so the pane keeps no list and
|
|
10
|
+
* no empty state of its own. The one status line it does carry is the host's
|
|
11
|
+
* verbatim reason when `tools.register` threw: a silently missing native tool
|
|
12
|
+
* is otherwise indistinguishable from a model that simply never asks.
|
|
11
13
|
*
|
|
12
14
|
* Esc / backdrop / ✕ close it; the wrapper unmounts and the page keeps
|
|
13
15
|
* whatever the pane saved.
|
|
@@ -11,6 +11,12 @@ export type TransportAnswer<T> = {
|
|
|
11
11
|
export interface ImageToolView {
|
|
12
12
|
registered: boolean;
|
|
13
13
|
name: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Why the registration failed, when it did: the host records the error the
|
|
16
|
+
* `tools.register` call threw, so a broken schema is readable instead of
|
|
17
|
+
* silent. Absent while the tool is registered or never attempted.
|
|
18
|
+
*/
|
|
19
|
+
error?: string;
|
|
14
20
|
}
|
|
15
21
|
/** GET image-config 的应答体(结构声明:浏览器不 import host-only 模块)。 */
|
|
16
22
|
export interface ImageConfigView {
|
|
@@ -12,10 +12,15 @@
|
|
|
12
12
|
* attachment pipeline. Declaring `tool.call.images` under `children` is what
|
|
13
13
|
* authorizes the entry's `renderSlot` to dispatch it.
|
|
14
14
|
*
|
|
15
|
-
* The card is
|
|
16
|
-
*
|
|
17
|
-
* `generate_image` key — the host then registers this plugin's tool under
|
|
15
|
+
* The card is keyed by the tool name the HOST reports (the config route's
|
|
16
|
+
* `tool.name`), because a dsh-image-gen install can own the plain
|
|
17
|
+
* `generate_image` key — the host then registers this plugin's tool under a
|
|
18
18
|
* fallback name, and the card must follow the tool, never the wishful name.
|
|
19
|
+
* That host fact is a RECONCILIATION, not a precondition: the entry is first
|
|
20
|
+
* registered under the plain `IMAGE_TOOL_KEY` and re-keyed when the route
|
|
21
|
+
* names a different tool. A page loaded while the tool was still unregistered
|
|
22
|
+
* (the route reported `name: null`) would otherwise never register a card at
|
|
23
|
+
* all, and the generic row shows no image for any tool but `read_image`.
|
|
19
24
|
*
|
|
20
25
|
* @module dsh-model-think-level/client/injection/image-card
|
|
21
26
|
*/
|
|
@@ -43,6 +48,7 @@ interface ToolBlockLike {
|
|
|
43
48
|
readonly text?: string;
|
|
44
49
|
readonly attachment?: ImageRefLike['attachment'];
|
|
45
50
|
}[];
|
|
51
|
+
/** Legacy carrier some older result records used; `content` wins when both exist. */
|
|
46
52
|
readonly resultView?: {
|
|
47
53
|
readonly content?: readonly {
|
|
48
54
|
readonly type: string;
|
|
@@ -76,10 +82,16 @@ export declare function ImageToolCard(props: ImageCardProps & {
|
|
|
76
82
|
t: Translate;
|
|
77
83
|
}): ReactNode;
|
|
78
84
|
/**
|
|
79
|
-
* Register the image card
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
85
|
+
* Register the image card, then follow the tool to whatever name the host
|
|
86
|
+
* actually gave it.
|
|
87
|
+
*
|
|
88
|
+
* The entry is registered under `IMAGE_TOOL_KEY` right away rather than waiting
|
|
89
|
+
* for the config route: the route only names a tool that is ALREADY registered,
|
|
90
|
+
* so a page loaded before the host's `tools.register` succeeded would sit
|
|
91
|
+
* forever without a card — which is exactly the silent failure this card
|
|
92
|
+
* exists to avoid. When the route then reports a different name (a dsh-image-gen
|
|
93
|
+
* install owns the plain key, so the host renamed this tool), the entry is
|
|
94
|
+
* disposed and re-registered under the reported name.
|
|
83
95
|
*/
|
|
84
96
|
export declare function registerImageCard(ctx: ClientContext, t: Translate): void;
|
|
85
97
|
export {};
|
package/lib/client/locales.d.ts
CHANGED
|
@@ -241,6 +241,8 @@ export declare const en: {
|
|
|
241
241
|
imagegenTimeoutMinutes: string;
|
|
242
242
|
imagegenTimeoutHint: string;
|
|
243
243
|
imagegenCardRunning: string;
|
|
244
|
+
imagegenToolMissing: string;
|
|
245
|
+
imagegenToolMissingWhy: string;
|
|
244
246
|
};
|
|
245
247
|
/** The plugin's locale key union. */
|
|
246
248
|
export type BreKey = keyof typeof en;
|
|
@@ -31,6 +31,13 @@ export declare const ORDER_SAVED_AT_KEY = "dsh-model-think-level.order-saved-at"
|
|
|
31
31
|
* usually still lands (and `flushOrderSync` covers the rest).
|
|
32
32
|
*/
|
|
33
33
|
export declare const ORDER_PUSH_DEBOUNCE_MS = 400;
|
|
34
|
+
/**
|
|
35
|
+
* How often a visible page asks the host for the document again. The file is
|
|
36
|
+
* written by whichever machine synced last, so a page that only pulled at boot
|
|
37
|
+
* would keep showing the old order (and the old switches) until a reload. One
|
|
38
|
+
* GET a minute per open tab is cheap; `focus`/`visibilitychange` pull sooner.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ORDER_POLL_MS = 60000;
|
|
34
41
|
/** The wire shape of the order document (declared here; the host parses its own). */
|
|
35
42
|
export interface OrderDocumentView {
|
|
36
43
|
savedAt: number;
|
|
@@ -52,12 +59,16 @@ export interface OrderDocumentView {
|
|
|
52
59
|
*/
|
|
53
60
|
export declare function flushOrderSync(): void;
|
|
54
61
|
/**
|
|
55
|
-
* Boot pass
|
|
56
|
-
* acted on (adoption is synchronous; a push is
|
|
62
|
+
* Boot pass (and every later pull): fetch the file and arbitrate. Resolves once
|
|
63
|
+
* the decision has been acted on (adoption is synchronous; a push is
|
|
64
|
+
* fire-and-forget).
|
|
57
65
|
*/
|
|
58
66
|
export declare function reconcileOrderSync(): Promise<void>;
|
|
59
67
|
/**
|
|
60
|
-
* Start the sync: the boot pass
|
|
61
|
-
*
|
|
68
|
+
* Start the sync: the boot pass, the change subscription, and the pulls that
|
|
69
|
+
* make another machine's write show up without a reload — a visible page on a
|
|
70
|
+
* timer, plus `focus`/`visibilitychange` for the moment someone comes back to
|
|
71
|
+
* the tab. Returns the disposer; a disposed sync stops pushing, stops pulling
|
|
72
|
+
* and ignores answers already in flight.
|
|
62
73
|
*/
|
|
63
74
|
export declare function startOrderSync(): () => void;
|
|
@@ -26,5 +26,16 @@ export declare function isProviderEnabled(id: string): boolean;
|
|
|
26
26
|
export declare function setProviderEnabled(id: string, enabled: boolean): void;
|
|
27
27
|
/** Apply an external (cross-tab) value without writing it back. */
|
|
28
28
|
export declare function syncDisabledProviders(next: readonly string[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* Take a set that came from the shared order document, and persist it.
|
|
31
|
+
*
|
|
32
|
+
* This is the one path where the value is not a user action in this tab but the
|
|
33
|
+
* file's answer for every machine — the boot arbitrate's adoption. It must land
|
|
34
|
+
* in localStorage exactly like a switch would: `syncDisabledProviders` only
|
|
35
|
+
* updates the running page, so after a reload the pre-adoption set came back and
|
|
36
|
+
* the next reconcile pushed it over the file. That was the disabled set's
|
|
37
|
+
* "synced on one machine only" bug.
|
|
38
|
+
*/
|
|
39
|
+
export declare function adoptDisabledProviders(next: readonly string[]): void;
|
|
29
40
|
/** Listen for a switch, from this tab or another; returns the unsubscribe. */
|
|
30
41
|
export declare function subscribeDisabledProviders(listener: () => void): () => void;
|