chainlesschain 0.81.0 → 0.143.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.
- package/bin/chainlesschain.js +0 -0
- package/package.json +1 -1
- package/src/commands/a2a.js +62 -0
- package/src/commands/activitypub.js +61 -0
- package/src/commands/agent-network.js +254 -1
- package/src/commands/agent.js +117 -0
- package/src/commands/audit.js +302 -0
- package/src/commands/automation.js +271 -1
- package/src/commands/bi.js +61 -0
- package/src/commands/bm25.js +78 -0
- package/src/commands/browse.js +64 -0
- package/src/commands/ccron.js +78 -0
- package/src/commands/codegen.js +224 -0
- package/src/commands/collab.js +341 -0
- package/src/commands/compliance.js +1075 -0
- package/src/commands/compt.js +78 -0
- package/src/commands/consol.js +231 -0
- package/src/commands/cowork.js +263 -0
- package/src/commands/crosschain.js +62 -0
- package/src/commands/dao.js +62 -0
- package/src/commands/dbevo.js +284 -0
- package/src/commands/dev.js +252 -0
- package/src/commands/did.js +358 -0
- package/src/commands/dlp.js +61 -0
- package/src/commands/economy.js +56 -0
- package/src/commands/encrypt.js +341 -0
- package/src/commands/evolution.js +56 -0
- package/src/commands/evomap.js +61 -0
- package/src/commands/export.js +256 -1
- package/src/commands/fflag.js +178 -0
- package/src/commands/fusion.js +258 -0
- package/src/commands/git.js +45 -0
- package/src/commands/governance.js +325 -0
- package/src/commands/hardening.js +411 -0
- package/src/commands/hmemory.js +56 -0
- package/src/commands/hook.js +148 -0
- package/src/commands/import.js +252 -0
- package/src/commands/incentive.js +322 -0
- package/src/commands/inference.js +42 -0
- package/src/commands/infra.js +244 -0
- package/src/commands/instinct.js +260 -0
- package/src/commands/ipfs.js +318 -0
- package/src/commands/itbudget.js +45 -0
- package/src/commands/kg.js +387 -0
- package/src/commands/llm.js +263 -0
- package/src/commands/lowcode.js +44 -0
- package/src/commands/matrix.js +62 -0
- package/src/commands/mcp.js +221 -0
- package/src/commands/mcpscaf.js +41 -0
- package/src/commands/meminj.js +41 -0
- package/src/commands/memory.js +248 -0
- package/src/commands/multimodal.js +296 -0
- package/src/commands/nlprog.js +356 -0
- package/src/commands/nostr.js +62 -0
- package/src/commands/note.js +244 -0
- package/src/commands/ops.js +354 -0
- package/src/commands/orchestrate.js +166 -0
- package/src/commands/orchgov.js +45 -0
- package/src/commands/org.js +277 -0
- package/src/commands/p2p.js +390 -0
- package/src/commands/pdfp.js +78 -0
- package/src/commands/perception.js +290 -0
- package/src/commands/perf.js +39 -0
- package/src/commands/perm.js +45 -0
- package/src/commands/permmem.js +251 -0
- package/src/commands/pipeline.js +57 -1
- package/src/commands/planmode.js +45 -0
- package/src/commands/plugin-ecosystem.js +273 -0
- package/src/commands/pqc.js +393 -0
- package/src/commands/promcomp.js +82 -0
- package/src/commands/quantization.js +351 -0
- package/src/commands/rcache.js +271 -0
- package/src/commands/recommend.js +382 -0
- package/src/commands/runtime.js +307 -0
- package/src/commands/scim.js +262 -0
- package/src/commands/seshhook.js +41 -0
- package/src/commands/seshsearch.js +41 -0
- package/src/commands/seshtail.js +41 -0
- package/src/commands/seshu.js +41 -0
- package/src/commands/session.js +258 -0
- package/src/commands/sganal.js +78 -0
- package/src/commands/siem.js +40 -0
- package/src/commands/skill.js +267 -1
- package/src/commands/slotfill.js +41 -0
- package/src/commands/social.js +290 -0
- package/src/commands/sso.js +186 -1
- package/src/commands/svccont.js +45 -0
- package/src/commands/sync.js +256 -0
- package/src/commands/tech.js +338 -0
- package/src/commands/tenant.js +351 -0
- package/src/commands/tms.js +45 -0
- package/src/commands/tokens.js +269 -0
- package/src/commands/topiccls.js +45 -0
- package/src/commands/trust.js +249 -0
- package/src/commands/uprof.js +45 -0
- package/src/commands/vcheck.js +78 -0
- package/src/commands/wallet.js +277 -0
- package/src/commands/webfetch.js +41 -0
- package/src/commands/workflow.js +171 -0
- package/src/commands/zkp.js +62 -0
- package/src/harness/prompt-compressor.js +331 -0
- package/src/index.js +65 -1
- package/src/lib/a2a-protocol.js +105 -0
- package/src/lib/activitypub-bridge.js +105 -0
- package/src/lib/agent-coordinator.js +325 -0
- package/src/lib/agent-economy.js +105 -0
- package/src/lib/agent-network.js +387 -0
- package/src/lib/agent-router.js +395 -0
- package/src/lib/aiops.js +478 -0
- package/src/lib/app-builder.js +105 -0
- package/src/lib/audit-logger.js +379 -0
- package/src/lib/automation-engine.js +330 -0
- package/src/lib/autonomous-agent.js +105 -0
- package/src/lib/autonomous-developer.js +350 -0
- package/src/lib/bi-engine.js +105 -0
- package/src/lib/bm25-search.js +81 -0
- package/src/lib/browser-automation.js +105 -0
- package/src/lib/code-agent.js +323 -0
- package/src/lib/collaboration-governance.js +364 -0
- package/src/lib/community-governance.js +436 -0
- package/src/lib/compliance-framework-reporter.js +105 -0
- package/src/lib/compliance-manager.js +434 -0
- package/src/lib/compression-telemetry.js +81 -0
- package/src/lib/content-recommendation.js +469 -0
- package/src/lib/content-recommender.js +105 -0
- package/src/lib/cowork-cron.js +81 -0
- package/src/lib/cowork-task-runner.js +105 -0
- package/src/lib/cross-chain.js +105 -0
- package/src/lib/crypto-manager.js +350 -0
- package/src/lib/dao-governance.js +105 -0
- package/src/lib/dbevo.js +338 -0
- package/src/lib/decentral-infra.js +340 -0
- package/src/lib/did-manager.js +367 -0
- package/src/lib/dlp-engine.js +105 -0
- package/src/lib/evolution-system.js +105 -0
- package/src/lib/evomap-manager.js +105 -0
- package/src/lib/execution-backend.js +105 -0
- package/src/lib/feature-flags.js +85 -0
- package/src/lib/git-integration.js +105 -0
- package/src/lib/hardening-manager.js +348 -0
- package/src/lib/hierarchical-memory.js +105 -0
- package/src/lib/hook-manager.js +380 -0
- package/src/lib/inference-network.js +105 -0
- package/src/lib/instinct-manager.js +332 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/iteration-budget.js +105 -0
- package/src/lib/knowledge-exporter.js +381 -0
- package/src/lib/knowledge-graph.js +432 -0
- package/src/lib/knowledge-importer.js +379 -0
- package/src/lib/llm-providers.js +391 -0
- package/src/lib/matrix-bridge.js +105 -0
- package/src/lib/mcp-registry.js +333 -0
- package/src/lib/mcp-scaffold.js +81 -0
- package/src/lib/memory-injection.js +81 -0
- package/src/lib/memory-manager.js +330 -0
- package/src/lib/multimodal.js +346 -0
- package/src/lib/nl-programming.js +343 -0
- package/src/lib/nostr-bridge.js +105 -0
- package/src/lib/note-versioning.js +327 -0
- package/src/lib/orchestrator.js +105 -0
- package/src/lib/org-manager.js +323 -0
- package/src/lib/p2p-manager.js +387 -0
- package/src/lib/pdf-parser.js +81 -0
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +109 -1
- package/src/lib/permanent-memory.js +320 -0
- package/src/lib/permission-engine.js +81 -0
- package/src/lib/pipeline-orchestrator.js +105 -0
- package/src/lib/plan-mode.js +81 -0
- package/src/lib/plugin-ecosystem.js +377 -0
- package/src/lib/pqc-manager.js +368 -0
- package/src/lib/prompt-compressor.js +1 -10
- package/src/lib/protocol-fusion.js +417 -0
- package/src/lib/quantization.js +325 -0
- package/src/lib/response-cache.js +327 -0
- package/src/lib/scim-manager.js +329 -0
- package/src/lib/service-container.js +81 -0
- package/src/lib/session-consolidator.js +105 -0
- package/src/lib/session-hooks.js +81 -0
- package/src/lib/session-manager.js +329 -0
- package/src/lib/session-search.js +81 -0
- package/src/lib/session-tail.js +81 -0
- package/src/lib/session-usage.js +83 -0
- package/src/lib/siem-exporter.js +105 -0
- package/src/lib/skill-loader.js +377 -0
- package/src/lib/slot-filler.js +81 -0
- package/src/lib/social-graph-analytics.js +81 -0
- package/src/lib/social-graph.js +81 -0
- package/src/lib/social-manager.js +326 -0
- package/src/lib/sso-manager.js +332 -0
- package/src/lib/sub-agent-registry.js +110 -0
- package/src/lib/sync-manager.js +326 -0
- package/src/lib/task-model-selector.js +81 -0
- package/src/lib/tech-learning-engine.js +369 -0
- package/src/lib/tenant-saas.js +460 -0
- package/src/lib/threat-intel.js +335 -0
- package/src/lib/todo-manager.js +105 -0
- package/src/lib/token-incentive.js +293 -0
- package/src/lib/token-tracker.js +329 -0
- package/src/lib/topic-classifier.js +105 -0
- package/src/lib/trust-security.js +390 -0
- package/src/lib/ueba.js +389 -0
- package/src/lib/universal-runtime.js +325 -0
- package/src/lib/user-profile.js +81 -0
- package/src/lib/version-checker.js +81 -0
- package/src/lib/wallet-manager.js +326 -0
- package/src/lib/web-fetch.js +81 -0
- package/src/lib/workflow-engine.js +322 -0
- package/src/lib/zkp-engine.js +105 -0
package/src/commands/org.js
CHANGED
|
@@ -28,6 +28,37 @@ import {
|
|
|
28
28
|
rejectRequest,
|
|
29
29
|
getApprovals,
|
|
30
30
|
getOrgSummary,
|
|
31
|
+
ORG_MATURITY_V2,
|
|
32
|
+
MEMBER_LIFECYCLE_V2,
|
|
33
|
+
getMaxActiveOrgsPerOwnerV2,
|
|
34
|
+
setMaxActiveOrgsPerOwnerV2,
|
|
35
|
+
getMaxActiveMembersPerOrgV2,
|
|
36
|
+
setMaxActiveMembersPerOrgV2,
|
|
37
|
+
getOrgIdleMsV2,
|
|
38
|
+
setOrgIdleMsV2,
|
|
39
|
+
getInviteStaleMsV2,
|
|
40
|
+
setInviteStaleMsV2,
|
|
41
|
+
getActiveOrgCountV2,
|
|
42
|
+
getActiveMemberCountV2,
|
|
43
|
+
registerOrgV2,
|
|
44
|
+
getOrgV2,
|
|
45
|
+
listOrgsV2,
|
|
46
|
+
setOrgMaturityV2,
|
|
47
|
+
activateOrgV2,
|
|
48
|
+
suspendOrgV2,
|
|
49
|
+
archiveOrgV2,
|
|
50
|
+
touchOrgV2,
|
|
51
|
+
inviteMemberV2,
|
|
52
|
+
getMemberV2,
|
|
53
|
+
listMembersV2,
|
|
54
|
+
setMemberStatusV2,
|
|
55
|
+
activateMemberV2,
|
|
56
|
+
suspendMemberV2,
|
|
57
|
+
revokeMemberV2,
|
|
58
|
+
departMemberV2,
|
|
59
|
+
autoArchiveIdleOrgsV2,
|
|
60
|
+
autoRevokeStaleInvitesV2,
|
|
61
|
+
getOrgManagerStatsV2,
|
|
31
62
|
} from "../lib/org-manager.js";
|
|
32
63
|
|
|
33
64
|
export function registerOrgCommand(program) {
|
|
@@ -502,4 +533,250 @@ export function registerOrgCommand(program) {
|
|
|
502
533
|
process.exit(1);
|
|
503
534
|
}
|
|
504
535
|
});
|
|
536
|
+
|
|
537
|
+
/* ═══ Org V2 — in-memory maturity + member lifecycle ═══ */
|
|
538
|
+
|
|
539
|
+
org
|
|
540
|
+
.command("maturities-v2")
|
|
541
|
+
.description("List org maturity states (V2)")
|
|
542
|
+
.action(() => {
|
|
543
|
+
for (const v of Object.values(ORG_MATURITY_V2)) console.log(` ${v}`);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
org
|
|
547
|
+
.command("member-lifecycles-v2")
|
|
548
|
+
.description("List member lifecycle states (V2)")
|
|
549
|
+
.action(() => {
|
|
550
|
+
for (const v of Object.values(MEMBER_LIFECYCLE_V2)) console.log(` ${v}`);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
org
|
|
554
|
+
.command("stats-v2")
|
|
555
|
+
.description("Show V2 org/member stats")
|
|
556
|
+
.action(() => {
|
|
557
|
+
console.log(JSON.stringify(getOrgManagerStatsV2(), null, 2));
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
org
|
|
561
|
+
.command("max-active-orgs-per-owner")
|
|
562
|
+
.argument("[n]", "New cap")
|
|
563
|
+
.description("Get/set max active orgs per owner (V2)")
|
|
564
|
+
.action((n) => {
|
|
565
|
+
if (n !== undefined) setMaxActiveOrgsPerOwnerV2(n);
|
|
566
|
+
console.log(getMaxActiveOrgsPerOwnerV2());
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
org
|
|
570
|
+
.command("max-active-members-per-org")
|
|
571
|
+
.argument("[n]", "New cap")
|
|
572
|
+
.description("Get/set max active members per org (V2)")
|
|
573
|
+
.action((n) => {
|
|
574
|
+
if (n !== undefined) setMaxActiveMembersPerOrgV2(n);
|
|
575
|
+
console.log(getMaxActiveMembersPerOrgV2());
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
org
|
|
579
|
+
.command("org-idle-ms")
|
|
580
|
+
.argument("[ms]", "New idle window")
|
|
581
|
+
.description("Get/set org idle window ms (V2)")
|
|
582
|
+
.action((ms) => {
|
|
583
|
+
if (ms !== undefined) setOrgIdleMsV2(ms);
|
|
584
|
+
console.log(getOrgIdleMsV2());
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
org
|
|
588
|
+
.command("invite-stale-ms")
|
|
589
|
+
.argument("[ms]", "New invite stale window")
|
|
590
|
+
.description("Get/set invite stale window ms (V2)")
|
|
591
|
+
.action((ms) => {
|
|
592
|
+
if (ms !== undefined) setInviteStaleMsV2(ms);
|
|
593
|
+
console.log(getInviteStaleMsV2());
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
org
|
|
597
|
+
.command("active-org-count-v2 <owner>")
|
|
598
|
+
.description("Count active orgs for owner (V2)")
|
|
599
|
+
.action((owner) => {
|
|
600
|
+
console.log(getActiveOrgCountV2(owner));
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
org
|
|
604
|
+
.command("active-member-count-v2 <orgId>")
|
|
605
|
+
.description("Count active members for org (V2)")
|
|
606
|
+
.action((orgId) => {
|
|
607
|
+
console.log(getActiveMemberCountV2(orgId));
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
org
|
|
611
|
+
.command("register-org-v2 <id>")
|
|
612
|
+
.requiredOption("-o, --owner <owner>", "Owner")
|
|
613
|
+
.requiredOption("-n, --name <name>", "Org name")
|
|
614
|
+
.description("Register a new provisional org (V2)")
|
|
615
|
+
.action((id, opts) => {
|
|
616
|
+
console.log(
|
|
617
|
+
JSON.stringify(
|
|
618
|
+
registerOrgV2(id, { owner: opts.owner, name: opts.name }),
|
|
619
|
+
null,
|
|
620
|
+
2,
|
|
621
|
+
),
|
|
622
|
+
);
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
org
|
|
626
|
+
.command("org-v2 <id>")
|
|
627
|
+
.description("Show org by id (V2)")
|
|
628
|
+
.action((id) => {
|
|
629
|
+
const o = getOrgV2(id);
|
|
630
|
+
if (!o) {
|
|
631
|
+
console.error(`org ${id} not found`);
|
|
632
|
+
process.exit(1);
|
|
633
|
+
}
|
|
634
|
+
console.log(JSON.stringify(o, null, 2));
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
org
|
|
638
|
+
.command("list-orgs-v2")
|
|
639
|
+
.option("-o, --owner <owner>", "Filter by owner")
|
|
640
|
+
.option("-m, --maturity <m>", "Filter by maturity")
|
|
641
|
+
.description("List orgs (V2)")
|
|
642
|
+
.action((opts) => {
|
|
643
|
+
console.log(
|
|
644
|
+
JSON.stringify(
|
|
645
|
+
listOrgsV2({ owner: opts.owner, maturity: opts.maturity }),
|
|
646
|
+
null,
|
|
647
|
+
2,
|
|
648
|
+
),
|
|
649
|
+
);
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
org
|
|
653
|
+
.command("set-org-maturity-v2 <id> <next>")
|
|
654
|
+
.description("Transition org maturity (V2)")
|
|
655
|
+
.action((id, next) => {
|
|
656
|
+
console.log(JSON.stringify(setOrgMaturityV2(id, next), null, 2));
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
org
|
|
660
|
+
.command("activate-org-v2 <id>")
|
|
661
|
+
.description("Activate org (V2)")
|
|
662
|
+
.action((id) => {
|
|
663
|
+
console.log(JSON.stringify(activateOrgV2(id), null, 2));
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
org
|
|
667
|
+
.command("suspend-org-v2 <id>")
|
|
668
|
+
.description("Suspend org (V2)")
|
|
669
|
+
.action((id) => {
|
|
670
|
+
console.log(JSON.stringify(suspendOrgV2(id), null, 2));
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
org
|
|
674
|
+
.command("archive-org-v2 <id>")
|
|
675
|
+
.description("Archive org terminally (V2)")
|
|
676
|
+
.action((id) => {
|
|
677
|
+
console.log(JSON.stringify(archiveOrgV2(id), null, 2));
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
org
|
|
681
|
+
.command("touch-org-v2 <id>")
|
|
682
|
+
.description("Update org lastSeenAt (V2)")
|
|
683
|
+
.action((id) => {
|
|
684
|
+
console.log(JSON.stringify(touchOrgV2(id), null, 2));
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
org
|
|
688
|
+
.command("invite-member-v2 <id>")
|
|
689
|
+
.requiredOption("-o, --org <orgId>", "Org id")
|
|
690
|
+
.requiredOption("-u, --user <userId>", "User id")
|
|
691
|
+
.option("-r, --role <role>", "Role", "member")
|
|
692
|
+
.description("Invite a member to an org (V2)")
|
|
693
|
+
.action((id, opts) => {
|
|
694
|
+
console.log(
|
|
695
|
+
JSON.stringify(
|
|
696
|
+
inviteMemberV2(id, {
|
|
697
|
+
orgId: opts.org,
|
|
698
|
+
userId: opts.user,
|
|
699
|
+
role: opts.role,
|
|
700
|
+
}),
|
|
701
|
+
null,
|
|
702
|
+
2,
|
|
703
|
+
),
|
|
704
|
+
);
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
org
|
|
708
|
+
.command("member-v2 <id>")
|
|
709
|
+
.description("Show member by id (V2)")
|
|
710
|
+
.action((id) => {
|
|
711
|
+
const m = getMemberV2(id);
|
|
712
|
+
if (!m) {
|
|
713
|
+
console.error(`member ${id} not found`);
|
|
714
|
+
process.exit(1);
|
|
715
|
+
}
|
|
716
|
+
console.log(JSON.stringify(m, null, 2));
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
org
|
|
720
|
+
.command("list-members-v2")
|
|
721
|
+
.option("-o, --org <orgId>", "Filter by orgId")
|
|
722
|
+
.option("-s, --status <s>", "Filter by status")
|
|
723
|
+
.description("List members (V2)")
|
|
724
|
+
.action((opts) => {
|
|
725
|
+
console.log(
|
|
726
|
+
JSON.stringify(
|
|
727
|
+
listMembersV2({ orgId: opts.org, status: opts.status }),
|
|
728
|
+
null,
|
|
729
|
+
2,
|
|
730
|
+
),
|
|
731
|
+
);
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
org
|
|
735
|
+
.command("set-member-status-v2 <id> <next>")
|
|
736
|
+
.description("Transition member status (V2)")
|
|
737
|
+
.action((id, next) => {
|
|
738
|
+
console.log(JSON.stringify(setMemberStatusV2(id, next), null, 2));
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
org
|
|
742
|
+
.command("activate-member-v2 <id>")
|
|
743
|
+
.description("Activate member (V2)")
|
|
744
|
+
.action((id) => {
|
|
745
|
+
console.log(JSON.stringify(activateMemberV2(id), null, 2));
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
org
|
|
749
|
+
.command("suspend-member-v2 <id>")
|
|
750
|
+
.description("Suspend member (V2)")
|
|
751
|
+
.action((id) => {
|
|
752
|
+
console.log(JSON.stringify(suspendMemberV2(id), null, 2));
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
org
|
|
756
|
+
.command("revoke-member-v2 <id>")
|
|
757
|
+
.description("Revoke member terminally (V2)")
|
|
758
|
+
.action((id) => {
|
|
759
|
+
console.log(JSON.stringify(revokeMemberV2(id), null, 2));
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
org
|
|
763
|
+
.command("depart-member-v2 <id>")
|
|
764
|
+
.description("Depart member terminally (V2)")
|
|
765
|
+
.action((id) => {
|
|
766
|
+
console.log(JSON.stringify(departMemberV2(id), null, 2));
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
org
|
|
770
|
+
.command("auto-archive-idle-orgs")
|
|
771
|
+
.description("Auto-archive non-provisional orgs idle past window (V2)")
|
|
772
|
+
.action(() => {
|
|
773
|
+
console.log(JSON.stringify(autoArchiveIdleOrgsV2(), null, 2));
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
org
|
|
777
|
+
.command("auto-revoke-stale-invites")
|
|
778
|
+
.description("Auto-revoke invited members stale past window (V2)")
|
|
779
|
+
.action(() => {
|
|
780
|
+
console.log(JSON.stringify(autoRevokeStaleInvitesV2(), null, 2));
|
|
781
|
+
});
|
|
505
782
|
}
|
package/src/commands/p2p.js
CHANGED
|
@@ -20,6 +20,35 @@ import {
|
|
|
20
20
|
unpairDevice,
|
|
21
21
|
generatePeerId,
|
|
22
22
|
P2PBridge,
|
|
23
|
+
PEER_MATURITY_V2,
|
|
24
|
+
MESSAGE_LIFECYCLE_V2,
|
|
25
|
+
getMaxActivePeersPerNetworkV2,
|
|
26
|
+
setMaxActivePeersPerNetworkV2,
|
|
27
|
+
getMaxPendingMessagesPerPeerV2,
|
|
28
|
+
setMaxPendingMessagesPerPeerV2,
|
|
29
|
+
getPeerIdleMsV2,
|
|
30
|
+
setPeerIdleMsV2,
|
|
31
|
+
getMessageStuckMsV2,
|
|
32
|
+
setMessageStuckMsV2,
|
|
33
|
+
registerPeerV2,
|
|
34
|
+
getPeerV2,
|
|
35
|
+
listPeersV2,
|
|
36
|
+
activatePeerV2,
|
|
37
|
+
offlinePeerV2,
|
|
38
|
+
archivePeerV2,
|
|
39
|
+
touchPeerV2,
|
|
40
|
+
createMessageV2,
|
|
41
|
+
getMessageV2,
|
|
42
|
+
listMessagesV2,
|
|
43
|
+
startMessageV2,
|
|
44
|
+
deliverMessageV2,
|
|
45
|
+
failMessageV2,
|
|
46
|
+
cancelMessageV2,
|
|
47
|
+
getActivePeerCountV2,
|
|
48
|
+
getPendingMessageCountV2,
|
|
49
|
+
autoOfflineIdlePeersV2,
|
|
50
|
+
autoFailStuckMessagesV2,
|
|
51
|
+
getP2pManagerStatsV2,
|
|
23
52
|
} from "../lib/p2p-manager.js";
|
|
24
53
|
|
|
25
54
|
export function registerP2pCommand(program) {
|
|
@@ -271,4 +300,365 @@ export function registerP2pCommand(program) {
|
|
|
271
300
|
process.exit(1);
|
|
272
301
|
}
|
|
273
302
|
});
|
|
303
|
+
|
|
304
|
+
// ===== V2 in-memory governance surface (no DB, no bootstrap) =====
|
|
305
|
+
|
|
306
|
+
p2p
|
|
307
|
+
.command("peer-maturities-v2")
|
|
308
|
+
.description("[V2] List peer maturity states")
|
|
309
|
+
.option("--json", "Output as JSON")
|
|
310
|
+
.action((options) => {
|
|
311
|
+
const states = Object.values(PEER_MATURITY_V2);
|
|
312
|
+
if (options.json) console.log(JSON.stringify(states, null, 2));
|
|
313
|
+
else for (const s of states) logger.log(s);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
p2p
|
|
317
|
+
.command("message-lifecycles-v2")
|
|
318
|
+
.description("[V2] List message lifecycle states")
|
|
319
|
+
.option("--json", "Output as JSON")
|
|
320
|
+
.action((options) => {
|
|
321
|
+
const states = Object.values(MESSAGE_LIFECYCLE_V2);
|
|
322
|
+
if (options.json) console.log(JSON.stringify(states, null, 2));
|
|
323
|
+
else for (const s of states) logger.log(s);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
p2p
|
|
327
|
+
.command("config-v2")
|
|
328
|
+
.description("[V2] Show governance config")
|
|
329
|
+
.option("--json", "Output as JSON")
|
|
330
|
+
.action((options) => {
|
|
331
|
+
const cfg = {
|
|
332
|
+
maxActivePeersPerNetwork: getMaxActivePeersPerNetworkV2(),
|
|
333
|
+
maxPendingMessagesPerPeer: getMaxPendingMessagesPerPeerV2(),
|
|
334
|
+
peerIdleMs: getPeerIdleMsV2(),
|
|
335
|
+
messageStuckMs: getMessageStuckMsV2(),
|
|
336
|
+
};
|
|
337
|
+
if (options.json) console.log(JSON.stringify(cfg, null, 2));
|
|
338
|
+
else for (const [k, v] of Object.entries(cfg)) logger.log(`${k}: ${v}`);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
p2p
|
|
342
|
+
.command("set-max-active-peers-per-network-v2 <n>")
|
|
343
|
+
.description("[V2] Set per-network active peer cap")
|
|
344
|
+
.action((n) => {
|
|
345
|
+
try {
|
|
346
|
+
setMaxActivePeersPerNetworkV2(Number(n));
|
|
347
|
+
logger.success(
|
|
348
|
+
`max active peers/network = ${getMaxActivePeersPerNetworkV2()}`,
|
|
349
|
+
);
|
|
350
|
+
} catch (err) {
|
|
351
|
+
logger.error(err.message);
|
|
352
|
+
process.exit(1);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
p2p
|
|
357
|
+
.command("set-max-pending-messages-per-peer-v2 <n>")
|
|
358
|
+
.description("[V2] Set per-peer pending message cap")
|
|
359
|
+
.action((n) => {
|
|
360
|
+
try {
|
|
361
|
+
setMaxPendingMessagesPerPeerV2(Number(n));
|
|
362
|
+
logger.success(
|
|
363
|
+
`max pending messages/peer = ${getMaxPendingMessagesPerPeerV2()}`,
|
|
364
|
+
);
|
|
365
|
+
} catch (err) {
|
|
366
|
+
logger.error(err.message);
|
|
367
|
+
process.exit(1);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
p2p
|
|
372
|
+
.command("set-peer-idle-ms-v2 <ms>")
|
|
373
|
+
.description("[V2] Set peer idle threshold (ms)")
|
|
374
|
+
.action((ms) => {
|
|
375
|
+
try {
|
|
376
|
+
setPeerIdleMsV2(Number(ms));
|
|
377
|
+
logger.success(`peer idle ms = ${getPeerIdleMsV2()}`);
|
|
378
|
+
} catch (err) {
|
|
379
|
+
logger.error(err.message);
|
|
380
|
+
process.exit(1);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
p2p
|
|
385
|
+
.command("set-message-stuck-ms-v2 <ms>")
|
|
386
|
+
.description("[V2] Set message stuck threshold (ms)")
|
|
387
|
+
.action((ms) => {
|
|
388
|
+
try {
|
|
389
|
+
setMessageStuckMsV2(Number(ms));
|
|
390
|
+
logger.success(`message stuck ms = ${getMessageStuckMsV2()}`);
|
|
391
|
+
} catch (err) {
|
|
392
|
+
logger.error(err.message);
|
|
393
|
+
process.exit(1);
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
p2p
|
|
398
|
+
.command("register-peer-v2 <id>")
|
|
399
|
+
.description("[V2] Register a peer profile (PENDING)")
|
|
400
|
+
.requiredOption("-n, --network <id>", "Network ID")
|
|
401
|
+
.option("-d, --device-name <name>", "Device name")
|
|
402
|
+
.option("-t, --device-type <type>", "Device type", "desktop")
|
|
403
|
+
.action((id, opts) => {
|
|
404
|
+
try {
|
|
405
|
+
const peer = registerPeerV2(id, {
|
|
406
|
+
networkId: opts.network,
|
|
407
|
+
deviceName: opts.deviceName,
|
|
408
|
+
deviceType: opts.deviceType,
|
|
409
|
+
});
|
|
410
|
+
logger.success(`peer ${peer.id} registered (status=${peer.status})`);
|
|
411
|
+
} catch (err) {
|
|
412
|
+
logger.error(err.message);
|
|
413
|
+
process.exit(1);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
p2p
|
|
418
|
+
.command("activate-peer-v2 <id>")
|
|
419
|
+
.description("[V2] Activate a peer (pending|offline -> active)")
|
|
420
|
+
.action((id) => {
|
|
421
|
+
try {
|
|
422
|
+
const p = activatePeerV2(id);
|
|
423
|
+
logger.success(`peer ${p.id} active`);
|
|
424
|
+
} catch (err) {
|
|
425
|
+
logger.error(err.message);
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
p2p
|
|
431
|
+
.command("offline-peer-v2 <id>")
|
|
432
|
+
.description("[V2] Mark peer offline (active -> offline)")
|
|
433
|
+
.action((id) => {
|
|
434
|
+
try {
|
|
435
|
+
const p = offlinePeerV2(id);
|
|
436
|
+
logger.success(`peer ${p.id} offline`);
|
|
437
|
+
} catch (err) {
|
|
438
|
+
logger.error(err.message);
|
|
439
|
+
process.exit(1);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
p2p
|
|
444
|
+
.command("archive-peer-v2 <id>")
|
|
445
|
+
.description("[V2] Archive peer (terminal)")
|
|
446
|
+
.action((id) => {
|
|
447
|
+
try {
|
|
448
|
+
const p = archivePeerV2(id);
|
|
449
|
+
logger.success(`peer ${p.id} archived`);
|
|
450
|
+
} catch (err) {
|
|
451
|
+
logger.error(err.message);
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
p2p
|
|
457
|
+
.command("touch-peer-v2 <id>")
|
|
458
|
+
.description("[V2] Bump peer lastSeenAt")
|
|
459
|
+
.action((id) => {
|
|
460
|
+
try {
|
|
461
|
+
const p = touchPeerV2(id);
|
|
462
|
+
logger.success(`peer ${p.id} touched`);
|
|
463
|
+
} catch (err) {
|
|
464
|
+
logger.error(err.message);
|
|
465
|
+
process.exit(1);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
p2p
|
|
470
|
+
.command("get-peer-v2 <id>")
|
|
471
|
+
.description("[V2] Show peer profile")
|
|
472
|
+
.option("--json", "Output as JSON")
|
|
473
|
+
.action((id, opts) => {
|
|
474
|
+
try {
|
|
475
|
+
const p = getPeerV2(id);
|
|
476
|
+
if (!p) {
|
|
477
|
+
logger.info("peer not found");
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (opts.json) console.log(JSON.stringify(p, null, 2));
|
|
481
|
+
else logger.log(JSON.stringify(p, null, 2));
|
|
482
|
+
} catch (err) {
|
|
483
|
+
logger.error(err.message);
|
|
484
|
+
process.exit(1);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
p2p
|
|
489
|
+
.command("list-peers-v2")
|
|
490
|
+
.description("[V2] List peer profiles")
|
|
491
|
+
.option("-n, --network <id>", "Filter by network")
|
|
492
|
+
.option("-s, --status <s>", "Filter by status")
|
|
493
|
+
.option("-t, --device-type <t>", "Filter by device type")
|
|
494
|
+
.option("--json", "Output as JSON")
|
|
495
|
+
.action((opts) => {
|
|
496
|
+
const list = listPeersV2({
|
|
497
|
+
networkId: opts.network,
|
|
498
|
+
status: opts.status,
|
|
499
|
+
deviceType: opts.deviceType,
|
|
500
|
+
});
|
|
501
|
+
if (opts.json) console.log(JSON.stringify(list, null, 2));
|
|
502
|
+
else
|
|
503
|
+
for (const p of list)
|
|
504
|
+
logger.log(`${p.id}\t${p.networkId}\t${p.status}\t${p.deviceType}`);
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
p2p
|
|
508
|
+
.command("create-message-v2 <id>")
|
|
509
|
+
.description("[V2] Create a queued V2 message")
|
|
510
|
+
.requiredOption("-p, --peer <peerId>", "Peer ID")
|
|
511
|
+
.option("-k, --kind <kind>", "Message kind", "text")
|
|
512
|
+
.action((id, opts) => {
|
|
513
|
+
try {
|
|
514
|
+
const m = createMessageV2(id, { peerId: opts.peer, kind: opts.kind });
|
|
515
|
+
logger.success(
|
|
516
|
+
`message ${m.id} queued (peer=${m.peerId} kind=${m.kind})`,
|
|
517
|
+
);
|
|
518
|
+
} catch (err) {
|
|
519
|
+
logger.error(err.message);
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
p2p
|
|
525
|
+
.command("start-message-v2 <id>")
|
|
526
|
+
.description("[V2] Mark message sending (queued -> sending)")
|
|
527
|
+
.action((id) => {
|
|
528
|
+
try {
|
|
529
|
+
const m = startMessageV2(id);
|
|
530
|
+
logger.success(`message ${m.id} sending`);
|
|
531
|
+
} catch (err) {
|
|
532
|
+
logger.error(err.message);
|
|
533
|
+
process.exit(1);
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
p2p
|
|
538
|
+
.command("deliver-message-v2 <id>")
|
|
539
|
+
.description("[V2] Mark message delivered (sending -> delivered)")
|
|
540
|
+
.action((id) => {
|
|
541
|
+
try {
|
|
542
|
+
const m = deliverMessageV2(id);
|
|
543
|
+
logger.success(`message ${m.id} delivered`);
|
|
544
|
+
} catch (err) {
|
|
545
|
+
logger.error(err.message);
|
|
546
|
+
process.exit(1);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
p2p
|
|
551
|
+
.command("fail-message-v2 <id>")
|
|
552
|
+
.description("[V2] Mark message failed (queued|sending -> failed)")
|
|
553
|
+
.action((id) => {
|
|
554
|
+
try {
|
|
555
|
+
const m = failMessageV2(id);
|
|
556
|
+
logger.success(`message ${m.id} failed`);
|
|
557
|
+
} catch (err) {
|
|
558
|
+
logger.error(err.message);
|
|
559
|
+
process.exit(1);
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
p2p
|
|
564
|
+
.command("cancel-message-v2 <id>")
|
|
565
|
+
.description("[V2] Cancel message (queued|sending -> cancelled)")
|
|
566
|
+
.action((id) => {
|
|
567
|
+
try {
|
|
568
|
+
const m = cancelMessageV2(id);
|
|
569
|
+
logger.success(`message ${m.id} cancelled`);
|
|
570
|
+
} catch (err) {
|
|
571
|
+
logger.error(err.message);
|
|
572
|
+
process.exit(1);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
p2p
|
|
577
|
+
.command("get-message-v2 <id>")
|
|
578
|
+
.description("[V2] Show message")
|
|
579
|
+
.option("--json", "Output as JSON")
|
|
580
|
+
.action((id, opts) => {
|
|
581
|
+
try {
|
|
582
|
+
const m = getMessageV2(id);
|
|
583
|
+
if (!m) {
|
|
584
|
+
logger.info("message not found");
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (opts.json) console.log(JSON.stringify(m, null, 2));
|
|
588
|
+
else logger.log(JSON.stringify(m, null, 2));
|
|
589
|
+
} catch (err) {
|
|
590
|
+
logger.error(err.message);
|
|
591
|
+
process.exit(1);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
p2p
|
|
596
|
+
.command("list-messages-v2")
|
|
597
|
+
.description("[V2] List V2 messages")
|
|
598
|
+
.option("-p, --peer <peerId>", "Filter by peer")
|
|
599
|
+
.option("-s, --status <s>", "Filter by status")
|
|
600
|
+
.option("--json", "Output as JSON")
|
|
601
|
+
.action((opts) => {
|
|
602
|
+
const list = listMessagesV2({ peerId: opts.peer, status: opts.status });
|
|
603
|
+
if (opts.json) console.log(JSON.stringify(list, null, 2));
|
|
604
|
+
else
|
|
605
|
+
for (const m of list)
|
|
606
|
+
logger.log(`${m.id}\t${m.peerId}\t${m.status}\t${m.kind}`);
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
p2p
|
|
610
|
+
.command("active-peer-count-v2")
|
|
611
|
+
.description("[V2] Count active peers (optional --network filter)")
|
|
612
|
+
.option("-n, --network <id>", "Filter by network")
|
|
613
|
+
.action((opts) => {
|
|
614
|
+
const n = getActivePeerCountV2(opts.network);
|
|
615
|
+
logger.log(String(n));
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
p2p
|
|
619
|
+
.command("pending-message-count-v2")
|
|
620
|
+
.description(
|
|
621
|
+
"[V2] Count pending messages (queued+sending) (optional --peer filter)",
|
|
622
|
+
)
|
|
623
|
+
.option("-p, --peer <peerId>", "Filter by peer")
|
|
624
|
+
.action((opts) => {
|
|
625
|
+
const n = getPendingMessageCountV2(opts.peer);
|
|
626
|
+
logger.log(String(n));
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
p2p
|
|
630
|
+
.command("auto-offline-idle-peers-v2")
|
|
631
|
+
.description("[V2] Mark idle active peers offline")
|
|
632
|
+
.option("--now <ms>", "Override current time (ms)")
|
|
633
|
+
.option("--json", "Output as JSON")
|
|
634
|
+
.action((opts) => {
|
|
635
|
+
const list = autoOfflineIdlePeersV2(
|
|
636
|
+
opts.now ? { now: Number(opts.now) } : undefined,
|
|
637
|
+
);
|
|
638
|
+
if (opts.json) console.log(JSON.stringify(list, null, 2));
|
|
639
|
+
else logger.success(`offlined ${list.length} peer(s)`);
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
p2p
|
|
643
|
+
.command("auto-fail-stuck-messages-v2")
|
|
644
|
+
.description("[V2] Fail stuck sending messages")
|
|
645
|
+
.option("--now <ms>", "Override current time (ms)")
|
|
646
|
+
.option("--json", "Output as JSON")
|
|
647
|
+
.action((opts) => {
|
|
648
|
+
const list = autoFailStuckMessagesV2(
|
|
649
|
+
opts.now ? { now: Number(opts.now) } : undefined,
|
|
650
|
+
);
|
|
651
|
+
if (opts.json) console.log(JSON.stringify(list, null, 2));
|
|
652
|
+
else logger.success(`failed ${list.length} message(s)`);
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
p2p
|
|
656
|
+
.command("stats-v2")
|
|
657
|
+
.description("[V2] Show governance stats")
|
|
658
|
+
.option("--json", "Output as JSON")
|
|
659
|
+
.action((opts) => {
|
|
660
|
+
const s = getP2pManagerStatsV2();
|
|
661
|
+
if (opts.json) console.log(JSON.stringify(s, null, 2));
|
|
662
|
+
else logger.log(JSON.stringify(s, null, 2));
|
|
663
|
+
});
|
|
274
664
|
}
|