chainlesschain 0.47.9 → 0.51.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 (73) 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/ipfs.js +392 -0
  22. package/src/commands/kg.js +371 -0
  23. package/src/commands/marketplace.js +326 -0
  24. package/src/commands/mcp.js +97 -18
  25. package/src/commands/multimodal.js +404 -0
  26. package/src/commands/nlprog.js +329 -0
  27. package/src/commands/ops.js +408 -0
  28. package/src/commands/perception.js +385 -0
  29. package/src/commands/pqc.js +34 -0
  30. package/src/commands/privacy.js +345 -0
  31. package/src/commands/quantization.js +280 -0
  32. package/src/commands/recommend.js +336 -0
  33. package/src/commands/reputation.js +349 -0
  34. package/src/commands/runtime.js +500 -0
  35. package/src/commands/sla.js +352 -0
  36. package/src/commands/stress.js +252 -0
  37. package/src/commands/tech.js +268 -0
  38. package/src/commands/tenant.js +576 -0
  39. package/src/commands/trust.js +366 -0
  40. package/src/harness/mcp-client.js +330 -54
  41. package/src/index.js +118 -0
  42. package/src/lib/aiops.js +523 -0
  43. package/src/lib/autonomous-developer.js +524 -0
  44. package/src/lib/code-agent.js +442 -0
  45. package/src/lib/collaboration-governance.js +556 -0
  46. package/src/lib/community-governance.js +649 -0
  47. package/src/lib/content-recommendation.js +600 -0
  48. package/src/lib/cross-chain.js +669 -0
  49. package/src/lib/dbevo.js +669 -0
  50. package/src/lib/decentral-infra.js +445 -0
  51. package/src/lib/federation-hardening.js +587 -0
  52. package/src/lib/hardening-manager.js +409 -0
  53. package/src/lib/inference-network.js +407 -0
  54. package/src/lib/ipfs-storage.js +575 -0
  55. package/src/lib/knowledge-graph.js +530 -0
  56. package/src/lib/mcp-client.js +3 -0
  57. package/src/lib/multimodal.js +725 -0
  58. package/src/lib/nl-programming.js +595 -0
  59. package/src/lib/perception.js +500 -0
  60. package/src/lib/pqc-manager.js +141 -9
  61. package/src/lib/privacy-computing.js +575 -0
  62. package/src/lib/protocol-fusion.js +535 -0
  63. package/src/lib/quantization.js +362 -0
  64. package/src/lib/reputation-optimizer.js +509 -0
  65. package/src/lib/skill-marketplace.js +397 -0
  66. package/src/lib/sla-manager.js +484 -0
  67. package/src/lib/stress-tester.js +383 -0
  68. package/src/lib/tech-learning-engine.js +651 -0
  69. package/src/lib/tenant-saas.js +831 -0
  70. package/src/lib/token-incentive.js +513 -0
  71. package/src/lib/trust-security.js +473 -0
  72. package/src/lib/universal-runtime.js +771 -0
  73. package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +0 -1
