chainlesschain 0.66.0 → 0.132.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 (143) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +380 -0
  4. package/src/commands/agent-network.js +254 -1
  5. package/src/commands/audit.js +302 -0
  6. package/src/commands/automation.js +271 -1
  7. package/src/commands/bi.js +348 -0
  8. package/src/commands/codegen.js +224 -0
  9. package/src/commands/collab.js +341 -0
  10. package/src/commands/compliance.js +1035 -0
  11. package/src/commands/cowork.js +221 -0
  12. package/src/commands/crosschain.js +218 -0
  13. package/src/commands/dbevo.js +284 -0
  14. package/src/commands/dev.js +252 -0
  15. package/src/commands/did.js +358 -0
  16. package/src/commands/dlp.js +341 -0
  17. package/src/commands/encrypt.js +341 -0
  18. package/src/commands/evomap.js +394 -0
  19. package/src/commands/export.js +256 -1
  20. package/src/commands/federation.js +283 -0
  21. package/src/commands/fusion.js +258 -0
  22. package/src/commands/governance.js +325 -0
  23. package/src/commands/hardening.js +411 -0
  24. package/src/commands/hook.js +148 -0
  25. package/src/commands/import.js +252 -0
  26. package/src/commands/incentive.js +322 -0
  27. package/src/commands/inference.js +318 -0
  28. package/src/commands/infra.js +244 -0
  29. package/src/commands/instinct.js +260 -0
  30. package/src/commands/ipfs.js +318 -0
  31. package/src/commands/kg.js +387 -0
  32. package/src/commands/llm.js +263 -0
  33. package/src/commands/lowcode.js +356 -0
  34. package/src/commands/marketplace.js +256 -0
  35. package/src/commands/mcp.js +221 -0
  36. package/src/commands/memory.js +248 -0
  37. package/src/commands/multimodal.js +296 -0
  38. package/src/commands/nlprog.js +356 -0
  39. package/src/commands/note.js +244 -0
  40. package/src/commands/ops.js +354 -0
  41. package/src/commands/orchestrate.js +166 -0
  42. package/src/commands/org.js +277 -0
  43. package/src/commands/p2p.js +390 -0
  44. package/src/commands/perception.js +290 -0
  45. package/src/commands/permmem.js +251 -0
  46. package/src/commands/plugin-ecosystem.js +273 -0
  47. package/src/commands/pqc.js +393 -0
  48. package/src/commands/privacy.js +321 -0
  49. package/src/commands/quantization.js +351 -0
  50. package/src/commands/rcache.js +271 -0
  51. package/src/commands/recommend.js +340 -0
  52. package/src/commands/reputation.js +261 -0
  53. package/src/commands/runtime.js +307 -0
  54. package/src/commands/scim.js +262 -0
  55. package/src/commands/session.js +258 -0
  56. package/src/commands/siem.js +246 -0
  57. package/src/commands/skill.js +267 -1
  58. package/src/commands/sla.js +259 -0
  59. package/src/commands/social.js +256 -0
  60. package/src/commands/sso.js +186 -1
  61. package/src/commands/stress.js +230 -0
  62. package/src/commands/sync.js +256 -0
  63. package/src/commands/tech.js +338 -0
  64. package/src/commands/tenant.js +351 -0
  65. package/src/commands/terraform.js +245 -0
  66. package/src/commands/tokens.js +269 -0
  67. package/src/commands/trust.js +249 -0
  68. package/src/commands/wallet.js +277 -0
  69. package/src/commands/workflow.js +171 -0
  70. package/src/commands/zkp.js +335 -0
  71. package/src/index.js +4 -0
  72. package/src/lib/a2a-protocol.js +451 -0
  73. package/src/lib/agent-coordinator.js +325 -0
  74. package/src/lib/agent-network.js +387 -0
  75. package/src/lib/agent-router.js +395 -0
  76. package/src/lib/aiops.js +478 -0
  77. package/src/lib/app-builder.js +239 -0
  78. package/src/lib/audit-logger.js +379 -0
  79. package/src/lib/automation-engine.js +330 -0
  80. package/src/lib/autonomous-developer.js +350 -0
  81. package/src/lib/bi-engine.js +338 -0
  82. package/src/lib/code-agent.js +323 -0
  83. package/src/lib/collaboration-governance.js +364 -0
  84. package/src/lib/community-governance.js +436 -0
  85. package/src/lib/compliance-manager.js +434 -0
  86. package/src/lib/content-recommendation.js +469 -0
  87. package/src/lib/cross-chain.js +345 -0
  88. package/src/lib/crypto-manager.js +350 -0
  89. package/src/lib/dbevo.js +338 -0
  90. package/src/lib/decentral-infra.js +340 -0
  91. package/src/lib/did-manager.js +367 -0
  92. package/src/lib/dlp-engine.js +389 -0
  93. package/src/lib/evomap-federation.js +177 -0
  94. package/src/lib/evomap-governance.js +276 -0
  95. package/src/lib/federation-hardening.js +259 -0
  96. package/src/lib/hardening-manager.js +348 -0
  97. package/src/lib/hook-manager.js +380 -0
  98. package/src/lib/inference-network.js +330 -0
  99. package/src/lib/instinct-manager.js +332 -0
  100. package/src/lib/ipfs-storage.js +334 -0
  101. package/src/lib/knowledge-exporter.js +381 -0
  102. package/src/lib/knowledge-graph.js +432 -0
  103. package/src/lib/knowledge-importer.js +379 -0
  104. package/src/lib/llm-providers.js +391 -0
  105. package/src/lib/mcp-registry.js +333 -0
  106. package/src/lib/memory-manager.js +330 -0
  107. package/src/lib/multimodal.js +346 -0
  108. package/src/lib/nl-programming.js +343 -0
  109. package/src/lib/note-versioning.js +327 -0
  110. package/src/lib/org-manager.js +323 -0
  111. package/src/lib/p2p-manager.js +387 -0
  112. package/src/lib/perception.js +346 -0
  113. package/src/lib/perf-tuning.js +4 -1
  114. package/src/lib/permanent-memory.js +320 -0
  115. package/src/lib/plugin-ecosystem.js +377 -0
  116. package/src/lib/pqc-manager.js +368 -0
  117. package/src/lib/privacy-computing.js +427 -0
  118. package/src/lib/protocol-fusion.js +417 -0
  119. package/src/lib/quantization.js +325 -0
  120. package/src/lib/reputation-optimizer.js +299 -0
  121. package/src/lib/response-cache.js +327 -0
  122. package/src/lib/scim-manager.js +329 -0
  123. package/src/lib/session-manager.js +329 -0
  124. package/src/lib/siem-exporter.js +333 -0
  125. package/src/lib/skill-loader.js +377 -0
  126. package/src/lib/skill-marketplace.js +325 -0
  127. package/src/lib/sla-manager.js +275 -0
  128. package/src/lib/social-manager.js +326 -0
  129. package/src/lib/sso-manager.js +332 -0
  130. package/src/lib/stress-tester.js +330 -0
  131. package/src/lib/sync-manager.js +326 -0
  132. package/src/lib/tech-learning-engine.js +369 -0
  133. package/src/lib/tenant-saas.js +460 -0
  134. package/src/lib/terraform-manager.js +363 -0
  135. package/src/lib/threat-intel.js +335 -0
  136. package/src/lib/token-incentive.js +293 -0
  137. package/src/lib/token-tracker.js +329 -0
  138. package/src/lib/trust-security.js +390 -0
  139. package/src/lib/ueba.js +389 -0
  140. package/src/lib/universal-runtime.js +325 -0
  141. package/src/lib/wallet-manager.js +326 -0
  142. package/src/lib/workflow-engine.js +322 -0
  143. package/src/lib/zkp-engine.js +274 -0
