dsh-vod-devkit 0.5.0 → 0.5.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 +9 -8
- package/lib/index.js +243 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,28 +8,29 @@ VOD 用户声音采集插件 —— DeepSeek Harness (dsh) 薄壳。
|
|
|
8
8
|
- 插件=引擎客户端,只走 HTTPS(VOD external API),不 import 任何引擎模块
|
|
9
9
|
- 与 vod-devkit(MCP 形态,同仓 `../vod_mcp`)语义对齐:
|
|
10
10
|
- voiceId = f(source, content, 调用级 nonce):同调用幂等、跨调用保声量
|
|
11
|
-
-
|
|
12
|
-
|
|
11
|
+
- 归因=运行期从用户原话解析(引擎产品名录别名,含中文/长别名),唯一命中才采信;
|
|
12
|
+
优先级:字面证据 > 记忆(30 分钟)> 配置 product 先验 > 未知(引擎 UNKNOWN 池)
|
|
13
|
+
- 多产品命中=歧义 → 不带 product 上送(宁可人工归因,不可错归;与 vod_mcp 同口径)
|
|
13
14
|
- 无 key/401 → POST /external/token 零字段匿名令牌 → 本地落盘 → 重试一次
|
|
14
15
|
- 本地账本 data/runtime.json(cap 200 环形,读改写只动目标键)
|
|
15
16
|
|
|
16
17
|
## 安装
|
|
17
18
|
|
|
18
19
|
```
|
|
19
|
-
npx --yes vod-devkit install --target dsh --profile <name> --product <产品> #
|
|
20
|
+
npx --yes vod-devkit install --target dsh --profile <name> [--product <产品>] # 推荐(--product 可选先验;给了即硬校验)
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
> ⚠️ 不要用 `dsh plugin add dsh-vod-devkit` 裸装:只装插件本体不写配置——
|
|
23
|
-
>
|
|
24
|
-
>
|
|
25
|
-
>
|
|
24
|
+
> apiBase/uiBase 缺失时工具半不可用、UI 提交会发往 dsh 同源(404 → 本地暂存
|
|
25
|
+
> 发不出去,嵌入方真机实锤)。裸装后补救:跑一次上面的 npx 命令即可(幂等)。
|
|
26
|
+
> product 不再是必填:归因默认从用户原话解析,配置值只是无证据时的先验。
|
|
26
27
|
|
|
27
28
|
装后配置落在 profile 的 cordis.patch.yml(npx 包装命令自动写入):
|
|
28
29
|
|
|
29
30
|
```yaml
|
|
30
31
|
- id: vod-devkit
|
|
31
32
|
config:
|
|
32
|
-
product:
|
|
33
|
+
product: '' # 可选先验(无字面证据且无记忆时兜底);归因主路径=用户原话解析
|
|
33
34
|
# apiBase: https://vod-dev.topxtopx.com # 工具半(Node 服务端)用,缺省即此
|
|
34
35
|
# uiBase: https://vod-dev.topxtopx.com # 浏览器半(反馈按钮)直连用,缺省即此
|
|
35
36
|
```
|
|
@@ -49,7 +50,7 @@ npx --yes vod-devkit install --target dsh --profile <name> --product <产品>
|
|
|
49
50
|
| apiBase | https://vod-dev.topxtopx.com | VOD external API 基址(工具半/服务端用) |
|
|
50
51
|
| uiBase | 同 apiBase | 浏览器半(反馈按钮)直连基址;同源代理形态可留空 |
|
|
51
52
|
| apiKey | (空) | 缺省走零字段匿名令牌;灰度期可用运营签发 key |
|
|
52
|
-
| product | (空) |
|
|
53
|
+
| product | (空) | 可选归因先验(如 codearts):仅在无字面证据且无记忆时生效;空=完全靠原话解析,歧义落 UNKNOWN |
|
|
53
54
|
| confirmWrites | true | 写操作走 dsh 审批通道(tools/pre-execute → ask) |
|
|
54
55
|
| timeoutSec | 30 | HTTP 超时 |
|
|
55
56
|
|
package/lib/index.js
CHANGED
|
@@ -127,25 +127,229 @@ async function http(method, path, body, { base, key, timeoutSec, signal }) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
130
|
+
// ── 归因(D-attrib-B,2026-11-11 负责人拍板 A/A/A/A):与 vod_mcp/attribution.py
|
|
131
|
+
// 同一口径——用户原话字面证据 > 记忆(TTL 30 分钟)> 部署 config 先验 > 未知。
|
|
132
|
+
// 唯一命中才采信;多产品命中=歧义 → 不上送 product(引擎 UNKNOWN 池);
|
|
133
|
+
// 模型自报参数不存在(本壳工具面无 product 入参)。
|
|
134
134
|
const META_PATH = `${API_PREFIX}/external/meta`;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const META_TTL_MS = 24 * 3600 * 1000;
|
|
136
|
+
const ATTR_MEM_TTL = 30 * 60; // 秒(与 Python 侧 MEM_TTL 对齐)
|
|
137
|
+
const ATTR_SHORT_ALIAS = 5; // <5 字符短别名只认大小写精确(obs/maas)
|
|
138
|
+
const ATTR_BOUNDARY = /[A-Za-z0-9_-]/;
|
|
139
|
+
const ATTR_HISTORY_CAP = 10;
|
|
140
|
+
let _metaCache = null; // {at, data}
|
|
141
|
+
|
|
142
|
+
function emptyMeta() {
|
|
143
|
+
return { products: [], catalog: [], aliases: {}, nameAliases: {} };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function loadMeta(cfg, signal) {
|
|
147
|
+
if (_metaCache && Date.now() - _metaCache.at < META_TTL_MS) return _metaCache.data;
|
|
138
148
|
try {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
const out = await http('GET', META_PATH, undefined, { ...cfg, signal });
|
|
150
|
+
const d = out?.data?.data || out?.data || {};
|
|
151
|
+
const meta = {
|
|
152
|
+
products: Array.isArray(d.products) ? d.products : [],
|
|
153
|
+
catalog: Array.isArray(d.productCatalog) ? d.productCatalog : [],
|
|
154
|
+
aliases: d.aliases && typeof d.aliases === 'object' ? d.aliases : {},
|
|
155
|
+
nameAliases: d.nameAliases && typeof d.nameAliases === 'object' ? d.nameAliases : {},
|
|
156
|
+
};
|
|
157
|
+
if (meta.products.length) {
|
|
158
|
+
_metaCache = { at: Date.now(), data: meta };
|
|
159
|
+
return meta;
|
|
160
|
+
}
|
|
161
|
+
} catch (e) { /* 名录不可用 → 快照空:短码都拿不到,宁可 UNKNOWN 不猜 */ }
|
|
162
|
+
return _metaCache?.data || emptyMeta();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function buildAliasIndex(meta = {}) {
|
|
166
|
+
const products = (meta.products || []).map(String).filter(Boolean);
|
|
167
|
+
const catalog = meta.catalog || [];
|
|
168
|
+
const idByLower = new Map();
|
|
169
|
+
for (const it of catalog) {
|
|
170
|
+
const name = String(it?.name || '').trim();
|
|
171
|
+
if (name) idByLower.set(name.toLowerCase(), it.id != null ? String(it.id) : null);
|
|
172
|
+
}
|
|
173
|
+
const canon = new Map(); // lower(name) -> {label,id,aliases:Set,brand}
|
|
174
|
+
const slot = (nm, brand) => {
|
|
175
|
+
const key = String(nm).trim().toLowerCase();
|
|
176
|
+
let cur = canon.get(key);
|
|
177
|
+
if (!cur) {
|
|
178
|
+
cur = { label: String(nm).trim(), id: null, aliases: new Set(), brand: !!brand };
|
|
179
|
+
canon.set(key, cur);
|
|
180
|
+
} else if (brand && !cur.brand) {
|
|
181
|
+
cur.label = String(nm).trim();
|
|
182
|
+
cur.brand = true;
|
|
183
|
+
}
|
|
184
|
+
cur.aliases.add(String(nm).trim());
|
|
185
|
+
return cur;
|
|
186
|
+
};
|
|
187
|
+
products.forEach((p) => slot(p, true)); // 展示名优先成标签
|
|
188
|
+
catalog.forEach((it) => { if (it?.name) slot(it.name, false); });
|
|
189
|
+
for (const [key, list] of Object.entries(meta.nameAliases || {})) {
|
|
190
|
+
const aliases = (list || []).map(String).filter(Boolean);
|
|
191
|
+
let target = canon.get(String(key).toLowerCase());
|
|
192
|
+
if (!target) {
|
|
193
|
+
for (const a of aliases) {
|
|
194
|
+
const s = canon.get(a.toLowerCase());
|
|
195
|
+
if (s) { target = s; break; }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (!target) target = slot(key, true);
|
|
199
|
+
aliases.forEach((a) => target.aliases.add(a));
|
|
200
|
+
target.aliases.add(String(key));
|
|
201
|
+
}
|
|
202
|
+
for (const [key, targetName] of Object.entries(meta.aliases || {})) {
|
|
203
|
+
let s = canon.get(String(targetName).toLowerCase());
|
|
204
|
+
if (!s) s = slot(targetName, false); // 目标不在名录也不丢别名
|
|
205
|
+
s.aliases.add(String(key));
|
|
206
|
+
}
|
|
207
|
+
for (const s of canon.values()) { // 名字/别名任一命中 catalog → 拿 id
|
|
208
|
+
for (const a of [s.label, ...s.aliases]) {
|
|
209
|
+
if (idByLower.has(a.toLowerCase())) {
|
|
210
|
+
const id = idByLower.get(a.toLowerCase());
|
|
211
|
+
if (id != null) { s.id = id; break; }
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const merged = [];
|
|
216
|
+
const byId = new Map(); // 同 id 合并(展示名那条为准)
|
|
217
|
+
for (const s of canon.values()) {
|
|
218
|
+
if (s.id != null && byId.has(s.id)) {
|
|
219
|
+
const keep = byId.get(s.id);
|
|
220
|
+
s.aliases.forEach((a) => keep.aliases.add(a));
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (s.id != null) byId.set(s.id, s);
|
|
224
|
+
merged.push(s);
|
|
225
|
+
}
|
|
226
|
+
const entries = [];
|
|
227
|
+
const seen = new Set();
|
|
228
|
+
for (const s of merged) {
|
|
229
|
+
for (const alias of s.aliases) {
|
|
230
|
+
const key = `${s.label.toLowerCase()}\u0000${alias}`; // 大小写敏感:留住 MaaS/Maas
|
|
231
|
+
if (!alias || seen.has(key)) continue;
|
|
232
|
+
seen.add(key);
|
|
233
|
+
entries.push({ product: s.label, id: s.id, alias });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
entries.sort((a, b) => b.alias.length - a.alias.length);
|
|
237
|
+
return entries;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function snippetOf(text, start, end) {
|
|
241
|
+
const lo = Math.max(0, start - 20);
|
|
242
|
+
const hi = Math.min(text.length, end + 20);
|
|
243
|
+
return text.slice(lo, hi).replace(/\s+/g, ' ').slice(0, 80);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function matchProducts(text, index) {
|
|
247
|
+
const t = String(text || '');
|
|
248
|
+
if (!t || !Array.isArray(index) || !index.length) return [];
|
|
249
|
+
const taken = [];
|
|
250
|
+
const hits = [];
|
|
251
|
+
const isAscii = (s) => [...s].every((c) => c.charCodeAt(0) < 128);
|
|
252
|
+
for (const e of index) {
|
|
253
|
+
const alias = String(e.alias || '');
|
|
254
|
+
if (!alias) continue;
|
|
255
|
+
const spans = [];
|
|
256
|
+
if (!isAscii(alias)) {
|
|
257
|
+
let i = 0;
|
|
258
|
+
while ((i = t.indexOf(alias, i)) >= 0) { spans.push([i, i + alias.length]); i += 1; }
|
|
259
|
+
} else {
|
|
260
|
+
const exact = alias.length < ATTR_SHORT_ALIAS;
|
|
261
|
+
const hay = exact ? t : t.toLowerCase();
|
|
262
|
+
const needle = exact ? alias : alias.toLowerCase();
|
|
263
|
+
let i = 0;
|
|
264
|
+
while ((i = hay.indexOf(needle, i)) >= 0) {
|
|
265
|
+
const j = i + needle.length;
|
|
266
|
+
const beforeOk = i === 0 || !ATTR_BOUNDARY.test(hay[i - 1]);
|
|
267
|
+
let afterOk = true;
|
|
268
|
+
if (j < hay.length) {
|
|
269
|
+
const n = hay[j];
|
|
270
|
+
if (ATTR_BOUNDARY.test(n)) afterOk = false;
|
|
271
|
+
else if (n === '.' && j + 1 < hay.length && /[A-Za-z0-9]/.test(hay[j + 1])) afterOk = false;
|
|
272
|
+
}
|
|
273
|
+
if (beforeOk && afterOk) spans.push([i, j]);
|
|
274
|
+
i += 1;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
for (const [s, en] of spans) {
|
|
278
|
+
if (taken.some(([ts, te]) => !(en <= ts || s >= te))) continue; // 长别名优先
|
|
279
|
+
taken.push([s, en]);
|
|
280
|
+
hits.push({ product: e.product, id: e.id, alias, start: s, end: en, snippet: snippetOf(t, s, en) });
|
|
143
281
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
282
|
+
}
|
|
283
|
+
hits.sort((a, b) => a.start - b.start);
|
|
284
|
+
return hits;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function resolveSubmitValue(product, meta) {
|
|
288
|
+
const p = String(product || '').trim();
|
|
289
|
+
if (!p) return '';
|
|
290
|
+
if (/^\d+$/.test(p)) return p;
|
|
291
|
+
const idx = buildAliasIndex(meta || {});
|
|
292
|
+
const low = p.toLowerCase();
|
|
293
|
+
for (const e of idx) {
|
|
294
|
+
if (String(e.product).toLowerCase() === low && e.id != null) return String(e.id);
|
|
295
|
+
}
|
|
296
|
+
for (const e of idx) {
|
|
297
|
+
if (String(e.alias).toLowerCase() === low && e.id != null) return String(e.id);
|
|
298
|
+
}
|
|
299
|
+
return p;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function attributeProduct(text, meta, opts = {}) {
|
|
303
|
+
const nowSec = opts.now ?? Math.floor(Date.now() / 1000);
|
|
304
|
+
const ttl = opts.ttl ?? ATTR_MEM_TTL;
|
|
305
|
+
const hits = matchProducts(text, buildAliasIndex(meta || {}));
|
|
306
|
+
const groups = new Map();
|
|
307
|
+
for (const h of hits) {
|
|
308
|
+
const k = String(h.product).toLowerCase();
|
|
309
|
+
const cur = groups.get(k);
|
|
310
|
+
if (!cur || h.alias.length > cur.alias.length) groups.set(k, h);
|
|
311
|
+
}
|
|
312
|
+
if (groups.size === 1) {
|
|
313
|
+
const h = [...groups.values()][0];
|
|
314
|
+
return { product: h.id != null ? String(h.id) : h.product, productName: h.product,
|
|
315
|
+
source: 'user_input',
|
|
316
|
+
evidence: [{ product: h.product, alias: h.alias, snippet: h.snippet }] };
|
|
317
|
+
}
|
|
318
|
+
if (groups.size > 1) {
|
|
319
|
+
return { product: null, productName: null, source: 'unknown',
|
|
320
|
+
evidence: hits.map((h) => ({ product: h.product, alias: h.alias,
|
|
321
|
+
snippet: h.snippet, reason: 'ambiguous' })) };
|
|
322
|
+
}
|
|
323
|
+
const mem = opts.memory || {};
|
|
324
|
+
if (mem.product && nowSec - Number(mem.at || 0) <= ttl) {
|
|
325
|
+
return { product: String(mem.product), productName: mem.productName || null,
|
|
326
|
+
source: 'memory',
|
|
327
|
+
evidence: [{ product: mem.productName || String(mem.product), alias: mem.alias,
|
|
328
|
+
snippet: mem.snippet, at: mem.at, reason: 'memory' }] };
|
|
329
|
+
}
|
|
330
|
+
const binding = String(opts.binding || '').trim();
|
|
331
|
+
if (binding) {
|
|
332
|
+
return { product: resolveSubmitValue(binding, meta), productName: binding,
|
|
333
|
+
source: 'install_binding', evidence: [] };
|
|
334
|
+
}
|
|
335
|
+
return { product: null, productName: null, source: 'unknown',
|
|
336
|
+
evidence: [{ reason: 'no-evidence' }] };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// 记忆:只记「字面证据唯一命中」;覆盖时旧条目进 attribution_history(cap 10)
|
|
340
|
+
function rememberAttribution(attr) {
|
|
341
|
+
if (attr?.source !== 'user_input') return;
|
|
342
|
+
const ev = (attr.evidence || [])[0] || {};
|
|
343
|
+
const mem = { product: attr.product, productName: ev.product || attr.productName || null,
|
|
344
|
+
alias: ev.alias, snippet: ev.snippet, at: Math.floor(Date.now() / 1000) };
|
|
345
|
+
const rt = loadRuntime();
|
|
346
|
+
const prev = rt.attribution_memory || {};
|
|
347
|
+
if (prev.product) {
|
|
348
|
+
const hist = (Array.isArray(rt.attribution_history) ? rt.attribution_history : [])
|
|
349
|
+
.concat([{ ...prev, replacedAt: mem.at }]).slice(-ATTR_HISTORY_CAP);
|
|
350
|
+
saveRuntime({ attribution_history: hist });
|
|
351
|
+
}
|
|
352
|
+
saveRuntime({ attribution_memory: mem });
|
|
149
353
|
}
|
|
150
354
|
|
|
151
355
|
async function fetchAnonToken(cfg) {
|
|
@@ -156,15 +360,6 @@ async function fetchAnonToken(cfg) {
|
|
|
156
360
|
return null;
|
|
157
361
|
}
|
|
158
362
|
|
|
159
|
-
const PRODUCT_MAP = { // 引擎枚举归一(实测:小写 codearts → 400 空响应;Python 侧同款映射)
|
|
160
|
-
// 已知差距(M2/M3 不适用于 dsh 形态):本表硬编码,不拉 GET /external/meta——
|
|
161
|
-
// 引擎 VodExternalProducts 变更时需同步此表(含 kb-query-auth 合入后的 AISHELL/nameAliases)。
|
|
162
|
-
// 详见 docs/decisions.md D-dsh-3。
|
|
163
|
-
agentarts: 'AgentArts', codearts: 'CodeArts', dataarts: 'DataArts',
|
|
164
|
-
maas: 'MaaS', obs: 'OBS', officeclaw: 'OfficeClaw',
|
|
165
|
-
modelarts: 'MaaS',
|
|
166
|
-
};
|
|
167
|
-
|
|
168
363
|
function voiceId(source, content, nonce) {
|
|
169
364
|
const h = createHash('sha1').update(content + nonce).digest('hex').slice(0, 12);
|
|
170
365
|
return `ext_${source}_${h}`;
|
|
@@ -358,7 +553,7 @@ export function apply(ctx, config) {
|
|
|
358
553
|
+ 'content MUST be a faithful transcription of the user\'s own words - '
|
|
359
554
|
+ 'NEVER invent sentiment (e.g. 体验不好) or fabricate content the user did not say. '
|
|
360
555
|
+ 'A bare product name or a question is NOT feedback - ask what the user wants to report. ' +
|
|
361
|
-
'
|
|
556
|
+
'Attribution comes from the user\'s own words; config product is only a fallback. NEVER ask or invent a product. ' +
|
|
362
557
|
'Fixed one-time follow-up at confirmation, verbatim: 「方便的话,补充一下遇到这个问题时的操作步骤或期望的表现吗?不方便回复"没有",我直接提交。」' +
|
|
363
558
|
'Answer → reproSteps/expectedBehavior verbatim excerpt, never into content; "没有/跳过"=omit both. ' +
|
|
364
559
|
'Batch ≤50. Returns voiceIds (reconciliation key) + taskIds.',
|
|
@@ -376,12 +571,15 @@ export function apply(ctx, config) {
|
|
|
376
571
|
const voices = Array.isArray(args.voices) ? args.voices : [];
|
|
377
572
|
if (!voices.length) return textResult({ error: 'voices 为空', code: -32001 });
|
|
378
573
|
if (voices.length > 50) return textResult({ error: '单批上限 50 条', code: -32001 });
|
|
379
|
-
// 归因(D-attrib-
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
574
|
+
// 归因(D-attrib-B,对齐 vod_mcp/attribution.py):从用户原话解析,
|
|
575
|
+
// 部署 config.product 只是「无字面证据且无记忆」时的先验
|
|
576
|
+
const meta = await loadMeta(c, exec?.signal);
|
|
577
|
+
const attrText = voices.map((v) => String(v?.content ?? '')).join('\n');
|
|
578
|
+
const attr = attributeProduct(attrText, meta, {
|
|
579
|
+
memory: loadRuntime().attribution_memory,
|
|
580
|
+
binding: String(c.product || ''),
|
|
581
|
+
});
|
|
582
|
+
const product = attr.product || '';
|
|
385
583
|
const source = 'dsh';
|
|
386
584
|
// D-rguard-1:原文比对(whitelist 通道=会话日志 user 轮)。enforce 档
|
|
387
585
|
// mismatch/unavailable 拒收;report(默认)只标注;off 全跳过。
|
|
@@ -421,14 +619,15 @@ export function apply(ctx, config) {
|
|
|
421
619
|
hoard.push(hv);
|
|
422
620
|
}
|
|
423
621
|
if (hoard.length) {
|
|
424
|
-
|
|
622
|
+
const hoardBody = { voices: hoard, ...(product ? { product } : {}) };
|
|
623
|
+
let out = await http('POST', HOARD_PATH, hoardBody,
|
|
425
624
|
{ ...c, key, signal: exec?.signal });
|
|
426
625
|
if (out.status === 401 && i0Anon(c)) {
|
|
427
626
|
const token = await fetchAnonToken({ ...c, key: '', signal: exec?.signal });
|
|
428
627
|
if (token) {
|
|
429
628
|
key = token;
|
|
430
629
|
saveRuntime({ java_key: token, token_tier: 'anonymous' });
|
|
431
|
-
out = await http('POST', HOARD_PATH,
|
|
630
|
+
out = await http('POST', HOARD_PATH, hoardBody,
|
|
432
631
|
{ ...c, key, signal: exec?.signal });
|
|
433
632
|
} else {
|
|
434
633
|
return textResult({
|
|
@@ -450,14 +649,18 @@ export function apply(ctx, config) {
|
|
|
450
649
|
taskIds.push(null); // 囤积语义:无即时任务
|
|
451
650
|
}
|
|
452
651
|
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
652
|
+
rememberAttribution(attr); // 只记有字面证据的唯一命中
|
|
453
653
|
ledgerAppend(hoard.map((h, i) => ({
|
|
454
654
|
voiceId: ids[i] || '', taskId: null,
|
|
455
655
|
title: h.title.slice(0, 40), product,
|
|
656
|
+
productSource: attr.source, productEvidence: attr.evidence,
|
|
456
657
|
at: now, status: sts[i] === 'skipped' ? 'accepted' : 'accepted',
|
|
457
658
|
})));
|
|
458
659
|
return textResult({
|
|
459
660
|
accepted: accepted.length, voiceIds: accepted,
|
|
460
661
|
taskIds, rejected, path: 'hoarding',
|
|
662
|
+
productSource: attr.source,
|
|
663
|
+
...(attr.evidence && attr.evidence.length ? { productEvidence: attr.evidence } : {}),
|
|
461
664
|
...(rgMode !== 'off' ? { receiptGuard: rgGuardSummary(rgVerdict, hoard.length) } : {}),
|
|
462
665
|
...(d.productRegistered !== undefined ? { productRegistered: d.productRegistered } : {}),
|
|
463
666
|
});
|
|
@@ -477,7 +680,7 @@ export function apply(ctx, config) {
|
|
|
477
680
|
voiceId: vid,
|
|
478
681
|
title: content.slice(0, 128), // R3:title=用户原文(分析消费),模板只允许出现在 description
|
|
479
682
|
description: desc,
|
|
480
|
-
product,
|
|
683
|
+
...(product ? { product } : {}), // 无证据/歧义 → 不带 product(引擎 UNKNOWN 池)
|
|
481
684
|
source,
|
|
482
685
|
...(v.userType ? { customer: v.userType } : {}),
|
|
483
686
|
};
|
|
@@ -508,12 +711,16 @@ export function apply(ctx, config) {
|
|
|
508
711
|
}
|
|
509
712
|
}
|
|
510
713
|
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
714
|
+
if (accepted.length) rememberAttribution(attr);
|
|
511
715
|
ledgerAppend(accepted.map((vid, i) => ({
|
|
512
716
|
voiceId: vid, taskId: taskIds[i],
|
|
513
717
|
title: String((voices[i] || {}).content ?? '').slice(0, 40),
|
|
514
|
-
product,
|
|
718
|
+
product, productSource: attr.source, productEvidence: attr.evidence,
|
|
719
|
+
at: now,
|
|
515
720
|
})));
|
|
516
721
|
return textResult({ accepted: accepted.length, voiceIds: accepted, taskIds, rejected,
|
|
722
|
+
productSource: attr.source,
|
|
723
|
+
...(attr.evidence && attr.evidence.length ? { productEvidence: attr.evidence } : {}),
|
|
517
724
|
...(rgMode !== 'off' ? { receiptGuard: rgGuardSummary(rgVerdict, voices.length) } : {}) });
|
|
518
725
|
},
|
|
519
726
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vod-devkit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "VOD user-voice collection tools for DeepSeek Harness (dsh). Thin shell over the VOD external HTTP API — mirrors vod-devkit (MCP) collect semantics.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|