dsh-thinking-levels 0.3.1 → 0.4.1
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 +1 -5
- package/README.zh.md +1 -5
- package/lib/client.js +1 -0
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +36 -4
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -91,11 +91,7 @@ Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: f
|
|
|
91
91
|
|
|
92
92
|
## Dependency note
|
|
93
93
|
|
|
94
|
-
The host half value-
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
dsh plugin --profile web add @deepseek-ai/dsh-settings@^0.1.0-rc.7 -w
|
|
98
|
-
```
|
|
94
|
+
The host half does **not** value-depend on `@deepseek-ai/dsh-settings` (settings registration goes through the cordis `settings` service provided by the dsh runtime) — no need to install official packages into the profile manually. `dependencies` is just `@deepseek-ai/schemastery` (installed automatically with the package).
|
|
99
95
|
|
|
100
96
|
## Development
|
|
101
97
|
|
package/README.zh.md
CHANGED
|
@@ -91,11 +91,7 @@ cd ~/.dsh/profiles/web && pnpm install && dsh web
|
|
|
91
91
|
|
|
92
92
|
## 依赖说明
|
|
93
93
|
|
|
94
|
-
插件 host
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
dsh plugin --profile web add @deepseek-ai/dsh-settings@^0.1.0-rc.7 -w
|
|
98
|
-
```
|
|
94
|
+
插件 host 侧**不**值依赖 `@deepseek-ai/dsh-settings`(设置注册通过 cordis 的 `settings` 服务,由 dsh 运行时提供)——无需在 profile 中手动安装官方包。`dependencies` 仅 `@deepseek-ai/schemastery`(随包自动安装)。
|
|
99
95
|
|
|
100
96
|
## 开发
|
|
101
97
|
|
package/lib/client.js
CHANGED
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["useSyncExternalStore"],"sources":["../src/client/locales.ts","../src/client/card.tsx","../src/client/index.ts"],"sourcesContent":["/** `thinking-levels` client dictionaries. */\r\n\r\n/** Dictionary namespace owned by this plugin. */\r\nexport const NS = 'thinking-levels'\r\n\r\n/** Simplified Chinese dictionary (the key-set source of truth). */\r\nexport const zh = {\r\n 'card.title': '思考档位',\r\n 'card.description': '在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位与调度边界。',\r\n 'card.level': '默认档位',\r\n 'card.level.off': 'off — 关闭思考(仅手动,永不自动选择)',\r\n 'card.level.low': 'low — 低(简单任务,廉价轮保持廉价)',\r\n 'card.level.high': 'high — 高(官方默认)',\r\n 'card.level.max': 'max — 最大(重任务)',\r\n 'card.level.auto': 'auto — 按工具历史自动调度(默认)',\r\n 'card.enabled': '启用',\r\n 'card.allowDowngrade': '允许降档(auto 可降至 low)',\r\n 'card.allowUpgrade': '允许升档(auto 可升至 max)',\r\n 'card.unavailable': '设置命名空间不可用:请确认 dsh-thinking-levels 已装配进 profile。',\r\n 'card.readonly': '只读',\r\n} satisfies Record<string, string>\r\n\r\n/** English dictionary (keys mirror zh). */\r\nexport const en: Record<keyof typeof zh, string> = {\r\n 'card.title': 'Thinking Levels',\r\n 'card.description': 'Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level and scheduler bounds.',\r\n 'card.level': 'Default level',\r\n 'card.level.off': 'off — disable thinking (manual only, never auto-picked)',\r\n 'card.level.low': 'low — cheap rounds stay cheap',\r\n 'card.level.high': 'high — the official default',\r\n 'card.level.max': 'max — heavy work',\r\n 'card.level.auto': 'auto — schedule from tool history (default)',\r\n 'card.enabled': 'Enabled',\r\n 'card.allowDowngrade': 'Allow downgrade (auto may drop to low)',\r\n 'card.allowUpgrade': 'Allow upgrade (auto may lift to max)',\r\n 'card.unavailable': 'Settings namespace unavailable: make sure dsh-thinking-levels is assembled into this profile.',\r\n 'card.readonly': 'Read-only',\r\n}\r\n","/**\r\n * Thinking-levels settings card — the `settings.plugin.item` face of the\r\n * dsh-thinking-levels plugin.\r\n *\r\n * The card binds the `thinking-levels` settings namespace through the\r\n * `settingsScope` cordis service and renders its four fields: the level picker\r\n * (off / low / high / max / auto) plus the three scheduler toggles. Every\r\n * change commits immediately through the scope (no staged form): the decision\r\n * is read per model request, so a committed change applies to the next request\r\n * without a restart.\r\n *\r\n * Kept dependency-free beyond react: the scope is subscribed with\r\n * `useSyncExternalStore`, and the controls are plain HTML so the client bundle\r\n * needs no CSS modules and no primitives value import.\r\n */\r\nimport { useSyncExternalStore } from 'react'\r\nimport type { CSSProperties, JSX } from 'react'\r\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\r\nimport type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { EffortId } from '../thinking-level.ts'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\n\r\n/** One injected face: the bound settings scope for the `thinking-levels` namespace. */\r\nexport interface ThinkingLevelsCardInjected {\r\n scope: SettingsScope<ThinkingLevelsConfig>\r\n}\r\n\r\n/** Full props: locale seat + the injected scope. */\r\nexport type ThinkingLevelsCardProps = PropsLocale<'thinking-levels'> & ThinkingLevelsCardInjected\r\n\r\n/** The five user-facing levels, in picker order. */\r\nconst EFFORT_OPTIONS: readonly EffortId[] = ['off', 'low', 'high', 'max', 'auto']\r\n\r\n/** Minimal shared row styling (inline; keeps the client bundle CSS-free). */\r\nconst rowStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'space-between',\r\n gap: '12px',\r\n padding: '6px 0',\r\n fontSize: '13px',\r\n lineHeight: '20px',\r\n}\r\n\r\nconst labelStyle: CSSProperties = { margin: 0, color: 'var(--dsw-alias-label-primary)' }\r\n\r\nconst controlStyle: CSSProperties = {\r\n background: 'var(--dsw-alias-bg-surface, #fff)',\r\n color: 'var(--dsw-alias-label-primary)',\r\n border: '1px solid var(--dsw-alias-border-l2)',\r\n borderRadius: '4px',\r\n padding: '3px 8px',\r\n fontSize: '13px',\r\n}\r\n\r\n/** One boolean field row (checkbox) bound to the scope. */\r\nfunction ToggleRow(props: {\r\n id: string\r\n label: string\r\n checked: boolean\r\n disabled: boolean\r\n onChange: (next: boolean) => void\r\n}): JSX.Element {\r\n const { id, label, checked, disabled, onChange } = props\r\n return (\r\n <div style={rowStyle}>\r\n <label htmlFor={id} style={labelStyle}>{label}</label>\r\n <input\r\n id={id}\r\n type=\"checkbox\"\r\n checked={checked}\r\n disabled={disabled}\r\n onChange={(event) => onChange(event.currentTarget.checked)}\r\n />\r\n </div>\r\n )\r\n}\r\n\r\n/**\r\n * The card body.\r\n * @param props - locale copy and the injected settings scope.\r\n */\r\nexport function ThinkingLevelsCard({ t, scope }: ThinkingLevelsCardProps): JSX.Element {\r\n const snapshot = useSyncExternalStore(\r\n (listener) => scope.subscribe(listener),\r\n () => scope.getSnapshot(),\r\n )\r\n const unavailable = snapshot.status === 'unavailable'\r\n const readonly = unavailable || !snapshot.writable\r\n const value = (snapshot.value ?? {}) as Partial<ThinkingLevelsConfig>\r\n const level = EFFORT_OPTIONS.includes(value.level as EffortId) ? value.level as EffortId : 'auto'\r\n\r\n if (unavailable) {\r\n return (\r\n <div style={{ padding: '12px 16px', fontSize: '13px', color: 'var(--dsw-alias-label-tertiary)' }}>\r\n {t('card.unavailable')}\r\n </div>\r\n )\r\n }\r\n\r\n return (\r\n <div style={{ padding: '12px 16px' }}>\r\n <div style={rowStyle}>\r\n <label htmlFor=\"plugin-config-thinking-levels-level\" style={labelStyle}>{t('card.level')}</label>\r\n <select\r\n id=\"plugin-config-thinking-levels-level\"\r\n value={level}\r\n disabled={readonly}\r\n style={controlStyle}\r\n onChange={(event) => { void scope.set('level', event.currentTarget.value as EffortId) }}\r\n >\r\n {EFFORT_OPTIONS.map((option) => (\r\n <option key={option} value={option}>{t(`card.level.${option}`)}</option>\r\n ))}\r\n </select>\r\n </div>\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-enabled\"\r\n label={t('card.enabled')}\r\n checked={value.enabled ?? true}\r\n disabled={readonly}\r\n onChange={(next) => { void scope.set('enabled', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-downgrade\"\r\n label={t('card.allowDowngrade')}\r\n checked={value.allowDowngrade ?? true}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowDowngrade', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-upgrade\"\r\n label={t('card.allowUpgrade')}\r\n checked={value.allowUpgrade ?? false}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowUpgrade', next) }}\r\n />\r\n {!snapshot.writable && <p style={{ margin: '8px 0 0', fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)' }}>{t('card.readonly')}</p>}\r\n </div>\r\n )\r\n}\r\n","/**\r\n * dsh-thinking-levels — browser half.\r\n *\r\n * Registers the `thinking-levels` dictionaries and one `settings.plugin.item`\r\n * card keyed by the plugin's settings namespace, so the shared Plugins\r\n * settings tab renders an editable card: the level picker (off / low / high /\r\n * max / auto) plus the scheduler toggles.\r\n *\r\n * All @deepseek-ai/* imports are type-only: collaboration happens through\r\n * cordis services (`settingsScope`) and slot registration only (client bundle\r\n * purity).\r\n */\r\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\r\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\r\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\nimport { NS, en, zh } from './locales.ts'\r\nimport { ThinkingLevelsCard, type ThinkingLevelsCardInjected } from './card.tsx'\r\n\r\n/** The settings namespace the host half registers (kept in lockstep with src/index.ts). */\r\nconst THINKING_LEVELS_NS = 'thinking-levels'\r\n\r\n/** Services required by the browser half. */\r\nexport const inject = ['slots', 'locale', 'settingsScope']\r\n\r\n/**\r\n * Client plugin body: dictionaries plus the settings card registration.\r\n * @param ctx - client root context.\r\n */\r\nexport function apply(ctx: ClientContext): void {\r\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-thinking-levels: dictionaries')\r\n\r\n ctx.slots.inject('settings.plugin.item', function* () {\r\n yield ctx.slots.register({\r\n name: 'settings.plugin.item',\r\n key: THINKING_LEVELS_NS,\r\n locale: NS,\r\n inject: (): ThinkingLevelsCardInjected => {\r\n const scope = ctx.settingsScope.bind<ThinkingLevelsConfig>({ namespace: THINKING_LEVELS_NS })\r\n return { scope }\r\n },\r\n }, ThinkingLevelsCard)\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;EAGA,MAAa,KAAK;;EAGlB,MAAa,KAAK;GAChB,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;EAGA,MAAa,KAAsC;GACjD,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;;;;;;;;;;;;;;;;;;ECNA,MAAM,iBAAsC;GAAC;GAAO;GAAO;GAAQ;GAAO;EAAM;;EAGhF,MAAM,WAA0B;GAC9B,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GACL,SAAS;GACT,UAAU;GACV,YAAY;EACd;EAEA,MAAM,aAA4B;GAAE,QAAQ;GAAG,OAAO;EAAiC;EAEvF,MAAM,eAA8B;GAClC,YAAY;GACZ,OAAO;GACP,QAAQ;GACR,cAAc;GACd,SAAS;GACT,UAAU;EACZ;;EAGA,SAAS,UAAU,OAMH;GACd,MAAM,EAAE,IAAI,OAAO,SAAS,UAAU,aAAa;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AAmB,CAC9E,EAAE;KACjB;IACF,GAAG,kBAAkB;GACvB,CAAC;EACH"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["useSyncExternalStore"],"sources":["../src/client/locales.ts","../src/client/card.tsx","../src/client/index.ts"],"sourcesContent":["/** `thinking-levels` client dictionaries. */\r\n\r\n/** Dictionary namespace owned by this plugin. */\r\nexport const NS = 'thinking-levels'\r\n\r\n/** Simplified Chinese dictionary (the key-set source of truth). */\r\nexport const zh = {\r\n 'card.title': '思考档位',\r\n 'card.description': '在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位与调度边界。',\r\n 'card.level': '默认档位',\r\n 'card.level.off': 'off — 关闭思考(仅手动,永不自动选择)',\r\n 'card.level.low': 'low — 低(简单任务,廉价轮保持廉价)',\r\n 'card.level.high': 'high — 高(官方默认)',\r\n 'card.level.max': 'max — 最大(重任务)',\r\n 'card.level.auto': 'auto — 按工具历史自动调度(默认)',\r\n 'card.enabled': '启用',\r\n 'card.allowDowngrade': '允许降档(auto 可降至 low)',\r\n 'card.allowUpgrade': '允许升档(auto 可升至 max)',\r\n 'card.unavailable': '设置命名空间不可用:请确认 dsh-thinking-levels 已装配进 profile。',\r\n 'card.readonly': '只读',\r\n} satisfies Record<string, string>\r\n\r\n/** English dictionary (keys mirror zh). */\r\nexport const en: Record<keyof typeof zh, string> = {\r\n 'card.title': 'Thinking Levels',\r\n 'card.description': 'Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level and scheduler bounds.',\r\n 'card.level': 'Default level',\r\n 'card.level.off': 'off — disable thinking (manual only, never auto-picked)',\r\n 'card.level.low': 'low — cheap rounds stay cheap',\r\n 'card.level.high': 'high — the official default',\r\n 'card.level.max': 'max — heavy work',\r\n 'card.level.auto': 'auto — schedule from tool history (default)',\r\n 'card.enabled': 'Enabled',\r\n 'card.allowDowngrade': 'Allow downgrade (auto may drop to low)',\r\n 'card.allowUpgrade': 'Allow upgrade (auto may lift to max)',\r\n 'card.unavailable': 'Settings namespace unavailable: make sure dsh-thinking-levels is assembled into this profile.',\r\n 'card.readonly': 'Read-only',\r\n}\r\n","/**\r\n * Thinking-levels settings card — the `settings.plugin.item` face of the\r\n * dsh-thinking-levels plugin.\r\n *\r\n * The card binds the `thinking-levels` settings namespace through the\r\n * `settingsScope` cordis service and renders its four fields: the level picker\r\n * (off / low / high / max / auto) plus the three scheduler toggles. Every\r\n * change commits immediately through the scope (no staged form): the decision\r\n * is read per model request, so a committed change applies to the next request\r\n * without a restart.\r\n *\r\n * Kept dependency-free beyond react: the scope is subscribed with\r\n * `useSyncExternalStore`, and the controls are plain HTML so the client bundle\r\n * needs no CSS modules and no primitives value import.\r\n */\r\nimport { useSyncExternalStore } from 'react'\r\nimport type { CSSProperties, JSX } from 'react'\r\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\r\nimport type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { EffortId } from '../thinking-level.ts'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\n\r\n/** One injected face: the bound settings scope for the `thinking-levels` namespace. */\r\nexport interface ThinkingLevelsCardInjected {\r\n scope: SettingsScope<ThinkingLevelsConfig>\r\n}\r\n\r\n/** Full props: locale seat + the injected scope. */\r\nexport type ThinkingLevelsCardProps = PropsLocale<'thinking-levels'> & ThinkingLevelsCardInjected\r\n\r\n/** The five user-facing levels, in picker order. */\r\nconst EFFORT_OPTIONS: readonly EffortId[] = ['off', 'low', 'high', 'max', 'auto']\r\n\r\n/** Minimal shared row styling (inline; keeps the client bundle CSS-free). */\r\nconst rowStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'space-between',\r\n gap: '12px',\r\n padding: '6px 0',\r\n fontSize: '13px',\r\n lineHeight: '20px',\r\n}\r\n\r\nconst labelStyle: CSSProperties = { margin: 0, color: 'var(--dsw-alias-label-primary)' }\r\n\r\nconst controlStyle: CSSProperties = {\r\n background: 'var(--dsw-alias-bg-surface, #fff)',\r\n color: 'var(--dsw-alias-label-primary)',\r\n border: '1px solid var(--dsw-alias-border-l2)',\r\n borderRadius: '4px',\r\n padding: '3px 8px',\r\n fontSize: '13px',\r\n}\r\n\r\n/** One boolean field row (checkbox) bound to the scope. */\r\nfunction ToggleRow(props: {\r\n id: string\r\n label: string\r\n checked: boolean\r\n disabled: boolean\r\n onChange: (next: boolean) => void\r\n}): JSX.Element {\r\n const { id, label, checked, disabled, onChange } = props\r\n return (\r\n <div style={rowStyle}>\r\n <label htmlFor={id} style={labelStyle}>{label}</label>\r\n <input\r\n id={id}\r\n type=\"checkbox\"\r\n checked={checked}\r\n disabled={disabled}\r\n onChange={(event) => onChange(event.currentTarget.checked)}\r\n />\r\n </div>\r\n )\r\n}\r\n\r\n/**\r\n * The card body.\r\n * @param props - locale copy and the injected settings scope.\r\n */\r\nexport function ThinkingLevelsCard({ t, scope }: ThinkingLevelsCardProps): JSX.Element {\r\n const snapshot = useSyncExternalStore(\r\n (listener) => scope.subscribe(listener),\r\n () => scope.getSnapshot(),\r\n )\r\n const unavailable = snapshot.status === 'unavailable'\r\n const readonly = unavailable || !snapshot.writable\r\n const value = (snapshot.value ?? {}) as Partial<ThinkingLevelsConfig>\r\n const level = EFFORT_OPTIONS.includes(value.level as EffortId) ? value.level as EffortId : 'auto'\r\n\r\n if (unavailable) {\r\n return (\r\n <div style={{ padding: '12px 16px', fontSize: '13px', color: 'var(--dsw-alias-label-tertiary)' }}>\r\n {t('card.unavailable')}\r\n </div>\r\n )\r\n }\r\n\r\n return (\r\n <div style={{ padding: '12px 16px' }}>\r\n <div style={rowStyle}>\r\n <label htmlFor=\"plugin-config-thinking-levels-level\" style={labelStyle}>{t('card.level')}</label>\r\n <select\r\n id=\"plugin-config-thinking-levels-level\"\r\n value={level}\r\n disabled={readonly}\r\n style={controlStyle}\r\n onChange={(event) => { void scope.set('level', event.currentTarget.value as EffortId) }}\r\n >\r\n {EFFORT_OPTIONS.map((option) => (\r\n <option key={option} value={option}>{t(`card.level.${option}`)}</option>\r\n ))}\r\n </select>\r\n </div>\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-enabled\"\r\n label={t('card.enabled')}\r\n checked={value.enabled ?? true}\r\n disabled={readonly}\r\n onChange={(next) => { void scope.set('enabled', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-downgrade\"\r\n label={t('card.allowDowngrade')}\r\n checked={value.allowDowngrade ?? true}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowDowngrade', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-upgrade\"\r\n label={t('card.allowUpgrade')}\r\n checked={value.allowUpgrade ?? false}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowUpgrade', next) }}\r\n />\r\n {!snapshot.writable && <p style={{ margin: '8px 0 0', fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)' }}>{t('card.readonly')}</p>}\r\n </div>\r\n )\r\n}\r\n","/**\r\n * dsh-thinking-levels — browser half.\r\n *\r\n * Registers the `thinking-levels` dictionaries and one `settings.plugin.item`\r\n * card keyed by the plugin's settings namespace, so the shared Plugins\r\n * settings tab renders an editable card: the level picker (off / low / high /\r\n * max / auto) plus the scheduler toggles.\r\n *\r\n * All @deepseek-ai/* imports are type-only: collaboration happens through\r\n * cordis services (`settingsScope`) and slot registration only (client bundle\r\n * purity).\r\n */\r\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\r\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\r\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\nimport { NS, en, zh } from './locales.ts'\r\nimport { ThinkingLevelsCard, type ThinkingLevelsCardInjected } from './card.tsx'\r\n\r\n/** The settings namespace the host half registers (kept in lockstep with src/index.ts). */\r\nconst THINKING_LEVELS_NS = 'thinking-levels'\r\n\r\n/** Services required by the browser half. */\r\nexport const inject = ['slots', 'locale', 'settingsScope']\r\n\r\n/**\r\n * Client plugin body: dictionaries plus the settings card registration.\r\n * @param ctx - client root context.\r\n */\r\nexport function apply(ctx: ClientContext): void {\r\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-thinking-levels: dictionaries')\r\n\r\n ctx.slots.inject('settings.plugin.item', function* () {\r\n yield ctx.slots.register({\r\n name: 'settings.plugin.item',\r\n // Both keys are supplied: CLI dsh declares this slot `keyed` (needs\r\n // `key`) while DSH Desktop's bundled version declares it `list` (needs\r\n // `id`) — the slots service validates only its kind's field, so the\r\n // pair keeps the card working in both environments.\r\n id: THINKING_LEVELS_NS,\r\n key: THINKING_LEVELS_NS,\r\n locale: NS,\r\n inject: (): ThinkingLevelsCardInjected => {\r\n const scope = ctx.settingsScope.bind<ThinkingLevelsConfig>({ namespace: THINKING_LEVELS_NS })\r\n return { scope }\r\n },\r\n }, ThinkingLevelsCard)\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;EAGA,MAAa,KAAK;;EAGlB,MAAa,KAAK;GAChB,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;EAGA,MAAa,KAAsC;GACjD,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;;;;;;;;;;;;;;;;;;ECNA,MAAM,iBAAsC;GAAC;GAAO;GAAO;GAAQ;GAAO;EAAM;;EAGhF,MAAM,WAA0B;GAC9B,SAAS;GACT,YAAY;GACZ,gBAAgB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,MAAM,KAA0B;GAC9C,IAAI,aAAa,IAAI,OAAO,SAAS,IAAI;IAAE;IAAI;GAAG,CAAC,GAAG,mCAAmC;GAEzF,IAAI,MAAM,OAAO,wBAAwB,aAAa;IACpD,MAAM,IAAI,MAAM,SAAS;KACvB,MAAM;KAKN,IAAI;KACJ,KAAK;KACL,QAAQ;KACR,cAA0C;MAExC,OAAO,EAAE,OADK,IAAI,cAAc,KAA2B,EAAE,WAAW,mBAAmB,CAC9E,EAAE;KACjB;IACF,GAAG,kBAAkB;GACvB,CAAC;EACH"}
|
package/lib/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const Config: z<ThinkingLevelsConfig>;
|
|
|
34
34
|
/** Settings defaults, kept in lockstep with the schema defaults above. */
|
|
35
35
|
export declare const DEFAULT_CONFIG: ThinkingLevelsConfig;
|
|
36
36
|
/** Runtime-adjustable settings namespace: level + scheduler toggles. */
|
|
37
|
-
export declare const THINKING_LEVELS_SETTINGS_NAMESPACE
|
|
37
|
+
export declare const THINKING_LEVELS_SETTINGS_NAMESPACE = "thinking-levels";
|
|
38
38
|
/**
|
|
39
39
|
* Plugin body.
|
|
40
40
|
* @param ctx - host context carrying the agent-event dispatch.
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import z from '@deepseek-ai/schemastery';
|
|
2
|
-
import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
3
2
|
import { assertEffortId, decideEffort, isEffortId } from "./thinking-level.js";
|
|
4
3
|
import { recentToolCalls } from "./session-events.js";
|
|
5
4
|
/**
|
|
@@ -22,7 +21,33 @@ export const DEFAULT_CONFIG = {
|
|
|
22
21
|
allowUpgrade: false,
|
|
23
22
|
};
|
|
24
23
|
/** Runtime-adjustable settings namespace: level + scheduler toggles. */
|
|
25
|
-
export const THINKING_LEVELS_SETTINGS_NAMESPACE =
|
|
24
|
+
export const THINKING_LEVELS_SETTINGS_NAMESPACE = 'thinking-levels';
|
|
25
|
+
/**
|
|
26
|
+
* Inline equivalent of the official `installSettingsSection` helper: register
|
|
27
|
+
* the namespace through the `settings` service (cordis injection), layer the
|
|
28
|
+
* composition entry as `base`, and keep the runtime source live. Kept local so
|
|
29
|
+
* the host half has no value dependency on `@deepseek-ai/dsh-settings`.
|
|
30
|
+
* @param ctx - host context carrying the settings service.
|
|
31
|
+
* @param ns - settings namespace to register.
|
|
32
|
+
* @param schema - schemastery schema resolving the namespace value.
|
|
33
|
+
* @param entry - composition-entry config used as the `base` layer.
|
|
34
|
+
* @param hooks - source sink and change notification.
|
|
35
|
+
*/
|
|
36
|
+
function installSettingsSection(ctx, ns, schema, entry, hooks) {
|
|
37
|
+
;
|
|
38
|
+
ctx.inject(['settings'], (sctx) => {
|
|
39
|
+
const scope = sctx.settings.register(ns, schema, { base: entry });
|
|
40
|
+
hooks.setSource(() => scope.get());
|
|
41
|
+
hooks.onChange();
|
|
42
|
+
// Detach: on plugin unload fall back to the composition entry, mirroring
|
|
43
|
+
// the official helper's disposer.
|
|
44
|
+
sctx.effect(() => () => {
|
|
45
|
+
hooks.setSource(() => entry);
|
|
46
|
+
hooks.onChange();
|
|
47
|
+
});
|
|
48
|
+
scope.watch(() => hooks.onChange());
|
|
49
|
+
});
|
|
50
|
+
}
|
|
26
51
|
const TOOL_AGE_LIMIT_MS = 10 * 60 * 1000;
|
|
27
52
|
/**
|
|
28
53
|
* The `auto` mask shown in the model directory: a user-facing level that is
|
|
@@ -112,8 +137,15 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
|
|
|
112
137
|
return { ...seed, reasoningEffort: level };
|
|
113
138
|
}, { prepend: true });
|
|
114
139
|
// Advertise the `auto` mask in the model directory so the session model
|
|
115
|
-
// selector offers it alongside Off/Low/High/Max.
|
|
116
|
-
|
|
140
|
+
// selector offers it alongside Off/Low/High/Max. Adapters may register after
|
|
141
|
+
// this plugin's apply (the load order differs between the CLI and DSH
|
|
142
|
+
// Desktop), so the wrapper also re-runs on every `llm/adapters-updated`.
|
|
143
|
+
const llm = ctx.get('llm');
|
|
144
|
+
advertiseAutoEffort(llm);
|
|
145
|
+
const onAny = ctx.on;
|
|
146
|
+
onAny('llm/adapters-updated', () => {
|
|
147
|
+
advertiseAutoEffort(ctx.get('llm'));
|
|
148
|
+
});
|
|
117
149
|
// Per-tool wall-clock telemetry: log tool/call -> tool/result durations.
|
|
118
150
|
// Same boundary widening as above (agent/tool is a generated scope event).
|
|
119
151
|
const started = new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-thinking-levels",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "DSH host plugin: thinking-level (reasoning_effort) control for dsh — auto-adjust per tool round, with optional manual lock and per-tool timing telemetry.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,17 +33,13 @@
|
|
|
33
33
|
"node": ">=20"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@deepseek-ai/cordis": "^4.0.1"
|
|
37
|
-
"@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
|
|
38
|
-
"@deepseek-ai/dsh-settings": "^0.1.0-rc.7"
|
|
36
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
39
|
"@deepseek-ai/schemastery": "^3.18.0"
|
|
42
40
|
},
|
|
43
41
|
"devDependencies": {
|
|
44
42
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
45
|
-
"@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
|
|
46
|
-
"@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
|
|
47
43
|
"@deepseek-ai/dsh-client-locale": "^0.1.0-rc.7",
|
|
48
44
|
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.7",
|
|
49
45
|
"@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.7",
|