@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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +286 -0
  4. package/README.zh.md +138 -0
  5. package/cordis.patch.yml +8 -0
  6. package/lib/client.js +10100 -0
  7. package/lib/index.js +4022 -0
  8. package/lib/invariant.js +25 -0
  9. package/lib/mcpConnector-C2TbkPBY.js +69 -0
  10. package/lib/typert.host.d.ts +3 -0
  11. package/lib/typert.host.js +1417 -0
  12. package/lib/typert.remote-client.d.ts +68 -0
  13. package/lib/typert.remote-client.js +1136 -0
  14. package/lib/types/capabilities.d.ts +103 -0
  15. package/lib/types/capabilities.js +116 -0
  16. package/lib/types/channels.d.ts +41 -0
  17. package/lib/types/channels.js +75 -0
  18. package/lib/types/client/AddMcpDialog.d.ts +13 -0
  19. package/lib/types/client/AddMcpDialog.js +79 -0
  20. package/lib/types/client/AddSkillModal.d.ts +17 -0
  21. package/lib/types/client/AddSkillModal.js +138 -0
  22. package/lib/types/client/BundleFileTree.d.ts +7 -0
  23. package/lib/types/client/BundleFileTree.js +74 -0
  24. package/lib/types/client/CapabilityCatalogCard.d.ts +57 -0
  25. package/lib/types/client/CapabilityCatalogCard.js +479 -0
  26. package/lib/types/client/CredentialField.d.ts +14 -0
  27. package/lib/types/client/CredentialField.js +9 -0
  28. package/lib/types/client/McpCards.d.ts +13 -0
  29. package/lib/types/client/McpCards.js +12 -0
  30. package/lib/types/client/McpServerManageModal.d.ts +18 -0
  31. package/lib/types/client/McpServerManageModal.js +63 -0
  32. package/lib/types/client/MetadataRow.d.ts +10 -0
  33. package/lib/types/client/MetadataRow.js +6 -0
  34. package/lib/types/client/ModalShell.d.ts +16 -0
  35. package/lib/types/client/ModalShell.js +27 -0
  36. package/lib/types/client/ModeChips.d.ts +38 -0
  37. package/lib/types/client/ModeChips.js +42 -0
  38. package/lib/types/client/SchemaView.d.ts +11 -0
  39. package/lib/types/client/SchemaView.js +143 -0
  40. package/lib/types/client/SkillCards.d.ts +28 -0
  41. package/lib/types/client/SkillCards.js +43 -0
  42. package/lib/types/client/SkillDetailModal.d.ts +69 -0
  43. package/lib/types/client/SkillDetailModal.js +167 -0
  44. package/lib/types/client/ToolCards.d.ts +28 -0
  45. package/lib/types/client/ToolCards.js +52 -0
  46. package/lib/types/client/ToolDetailModal.d.ts +12 -0
  47. package/lib/types/client/ToolDetailModal.js +29 -0
  48. package/lib/types/client/icons.d.ts +26 -0
  49. package/lib/types/client/icons.js +10 -0
  50. package/lib/types/client/index.d.ts +21 -0
  51. package/lib/types/client/index.js +196 -0
  52. package/lib/types/client/locales.d.ts +392 -0
  53. package/lib/types/client/locales.js +395 -0
  54. package/lib/types/client/mcp-model.d.ts +24 -0
  55. package/lib/types/client/mcp-model.js +87 -0
  56. package/lib/types/client/mode-model.d.ts +108 -0
  57. package/lib/types/client/mode-model.js +140 -0
  58. package/lib/types/client/preset-display.d.ts +21 -0
  59. package/lib/types/client/preset-display.js +20 -0
  60. package/lib/types/client/settle.d.ts +40 -0
  61. package/lib/types/client/settle.js +57 -0
  62. package/lib/types/client/slots.d.ts +86 -0
  63. package/lib/types/client/slots.js +1 -0
  64. package/lib/types/envHint.d.ts +22 -0
  65. package/lib/types/envHint.js +76 -0
  66. package/lib/types/import.d.ts +106 -0
  67. package/lib/types/import.js +635 -0
  68. package/lib/types/index.d.ts +216 -0
  69. package/lib/types/index.js +739 -0
  70. package/lib/types/invariant.d.ts +16 -0
  71. package/lib/types/invariant.js +23 -0
  72. package/lib/types/mcpConnector.d.ts +24 -0
  73. package/lib/types/mcpConnector.js +73 -0
  74. package/lib/types/mcpStore.d.ts +68 -0
  75. package/lib/types/mcpStore.js +235 -0
  76. package/lib/types/mcpTools.d.ts +45 -0
  77. package/lib/types/mcpTools.js +125 -0
  78. package/lib/types/mcps.d.ts +64 -0
  79. package/lib/types/mcps.js +157 -0
  80. package/lib/types/modes.d.ts +65 -0
  81. package/lib/types/modes.js +97 -0
  82. package/lib/types/namespace.d.ts +9 -0
  83. package/lib/types/namespace.js +8 -0
  84. package/lib/types/official-tools.d.ts +3 -0
  85. package/lib/types/official-tools.js +44 -0
  86. package/lib/types/preset-scope.d.ts +105 -0
  87. package/lib/types/preset-scope.js +117 -0
  88. package/lib/types/remote.d.ts +48 -0
  89. package/lib/types/remote.js +120 -0
  90. package/lib/types/scoped-delivery.d.ts +243 -0
  91. package/lib/types/scoped-delivery.js +686 -0
  92. package/lib/types/scoped-edits.d.ts +90 -0
  93. package/lib/types/scoped-edits.js +234 -0
  94. package/lib/types/settings.d.ts +28 -0
  95. package/lib/types/settings.js +28 -0
  96. package/lib/types/shellEnv.d.ts +65 -0
  97. package/lib/types/shellEnv.js +232 -0
  98. package/lib/types/skills.d.ts +103 -0
  99. package/lib/types/skills.js +303 -0
  100. package/lib/types/tool-origin.d.ts +29 -0
  101. package/lib/types/tool-origin.js +30 -0
  102. package/lib/types/types.d.ts +315 -0
  103. package/lib/types/types.js +8 -0
  104. package/lib/types/zip.d.ts +24 -0
  105. package/lib/types/zip.js +80 -0
  106. package/locale/en.json +6 -0
  107. package/locale/zh.json +6 -0
  108. package/package.json +119 -0
  109. package/scripts/gen-official-tools.mts +52 -0
@@ -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 };
@@ -0,0 +1,3 @@
1
+ /* Generated by @deepseek-ai/dsh-typert-generator from FaceModel — do not edit. */
2
+
3
+ export declare const TYPERT: unknown