chainlesschain 0.47.8 → 0.49.0

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 (86) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +10 -8
  3. package/src/assets/web-panel/.build-hash +1 -1
  4. package/src/assets/web-panel/assets/{AppLayout-6SPt_8Y_.js → AppLayout-Rvi759IS.js} +1 -1
  5. package/src/assets/web-panel/assets/Dashboard-BS-tzGNj.css +1 -0
  6. package/src/assets/web-panel/assets/{Dashboard-Br7kCwKJ.js → Dashboard-DBhFxXYQ.js} +2 -2
  7. package/src/assets/web-panel/assets/{index-tN-8TosE.js → index-uL0cZ8N_.js} +2 -2
  8. package/src/assets/web-panel/index.html +2 -2
  9. package/src/commands/activitypub.js +533 -0
  10. package/src/commands/codegen.js +303 -0
  11. package/src/commands/collab.js +482 -0
  12. package/src/commands/compliance.js +597 -6
  13. package/src/commands/crosschain.js +382 -0
  14. package/src/commands/dbevo.js +388 -0
  15. package/src/commands/dev.js +411 -0
  16. package/src/commands/federation.js +427 -0
  17. package/src/commands/fusion.js +332 -0
  18. package/src/commands/governance.js +505 -0
  19. package/src/commands/hardening.js +110 -0
  20. package/src/commands/incentive.js +373 -0
  21. package/src/commands/inference.js +304 -0
  22. package/src/commands/infra.js +361 -0
  23. package/src/commands/kg.js +371 -0
  24. package/src/commands/marketplace.js +326 -0
  25. package/src/commands/matrix.js +283 -0
  26. package/src/commands/mcp.js +441 -18
  27. package/src/commands/nlprog.js +329 -0
  28. package/src/commands/nostr.js +196 -7
  29. package/src/commands/ops.js +408 -0
  30. package/src/commands/perception.js +385 -0
  31. package/src/commands/pqc.js +34 -0
  32. package/src/commands/privacy.js +345 -0
  33. package/src/commands/quantization.js +280 -0
  34. package/src/commands/recommend.js +336 -0
  35. package/src/commands/reputation.js +349 -0
  36. package/src/commands/runtime.js +500 -0
  37. package/src/commands/sla.js +352 -0
  38. package/src/commands/social.js +265 -0
  39. package/src/commands/stress.js +252 -0
  40. package/src/commands/tech.js +268 -0
  41. package/src/commands/tenant.js +576 -0
  42. package/src/commands/trust.js +366 -0
  43. package/src/harness/mcp-client.js +330 -54
  44. package/src/index.js +114 -0
  45. package/src/lib/activitypub-bridge.js +623 -0
  46. package/src/lib/aiops.js +523 -0
  47. package/src/lib/autonomous-developer.js +524 -0
  48. package/src/lib/code-agent.js +442 -0
  49. package/src/lib/collaboration-governance.js +556 -0
  50. package/src/lib/community-governance.js +649 -0
  51. package/src/lib/compliance-framework-reporter.js +600 -0
  52. package/src/lib/content-recommendation.js +600 -0
  53. package/src/lib/cross-chain.js +669 -0
  54. package/src/lib/dbevo.js +669 -0
  55. package/src/lib/decentral-infra.js +445 -0
  56. package/src/lib/federation-hardening.js +587 -0
  57. package/src/lib/hardening-manager.js +409 -0
  58. package/src/lib/inference-network.js +407 -0
  59. package/src/lib/knowledge-graph.js +530 -0
  60. package/src/lib/matrix-bridge.js +252 -0
  61. package/src/lib/mcp-client.js +3 -0
  62. package/src/lib/mcp-registry.js +347 -0
  63. package/src/lib/mcp-scaffold.js +385 -0
  64. package/src/lib/multimodal.js +698 -0
  65. package/src/lib/nl-programming.js +595 -0
  66. package/src/lib/nostr-bridge.js +214 -38
  67. package/src/lib/perception.js +500 -0
  68. package/src/lib/pqc-manager.js +141 -9
  69. package/src/lib/privacy-computing.js +575 -0
  70. package/src/lib/protocol-fusion.js +535 -0
  71. package/src/lib/quantization.js +362 -0
  72. package/src/lib/reputation-optimizer.js +509 -0
  73. package/src/lib/skill-marketplace.js +397 -0
  74. package/src/lib/sla-manager.js +484 -0
  75. package/src/lib/social-graph.js +408 -0
  76. package/src/lib/stix-parser.js +167 -0
  77. package/src/lib/stress-tester.js +383 -0
  78. package/src/lib/tech-learning-engine.js +651 -0
  79. package/src/lib/tenant-saas.js +831 -0
  80. package/src/lib/threat-intel.js +268 -0
  81. package/src/lib/token-incentive.js +513 -0
  82. package/src/lib/topic-classifier.js +400 -0
  83. package/src/lib/trust-security.js +473 -0
  84. package/src/lib/ueba.js +403 -0
  85. package/src/lib/universal-runtime.js +771 -0
  86. package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +0 -1