@@ -14,6 +14,35 @@ import {
14
14
  decayInstincts,
15
15
  generateInstinctPrompt,
16
16
  INSTINCT_CATEGORIES,
17
+ PROFILE_MATURITY_V2,
18
+ OBSERVATION_LIFECYCLE_V2,
19
+ getMaxActiveProfilesPerUserV2,
20
+ setMaxActiveProfilesPerUserV2,
21
+ getMaxPendingObsPerProfileV2,
22
+ setMaxPendingObsPerProfileV2,
23
+ getProfileIdleMsV2,
24
+ setProfileIdleMsV2,
25
+ getObsStuckMsV2,
26
+ setObsStuckMsV2,
27
+ getActiveProfileCountV2,
28
+ getPendingObsCountV2,
29
+ registerProfileV2,
30
+ getProfileV2,
31
+ listProfilesV2,
32
+ activateProfileV2,
33
+ dormantProfileV2,
34
+ archiveProfileV2,
35
+ touchProfileV2,
36
+ createObservationV2,
37
+ getObservationV2,
38
+ listObservationsV2,
39
+ reviewObservationV2,
40
+ reinforceObservationV2,
41
+ promoteObservationV2,
42
+ discardObservationV2,
43
+ autoDormantIdleProfilesV2,
44
+ autoDiscardStaleObservationsV2,
45
+ getInstinctManagerStatsV2,
17
46
  } from "../lib/instinct-manager.js";
