dsh-plugin-effort-declare 0.1.3 → 0.1.5

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.
Files changed (48) hide show
  1. package/CONTRIBUTING.en.md +20 -10
  2. package/CONTRIBUTING.md +23 -13
  3. package/INSTALL.en.md +9 -9
  4. package/INSTALL.md +16 -16
  5. package/README.en.md +27 -21
  6. package/README.md +30 -24
  7. package/lib/client.js +142 -61
  8. package/lib/client.js.map +1 -1
  9. package/lib/types/client/EffortDeclareSection.d.ts +5 -4
  10. package/lib/types/client/EffortDeclareSection.d.ts.map +1 -1
  11. package/lib/types/client/index.d.ts +23 -2
  12. package/lib/types/client/index.d.ts.map +1 -1
  13. package/lib/types/client/load-drafts.d.ts +3 -3
  14. package/lib/types/client/load-drafts.d.ts.map +1 -1
  15. package/lib/types/client/locales.d.ts +1 -1
  16. package/lib/types/client/locales.d.ts.map +1 -1
  17. package/lib/types/client/remotes.d.ts +40 -0
  18. package/lib/types/client/remotes.d.ts.map +1 -0
  19. package/lib/types/core/catalog.d.ts +11 -3
  20. package/lib/types/core/catalog.d.ts.map +1 -1
  21. package/lib/types/core/drafts.d.ts +9 -5
  22. package/lib/types/core/drafts.d.ts.map +1 -1
  23. package/lib/types/core/filter.d.ts +1 -1
  24. package/lib/types/core/filter.d.ts.map +1 -1
  25. package/lib/types/core/input.d.ts +15 -0
  26. package/lib/types/core/input.d.ts.map +1 -0
  27. package/lib/types/core/path-ops.d.ts +1 -1
  28. package/lib/types/core/path-ops.d.ts.map +1 -1
  29. package/lib/types/core/validate.d.ts +3 -0
  30. package/lib/types/core/validate.d.ts.map +1 -1
  31. package/package.json +10 -13
  32. package/src/README.en.md +2 -2
  33. package/src/README.md +2 -2
  34. package/src/client/EffortDeclareSection.tsx +36 -26
  35. package/src/client/README.en.md +8 -7
  36. package/src/client/README.md +8 -7
  37. package/src/client/index.ts +35 -6
  38. package/src/client/load-drafts.ts +10 -10
  39. package/src/client/locales.ts +15 -6
  40. package/src/client/remotes.ts +39 -0
  41. package/src/core/README.en.md +8 -7
  42. package/src/core/README.md +8 -7
  43. package/src/core/catalog.ts +14 -2
  44. package/src/core/drafts.ts +41 -27
  45. package/src/core/filter.ts +1 -1
  46. package/src/core/input.ts +49 -0
  47. package/src/core/path-ops.ts +1 -1
  48. package/src/core/validate.ts +8 -0
@@ -7,22 +7,23 @@
7
7
  </samp>
8
8
  </p>
9
9
 
10
- 浏览器半区:在 Web UI 的设置面板注册「推理档位」,并经官方 settings RPC 写入 `llm-pi-ai`。
10
+ 浏览器半区:在 Web UI 的设置面板注册「推理档位」,并经官方 settings RPC `llm-pi-ai` 写入每模型的 `reasoningEfforts` 与 `input`。
11
11
 
12
- `apply` 接线失败会抛出,与官方模型页相同;不要整段 `try/catch` 吞掉。卸载时 locale、CSS 与事件订阅随 `ctx.effect` 清理。
12
+ 缺失的 inject 服务会让插件停在 PENDING,`apply` 不会跑到。不要给 `apply` 套整段 `try/catch`(与官方模型页相同)。RPC 方法缺失时设置页显示加载错误,不要用空列表冒充成功。卸载时 locale、CSS 与事件订阅随 `ctx.effect` 清理。
13
13
 
14
- 跨插件协作只使用 Cordis 服务(`connection`、`settingsScope`、`settingsSchema`、`slots`、`locale`、`remote`)。不要 value-import `@deepseek-ai/dsh-client-ui-settings-models`:client bundle 的 purity 规则禁止把其它 `@deepseek-ai/*` 打进包内(shell 冻结模块表里的平台模块除外)。
14
+ 跨插件协作只使用 Cordis 服务(`remote` / `remote.llm` / `remote.settings`、`settingsScope`、`settingsSchema`、`slots`、`locale`)。不要 value-import `@deepseek-ai/dsh-client-ui-settings-models`:client bundle 的 purity 规则禁止把其它 `@deepseek-ai/*` 打进包内(shell 冻结模块表里的平台模块除外)。
15
15
 
16
16
  ## 这个目录里有什么
17
17
 
18
18
  | 文件 | 说明 |
19
19
  | --- | --- |
