dsh-model-think-level 2.1.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 -4
- package/lib/autofill.d.ts +20 -2
- package/lib/client/ConfigPane.d.ts +6 -6
- package/lib/client/image-config-client.d.ts +6 -23
- package/lib/client/index.d.ts +1 -0
- package/lib/client/injection/compat-guard.d.ts +33 -0
- package/lib/client/injection/image-card.d.ts +19 -7
- package/lib/client/injection/key-prefetch.d.ts +13 -1
- package/lib/client/injection/model-order-drag.d.ts +1 -1
- package/lib/client/injection/models-page-editor.d.ts +1 -2
- package/lib/client/injection/models-page-mutation.d.ts +6 -0
- package/lib/client/injection/provider-balance.d.ts +12 -1
- package/lib/client/injection/provider-delete-seat.d.ts +4 -1
- package/lib/client/injection/provider-disabled-group.d.ts +4 -1
- package/lib/client/injection/provider-order-drag.d.ts +5 -1
- package/lib/client/injection/provider-toggle.d.ts +4 -1
- package/lib/client/key-manager-client.d.ts +21 -9
- package/lib/client/locales.d.ts +7 -25
- package/lib/client/model-order.d.ts +9 -0
- package/lib/client/order-sync.d.ts +74 -0
- package/lib/client/provider-enabled.d.ts +11 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client.js +22 -166
- package/lib/client.js.map +4 -4
- package/lib/constants.d.ts +15 -7
- package/lib/image/command.d.ts +1 -1
- 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 +848 -334
- package/lib/index.js.map +4 -4
- package/lib/key-index.d.ts +11 -0
- package/lib/knowledge.d.ts +26 -0
- package/lib/order-store.d.ts +100 -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,6 +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 凭据库保管)。
|
|
75
|
+
- 模型页拖出来的**供应商排序、各供应商的模型排序,以及供应商启用开关**也会镜像到同目录的 `ui-order.json`:页面上每次改动照旧即时生效(实时状态在 localStorage),插件在后台防抖写入这个文件,并按「最后写入者胜」与本地状态对齐(文件更新就采纳文件,本地更新就回写文件)。采纳文件里的停用集合时会**写回 localStorage**,所以刷新、重开浏览器之后仍是文件那一份,不会出现「这台机器看着同步好了、一刷新又变回去并把它推回文件」;每次改动都会拿到严格递增的时间戳,重启后同一毫秒内的多次改动也不会互相覆盖。文件比本页新时会立即采纳,本页的时间戳不更新时就**拒绝写入**(服务器回 409 并把赢得的那份文档带回来),旧标签页不会把别人的新顺序或新开关回滚回去。页面每分钟、以及切回标签页/窗口获得焦点时重新拉取一次,另一台电脑的改动不用重启就能出现。文件里只有供应商路由、模型 id 和停用名单,不含任何密钥,可以放心交给同步盘/网盘携带,实现多台机器的排序与启停同步。
|
|
73
76
|
- 新增供应商的表单在官方密钥输入框下方也带这套卡片式密钥列表:草稿密钥先暂存在本页,点「创建」供应商落库后自动写入,第一把草稿密钥自动成为启用密钥。挂载前已敲进官方输入框的值保留在原处——官方框保存的仍是那把密钥,下方的列表只收之后新增的。刷新页面会丢弃草稿,与表单自身行为一致;若 id 撞上已存在的供应商,草稿不会写入对方。
|
|
74
77
|
|
|
75
78
|
### 按密钥切换协议与多地址
|
package/lib/autofill.d.ts
CHANGED
|
@@ -27,6 +27,24 @@ export declare function buildAutofillPatch(providers: unknown, routeFilter?: (ro
|
|
|
27
27
|
efforts?: boolean;
|
|
28
28
|
modalities?: boolean;
|
|
29
29
|
}, revision?: number): JsonObject | undefined;
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Build the protocol-mismatch cleanup patch (the compat guard): every model
|
|
32
|
+
* row -- and the route-level compat block -- whose compat carries a switch its
|
|
33
|
+
* route's wire protocol does not take loses exactly those keys.
|
|
34
|
+
*
|
|
35
|
+
* This is the repair for a protocol switched after the switches were written:
|
|
36
|
+
* openai-completions → openai-responses leaves `supportsReasoningEffort` on
|
|
37
|
+
* every model, and the kernel then refuses each of them at catalog resolution
|
|
38
|
+
* ("sets compat ..., but its api is ..., which does not take it"), so the
|
|
39
|
+
* route serves nothing until the keys are gone.
|
|
40
|
+
*
|
|
41
|
+
* Only routes that NAME a wire protocol are swept: a route without `api`
|
|
42
|
+
* resolves each model's protocol from the installed catalog, which this
|
|
43
|
+
* builder cannot see, so touching it could strip a key a catalog model
|
|
44
|
+
* legitimately takes. Returns the partial providers patch, or undefined when
|
|
45
|
+
* nothing is dirty -- the common case, so a caller never writes speculatively.
|
|
46
|
+
* Pure data logic like {@link buildAutofillPatch}: shared by BOTH halves.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildCompatCleanupPatch(providers: unknown): JsonObject | undefined;
|
|
49
|
+
/** Strip newer-only compat keys from an autofill patch (older-kernel downgrade). */ export declare function stripNewCompatKeysDeep(patch: JsonObject): JsonObject | undefined;
|
|
32
50
|
export {};
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Models-page title-row button.
|
|
5
5
|
*
|
|
6
6
|
* One card today, 「生图」, per the design's card-list shape with room for
|
|
7
|
-
* more: the params row
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* more: the params row and the default-model select under it. The marked
|
|
8
|
+
* models surface as that select's options; marking itself lives on the Models
|
|
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.
|
|
13
13
|
*
|
|
14
14
|
* Esc / backdrop / ✕ close it; the wrapper unmounts and the page keeps
|
|
15
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 {
|
|
@@ -50,26 +56,3 @@ export declare function saveImageConfig(patch: {
|
|
|
50
56
|
}>;
|
|
51
57
|
outputDir?: string;
|
|
52
58
|
}): Promise<TransportAnswer<undefined>>;
|
|
53
|
-
/** 对一行模型发起端点测试(n:1、最小尺寸的真实请求)。 */
|
|
54
|
-
export declare function testImageEndpoint(id: string): Promise<TransportAnswer<{
|
|
55
|
-
status: string;
|
|
56
|
-
checkedAt?: string;
|
|
57
|
-
}>>;
|
|
58
|
-
/** 显式生成(辅通道):拿全部落盘路径直接弹预览。 */
|
|
59
|
-
export declare function generateImageDirect(request: {
|
|
60
|
-
model?: string;
|
|
61
|
-
prompt: string;
|
|
62
|
-
size?: string;
|
|
63
|
-
quality?: string;
|
|
64
|
-
n?: number;
|
|
65
|
-
referenceImages?: readonly string[];
|
|
66
|
-
}): Promise<TransportAnswer<{
|
|
67
|
-
images: readonly string[];
|
|
68
|
-
model: string;
|
|
69
|
-
paramsUsed: {
|
|
70
|
-
size: string;
|
|
71
|
-
quality: string;
|
|
72
|
-
n: number;
|
|
73
|
-
};
|
|
74
|
-
warning?: string;
|
|
75
|
-
}>>;
|
package/lib/client/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* slider-toggle-slot.ts the Models-page footer toggle
|
|
15
15
|
* provider-order-drag.ts the Models-page provider-row drag handles (order)
|
|
16
16
|
* provider-order.ts the stored provider order (settings page + composer)
|
|
17
|
+
* order-sync.ts the orderings mirrored into ui-order.json (sync)
|
|
17
18
|
* provider-toggle.ts the Models-page per-provider enable switch
|
|
18
19
|
* provider-enabled.ts the stored disabled providers (settings page + composer)
|
|
19
20
|
* autofill-run.ts the running auto-fill complement (issue #7)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compat guard: the running repair for a wire protocol switched after
|
|
3
|
+
* compat switches were written.
|
|
4
|
+
*
|
|
5
|
+
* Switching a route to `openai-responses` (or `anthropic-messages`) leaves the
|
|
6
|
+
* old openai-completions switches -- `supportsReasoningEffort` and friends --
|
|
7
|
+
* stored on its models, and the kernel then refuses every model that still
|
|
8
|
+
* carries one ("sets compat ..., but its api is ..., which does not take it"):
|
|
9
|
+
* the route serves nothing until the keys are gone. The host heals what it
|
|
10
|
+
* finds at boot; everything a session changes afterwards is healed HERE, on
|
|
11
|
+
* the idle pass -- the only moment no official card is holding a revision
|
|
12
|
+
* baseline a write would invalidate (issue #7, the same rule the running
|
|
13
|
+
* auto-fill complement follows).
|
|
14
|
+
*
|
|
15
|
+
* @module dsh-model-think-level/client/injection/compat-guard
|
|
16
|
+
*/
|
|
17
|
+
import type { RemoteApi, SettingsJoin } from '../types.js';
|
|
18
|
+
/** What the guard needs from its host. */
|
|
19
|
+
export interface CompatGuardDeps {
|
|
20
|
+
/** The settings remote. */
|
|
21
|
+
api: RemoteApi;
|
|
22
|
+
}
|
|
23
|
+
/** The guard's face. */
|
|
24
|
+
export interface CompatGuard {
|
|
25
|
+
/** Run the guard; fire-and-forget on the injector's idle pass. */
|
|
26
|
+
run: (join?: SettingsJoin) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the guard.
|
|
30
|
+
* @param deps - the settings remote.
|
|
31
|
+
* @returns the guard's {@link CompatGuard} face.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createCompatGuard(deps: CompatGuardDeps): CompatGuard;
|
|
@@ -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 {};
|
|
@@ -20,10 +20,18 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { KeyManagerClient } from '../key-manager-client.js';
|
|
22
22
|
import type { HostLabels } from './models-page-editor.js';
|
|
23
|
+
interface PendingKeyList {
|
|
24
|
+
readonly route: string;
|
|
25
|
+
readonly client: KeyManagerClient;
|
|
26
|
+
}
|
|
23
27
|
/** Per-session bookkeeping (one instance lives in `models-page.ts`). */
|
|
24
28
|
export interface KeyPrefetchState {
|
|
25
29
|
/** Routes already asked during THIS page opening. */
|
|
26
30
|
readonly requested: Set<string>;
|
|
31
|
+
/** Work not yet started; discarded when the provider list disappears. */
|
|
32
|
+
readonly pending: PendingKeyList[];
|
|
33
|
+
/** In-flight reads survive page reopen, keeping the shared limit at two. */
|
|
34
|
+
readonly running: Set<string>;
|
|
27
35
|
/** Whether the provider list was present in the previous pass. */
|
|
28
36
|
visible: boolean;
|
|
29
37
|
}
|
|
@@ -40,5 +48,9 @@ export interface KeyPrefetchDeps {
|
|
|
40
48
|
* Visit the provider list once per scan: on a (re)opened page, ask the host for
|
|
41
49
|
* each visible provider's key list, once, and let the panel's cache hold the
|
|
42
50
|
* answer until an expansion needs it.
|
|
51
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
52
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
53
|
+
* per pass, and one burst runs several passes.
|
|
43
54
|
*/
|
|
44
|
-
export declare function reconcileKeyPrefetch(root: HTMLElement, deps: KeyPrefetchDeps, state: KeyPrefetchState): void;
|
|
55
|
+
export declare function reconcileKeyPrefetch(root: HTMLElement, deps: KeyPrefetchDeps, state: KeyPrefetchState, list?: HTMLElement | undefined): void;
|
|
56
|
+
export {};
|
|
@@ -71,7 +71,7 @@ export declare function modelListMutation(records: readonly MutationRecord[]): b
|
|
|
71
71
|
* that might belong to another provider, or writing one there, is worse than
|
|
72
72
|
* leaving that editor without grips for a scan.
|
|
73
73
|
*/
|
|
74
|
-
export declare function reconcileModelOrder(root: HTMLElement, deps: ModelOrderDeps, state: ModelOrderState): void;
|
|
74
|
+
export declare function reconcileModelOrder(root: HTMLElement, deps: ModelOrderDeps, state: ModelOrderState, lists?: readonly HTMLElement[]): void;
|
|
75
75
|
/**
|
|
76
76
|
* Undo everything this module put on the page. A plugin disable or an HMR
|
|
77
77
|
* replace unmounts React trees on its own, but the grips, the widened grids and
|
|
@@ -801,8 +801,7 @@ export declare function pinModelListCards(root: HTMLElement, windowMs?: number):
|
|
|
801
801
|
* own DOM are skipped, exactly like the Edit buttons above.
|
|
802
802
|
*/
|
|
803
803
|
export declare function addModelTriggersOf(scope: HTMLElement, labels: HostLabels): HTMLElement[];
|
|
804
|
-
/**
|
|
805
|
-
* Scan the settings DOM for official model rows and reconcile the injected
|
|
804
|
+
/** Scan the settings DOM for official model rows and reconcile the injected
|
|
806
805
|
* editors. Idempotent: existing editors are left alone, new disclosures get
|
|
807
806
|
* one, and removed ones are unmounted.
|
|
808
807
|
* @param root - the settings panel root to scan.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat streaming and foreign-root renders must not wake every Models-page seam.
|
|
3
|
+
* Inspect the mutation's subtree, not document.body. Removed subtrees are kept
|
|
4
|
+
* in the records too, so navigation away still releases page-opening sessions.
|
|
5
|
+
*/
|
|
6
|
+
export declare function modelsPageMutation(records: readonly MutationRecord[]): boolean;
|
|
@@ -43,9 +43,16 @@ export interface ProviderBalanceState {
|
|
|
43
43
|
readonly inflight: Set<string>;
|
|
44
44
|
/** Routes invalidated while a read was in flight (re-read on settle). */
|
|
45
45
|
readonly pending: Set<string>;
|
|
46
|
+
/** Reads waiting for a concurrency slot; discarded when the page closes. */
|
|
47
|
+
readonly queued: PendingBalanceRead[];
|
|
46
48
|
/** Whether the provider list was present in the previous pass. */
|
|
47
49
|
visible: boolean;
|
|
48
50
|
}
|
|
51
|
+
/** A read waiting for a slot: the row that asked and the route it asked for. */
|
|
52
|
+
interface PendingBalanceRead {
|
|
53
|
+
readonly head: HTMLElement;
|
|
54
|
+
readonly route: string;
|
|
55
|
+
}
|
|
49
56
|
/** What the chip needs from its host. */
|
|
50
57
|
export interface ProviderBalanceDeps {
|
|
51
58
|
/** The plugin's own translator, for the chip's label and tooltip. */
|
|
@@ -71,8 +78,11 @@ export declare function createProviderBalanceState(): ProviderBalanceState;
|
|
|
71
78
|
* A missing provider list means the Models page is closed (or not rendered):
|
|
72
79
|
* the opening is over, so the next presence starts a new read session. No
|
|
73
80
|
* request is made from this function while the list is absent.
|
|
81
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
82
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
83
|
+
* per pass, and one burst runs several passes.
|
|
74
84
|
*/
|
|
75
|
-
export declare function reconcileProviderBalance(root: HTMLElement, deps: ProviderBalanceDeps, state: ProviderBalanceState): void;
|
|
85
|
+
export declare function reconcileProviderBalance(root: HTMLElement, deps: ProviderBalanceDeps, state: ProviderBalanceState, list?: HTMLElement | undefined): void;
|
|
76
86
|
/**
|
|
77
87
|
* Forget one route's session, so the next reconcile reads it now.
|
|
78
88
|
* A balance URL was just written (or cleared): the old amount belongs to the
|
|
@@ -81,3 +91,4 @@ export declare function reconcileProviderBalance(root: HTMLElement, deps: Provid
|
|
|
81
91
|
export declare function invalidateProviderBalance(state: ProviderBalanceState, route: string): void;
|
|
82
92
|
/** Remove every chip (the fiber is going away). */
|
|
83
93
|
export declare function teardownProviderBalance(): void;
|
|
94
|
+
export {};
|
|
@@ -32,7 +32,10 @@ export interface ProviderDeleteDeps {
|
|
|
32
32
|
* Give every provider row the delete seat the host left out. Idempotent: a row
|
|
33
33
|
* that already has one is only relabelled, and a row whose provider became
|
|
34
34
|
* removable hands the seat back to the host's own button.
|
|
35
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
36
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
37
|
+
* per pass, and one burst runs several passes.
|
|
35
38
|
*/
|
|
36
|
-
export declare function reconcileProviderDeleteSeat(root: HTMLElement, deps: ProviderDeleteDeps): void;
|
|
39
|
+
export declare function reconcileProviderDeleteSeat(root: HTMLElement, deps: ProviderDeleteDeps, list?: HTMLElement | undefined): void;
|
|
37
40
|
/** Take every seat out again (plugin dispose, HMR teardown). */
|
|
38
41
|
export declare function teardownProviderDeleteSeats(): void;
|
|
@@ -50,7 +50,10 @@ export declare function createProviderDisabledGroupState(): ProviderDisabledGrou
|
|
|
50
50
|
* Idempotent: a row already folded stays folded, and the control is only ever
|
|
51
51
|
* written when a value genuinely changed, so a scan never mutates the page on
|
|
52
52
|
* behalf of a state that is already on it.
|
|
53
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
54
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
55
|
+
* per pass, and one burst runs several passes.
|
|
53
56
|
*/
|
|
54
|
-
export declare function reconcileProviderDisabledGroup(root: HTMLElement, deps: ProviderDisabledGroupDeps, state: ProviderDisabledGroupState): void;
|
|
57
|
+
export declare function reconcileProviderDisabledGroup(root: HTMLElement, deps: ProviderDisabledGroupDeps, state: ProviderDisabledGroupState, list?: HTMLElement | undefined): void;
|
|
55
58
|
/** Remove the control and unfold every row it hid. */
|
|
56
59
|
export declare function teardownProviderDisabledGroup(): void;
|
|
@@ -74,8 +74,12 @@ export declare function applyRowOrder(list: HTMLElement, ids: readonly string[])
|
|
|
74
74
|
* open, so this cannot ride along with it) and is idempotent by DOM presence —
|
|
75
75
|
* the same guard the editor injector uses, which keeps the insertion from
|
|
76
76
|
* re-triggering the scan that found it.
|
|
77
|
+
* @param list - the provider list already resolved by the caller's scan. Every
|
|
78
|
+
* pass of one `reconcileDom` shares one `rowsListOf` answer: the fallback
|
|
79
|
+
* re-derivation costs a full-document substring-class walk, and seven passes
|
|
80
|
+
* paying it separately is what showed up as tens of walks per burst.
|
|
77
81
|
*/
|
|
78
|
-
export declare function reconcileProviderOrder(root: HTMLElement, deps: ProviderOrderDeps, state: ProviderOrderState): void;
|
|
82
|
+
export declare function reconcileProviderOrder(root: HTMLElement, deps: ProviderOrderDeps, state: ProviderOrderState, list?: HTMLElement | undefined): void;
|
|
79
83
|
/**
|
|
80
84
|
* Undo everything this module put on the official page. A plugin disable or an
|
|
81
85
|
* HMR replace unmounts React trees on its own, but the grips, the draggable
|
|
@@ -36,7 +36,10 @@ export declare function createProviderToggleState(): ProviderToggleState;
|
|
|
36
36
|
* Visit every provider row and make sure it shows a switch carrying its own
|
|
37
37
|
* state. Idempotent: a row that already has one is only relabelled, which is
|
|
38
38
|
* also how a language switch and an external toggle reach the page.
|
|
39
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
40
|
+
* {@link reconcileProviderOrder}); re-deriving it here costs a document-wide
|
|
41
|
+
* walk per pass, and one burst runs several passes.
|
|
39
42
|
*/
|
|
40
|
-
export declare function reconcileProviderEnabled(root: HTMLElement, deps: ProviderToggleDeps, state: ProviderToggleState): void;
|
|
43
|
+
export declare function reconcileProviderEnabled(root: HTMLElement, deps: ProviderToggleDeps, state: ProviderToggleState, list?: HTMLElement | undefined): void;
|
|
41
44
|
/** Remove every switch and every dimmed row. */
|
|
42
45
|
export declare function teardownProviderEnabled(): void;
|
|
@@ -71,9 +71,10 @@ export interface KeyRow {
|
|
|
71
71
|
*/
|
|
72
72
|
readonly protocol?: RouteProtocol;
|
|
73
73
|
/**
|
|
74
|
-
* Whether the key's model scope is the
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* Whether the key's model scope is the probe's assignment rather than a
|
|
75
|
+
* manual one — the panel shows it so a scope edit knows the checked chips
|
|
76
|
+
* will keep being rewritten on every probe run until the user saves one by
|
|
77
|
+
* hand.
|
|
77
78
|
*/
|
|
78
79
|
readonly auto?: boolean;
|
|
79
80
|
/**
|
|
@@ -111,10 +112,9 @@ export interface KeyState {
|
|
|
111
112
|
/** The provider's two base URLs, keyed by protocol family. */
|
|
112
113
|
readonly endpoints: KeyEndpoints;
|
|
113
114
|
/**
|
|
114
|
-
* Whether the host is probing this route's keys
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* reopen.
|
|
115
|
+
* Whether the host is probing this route's keys right now (the panel button's
|
|
116
|
+
* scope check). The panel follows it with a quiet poll until it clears, so
|
|
117
|
+
* the assignments the probe writes land on screen without a reopen.
|
|
118
118
|
*/
|
|
119
119
|
readonly probing?: boolean;
|
|
120
120
|
}
|
|
@@ -140,10 +140,15 @@ export interface RouteBalanceAnswer {
|
|
|
140
140
|
/** The host's wording when the read was refused. */
|
|
141
141
|
readonly error?: string;
|
|
142
142
|
}
|
|
143
|
+
/** Read policy for the masked key list; omitted options always revalidate. */
|
|
144
|
+
export interface KeyListOptions {
|
|
145
|
+
/** Reuse a successful masked answer for up to five seconds. */
|
|
146
|
+
readonly preferCache?: boolean;
|
|
147
|
+
}
|
|
143
148
|
/** The manager's transport, injectable so the panel can be tested without one. */
|
|
144
149
|
export interface KeyManagerClient {
|
|
145
|
-
/** Read the provider's whole key list. */
|
|
146
|
-
list(route: string): Promise<KeyAnswer>;
|
|
150
|
+
/** Read the provider's whole key list (fresh unless cache reuse is requested). */
|
|
151
|
+
list(route: string, options?: KeyListOptions): Promise<KeyAnswer>;
|
|
147
152
|
/**
|
|
148
153
|
* Read only the route's two addresses.
|
|
149
154
|
*
|
|
@@ -193,6 +198,13 @@ export interface KeyManagerClient {
|
|
|
193
198
|
* survive a balance edit.
|
|
194
199
|
*/
|
|
195
200
|
setBalanceEndpoint?(route: string, endpoint: string): Promise<KeyAnswer>;
|
|
201
|
+
/**
|
|
202
|
+
* Ask the host to probe every key of a multi-key route and check the
|
|
203
|
+
* probe-maintained scopes to what each key actually serves. The answer is
|
|
204
|
+
* the list as it stands when the run was queued — `probing` says the run is
|
|
205
|
+
* on, and the panel follows it to the assignments it writes.
|
|
206
|
+
*/
|
|
207
|
+
probe(route: string): Promise<KeyAnswer>;
|
|
196
208
|
/** The stored value of one listed reference, or undefined. */
|
|
197
209
|
reveal(route: string, ref: string): Promise<string | undefined>;
|
|
198
210
|
}
|
package/lib/client/locales.d.ts
CHANGED
|
@@ -154,6 +154,11 @@ export declare const en: {
|
|
|
154
154
|
keysScopeSaved: string;
|
|
155
155
|
keysScopeHint: string;
|
|
156
156
|
keysScopeAutoHint: string;
|
|
157
|
+
keysProbe: string;
|
|
158
|
+
keysProbing: string;
|
|
159
|
+
keysProbeHint: string;
|
|
160
|
+
keysProbeSingle: string;
|
|
161
|
+
keysProbeDone: string;
|
|
157
162
|
keysScopeObserved: string;
|
|
158
163
|
keysScopeObservedHint: string;
|
|
159
164
|
keysScopeEmpty: string;
|
|
@@ -223,44 +228,21 @@ export declare const en: {
|
|
|
223
228
|
configPaneTitle: string;
|
|
224
229
|
configPaneClose: string;
|
|
225
230
|
configPaneFailed: string;
|
|
226
|
-
configPaneFoot: string;
|
|
227
231
|
imagegenSectionTitle: string;
|
|
228
|
-
imagegenSectionSub: string;
|
|
229
|
-
imagegenModelCount: string;
|
|
230
232
|
imagegenLoading: string;
|
|
231
233
|
imagegenLoadFailed: string;
|
|
232
234
|
imagegenDefaultsLabel: string;
|
|
233
235
|
imagegenDefaultModelLabel: string;
|
|
234
236
|
imagegenDefaultModelNone: string;
|
|
235
|
-
imagegenDefaultBadge: string;
|
|
236
|
-
imagegenEndpointOk: string;
|
|
237
|
-
imagegenEndpointUnverified: string;
|
|
238
|
-
imagegenEndpointUnsupported: string;
|
|
239
|
-
imagegenEndpointBadgeHint: string;
|
|
240
|
-
imagegenNoEndpoint: string;
|
|
241
237
|
imagegenSizeLabel: string;
|
|
242
238
|
imagegenQualityLabel: string;
|
|
243
239
|
imagegenCountLabel: string;
|
|
244
240
|
imagegenTimeoutLabel: string;
|
|
245
241
|
imagegenTimeoutMinutes: string;
|
|
246
242
|
imagegenTimeoutHint: string;
|
|
247
|
-
imagegenTestEndpoint: string;
|
|
248
|
-
imagegenProbe: string;
|
|
249
|
-
imagegenProbeDone: string;
|
|
250
|
-
imagegenEmptyText: string;
|
|
251
|
-
imagegenEmptyHint: string;
|
|
252
|
-
imagegenFindSuspects: string;
|
|
253
|
-
imagegenNoSuspects: string;
|
|
254
|
-
imagegenMarkSuspects: string;
|
|
255
|
-
imagegenMarked: string;
|
|
256
|
-
imagegenMarkFailed: string;
|
|
257
|
-
imagegenProbeDoneMulti: string;
|
|
258
|
-
imagegenToolTitle: string;
|
|
259
|
-
imagegenToolRegistered: string;
|
|
260
|
-
imagegenToolUnregistered: string;
|
|
261
|
-
imagegenToolTest: string;
|
|
262
|
-
imagegenToolHint: string;
|
|
263
243
|
imagegenCardRunning: string;
|
|
244
|
+
imagegenToolMissing: string;
|
|
245
|
+
imagegenToolMissingWhy: string;
|
|
264
246
|
};
|
|
265
247
|
/** The plugin's locale key union. */
|
|
266
248
|
export type BreKey = keyof typeof en;
|
|
@@ -35,6 +35,15 @@ export declare function modelOrderOf(provider: string): readonly string[];
|
|
|
35
35
|
export declare function setModelOrder(provider: string, next: readonly string[]): void;
|
|
36
36
|
/** Apply a map incoming from another tab (no persist: the writer already stored it). */
|
|
37
37
|
export declare function syncModelOrders(next: ModelOrderMap): void;
|
|
38
|
+
/**
|
|
39
|
+
* Replace the whole map with `next` AND persist it — the boot adoption of the
|
|
40
|
+
* synced order document (`order-sync.ts`). Like `syncModelOrders` it is a
|
|
41
|
+
* wholesale replace; unlike it, the map also lands in localStorage, because
|
|
42
|
+
* the writer here is the file sync, not another tab's own persisting store.
|
|
43
|
+
* Entries with no nameable model left are dropped, exactly as `parseModelOrders`
|
|
44
|
+
* drops them, so an adopted map is a parsed-map shape.
|
|
45
|
+
*/
|
|
46
|
+
export declare function adoptModelOrders(next: ModelOrderMap): void;
|
|
38
47
|
/** Subscribe to order changes; returns the disposer. */
|
|
39
48
|
export declare function subscribeModelOrders(listener: () => void): () => void;
|
|
40
49
|
/**
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order document's sync: the browser half's provider/model orderings
|
|
3
|
+
* mirrored into the host's `ui-order.json` (ORDER_PATH).
|
|
4
|
+
*
|
|
5
|
+
* localStorage — the live stores' medium (provider-order.ts / model-order.ts)
|
|
6
|
+
* — is per-install and does not travel; the file does. The sync is a two-way
|
|
7
|
+
* last-writer-wins fold, arbitrated by the `savedAt` stamp each side carries:
|
|
8
|
+
*
|
|
9
|
+
* - Every local ORDER CHANGE is stamped into localStorage immediately (not
|
|
10
|
+
* when the push lands), so a page closed inside the debounce window still
|
|
11
|
+
* reads as the newer side at the next boot and pushes what it holds.
|
|
12
|
+
* - Boot pulls the file: a file newer than the local stamp is ADOPTED into
|
|
13
|
+
* the stores (and with them into localStorage, so the page and the
|
|
14
|
+
* composer follow without a reload); an older or absent file is
|
|
15
|
+
* overwritten by the local state — the seed after an upgrade, and the
|
|
16
|
+
* repair when a previous push never landed.
|
|
17
|
+
* - Every change is pushed, debounced, so a drag burst lands as one write;
|
|
18
|
+
* an adoption schedules nothing (the content already matches).
|
|
19
|
+
*
|
|
20
|
+
* The file holds no secrets — provider routes and model ids only — which is
|
|
21
|
+
* what makes it safe to point a sync tool at. Every fetch failure is silent:
|
|
22
|
+
* the local stores keep working, and the next boot reconciles.
|
|
23
|
+
*
|
|
24
|
+
* @module dsh-model-think-level/client/order-sync
|
|
25
|
+
*/
|
|
26
|
+
/** localStorage key of the last local order change (epoch ms; 0 = unstamped). */
|
|
27
|
+
export declare const ORDER_SAVED_AT_KEY = "dsh-model-think-level.order-saved-at";
|
|
28
|
+
/**
|
|
29
|
+
* Floor between a drag and its push. Long enough to fold a keyboard nudge
|
|
30
|
+
* burst into one write, short enough that closing the page right after a drag
|
|
31
|
+
* usually still lands (and `flushOrderSync` covers the rest).
|
|
32
|
+
*/
|
|
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;
|
|
41
|
+
/** The wire shape of the order document (declared here; the host parses its own). */
|
|
42
|
+
export interface OrderDocumentView {
|
|
43
|
+
savedAt: number;
|
|
44
|
+
providerOrder: readonly string[];
|
|
45
|
+
modelOrder: Readonly<Record<string, readonly string[]>>;
|
|
46
|
+
/**
|
|
47
|
+
* The disabled set the document carries, or `undefined` when it names none —
|
|
48
|
+
* which is not the same as naming an empty one: an explicit empty array is a
|
|
49
|
+
* real "everything is on" a newer file can hold over a local disabled row,
|
|
50
|
+
* while an absent field is an old writer that never knew the field, and must
|
|
51
|
+
* not clear what this machine has.
|
|
52
|
+
*/
|
|
53
|
+
providersDisabled: readonly string[] | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Push any pending change immediately — the pagehide flush. A drag landing
|
|
57
|
+
* inside the debounce window would otherwise stay local until the next boot.
|
|
58
|
+
* The pending timer is cancelled with it: one change, one push.
|
|
59
|
+
*/
|
|
60
|
+
export declare function flushOrderSync(): void;
|
|
61
|
+
/**
|
|
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).
|
|
65
|
+
*/
|
|
66
|
+
export declare function reconcileOrderSync(): Promise<void>;
|
|
67
|
+
/**
|
|
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.
|
|
73
|
+
*/
|
|
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;
|