@@ -0,0 +1,361 @@
1
+ /**
2
+ * `cc infra` — CLI surface for Phase 74-75 Decentralized Infrastructure.
3
+ */
4
+
5
+ import { Command } from "commander";
6
+
7
+ import {
8
+ DEAL_STATUS,
9
+ ROUTE_TYPE,
10
+ ROUTE_STATUS,
11
+ ensureDecentralInfraTables,
12
+ createDeal,
13
+ updateDealStatus,
14
+ renewDeal,
15
+ getDeal,
16
+ listDeals,
17
+ addContentVersion,
18
+ getContentVersion,
19
+ listContentVersions,
20
+ cacheVersion,
21
+ addRoute,
22
+ updateRouteStatus,
23
+ removeRoute,
24
+ getRoute,
25
+ listRoutes,
26
+ getConnectivityReport,
27
+ getInfraStats,
28
+ } from "../lib/decentral-infra.js";
29
+
30
+ function _dbFromCtx(cmd) {
31
+ const root = cmd?.parent?.parent ?? cmd?.parent;
32
+ return root?._db;
33
+ }
34
+
35
+ export function registerInfraCommand(program) {
36
+ const inf = new Command("infra")
37
+ .description("Decentralized infrastructure (Phase 74-75)")
38
+ .hook("preAction", (thisCmd) => {
39
+ const db = _dbFromCtx(thisCmd);
40
+ if (db) ensureDecentralInfraTables(db);
41
+ });
42
+
43
+ /* ── Catalogs ────────────────────────────────────── */
44
+
45
+ inf
46
+ .command("deal-statuses")
47
+ .description("List deal statuses")
48
+ .option("--json", "JSON output")
49
+ .action((opts) => {
50
+ const statuses = Object.values(DEAL_STATUS);
51
+ if (opts.json) return console.log(JSON.stringify(statuses, null, 2));
52
+ for (const s of statuses) console.log(` ${s}`);
53
+ });
54
+
55
+ inf
56
+ .command("route-types")
57
+ .description("List route types")
58
+ .option("--json", "JSON output")
59
+ .action((opts) => {
60
+ const types = Object.values(ROUTE_TYPE);
61
+ if (opts.json) return console.log(JSON.stringify(types, null, 2));
62
+ for (const t of types) console.log(` ${t}`);
63
+ });
64
+
65
+ /* ── Filecoin Storage (Phase 74) ��────────────────── */
66
+
67
+ inf
68
+ .command("deal-create")
69
+ .description("Create Filecoin storage deal")
70
+ .requiredOption("-c, --cid <cid>", "Content CID")
71
+ .requiredOption("-s, --size <bytes>", "Size in bytes", parseInt)
72
+ .option("-m, --miner <id>", "Miner ID")
73
+ .option("-p, --price <fil>", "Price in FIL", parseFloat)
74
+ .option("-d, --duration <epochs>", "Duration in epochs", parseInt)
75
+ .option("--json", "JSON output")
76
+ .action((opts) => {
77
+ const db = _dbFromCtx(inf);
78
+ const result = createDeal(db, {
79
+ cid: opts.cid,
80
+ minerId: opts.miner,
81
+ sizeBytes: opts.size,
82
+ priceFil: opts.price,
83
+ durationEpochs: opts.duration,
84
+ });
85
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
86
+ if (result.dealId) console.log(`Deal created: ${result.dealId}`);
87
+ else console.log(`Failed: ${result.reason}`);
88
+ });
89
+
90
+ inf
91
+ .command("deal-status <id> <status>")
92
+ .description("Update deal status")
93
+ .option("--json", "JSON output")
94
+ .action((id, status, opts) => {
95
+ const db = _dbFromCtx(inf);
96
+ const result = updateDealStatus(db, id, status);
97
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
98
+ console.log(
99
+ result.updated ? "Status updated." : `Failed: ${result.reason}`,
100
+ );
101
+ });
102
+
103
+ inf
104
+ .command("deal-renew <id>")
105
+ .description("Renew a storage deal")
106
+ .option("--json", "JSON output")
107
+ .action((id, opts) => {
108
+ const db = _dbFromCtx(inf);
109
+ const result = renewDeal(db, id);
110
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
111
+ if (result.renewed)
112
+ console.log(`Renewed (count: ${result.renewalCount})`);
113
+ else console.log(`Failed: ${result.reason}`);
114
+ });
115
+
116
+ inf
117
+ .command("deal-show <id>")
118
+ .description("Show deal details")
119
+ .option("--json", "JSON output")
120
+ .action((id, opts) => {
121
+ const db = _dbFromCtx(inf);
122
+ const d = getDeal(db, id);
123
+ if (!d) return console.log("Deal not found.");
124
+ if (opts.json) return console.log(JSON.stringify(d, null, 2));
125
+ console.log(`ID: ${d.id}`);
126
+ console.log(`CID: ${d.cid}`);
127
+ if (d.miner_id) console.log(`Miner: ${d.miner_id}`);
128
+ console.log(`Size: ${d.size_bytes} bytes`);
129
+ console.log(`Price: ${d.price_fil} FIL`);
130
+ console.log(`Status: ${d.status}`);
131
+ console.log(`Renewals: ${d.renewal_count}`);
132
+ });
133
+
134
+ inf
135
+ .command("deals")
136
+ .description("List storage deals")
137
+ .option("-s, --status <status>", "Filter by status")
138
+ .option("--limit <n>", "Max results", parseInt)
139
+ .option("--json", "JSON output")
140
+ .action((opts) => {
141
+ const db = _dbFromCtx(inf);
142
+ const deals = listDeals(db, {
143
+ status: opts.status,
144
+ limit: opts.limit,
145
+ });
146
+ if (opts.json) return console.log(JSON.stringify(deals, null, 2));
147
+ if (deals.length === 0) return console.log("No deals.");
148
+ for (const d of deals) {
149
+ console.log(
150
+ ` ${d.status.padEnd(10)} ${d.cid.slice(0, 20).padEnd(22)} ${d.size_bytes}B ${d.id.slice(0, 8)}`,
151
+ );
152
+ }
153
+ });
154
+
155
+ /* ── Content Versions ────────────────────────────── */
156
+
157
+ inf
158
+ .command("version-add")
159
+ .description("Add content version")
160
+ .requiredOption("-c, --cid <cid>", "Content CID")
161
+ .option("-p, --parent <cid>", "Parent CID")
162
+ .option("-d, --dag <json>", "DAG structure")
163
+ .option("-n, --peers <n>", "Peer count", parseInt)
164
+ .option("--json", "JSON output")
165
+ .action((opts) => {
166
+ const db = _dbFromCtx(inf);
167
+ const result = addContentVersion(db, {
168
+ contentCid: opts.cid,
169
+ parentCid: opts.parent,
170
+ dagStructure: opts.dag,
171
+ peerCount: opts.peers,
172
+ });
173
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
174
+ if (result.versionId)
175
+ console.log(`Version ${result.version}: ${result.versionId}`);
176
+ else console.log(`Failed: ${result.reason}`);
177
+ });
178
+
179
+ inf
180
+ .command("version-show <id>")
181
+ .description("Show content version")
182
+ .option("--json", "JSON output")
183
+ .action((id, opts) => {
184
+ const db = _dbFromCtx(inf);
185
+ const v = getContentVersion(db, id);
186
+ if (!v) return console.log("Version not found.");
187
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
188
+ console.log(`ID: ${v.id}`);
189
+ console.log(`CID: ${v.content_cid}`);
190
+ console.log(`Version: ${v.version}`);
191
+ if (v.parent_cid) console.log(`Parent: ${v.parent_cid}`);
192
+ console.log(`Cached: ${v.cached ? "YES" : "NO"}`);
193
+ console.log(`Peers: ${v.peer_count}`);
194
+ });
195
+
196
+ inf
197
+ .command("versions")
198
+ .description("List content versions")
199
+ .option("-c, --cid <cid>", "Filter by content CID")
200
+ .option("--limit <n>", "Max results", parseInt)
201
+ .option("--json", "JSON output")
202
+ .action((opts) => {
203
+ const db = _dbFromCtx(inf);
204
+ const vers = listContentVersions(db, {
205
+ contentCid: opts.cid,
206
+ limit: opts.limit,
207
+ });
208
+ if (opts.json) return console.log(JSON.stringify(vers, null, 2));
209
+ if (vers.length === 0) return console.log("No versions.");
210
+ for (const v of vers) {
211
+ console.log(
212
+ ` v${String(v.version).padEnd(4)} ${v.content_cid.slice(0, 20).padEnd(22)} ${v.cached ? "cached" : " "} ${v.id.slice(0, 8)}`,
213
+ );
214
+ }
215
+ });
216
+
217
+ inf
218
+ .command("version-cache <id>")
219
+ .description("Mark content version as cached")
220
+ .option("--json", "JSON output")
221
+ .action((id, opts) => {
222
+ const db = _dbFromCtx(inf);
223
+ const result = cacheVersion(db, id);
224
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
225
+ console.log(
226
+ result.cached ? "Version cached." : `Failed: ${result.reason}`,
227
+ );
228
+ });
229
+
230
+ /* ── Anti-Censorship Routes (Phase 75) ───────────── */
231
+
232
+ inf
233
+ .command("route-add")
234
+ .description("Add anti-censorship route")
235
+ .requiredOption(
236
+ "-t, --type <type>",
237
+ "Route type (tor/domain_front/mesh_ble/mesh_wifi/direct)",
238
+ )
239
+ .option("-e, --endpoint <url>", "Endpoint URL")
240
+ .option("-l, --latency <ms>", "Latency in ms", parseInt)
241
+ .option("-r, --reliability <0-1>", "Reliability score", parseFloat)
242
+ .option("--json", "JSON output")
243
+ .action((opts) => {
244
+ const db = _dbFromCtx(inf);
245
+ const result = addRoute(db, {
246
+ routeType: opts.type,
247
+ endpoint: opts.endpoint,
248
+ latencyMs: opts.latency,
249
+ reliability: opts.reliability,
250
+ });
251
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
252
+ if (result.routeId) console.log(`Route added: ${result.routeId}`);
253
+ else console.log(`Failed: ${result.reason}`);
254
+ });
255
+
256
+ inf
257
+ .command("route-status <id> <status>")
258
+ .description("Update route status")
259
+ .option("--json", "JSON output")
260
+ .action((id, status, opts) => {
261
+ const db = _dbFromCtx(inf);
262
+ const result = updateRouteStatus(db, id, status);
263
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
264
+ console.log(
265
+ result.updated ? "Status updated." : `Failed: ${result.reason}`,
266
+ );
267
+ });
268
+
269
+ inf
270
+ .command("route-remove <id>")
271
+ .description("Remove route")
272
+ .option("--json", "JSON output")
273
+ .action((id, opts) => {
274
+ const db = _dbFromCtx(inf);
275
+ const result = removeRoute(db, id);
276
+ if (opts.json) return console.log(JSON.stringify(result, null, 2));
277
+ console.log(
278
+ result.removed ? "Route removed." : `Failed: ${result.reason}`,
279
+ );
280
+ });
281
+
282
+ inf
283
+ .command("route-show <id>")
284
+ .description("Show route details")
285
+ .option("--json", "JSON output")
286
+ .action((id, opts) => {
287
+ const db = _dbFromCtx(inf);
288
+ const r = getRoute(db, id);
289
+ if (!r) return console.log("Route not found.");
290
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
291
+ console.log(`ID: ${r.id}`);
292
+ console.log(`Type: ${r.route_type}`);
293
+ if (r.endpoint) console.log(`Endpoint: ${r.endpoint}`);
294
+ console.log(`Status: ${r.status}`);
295
+ if (r.latency_ms != null) console.log(`Latency: ${r.latency_ms}ms`);
296
+ console.log(`Reliability: ${r.reliability}`);
297
+ });
298
+
299
+ inf
300
+ .command("routes")
301
+ .description("List anti-censorship routes")
302
+ .option("-t, --type <type>", "Filter by route type")
303
+ .option("-s, --status <status>", "Filter by status")
304
+ .option("--limit <n>", "Max results", parseInt)
305
+ .option("--json", "JSON output")
306
+ .action((opts) => {
307
+ const db = _dbFromCtx(inf);
308
+ const routes = listRoutes(db, {
309
+ routeType: opts.type,
310
+ status: opts.status,
311
+ limit: opts.limit,
312
+ });
313
+ if (opts.json) return console.log(JSON.stringify(routes, null, 2));
314
+ if (routes.length === 0) return console.log("No routes.");
315
+ for (const r of routes) {
316
+ console.log(
317
+ ` ${r.status.padEnd(10)} ${r.route_type.padEnd(14)} ${(r.endpoint || "").slice(0, 30).padEnd(32)} ${r.id.slice(0, 8)}`,
318
+ );
319
+ }
320
+ });
321
+
322
+ inf
323
+ .command("connectivity")
324
+ .description("Connectivity report")
325
+ .option("--json", "JSON output")
326
+ .action((opts) => {
327
+ const db = _dbFromCtx(inf);
328
+ const r = getConnectivityReport(db);
329
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
330
+ console.log(`Total: ${r.totalRoutes}`);
331
+ console.log(`Active: ${r.activeRoutes}`);
332
+ console.log(`Avg Latency: ${r.avgLatencyMs}ms`);
333
+ console.log(`Avg Reliability: ${r.avgReliability}`);
334
+ for (const [type, count] of Object.entries(r.byType)) {
335
+ console.log(` ${type.padEnd(14)} ${count}`);
336
+ }
337
+ });
338
+
339
+ /* ── Stats ────────────────────────────────────��──── */
340
+
341
+ inf
342
+ .command("stats")
343
+ .description("Infrastructure statistics")
344
+ .option("--json", "JSON output")
345
+ .action((opts) => {
346
+ const db = _dbFromCtx(inf);
347
+ const s = getInfraStats(db);
348
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
349
+ console.log(
350
+ `Storage: ${s.storage.totalDeals} deals (${s.storage.active} active, ${s.storage.totalSizeBytes}B, ${s.storage.totalPriceFil} FIL)`,
351
+ );
352
+ console.log(
353
+ `Content: ${s.content.totalVersions} versions (${s.content.cached} cached, ${s.content.uniqueCids} unique CIDs)`,
354
+ );
355
+ console.log(
356
+ `Routes: ${s.connectivity.totalRoutes} (${s.connectivity.activeRoutes} active, avg ${s.connectivity.avgLatencyMs}ms)`,
357
+ );
358
+ });
359
+
360
+ program.addCommand(inf);
361
+ }