18
47
 
19
48
  export function registerInstinctCommand(program) {
@@ -199,4 +228,235 @@ export function registerInstinctCommand(program) {
199
228
  process.exit(1);
200
229
  }
201
230
  });
231
+
232
+ // ─── V2 governance surface ─────────────────────────────────
233
+
234
+ instinct
235
+ .command("profile-maturities-v2")
236
+ .description("List V2 profile maturity states")
237
+ .action(() => {
238
+ console.log(JSON.stringify(Object.values(PROFILE_MATURITY_V2), null, 2));
239
+ });
240
+
241
+ instinct
242
+ .command("observation-lifecycles-v2")
243
+ .description("List V2 observation lifecycle states")
244
+ .action(() => {
245
+ console.log(
246
+ JSON.stringify(Object.values(OBSERVATION_LIFECYCLE_V2), null, 2),
247
+ );
248
+ });
249
+
250
+ instinct
251
+ .command("stats-v2")
252
+ .description("Show V2 governance stats")
253
+ .action(() => {
254
+ console.log(JSON.stringify(getInstinctManagerStatsV2(), null, 2));
255
+ });
256
+
257
+ instinct
258
+ .command("get-max-active-profiles-v2")
259
+ .description("Get max active profiles per user")
260
+ .action(() => console.log(getMaxActiveProfilesPerUserV2()));
261
+
262
+ instinct
263
+ .command("set-max-active-profiles-v2 <n>")
264
+ .description("Set max active profiles per user")
265
+ .action((n) => {
266
+ setMaxActiveProfilesPerUserV2(Number(n));
267
+ console.log(getMaxActiveProfilesPerUserV2());
268
+ });
269
+
270
+ instinct
271
+ .command("get-max-pending-obs-v2")
272
+ .description("Get max pending observations per profile")
273
+ .action(() => console.log(getMaxPendingObsPerProfileV2()));
274
+
275
+ instinct
276
+ .command("set-max-pending-obs-v2 <n>")
277
+ .description("Set max pending observations per profile")
278
+ .action((n) => {
279
+ setMaxPendingObsPerProfileV2(Number(n));
280
+ console.log(getMaxPendingObsPerProfileV2());
281
+ });
282
+
283
+ instinct
284
+ .command("get-profile-idle-ms-v2")
285
+ .description("Get profile idle threshold (ms)")
286
+ .action(() => console.log(getProfileIdleMsV2()));
287
+
288
+ instinct
289
+ .command("set-profile-idle-ms-v2 <n>")
290
+ .description("Set profile idle threshold (ms)")
291
+ .action((n) => {
292
+ setProfileIdleMsV2(Number(n));
293
+ console.log(getProfileIdleMsV2());
294
+ });
295
+
296
+ instinct
297
+ .command("get-obs-stuck-ms-v2")
298
+ .description("Get observation stuck threshold (ms)")
299
+ .action(() => console.log(getObsStuckMsV2()));
300
+
301
+ instinct
302
+ .command("set-obs-stuck-ms-v2 <n>")
303
+ .description("Set observation stuck threshold (ms)")
304
+ .action((n) => {
305
+ setObsStuckMsV2(Number(n));
306
+ console.log(getObsStuckMsV2());
307
+ });
308
+
309
+ instinct
310
+ .command("active-profile-count-v2 <userId>")
311
+ .description("Count active profiles for a user")
312
+ .action((userId) => console.log(getActiveProfileCountV2(userId)));
313
+
314
+ instinct
315
+ .command("pending-obs-count-v2 <profileId>")
316
+ .description("Count pending observations for a profile")
317
+ .action((profileId) => console.log(getPendingObsCountV2(profileId)));
318
+
319
+ instinct
320
+ .command("register-profile-v2 <id>")
321
+ .description("Register a V2 profile")
322
+ .requiredOption("-u, --user <userId>", "User id")
323
+ .requiredOption("-c, --category <category>", "Category")
324
+ .action((id, opts) => {
325
+ const p = registerProfileV2(id, {
326
+ userId: opts.user,
327
+ category: opts.category,
328
+ });
329
+ console.log(JSON.stringify(p, null, 2));
330
+ });
331
+
332
+ instinct
333
+ .command("get-profile-v2 <id>")
334
+ .description("Get a V2 profile")
335
+ .action((id) => {
336
+ const p = getProfileV2(id);
337
+ console.log(p ? JSON.stringify(p, null, 2) : "null");
338
+ });
339
+
340
+ instinct
341
+ .command("list-profiles-v2")
342
+ .description("List V2 profiles")
343
+ .option("-u, --user <userId>", "Filter by user")
344
+ .option("-c, --category <category>", "Filter by category")
345
+ .option("-s, --status <status>", "Filter by status")
346
+ .action((opts) => {
347
+ console.log(
348
+ JSON.stringify(
349
+ listProfilesV2({
350
+ userId: opts.user,
351
+ category: opts.category,
352
+ status: opts.status,
353
+ }),
354
+ null,
355
+ 2,
356
+ ),
357
+ );
358
+ });
359
+
360
+ instinct
361
+ .command("activate-profile-v2 <id>")
362
+ .description("pending|dormant → active")
363
+ .action((id) =>
364
+ console.log(JSON.stringify(activateProfileV2(id), null, 2)),
365
+ );
366
+
367
+ instinct
368
+ .command("dormant-profile-v2 <id>")
369
+ .description("active → dormant")
370
+ .action((id) => console.log(JSON.stringify(dormantProfileV2(id), null, 2)));
371
+
372
+ instinct
373
+ .command("archive-profile-v2 <id>")
374
+ .description("→ archived (terminal)")
375
+ .action((id) => console.log(JSON.stringify(archiveProfileV2(id), null, 2)));
376
+
377
+ instinct
378
+ .command("touch-profile-v2 <id>")
379
+ .description("Update lastSeenAt")
380
+ .action((id) => console.log(JSON.stringify(touchProfileV2(id), null, 2)));
381
+
382
+ instinct
383
+ .command("create-observation-v2 <id>")
384
+ .description("Create a V2 observation")
385
+ .requiredOption("-p, --profile <profileId>", "Profile id")
386
+ .requiredOption("-s, --signal <signal>", "Signal text")
387
+ .action((id, opts) => {
388
+ const o = createObservationV2(id, {
389
+ profileId: opts.profile,
390
+ signal: opts.signal,
391
+ });
392
+ console.log(JSON.stringify(o, null, 2));
393
+ });
394
+
395
+ instinct
396
+ .command("get-observation-v2 <id>")
397
+ .description("Get a V2 observation")
398
+ .action((id) => {
399
+ const o = getObservationV2(id);
400
+ console.log(o ? JSON.stringify(o, null, 2) : "null");
401
+ });
402
+
403
+ instinct
404
+ .command("list-observations-v2")
405
+ .description("List V2 observations")
406
+ .option("-p, --profile <profileId>", "Filter by profile")
407
+ .option("-s, --status <status>", "Filter by status")
408
+ .action((opts) => {
409
+ console.log(
410
+ JSON.stringify(
411
+ listObservationsV2({
412
+ profileId: opts.profile,
413
+ status: opts.status,
414
+ }),
415
+ null,
416
+ 2,
417
+ ),
418
+ );
419
+ });
420
+
421
+ instinct
422
+ .command("review-observation-v2 <id>")
423
+ .description("captured → reviewed")
424
+ .action((id) =>
425
+ console.log(JSON.stringify(reviewObservationV2(id), null, 2)),
426
+ );
427
+
428
+ instinct
429
+ .command("reinforce-observation-v2 <id>")
430
+ .description("reviewed → reinforced")
431
+ .action((id) =>
432
+ console.log(JSON.stringify(reinforceObservationV2(id), null, 2)),
433
+ );
434
+
435
+ instinct
436
+ .command("promote-observation-v2 <id>")
437
+ .description("reviewed|reinforced → promoted (terminal)")
438
+ .action((id) =>
439
+ console.log(JSON.stringify(promoteObservationV2(id), null, 2)),
440
+ );
441
+
442
+ instinct
443
+ .command("discard-observation-v2 <id>")
444
+ .description("→ discarded (terminal)")
445
+ .action((id) =>
446
+ console.log(JSON.stringify(discardObservationV2(id), null, 2)),
447
+ );
448
+
449
+ instinct
450
+ .command("auto-dormant-idle-profiles-v2")
451
+ .description("Flip idle active profiles → dormant")
452
+ .action(() =>
453
+ console.log(JSON.stringify(autoDormantIdleProfilesV2(), null, 2)),
454
+ );
455
+
456
+ instinct
457
+ .command("auto-discard-stale-observations-v2")
458
+ .description("Flip stale captured/reviewed → discarded")
459
+ .action(() =>
460
+ console.log(JSON.stringify(autoDiscardStaleObservationsV2(), null, 2)),
461
+ );
202
462
  }
