@khorsheed/dsh-capability-catalog 0.1.95
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +286 -0
- package/README.zh.md +138 -0
- package/cordis.patch.yml +8 -0
- package/lib/client.js +10100 -0
- package/lib/index.js +4022 -0
- package/lib/invariant.js +25 -0
- package/lib/mcpConnector-C2TbkPBY.js +69 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1417 -0
- package/lib/typert.remote-client.d.ts +68 -0
- package/lib/typert.remote-client.js +1136 -0
- package/lib/types/capabilities.d.ts +103 -0
- package/lib/types/capabilities.js +116 -0
- package/lib/types/channels.d.ts +41 -0
- package/lib/types/channels.js +75 -0
- package/lib/types/client/AddMcpDialog.d.ts +13 -0
- package/lib/types/client/AddMcpDialog.js +79 -0
- package/lib/types/client/AddSkillModal.d.ts +17 -0
- package/lib/types/client/AddSkillModal.js +138 -0
- package/lib/types/client/BundleFileTree.d.ts +7 -0
- package/lib/types/client/BundleFileTree.js +74 -0
- package/lib/types/client/CapabilityCatalogCard.d.ts +57 -0
- package/lib/types/client/CapabilityCatalogCard.js +479 -0
- package/lib/types/client/CredentialField.d.ts +14 -0
- package/lib/types/client/CredentialField.js +9 -0
- package/lib/types/client/McpCards.d.ts +13 -0
- package/lib/types/client/McpCards.js +12 -0
- package/lib/types/client/McpServerManageModal.d.ts +18 -0
- package/lib/types/client/McpServerManageModal.js +63 -0
- package/lib/types/client/MetadataRow.d.ts +10 -0
- package/lib/types/client/MetadataRow.js +6 -0
- package/lib/types/client/ModalShell.d.ts +16 -0
- package/lib/types/client/ModalShell.js +27 -0
- package/lib/types/client/ModeChips.d.ts +38 -0
- package/lib/types/client/ModeChips.js +42 -0
- package/lib/types/client/SchemaView.d.ts +11 -0
- package/lib/types/client/SchemaView.js +143 -0
- package/lib/types/client/SkillCards.d.ts +28 -0
- package/lib/types/client/SkillCards.js +43 -0
- package/lib/types/client/SkillDetailModal.d.ts +69 -0
- package/lib/types/client/SkillDetailModal.js +167 -0
- package/lib/types/client/ToolCards.d.ts +28 -0
- package/lib/types/client/ToolCards.js +52 -0
- package/lib/types/client/ToolDetailModal.d.ts +12 -0
- package/lib/types/client/ToolDetailModal.js +29 -0
- package/lib/types/client/icons.d.ts +26 -0
- package/lib/types/client/icons.js +10 -0
- package/lib/types/client/index.d.ts +21 -0
- package/lib/types/client/index.js +196 -0
- package/lib/types/client/locales.d.ts +392 -0
- package/lib/types/client/locales.js +395 -0
- package/lib/types/client/mcp-model.d.ts +24 -0
- package/lib/types/client/mcp-model.js +87 -0
- package/lib/types/client/mode-model.d.ts +108 -0
- package/lib/types/client/mode-model.js +140 -0
- package/lib/types/client/preset-display.d.ts +21 -0
- package/lib/types/client/preset-display.js +20 -0
- package/lib/types/client/settle.d.ts +40 -0
- package/lib/types/client/settle.js +57 -0
- package/lib/types/client/slots.d.ts +86 -0
- package/lib/types/client/slots.js +1 -0
- package/lib/types/envHint.d.ts +22 -0
- package/lib/types/envHint.js +76 -0
- package/lib/types/import.d.ts +106 -0
- package/lib/types/import.js +635 -0
- package/lib/types/index.d.ts +216 -0
- package/lib/types/index.js +739 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/invariant.js +23 -0
- package/lib/types/mcpConnector.d.ts +24 -0
- package/lib/types/mcpConnector.js +73 -0
- package/lib/types/mcpStore.d.ts +68 -0
- package/lib/types/mcpStore.js +235 -0
- package/lib/types/mcpTools.d.ts +45 -0
- package/lib/types/mcpTools.js +125 -0
- package/lib/types/mcps.d.ts +64 -0
- package/lib/types/mcps.js +157 -0
- package/lib/types/modes.d.ts +65 -0
- package/lib/types/modes.js +97 -0
- package/lib/types/namespace.d.ts +9 -0
- package/lib/types/namespace.js +8 -0
- package/lib/types/official-tools.d.ts +3 -0
- package/lib/types/official-tools.js +44 -0
- package/lib/types/preset-scope.d.ts +105 -0
- package/lib/types/preset-scope.js +117 -0
- package/lib/types/remote.d.ts +48 -0
- package/lib/types/remote.js +120 -0
- package/lib/types/scoped-delivery.d.ts +243 -0
- package/lib/types/scoped-delivery.js +686 -0
- package/lib/types/scoped-edits.d.ts +90 -0
- package/lib/types/scoped-edits.js +234 -0
- package/lib/types/settings.d.ts +28 -0
- package/lib/types/settings.js +28 -0
- package/lib/types/shellEnv.d.ts +65 -0
- package/lib/types/shellEnv.js +232 -0
- package/lib/types/skills.d.ts +103 -0
- package/lib/types/skills.js +303 -0
- package/lib/types/tool-origin.d.ts +29 -0
- package/lib/types/tool-origin.js +30 -0
- package/lib/types/types.d.ts +315 -0
- package/lib/types/types.js +8 -0
- package/lib/types/zip.d.ts +24 -0
- package/lib/types/zip.js +80 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +119 -0
- package/scripts/gen-official-tools.mts +52 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability catalog host service: a Typert Remote over the running skill and
|
|
3
|
+
* tool registries. It projects `ctx.skills.snapshot()` into catalog rows,
|
|
4
|
+
* attributes `ctx.tools.schemas()` to a channel (mcp prefix / official
|
|
5
|
+
* whitelist / baseline-diff), loads per-skill detail on demand, writes
|
|
6
|
+
* declared credentials, and adds skills into the managed root. The browser
|
|
7
|
+
* half binds through the generated `capabilityCatalog` Remote namespace.
|
|
8
|
+
*
|
|
9
|
+
* Zero host edits: everything rides existing official services (`ctx.skills`,
|
|
10
|
+
* `ctx.tools`, `ctx.credentials`) through `ctx.get`, degrading silently when a
|
|
11
|
+
* capability is absent.
|
|
12
|
+
* @module @khorsheed/dsh-capability-catalog
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
16
|
+
import type { CapabilityCatalogSnapshot, CatalogAddSkillRequest, CatalogAddSkillResult, CatalogCredentialSetRequest, CatalogDeleteSkillResult, CatalogMcpServerConfig, CatalogMcpSnapshot, CatalogMcpTool, CatalogModeFace, CatalogSkillDetail, CatalogSkillFileRead, CatalogDirSkillInfo, CatalogPresetScopeStatus, CatalogPresetOption, CatalogPresetScopeSetRequest, CatalogPresetScopeAdoptRequest, CatalogPresetScopeEditResult } from './types.ts';
|
|
17
|
+
export { TOOL_ORIGIN, setToolOrigin, toolOrigin } from './tool-origin.ts';
|
|
18
|
+
export type { ToolOrigin } from './tool-origin.ts';
|
|
19
|
+
export type { CapabilityCatalogSnapshot, CatalogJsonValue, CatalogSkillRow, CatalogToolRow, CatalogMcpServerRow, CatalogChannelSummary, CatalogSkillDetail, CatalogSkillFileRead, CatalogCredentialState, CatalogAddSkillRequest, CatalogAddSkillResult, CatalogDeleteSkillResult, CatalogCredentialSetRequest, CatalogPresetScopeStatus, CatalogScopedSkillRow, CatalogScopedPresetRow, CatalogPresetOption, CatalogModeFace, CatalogPresetScopeSetRequest, CatalogPresetScopeAdoptRequest, CatalogPresetScopeEditResult, } from './types.ts';
|
|
20
|
+
export { resolveSkillNameFromContent } from './import.ts';
|
|
21
|
+
export { resolvePresetScope } from './preset-scope.ts';
|
|
22
|
+
export type { PresetRosterSlice, PresetRosterRow, ResolvedPresetScope } from './preset-scope.ts';
|
|
23
|
+
export { modeOptions, readModeFaces } from './modes.ts';
|
|
24
|
+
export { ScopedSkillDelivery, scopedSkillsRoot, scanManagedSkills, managedSkillFrom, parsePresetScopeFrontmatter, defaultSkillRoots, detectConflicts, SCOPED_PROVIDER_NAME, MANAGED_SKILL_RANK, } from './scoped-delivery.ts';
|
|
25
|
+
export { adoptManagedSkill, releaseManagedSkill, setManagedPresetScope, withPresetScope, findSkillSource, managedLocation, isDirectory, } from './scoped-edits.ts';
|
|
26
|
+
export type { ScopedEditResult, SkillSource, ManagedSkillLocation } from './scoped-edits.ts';
|
|
27
|
+
export type { ManagedSkill, ScopedDeliveryDeps, ScopedDeliveryRegistry, ScopedDeliveryStatus, ScopedPresetStatus, ScopedSkillStatus, } from './scoped-delivery.ts';
|
|
28
|
+
export { canonicalCapabilities, canonicalJson, capsTag, hashOf, hashSkillBody, CAPS_TAG_PREFIX, } from './capabilities.ts';
|
|
29
|
+
export type { CanonicalCapabilities, CanonicalMcpServer, CanonicalSkill, CanonicalTool, } from './capabilities.ts';
|
|
30
|
+
declare module '@deepseek-ai/cordis' {
|
|
31
|
+
interface Context {
|
|
32
|
+
capabilityCatalog: CapabilityCatalogService;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The remote namespace name (matches the generated remote-client type). */
|
|
36
|
+
export declare const REMOTE_NS = "capabilityCatalog";
|
|
37
|
+
/**
|
|
38
|
+
* Capability catalog Remote service.
|
|
39
|
+
* @module @khorsheed/dsh-capability-catalog
|
|
40
|
+
*/
|
|
41
|
+
export declare class CapabilityCatalogService extends TypertRemoteService {
|
|
42
|
+
config: {
|
|
43
|
+
mcp?: unknown;
|
|
44
|
+
};
|
|
45
|
+
static inject: never[];
|
|
46
|
+
static Config: import("@deepseek-ai/schemastery").default<Schemastery.ObjectS<{
|
|
47
|
+
mcp: import("@deepseek-ai/schemastery").default<any, any>;
|
|
48
|
+
}>, Schemastery.ObjectT<{
|
|
49
|
+
mcp: import("@deepseek-ai/schemastery").default<any, any>;
|
|
50
|
+
}>>;
|
|
51
|
+
private baseline;
|
|
52
|
+
private readonly appearedAfterApply;
|
|
53
|
+
private readonly mcp;
|
|
54
|
+
/** The live `ctx.tools` (traceable proxy) captured from the tools inject. */
|
|
55
|
+
private mcpToolsRegistry;
|
|
56
|
+
/** Registered MCP tool disposers, keyed by model-facing public name. */
|
|
57
|
+
private readonly mcpToolDisposers;
|
|
58
|
+
/** Preset-scoped delivery of the plugin's own managed skill root. */
|
|
59
|
+
private scoped;
|
|
60
|
+
/** The workspace the catalog was last asked about, for project-root conflict checks. */
|
|
61
|
+
private observedWorkdir;
|
|
62
|
+
constructor(ctx: Context, config: {
|
|
63
|
+
mcp?: unknown;
|
|
64
|
+
});
|
|
65
|
+
/** The preset-scoped delivery's current state, for the settings surface. */
|
|
66
|
+
presetScopeStatus(): Promise<CatalogPresetScopeStatus>;
|
|
67
|
+
/** Every preset the roster supplies, for the scope picker. */
|
|
68
|
+
presetScopeRoster(): Promise<readonly CatalogPresetOption[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Every mode's capability face in ONE call, for the cross-mode comparison
|
|
71
|
+
* view ("which modes load this tool/skill?").
|
|
72
|
+
*
|
|
73
|
+
* This is the expensive verb of the pair: a mode whose standing scope has not
|
|
74
|
+
* been composed yet is MOUNTED by its read (see modes.ts — there is no cheap
|
|
75
|
+
* honest source, because a composition file names plugins, not the tools and
|
|
76
|
+
* skills those plugins register). The browser therefore calls it only when a
|
|
77
|
+
* human chooses to compare modes, never on opening the section.
|
|
78
|
+
*
|
|
79
|
+
* A mode that cannot be read keeps its row with `unavailable` set rather than
|
|
80
|
+
* an empty face, so the comparison never claims that a broken mode loads
|
|
81
|
+
* nothing. `preset` on a face is always the id that was asked for: a read
|
|
82
|
+
* that silently degraded to the global layer is reported as unavailable, not
|
|
83
|
+
* as that mode's face.
|
|
84
|
+
* @param workdir - optional cwd for project-scoped skill roots.
|
|
85
|
+
*/
|
|
86
|
+
modeFaces(workdir?: string): Promise<readonly CatalogModeFace[]>;
|
|
87
|
+
/** The roster rows, or [] when this composition mounts no agent-preset service. */
|
|
88
|
+
private rosterRows;
|
|
89
|
+
/** Declare which presets one managed skill is delivered to. */
|
|
90
|
+
presetScopeSet(request: CatalogPresetScopeSetRequest): Promise<CatalogPresetScopeEditResult>;
|
|
91
|
+
/** Move an installed skill into the managed root with a preset scope. */
|
|
92
|
+
presetScopeAdopt(request: CatalogPresetScopeAdoptRequest): Promise<CatalogPresetScopeEditResult>;
|
|
93
|
+
/** Move a managed skill back to the user skill root (the recovery direction). */
|
|
94
|
+
presetScopeRelease(name: string): Promise<CatalogPresetScopeEditResult>;
|
|
95
|
+
/** Re-deliver after a write; a delivery that is absent is not an error. */
|
|
96
|
+
private reconcileScoped;
|
|
97
|
+
/** Record tools that appeared after the apply-time baseline (reads the live
|
|
98
|
+
* registry each time, so a change event never sees a stale/undefined ref). */
|
|
99
|
+
private markNewTools;
|
|
100
|
+
/** The managed skills root under `$DSH_HOME`. */
|
|
101
|
+
private dshHome;
|
|
102
|
+
/**
|
|
103
|
+
* The standing skill view scope of ONE preset. In the web bundle the
|
|
104
|
+
* host-global skill-filesystem provider is mounted under each agent
|
|
105
|
+
* preset's standing scope, so a host-global snapshot sees only runtime
|
|
106
|
+
* skills; reading at the preset's scope surfaces the official/plugin/user
|
|
107
|
+
* skills the model actually sees. When the presets service is absent the
|
|
108
|
+
* catalog degrades to the global layer alone.
|
|
109
|
+
*
|
|
110
|
+
* `presetId` names WHICH preset — the deployment default when omitted, the
|
|
111
|
+
* way every reader before `snapshotFor` behaved. The roster's scope face
|
|
112
|
+
* (0.1.5's `standingKeyFor`, rc.1's leased `acquireScope`) has always taken
|
|
113
|
+
* an id; the catalog simply never passed one, so "the capability face of
|
|
114
|
+
* preset X" was unaskable and a condition declaring `preset: X` could only
|
|
115
|
+
* be believed.
|
|
116
|
+
*
|
|
117
|
+
* `strict` is the listing/fingerprint split — see
|
|
118
|
+
* {@link resolvePresetScope}, which owns the policy.
|
|
119
|
+
* @param presetId - the preset to read, or undefined for the default.
|
|
120
|
+
* @param strict - throw instead of degrading when the roster cannot answer.
|
|
121
|
+
*/
|
|
122
|
+
private catalogScope;
|
|
123
|
+
/** Release a scope lease, logging rather than failing the read it followed. */
|
|
124
|
+
private releaseScope;
|
|
125
|
+
/** The optional agent-preset roster (absent in a rosterless composition). */
|
|
126
|
+
private agentPresets;
|
|
127
|
+
/** Register the model-facing `list_capabilities` tool (optional; called from the
|
|
128
|
+
* tools inject so the registry is guaranteed present). */
|
|
129
|
+
private registerListTool;
|
|
130
|
+
snapshot(workdir?: string): Promise<CapabilityCatalogSnapshot>;
|
|
131
|
+
/**
|
|
132
|
+
* The capability face of ONE mode as a LISTING — {@link snapshot} scoped to a
|
|
133
|
+
* named preset, for the settings surface's mode picker.
|
|
134
|
+
*
|
|
135
|
+
* The LISTING/FINGERPRINT split matters here the way it does everywhere else:
|
|
136
|
+
* a viewer wants rows as fast as the registries can produce them, not every
|
|
137
|
+
* skill body loaded and digested. Asking for a preset's IDENTITY is
|
|
138
|
+
* {@link snapshotFor}. Like every scope resolution, this MOUNTS a preset
|
|
139
|
+
* nothing has composed yet.
|
|
140
|
+
*
|
|
141
|
+
* Degrades like {@link snapshot}: a preset whose standing scope refuses
|
|
142
|
+
* answers with the global layer and NO `preset` stamp, which is how a caller
|
|
143
|
+
* tells "this mode" from "the fallback" and says so.
|
|
144
|
+
* @param presetId - the mode to read, or undefined for the deployment default.
|
|
145
|
+
* @param workdir - optional cwd for project-scoped skill roots.
|
|
146
|
+
*/
|
|
147
|
+
snapshotAt(presetId?: string, workdir?: string): Promise<CapabilityCatalogSnapshot>;
|
|
148
|
+
/**
|
|
149
|
+
* The capability face of ONE preset, with its {@link hashOf} digest.
|
|
150
|
+
*
|
|
151
|
+
* This is the fingerprint verb: every skill body is loaded (so the rows
|
|
152
|
+
* carry `bodySha`) and `sha` is stamped, which is what makes the answer an
|
|
153
|
+
* identity rather than a listing. `presetId` omitted reads the deployment
|
|
154
|
+
* default — the same face `snapshot` reads, now hashable.
|
|
155
|
+
*
|
|
156
|
+
* Degrades like every other verb: without a skills registry the answer is
|
|
157
|
+
* an empty face with the hash of an empty face, not a throw. Note that a
|
|
158
|
+
* preset nobody has composed yet is MOUNTED by the read (the roster's
|
|
159
|
+
* single-flight standing mount), so asking is not free.
|
|
160
|
+
* @param presetId - the preset to fingerprint, or undefined for the default.
|
|
161
|
+
* @param workdir - optional cwd for project-scoped skill roots.
|
|
162
|
+
*/
|
|
163
|
+
snapshotFor(presetId?: string, workdir?: string): Promise<CapabilityCatalogSnapshot>;
|
|
164
|
+
/**
|
|
165
|
+
* Shared body of {@link snapshot} and {@link snapshotFor}. The scope is
|
|
166
|
+
* resolved ONCE — three resolutions of a mounting preset would race the
|
|
167
|
+
* roster's single-flight for no reason — and `fingerprint` makes the
|
|
168
|
+
* resolution strict.
|
|
169
|
+
*/
|
|
170
|
+
private collect;
|
|
171
|
+
detail(name: string, workdir?: string, presetId?: string): Promise<CatalogSkillDetail | undefined>;
|
|
172
|
+
readSkillFile(name: string, filePath: string, workdir?: string, presetId?: string): Promise<CatalogSkillFileRead | undefined>;
|
|
173
|
+
/** One managed skill's definition, for management reads outside its scope. */
|
|
174
|
+
private managedDefinition;
|
|
175
|
+
listDirSkills(dirPath: string): Promise<readonly CatalogDirSkillInfo[]>;
|
|
176
|
+
setCredential(request: CatalogCredentialSetRequest): Promise<boolean>;
|
|
177
|
+
addSkill(request: CatalogAddSkillRequest): Promise<CatalogAddSkillResult>;
|
|
178
|
+
deleteSkill(name: string, workdir?: string, presetId?: string): Promise<CatalogDeleteSkillResult>;
|
|
179
|
+
pickDirectory(): Promise<string | null>;
|
|
180
|
+
mcpList(): Promise<readonly CatalogMcpServerConfig[]>;
|
|
181
|
+
mcpAdd(config: CatalogMcpServerConfig): Promise<boolean>;
|
|
182
|
+
mcpRemove(serverName: string): Promise<boolean>;
|
|
183
|
+
mcpSetEnabled(serverName: string, enabled: boolean): Promise<void>;
|
|
184
|
+
mcpSetCredential(ref: string, value: string): Promise<boolean>;
|
|
185
|
+
mcpSetToolEnabled(serverName: string, tool: string, enabled: boolean): Promise<void>;
|
|
186
|
+
mcpDiscover(serverName: string): Promise<readonly CatalogMcpTool[]>;
|
|
187
|
+
mcpSnapshot(): Promise<CatalogMcpSnapshot>;
|
|
188
|
+
/** The visible tool schemas in the standing scope (the set the model sees),
|
|
189
|
+
* or the global layer when no preset standing key resolves. Skills already
|
|
190
|
+
* enumerate through the same scope; tools must use it too so the
|
|
191
|
+
* settings reader sees the official/plugin/MCP tools the model actually has. */
|
|
192
|
+
private toolSchemasIn;
|
|
193
|
+
/** tool name → author-declared origin, read via `ctx.tools.get(name)` so the
|
|
194
|
+
* `Symbol.for('dsh.tool.origin')` tag on the retained definition survives (the
|
|
195
|
+
* system-prompt assembly strips it, but `get()` returns the full definition). */
|
|
196
|
+
private toolOriginsMap;
|
|
197
|
+
/** MCP server names from live `mcp__`-prefixed tools (prefix-derived baseline). */
|
|
198
|
+
private mcpServerNamesIn;
|
|
199
|
+
/**
|
|
200
|
+
* Reconcile which discovered MCP tools are registered on `ctx.tools` so the
|
|
201
|
+
* model can call them. `mcpToolsRegistry` is the traceable `ctx.tools` proxy,
|
|
202
|
+
* so `register` is always invoked as a MEMBER call (`reconcile` calls
|
|
203
|
+
* `registry.register(...)`) — extracting it to a standalone variable loses the
|
|
204
|
+
* `this.ctx` binding and breaks the disposal effect.
|
|
205
|
+
*/
|
|
206
|
+
private syncRegisteredMcpTools;
|
|
207
|
+
/** Re-sync registered MCP tools after any MCP store mutation. */
|
|
208
|
+
private afterMcpMutation;
|
|
209
|
+
/** Refill the persisted MCP tools' descriptions/parameters by re-connecting the
|
|
210
|
+
* enabled servers at boot (the persisted `mcp` block stores only name+enabled to
|
|
211
|
+
* keep settings.yaml small). Async: boot is not blocked; each server's errors are
|
|
212
|
+
* contained, and registration is re-synced once the descriptions are back. */
|
|
213
|
+
private reconnectEnabledMcp;
|
|
214
|
+
}
|
|
215
|
+
export default CapabilityCatalogService;
|
|
216
|
+
//# sourceMappingURL=index.d.ts.map
|