chainlesschain 0.47.9 → 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 (70) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  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/codegen.js +303 -0
  10. package/src/commands/collab.js +482 -0
  11. package/src/commands/crosschain.js +382 -0
  12. package/src/commands/dbevo.js +388 -0
  13. package/src/commands/dev.js +411 -0
  14. package/src/commands/federation.js +427 -0
  15. package/src/commands/fusion.js +332 -0
  16. package/src/commands/governance.js +505 -0
  17. package/src/commands/hardening.js +110 -0
  18. package/src/commands/incentive.js +373 -0
  19. package/src/commands/inference.js +304 -0
  20. package/src/commands/infra.js +361 -0
  21. package/src/commands/kg.js +371 -0
  22. package/src/commands/marketplace.js +326 -0
  23. package/src/commands/mcp.js +97 -18
  24. package/src/commands/nlprog.js +329 -0
  25. package/src/commands/ops.js +408 -0
  26. package/src/commands/perception.js +385 -0
  27. package/src/commands/pqc.js +34 -0
  28. package/src/commands/privacy.js +345 -0
  29. package/src/commands/quantization.js +280 -0
  30. package/src/commands/recommend.js +336 -0
  31. package/src/commands/reputation.js +349 -0
  32. package/src/commands/runtime.js +500 -0
  33. package/src/commands/sla.js +352 -0
  34. package/src/commands/stress.js +252 -0
  35. package/src/commands/tech.js +268 -0
  36. package/src/commands/tenant.js +576 -0
  37. package/src/commands/trust.js +366 -0
  38. package/src/harness/mcp-client.js +330 -54
  39. package/src/index.js +112 -0
  40. package/src/lib/aiops.js +523 -0
  41. package/src/lib/autonomous-developer.js +524 -0
  42. package/src/lib/code-agent.js +442 -0
  43. package/src/lib/collaboration-governance.js +556 -0
  44. package/src/lib/community-governance.js +649 -0
  45. package/src/lib/content-recommendation.js +600 -0
  46. package/src/lib/cross-chain.js +669 -0
  47. package/src/lib/dbevo.js +669 -0
  48. package/src/lib/decentral-infra.js +445 -0
  49. package/src/lib/federation-hardening.js +587 -0
  50. package/src/lib/hardening-manager.js +409 -0
  51. package/src/lib/inference-network.js +407 -0
  52. package/src/lib/knowledge-graph.js +530 -0
  53. package/src/lib/mcp-client.js +3 -0
  54. package/src/lib/multimodal.js +698 -0
  55. package/src/lib/nl-programming.js +595 -0
  56. package/src/lib/perception.js +500 -0
  57. package/src/lib/pqc-manager.js +141 -9
  58. package/src/lib/privacy-computing.js +575 -0
  59. package/src/lib/protocol-fusion.js +535 -0
  60. package/src/lib/quantization.js +362 -0
  61. package/src/lib/reputation-optimizer.js +509 -0
  62. package/src/lib/skill-marketplace.js +397 -0
  63. package/src/lib/sla-manager.js +484 -0
  64. package/src/lib/stress-tester.js +383 -0
  65. package/src/lib/tech-learning-engine.js +651 -0
  66. package/src/lib/tenant-saas.js +831 -0
  67. package/src/lib/token-incentive.js +513 -0
  68. package/src/lib/trust-security.js +473 -0
  69. package/src/lib/universal-runtime.js +771 -0
  70. package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +0 -1
