dsh-media-lens 0.3.2 → 0.3.4
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 +9 -1
- package/README.md +11 -1
- package/dsh.plugin.json +1 -1
- package/lib/client.js +30 -18
- package/lib/index.js +12 -0
- package/lib/tui-command.d.ts +25 -0
- package/lib/tui-command.js +98 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.4
|
|
4
|
+
|
|
5
|
+
- 修复多语言注册告警噪音:`addLanguage` 命中全局语言表"先到先得"、`register` 命中命名空间重复(`already registered` / `already has locale`)时改为良性跳过,不再刷"注册失败"红色告警;跨插件共用标准语码与本插件 `_reload` 均不再误报。
|
|
6
|
+
|
|
7
|
+
## 0.3.3
|
|
8
|
+
|
|
9
|
+
- 终端面(dsh-tui / Desktop 命令面板同源):/media 只读设置节面(status)。
|
|
2
10
|
|
|
3
11
|
## 0.3.1 (2026-11-14)
|
|
4
12
|
|
package/README.md
CHANGED
|
@@ -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
package/lib/client.js
CHANGED
|
@@ -6,7 +6,7 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
|
|
9
|
+
// src/config.ts
|
|
10
10
|
const DEFAULT_CONFIG = {
|
|
11
11
|
strictLocalOnly: false,
|
|
12
12
|
cooldownMs: 6e5,
|
|
@@ -122,8 +122,7 @@ window.__ModuleLoader__.load({
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
//#region src/client/MediaLensSettingsCard.tsx
|
|
125
|
+
// src/client/MediaLensSettingsCard.tsx
|
|
127
126
|
/**
|
|
128
127
|
* media-lens 客户端设置卡(全量可编辑表单)。
|
|
129
128
|
* 数据面:宿主 configForms 权威 scope(0.1.7+/0.2.0/0.2.1 唯一活写路径)。
|
|
@@ -553,8 +552,7 @@ window.__ModuleLoader__.load({
|
|
|
553
552
|
]
|
|
554
553
|
});
|
|
555
554
|
}
|
|
556
|
-
|
|
557
|
-
//#region src/client/locales.ts
|
|
555
|
+
// src/client/locales.ts
|
|
558
556
|
/**
|
|
559
557
|
* media-lens 客户端 UI 字典(9 语:zh en ja ko fr de it ru es)。
|
|
560
558
|
* zh 键集为真理源,其余 8 语用 Record<keyof typeof zh, string> 编译期对齐;
|
|
@@ -979,8 +977,7 @@ window.__ModuleLoader__.load({
|
|
|
979
977
|
}
|
|
980
978
|
}
|
|
981
979
|
];
|
|
982
|
-
|
|
983
|
-
//#region src/client/index.ts
|
|
980
|
+
// src/client/index.ts
|
|
984
981
|
/**
|
|
985
982
|
* media-lens 客户端半身入口。
|
|
986
983
|
*
|
|
@@ -1003,6 +1000,16 @@ window.__ModuleLoader__.load({
|
|
|
1003
1000
|
const FAMILY_TAB_ORDER = 65;
|
|
1004
1001
|
const SECTION_ORDER = 24;
|
|
1005
1002
|
const FAMILY_YIELD_MS = 1e3;
|
|
1003
|
+
/**
|
|
1004
|
+
* Host locale APIs throw on duplicate writes: `addLanguage` when the global
|
|
1005
|
+
* catalog already has the id (`... is already registered`), and `register` when
|
|
1006
|
+
* the namespace already carries that locale (`... already has locale "..."`).
|
|
1007
|
+
* Both mean the entry is already present and usable, so they are benign skips
|
|
1008
|
+
* (multi-mount or `_reload` re-running apply), not real failures — never warn.
|
|
1009
|
+
*/
|
|
1010
|
+
function isBenignLocaleDuplicate(error) {
|
|
1011
|
+
return error instanceof Error && /already (?:registered|has locale)/.test(error.message);
|
|
1012
|
+
}
|
|
1006
1013
|
function apply(ctx) {
|
|
1007
1014
|
try {
|
|
1008
1015
|
ctx.locale.register(NS, {
|
|
@@ -1010,17 +1017,23 @@ window.__ModuleLoader__.load({
|
|
|
1010
1017
|
en
|
|
1011
1018
|
});
|
|
1012
1019
|
} catch (error) {
|
|
1013
|
-
console.warn("[dsh-media-lens] locale zh/en
|
|
1020
|
+
if (!isBenignLocaleDuplicate(error)) console.warn("[dsh-media-lens] locale zh/en register failed:", error);
|
|
1014
1021
|
}
|
|
1015
|
-
for (const language of extraLanguages)
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1022
|
+
for (const language of extraLanguages) {
|
|
1023
|
+
try {
|
|
1024
|
+
ctx.locale.register(NS, language.id, language.dict);
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
if (!isBenignLocaleDuplicate(error)) console.warn(`[dsh-media-lens] locale "${language.id}" dictionary registration failed:`, error);
|
|
1027
|
+
}
|
|
1028
|
+
try {
|
|
1029
|
+
ctx.locale.addLanguage({
|
|
1030
|
+
id: language.id,
|
|
1031
|
+
label: language.label,
|
|
1032
|
+
fallback: "en"
|
|
1033
|
+
});
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
if (!isBenignLocaleDuplicate(error)) console.warn(`[dsh-media-lens] locale "${language.id}" language registration failed:`, error);
|
|
1036
|
+
}
|
|
1024
1037
|
}
|
|
1025
1038
|
const tNav = ctx.locale.bind(NS);
|
|
1026
1039
|
let configForms;
|
|
@@ -1191,7 +1204,6 @@ window.__ModuleLoader__.load({
|
|
|
1191
1204
|
console.warn("[dsh-media-lens] plugins.bundle.config 注册失败(旧宿主无该槽,静默缺席):", error);
|
|
1192
1205
|
}
|
|
1193
1206
|
}
|
|
1194
|
-
//#endregion
|
|
1195
1207
|
exports.apply = apply;
|
|
1196
1208
|
exports.inject = inject;
|
|
1197
1209
|
return module.exports;
|
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.
|
|
3
|
+
"version": "0.3.4",
|
|
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",
|