@@ -32,6 +32,40 @@ import {
32
32
  setQuota,
33
33
  addKnowledgeAttachment,
34
34
  getKnowledgeAttachments,
35
+ // V2 (Phase 17 V2)
36
+ GATEWAY_MATURITY_V2,
37
+ PIN_LIFECYCLE_V2,
38
+ getDefaultMaxActiveGatewaysPerOperatorV2,
39
+ getMaxActiveGatewaysPerOperatorV2,
40
+ setMaxActiveGatewaysPerOperatorV2,
41
+ getDefaultMaxPendingPinsPerOwnerV2,
42
+ getMaxPendingPinsPerOwnerV2,
43
+ setMaxPendingPinsPerOwnerV2,
44
+ getDefaultGatewayIdleMsV2,
45
+ getGatewayIdleMsV2,
46
+ setGatewayIdleMsV2,
47
+ getDefaultPinPendingMsV2,
48
+ getPinPendingMsV2,
49
+ setPinPendingMsV2,
50
+ registerGatewayV2,
51
+ getGatewayV2,
52
+ setGatewayMaturityV2,
53
+ activateGateway,
54
+ degradeGateway,
55
+ offlineGateway,
56
+ retireGateway,
57
+ touchGatewayHeartbeat,
58
+ registerPinV2,
59
+ getPinV2,
60
+ setPinStatusV2,
61
+ confirmPin,
62
+ failPin,
63
+ unpinV2,
64
+ getActiveGatewayCount,
65
+ getPendingPinCount,
66
+ autoOfflineStaleGateways,
67
+ autoFailStalePendingPins,
68
+ getIpfsStatsV2,
35
69
  } from "../lib/ipfs-storage.js";
