dsh-context-toolkit 0.3.0 → 0.3.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 CHANGED
@@ -115,7 +115,7 @@ Tool switches: `tools.execute`, `tools.executeFile`, `tools.batchExecute`, `tool
115
115
  The offline suites need no DSH runtime:
116
116
 
117
117
  ```bash
118
- node smoke.mjs # 70 checks: contract, runtime discovery, tools, gate (segment matching, prefix/path normalisation, host-aligned path base, script_path and host-fetcher coverage), resource disposal, knowledge base, observability, version reporting
118
+ node smoke.mjs # 82 checks: contract, runtime discovery, tools, gate (segment matching, host-aligned path base, script_path and host-fetcher coverage), output slimming and reversible retrieval, resource disposal, knowledge base, observability, version reporting
119
119
  node test-client.mjs # 27 checks: browser-half contract and bilingual dictionary parity
120
120
  node test-package.mjs # 20 checks: publish manifest and the zero-dependency constraint
121
121
  node release-check.mjs # 30 checks: release readiness (manifest, deps, tool count, gate matching, version, SHA coverage, no hardcoded paths)
package/README.zh.md CHANGED
@@ -116,7 +116,7 @@ await ctk_search({ queries: ['rate limit', 'auth'] }); // 只取相关片段
116
116
  离线套件不依赖 DSH 运行时:
117
117
 
