@daweifu/capability-menu 0.1.0 → 0.1.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.
- package/README.en.md +217 -0
- package/README.md +144 -135
- package/cordis.patch.yml +41 -33
- package/lib/client.d.ts +182 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +6508 -0
- package/lib/index.js +27 -13
- package/lib/index.js.map +1 -0
- package/lib/invoke.js +69 -97
- package/lib/invoke.js.map +1 -0
- package/lib/policy.js +228 -84
- package/lib/policy.js.map +1 -0
- package/lib/registry.js +184 -144
- package/lib/registry.js.map +1 -0
- package/lib/search.js +19 -10
- package/lib/search.js.map +1 -0
- package/lib/server/remote.js +194 -0
- package/lib/server/remote.js.map +1 -0
- package/lib/types/index.d.ts +25 -13
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/invoke.d.ts +7 -13
- package/lib/types/invoke.d.ts.map +1 -0
- package/lib/types/policy.d.ts +80 -57
- package/lib/types/policy.d.ts.map +1 -0
- package/lib/types/registry.d.ts +63 -26
- package/lib/types/registry.d.ts.map +1 -0
- package/lib/types/search.d.ts.map +1 -0
- package/lib/types/server/remote.d.ts +72 -0
- package/lib/types/server/remote.d.ts.map +1 -0
- package/package.json +55 -27
- package/lib/invariant.js +0 -22
- package/lib/types/invariant.d.ts +0 -16
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { TypertRemoteService, Remote } from '@deepseek-ai/dsh-typert-protocol';
|
|
36
|
+
import { readFile } from 'node:fs/promises';
|
|
37
|
+
import yaml from 'js-yaml';
|
|
38
|
+
import { BUILT_IN_SERVER } from "../registry.js";
|
|
39
|
+
/**
|
|
40
|
+
* Host-side remote face for the 能力管理 tab. Every method delegates to the
|
|
41
|
+
* policy service installed by `@daweifu/capability-menu/policy`; the registry
|
|
42
|
+
* sibling (`capability`) must be mounted for `classifyAll` to return anything.
|
|
43
|
+
*
|
|
44
|
+
* The service registers under a distinct key (`capabilityPolicyGateway`) so it
|
|
45
|
+
* does not collide with the `capabilityPolicy` service the policy plugin
|
|
46
|
+
* provides; the Typert wire namespace is still `capabilityPolicy` (matching
|
|
47
|
+
* the client remote descriptors), and the gateway reads the real policy
|
|
48
|
+
* service through `this.ctx.capabilityPolicy`.
|
|
49
|
+
*/
|
|
50
|
+
let CapabilityPolicyGateway = (() => {
|
|
51
|
+
let _classSuper = TypertRemoteService;
|
|
52
|
+
let _instanceExtraInitializers = [];
|
|
53
|
+
let _getConfig_decorators;
|
|
54
|
+
let _updateConfig_decorators;
|
|
55
|
+
let _classifyAll_decorators;
|
|
56
|
+
let _getDetail_decorators;
|
|
57
|
+
let _listSkillDir_decorators;
|
|
58
|
+
let _readSkillFile_decorators;
|
|
59
|
+
let _getCatalogDocs_decorators;
|
|
60
|
+
return class CapabilityPolicyGateway extends _classSuper {
|
|
61
|
+
static {
|
|
62
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
63
|
+
_getConfig_decorators = [Remote('getConfig')];
|
|
64
|
+
_updateConfig_decorators = [Remote('updateConfig')];
|
|
65
|
+
_classifyAll_decorators = [Remote('classifyAll')];
|
|
66
|
+
_getDetail_decorators = [Remote('getDetail')];
|
|
67
|
+
_listSkillDir_decorators = [Remote('listSkillDir')];
|
|
68
|
+
_readSkillFile_decorators = [Remote('readSkillFile')];
|
|
69
|
+
_getCatalogDocs_decorators = [Remote('getCatalogDocs')];
|
|
70
|
+
__esDecorate(this, null, _getConfig_decorators, { kind: "method", name: "getConfig", static: false, private: false, access: { has: obj => "getConfig" in obj, get: obj => obj.getConfig }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
71
|
+
__esDecorate(this, null, _updateConfig_decorators, { kind: "method", name: "updateConfig", static: false, private: false, access: { has: obj => "updateConfig" in obj, get: obj => obj.updateConfig }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
72
|
+
__esDecorate(this, null, _classifyAll_decorators, { kind: "method", name: "classifyAll", static: false, private: false, access: { has: obj => "classifyAll" in obj, get: obj => obj.classifyAll }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
73
|
+
__esDecorate(this, null, _getDetail_decorators, { kind: "method", name: "getDetail", static: false, private: false, access: { has: obj => "getDetail" in obj, get: obj => obj.getDetail }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
74
|
+
__esDecorate(this, null, _listSkillDir_decorators, { kind: "method", name: "listSkillDir", static: false, private: false, access: { has: obj => "listSkillDir" in obj, get: obj => obj.listSkillDir }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
75
|
+
__esDecorate(this, null, _readSkillFile_decorators, { kind: "method", name: "readSkillFile", static: false, private: false, access: { has: obj => "readSkillFile" in obj, get: obj => obj.readSkillFile }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
+
__esDecorate(this, null, _getCatalogDocs_decorators, { kind: "method", name: "getCatalogDocs", static: false, private: false, access: { has: obj => "getCatalogDocs" in obj, get: obj => obj.getCatalogDocs }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
77
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
78
|
+
}
|
|
79
|
+
static inject = ['capabilityPolicy', 'capability'];
|
|
80
|
+
constructor(ctx) {
|
|
81
|
+
super(ctx, 'capabilityPolicyGateway', { namespace: 'capabilityPolicy' });
|
|
82
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
83
|
+
}
|
|
84
|
+
/** Current (resolved) policy config. */
|
|
85
|
+
getConfig() {
|
|
86
|
+
return this.ctx.capabilityPolicy.getConfig();
|
|
87
|
+
}
|
|
88
|
+
/** Replace a subset of the policy config (recompile rules + rewrite catalog). */
|
|
89
|
+
async updateConfig(partial) {
|
|
90
|
+
await this.ctx.capabilityPolicy.updateConfig(partial);
|
|
91
|
+
}
|
|
92
|
+
/** Classify every capability currently indexed by `ctx.capability`. */
|
|
93
|
+
classifyAll() {
|
|
94
|
+
return [...this.ctx.capabilityPolicy.classifyAll()];
|
|
95
|
+
}
|
|
96
|
+
/** Resolve one capability's full detail (schema, description; skill body optional). */
|
|
97
|
+
async getDetail(id) {
|
|
98
|
+
return this.ctx.capability.getDetail(id);
|
|
99
|
+
}
|
|
100
|
+
/** List a skill's directory children (one level deep; optional subpath). */
|
|
101
|
+
async listSkillDir(id, relPath) {
|
|
102
|
+
return this.ctx.capability.listSkillDir(id, relPath);
|
|
103
|
+
}
|
|
104
|
+
/** Read a text file inside a skill's directory. */
|
|
105
|
+
async readSkillFile(id, relPath) {
|
|
106
|
+
return this.ctx.capability.readSkillFile(id, relPath);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 能力目录查看:返回「三档策略配置」语义化视图——默认全部常驻,
|
|
110
|
+
* tools.resident 按 server 各显示 '*',例外(on-demand/disabled)按
|
|
111
|
+
* server → 工具短名 分级列出;skills 无 server 维度,resident 恒为 '*',
|
|
112
|
+
* 例外为短名平铺。空例外不渲染 key,避免 []/{} 歧义。
|
|
113
|
+
* 另返回按需能力目录物化文件(~/.dsh/capability-catalog.yaml)的路径和内容。
|
|
114
|
+
* 两者都是只读视图——策略持久化入口仍是 cordis.patch.yml。
|
|
115
|
+
*/
|
|
116
|
+
async getCatalogDocs() {
|
|
117
|
+
const effective = [...this.ctx.capabilityPolicy.classifyAll()];
|
|
118
|
+
const toolRows = effective.filter(row => row.kind === 'tool');
|
|
119
|
+
const skillRows = effective.filter(row => row.kind === 'skill');
|
|
120
|
+
const count = (rows, cls) => rows.filter(row => row.class === cls).length;
|
|
121
|
+
/** 例外档(on-demand/disabled)的生效工具,按 server 分组为 server → 短名列表。 */
|
|
122
|
+
const toolGroups = (cls) => {
|
|
123
|
+
const groups = new Map();
|
|
124
|
+
for (const row of toolRows.filter(r => r.class === cls)) {
|
|
125
|
+
const server = row.server ?? BUILT_IN_SERVER;
|
|
126
|
+
const prefix = row.server === undefined ? undefined : `mcp__${row.server}__`;
|
|
127
|
+
const short = prefix !== undefined && row.name.startsWith(prefix) ? row.name.slice(prefix.length) : row.name;
|
|
128
|
+
const list = groups.get(server);
|
|
129
|
+
if (list === undefined)
|
|
130
|
+
groups.set(server, [short]);
|
|
131
|
+
else
|
|
132
|
+
list.push(short);
|
|
133
|
+
}
|
|
134
|
+
return Object.fromEntries([...groups.entries()]
|
|
135
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
136
|
+
.map(([server, names]) => [server, names.sort((a, b) => a.localeCompare(b))]));
|
|
137
|
+
};
|
|
138
|
+
/** 例外档技能的生效短名(技能无 server 维度,平铺列表)。 */
|
|
139
|
+
const skillNames = (cls) => skillRows.filter(row => row.class === cls).map(row => row.name).sort((a, b) => a.localeCompare(b));
|
|
140
|
+
// tools.resident:每个含工具的 server 一个 '*'(该 server 其余工具默认常驻)。
|
|
141
|
+
const servers = [...new Set(toolRows.map(row => row.server ?? BUILT_IN_SERVER))]
|
|
142
|
+
.sort((a, b) => a.localeCompare(b));
|
|
143
|
+
const residentTools = {};
|
|
144
|
+
for (const server of servers)
|
|
145
|
+
residentTools[server] = '*';
|
|
146
|
+
// 例外档仅当实际存在时才写入,避免空的 []/{}。
|
|
147
|
+
const tools = { resident: residentTools };
|
|
148
|
+
const onDemandTools = toolGroups('on-demand');
|
|
149
|
+
const disabledTools = toolGroups('disabled');
|
|
150
|
+
if (Object.keys(onDemandTools).length > 0)
|
|
151
|
+
tools['on-demand'] = onDemandTools;
|
|
152
|
+
if (Object.keys(disabledTools).length > 0)
|
|
153
|
+
tools.disabled = disabledTools;
|
|
154
|
+
const skills = { resident: '*' };
|
|
155
|
+
const onDemandSkills = skillNames('on-demand');
|
|
156
|
+
const disabledSkills = skillNames('disabled');
|
|
157
|
+
if (onDemandSkills.length > 0)
|
|
158
|
+
skills['on-demand'] = onDemandSkills;
|
|
159
|
+
if (disabledSkills.length > 0)
|
|
160
|
+
skills.disabled = disabledSkills;
|
|
161
|
+
const policyYaml = [
|
|
162
|
+
'# 能力管理 · 当前生效策略(只读;持久化入口:cordis.patch.yml)',
|
|
163
|
+
'# 语义:默认全部能力常驻;下方 on-demand / disabled 为按 server → 工具名分级的例外。',
|
|
164
|
+
`# 生效:tools 常驻 ${count(toolRows, 'resident')} · 按需 ${count(toolRows, 'on-demand')} · 禁用 ${count(toolRows, 'disabled')};` +
|
|
165
|
+
`skills 常驻 ${count(skillRows, 'resident')} · 按需 ${count(skillRows, 'on-demand')} · 禁用 ${count(skillRows, 'disabled')}`,
|
|
166
|
+
yaml.dump({
|
|
167
|
+
metaTools: [...this.ctx.capabilityPolicy.metaTools()],
|
|
168
|
+
tools,
|
|
169
|
+
skills,
|
|
170
|
+
}).trimEnd(),
|
|
171
|
+
].join('\n');
|
|
172
|
+
const catalogPath = this.ctx.capability.catalogPath?.();
|
|
173
|
+
if (catalogPath === undefined) {
|
|
174
|
+
return { policyYaml, catalogMissing: 'disabled' };
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const content = await readFile(catalogPath, 'utf8');
|
|
178
|
+
return { policyYaml, catalog: { path: catalogPath, content } };
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
this.ctx.logger.warn(`capability-menu-remote: on-demand catalog read failed (${catalogPath}): ${String(error)}`);
|
|
182
|
+
return { policyYaml, catalogMissing: 'read-failed' };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
})();
|
|
187
|
+
export { CapabilityPolicyGateway };
|
|
188
|
+
/** Register the remote gateway on a context. */
|
|
189
|
+
export const name = 'capability-menu-remote';
|
|
190
|
+
export const inject = ['capabilityPolicy', 'capability'];
|
|
191
|
+
export function apply(ctx) {
|
|
192
|
+
ctx.plugin(CapabilityPolicyGateway);
|
|
193
|
+
}
|
|
194
|
+
//# sourceMapping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AE,MAAM,CAAC,CAAA;gBACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,CAAA;YAChE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,0DAA0D,WAAW,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;gBAChH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,CAAA;YACtD,CAAC;QACH,CAAC;;;SAxHU,uBAAuB;AA2HpC,gDAAgD;AAChD,MAAM,CAAC,MAAM,IAAI,GAAG,wBAAwB,CAAA;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAA;AACxD,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,GAAG,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAA;AACrC,CAAC"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @daweifu/capability-menu — consolidated plugin package.
|
|
2
|
+
* @daweifu/capability-menu — consolidated plugin package (server + browser).
|
|
3
3
|
*
|
|
4
|
-
* One installable source package exposing
|
|
5
|
-
* bundle mounts as separate entries via subpath exports (`/registry`, `/search`,
|
|
6
|
-
* `/invoke`, `/policy`):
|
|
4
|
+
* One installable source package exposing:
|
|
7
5
|
*
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* - four cordis plugin factories via subpath exports (`/registry`, `/search`,
|
|
7
|
+
* `/invoke`, `/policy`), mounted by the bundle patch as separate entries:
|
|
8
|
+
* - `registry` (P0): capability catalog + `ctx.capability` service (no model tool).
|
|
9
|
+
* - `search` (P1): registers `meta_search`.
|
|
10
|
+
* - `invoke` (P2): registers `meta_invoke`.
|
|
11
|
+
* - `policy` (P3): Resident/On-demand/Disabled projection policy + `ctx.capabilityPolicy`.
|
|
12
|
+
* - the package root entry (`name` + `apply` below): mounts the Typert gateway
|
|
13
|
+
* that exposes `ctx.capabilityPolicy` to the browser as the `capabilityPolicy`
|
|
14
|
+
* remote namespace — the data source of the 能力管理 settings tab.
|
|
15
|
+
* - a browser bundle via the `./client` subpath (`src/client`), discovered by
|
|
16
|
+
* `@deepseek-ai/dsh-client-modules` from this package's `dsh.client`
|
|
17
|
+
* declaration and served as `/plugins/<id>/client.js`.
|
|
18
|
+
*
|
|
19
|
+
* NOTE: this module deliberately re-exports nothing from the subpath plugins
|
|
20
|
+
* (not even types — those live at `/registry`, `/search`, `/invoke`, `/policy`).
|
|
21
|
+
* Re-exporting would either pollute the root entry's plugin identity with the
|
|
22
|
+
* sub-plugins' `name`/`apply`/`inject`, or trigger ambiguous-type re-exports
|
|
23
|
+
* (each subpath exports its own `Config` interface).
|
|
12
24
|
*
|
|
13
25
|
* @module @daweifu/capability-menu
|
|
14
26
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export
|
|
27
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
28
|
+
/** Root plugin identity (matches the `capability-menu` patch entry id). */
|
|
29
|
+
export declare const name = "capability-menu";
|
|
30
|
+
/** Root entry: mount the browser-facing capabilityPolicy gateway. */
|
|
31
|
+
export declare function apply(ctx: Context): void;
|
|
20
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,2EAA2E;AAC3E,eAAO,MAAM,IAAI,oBAAoB,CAAA;AAErC,qEAAqE;AACrE,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAExC"}
|
package/lib/types/invoke.d.ts
CHANGED
|
@@ -59,22 +59,16 @@ export type MetaInvokeResult = {
|
|
|
59
59
|
/**
|
|
60
60
|
* Register the `meta_invoke` tool.
|
|
61
61
|
*
|
|
62
|
-
* Dispatch is by `
|
|
63
|
-
* kept only as a defensive guard alongside the kind check).
|
|
62
|
+
* Dispatch is by the explicit `kind` argument (no id-prefix parsing).
|
|
64
63
|
*
|
|
65
|
-
* - Tools (`kind: 'tool'`,
|
|
66
|
-
* call via the official
|
|
67
|
-
* `agent`/`signal`/parent lineage.
|
|
68
|
-
* the target schema so the model can
|
|
69
|
-
*
|
|
64
|
+
* - Tools (`kind: 'tool'`, e.g. `mcp__gongfeng__create_issue` or a harness-native
|
|
65
|
+
* tool such as `bash`): forwards to the underlying tool call via the official
|
|
66
|
+
* `ctx.tools.execute` pipeline, preserving `agent`/`signal`/parent lineage.
|
|
67
|
+
* `forwardMode: 'resolve'` instead returns the target schema so the model can
|
|
68
|
+
* call the tool directly.
|
|
69
|
+
* - Skills (`kind: 'skill'`, id is the bare skill name): loads the full skill
|
|
70
70
|
* instructions and returns them as `<skill_content>` — no args, no script
|
|
71
71
|
* execution (matches the existing `skill` tool semantics).
|
|
72
72
|
*/
|
|
73
73
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
74
|
-
/**
|
|
75
|
-
* Strip leading YAML frontmatter (`---\n...\n---`) from a raw SKILL.md body,
|
|
76
|
-
* returning the remaining markdown. Falls back to the raw text when no
|
|
77
|
-
* frontmatter delimiter is present.
|
|
78
|
-
*/
|
|
79
|
-
export declare function stripFrontmatter(markdown: string): string;
|
|
80
74
|
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/invoke.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;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AC,IAAI,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,GAClE;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,GACtE;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,CAAA;AAE9E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAwP7D"}
|
package/lib/types/policy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Resident / On-demand / Disabled capability projection policy for the DeepSeek
|
|
3
3
|
* Harness.
|
|
4
4
|
*
|
|
5
5
|
* @module @daweifu/capability-menu (policy plugin)
|
|
@@ -11,19 +11,19 @@ import { type CapabilityKind } from './registry.ts';
|
|
|
11
11
|
/**
|
|
12
12
|
* Canonical policy classes, mirroring the registry's `CapabilityKind`.
|
|
13
13
|
*
|
|
14
|
-
* - `
|
|
14
|
+
* - `resident`: the capability is on the dsh-native exposure surface — tools in
|
|
15
15
|
* `assembly.tools` (the request `tools` payload), skills in the
|
|
16
16
|
* `<available_skills>` catalog — so the model can call/load it single-hop.
|
|
17
|
-
* - `
|
|
17
|
+
* - `on-demand`: absent from the native surface but discoverable in the
|
|
18
18
|
* persistent meta registry; the model reaches it via `meta_search` then
|
|
19
19
|
* `meta_invoke` (catalog-resident, load/execute on demand).
|
|
20
|
-
* - `
|
|
20
|
+
* - `disabled`: neither resident nor discoverable nor executable.
|
|
21
21
|
*/
|
|
22
|
-
export type CapabilityClass = '
|
|
22
|
+
export type CapabilityClass = 'resident' | 'on-demand' | 'disabled';
|
|
23
23
|
/**
|
|
24
24
|
* A single classify rule: an exact name or a `*`-glob pattern.
|
|
25
|
-
* A pattern matches a capability id (`mcp__<server>__<raw
|
|
26
|
-
* or a server name (`server:<name>`).
|
|
25
|
+
* A pattern matches a capability id (`mcp__<server>__<raw>`, a native tool
|
|
26
|
+
* name, or a bare skill name) or a server name (`server:<name>`).
|
|
27
27
|
*/
|
|
28
28
|
export interface PolicyRule {
|
|
29
29
|
/** Whether the rule is a literal exact name (`*` free) or a glob pattern. */
|
|
@@ -36,39 +36,57 @@ export interface PolicyRule {
|
|
|
36
36
|
readonly target: 'id' | 'server';
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Per-kind explicit configuration. `
|
|
39
|
+
* Per-kind explicit configuration. `resident`/`on-demand`/`disabled` are
|
|
40
40
|
* ordered lists of exact-name / glob rules. Empty lists mean "nothing
|
|
41
|
-
* explicitly classified", so the default (`
|
|
41
|
+
* explicitly classified", so the default (`resident`) applies.
|
|
42
42
|
*/
|
|
43
43
|
export interface CapabilitySetConfig {
|
|
44
|
-
/** Explicitly-
|
|
44
|
+
/** Explicitly-Resident rule list (exact name or glob). */
|
|
45
|
+
resident?: string[];
|
|
46
|
+
/** Explicitly-On-demand rule list (exact name or glob). */
|
|
47
|
+
'on-demand'?: string[];
|
|
48
|
+
/** Explicitly-Disabled rule list (exact name or glob); wins over everything. */
|
|
49
|
+
disabled?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated pre-rename alias of `disabled`; accepted and mapped so legacy
|
|
52
|
+
* profiles written with the `blocked` key keep working without an on-disk
|
|
53
|
+
* rewrite.
|
|
54
|
+
*/
|
|
55
|
+
blocked?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated pre-rename alias of `resident`; accepted and mapped so legacy
|
|
58
|
+
* profiles keep working without an on-disk rewrite.
|
|
59
|
+
*/
|
|
45
60
|
exposed?: string[];
|
|
46
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated pre-rename alias of `on-demand`; accepted and mapped so legacy
|
|
63
|
+
* profiles keep working without an on-disk rewrite.
|
|
64
|
+
*/
|
|
47
65
|
progressive?: string[];
|
|
48
|
-
/** Explicitly-Blocked rule list (exact name or glob); wins over everything. */
|
|
49
|
-
blocked?: string[];
|
|
50
66
|
}
|
|
51
|
-
/**
|
|
67
|
+
/** Resident / On-demand / Disabled projection policy configuration. */
|
|
52
68
|
export interface Config {
|
|
53
|
-
/** Tool classification: `tools.
|
|
69
|
+
/** Tool classification: `tools.resident` / `tools.on-demand` / `tools.disabled`. */
|
|
54
70
|
tools?: CapabilitySetConfig;
|
|
55
|
-
/** Skill classification: `skills.
|
|
71
|
+
/** Skill classification: `skills.resident` / `skills.on-demand` / `skills.disabled`. */
|
|
56
72
|
skills?: CapabilitySetConfig;
|
|
57
73
|
/**
|
|
58
|
-
* Tool names that are ALWAYS kept
|
|
59
|
-
*
|
|
74
|
+
* Tool names that are ALWAYS kept resident and can never be classified
|
|
75
|
+
* On-demand or Disabled. Default `[meta_search, meta_invoke]`.
|
|
60
76
|
*/
|
|
61
77
|
metaTools?: string[];
|
|
62
|
-
/**
|
|
63
|
-
* Optional path to a Progressive-skill catalog YAML (name + description +
|
|
64
|
-
* path). Consumed by the registry as an additional skill index source (see
|
|
65
|
-
* `@daweifu/capability-menu-registry` `progressiveSkillCatalog`).
|
|
66
|
-
*/
|
|
67
|
-
progressiveSkillCatalog?: string;
|
|
68
78
|
}
|
|
69
79
|
/** Validate and default the policy configuration. */
|
|
70
80
|
export declare const Config: z<Config>;
|
|
71
81
|
export declare const DEFAULT_META_TOOLS: readonly ["meta_search", "meta_invoke"];
|
|
82
|
+
/**
|
|
83
|
+
* Map a legacy rule set (old keys `exposed`/`progressive`/`blocked`) onto the
|
|
84
|
+
* current key names (`resident`/`on-demand`/`disabled`), so already-deployed
|
|
85
|
+
* `cordis.patch.yml` profiles keep working without an on-disk rewrite. New
|
|
86
|
+
* keys win when they carry rules; a legacy key fills in when the matching new
|
|
87
|
+
* list is empty.
|
|
88
|
+
*/
|
|
89
|
+
export declare function normalizeSetConfig(set: CapabilitySetConfig | undefined): CapabilitySetConfig | undefined;
|
|
72
90
|
/**
|
|
73
91
|
* Convert a user-facing rule string into a normalized {@link PolicyRule}.
|
|
74
92
|
* - `server:<name>` → server-targeted rule (`target: 'server'`).
|
|
@@ -81,17 +99,17 @@ export declare function parseRule(rule: string): PolicyRule;
|
|
|
81
99
|
export declare function compileGlob(pattern: string): RegExp;
|
|
82
100
|
/** A compiled rule set for one capability kind. */
|
|
83
101
|
export interface CompiledCapabilityRules {
|
|
84
|
-
readonly
|
|
85
|
-
readonly
|
|
86
|
-
readonly
|
|
102
|
+
readonly resident: readonly PolicyRule[];
|
|
103
|
+
readonly onDemand: readonly PolicyRule[];
|
|
104
|
+
readonly disabled: readonly PolicyRule[];
|
|
87
105
|
}
|
|
88
106
|
/** Compile a {@link CapabilitySetConfig} into fast-matchable rules. */
|
|
89
107
|
export declare function compileSet(set?: CapabilitySetConfig): CompiledCapabilityRules;
|
|
90
108
|
/** Candidate fields a rule is matched against. */
|
|
91
109
|
export interface MatchTarget {
|
|
92
|
-
/**
|
|
110
|
+
/** Capability id: `mcp__<server>__<raw>`, a native tool name, or a bare skill name. */
|
|
93
111
|
readonly id: string;
|
|
94
|
-
/**
|
|
112
|
+
/** Model-facing name (for skills it equals the id; for MCP tools the public `mcp__...` name). */
|
|
95
113
|
readonly name: string;
|
|
96
114
|
/** Server name for tools; undefined for skills. */
|
|
97
115
|
readonly server?: string;
|
|
@@ -102,9 +120,13 @@ export interface MatchTarget {
|
|
|
102
120
|
}
|
|
103
121
|
/**
|
|
104
122
|
* Classify a capability against compiled rules. Priority (hit stops the walk):
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
123
|
+
* disabled-exact > disabled-wildcard > resident-exact > on-demand-exact >
|
|
124
|
+
* resident-wildcard > on-demand-wildcard > default (resident). `disabled` is a
|
|
125
|
+
* control decision, so it beats an explicit `resident` rule. Within
|
|
126
|
+
* resident/on-demand an exact name beats a wildcard, so the management UI can
|
|
127
|
+
* pin a single capability to a class even when a broader wildcard rule says
|
|
128
|
+
* otherwise (e.g. `tools.resident: ['mcp__gongfeng__*']` must not silently win
|
|
129
|
+
* over an explicit per-tool `on-demand` rule).
|
|
108
130
|
*/
|
|
109
131
|
export declare function classify(compiled: CompiledCapabilityRules, target: MatchTarget, metaTools?: ReadonlySet<string> | readonly string[]): CapabilityClass;
|
|
110
132
|
/**
|
|
@@ -117,12 +139,14 @@ export interface CapabilityClassification {
|
|
|
117
139
|
readonly kind: CapabilityKind;
|
|
118
140
|
/** Model-facing name (tool name or skill bare name). */
|
|
119
141
|
readonly name: string;
|
|
120
|
-
/**
|
|
142
|
+
/** Server namespace for tools (`built-in` for harness-native tools); undefined for skills. */
|
|
121
143
|
readonly server?: string;
|
|
144
|
+
/** Skill source root label, present only for skills. */
|
|
145
|
+
readonly source?: string;
|
|
122
146
|
readonly class: CapabilityClass;
|
|
123
147
|
/** Human-friendly display label for the classification. */
|
|
124
148
|
readonly classLabel: string;
|
|
125
|
-
/** True when this capability is a mandatory meta tool (always
|
|
149
|
+
/** True when this capability is a mandatory meta tool (always Resident). */
|
|
126
150
|
readonly mandatory: boolean;
|
|
127
151
|
}
|
|
128
152
|
/**
|
|
@@ -133,34 +157,33 @@ export interface CapabilityPolicyService {
|
|
|
133
157
|
classifyTool(name: string): CapabilityClass;
|
|
134
158
|
/** Classify a skill by its bare name. */
|
|
135
159
|
classifySkill(name: string): CapabilityClass;
|
|
136
|
-
/** True when a tool is
|
|
137
|
-
|
|
138
|
-
/** True when a skill is
|
|
139
|
-
|
|
140
|
-
/** True when a tool is
|
|
141
|
-
|
|
142
|
-
/** True when a skill is
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
/** Tool names that are always kept Exposed. */
|
|
160
|
+
/** True when a tool is Resident (or a mandatory meta tool). */
|
|
161
|
+
isResidentTool(name: string): boolean;
|
|
162
|
+
/** True when a skill is Resident. */
|
|
163
|
+
isResidentSkill(name: string): boolean;
|
|
164
|
+
/** True when a tool is Disabled. */
|
|
165
|
+
isDisabledTool(name: string): boolean;
|
|
166
|
+
/** True when a skill is Disabled. */
|
|
167
|
+
isDisabledSkill(name: string): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* True when a capability (by id and `kind`) is Disabled. `kind` disambiguates
|
|
170
|
+
* a bare name shared by a tool and a skill.
|
|
171
|
+
*/
|
|
172
|
+
isDisabledCapability(id: string, kind?: CapabilityKind): boolean;
|
|
173
|
+
/** Tool names that are always kept Resident. */
|
|
151
174
|
metaTools(): readonly string[];
|
|
152
|
-
/** Resolve a capability's id
|
|
153
|
-
classifyCapability(id: string): CapabilityClass;
|
|
154
|
-
/** Rules
|
|
175
|
+
/** Resolve a capability's id to a class; pass `kind` to disambiguate a bare name. */
|
|
176
|
+
classifyCapability(id: string, kind?: CapabilityKind): CapabilityClass;
|
|
177
|
+
/** Rules resident for the registry/other consumers. */
|
|
155
178
|
toolRules(): CompiledCapabilityRules;
|
|
156
179
|
skillRules(): CompiledCapabilityRules;
|
|
157
180
|
/** Current (resolved) policy config. */
|
|
158
181
|
getConfig(): Config;
|
|
159
182
|
/** Replace a subset of the policy config and recompile rules immediately. */
|
|
160
|
-
updateConfig(partial: Partial<Config>): void
|
|
183
|
+
updateConfig(partial: Partial<Config>): Promise<void>;
|
|
161
184
|
/**
|
|
162
|
-
* Classify every capability currently indexed by `ctx.
|
|
163
|
-
* sibling). Returns an empty array when the registry is not mounted.
|
|
185
|
+
* Classify every capability currently indexed by `ctx.capability` (the
|
|
186
|
+
* registry sibling). Returns an empty array when the registry is not mounted.
|
|
164
187
|
*/
|
|
165
188
|
classifyAll(): readonly CapabilityClassification[];
|
|
166
189
|
}
|
|
@@ -170,12 +193,12 @@ declare module '@deepseek-ai/cordis' {
|
|
|
170
193
|
}
|
|
171
194
|
}
|
|
172
195
|
/**
|
|
173
|
-
* Build the projection listener for one assembly: keep only
|
|
196
|
+
* Build the projection listener for one assembly: keep only Resident tools plus
|
|
174
197
|
* the mandatory meta tools.
|
|
175
198
|
*/
|
|
176
199
|
export declare function projectAssemblyTools(assembly: PromptAssembly, service: CapabilityPolicyService): PromptAssembly;
|
|
177
200
|
/** Build the policy plugin. */
|
|
178
201
|
export declare const name = "capability-menu-policy";
|
|
179
202
|
export declare const inject: string[];
|
|
180
|
-
export declare function apply(ctx: Context, config?: Config): void
|
|
203
|
+
export declare function apply(ctx: Context, config?: Config): Promise<void>;
|
|
181
204
|
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAA;AAEnE;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAA;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAA;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,QAAQ,C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