dsh-media-lens 0.3.1 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- # Changelog
1
+ # Changelog
2
+
3
+ ## 0.3.3
4
+
5
+ - 终端面(dsh-tui / Desktop 命令面板同源):/media 只读设置节面(status)。
2
6
 
3
7
  ## 0.3.1 (2026-11-14)
4
8
 
package/README.md CHANGED
@@ -11,7 +11,7 @@ media_read_video / media_read_audio / media_read_image
11
11
  ```
12
12
 
13
13
  <!-- host-compat:begin — generated by scripts/sync-hosts.mjs from scripts/hosts.mjs; DO NOT EDIT -->
14
- - **Declared range:** `>=0.1.7-rc.1 <0.3.0` (`engines.dsh`; peers enumerate the verified cells below)
14
+ - **Declared range:** `>=0.1.7-rc.1 <0.3.0-0` (`engines.dsh`; peers enumerate the verified cells below)
15
15
  - **Supported DSH hosts:** `0.1.7-rc.1` `0.1.7-rc.2` `0.2.0-rc.1` `0.2.0-rc.2` `0.2.1-rc.1` `0.2.1-rc.2` `0.2.1-rc.3` `0.2.1-rc.4` `0.2.1-rc.5` `0.2.2-rc.1` (10 rc across lines 0.1.7 / 0.2.0 / 0.2.1)
16
16
  - **Runtime-verified:** `0.1.7-rc.2`, `0.2.0-rc.2`, `0.2.1-rc.1` — evidence in `.compat-results/`
17
17
  <!-- host-compat:end -->
@@ -163,4 +163,14 @@ lazy 机制(两路注入均在 apply 期顶层注册,工厂只在「声明
163
163
 
164
164
  ## 版本线
165
165
 
166
- `0.1.0`(engines.dsh `0.2.0-rc.1 || 0.2.0-rc.2`)。发布走 npm staged 人工审批;dist-tag 分层 `dsh-0.2.0`(对齐 date-wrapper 先例),latest 收敛在发版时统一处理。
166
+ `0.1.0`(engines.dsh `0.2.0-rc.1 || 0.2.0-rc.2`)。发布走 npm staged 人工审批;dist-tag 分层 `dsh-0.2.0`(对齐 date-wrapper 先例),latest 收敛在发版时统一处理。
167
+
168
+ ## TUI 终端面(dsh-tui)
169
+
170
+ dsh-tui 不加载插件的 client 半边(面板/卡片/设置页),也调不到插件自有 RPC;工具调用只显示一行摘要。人可读、人可操作的面只剩宿主斜杠命令。输出约定:单行 ≤100 字符、总行 ≤40、无 ANSI、两空格对齐;写操作默认 dry、加 `--yes` 才执行;`--json` 输出单行 JSON。
171
+
172
+ | 命令 | 作用 |
173
+ |---|---|
174
+ | `/media status` | 媒体路由设置节(终端不可视媒体本身) |
175
+
176
+ 命令由插件自己在宿主侧注册(`ctx.inject(['commands'], …)`):命令服务缺席的老宿主线上不激活、不报错。
package/dsh.plugin.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-media-lens",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Media evidence lens + provider router for DeepSeek Harness (media_read_video / media_read_audio / media_read_image).",
6
6
  "engines": {
7
- "dsh": ">=0.1.7-rc.1 <0.3.0"
7
+ "dsh": ">=0.1.7-rc.1 <0.3.0-0"
8
8
  },
9
9
  "contributes": {
10
10
  "tools": [],
package/lib/index.js CHANGED
@@ -61,6 +61,17 @@ export const Config = z.object({
61
61
  });
62
62
  const DISCOVERY_TTL_MS = 60_000;
63
63
  export function apply(ctx, config = {}) {
64
+ // ── dsh-tui 终端面:`/media` ────────────────────────────────────
65
+ // TUI 不加载设置卡/图片卡,终端本身不可视媒体 → 至少要让“路由配没配”可查。
66
+ // 命令层只读设置节;每次工具调用的回退链仍在结果 meta.attempts 里。
67
+ ;
68
+ ctx.inject?.(['commands'], (scope) => {
69
+ registerMediaCommand(scope, {
70
+ ns: 'dsh-media-lens',
71
+ section: () => describeSection(scope, 'dsh-media-lens'),
72
+ lastAttempts: () => [],
73
+ });
74
+ });
64
75
  // volatile 活读:宿主对 `.volatile()` 字段传带 `.get()` 的活引用,且写入后只发
65
76
  // `loader/volatile-update` 事件、不重跑 apply(llm-pi-ai / llm-deepseek 同范式)。
66
77
  // resolved 必须可整体重算——下方闭包全部在调用期解引用 `resolved`,重算即热生效。
@@ -208,3 +219,4 @@ export { decideBudget } from "./router/budget.js";
208
219
  export { discoverRegisteredModels, filterDiscoverySnapshot, resolveSelection } from "./discovery.js";
209
220
  export { refineEvidence, EVIDENCE_REFINE_INSTRUCTION } from "./refine.js";
210
221
  export { createVisionBridge, shouldWrapModel, evidenceBridgeText, fileHandlePath, rewriteMessages, EvidenceMemo, BRIDGE_FAILURES, OWN_PROVIDER_PREFIX, VISION_MODEL_SUFFIX } from "./inject.js";
222
+ import { registerMediaCommand, describeSection } from "./tui-command.js";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * tui-command.ts — `/media`:media-lens 的 dsh-tui 终端面。
3
+ *
4
+ * 背景:TUI 不加载设置卡 / 图片卡片,且终端本身不可视 → 「媒体路由到底配没配、
5
+ * 上次走了哪个回退」在终端里无处可查。命令只读回显设置节与最近一次回退信息。
6
+ *
7
+ * 契约:单行 <=100、总行 <=40、无 ANSI、--json 单行。
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ export type CommandKind = 'success' | 'error';
11
+ export interface CommandResult {
12
+ kind: CommandKind;
13
+ text: string;
14
+ }
15
+ export interface MediaDeps {
16
+ ns: string;
17
+ section(): Record<string, unknown> | undefined;
18
+ lastAttempts(): string[];
19
+ }
20
+ export declare function clip(text: string, width?: number): string;
21
+ export declare function renderLines(lines: string[], limit?: number): string;
22
+ /** 从 settings.describe() 里取本节;找不到就按 needle 回退。 */
23
+ export declare function describeSection(ctx: Context, ns: string, needle?: string): Record<string, unknown> | undefined;
24
+ export declare function runMediaCommand(rawInput: string, deps: MediaDeps): CommandResult;
25
+ export declare function registerMediaCommand(ctx: Context, deps: MediaDeps): void;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * tui-command.ts — `/media`:media-lens 的 dsh-tui 终端面。
3
+ *
4
+ * 背景:TUI 不加载设置卡 / 图片卡片,且终端本身不可视 → 「媒体路由到底配没配、
5
+ * 上次走了哪个回退」在终端里无处可查。命令只读回显设置节与最近一次回退信息。
6
+ *
7
+ * 契约:单行 <=100、总行 <=40、无 ANSI、--json 单行。
8
+ */
9
+ const MAX_LINES = 40;
10
+ const MAX_WIDTH = 100;
11
+ export function clip(text, width = MAX_WIDTH) {
12
+ const value = String(text ?? '').replace(/[\r\n]+/g, ' ').replace(/\s+$/, '');
13
+ return value.length <= width ? value : `${value.slice(0, width - 1)}…`;
14
+ }
15
+ export function renderLines(lines, limit = MAX_LINES) {
16
+ const clipped = lines.map((line) => clip(line));
17
+ if (clipped.length <= limit)
18
+ return clipped.join('\n');
19
+ const kept = clipped.slice(0, limit - 1);
20
+ return [...kept, `… 还有 ${clipped.length - kept.length} 行,加 --all 查看`].join('\n');
21
+ }
22
+ /** 从 settings.describe() 里取本节;找不到就按 needle 回退。 */
23
+ export function describeSection(ctx, ns, needle = 'endpoints') {
24
+ const settings = ctx.get?.('settings');
25
+ const raw = settings?.describe?.();
26
+ const list = Array.isArray(raw) ? raw : raw?.namespaces;
27
+ if (!Array.isArray(list))
28
+ return undefined;
29
+ for (const entry of list) {
30
+ const row = entry;
31
+ if (row?.ns === ns && row.value !== null && typeof row.value === 'object')
32
+ return row.value;
33
+ }
34
+ for (const entry of list) {
35
+ const value = entry?.value;
36
+ if (value !== null && typeof value === 'object' && needle in value) {
37
+ return value;
38
+ }
39
+ }
40
+ return undefined;
41
+ }
42
+ export function runMediaCommand(rawInput, deps) {
43
+ const argv = String(rawInput ?? '').trim().split(/\s+/).filter(Boolean);
44
+ const json = argv.includes('--json');
45
+ const sub = (argv.find((token) => !token.startsWith('--')) ?? 'status').toLowerCase();
46
+ const wrap = (result, data) => {
47
+ if (!json)
48
+ return result;
49
+ const body = result.kind === 'error'
50
+ ? { ok: false, cmd: 'media', error: { message: result.text.split('\n')[0] ?? result.text } }
51
+ : { ok: true, cmd: 'media', data };
52
+ return { kind: result.kind, text: JSON.stringify(body) };
53
+ };
54
+ if (sub === 'help' || sub === '?') {
55
+ return wrap({ kind: 'success', text: renderLines([
56
+ 'media — 媒体证据路由(只读)',
57
+ ' /media status 设置节 + 最近回退记录',
58
+ ' flags --json 单行 JSON',
59
+ ' note 终端不可视媒体本身;读图请用 media_read_image 工具',
60
+ ]) }, { help: true });
61
+ }
62
+ if (sub !== 'status') {
63
+ return wrap({ kind: 'error', text: renderLines([`media: 未知子命令 "${sub}"`, ' next: /media help']) }, {});
64
+ }
65
+ const section = deps.section();
66
+ const attempts = deps.lastAttempts();
67
+ const lines = [`media — 设置节 ${section === undefined ? '缺失' : '已加载'}`];
68
+ if (section === undefined) {
69
+ lines.push(' next 插件未进入 profile 文档,或本宿主未挂 settings 服务');
70
+ }
71
+ else {
72
+ const keys = Object.keys(section);
73
+ for (const key of keys.slice(0, 10)) {
74
+ const value = section[key];
75
+ lines.push(` ${key.padEnd(18)} ${clip(typeof value === 'object' && value !== null ? JSON.stringify(value) : String(value), 60)}`);
76
+ }
77
+ if (keys.length > 10)
78
+ lines.push(` … 还有 ${keys.length - 10} 个字段`);
79
+ }
80
+ if (attempts.length > 0) {
81
+ lines.push(' last fallbacks');
82
+ for (const attempt of attempts.slice(0, 6))
83
+ lines.push(` ${clip(attempt, 90)}`);
84
+ }
85
+ return wrap({ kind: 'success', text: renderLines(lines) }, { section, attempts });
86
+ }
87
+ export function registerMediaCommand(ctx, deps) {
88
+ const registry = ctx.commands;
89
+ if (!registry || typeof registry.register !== 'function')
90
+ return;
91
+ registry.register({
92
+ definitionId: 'dsh-media-lens',
93
+ name: 'media',
94
+ description: 'Media lens console: settings section + recent fallback attempts (read-only)',
95
+ input: { hint: '[status] [--json]' },
96
+ handler: (invocation) => runMediaCommand(invocation?.rawInput ?? '', deps),
97
+ });
98
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-media-lens",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Media evidence lens + provider router for DeepSeek Harness: media_read_video / media_read_audio / media_read_image turn local media into structured evidence (timeline / transcript / regions) via host-registered multimodal models first, configured OpenAI-compatible endpoints second, and local ffmpeg/CLI fallbacks last. Every fallback is recorded in meta.attempts — a fallback is never silent.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -62,12 +62,12 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@deepseek-ai/cordis": "^4.0.2",
65
- "@deepseek-ai/dsh-attachment": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
66
- "@deepseek-ai/dsh-client-locale": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
67
- "@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
68
- "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
69
- "@deepseek-ai/dsh-llm": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
70
- "@deepseek-ai/dsh-tools": "0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
65
+ "@deepseek-ai/dsh-attachment": ">=0.1.7-rc.1 <0.3.0-0",
66
+ "@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.3.0-0",
67
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.1 <0.3.0-0",
68
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.1.7-rc.1 <0.3.0-0",
69
+ "@deepseek-ai/dsh-llm": ">=0.1.7-rc.1 <0.3.0-0",
70
+ "@deepseek-ai/dsh-tools": ">=0.1.7-rc.1 <0.3.0-0",
71
71
  "dsh-llm-openai-completions": ">=0.4.4",
72
72
  "dsh-thinking-levels": ">=4.4.4",
73
73
  "react": ">=18 <19"
@@ -116,7 +116,7 @@
116
116
  },
117
117
  "engines": {
118
118
  "node": "^22.19.0 || >=24.0.0",
119
- "dsh": ">=0.1.7-rc.1 <0.3.0"
119
+ "dsh": ">=0.1.7-rc.1 <0.3.0-0"
120
120
  },
121
121
  "keywords": [
122
122
  "deepseek-harness",