20
- | [`index.ts`](./index.ts) | 注册 zh/en 文案、CSS(`ctx.effect` 插入/移除)与 `settings.section`(id `effort-declare`,order 12)。`describe.subscribe` 只同步 `writable`(任意 namespace 都会触发,含自己的 `acceptView`)。`settings/document-updated`(仅 `llm-pi-ai`)带上 Host 的 revision;设置页跳过自己这次 mutate 的回声,等镜像 revision **追上**后再 `getSnapshot()`,不把 `ensure()` 当刷新。提供方目录来自 `llm/adapters-updated`;`connection/reset` 走 `ensure()` 以便等待官方镜像的 in-flight `load()`。`locale: NS` 由框架注入 `t`,inject 只传 `api` / `describe` / `schema` / `subscribeInvalidate`。 |
21
- | [`EffortDeclareSection.tsx`](./EffortDeclareSection.tsx) | 路由卡片、预设、Off 三态、高级协议开关、保存与取消。保存互斥到整个 `llm-pi-ai` namespace(以 ref 防连点);`busy` 只给正在 mutate 的卡显示「保存中」,其它卡 `saveLocked`。自己写入成功立刻同步 `draftsRef` 并走 `acceptView` + `applySaveSuccess`。保存过程中到达的外部 `document-updated` 会在结束后补刷。无冲突的 reload 清掉该卡 conflict/error notice。页脚显示打包时冻结的版本与版权年。 |
20
+ | [`index.ts`](./index.ts) | 注册 zh/en 文案、CSS(`ctx.effect` 插入/移除)与 `settings.section`(id `effort-declare`,order 12)。`describe.subscribe` 只同步 `writable`(任意 namespace 都会触发,含自己的 `acceptView`)。`settings/document-updated`(仅 `llm-pi-ai`)带上 Host 的 revision;设置页跳过自己这次 mutate 的回声,等镜像 revision **追上**后再 `getSnapshot()`,不把 `ensure()` 当刷新。提供方目录来自 `llm/adapters-updated`;`connection/reset` 走 `ensure()` 以便等待官方镜像的 in-flight `load()`。`locale: NS` 由框架注入 `t`;slot 的 `inject()` 只返回 `llm` / `settings` / `describe` / `schema` / `subscribeInvalidate`。 |
21
+ | [`EffortDeclareSection.tsx`](./EffortDeclareSection.tsx) | 路由卡片、预设、Off 三态、每模型「支持图片输入」、高级协议开关、保存与取消。保存互斥到整个 `llm-pi-ai` namespace(以 ref 防连点);`busy` 只给正在 mutate 的卡显示「保存中」,其它卡 `saveLocked`。保存前用 `modelRowError` 拦截空档位、只开 Off 与非法 `input`。自己写入成功立刻同步 `draftsRef` 并走 `acceptView` + `applySaveSuccess`。保存过程中到达的外部 `document-updated` 会在结束后补刷。无冲突的 reload 清掉该卡 conflict/error notice。页脚显示打包时冻结的版本与版权年。 |
22
22
  | [`build-info.ts`](./build-info.ts) | 读取 tsdown `define` 注入的 `package.json` version 与 UTC 打包年,拼出页脚文案。 |
23
23
  | [`globals.d.ts`](./globals.d.ts) | `__PLUGIN_VERSION__` / `__COPYRIGHT_TO__` 的类型声明。 |
24
- | [`load-drafts.ts`](./load-drafts.ts) | 从 `llm.providers` + 镜像组装草稿;草稿取自 `user`,协议分类可用 `value`。`thinkingFormat` 可选项只来自现场 schema union。首屏 `ensure()`;刷新只读 `getSnapshot()`,并提供等 namespace revision 的 helper。 |
25
- | [`locales.ts`](./locales.ts) | 文案 namespace `plugin-effort-declare`。 |
24
+ | [`load-drafts.ts`](./load-drafts.ts) | 从 `llm.listConfigurableProviders` + 镜像组装草稿;草稿取自 `user`,协议分类可用 `value`。`thinkingFormat` 可选项只来自现场 schema union。首屏 `ensure()`;刷新只读 `getSnapshot()`,并提供等 namespace revision 的 helper。 |
25
+ | [`remotes.ts`](./remotes.ts) | 本页实际调用的 DSH 0.1.2 Remote 方法:`listConfigurableProviders` 与 `settings.mutate`(成功 `{ ok, value }`,失败 `{ ok: false, error }`,冲突码 `settings/conflict`)。 |
26
+ | [`locales.ts`](./locales.ts) | 文案 namespace `plugin-effort-declare`(含档位、图片输入与校验错误)。 |
26
27
  | [`effort-declare.module.css`](./effort-declare.module.css) | 仅使用 `--dsw-alias-*` 设计令牌,保证暗色主题正确。 |
27
28
  | [`schema-ops.ts`](./schema-ops.ts) | 将 `settingsSchema` 收成普通回调(含 `validate`),避免把服务身份带进 React。 |
28
29
 
@@ -2,11 +2,11 @@
2
2
  * dsh-plugin-effort-declare — browser half: settings.section for per-model
3
3
  * reasoning effort declarations.
4
4
  */
5
- import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
6
- import type { ConnectionHandle } from '@deepseek-ai/dsh-api-remotes/client'
5
+ import type { Context } from '@deepseek-ai/cordis'
7
6
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
8
7
  import type {} from '@deepseek-ai/dsh-client-locale/client'
9
8
  import type {} from '@deepseek-ai/dsh-api-remotes/client'
9
+ import type { SlotCore } from '@deepseek-ai/dsh-client-ui-slots'
10
10
  import { EffortDeclareSection } from './EffortDeclareSection.tsx'
11
11
  import type { EffortDeclareSectionInjected, Invalidation } from './EffortDeclareSection.tsx'
12
12
  import { bindSchema } from './schema-ops.ts'
@@ -21,7 +21,36 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
21
21
  }
22
22
  }
23
23
 
24
- export const inject = ['slots', 'locale', 'connection', 'remote', 'settingsScope', 'settingsSchema']
24
+ /**
25
+ * `slots` and `connection/reset` are provided by the unpublished
26
+ * dsh-client-runtime wrapper. 0.1.2-alpha.2 did not publish that package;
27
+ * the shapes match the official models page and SlotCore.
28
+ */
29
+ declare module '@deepseek-ai/cordis' {
30
+ interface Events {
31
+ /**
32
+ * A connection generation was (re-)established. Wire-derived caches must
33
+ * treat their state as stale and repull.
34
+ * @mode emit
35
+ */
36
+ 'connection/reset'(): void
37
+ }
38
+ interface Context {
39
+ slots: SlotCore & {
40
+ inject(name: string, factory: () => unknown): unknown
41
+ }
42
+ }
43
+ }
44
+
45
+ export const inject = [
46
+ 'slots',
47
+ 'locale',
48
+ 'remote',
49
+ 'remote.llm',
50
+ 'remote.settings',
51
+ 'settingsScope',
52
+ 'settingsSchema',
53
+ ]
25
54
 
26
55
  const PLUGIN_ID = 'dsh-plugin-effort-declare'
