@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
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@khorsheed/dsh-capability-catalog`.
|
|
4
|
+
* @module @khorsheed/dsh-capability-catalog/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@khorsheed/dsh-capability-catalog";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "capability-catalog-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: the catalog is read-only over existing registries
|
|
13
|
+
* (ctx.skills / ctx.tools) and the add-skill write path validates its inputs
|
|
14
|
+
* before touching disk. The unit tests exercise the channel attribution,
|
|
15
|
+
* skill decoding, and the wire projection.
|
|
16
|
+
*/
|
|
17
|
+
const install = () => {};
|
|
18
|
+
/**
|
|
19
|
+
* Register this package's invariant companion.
|
|
20
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
21
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
22
|
+
*/
|
|
23
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
24
|
+
//#endregion
|
|
25
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
|
+
//#region lib/types/mcpConnector.js
|
|
5
|
+
/**
|
|
6
|
+
* MCP connector backed by the official `@modelcontextprotocol/sdk` (the same
|
|
7
|
+
* library `@deepseek-ai/dsh-mcp-client` uses). Kept as a thin, swappable seam:
|
|
8
|
+
* the catalog owns the connection lifecycle (connect → list → register tools →
|
|
9
|
+
* call → close) and registers discovered tools on `ctx.tools`. If upstream later
|
|
10
|
+
* exposes a stable dynamic `connect(ctx, config)`, swap this adapter for it.
|
|
11
|
+
*
|
|
12
|
+
* v1 scope: stdio + streamable-http connect, paginated `tools/list`,
|
|
13
|
+
* `tools/call` passthrough, and close. Reconnect/atomic-replace/tool-filter are
|
|
14
|
+
* follow-ups.
|
|
15
|
+
* @module @khorsheed/dsh-capability-catalog/mcpConnector
|
|
16
|
+
*/
|
|
17
|
+
/** Build the transport for a config (secrets already resolved to plaintext). */
|
|
18
|
+
function makeTransport(config) {
|
|
19
|
+
if (config.transport === "stdio") {
|
|
20
|
+
const env = {};
|
|
21
|
+
for (const [k, v] of config.env ?? []) env[k] = v;
|
|
22
|
+
return new StdioClientTransport({
|
|
23
|
+
command: config.command ?? "npx",
|
|
24
|
+
args: [...config.args ?? []],
|
|
25
|
+
...Object.keys(env).length > 0 ? { env } : {},
|
|
26
|
+
...config.cwd ? { cwd: config.cwd } : {}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const headers = config.headers ?? [];
|
|
30
|
+
if (headers.length > 0) return new StreamableHTTPClientTransport(new URL(config.url ?? ""), { requestInit: { headers: Object.fromEntries(headers) } });
|
|
31
|
+
return new StreamableHTTPClientTransport(new URL(config.url ?? ""));
|
|
32
|
+
}
|
|
33
|
+
/** Map an SDK tool to the catalog's tool row (enabled by default). */
|
|
34
|
+
function toCatalogTool(sdkTool) {
|
|
35
|
+
return {
|
|
36
|
+
name: sdkTool.name,
|
|
37
|
+
description: sdkTool.description ?? "",
|
|
38
|
+
...sdkTool.inputSchema !== void 0 ? { parameters: sdkTool.inputSchema } : {},
|
|
39
|
+
enabled: true
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Connect, discover all tools (follow pagination), and return a live handle. */
|
|
43
|
+
async function connectMcpServer(config) {
|
|
44
|
+
const client = new Client({
|
|
45
|
+
name: "dsh-capability-catalog",
|
|
46
|
+
version: "0.1.0"
|
|
47
|
+
});
|
|
48
|
+
const transport = makeTransport(config);
|
|
49
|
+
await client.connect(transport);
|
|
50
|
+
const tools = [];
|
|
51
|
+
let cursor;
|
|
52
|
+
do {
|
|
53
|
+
const page = await client.listTools(cursor === void 0 ? void 0 : { cursor });
|
|
54
|
+
for (const t of page.tools) tools.push(toCatalogTool(t));
|
|
55
|
+
cursor = page.nextCursor;
|
|
56
|
+
} while (cursor !== void 0);
|
|
57
|
+
return {
|
|
58
|
+
tools,
|
|
59
|
+
call: async (toolName, args) => client.callTool({
|
|
60
|
+
name: toolName,
|
|
61
|
+
arguments: args
|
|
62
|
+
}),
|
|
63
|
+
close: async () => {
|
|
64
|
+
await client.close().catch(() => {});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { connectMcpServer };
|