36
70
 
37
71
  function _dbFromCtx(cmd) {
@@ -388,5 +422,289 @@ export function registerIpfsCommand(program) {
388
422
  );
389
423
  });
390
424
 
425
+ /* ── V2 (Phase 17 V2) ────────────────────────────── */
426
+
427
+ function _parseJsonFlag(value, label) {
428
+ if (value === undefined) return undefined;
429
+ try {
430
+ return JSON.parse(value);
431
+ } catch {
432
+ throw new Error(`Invalid JSON for ${label}`);
433
+ }
434
+ }
435
+
436
+ ipfs
437
+ .command("gateway-maturities-v2")
438
+ .option("--json", "JSON output")
439
+ .description("List V2 gateway maturity states")
440
+ .action((opts) => {
441
+ const out = Object.values(GATEWAY_MATURITY_V2);
442
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
443
+ for (const s of out) console.log(` ${s}`);
444
+ });
445
+ ipfs
446
+ .command("pin-lifecycles-v2")
447
+ .option("--json", "JSON output")
448
+ .description("List V2 pin lifecycle states")
449
+ .action((opts) => {
450
+ const out = Object.values(PIN_LIFECYCLE_V2);
451
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
452
+ for (const s of out) console.log(` ${s}`);
453
+ });
454
+
455
+ ipfs
456
+ .command("default-max-active-gateways-per-operator")
457
+ .description("Show V2 default per-operator active-gateway cap")
458
+ .action(() =>
459
+ console.log(String(getDefaultMaxActiveGatewaysPerOperatorV2())),
460
+ );
461
+ ipfs
462
+ .command("max-active-gateways-per-operator")
463
+ .description("Show current V2 per-operator active-gateway cap")
464
+ .action(() => console.log(String(getMaxActiveGatewaysPerOperatorV2())));
465
+ ipfs
466
+ .command("set-max-active-gateways-per-operator <n>")
467
+ .description("Set V2 per-operator active-gateway cap")
468
+ .action((n) =>
469
+ console.log(String(setMaxActiveGatewaysPerOperatorV2(Number(n)))),
470
+ );
471
+
472
+ ipfs
473
+ .command("default-max-pending-pins-per-owner")
474
+ .description("Show V2 default per-owner pending-pin cap")
475
+ .action(() => console.log(String(getDefaultMaxPendingPinsPerOwnerV2())));
476
+ ipfs
477
+ .command("max-pending-pins-per-owner")
478
+ .description("Show current V2 per-owner pending-pin cap")
479
+ .action(() => console.log(String(getMaxPendingPinsPerOwnerV2())));
480
+ ipfs
481
+ .command("set-max-pending-pins-per-owner <n>")
482
+ .description("Set V2 per-owner pending-pin cap")
483
+ .action((n) => console.log(String(setMaxPendingPinsPerOwnerV2(Number(n)))));
484
+
485
+ ipfs
486
+ .command("default-gateway-idle-ms")
487
+ .description("Show V2 default gateway-idle window (ms)")
488
+ .action(() => console.log(String(getDefaultGatewayIdleMsV2())));
489
+ ipfs
490
+ .command("gateway-idle-ms")
491
+ .description("Show current V2 gateway-idle window (ms)")
492
+ .action(() => console.log(String(getGatewayIdleMsV2())));
493
+ ipfs
494
+ .command("set-gateway-idle-ms <ms>")
495
+ .description("Set V2 gateway-idle window (ms)")
496
+ .action((ms) => console.log(String(setGatewayIdleMsV2(Number(ms)))));
497
+
498
+ ipfs
499
+ .command("default-pin-pending-ms")
500
+ .description("Show V2 default pin-pending window (ms)")
501
+ .action(() => console.log(String(getDefaultPinPendingMsV2())));
502
+ ipfs
503
+ .command("pin-pending-ms")
504
+ .description("Show current V2 pin-pending window (ms)")
505
+ .action(() => console.log(String(getPinPendingMsV2())));
506
+ ipfs
507
+ .command("set-pin-pending-ms <ms>")
508
+ .description("Set V2 pin-pending window (ms)")
509
+ .action((ms) => console.log(String(setPinPendingMsV2(Number(ms)))));
510
+
511
+ ipfs
512
+ .command("active-gateway-count")
513
+ .description("Count active V2 gateways (optionally scoped by operator)")
514
+ .option("-o, --operator <operator>", "Scope by operator")
515
+ .action((opts) =>
516
+ console.log(String(getActiveGatewayCount(opts.operator))),
517
+ );
518
+ ipfs
519
+ .command("pending-pin-count")
520
+ .description("Count pending V2 pins (optionally scoped by owner)")
521
+ .option("-o, --owner <owner>", "Scope by owner")
522
+ .action((opts) => console.log(String(getPendingPinCount(opts.owner))));
523
+
524
+ ipfs
525
+ .command("register-gateway-v2 <gateway-id>")
526
+ .description("Register a V2 gateway")
527
+ .requiredOption("-o, --operator-id <operator>", "Operator id")
528
+ .requiredOption("-e, --endpoint <url>", "Endpoint URL")
529
+ .option("-i, --initial-status <status>", "Initial maturity status")
530
+ .option("-m, --metadata <json>", "Metadata JSON")
531
+ .action((gatewayId, opts) => {
532
+ const db = _dbFromCtx(ipfs);
533
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
534
+ console.log(
535
+ JSON.stringify(
536
+ registerGatewayV2(db, {
537
+ gatewayId,
538
+ operatorId: opts.operatorId,
539
+ endpoint: opts.endpoint,
540
+ initialStatus: opts.initialStatus,
541
+ metadata,
542
+ }),
543
+ null,
544
+ 2,
545
+ ),
546
+ );
547
+ });
548
+ ipfs
549
+ .command("gateway-v2 <gateway-id>")
550
+ .description("Show a V2 gateway")
551
+ .action((id) => {
552
+ const out = getGatewayV2(id);
553
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
554
+ });
555
+ ipfs
556
+ .command("set-gateway-maturity-v2 <gateway-id> <status>")
557
+ .option("-r, --reason <reason>")
558
+ .option("-m, --metadata <json>")
559
+ .description("Set V2 gateway maturity status")
560
+ .action((id, status, opts) => {
561
+ const db = _dbFromCtx(ipfs);
562
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
563
+ console.log(
564
+ JSON.stringify(
565
+ setGatewayMaturityV2(db, id, status, {
566
+ reason: opts.reason,
567
+ metadata,
568
+ }),
569
+ null,
570
+ 2,
571
+ ),
572
+ );
573
+ });
574
+ ipfs
575
+ .command("activate-gateway <gateway-id>")
576
+ .option("-r, --reason <reason>")
577
+ .description("Activate a V2 gateway")
578
+ .action((id, opts) => {
579
+ const db = _dbFromCtx(ipfs);
580
+ console.log(
581
+ JSON.stringify(activateGateway(db, id, opts.reason), null, 2),
582
+ );
583
+ });
584
+ ipfs
585
+ .command("degrade-gateway <gateway-id>")
586
+ .option("-r, --reason <reason>")
587
+ .description("Degrade a V2 gateway")
588
+ .action((id, opts) => {
589
+ const db = _dbFromCtx(ipfs);
590
+ console.log(JSON.stringify(degradeGateway(db, id, opts.reason), null, 2));
591
+ });
592
+ ipfs
593
+ .command("offline-gateway <gateway-id>")
594
+ .option("-r, --reason <reason>")
595
+ .description("Offline a V2 gateway")
596
+ .action((id, opts) => {
597
+ const db = _dbFromCtx(ipfs);
598
+ console.log(JSON.stringify(offlineGateway(db, id, opts.reason), null, 2));
599
+ });
600
+ ipfs
601
+ .command("retire-gateway <gateway-id>")
602
+ .option("-r, --reason <reason>")
603
+ .description("Retire a V2 gateway")
604
+ .action((id, opts) => {
605
+ const db = _dbFromCtx(ipfs);
606
+ console.log(JSON.stringify(retireGateway(db, id, opts.reason), null, 2));
607
+ });
608
+ ipfs
609
+ .command("touch-gateway-heartbeat <gateway-id>")
610
+ .description("Bump lastHeartbeatAt on a V2 gateway")
611
+ .action((id) =>
612
+ console.log(JSON.stringify(touchGatewayHeartbeat(id), null, 2)),
613
+ );
614
+
615
+ ipfs
616
+ .command("register-pin-v2 <pin-id>")
617
+ .description("Register a V2 pin request")
618
+ .requiredOption("-o, --owner-id <owner>", "Owner id")
619
+ .requiredOption("-c, --cid <cid>", "CID")
620
+ .option("-i, --initial-status <status>", "Initial lifecycle status")
621
+ .option("-m, --metadata <json>", "Metadata JSON")
622
+ .action((pinId, opts) => {
623
+ const db = _dbFromCtx(ipfs);
624
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
625
+ console.log(
626
+ JSON.stringify(
627
+ registerPinV2(db, {
628
+ pinId,
629
+ ownerId: opts.ownerId,
630
+ cid: opts.cid,
631
+ initialStatus: opts.initialStatus,
632
+ metadata,
633
+ }),
634
+ null,
635
+ 2,
636
+ ),
637
+ );
638
+ });
639
+ ipfs
640
+ .command("pin-v2 <pin-id>")
641
+ .description("Show a V2 pin record")
642
+ .action((id) => {
643
+ const out = getPinV2(id);
644
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
645
+ });
646
+ ipfs
647
+ .command("set-pin-status-v2 <pin-id> <status>")
648
+ .option("-r, --reason <reason>")
649
+ .option("-m, --metadata <json>")
650
+ .description("Set V2 pin lifecycle status")
651
+ .action((id, status, opts) => {
652
+ const db = _dbFromCtx(ipfs);
653
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
654
+ console.log(
655
+ JSON.stringify(
656
+ setPinStatusV2(db, id, status, {
657
+ reason: opts.reason,
658
+ metadata,
659
+ }),
660
+ null,
661
+ 2,
662
+ ),
663
+ );
664
+ });
665
+ ipfs
666
+ .command("confirm-pin <pin-id>")
667
+ .option("-r, --reason <reason>")
668
+ .description("Confirm a V2 pin (pending -> pinned)")
669
+ .action((id, opts) => {
670
+ const db = _dbFromCtx(ipfs);
671
+ console.log(JSON.stringify(confirmPin(db, id, opts.reason), null, 2));
672
+ });
673
+ ipfs
674
+ .command("fail-pin <pin-id>")
675
+ .option("-r, --reason <reason>")
676
+ .description("Fail a V2 pin")
677
+ .action((id, opts) => {
678
+ const db = _dbFromCtx(ipfs);
679
+ console.log(JSON.stringify(failPin(db, id, opts.reason), null, 2));
680
+ });
681
+ ipfs
682
+ .command("unpin-v2 <pin-id>")
683
+ .option("-r, --reason <reason>")
684
+ .description("Unpin a V2 pin (terminal)")
685
+ .action((id, opts) => {
686
+ const db = _dbFromCtx(ipfs);
687
+ console.log(JSON.stringify(unpinV2(db, id, opts.reason), null, 2));
688
+ });
689
+
690
+ ipfs
691
+ .command("auto-offline-stale-gateways")
692
+ .description("Auto-flip stale ACTIVE/DEGRADED V2 gateways to OFFLINE")
693
+ .action(() => {
694
+ const db = _dbFromCtx(ipfs);
695
+ console.log(JSON.stringify(autoOfflineStaleGateways(db), null, 2));
696
+ });
697
+ ipfs
698
+ .command("auto-fail-stale-pending-pins")
699
+ .description("Auto-flip stale PENDING V2 pins to FAILED")
700
+ .action(() => {
701
+ const db = _dbFromCtx(ipfs);
702
+ console.log(JSON.stringify(autoFailStalePendingPins(db), null, 2));
703
+ });
704
+ ipfs
705
+ .command("stats-v2")
706
+ .description("V2 IPFS stats (counts by state + config)")
707
+ .action(() => console.log(JSON.stringify(getIpfsStatsV2(), null, 2)));
708
+
391
709
  program.addCommand(ipfs);
392
710
  }