@omdp/dsh-connector 0.3.1 → 0.3.2

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.
Files changed (2) hide show
  1. package/index.js +12 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -941,22 +941,19 @@ export function apply(ctx) {
941
941
  }
942
942
  }
943
943
 
944
- // ── 三件套之 (1):prompt 层过滤 —— 被滤掉的工具不进模型 schema ──
945
- // tools provider 在每次 assembly 时求值,读最新快照;无 tools/systemPrompt
946
- // 服务时跳过(ctx.get 可选读,失败隔离:connector 照常提供设置页)。
944
+ // ── 三件套之 (1):prompt 层过滤 —— assemble waterfall 真替换 ──
945
+ // 注意:systemPrompt.tools(provider) 是追加合并语义(各 provider 输出拼在一起),
946
+ // 只能加不能减,做减法必须监听 system-prompt/assemble,await next() 后替换 tools 数组。
947
+ // 成熟参照:hyqhyq3/dsh-mcp-manager 就是 ctx.on('system-prompt/assemble', …, { global: true })。
948
+ // { global: true } 让 scope filter 放行(见 dsh-scope scopeTarget 的 hook.global 短路)。
947
949
  try {
948
- const systemPrompt = ctx.get('systemPrompt')
949
- if (systemPrompt && typeof systemPrompt.tools === 'function') {
950
- ctx.effect(() => systemPrompt.tools(() => {
951
- let schemas = []
952
- try {
953
- const tools = ctx.get('tools')
954
- schemas = tools ? tools.schemas() : []
955
- } catch { return { schemas: [] } }
956
- const kept = schemas.filter((s) => isToolAllowed(toolFilters, s && s.name))
957
- return { schemas: kept, knownNames: schemas.map((s) => s && s.name).filter(Boolean) }
958
- }), 'connector: mcp tool filter provider')
959
- }
950
+ ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
951
+ const assembled = await next()
952
+ if (!assembled || !Array.isArray(assembled.tools)) return assembled
953
+ const kept = assembled.tools.filter((t) => isToolAllowed(toolFilters, t && t.name))
954
+ if (kept.length === assembled.tools.length) return assembled
955
+ return { ...assembled, tools: kept }
956
+ }, { global: true })
960
957
  } catch {}
961
958
  // ── 三件套之 (2):执行期硬拦截 —— 补 provider 漏网(如 guard 注册时序)──
962
959
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omdp/dsh-connector",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Unified DeepSeek Harness connector: edit MCP servers (cordis.patch.yml), user skills (~/.dsh/skills) and browse the ModelScope MCP/Skills marketplaces from one Web UI settings page.",
5
5
  "type": "module",
6
6
  "main": "index.js",