118
118
  ```bash
119
- node smoke.mjs # 70 项:契约、运行时探测、三工具、门禁(分段匹配 + 前缀/路径归一 + 路径基准对齐 + script_path 与取网页工具覆盖)、资源释放、知识库、观测、版本自述
119
+ node smoke.mjs # 82 项:契约、运行时探测、工具、门禁(分段匹配 + 路径基准对齐 + script_path 与取网页工具覆盖)、输出瘦身与可逆取回、资源释放、知识库、观测、版本自述
120
120
  node test-client.mjs # 27 项:浏览器半体契约与双语字典一致性
121
121
  node test-package.mjs # 20 项:发布清单与零依赖约束
122
122
  node release-check.mjs # 30 项:发布就绪(清单/依赖/工具数/门禁匹配/版本/SHA 覆盖/无硬编码路径)
package/index.js CHANGED
@@ -1086,11 +1086,16 @@ function registerKnowledgeTools(ctx, config, stats, store, log) {
1086
1086
  }
1087
1087
  }
1088
1088
  stats.calls['ctk_retrieve'] = (stats.calls['ctk_retrieve'] || 0) + 1
1089
+ // isError must be present on every return: the host validates a tool's output
1090
+ // against the declared schema and rejects the call outright when it is missing.
1091
+ // Omitting it here made the whole tool unusable — the marker was injected, the
1092
+ // original was stored, and the read-back failed with "missing required property".
1089
1093
  return {
1090
1094
  text: '## ctk_retrieve ' + id + '\n'
1091
1095
  + '- bytes: ' + found.bytes + ' (exact original, restored verbatim)\n'
1092
1096
  + '- stored: ' + new Date(found.createdAtMs).toISOString() + '\n\n'
1093
1097
  + found.text,
1098
+ isError: false,
1094
1099
  }
1095
1100
  },
1096
1101
  }, 'ctk_retrieve'))
@@ -1411,8 +1416,11 @@ function registerObservabilityTools(ctx, config, stats, store, storageDir, log)
1411
1416
  description: 'Report this plugin\'s savings ledger and knowledge-base usage. Shows how many calls the routing gate refused, how many bytes the sandbox kept out of the conversation, how many bytes were filed, and the per-tool call counts.',
1412
1417
  parameters: { type: 'object', properties: {}, additionalProperties: false },
1413
1418
  async execute() {
1414
- const kb = store ? store.stats() : { documents: 0, chunks: 0, bytes: 0 }
1415
- const produced = stats.bytesSandboxed + stats.bytesIndexed + stats.deniedBytes
1419
+ const kb = store ? store.stats() : { documents: 0, chunks: 0, bytes: 0, blobs: 0, blobBytes: 0 }
1420
+ // Slimmed bytes are kept out too — they were removed from output before it
1421
+ // reached the model. Leaving them out understated the ledger by exactly the
1422
+ // amount this half of the plugin exists to save.
1423
+ const produced = stats.bytesSandboxed + stats.bytesIndexed + stats.deniedBytes + stats.slimmedBytes
1416
1424
  const keptOut = produced
1417
1425
  const uptimeMs = Date.now() - stats.startedAt
1418
1426
  const lines = [
@@ -1422,12 +1430,14 @@ function registerObservabilityTools(ctx, config, stats, store, storageDir, log)
1422
1430
  '- 门禁拦截 denied: ' + stats.denied + ' 次(约 ' + stats.deniedBytes + ' 字节未进入上下文)',
1423
1431
  '- 沙箱保留 bytesSandboxed: ' + stats.bytesSandboxed + ' 字节(子进程产出但只回结论的部分)',
1424
1432
  '- 已归档 bytesIndexed: ' + stats.bytesIndexed + ' 字节(存入知识库、未留在对话里)',
1433
+ '- 输出瘦身 slimmed: ' + stats.slimmed + ' 块(' + stats.slimmedBytes + ' 字节 ≈ ' + stats.slimmedTokens + ' tokens 未进入上下文;跳过的块 ' + stats.slimSkipped + ')',
1425
1434
  '- 合计 kept out of context: ' + keptOut + ' 字节 ≈ ' + Math.round(keptOut / 4) + ' tokens(按 4 字节/token 估算)',
1426
1435
  '',
1427
1436
  '### 知识库 / knowledge base',
1428
1437
  '- 文档 documents: ' + kb.documents,
1429
1438
  '- 片段 chunks: ' + kb.chunks,
1430
1439
  '- 原文字节 bytes: ' + kb.bytes,
1440
+ '- 可逆原文 blobs: ' + (kb.blobs || 0) + '(' + (kb.blobBytes || 0) + ' 字节,可用 ctk_retrieve 逐字节取回)',
1431
1441
  '- 位置: ' + storageDir,
1432
1442
  '',
1433
1443
  '### 本插件注册的工具',
@@ -1499,6 +1509,9 @@ function registerObservabilityTools(ctx, config, stats, store, storageDir, log)
1499
1509
  lines.push('- 门禁拦截 denied: ' + stats.denied + ' 次(' + stats.deniedBytes + ' 字节未进入上下文)')
1500
1510
  lines.push('- 沙箱保留 bytesSandboxed: ' + stats.bytesSandboxed + ' 字节')
1501
1511
  lines.push('- 已归档 bytesIndexed: ' + stats.bytesIndexed + ' 字节')
1512
+ lines.push('- 输出瘦身 slimmed: ' + stats.slimmed + ' 块(' + stats.slimmedBytes + ' 字节 ≈ ' + stats.slimmedTokens + ' tokens 未进入上下文)')
1513
+ lines.push('- 可逆原文 blobsStored: ' + stats.blobsStored + ' 份(可用 ctk_retrieve 逐字节取回)')
1514
+ if (stats.slimmed > 0) lines.push('- 瘦身策略: ' + Object.keys(stats.slimStrategies).map((k) => k + '×' + stats.slimStrategies[k]).join(' · '))
1502
1515
  lines.push('- 已注册 registered: ' + stats.registered)
1503
1516
  return { text: lines.join('\n'), isError: false }
1504
1517
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context-toolkit",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "DeepSeek Harness bundle: native ctk_* sandbox tools, a routing gate that keeps bulk output out of the transcript, and a local full-text knowledge base. No third-party runtime dependencies.",
5
5
  "repository": {
6
6
  "type": "git",