@@ -0,0 +1,385 @@
1
+ /**
2
+ * MCP server scaffolder — pure template generator.
3
+ *
4
+ * Turns a `{name, description, transport, author}` spec into a list of
5
+ * `{path, content}` files that together form a runnable boilerplate
6
+ * project built on `@modelcontextprotocol/sdk`. Intentionally pure: the
7
+ * command layer decides where to write the files (and whether to
8
+ * overwrite), so tests can snapshot the output without hitting disk.
9
+ *
10
+ * Two transports are supported:
11
+ *
12
+ * - **stdio** — default, matches every MCP example under
13
+ * `@modelcontextprotocol/server-*`. Uses `StdioServerTransport`,
14
+ * run via `node index.js` and wired into a host's MCP config with
15
+ * `command: "node"`.
16
+ * - **http** — streamable HTTP + SSE. Uses `StreamableHTTPServerTransport`
17
+ * behind a tiny Express app so `cc mcp add <name> -u http://...`
18
+ * (or any MCP host) can connect.
19
+ *
20
+ * Every generated project includes:
21
+ *
22
+ * - package.json — `type: module`, `start` script, MCP SDK dep
23
+ * - index.js — 1 example tool (`echo`) + 1 example resource
24
+ * (`hello://world`) wired through the chosen transport
25
+ * - README.md — run + wire-up instructions tailored to transport
26
+ * - .gitignore — node_modules / logs / `.env`
27
+ *
28
+ * The scaffold stays intentionally tiny — "hello-world MCP server" —
29
+ * rather than trying to demo every SDK feature. Authors clone and extend.
30
+ */
31
+
32
+ /* ── constants ──────────────────────────────────────────────── */
33
+
34
+ export const SUPPORTED_TRANSPORTS = Object.freeze(["stdio", "http"]);
35
+
36
+ export const SDK_VERSION = "^1.0.0";
37
+ export const EXPRESS_VERSION = "^4.19.2";
38
+
39
+ const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
40
+
41
+ /* ── public API ─────────────────────────────────────────────── */
42
+
43
+ /**
44
+ * Generate the full file set for a new MCP server project.
45
+ *
46
+ * @param {object} spec
47
+ * @param {string} spec.name — npm-style kebab-case package name
48
+ * @param {string} [spec.description]
49
+ * @param {"stdio"|"http"} [spec.transport="stdio"]
50
+ * @param {string} [spec.author]
51
+ * @param {number} [spec.port=3333] — only used for http transport
52
+ * @returns {{ files: Array<{path:string, content:string}>, summary: object }}
53
+ */
54
+ export function generateMcpServerScaffold(spec = {}) {
55
+ const name = normalizeName(spec.name);
56
+ const description =
57
+ (typeof spec.description === "string" && spec.description.trim()) ||
58
+ `An MCP server — ${name}`;
59
+ const transport = normalizeTransport(spec.transport);
60
+ const author = typeof spec.author === "string" ? spec.author.trim() : "";
61
+ const port = Number.isInteger(spec.port) && spec.port > 0 ? spec.port : 3333;
62
+
63
+ const files = [
64
+ {
65
+ path: "package.json",
66
+ content: renderPackageJson({ name, description, transport, author }),
67
+ },
68
+ {
69
+ path: "index.js",
70
+ content: renderIndexJs({ name, description, transport, port }),
71
+ },
72
+ {
73
+ path: "README.md",
74
+ content: renderReadme({ name, description, transport, port }),
75
+ },
76
+ { path: ".gitignore", content: renderGitignore() },
77
+ ];
78
+
79
+ const summary = {
80
+ name,
81
+ description,
82
+ transport,
83
+ port: transport === "http" ? port : null,
84
+ fileCount: files.length,
85
+ };
86
+
87
+ return { files, summary };
88
+ }
89
+
90
+ /**
91
+ * Validate a proposed server name. Throws with a concrete reason —
92
+ * callers can surface the message verbatim.
93
+ */
94
+ export function normalizeName(raw) {
95
+ if (typeof raw !== "string" || !raw.trim()) {
96
+ throw new Error("Server name is required.");
97
+ }
98
+ const name = raw.trim().toLowerCase();
99
+ if (!NAME_PATTERN.test(name)) {
100
+ throw new Error(
101
+ `Invalid server name "${raw}". ` +
102
+ `Use lowercase letters, digits, or hyphens (e.g. "my-weather").`,
103
+ );
104
+ }
105
+ if (name.length > 60) {
106
+ throw new Error("Server name must be 60 characters or fewer.");
107
+ }
108
+ return name;
109
+ }
110
+
111
+ export function normalizeTransport(raw) {
112
+ const t =
113
+ (typeof raw === "string" ? raw.trim().toLowerCase() : "stdio") || "stdio";
114
+ if (!SUPPORTED_TRANSPORTS.includes(t)) {
115
+ throw new Error(
116
+ `Unknown transport "${raw}". Supported: ${SUPPORTED_TRANSPORTS.join(", ")}.`,
117
+ );
118
+ }
119
+ return t;
120
+ }
121
+
122
+ /* ── renderers ──────────────────────────────────────────────── */
123
+
124
+ function renderPackageJson({ name, description, transport, author }) {
125
+ const deps = {
126
+ "@modelcontextprotocol/sdk": SDK_VERSION,
127
+ };
128
+ if (transport === "http") deps.express = EXPRESS_VERSION;
129
+
130
+ const pkg = {
131
+ name,
132
+ version: "0.1.0",
133
+ description,
134
+ type: "module",
135
+ main: "index.js",
136
+ scripts: {
137
+ start: "node index.js",
138
+ },
139
+ dependencies: deps,
140
+ };
141
+ if (author) pkg.author = author;
142
+
143
+ return JSON.stringify(pkg, null, 2) + "\n";
144
+ }
145
+
146
+ function renderIndexJs({ name, description, transport, port }) {
147
+ if (transport === "stdio") return renderStdioIndex({ name, description });
148
+ return renderHttpIndex({ name, description, port });
149
+ }
150
+
151
+ function renderStdioIndex({ name, description }) {
152
+ return `#!/usr/bin/env node
153
+ /**
154
+ * ${name} — ${description}
155
+ *
156
+ * An MCP server over stdio. Registered by an MCP host via:
157
+ *
158
+ * { "command": "node", "args": ["./index.js"] }
159
+ *
160
+ * (Or via \`cc mcp add ${name} -c node -a "./index.js"\`.)
161
+ */
162
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
163
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
164
+ import {
165
+ CallToolRequestSchema,
166
+ ListResourcesRequestSchema,
167
+ ListToolsRequestSchema,
168
+ ReadResourceRequestSchema,
169
+ } from "@modelcontextprotocol/sdk/types.js";
170
+
171
+ const server = new Server(
172
+ { name: "${name}", version: "0.1.0" },
173
+ { capabilities: { tools: {}, resources: {} } },
174
+ );
175
+
176
+ // ── Example tool ─────────────────────────────────────────────
177
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
178
+ tools: [
179
+ {
180
+ name: "echo",
181
+ description: "Echo back the supplied message.",
182
+ inputSchema: {
183
+ type: "object",
184
+ required: ["message"],
185
+ properties: {
186
+ message: { type: "string", description: "Text to echo." },
187
+ },
188
+ },
189
+ },
190
+ ],
191
+ }));
192
+
193
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
194
+ const { name: tool, arguments: args } = req.params;
195
+ if (tool === "echo") {
196
+ return {
197
+ content: [{ type: "text", text: String(args?.message ?? "") }],
198
+ };
199
+ }
200
+ throw new Error(\`Unknown tool: \${tool}\`);
201
+ });
202
+
203
+ // ── Example resource ─────────────────────────────────────────
204
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
205
+ resources: [
206
+ {
207
+ uri: "hello://world",
208
+ name: "Hello world",
209
+ description: "A trivial resource you can read to test connectivity.",
210
+ mimeType: "text/plain",
211
+ },
212
+ ],
213
+ }));
214
+
215
+ server.setRequestHandler(ReadResourceRequestSchema, async (req) => {
216
+ if (req.params.uri === "hello://world") {
217
+ return {
218
+ contents: [
219
+ { uri: req.params.uri, mimeType: "text/plain", text: "Hello, MCP!" },
220
+ ],
221
+ };
222
+ }
223
+ throw new Error(\`Unknown resource: \${req.params.uri}\`);
224
+ });
225
+
226
+ // ── Start ────────────────────────────────────────────────────
227
+ const transport = new StdioServerTransport();
228
+ await server.connect(transport);
229
+ `;
230
+ }
231
+
232
+ function renderHttpIndex({ name, description, port }) {
233
+ return `#!/usr/bin/env node
234
+ /**
235
+ * ${name} — ${description}
236
+ *
237
+ * An MCP server over Streamable HTTP + SSE. Started with:
238
+ *
239
+ * npm start # listens on 0.0.0.0:${port}
240
+ * PORT=9001 npm start # override port
241
+ *
242
+ * Hosts connect by URL — with this CLI:
243
+ *
244
+ * cc mcp add ${name} -u http://localhost:${port}/mcp
245
+ */
246
+ import express from "express";
247
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
248
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
249
+ import {
250
+ CallToolRequestSchema,
251
+ ListResourcesRequestSchema,
252
+ ListToolsRequestSchema,
253
+ ReadResourceRequestSchema,
254
+ } from "@modelcontextprotocol/sdk/types.js";
255
+
256
+ function makeServer() {
257
+ const server = new Server(
258
+ { name: "${name}", version: "0.1.0" },
259
+ { capabilities: { tools: {}, resources: {} } },
260
+ );
261
+
262
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
263
+ tools: [
264
+ {
265
+ name: "echo",
266
+ description: "Echo back the supplied message.",
267
+ inputSchema: {
268
+ type: "object",
269
+ required: ["message"],
270
+ properties: {
271
+ message: { type: "string", description: "Text to echo." },
272
+ },
273
+ },
274
+ },
275
+ ],
276
+ }));
277
+
278
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
279
+ const { name: tool, arguments: args } = req.params;
280
+ if (tool === "echo") {
281
+ return {
282
+ content: [{ type: "text", text: String(args?.message ?? "") }],
283
+ };
284
+ }
285
+ throw new Error(\`Unknown tool: \${tool}\`);
286
+ });
287
+
288
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
289
+ resources: [
290
+ {
291
+ uri: "hello://world",
292
+ name: "Hello world",
293
+ description: "A trivial resource you can read to test connectivity.",
294
+ mimeType: "text/plain",
295
+ },
296
+ ],
297
+ }));
298
+
299
+ server.setRequestHandler(ReadResourceRequestSchema, async (req) => {
300
+ if (req.params.uri === "hello://world") {
301
+ return {
302
+ contents: [
303
+ { uri: req.params.uri, mimeType: "text/plain", text: "Hello, MCP!" },
304
+ ],
305
+ };
306
+ }
307
+ throw new Error(\`Unknown resource: \${req.params.uri}\`);
308
+ });
309
+
310
+ return server;
311
+ }
312
+
313
+ const app = express();
314
+ app.use(express.json());
315
+
316
+ app.all("/mcp", async (req, res) => {
317
+ const transport = new StreamableHTTPServerTransport({
318
+ sessionIdGenerator: () => crypto.randomUUID(),
319
+ });
320
+ const server = makeServer();
321
+ await server.connect(transport);
322
+ await transport.handleRequest(req, res, req.body);
323
+ });
324
+
325
+ const port = Number(process.env.PORT) || ${port};
326
+ app.listen(port, () => {
327
+ console.log(\`[${name}] MCP server listening on http://localhost:\${port}/mcp\`);
328
+ });
329
+ `;
330
+ }
331
+
332
+ function renderReadme({ name, description, transport, port }) {
333
+ const wireUp =
334
+ transport === "stdio"
335
+ ? `cc mcp add ${name} -c node -a "./index.js"`
336
+ : `cc mcp add ${name} -u http://localhost:${port}/mcp`;
337
+
338
+ const run =
339
+ transport === "stdio"
340
+ ? "An MCP host invokes the server on demand — there's no long-running process. Use `node index.js` only to sanity-check that the file parses."
341
+ : `\`\`\`bash\nnpm install\nnpm start # listens on http://localhost:${port}/mcp\n\`\`\``;
342
+
343
+ return `# ${name}
344
+
345
+ ${description}
346
+
347
+ Transport: **${transport}**${transport === "http" ? ` (port ${port})` : ""}
348
+
349
+ ## Install
350
+
351
+ \`\`\`bash
352
+ npm install
353
+ \`\`\`
354
+
355
+ ## Run
356
+
357
+ ${run}
358
+
359
+ ## Wire into a host
360
+
361
+ ${transport === "stdio" ? "" : ""}\`\`\`bash
362
+ ${wireUp}
363
+ cc mcp tools # list discovered tools
364
+ cc mcp call ${name} echo --args '{"message":"hi"}'
365
+ \`\`\`
366
+
367
+ ## What's in the box
368
+
369
+ - \`echo\` tool — accepts \`{message}\`, returns it verbatim.
370
+ - \`hello://world\` resource — a trivial plain-text resource you can read
371
+ to confirm the server is reachable.
372
+
373
+ Extend \`index.js\` with your own \`Set*RequestHandler\` calls; the MCP SDK
374
+ docs at https://modelcontextprotocol.io/docs cover every request type.
375
+ `;
376
+ }
377
+
378
+ function renderGitignore() {
379
+ return `node_modules/
380
+ *.log
381
+ .env
382
+ .env.*
383
+ !.env.example
384
+ `;
385
+ }