27
56
 
@@ -39,11 +68,10 @@ function mountPluginCss(): () => void {
39
68
  return () => { tag?.remove() }
40
69
  }
41
70
 
42
- export function apply(ctx: ClientContext): void {
71
+ export function apply(ctx: Context): void {
43
72
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), `${PLUGIN_ID}: dictionaries`)
44
73
  ctx.effect(() => mountPluginCss(), `${PLUGIN_ID}: css`)
45
74
 
46
- const connection = ctx.get('connection') as ConnectionHandle
47
75
  const settingsSchema = ctx.settingsSchema
48
76
  const schema = bindSchema({
49
77
  rehydrate: serialized => settingsSchema.rehydrate(serialized),
@@ -97,7 +125,8 @@ export function apply(ctx: ClientContext): void {
97
125
  label: () => t('nav'),
98
126
  locale: NS,
99
127
  inject: (): EffortDeclareSectionInjected => ({
100
- api: connection.api,
128
+ llm: ctx.remote.llm,
129
+ settings: ctx.remote.settings,
101
130
  describe,
102
131
  schema,
103
132
  subscribeInvalidate,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Load editable route drafts from llm.providers + the llm-pi-ai namespace.
2
+ * Load editable route drafts from llm.listConfigurableProviders + the llm-pi-ai namespace.
3
3
  * Drafts come from the user layer; route protocol classification may use effective value.
4
4
  *
5
5
  * First paint uses `ensure()` (idle-only). Refresh never calls `ensure()`:
@@ -8,8 +8,8 @@
8
8
  * by revision (including older delayed echoes), not ignored as a generic
9
9
  * document-updated.
10
10
  */
11
- import type { IApiClient, SettingsNamespaceView } from '@deepseek-ai/dsh-api-remotes/client'
12
11
  import type { SettingsDescribeFace } from '@deepseek-ai/dsh-client-ui-settings/client'
12
+ import type { LlmDirectoryRemote } from './remotes.ts'
13
13
  import {
14
14
  LLM_PI_AI_NS,
15
15
  SCHEMA_PROBE_ROUTE,
@@ -136,7 +136,7 @@ export async function waitForNamespaceRevisionChange(
136
136
  }
137
137
 
138
138
  async function assembleDrafts(
139
- api: Pick<IApiClient, 'llm'>,
139
+ llm: LlmDirectoryRemote,
140
140
  describe: Pick<SettingsDescribeFace, 'getSnapshot'>,
141
141
  schema: SchemaOps,
142
142
  ): Promise<LoadDraftsResult> {
@@ -144,16 +144,16 @@ async function assembleDrafts(
144
144
  if (mirrored.view === undefined) {
145
145
  return { writable: false, formats: [], drafts: [], error: mirrored.error ?? undefined }
146
146
  }
147
- const providersResponse = await api.llm.providers({})
148
- if (!providersResponse.result.ok) {
147
+ const providersResponse = await llm.listConfigurableProviders()
148
+ if (!providersResponse.ok) {
149
149
  return {
150
150
  writable: mirrored.view.writable,
151
151
  formats: [],
152
152
  drafts: [],
153
- error: providersResponse.result.error.message,
153
+ error: providersResponse.error.message,
154
154
  }
155
155
  }
156
- const namespaces = new Map(mirrored.view.namespaces.map((view: SettingsNamespaceView) => [view.ns, view]))
156
+ const namespaces = new Map(mirrored.view.namespaces.map(view => [view.ns, view]))
157
157
  const pi = namespaces.get(LLM_PI_AI_NS)
158
158
  let formats: string[] = []
159
159
  let schemaDefaultApi: string | undefined
@@ -169,7 +169,7 @@ async function assembleDrafts(
169
169
  }
170
170
  }
171
171
  const drafts: RouteDraft[] = []
172
- for (const entry of providersResponse.result.value.providers) {
172
+ for (const entry of providersResponse.value) {
173
173
  const settingsPath = entry.settingsPath !== undefined && entry.settingsPath.length > 0
174
174
  ? [...entry.settingsPath]
175
175
  : ['providers', entry.provider]
@@ -191,11 +191,11 @@ async function assembleDrafts(
191
191
  * `snapshot`: refresh after the mirror revision already moved — do not ensure.
192
192
  */
193
193
  export async function loadDrafts(
194
- api: Pick<IApiClient, 'llm'>,
194
+ llm: LlmDirectoryRemote,
195
195
  describe: Pick<SettingsDescribeFace, 'ensure' | 'getSnapshot'>,
196
196
  schema: SchemaOps,
197
197
  mode: LoadDraftsMode = 'ensure',
198
198
  ): Promise<LoadDraftsResult> {
199
199
  if (mode === 'ensure') await describe.ensure()
200
- return assembleDrafts(api, describe, schema)
200
+ return assembleDrafts(llm, describe, schema)
201
201
  }
@@ -44,15 +44,18 @@ export type EffortDeclareKey =
44
44
  | 'errorBadWire'
45
45
  | 'noModels'
46
46
  | 'reload'
47
+ | 'imageInput'
48
+ | 'imageInputHint'
49
+ | 'errorBadInput'
47
50
 
48
51
  export const NS = 'plugin-effort-declare'
49
52
 
50
53
  export const zh: Record<EffortDeclareKey, string> = {
51
54
  nav: '推理档位',
52
55
  title: '推理档位声明',
53
- intro: '本页声明「这模型能选哪些推理档」。对话里的档位选择仍在输入框模型菜单。没声明 = 和现在一样没有 Effort 行。不会改密钥、目录或当次选择。',
56
+ intro: '声明手工模型可提供的推理档位,以及是否接受图片输入。未声明则不显示 Effort 行,图片附件也会被拒绝。档位仍在输入框菜单中选择;密钥、目录与当前选中项不在本页修改。',
54
57
  empty: '没有可编辑的手工 openai-completions 路由。',
55
- emptyHint: '请先到「模型」页添加提供方(llm-pi-ai 手工路由)。官方 DeepSeek 与 catalog 路由不在本页编辑。需要 DSH ≥ 0.1.0-rc.8(providers.declared)。',
58
+ emptyHint: '请先到「模型」页添加提供方(llm-pi-ai 手工路由)。官方 DeepSeek 与 catalog 路由不在本页编辑。需要 DSH ≥ 0.1.2-alpha.2。',
56
59
  loadError: '无法加载提供方或设置。',
57
60
  loading: '正在加载…',
58
61
  readOnly: '当前设置为只读,无法保存。',
@@ -60,7 +63,7 @@ export const zh: Record<EffortDeclareKey, string> = {
60
63
  saving: '保存中…',
61
64
  saveBusy: '另有路由正在保存,请稍候。',
62
65
  cancel: '取消',
63
- saved: '已保存。对话选择器会按新的能力声明显示 Effort 行。',
66
+ saved: '已保存。对话会按新的能力声明更新 Effort 行和是否允许贴图。',
64
67
  conflict: '设置已被其他地方改过,请重新加载后再保存。',
65
68
  dirtyConflict: '此路由有未保存修改,设置已在其他地方更新。保存会写到最新文档上,或先取消再改。',
66
69
  presets: '预设',
@@ -89,14 +92,17 @@ export const zh: Record<EffortDeclareKey, string> = {
89
92
  errorBadWire: '思考档必须填写线上拼写;只有 Off 可以留空。不能使用未知档位键。',
90
93
  noModels: '这条路由还没有 models 列表。请先到「模型」页添加模型。',
91
94
  reload: '重新加载',
95
+ imageInput: '支持图片输入',
96
+ imageInputHint: '只在这个模型确实能看图时勾选。勾错了图会进聊天记录,然后被接口打回来。',
97
+ errorBadInput: 'input 只能是 text / image,必须包含 text,不能重复或留空。不支持图片请清除该键,不要写成空列表。',
92
98
  }
93
99
 
94
100
  export const en: Record<EffortDeclareKey, string> = {
95
101
  nav: 'Reasoning efforts',
96
102
  title: 'Reasoning effort declarations',
97
- intro: 'This page declares which reasoning levels a model can offer. The per-turn choice stays in the composer model menu. Undeclared models keep having no Effort row. Keys, catalogs, and the current selection are not edited here.',
103
+ intro: 'Declare reasoning levels and image input for hand-added models. Undeclared models omit the Effort row and refuse image attachments. Effort is still chosen in the composer menu; keys, catalogs, and the current selection are not modified here.',
98
104
  empty: 'No editable hand-declared openai-completions routes.',
99
- emptyHint: 'Add a provider on the Models page first (an llm-pi-ai hand-declared route). Official DeepSeek and catalog routes are not edited here. Requires DSH ≥ 0.1.0-rc.8 (providers.declared).',
105
+ emptyHint: 'Add a provider on the Models page first (an llm-pi-ai hand-declared route). Official DeepSeek and catalog routes are not edited here. Requires DSH ≥ 0.1.2-alpha.2.',
100
106
  loadError: 'Could not load providers or settings.',
101
107
  loading: 'Loading…',
102
108
  readOnly: 'Settings are read-only; saving is disabled.',
@@ -104,7 +110,7 @@ export const en: Record<EffortDeclareKey, string> = {
104
110
  saving: 'Saving…',
105
111
  saveBusy: 'Another route is saving. Wait, then save this card.',
106
112
  cancel: 'Cancel',
107
- saved: 'Saved. The composer Effort row follows this capability declaration.',
113
+ saved: 'Saved. The composer Effort row and image admission follow this capability declaration.',
108
114
  conflict: 'Settings changed elsewhere. Reload, then save again.',
109
115
  dirtyConflict: 'This route has unsaved edits and settings changed elsewhere. Save writes onto the latest document, or cancel first.',
110
116
  presets: 'Presets',
@@ -133,4 +139,7 @@ export const en: Record<EffortDeclareKey, string> = {
133
139
  errorBadWire: 'Thinking levels need a wire spelling; only Off may be empty. Unknown effort keys are rejected.',
134
140
  noModels: 'This route has no models list yet. Add models on the Models page first.',
135
141
  reload: 'Reload',
142
+ imageInput: 'Accepts image input',
143
+ imageInputHint: 'Check only if this model actually sees images. Over-claiming admits a picture into history, then the gateway rejects the turn.',
144
+ errorBadInput: 'input may only list text and image, must include text, and must not be empty or duplicated. To drop vision, unset the key; do not write [].',
136
145
  }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Client Remote faces this page actually calls (DSH 0.1.2).
3
+ * Shapes match the generated Host descriptors, not the removed IApiClient.
4
+ */
5
+ import type { SettingsDescribeFace } from '@deepseek-ai/dsh-client-ui-settings/client'
6
+ import type { ProviderDirectoryEntry } from '../core/filter.ts'
7
+ import type { PathOp } from '../core/path-ops.ts'
8
+
9
+ /** Gateway envelope for a successful Remote call. */
10
+ export type RemoteOk<T> = { ok: true; value: T }
11
+
12
+ /** Gateway envelope for a failed Remote call. */
13
+ export type RemoteErr = { ok: false; error: { code: string; message: string } }
14
+
15
+ export type RemoteResult<T> = RemoteOk<T> | RemoteErr
16
+
17
+ /**
18
+ * `llm.listConfigurableProviders` — generated
19
+ * `@deepseek-ai/dsh-llm#llm/listConfigurableProviders`.
20
+ * `value` is the directory array (no `{ providers }` wrapper).
21
+ */
22
+ export interface LlmDirectoryRemote {
23
+ listConfigurableProviders(): Promise<RemoteResult<readonly ProviderDirectoryEntry[]>>
24
+ }
25
+
26
+ type NamespaceView = Parameters<SettingsDescribeFace['acceptView']>[0]
27
+
28
+ /**
29
+ * `settings.mutate` — generated
30
+ * `@deepseek-ai/dsh-api-settings-controller#settings/mutate`.
31
+ * Conflict code is `settings/conflict`.
32
+ */
33
+ export interface SettingsWriteRemote {
34
+ mutate(
35
+ ns: string,
36
+ ops: readonly PathOp[],
37
+ expectedRevision: number | undefined,
38
+ ): Promise<RemoteResult<NamespaceView>>
39
+ }
@@ -7,22 +7,23 @@
7
7
  </samp>
8
8
  </p>
9
9
 
10
- Domain logic for the plugin: no React, no Cordis service instances. The settings page and Vitest both depend on these pure functions, so effort semantics can regress without booting DSH.
10
+ Domain logic for the plugin: no React, no Cordis service instances. The settings page and Vitest both depend on these pure functions, so reasoning-effort and image-input semantics can regress without booting DSH.
11
11
 
12
- Canonical level names and `thinkingFormat` values follow `@deepseek-ai/dsh-llm-pi-ai` (0.1.0-rc.8; 0.1.1-rc.2 uses the same level set). `thinkingFormat` is pinned to the live-schema snapshot in [`tests/fixtures/pi-ai-thinking-format-union.ts`](../../tests/fixtures/pi-ai-thinking-format-union.ts); effort keys stay a locally pinned whitelist. UI choices come only from the live schema union.
12
+ Canonical level names and `thinkingFormat` values follow `@deepseek-ai/dsh-llm-pi-ai` (0.1.2-alpha.2; the level set matches rc.8, and `thinkingFormat` adds `baseten`). `thinkingFormat` is pinned to the live-schema snapshot in [`tests/fixtures/pi-ai-thinking-format-union.ts`](../../tests/fixtures/pi-ai-thinking-format-union.ts); effort keys stay a locally pinned whitelist. UI choices come only from the live schema union. Writable `models[].input` modalities are `text` and `image`, matching the official schema.
13
13
 
14
14
  ## What's in this directory
15
15
 
16
16
  | File | Role |
17
17
  | --- | --- |
18
- | [`catalog.ts`](./catalog.ts) | Canonical level order, `thinkingFormat` fallback list, `llm-pi-ai` / DeepSeek constants. |
18
+ | [`catalog.ts`](./catalog.ts) | Canonical level order, `thinkingFormat` fallback list, request modalities (`INPUT_MODALITIES` / `IMAGE_CAPABLE_INPUT`), `llm-pi-ai` / DeepSeek constants. |
19
19
  | [`efforts.ts`](./efforts.ts) | `reasoningEfforts` read/write, Off tri-state (value mode stores `trim()`), validation (empty object / Off-only / unknown keys return an error code, never throw). |
20
- | [`presets.ts`](./presets.ts) | DeepSeek, OpenAI, and on/off presets; each states all three dialect keys; spread onto existing model rows and route `compat`. |
20
+ | [`input.ts`](./input.ts) | Per-model `input`: checking writes `['text', 'image']`, unchecking deletes the key; empty list / image-only / duplicates / unknown modalities return an error code. |
21
+ | [`presets.ts`](./presets.ts) | DeepSeek, OpenAI, and on/off presets; each states all three dialect keys; spread onto existing model rows and route `compat`, leaving existing `input` intact. |
21
22
  | [`path-ops.ts`](./path-ops.ts) | Same one-level key diff as the official Models page; `buildSaveOps` uses `settingsPath` and only submits that route’s full `models` table and dirty `compat` keys. |
22
- | [`drafts.ts`](./drafts.ts) | User-layer drafts, dirty aligned with pathOps, post-save revision. On refresh, latest user-layer model membership wins; unsaved `reasoningEfforts` (including a cleared key) overlay by id; `compat` is a per-key 3-way merge. Conflict only when a locally dirty field also moved in originals (revision-only bumps and sibling-card saves do not warn). |
23
+ | [`drafts.ts`](./drafts.ts) | User-layer drafts, dirty aligned with pathOps, post-save revision. On refresh, latest user-layer model membership wins; unsaved overlay keys (`reasoningEfforts` and `input` independently, including a cleared key) overlay by id; `compat` is a per-key 3-way merge. Conflict only when a locally dirty field also moved in originals (revision-only bumps and sibling-card saves do not warn). |
23
24
  | [`paths.ts`](./paths.ts) | Nested reads; clones of objects and model tables (non-object rows skipped). |
24
25
  | [`filter.ts`](./filter.ts) | Which routes are editable: hand-declared `llm-pi-ai` + openai-completions; skip catalog and official DeepSeek. |
25
- | [`validate.ts`](./validate.ts) | Per-row `reasoningEfforts` validation. |
26
+ | [`validate.ts`](./validate.ts) | Per-row validation: `reasoningEfforts` first, then `input`. |
26
27
  | [`attribution.ts`](./attribution.ts) | Settings footer line: `version © year Stardust`. Start year is 2026; end year is the UTC year at pack time, not the user’s clock when DSH starts. |
27
28
 
28
- An **absent** field means default-off. Do not encode undeclared as `reasoningEfforts: false` — in official semantics `false` strips reasoning from a catalog model.
29
+ An **absent** field means default-off. Do not encode an undeclared effort as `reasoningEfforts: false` — in official semantics `false` strips reasoning from a catalog model. Do not encode “no vision” as `input: []` — the official resolver treats an empty list as absent, but a bad stamp must not be re-saved. Disabling image input must delete the key; do not write `['text']`.
@@ -7,22 +7,23 @@
7
7
  </samp>
8
8
  </p>
9
9
 
10
- 本插件的领域逻辑:无 React、无 Cordis 服务实例。设置页与 Vitest 都只依赖这些纯函数,因此档位语义可以在不启动 DSH 的情况下回归。
10
+ 本插件的领域逻辑:无 React、无 Cordis 服务实例。设置页与 Vitest 都只依赖这些纯函数,因此推理档位与图片输入语义可以在不启动 DSH 的情况下回归。
11
11
 
12
- 规范键名与 `thinkingFormat` 取值对齐 `@deepseek-ai/dsh-llm-pi-ai`(0.1.0-rc.8;0.1.1-rc.2 档位集合相同)。`thinkingFormat` 由 [`tests/fixtures/pi-ai-thinking-format-union.ts`](../../tests/fixtures/pi-ai-thinking-format-union.ts) 钉现场 schema;档位键由测试钉本地白名单。UI 可选项只来自现场 schema union
12
+ 规范键名与 `thinkingFormat` 取值对齐 `@deepseek-ai/dsh-llm-pi-ai`(0.1.2-alpha.2;档位集合与 rc.8 相同,`thinkingFormat` 增加 `baseten`)。`thinkingFormat` 由 [`tests/fixtures/pi-ai-thinking-format-union.ts`](../../tests/fixtures/pi-ai-thinking-format-union.ts) 钉现场 schema;档位键由测试钉本地白名单。UI 可选项只来自现场 schema union。`models[].input` 的可写模态为 `text` 与 `image`,与官方 schema 一致。
13
13
 
14
14
  ## 这个目录里有什么
15
15
 
16
16
  | 文件 | 说明 |
17
17
  | --- | --- |
18
- | [`catalog.ts`](./catalog.ts) | 规范档位顺序、`thinkingFormat` 回退列表、`llm-pi-ai` / DeepSeek 相关常量。 |
18
+ | [`catalog.ts`](./catalog.ts) | 规范档位顺序、`thinkingFormat` 回退列表、请求模态(`INPUT_MODALITIES` / `IMAGE_CAPABLE_INPUT`)、`llm-pi-ai` / DeepSeek 相关常量。 |
19
19
  | [`efforts.ts`](./efforts.ts) | `reasoningEfforts` 读写、Off 三态(value 模式写入 `trim()` 后的字符串)、校验(空对象 / 只开 Off / 未知键返回错误码,不抛异常)。 |
20
- | [`presets.ts`](./presets.ts) | DeepSeek、OpenAI、仅开/关三套预设;每套对三个方言键都表态;spread 到已有模型行与路由 `compat`。 |
20
+ | [`input.ts`](./input.ts) | 每模型 `input`:勾选写入 `['text', 'image']`,取消删除该键;空列表 / 仅 image / 重复 / 未知模态返回错误码。 |
21
+ | [`presets.ts`](./presets.ts) | DeepSeek、OpenAI、仅开/关三套预设;每套对三个方言键都表态;spread 到已有模型行与路由 `compat`,保留已有 `input`。 |
21
22
  | [`path-ops.ts`](./path-ops.ts) | 与官方模型页相同的一层键 diff;`buildSaveOps` 使用 `settingsPath`,只提交该路由的 `models` 整表和有差异的 `compat` 键。 |
22
- | [`drafts.ts`](./drafts.ts) | 用户层草稿、dirty 与 pathOps 一致、保存后 revision。刷新时以最新用户层模型名单为成员真理,按 id 贴回未保存的 `reasoningEfforts`(含已清除=删键);`compat` 按键三路合并。冲突仅当本地脏字段的 originals 也变了(只 bump revision 或别的卡保存不报)。 |
23
+ | [`drafts.ts`](./drafts.ts) | 用户层草稿、dirty 与 pathOps 一致、保存后 revision。刷新时以最新用户层模型名单为成员真理,按 id 贴回未保存的 overlay 键(`reasoningEfforts` 与 `input` 独立,含已清除 = 删键);`compat` 按键三路合并。冲突仅当本地脏字段的 originals 也变了(只 bump revision 或别的卡保存不报)。 |
23
24
  | [`paths.ts`](./paths.ts) | 嵌套读取、对象与模型表的 clone(非对象行跳过)。 |
24
25
  | [`filter.ts`](./filter.ts) | 哪些路由可编辑:手工 `llm-pi-ai` + openai-completions;排除 catalog 与官方 DeepSeek。 |
25
- | [`validate.ts`](./validate.ts) | 对单行 `reasoningEfforts` 调用校验。 |
26
+ | [`validate.ts`](./validate.ts) | 对单行先校验 `reasoningEfforts`,再校验 `input`。 |
26
27
  | [`attribution.ts`](./attribution.ts) | 设置页页脚:`version © 年 Stardust`。首年写死 2026,结束年由打包时的 UTC 年注入,不是用户打开 DSH 的日期。 |
27
28
 
28
- **缺席字段**表示默认关闭。不要把「未声明」写成 `reasoningEfforts: false`——`false` 在官方语义里是从 catalog 模型上剥掉推理。
29
+ **缺席字段**表示默认关闭。不要把「未声明档位」写成 `reasoningEfforts: false`——`false` 在官方语义里是从 catalog 模型上剥掉推理。不要把「未声明视觉」写成 `input: []`——官方把空列表当成缺席,但坏戳记不应被重新保存。取消图片输入必须删除该键,而不是写成 `['text']`。
@@ -2,7 +2,7 @@
2
2
  * Canonical thinking levels and openai-completions thinkingFormat names.
3
3
  *
4
4
  * Levels match `@deepseek-ai/dsh-llm-pi-ai` catalog.ts `THINKING_LEVELS`.
5
- * Formats match `SUPPORTED_THINKING_FORMATS` in the same file (rc.8).
5
+ * Formats match `SUPPORTED_THINKING_FORMATS` in the same file (0.1.2-alpha.2).
6
6
  * Tests pin these lists against a checked-in schema fixture
7
7
  * (`tests/fixtures/pi-ai-thinking-format-union.ts`) and the local level
8
8
  * whitelist. The settings page never offers the handwritten thinkingFormat
@@ -29,7 +29,7 @@ export const THINKING_LEVELS_WITHOUT_OFF = THINKING_LEVELS.filter(
29
29
  )
30
30
 
31
31
  /**
32
- * openai-completions thinkingFormat values from llm-pi-ai catalog.ts rc.8.
32
+ * openai-completions thinkingFormat values from llm-pi-ai catalog.ts 0.1.2-alpha.2.
33
33
  * Test pin only — not a writable UI fallback.
34
34
  */
35
35
  export const FALLBACK_THINKING_FORMATS = [
@@ -37,6 +37,7 @@ export const FALLBACK_THINKING_FORMATS = [
37
37
  'deepseek',
38
38
  'openrouter',
39
39
  'together',
40
+ 'baseten',
40
41
  'zai',
41
42
  'qwen',
42
43
  'chat-template',
@@ -61,3 +62,14 @@ export const DEEPSEEK_OFFICIAL = 'deepseek-official'
61
62
 
62
63
  /** Any route key walks a dict schema to the same profile node. */
63
64
  export const SCHEMA_PROBE_ROUTE = '\u0000probe'
65
+
66
+ /** Request modalities llm-pi-ai accepts on `models[].input` / `defaultInput`. */
67
+ export const INPUT_MODALITIES = ['text', 'image'] as const
68
+
69
+ export type InputModality = (typeof INPUT_MODALITIES)[number]
70
+
71
+ /**
72
+ * Canonical write for a hand-declared vision model.
73
+ * Must include `text`; image-only is not a serviceable OpenAI-completions route.
74
+ */
75
+ export const IMAGE_CAPABLE_INPUT: readonly InputModality[] = ['text', 'image']
@@ -10,7 +10,7 @@ import { cloneModels, cloneObject, isPlainObject } from './paths.ts'
10
10
  export interface RouteDraft {
11
11
  provider: string
12
12
  displayName: string
13
- /** Path inside the llm-pi-ai section (`llm.providers[].settingsPath`). */
13
+ /** Path inside the llm-pi-ai section (`listConfigurableProviders[].settingsPath`). */
14
14
  settingsPath: readonly string[]
15
15
  /** Namespace revision (one value for the whole llm-pi-ai document). */
16
16
  revision: number
@@ -112,31 +112,42 @@ function indexById(rows: readonly Record<string, unknown>[]): Map<string, Record
112
112
  return map
113
113
  }
114
114
 
115
- function effortsPresence(row: Record<string, unknown> | undefined): { present: boolean; value: unknown } {
116
- if (row === undefined || !Object.hasOwn(row, 'reasoningEfforts')) {
115
+ /** Model-row fields this page edits; other keys follow the Models page. */
116
+ export const MODEL_OVERLAY_KEYS = ['reasoningEfforts', 'input'] as const
117
+
118
+ export type ModelOverlayKey = (typeof MODEL_OVERLAY_KEYS)[number]
119
+
120
+ function fieldPresence(
121
+ row: Record<string, unknown> | undefined,
122
+ key: ModelOverlayKey,
123
+ ): { present: boolean; value: unknown } {
124
+ if (row === undefined || !Object.hasOwn(row, key)) {
117
125
  return { present: false, value: undefined }
118
126
  }
119
- return { present: true, value: row.reasoningEfforts }
127
+ return { present: true, value: row[key] }
120
128
  }
121
129
 
122
- function effortsEqual(
123
- left: { present: boolean; value: unknown },
124
- right: { present: boolean; value: unknown },
130
+ function fieldEqual(
131
+ left: Record<string, unknown> | undefined,
132
+ right: Record<string, unknown> | undefined,
133
+ key: ModelOverlayKey,
125
134
  ): boolean {
126
- if (left.present !== right.present) return false
127
- if (!left.present) return true
128
- return sliceEqual(left.value, right.value)
135
+ const a = fieldPresence(left, key)
136
+ const b = fieldPresence(right, key)
137
+ if (a.present !== b.present) return false
138
+ if (!a.present) return true
139
+ return sliceEqual(a.value, b.value)
129
140
  }
130
141
 
131
- function overlayLocalEfforts(
142
+ function overlayLocalFields(
132
143
  incomingRow: Record<string, unknown>,
133
144
  prevRow: Record<string, unknown>,
145
+ keys: readonly ModelOverlayKey[],
134
146
  ): Record<string, unknown> {
135
147
  const next = structuredClone(incomingRow)
136
- if (Object.hasOwn(prevRow, 'reasoningEfforts')) {
137
- next.reasoningEfforts = structuredClone(prevRow.reasoningEfforts)
138
- } else {
139
- delete next.reasoningEfforts
148
+ for (const key of keys) {
149
+ if (Object.hasOwn(prevRow, key)) next[key] = structuredClone(prevRow[key])
150
+ else delete next[key]
140
151
  }
141
152
  return next
142
153
  }
@@ -155,7 +166,8 @@ function objectKeyChanged(
155
166
 
156
167
  /**
157
168
  * Membership follows the latest user-layer models list (Models page add/delete).
158
- * Local unsaved `reasoningEfforts` (including a cleared key) overlay by id.
169
+ * Local unsaved overlay keys (including a cleared key) overlay by id; other
170
+ * fields on the row follow incoming.
159
171
  */
160
172
  export function mergeModelsById(args: {
161
173
  prevModels: readonly Record<string, unknown>[]
@@ -174,21 +186,23 @@ export function mergeModelsById(args: {
174
186
  const prevRow = prevById.get(id)
175
187
  if (prevRow === undefined) return structuredClone(incomingRow)
176
188
  const prevOrig = prevOrigById.get(id)
177
- const localDirty = !effortsEqual(effortsPresence(prevRow), effortsPresence(prevOrig))
178
- if (!localDirty) return structuredClone(incomingRow)
189
+ const dirtyKeys = MODEL_OVERLAY_KEYS.filter(key => !fieldEqual(prevRow, prevOrig, key))
190
+ if (dirtyKeys.length === 0) return structuredClone(incomingRow)
179
191
  const incomingOrig = incomingOrigById.get(id)
180
- if (!effortsEqual(effortsPresence(prevOrig), effortsPresence(incomingOrig))) {
181
- conflicted = true
192
+ for (const key of dirtyKeys) {
193
+ if (!fieldEqual(prevOrig, incomingOrig, key)) conflicted = true
182
194
  }
183
- return overlayLocalEfforts(incomingRow, prevRow)
195
+ return overlayLocalFields(incomingRow, prevRow, dirtyKeys)
184
196
  })
185
197
 
186
198
  for (const [id, prevRow] of prevById) {
187
199
  if (incomingIds.has(id)) continue
188
200
  const prevOrig = prevOrigById.get(id)
189
- if (effortsEqual(effortsPresence(prevRow), effortsPresence(prevOrig))) continue
190
- if (!effortsEqual(effortsPresence(prevOrig), effortsPresence(incomingOrigById.get(id)))) {
191
- conflicted = true
201
+ const dirtyKeys = MODEL_OVERLAY_KEYS.filter(key => !fieldEqual(prevRow, prevOrig, key))
202
+ if (dirtyKeys.length === 0) continue
203
+ const incomingOrig = incomingOrigById.get(id)
204
+ for (const key of dirtyKeys) {
205
+ if (!fieldEqual(prevOrig, incomingOrig, key)) conflicted = true
192
206
  }
193
207
  }
194
208
 
@@ -222,9 +236,9 @@ export function mergeCompat(args: {
222
236
 
223
237
  /**
224
238
  * Apply a freshly loaded table. Membership and metadata follow incoming;
225
- * unsaved reasoningEfforts / dirty compat keys overlay by id. Conflict only
226
- * when a locally dirty field also changed in originals (revision-only bumps
227
- * and sibling-card saves do not warn).
239
+ * unsaved overlay keys (`reasoningEfforts`, `input`) / dirty compat keys
240
+ * overlay by id. Conflict only when a locally dirty field also changed in
241
+ * originals (revision-only bumps and sibling-card saves do not warn).
228
242
  */
229
243
  export function mergeLoadedDrafts(
230
244
  current: readonly RouteDraft[],
@@ -6,7 +6,7 @@ import {
6
6
  } from './catalog.ts'
7
7
  import { getPath, isPlainObject } from './paths.ts'
8
8
 
9
- /** Directory row from `llm.providers()` (the fields v1 filtering reads). */
9
+ /** Directory row from `llm.listConfigurableProviders()` (the fields v1 filtering reads). */
10
10
  export interface ProviderDirectoryEntry {
11
11
  provider: string
12
12
  displayName?: string
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Per-model `input` modalities as stored in llm-pi-ai settings.
3
+ * Absence falls through to route `defaultInput` (`[text]`). Empty list is
4
+ * treated as absent by the official resolver — do not write `[]`.
5
+ */
6
+ import { IMAGE_CAPABLE_INPUT, INPUT_MODALITIES } from './catalog.ts'
7
+
8
+ /** Whether the stored `input` list includes image. Absence is false. */
9
+ export function readImageCapable(row: Record<string, unknown>): boolean {
10
+ const value = row.input
11
+ return Array.isArray(value) && value.includes('image')
12
+ }
13
+
14
+ /**
15
+ * Declare or drop image input on a spread row.
16
+ * Enabled writes `[text, image]`; disabled unsets the key (not `[]`, not `[text]`).
17
+ */
18
+ export function writeImageCapable(
19
+ row: Record<string, unknown>,
20
+ enabled: boolean,
21
+ ): Record<string, unknown> {
22
+ const next = { ...row }
23
+ if (enabled) next.input = [...IMAGE_CAPABLE_INPUT]
24
+ else delete next.input
25
+ return next
26
+ }
27
+
28
+ /**
29
+ * Validate a stored `input` field. Returns an error code; never throws.
30
+ * Absence is valid. Empty list is rejected so a bad stamp cannot be re-saved.
31
+ */
32
+ export function validateInput(input: unknown): 'bad-input' | undefined {
33
+ if (input === undefined) return undefined
34
+ if (!Array.isArray(input) || input.length === 0) return 'bad-input'
35
+ const known = new Set<string>(INPUT_MODALITIES)
36
+ const seen = new Set<string>()
37
+ for (const item of input) {
38
+ if (typeof item !== 'string' || !known.has(item) || seen.has(item)) return 'bad-input'
39
+ seen.add(item)
40
+ }
41
+ if (!seen.has('text')) return 'bad-input'
42
+ return undefined
43
+ }
44
+
45
+ /** Per-model client-side check used to show errors without throwing. */
46
+ export function modelInputError(row: Record<string, unknown>): 'bad-input' | undefined {
47
+ if (!('input' in row) || row.input === undefined) return undefined
48
+ return validateInput(row.input)
49
+ }
@@ -33,7 +33,7 @@ export function pathOps(
33
33
  }
34
34
 
35
35
  export interface SaveSlices {
36
- /** Profile path from `llm.providers[].settingsPath` (not a hardcoded route id). */
36
+ /** Profile path from `listConfigurableProviders[].settingsPath` (not a hardcoded route id). */
37
37
  settingsPath: readonly string[]
38
38
  /** Models array before the edit (user layer). */
39
39
  beforeModels: unknown
@@ -1,7 +1,15 @@
1
1
  import { validateReasoningEfforts } from './efforts.ts'
2
+ import { modelInputError } from './input.ts'
3
+
4
+ export type ModelRowError = 'empty' | 'off-only' | 'bad-wire' | 'bad-input'
2
5
 
3
6
  /** Per-model client-side check used to show errors without throwing. */
4
7
  export function modelEffortError(row: Record<string, unknown>): 'empty' | 'off-only' | 'bad-wire' | undefined {
5
8
  if (!('reasoningEfforts' in row) || row.reasoningEfforts === undefined) return undefined
6
9
  return validateReasoningEfforts(row.reasoningEfforts)
7
10
  }
11
+
12
+ /** First blocking error on a model row (efforts, then input). */
13
+ export function modelRowError(row: Record<string, unknown>): ModelRowError | undefined {
14
+ return modelEffortError(row) ?? modelInputError(row)
15
+ }