chainlesschain 0.51.0 → 0.81.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/package.json +1 -1
- package/src/assets/web-panel/.build-hash +1 -1
- package/src/assets/web-panel/assets/{AppLayout-Rvi759IS.js → AppLayout-6SPt_8Y_.js} +1 -1
- package/src/assets/web-panel/assets/{Dashboard-DBhFxXYQ.js → Dashboard-Br7kCwKJ.js} +2 -2
- package/src/assets/web-panel/assets/Dashboard-CKeMmCoT.css +1 -0
- package/src/assets/web-panel/assets/{index-uL0cZ8N_.js → index-tN-8TosE.js} +2 -2
- package/src/assets/web-panel/index.html +2 -2
- package/src/commands/a2a.js +380 -0
- package/src/commands/agent-network.js +785 -0
- package/src/commands/automation.js +654 -0
- package/src/commands/bi.js +348 -0
- package/src/commands/crosschain.js +218 -0
- package/src/commands/dao.js +565 -0
- package/src/commands/did-v2.js +620 -0
- package/src/commands/dlp.js +341 -0
- package/src/commands/economy.js +578 -0
- package/src/commands/evolution.js +391 -0
- package/src/commands/evomap.js +394 -0
- package/src/commands/federation.js +283 -0
- package/src/commands/hmemory.js +442 -0
- package/src/commands/inference.js +318 -0
- package/src/commands/lowcode.js +356 -0
- package/src/commands/marketplace.js +256 -0
- package/src/commands/perf.js +433 -0
- package/src/commands/pipeline.js +449 -0
- package/src/commands/plugin-ecosystem.js +517 -0
- package/src/commands/privacy.js +321 -0
- package/src/commands/reputation.js +261 -0
- package/src/commands/sandbox.js +401 -0
- package/src/commands/siem.js +246 -0
- package/src/commands/sla.js +259 -0
- package/src/commands/social.js +311 -0
- package/src/commands/sso.js +798 -0
- package/src/commands/stress.js +230 -0
- package/src/commands/terraform.js +245 -0
- package/src/commands/workflow.js +320 -0
- package/src/commands/zkp.js +562 -1
- package/src/index.js +21 -0
- package/src/lib/a2a-protocol.js +451 -0
- package/src/lib/agent-economy.js +479 -0
- package/src/lib/agent-network.js +1121 -0
- package/src/lib/app-builder.js +239 -0
- package/src/lib/automation-engine.js +948 -0
- package/src/lib/bi-engine.js +338 -0
- package/src/lib/cross-chain.js +345 -0
- package/src/lib/dao-governance.js +569 -0
- package/src/lib/did-v2-manager.js +1127 -0
- package/src/lib/dlp-engine.js +389 -0
- package/src/lib/evolution-system.js +453 -0
- package/src/lib/evomap-federation.js +177 -0
- package/src/lib/evomap-governance.js +276 -0
- package/src/lib/federation-hardening.js +259 -0
- package/src/lib/hierarchical-memory.js +481 -0
- package/src/lib/inference-network.js +330 -0
- package/src/lib/perf-tuning.js +734 -0
- package/src/lib/pipeline-orchestrator.js +928 -0
- package/src/lib/plugin-ecosystem.js +1109 -0
- package/src/lib/privacy-computing.js +427 -0
- package/src/lib/reputation-optimizer.js +299 -0
- package/src/lib/sandbox-v2.js +306 -0
- package/src/lib/siem-exporter.js +333 -0
- package/src/lib/skill-marketplace.js +325 -0
- package/src/lib/sla-manager.js +275 -0
- package/src/lib/social-graph-analytics.js +707 -0
- package/src/lib/sso-manager.js +841 -0
- package/src/lib/stress-tester.js +330 -0
- package/src/lib/terraform-manager.js +363 -0
- package/src/lib/workflow-engine.js +454 -1
- package/src/lib/zkp-engine.js +523 -20
- package/src/assets/web-panel/assets/Dashboard-BS-tzGNj.css +0 -1
package/src/lib/sla-manager.js
CHANGED
|
@@ -481,4 +481,279 @@ export function _resetState() {
|
|
|
481
481
|
_metrics.clear();
|
|
482
482
|
_violations.clear();
|
|
483
483
|
_seq = 0;
|
|
484
|
+
_maxActiveSlasPerOrg = DEFAULT_MAX_ACTIVE_SLAS_PER_ORG;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* ═══════════════════════════════════════════════════════════════
|
|
488
|
+
* V2 (Phase 61) — Frozen enums + contract/violation state
|
|
489
|
+
* machines + active-per-org cap + auto-expire + stats-v2.
|
|
490
|
+
* Strictly additive on top of the legacy surface above.
|
|
491
|
+
* ═══════════════════════════════════════════════════════════════ */
|
|
492
|
+
|
|
493
|
+
export const SLA_STATUS_V2 = Object.freeze({
|
|
494
|
+
ACTIVE: "active",
|
|
495
|
+
EXPIRED: "expired",
|
|
496
|
+
TERMINATED: "terminated",
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
export const SLA_TIER_V2 = Object.freeze({
|
|
500
|
+
GOLD: "gold",
|
|
501
|
+
SILVER: "silver",
|
|
502
|
+
BRONZE: "bronze",
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
export const SLA_TERM_V2 = Object.freeze({
|
|
506
|
+
AVAILABILITY: "availability",
|
|
507
|
+
RESPONSE_TIME: "response_time",
|
|
508
|
+
THROUGHPUT: "throughput",
|
|
509
|
+
ERROR_RATE: "error_rate",
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
export const VIOLATION_SEVERITY_V2 = Object.freeze({
|
|
513
|
+
MINOR: "minor",
|
|
514
|
+
MODERATE: "moderate",
|
|
515
|
+
MAJOR: "major",
|
|
516
|
+
CRITICAL: "critical",
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
export const VIOLATION_STATUS_V2 = Object.freeze({
|
|
520
|
+
OPEN: "open",
|
|
521
|
+
ACKNOWLEDGED: "acknowledged",
|
|
522
|
+
RESOLVED: "resolved",
|
|
523
|
+
WAIVED: "waived",
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const DEFAULT_MAX_ACTIVE_SLAS_PER_ORG = 1;
|
|
527
|
+
let _maxActiveSlasPerOrg = DEFAULT_MAX_ACTIVE_SLAS_PER_ORG;
|
|
528
|
+
export const SLA_DEFAULT_MAX_ACTIVE_PER_ORG = DEFAULT_MAX_ACTIVE_SLAS_PER_ORG;
|
|
529
|
+
|
|
530
|
+
export function setMaxActiveSlasPerOrg(n) {
|
|
531
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n < 1) {
|
|
532
|
+
throw new Error("maxActiveSlasPerOrg must be a positive integer");
|
|
533
|
+
}
|
|
534
|
+
_maxActiveSlasPerOrg = Math.floor(n);
|
|
535
|
+
return _maxActiveSlasPerOrg;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export function getMaxActiveSlasPerOrg() {
|
|
539
|
+
return _maxActiveSlasPerOrg;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// Contract state machine: active → { expired, terminated }; both terminal.
|
|
543
|
+
const _contractTerminal = new Set([
|
|
544
|
+
SLA_STATUS_V2.EXPIRED,
|
|
545
|
+
SLA_STATUS_V2.TERMINATED,
|
|
546
|
+
]);
|
|
547
|
+
const _contractAllowed = new Map([
|
|
548
|
+
[
|
|
549
|
+
SLA_STATUS_V2.ACTIVE,
|
|
550
|
+
new Set([SLA_STATUS_V2.EXPIRED, SLA_STATUS_V2.TERMINATED]),
|
|
551
|
+
],
|
|
552
|
+
[SLA_STATUS_V2.EXPIRED, new Set([])],
|
|
553
|
+
[SLA_STATUS_V2.TERMINATED, new Set([])],
|
|
554
|
+
]);
|
|
555
|
+
|
|
556
|
+
// Violation state machine: open → { acknowledged, resolved, waived };
|
|
557
|
+
// acknowledged → { resolved, waived }; resolved/waived terminal.
|
|
558
|
+
const _violationTerminal = new Set([
|
|
559
|
+
VIOLATION_STATUS_V2.RESOLVED,
|
|
560
|
+
VIOLATION_STATUS_V2.WAIVED,
|
|
561
|
+
]);
|
|
562
|
+
const _violationAllowed = new Map([
|
|
563
|
+
[
|
|
564
|
+
VIOLATION_STATUS_V2.OPEN,
|
|
565
|
+
new Set([
|
|
566
|
+
VIOLATION_STATUS_V2.ACKNOWLEDGED,
|
|
567
|
+
VIOLATION_STATUS_V2.RESOLVED,
|
|
568
|
+
VIOLATION_STATUS_V2.WAIVED,
|
|
569
|
+
]),
|
|
570
|
+
],
|
|
571
|
+
[
|
|
572
|
+
VIOLATION_STATUS_V2.ACKNOWLEDGED,
|
|
573
|
+
new Set([VIOLATION_STATUS_V2.RESOLVED, VIOLATION_STATUS_V2.WAIVED]),
|
|
574
|
+
],
|
|
575
|
+
[VIOLATION_STATUS_V2.RESOLVED, new Set([])],
|
|
576
|
+
[VIOLATION_STATUS_V2.WAIVED, new Set([])],
|
|
577
|
+
]);
|
|
578
|
+
|
|
579
|
+
export function getActiveSlaCountForOrg(orgId) {
|
|
580
|
+
let count = 0;
|
|
581
|
+
for (const c of _contracts.values()) {
|
|
582
|
+
if (c.orgId === orgId && c.status === SLA_STATUS_V2.ACTIVE) count++;
|
|
583
|
+
}
|
|
584
|
+
return count;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* createSLAV2 — like createSLA but enforces per-org active-contract cap
|
|
589
|
+
* and rejects unknown tier/status at the boundary. Augments stored
|
|
590
|
+
* contract with in-memory V2 fields (violationStatus doesn't apply here;
|
|
591
|
+
* see recordViolation*).
|
|
592
|
+
*/
|
|
593
|
+
export function createSLAV2(db, config = {}) {
|
|
594
|
+
const orgId = config.orgId;
|
|
595
|
+
if (!orgId) throw new Error("orgId is required");
|
|
596
|
+
|
|
597
|
+
const activeCount = getActiveSlaCountForOrg(orgId);
|
|
598
|
+
if (activeCount >= _maxActiveSlasPerOrg) {
|
|
599
|
+
throw new Error(
|
|
600
|
+
`Max active SLAs per org reached: ${activeCount}/${_maxActiveSlasPerOrg}`,
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return createSLA(db, config);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
export function setSLAStatus(db, slaId, newStatus) {
|
|
608
|
+
const contract = _contracts.get(slaId);
|
|
609
|
+
if (!contract) throw new Error(`SLA not found: ${slaId}`);
|
|
610
|
+
|
|
611
|
+
if (!Object.values(SLA_STATUS_V2).includes(newStatus)) {
|
|
612
|
+
throw new Error(`Unknown SLA status: ${newStatus}`);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const allowed = _contractAllowed.get(contract.status);
|
|
616
|
+
if (!allowed || !allowed.has(newStatus)) {
|
|
617
|
+
throw new Error(
|
|
618
|
+
`Invalid SLA status transition: ${contract.status} → ${newStatus}`,
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
contract.status = newStatus;
|
|
623
|
+
contract.updatedAt = Date.now();
|
|
624
|
+
db.prepare(
|
|
625
|
+
`UPDATE sla_contracts SET status = ?, updated_at = ? WHERE sla_id = ?`,
|
|
626
|
+
).run(contract.status, contract.updatedAt, slaId);
|
|
627
|
+
|
|
628
|
+
const { _seq: _omit, ...rest } = contract;
|
|
629
|
+
void _omit;
|
|
630
|
+
return rest;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export function expireSLA(db, slaId) {
|
|
634
|
+
return setSLAStatus(db, slaId, SLA_STATUS_V2.EXPIRED);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* autoExpireSLAs — bulk-flip ACTIVE contracts whose endDate < now to
|
|
639
|
+
* EXPIRED. Returns the list of flipped contracts.
|
|
640
|
+
*/
|
|
641
|
+
export function autoExpireSLAs(db, nowMs = Date.now()) {
|
|
642
|
+
const flipped = [];
|
|
643
|
+
for (const contract of _contracts.values()) {
|
|
644
|
+
if (contract.status === SLA_STATUS_V2.ACTIVE && contract.endDate < nowMs) {
|
|
645
|
+
contract.status = SLA_STATUS_V2.EXPIRED;
|
|
646
|
+
contract.updatedAt = nowMs;
|
|
647
|
+
db.prepare(
|
|
648
|
+
`UPDATE sla_contracts SET status = ?, updated_at = ? WHERE sla_id = ?`,
|
|
649
|
+
).run(contract.status, contract.updatedAt, contract.slaId);
|
|
650
|
+
const { _seq: _omit, ...rest } = contract;
|
|
651
|
+
void _omit;
|
|
652
|
+
flipped.push(rest);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return flipped;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
export function setViolationStatus(db, violationId, newStatus, patch = {}) {
|
|
659
|
+
const violation = _violations.get(violationId);
|
|
660
|
+
if (!violation) throw new Error(`Violation not found: ${violationId}`);
|
|
661
|
+
|
|
662
|
+
if (!Object.values(VIOLATION_STATUS_V2).includes(newStatus)) {
|
|
663
|
+
throw new Error(`Unknown violation status: ${newStatus}`);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const current = violation.v2Status || VIOLATION_STATUS_V2.OPEN;
|
|
667
|
+
const allowed = _violationAllowed.get(current);
|
|
668
|
+
if (!allowed || !allowed.has(newStatus)) {
|
|
669
|
+
throw new Error(
|
|
670
|
+
`Invalid violation status transition: ${current} → ${newStatus}`,
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
violation.v2Status = newStatus;
|
|
675
|
+
if (typeof patch.note === "string") {
|
|
676
|
+
violation.note = patch.note;
|
|
677
|
+
}
|
|
678
|
+
if (_violationTerminal.has(newStatus)) {
|
|
679
|
+
violation.resolvedAt = Date.now();
|
|
680
|
+
db.prepare(
|
|
681
|
+
`UPDATE sla_violations SET resolved_at = ? WHERE violation_id = ?`,
|
|
682
|
+
).run(violation.resolvedAt, violationId);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return { ...violation };
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export function acknowledgeViolation(db, violationId, note) {
|
|
689
|
+
return setViolationStatus(db, violationId, VIOLATION_STATUS_V2.ACKNOWLEDGED, {
|
|
690
|
+
note,
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
export function resolveViolation(db, violationId, note) {
|
|
695
|
+
return setViolationStatus(db, violationId, VIOLATION_STATUS_V2.RESOLVED, {
|
|
696
|
+
note,
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
export function waiveViolation(db, violationId, note) {
|
|
701
|
+
return setViolationStatus(db, violationId, VIOLATION_STATUS_V2.WAIVED, {
|
|
702
|
+
note,
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export function getSLAStatsV2() {
|
|
707
|
+
const contracts = [..._contracts.values()];
|
|
708
|
+
const violations = [..._violations.values()];
|
|
709
|
+
|
|
710
|
+
const byStatus = {};
|
|
711
|
+
for (const s of Object.values(SLA_STATUS_V2)) byStatus[s] = 0;
|
|
712
|
+
for (const c of contracts) byStatus[c.status] = (byStatus[c.status] || 0) + 1;
|
|
713
|
+
|
|
714
|
+
const byTier = {};
|
|
715
|
+
for (const t of Object.values(SLA_TIER_V2)) byTier[t] = 0;
|
|
716
|
+
for (const c of contracts) byTier[c.tier] = (byTier[c.tier] || 0) + 1;
|
|
717
|
+
|
|
718
|
+
const bySeverity = {};
|
|
719
|
+
for (const s of Object.values(VIOLATION_SEVERITY_V2)) bySeverity[s] = 0;
|
|
720
|
+
for (const v of violations)
|
|
721
|
+
bySeverity[v.severity] = (bySeverity[v.severity] || 0) + 1;
|
|
722
|
+
|
|
723
|
+
const byTerm = {};
|
|
724
|
+
for (const t of Object.values(SLA_TERM_V2)) byTerm[t] = 0;
|
|
725
|
+
for (const v of violations) byTerm[v.term] = (byTerm[v.term] || 0) + 1;
|
|
726
|
+
|
|
727
|
+
const byViolationStatus = {};
|
|
728
|
+
for (const s of Object.values(VIOLATION_STATUS_V2)) byViolationStatus[s] = 0;
|
|
729
|
+
for (const v of violations) {
|
|
730
|
+
const s = v.v2Status || VIOLATION_STATUS_V2.OPEN;
|
|
731
|
+
byViolationStatus[s] = (byViolationStatus[s] || 0) + 1;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
let totalCompensation = 0;
|
|
735
|
+
for (const v of violations) {
|
|
736
|
+
if (v.compensationAmount) totalCompensation += v.compensationAmount;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
const activeOrgs = new Set();
|
|
740
|
+
for (const c of contracts) {
|
|
741
|
+
if (c.status === SLA_STATUS_V2.ACTIVE) activeOrgs.add(c.orgId);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
return {
|
|
745
|
+
totalContracts: contracts.length,
|
|
746
|
+
activeContracts: byStatus[SLA_STATUS_V2.ACTIVE] || 0,
|
|
747
|
+
activeOrgs: activeOrgs.size,
|
|
748
|
+
maxActiveSlasPerOrg: _maxActiveSlasPerOrg,
|
|
749
|
+
byStatus,
|
|
750
|
+
byTier,
|
|
751
|
+
violations: {
|
|
752
|
+
total: violations.length,
|
|
753
|
+
byTerm,
|
|
754
|
+
bySeverity,
|
|
755
|
+
byStatus: byViolationStatus,
|
|
756
|
+
totalCompensation: Number(totalCompensation.toFixed(4)),
|
|
757
|
+
},
|
|
758
|
+
};
|
|
484
759
|
}
|