@@ -0,0 +1,332 @@
1
+ /**
2
+ * `cc fusion` — CLI surface for Phase 72-73 Protocol Fusion & AI Social.
3
+ */
4
+
5
+ import { Command } from "commander";
6
+
7
+ import {
8
+ PROTOCOL,
9
+ QUALITY_LEVEL,
10
+ ensureProtocolFusionTables,
11
+ sendMessage,
12
+ getMessage,
13
+ listMessages,
14
+ mapIdentity,
15
+ getIdentityMap,
16
+ getIdentityById,
17
+ listIdentities,
18
+ verifyIdentity,
19
+ assessQuality,
20
+ getQualityScore,
21
+ listQualityScores,
22
+ getQualityReport,
23
+ translateMessage,
24
+ detectLanguage,
25
+ getTranslationStats,
26
+ getProtocolFusionStats,
27
+ } from "../lib/protocol-fusion.js";
28
+
29
+ function _dbFromCtx(cmd) {
30
+ const root = cmd?.parent?.parent ?? cmd?.parent;
31
+ return root?._db;
32
+ }
33
+
34
+ export function registerFusionCommand(program) {
35
+ const fu = new Command("fusion")
36
+ .description("Protocol fusion & AI social (Phase 72-73)")
37
+ .hook("preAction", (thisCmd) => {
38
+ const db = _dbFromCtx(thisCmd);
39
+ if (db) ensureProtocolFusionTables(db);
40
+ });
41
+
42
+ /* ── Catalogs ────────────────────────────────────── */
43
+
44
+ fu.command("protocols")
45
+ .description("List supported protocols")
46
+ .option("--json", "JSON output")
47
+ .action((opts) => {
48
+ const protocols = Object.values(PROTOCOL);
49
+ if (opts.json) return console.log(JSON.stringify(protocols, null, 2));
50
+ for (const p of protocols) console.log(` ${p}`);
51
+ });
52
+
53
+ fu.command("quality-levels")
54
+ .description("List quality levels")
55
+ .option("--json", "JSON output")
56
+ .action((opts) => {
57
+ const levels = Object.values(QUALITY_LEVEL);
58
+ if (opts.json) return console.log(JSON.stringify(levels, null, 2));
59
+ for (const l of levels) console.log(` ${l}`);
60
+ });
61
+
62
+ /* ── Protocol Fusion (Phase 72) ──────────────────── */
63
+
64
+ fu.command("send")
65
+ .description("Send cross-protocol message")
66
+ .requiredOption("-s, --source <protocol>", "Source protocol")
67
+ .option("-t, --target <protocol>", "Target protocol")
68
+ .option("-f, --from <id>", "Sender ID")
69
+ .requiredOption("-c, --content <text>", "Message content")
70
+ .option("--json", "JSON output")
71
+ .action((opts) => {
72
+ const db = _dbFromCtx(fu);
73
+ const result = sendMessage(db, {
74
+ sourceProtocol: opts.source,
75
+ targetProtocol: opts.target,
76
+ senderId: opts.from,
77
+ content: opts.content,
78
+ });
79
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
80
+ if (result.messageId) {
81
+ console.log(`Message: ${result.messageId}`);
82
+ console.log(`Converted: ${result.converted ? "YES" : "NO"}`);
83
+ console.log(`Routed: ${result.routed ? "YES" : "NO"}`);
84
+ } else console.log(`Failed: ${result.reason}`);
85
+ });
86
+
87
+ fu.command("msg-show <id>")
88
+ .description("Show message details")
89
+ .option("--json", "JSON output")
90
+ .action((id, opts) => {
91
+ const db = _dbFromCtx(fu);
92
+ const m = getMessage(db, id);
93
+ if (!m) return console.log("Message not found.");
94
+ if (opts.json) return console.log(JSON.stringify(m, null, 2));
95
+ console.log(`ID: ${m.id}`);
96
+ console.log(`Source: ${m.source_protocol}`);
97
+ if (m.target_protocol) console.log(`Target: ${m.target_protocol}`);
98
+ if (m.sender_id) console.log(`Sender: ${m.sender_id}`);
99
+ console.log(`Content: ${m.content}`);
100
+ console.log(`Converted: ${m.converted ? "YES" : "NO"}`);
101
+ console.log(`Routed: ${m.routed ? "YES" : "NO"}`);
102
+ });
103
+
104
+ fu.command("messages")
105
+ .description("List unified messages")
106
+ .option("-p, --protocol <name>", "Filter by protocol")
107
+ .option("--limit <n>", "Max results", parseInt)
108
+ .option("--json", "JSON output")
109
+ .action((opts) => {
110
+ const db = _dbFromCtx(fu);
111
+ const msgs = listMessages(db, {
112
+ protocol: opts.protocol,
113
+ limit: opts.limit,
114
+ });
115
+ if (opts.json) return console.log(JSON.stringify(msgs, null, 2));
116
+ if (msgs.length === 0) return console.log("No messages.");
117
+ for (const m of msgs) {
118
+ const target = m.target_protocol ? ` → ${m.target_protocol}` : "";
119
+ console.log(
120
+ ` ${m.source_protocol.padEnd(14)}${target.padEnd(16)} ${(m.content || "").slice(0, 40).padEnd(42)} ${m.id.slice(0, 8)}`,
121
+ );
122
+ }
123
+ });
124
+
125
+ /* ── Identity Mapping ────────────────────────────── */
126
+
127
+ fu.command("map-identity")
128
+ .description("Create identity mapping")
129
+ .option("-d, --did <id>", "DID identifier")
130
+ .option("-a, --activitypub <id>", "ActivityPub identifier")
131
+ .option("-n, --nostr <pubkey>", "Nostr public key")
132
+ .option("-m, --matrix <id>", "Matrix identifier")
133
+ .option("--json", "JSON output")
134
+ .action((opts) => {
135
+ const db = _dbFromCtx(fu);
136
+ const result = mapIdentity(db, {
137
+ didId: opts.did,
138
+ activitypubId: opts.activitypub,
139
+ nostrPubkey: opts.nostr,
140
+ matrixId: opts.matrix,
141
+ });
142
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
143
+ if (result.mappingId) console.log(`Mapping: ${result.mappingId}`);
144
+ else console.log(`Failed: ${result.reason}`);
145
+ });
146
+
147
+ fu.command("identity <did>")
148
+ .description("Look up identity mapping by DID")
149
+ .option("--json", "JSON output")
150
+ .action((did, opts) => {
151
+ const db = _dbFromCtx(fu);
152
+ const m = getIdentityMap(db, did);
153
+ if (!m) return console.log("Identity mapping not found.");
154
+ if (opts.json) return console.log(JSON.stringify(m, null, 2));
155
+ console.log(`ID: ${m.id}`);
156
+ if (m.did_id) console.log(`DID: ${m.did_id}`);
157
+ if (m.activitypub_id) console.log(`ActivityPub: ${m.activitypub_id}`);
158
+ if (m.nostr_pubkey) console.log(`Nostr: ${m.nostr_pubkey}`);
159
+ if (m.matrix_id) console.log(`Matrix: ${m.matrix_id}`);
160
+ console.log(`Verified: ${m.verified ? "YES" : "NO"}`);
161
+ });
162
+
163
+ fu.command("identities")
164
+ .description("List identity mappings")
165
+ .option("--limit <n>", "Max results", parseInt)
166
+ .option("--json", "JSON output")
167
+ .action((opts) => {
168
+ const db = _dbFromCtx(fu);
169
+ const ids = listIdentities(db, { limit: opts.limit });
170
+ if (opts.json) return console.log(JSON.stringify(ids, null, 2));
171
+ if (ids.length === 0) return console.log("No identity mappings.");
172
+ for (const m of ids) {
173
+ const parts = [];
174
+ if (m.did_id) parts.push(`did:${m.did_id.slice(0, 12)}`);
175
+ if (m.activitypub_id) parts.push(`ap:${m.activitypub_id.slice(0, 12)}`);
176
+ if (m.nostr_pubkey) parts.push(`nostr:${m.nostr_pubkey.slice(0, 12)}`);
177
+ if (m.matrix_id) parts.push(`mx:${m.matrix_id.slice(0, 12)}`);
178
+ console.log(
179
+ ` ${m.verified ? "✓" : " "} ${parts.join(" | ").padEnd(50)} ${m.id.slice(0, 8)}`,
180
+ );
181
+ }
182
+ });
183
+
184
+ fu.command("verify-identity <id>")
185
+ .description("Verify an identity mapping")
186
+ .option("--json", "JSON output")
187
+ .action((id, opts) => {
188
+ const db = _dbFromCtx(fu);
189
+ const result = verifyIdentity(db, id);
190
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
191
+ console.log(
192
+ result.verified ? "Identity verified." : `Failed: ${result.reason}`,
193
+ );
194
+ });
195
+
196
+ /* ── Content Quality (Phase 73) ──────────────────── */
197
+
198
+ fu.command("assess <content>")
199
+ .description("Assess content quality")
200
+ .option("-i, --content-id <id>", "Content identifier")
201
+ .option("--json", "JSON output")
202
+ .action((content, opts) => {
203
+ const db = _dbFromCtx(fu);
204
+ const result = assessQuality(db, opts.contentId, content);
205
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
206
+ if (result.scoreId) {
207
+ console.log(`Score: ${result.score}`);
208
+ console.log(`Level: ${result.level}`);
209
+ console.log(`Harmful: ${result.harmful ? "YES" : "NO"}`);
210
+ } else console.log(`Failed: ${result.reason}`);
211
+ });
212
+
213
+ fu.command("quality-show <id>")
214
+ .description("Show quality score details")
215
+ .option("--json", "JSON output")
216
+ .action((id, opts) => {
217
+ const db = _dbFromCtx(fu);
218
+ const s = getQualityScore(db, id);
219
+ if (!s) return console.log("Quality score not found.");
220
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
221
+ console.log(`ID: ${s.id}`);
222
+ console.log(`Content: ${s.content_id}`);
223
+ console.log(`Level: ${s.quality_level}`);
224
+ console.log(`Score: ${s.quality_score}`);
225
+ console.log(`Harmful: ${s.harmful_detected ? "YES" : "NO"}`);
226
+ });
227
+
228
+ fu.command("quality-scores")
229
+ .description("List quality scores")
230
+ .option("-l, --level <level>", "Filter by quality level")
231
+ .option("--limit <n>", "Max results", parseInt)
232
+ .option("--json", "JSON output")
233
+ .action((opts) => {
234
+ const db = _dbFromCtx(fu);
235
+ const scores = listQualityScores(db, {
236
+ level: opts.level,
237
+ limit: opts.limit,
238
+ });
239
+ if (opts.json) return console.log(JSON.stringify(scores, null, 2));
240
+ if (scores.length === 0) return console.log("No quality scores.");
241
+ for (const s of scores) {
242
+ console.log(
243
+ ` ${s.quality_level.padEnd(10)} ${String(s.quality_score).padEnd(6)} ${s.harmful_detected ? "HARMFUL" : " "} ${s.id.slice(0, 8)}`,
244
+ );
245
+ }
246
+ });
247
+
248
+ fu.command("quality-report")
249
+ .description("Content quality report")
250
+ .option("--json", "JSON output")
251
+ .action((opts) => {
252
+ const db = _dbFromCtx(fu);
253
+ const r = getQualityReport(db);
254
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
255
+ console.log(`Total: ${r.total}`);
256
+ console.log(`Avg: ${r.avgScore}`);
257
+ console.log(`Harmful: ${r.harmful}`);
258
+ for (const [level, count] of Object.entries(r.byLevel)) {
259
+ console.log(` ${level.padEnd(10)} ${count}`);
260
+ }
261
+ });
262
+
263
+ /* ── Translation (Phase 73) ──────────────────────── */
264
+
265
+ fu.command("translate <text>")
266
+ .description("Translate text (simulated)")
267
+ .option("-s, --source-lang <lang>", "Source language")
268
+ .requiredOption("-t, --target-lang <lang>", "Target language")
269
+ .option("--json", "JSON output")
270
+ .action((text, opts) => {
271
+ const db = _dbFromCtx(fu);
272
+ const result = translateMessage(db, {
273
+ text,
274
+ sourceLang: opts.sourceLang,
275
+ targetLang: opts.targetLang,
276
+ });
277
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
278
+ if (result.translatedText) {
279
+ console.log(`Translation: ${result.translatedText}`);
280
+ console.log(`Cached: ${result.cached ? "YES" : "NO"}`);
281
+ } else console.log(`Failed: ${result.reason}`);
282
+ });
283
+
284
+ fu.command("detect-lang <text>")
285
+ .description("Detect language of text")
286
+ .option("--json", "JSON output")
287
+ .action((text, opts) => {
288
+ const result = detectLanguage(text);
289
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
290
+ if (result.lang) {
291
+ console.log(`Language: ${result.lang}`);
292
+ console.log(`Confidence: ${result.confidence}`);
293
+ } else console.log(`Failed: ${result.reason}`);
294
+ });
295
+
296
+ fu.command("translation-stats")
297
+ .description("Translation cache statistics")
298
+ .option("--json", "JSON output")
299
+ .action((opts) => {
300
+ const db = _dbFromCtx(fu);
301
+ const s = getTranslationStats(db);
302
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
303
+ console.log(`Total: ${s.total}`);
304
+ console.log(`Cache: ${s.cacheSize}`);
305
+ console.log(`Languages: ${s.languages.join(", ") || "none"}`);
306
+ });
307
+
308
+ /* ── Stats ───────────────────────────────────────── */
309
+
310
+ fu.command("stats")
311
+ .description("Protocol fusion & AI social statistics")
312
+ .option("--json", "JSON output")
313
+ .action((opts) => {
314
+ const db = _dbFromCtx(fu);
315
+ const s = getProtocolFusionStats(db);
316
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
317
+ console.log(
318
+ `Messages: ${s.messages.total} (${s.messages.converted} converted, ${s.messages.routed} routed)`,
319
+ );
320
+ console.log(
321
+ `Identities: ${s.identities.total} (${s.identities.verified} verified)`,
322
+ );
323
+ console.log(
324
+ `Quality: ${s.quality.total} (avg ${s.quality.avgScore}, ${s.quality.harmful} harmful)`,
325
+ );
326
+ console.log(
327
+ `Translations: ${s.translations.total} (cache: ${s.translations.cacheSize})`,
328
+ );
329
+ });
330
+
331
+ program.addCommand(fu);
332
+ }