chainlesschain 0.132.0 → 0.145.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/commands/a2a.js +230 -0
- package/src/commands/activitypub.js +191 -0
- package/src/commands/agent.js +601 -0
- package/src/commands/audit.js +206 -0
- package/src/commands/bi.js +186 -0
- package/src/commands/bm25.js +162 -0
- package/src/commands/browse.js +225 -0
- package/src/commands/ccron.js +178 -0
- package/src/commands/chat.js +207 -0
- package/src/commands/compliance.js +420 -0
- package/src/commands/compt.js +176 -0
- package/src/commands/consol.js +237 -0
- package/src/commands/cowork.js +588 -0
- package/src/commands/crosschain.js +216 -0
- package/src/commands/dao.js +216 -0
- package/src/commands/dlp.js +206 -0
- package/src/commands/economy.js +211 -0
- package/src/commands/evolution.js +209 -0
- package/src/commands/evomap.js +216 -0
- package/src/commands/fflag.js +230 -0
- package/src/commands/git.js +185 -0
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +210 -0
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +178 -0
- package/src/commands/itbudget.js +161 -0
- package/src/commands/kg.js +206 -0
- package/src/commands/lowcode.js +201 -0
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +214 -0
- package/src/commands/mcpscaf.js +153 -0
- package/src/commands/meminj.js +153 -0
- package/src/commands/nostr.js +213 -0
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +156 -0
- package/src/commands/pdfp.js +160 -0
- package/src/commands/perf.js +176 -0
- package/src/commands/perm.js +156 -0
- package/src/commands/pipeline.js +211 -0
- package/src/commands/planmode.js +154 -0
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +166 -0
- package/src/commands/recommend.js +185 -0
- package/src/commands/reputation.js +208 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/seshhook.js +153 -0
- package/src/commands/seshsearch.js +149 -0
- package/src/commands/seshtail.js +152 -0
- package/src/commands/seshu.js +160 -0
- package/src/commands/sganal.js +172 -0
- package/src/commands/siem.js +207 -0
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +154 -0
- package/src/commands/social.js +159 -0
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +157 -0
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +183 -0
- package/src/commands/topiccls.js +158 -0
- package/src/commands/uprof.js +154 -0
- package/src/commands/vcheck.js +172 -0
- package/src/commands/webfetch.js +150 -0
- package/src/commands/zkp.js +218 -0
- package/src/harness/prompt-compressor.js +331 -0
- package/src/index.js +101 -1
- package/src/lib/a2a-protocol.js +373 -0
- package/src/lib/activitypub-bridge.js +343 -0
- package/src/lib/agent-economy.js +358 -0
- package/src/lib/app-builder.js +338 -0
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/autonomous-agent.js +341 -0
- package/src/lib/bi-engine.js +339 -0
- package/src/lib/bm25-search.js +333 -0
- package/src/lib/browser-automation.js +352 -0
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/compliance-framework-reporter.js +359 -0
- package/src/lib/compliance-manager.js +330 -0
- package/src/lib/compression-telemetry.js +333 -0
- package/src/lib/content-recommender.js +370 -0
- package/src/lib/cowork-cron.js +330 -0
- package/src/lib/cowork-learning.js +333 -0
- package/src/lib/cowork-task-runner.js +362 -0
- package/src/lib/cowork-workflow.js +327 -0
- package/src/lib/cross-chain.js +365 -0
- package/src/lib/dao-governance.js +339 -0
- package/src/lib/dlp-engine.js +343 -0
- package/src/lib/evolution-system.js +336 -0
- package/src/lib/evomap-manager.js +339 -0
- package/src/lib/execution-backend.js +351 -0
- package/src/lib/feature-flags.js +330 -0
- package/src/lib/git-integration.js +343 -0
- package/src/lib/hardening-manager.js +341 -0
- package/src/lib/hierarchical-memory.js +341 -0
- package/src/lib/inference-network.js +362 -0
- package/src/lib/iteration-budget.js +357 -0
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/matrix-bridge.js +339 -0
- package/src/lib/mcp-scaffold.js +345 -0
- package/src/lib/memory-injection.js +320 -0
- package/src/lib/nostr-bridge.js +342 -0
- package/src/lib/orchestrator.js +350 -0
- package/src/lib/pdf-parser.js +330 -0
- package/src/lib/perf-tuning.js +364 -0
- package/src/lib/permission-engine.js +319 -0
- package/src/lib/pipeline-orchestrator.js +345 -0
- package/src/lib/plan-mode.js +328 -0
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/prompt-compressor.js +1 -10
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/service-container.js +342 -0
- package/src/lib/session-consolidator.js +352 -0
- package/src/lib/session-hooks.js +340 -0
- package/src/lib/session-search.js +334 -0
- package/src/lib/session-tail.js +320 -0
- package/src/lib/session-usage.js +329 -0
- package/src/lib/siem-exporter.js +352 -0
- package/src/lib/skill-marketplace.js +345 -0
- package/src/lib/sla-manager.js +341 -0
- package/src/lib/slot-filler.js +333 -0
- package/src/lib/social-graph-analytics.js +327 -0
- package/src/lib/social-graph.js +304 -0
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +359 -0
- package/src/lib/task-model-selector.js +333 -0
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/todo-manager.js +339 -0
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/topic-classifier.js +353 -0
- package/src/lib/user-profile.js +325 -0
- package/src/lib/version-checker.js +335 -0
- package/src/lib/web-fetch.js +322 -0
- package/src/lib/zkp-engine.js +342 -0
|
@@ -465,3 +465,365 @@ function _appendHistory(cwd, entry, userMessage) {
|
|
|
465
465
|
// Best-effort — don't fail the task for history write errors
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
+
|
|
469
|
+
// ===== V2 Surface: Cowork Task Runner governance overlay (CLI v0.139.0) =====
|
|
470
|
+
export const RUNNER_PROFILE_MATURITY_V2 = Object.freeze({
|
|
471
|
+
PENDING: "pending",
|
|
472
|
+
ACTIVE: "active",
|
|
473
|
+
PAUSED: "paused",
|
|
474
|
+
RETIRED: "retired",
|
|
475
|
+
});
|
|
476
|
+
export const RUNNER_EXEC_LIFECYCLE_V2 = Object.freeze({
|
|
477
|
+
QUEUED: "queued",
|
|
478
|
+
RUNNING: "running",
|
|
479
|
+
SUCCEEDED: "succeeded",
|
|
480
|
+
FAILED: "failed",
|
|
481
|
+
CANCELLED: "cancelled",
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
const _rpTrans = new Map([
|
|
485
|
+
[
|
|
486
|
+
RUNNER_PROFILE_MATURITY_V2.PENDING,
|
|
487
|
+
new Set([
|
|
488
|
+
RUNNER_PROFILE_MATURITY_V2.ACTIVE,
|
|
489
|
+
RUNNER_PROFILE_MATURITY_V2.RETIRED,
|
|
490
|
+
]),
|
|
491
|
+
],
|
|
492
|
+
[
|
|
493
|
+
RUNNER_PROFILE_MATURITY_V2.ACTIVE,
|
|
494
|
+
new Set([
|
|
495
|
+
RUNNER_PROFILE_MATURITY_V2.PAUSED,
|
|
496
|
+
RUNNER_PROFILE_MATURITY_V2.RETIRED,
|
|
497
|
+
]),
|
|
498
|
+
],
|
|
499
|
+
[
|
|
500
|
+
RUNNER_PROFILE_MATURITY_V2.PAUSED,
|
|
501
|
+
new Set([
|
|
502
|
+
RUNNER_PROFILE_MATURITY_V2.ACTIVE,
|
|
503
|
+
RUNNER_PROFILE_MATURITY_V2.RETIRED,
|
|
504
|
+
]),
|
|
505
|
+
],
|
|
506
|
+
[RUNNER_PROFILE_MATURITY_V2.RETIRED, new Set()],
|
|
507
|
+
]);
|
|
508
|
+
const _rpTerminal = new Set([RUNNER_PROFILE_MATURITY_V2.RETIRED]);
|
|
509
|
+
const _reTrans = new Map([
|
|
510
|
+
[
|
|
511
|
+
RUNNER_EXEC_LIFECYCLE_V2.QUEUED,
|
|
512
|
+
new Set([
|
|
513
|
+
RUNNER_EXEC_LIFECYCLE_V2.RUNNING,
|
|
514
|
+
RUNNER_EXEC_LIFECYCLE_V2.CANCELLED,
|
|
515
|
+
]),
|
|
516
|
+
],
|
|
517
|
+
[
|
|
518
|
+
RUNNER_EXEC_LIFECYCLE_V2.RUNNING,
|
|
519
|
+
new Set([
|
|
520
|
+
RUNNER_EXEC_LIFECYCLE_V2.SUCCEEDED,
|
|
521
|
+
RUNNER_EXEC_LIFECYCLE_V2.FAILED,
|
|
522
|
+
RUNNER_EXEC_LIFECYCLE_V2.CANCELLED,
|
|
523
|
+
]),
|
|
524
|
+
],
|
|
525
|
+
[RUNNER_EXEC_LIFECYCLE_V2.SUCCEEDED, new Set()],
|
|
526
|
+
[RUNNER_EXEC_LIFECYCLE_V2.FAILED, new Set()],
|
|
527
|
+
[RUNNER_EXEC_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
528
|
+
]);
|
|
529
|
+
|
|
530
|
+
const _rpsV2 = new Map();
|
|
531
|
+
const _resV2 = new Map();
|
|
532
|
+
let _rpMaxActivePerOwner = 8;
|
|
533
|
+
let _rpMaxPendingExecsPerProfile = 15;
|
|
534
|
+
let _rpIdleMs = 14 * 24 * 60 * 60 * 1000;
|
|
535
|
+
let _reStuckMs = 20 * 60 * 1000;
|
|
536
|
+
|
|
537
|
+
function _rpPos(n, lbl) {
|
|
538
|
+
const v = Math.floor(Number(n));
|
|
539
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
540
|
+
throw new Error(`${lbl} must be positive integer`);
|
|
541
|
+
return v;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export function setMaxActiveRunnerProfilesPerOwnerV2(n) {
|
|
545
|
+
_rpMaxActivePerOwner = _rpPos(n, "maxActiveRunnerProfilesPerOwner");
|
|
546
|
+
}
|
|
547
|
+
export function getMaxActiveRunnerProfilesPerOwnerV2() {
|
|
548
|
+
return _rpMaxActivePerOwner;
|
|
549
|
+
}
|
|
550
|
+
export function setMaxPendingRunnerExecsPerProfileV2(n) {
|
|
551
|
+
_rpMaxPendingExecsPerProfile = _rpPos(n, "maxPendingRunnerExecsPerProfile");
|
|
552
|
+
}
|
|
553
|
+
export function getMaxPendingRunnerExecsPerProfileV2() {
|
|
554
|
+
return _rpMaxPendingExecsPerProfile;
|
|
555
|
+
}
|
|
556
|
+
export function setRunnerProfileIdleMsV2(n) {
|
|
557
|
+
_rpIdleMs = _rpPos(n, "runnerProfileIdleMs");
|
|
558
|
+
}
|
|
559
|
+
export function getRunnerProfileIdleMsV2() {
|
|
560
|
+
return _rpIdleMs;
|
|
561
|
+
}
|
|
562
|
+
export function setRunnerExecStuckMsV2(n) {
|
|
563
|
+
_reStuckMs = _rpPos(n, "runnerExecStuckMs");
|
|
564
|
+
}
|
|
565
|
+
export function getRunnerExecStuckMsV2() {
|
|
566
|
+
return _reStuckMs;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
export function _resetStateRunnerV2() {
|
|
570
|
+
_rpsV2.clear();
|
|
571
|
+
_resV2.clear();
|
|
572
|
+
_rpMaxActivePerOwner = 8;
|
|
573
|
+
_rpMaxPendingExecsPerProfile = 15;
|
|
574
|
+
_rpIdleMs = 14 * 24 * 60 * 60 * 1000;
|
|
575
|
+
_reStuckMs = 20 * 60 * 1000;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export function registerRunnerProfileV2({
|
|
579
|
+
id,
|
|
580
|
+
owner,
|
|
581
|
+
template,
|
|
582
|
+
metadata,
|
|
583
|
+
} = {}) {
|
|
584
|
+
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
585
|
+
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
586
|
+
if (_rpsV2.has(id))
|
|
587
|
+
throw new Error(`runner profile ${id} already registered`);
|
|
588
|
+
const now = Date.now();
|
|
589
|
+
const p = {
|
|
590
|
+
id,
|
|
591
|
+
owner,
|
|
592
|
+
template: template || "default",
|
|
593
|
+
status: RUNNER_PROFILE_MATURITY_V2.PENDING,
|
|
594
|
+
createdAt: now,
|
|
595
|
+
updatedAt: now,
|
|
596
|
+
activatedAt: null,
|
|
597
|
+
retiredAt: null,
|
|
598
|
+
lastTouchedAt: now,
|
|
599
|
+
metadata: { ...(metadata || {}) },
|
|
600
|
+
};
|
|
601
|
+
_rpsV2.set(id, p);
|
|
602
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
603
|
+
}
|
|
604
|
+
function _rpCheckP(from, to) {
|
|
605
|
+
const a = _rpTrans.get(from);
|
|
606
|
+
if (!a || !a.has(to))
|
|
607
|
+
throw new Error(`invalid runner profile transition ${from} → ${to}`);
|
|
608
|
+
}
|
|
609
|
+
function _rpCountActive(owner) {
|
|
610
|
+
let n = 0;
|
|
611
|
+
for (const p of _rpsV2.values())
|
|
612
|
+
if (p.owner === owner && p.status === RUNNER_PROFILE_MATURITY_V2.ACTIVE)
|
|
613
|
+
n++;
|
|
614
|
+
return n;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export function activateRunnerProfileV2(id) {
|
|
618
|
+
const p = _rpsV2.get(id);
|
|
619
|
+
if (!p) throw new Error(`runner profile ${id} not found`);
|
|
620
|
+
_rpCheckP(p.status, RUNNER_PROFILE_MATURITY_V2.ACTIVE);
|
|
621
|
+
const recovery = p.status === RUNNER_PROFILE_MATURITY_V2.PAUSED;
|
|
622
|
+
if (!recovery) {
|
|
623
|
+
const c = _rpCountActive(p.owner);
|
|
624
|
+
if (c >= _rpMaxActivePerOwner)
|
|
625
|
+
throw new Error(
|
|
626
|
+
`max active runner profiles per owner (${_rpMaxActivePerOwner}) reached for ${p.owner}`,
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
const now = Date.now();
|
|
630
|
+
p.status = RUNNER_PROFILE_MATURITY_V2.ACTIVE;
|
|
631
|
+
p.updatedAt = now;
|
|
632
|
+
p.lastTouchedAt = now;
|
|
633
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
634
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
635
|
+
}
|
|
636
|
+
export function pauseRunnerProfileV2(id) {
|
|
637
|
+
const p = _rpsV2.get(id);
|
|
638
|
+
if (!p) throw new Error(`runner profile ${id} not found`);
|
|
639
|
+
_rpCheckP(p.status, RUNNER_PROFILE_MATURITY_V2.PAUSED);
|
|
640
|
+
p.status = RUNNER_PROFILE_MATURITY_V2.PAUSED;
|
|
641
|
+
p.updatedAt = Date.now();
|
|
642
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
643
|
+
}
|
|
644
|
+
export function retireRunnerProfileV2(id) {
|
|
645
|
+
const p = _rpsV2.get(id);
|
|
646
|
+
if (!p) throw new Error(`runner profile ${id} not found`);
|
|
647
|
+
_rpCheckP(p.status, RUNNER_PROFILE_MATURITY_V2.RETIRED);
|
|
648
|
+
const now = Date.now();
|
|
649
|
+
p.status = RUNNER_PROFILE_MATURITY_V2.RETIRED;
|
|
650
|
+
p.updatedAt = now;
|
|
651
|
+
if (!p.retiredAt) p.retiredAt = now;
|
|
652
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
653
|
+
}
|
|
654
|
+
export function touchRunnerProfileV2(id) {
|
|
655
|
+
const p = _rpsV2.get(id);
|
|
656
|
+
if (!p) throw new Error(`runner profile ${id} not found`);
|
|
657
|
+
if (_rpTerminal.has(p.status))
|
|
658
|
+
throw new Error(`cannot touch terminal runner profile ${id}`);
|
|
659
|
+
const now = Date.now();
|
|
660
|
+
p.lastTouchedAt = now;
|
|
661
|
+
p.updatedAt = now;
|
|
662
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
663
|
+
}
|
|
664
|
+
export function getRunnerProfileV2(id) {
|
|
665
|
+
const p = _rpsV2.get(id);
|
|
666
|
+
if (!p) return null;
|
|
667
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
668
|
+
}
|
|
669
|
+
export function listRunnerProfilesV2() {
|
|
670
|
+
return [..._rpsV2.values()].map((p) => ({
|
|
671
|
+
...p,
|
|
672
|
+
metadata: { ...p.metadata },
|
|
673
|
+
}));
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function _reCountPending(profileId) {
|
|
677
|
+
let n = 0;
|
|
678
|
+
for (const e of _resV2.values())
|
|
679
|
+
if (
|
|
680
|
+
e.profileId === profileId &&
|
|
681
|
+
(e.status === RUNNER_EXEC_LIFECYCLE_V2.QUEUED ||
|
|
682
|
+
e.status === RUNNER_EXEC_LIFECYCLE_V2.RUNNING)
|
|
683
|
+
)
|
|
684
|
+
n++;
|
|
685
|
+
return n;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export function createRunnerExecV2({
|
|
689
|
+
id,
|
|
690
|
+
profileId,
|
|
691
|
+
taskInput,
|
|
692
|
+
metadata,
|
|
693
|
+
} = {}) {
|
|
694
|
+
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
695
|
+
if (!profileId || typeof profileId !== "string")
|
|
696
|
+
throw new Error("profileId is required");
|
|
697
|
+
if (_resV2.has(id)) throw new Error(`runner exec ${id} already exists`);
|
|
698
|
+
if (!_rpsV2.has(profileId))
|
|
699
|
+
throw new Error(`runner profile ${profileId} not found`);
|
|
700
|
+
const pending = _reCountPending(profileId);
|
|
701
|
+
if (pending >= _rpMaxPendingExecsPerProfile)
|
|
702
|
+
throw new Error(
|
|
703
|
+
`max pending runner execs per profile (${_rpMaxPendingExecsPerProfile}) reached for ${profileId}`,
|
|
704
|
+
);
|
|
705
|
+
const now = Date.now();
|
|
706
|
+
const e = {
|
|
707
|
+
id,
|
|
708
|
+
profileId,
|
|
709
|
+
taskInput: taskInput || "",
|
|
710
|
+
status: RUNNER_EXEC_LIFECYCLE_V2.QUEUED,
|
|
711
|
+
createdAt: now,
|
|
712
|
+
updatedAt: now,
|
|
713
|
+
startedAt: null,
|
|
714
|
+
settledAt: null,
|
|
715
|
+
metadata: { ...(metadata || {}) },
|
|
716
|
+
};
|
|
717
|
+
_resV2.set(id, e);
|
|
718
|
+
return { ...e, metadata: { ...e.metadata } };
|
|
719
|
+
}
|
|
720
|
+
function _reCheckE(from, to) {
|
|
721
|
+
const a = _reTrans.get(from);
|
|
722
|
+
if (!a || !a.has(to))
|
|
723
|
+
throw new Error(`invalid runner exec transition ${from} → ${to}`);
|
|
724
|
+
}
|
|
725
|
+
export function startRunnerExecV2(id) {
|
|
726
|
+
const e = _resV2.get(id);
|
|
727
|
+
if (!e) throw new Error(`runner exec ${id} not found`);
|
|
728
|
+
_reCheckE(e.status, RUNNER_EXEC_LIFECYCLE_V2.RUNNING);
|
|
729
|
+
const now = Date.now();
|
|
730
|
+
e.status = RUNNER_EXEC_LIFECYCLE_V2.RUNNING;
|
|
731
|
+
e.updatedAt = now;
|
|
732
|
+
if (!e.startedAt) e.startedAt = now;
|
|
733
|
+
return { ...e, metadata: { ...e.metadata } };
|
|
734
|
+
}
|
|
735
|
+
export function succeedRunnerExecV2(id) {
|
|
736
|
+
const e = _resV2.get(id);
|
|
737
|
+
if (!e) throw new Error(`runner exec ${id} not found`);
|
|
738
|
+
_reCheckE(e.status, RUNNER_EXEC_LIFECYCLE_V2.SUCCEEDED);
|
|
739
|
+
const now = Date.now();
|
|
740
|
+
e.status = RUNNER_EXEC_LIFECYCLE_V2.SUCCEEDED;
|
|
741
|
+
e.updatedAt = now;
|
|
742
|
+
if (!e.settledAt) e.settledAt = now;
|
|
743
|
+
return { ...e, metadata: { ...e.metadata } };
|
|
744
|
+
}
|
|
745
|
+
export function failRunnerExecV2(id, reason) {
|
|
746
|
+
const e = _resV2.get(id);
|
|
747
|
+
if (!e) throw new Error(`runner exec ${id} not found`);
|
|
748
|
+
_reCheckE(e.status, RUNNER_EXEC_LIFECYCLE_V2.FAILED);
|
|
749
|
+
const now = Date.now();
|
|
750
|
+
e.status = RUNNER_EXEC_LIFECYCLE_V2.FAILED;
|
|
751
|
+
e.updatedAt = now;
|
|
752
|
+
if (!e.settledAt) e.settledAt = now;
|
|
753
|
+
if (reason) e.metadata.failReason = String(reason);
|
|
754
|
+
return { ...e, metadata: { ...e.metadata } };
|
|
755
|
+
}
|
|
756
|
+
export function cancelRunnerExecV2(id, reason) {
|
|
757
|
+
const e = _resV2.get(id);
|
|
758
|
+
if (!e) throw new Error(`runner exec ${id} not found`);
|
|
759
|
+
_reCheckE(e.status, RUNNER_EXEC_LIFECYCLE_V2.CANCELLED);
|
|
760
|
+
const now = Date.now();
|
|
761
|
+
e.status = RUNNER_EXEC_LIFECYCLE_V2.CANCELLED;
|
|
762
|
+
e.updatedAt = now;
|
|
763
|
+
if (!e.settledAt) e.settledAt = now;
|
|
764
|
+
if (reason) e.metadata.cancelReason = String(reason);
|
|
765
|
+
return { ...e, metadata: { ...e.metadata } };
|
|
766
|
+
}
|
|
767
|
+
export function getRunnerExecV2(id) {
|
|
768
|
+
const e = _resV2.get(id);
|
|
769
|
+
if (!e) return null;
|
|
770
|
+
return { ...e, metadata: { ...e.metadata } };
|
|
771
|
+
}
|
|
772
|
+
export function listRunnerExecsV2() {
|
|
773
|
+
return [..._resV2.values()].map((e) => ({
|
|
774
|
+
...e,
|
|
775
|
+
metadata: { ...e.metadata },
|
|
776
|
+
}));
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
export function autoPauseIdleRunnerProfilesV2({ now } = {}) {
|
|
780
|
+
const t = now ?? Date.now();
|
|
781
|
+
const flipped = [];
|
|
782
|
+
for (const p of _rpsV2.values())
|
|
783
|
+
if (
|
|
784
|
+
p.status === RUNNER_PROFILE_MATURITY_V2.ACTIVE &&
|
|
785
|
+
t - p.lastTouchedAt >= _rpIdleMs
|
|
786
|
+
) {
|
|
787
|
+
p.status = RUNNER_PROFILE_MATURITY_V2.PAUSED;
|
|
788
|
+
p.updatedAt = t;
|
|
789
|
+
flipped.push(p.id);
|
|
790
|
+
}
|
|
791
|
+
return { flipped, count: flipped.length };
|
|
792
|
+
}
|
|
793
|
+
export function autoFailStuckRunnerExecsV2({ now } = {}) {
|
|
794
|
+
const t = now ?? Date.now();
|
|
795
|
+
const flipped = [];
|
|
796
|
+
for (const e of _resV2.values())
|
|
797
|
+
if (
|
|
798
|
+
e.status === RUNNER_EXEC_LIFECYCLE_V2.RUNNING &&
|
|
799
|
+
e.startedAt != null &&
|
|
800
|
+
t - e.startedAt >= _reStuckMs
|
|
801
|
+
) {
|
|
802
|
+
e.status = RUNNER_EXEC_LIFECYCLE_V2.FAILED;
|
|
803
|
+
e.updatedAt = t;
|
|
804
|
+
if (!e.settledAt) e.settledAt = t;
|
|
805
|
+
e.metadata.failReason = "auto-fail-stuck";
|
|
806
|
+
flipped.push(e.id);
|
|
807
|
+
}
|
|
808
|
+
return { flipped, count: flipped.length };
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
export function getRunnerGovStatsV2() {
|
|
812
|
+
const profilesByStatus = {};
|
|
813
|
+
for (const s of Object.values(RUNNER_PROFILE_MATURITY_V2))
|
|
814
|
+
profilesByStatus[s] = 0;
|
|
815
|
+
for (const p of _rpsV2.values()) profilesByStatus[p.status]++;
|
|
816
|
+
const execsByStatus = {};
|
|
817
|
+
for (const s of Object.values(RUNNER_EXEC_LIFECYCLE_V2)) execsByStatus[s] = 0;
|
|
818
|
+
for (const e of _resV2.values()) execsByStatus[e.status]++;
|
|
819
|
+
return {
|
|
820
|
+
totalRunnerProfilesV2: _rpsV2.size,
|
|
821
|
+
totalRunnerExecsV2: _resV2.size,
|
|
822
|
+
maxActiveRunnerProfilesPerOwner: _rpMaxActivePerOwner,
|
|
823
|
+
maxPendingRunnerExecsPerProfile: _rpMaxPendingExecsPerProfile,
|
|
824
|
+
runnerProfileIdleMs: _rpIdleMs,
|
|
825
|
+
runnerExecStuckMs: _reStuckMs,
|
|
826
|
+
profilesByStatus,
|
|
827
|
+
execsByStatus,
|
|
828
|
+
};
|
|
829
|
+
}
|
|
@@ -569,3 +569,330 @@ function _appendHistory(cwd, record) {
|
|
|
569
569
|
// best-effort
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
+
|
|
573
|
+
// =====================================================================
|
|
574
|
+
// cowork-workflow V2 governance overlay (iter17)
|
|
575
|
+
// =====================================================================
|
|
576
|
+
export const CWWF_PROFILE_MATURITY_V2 = Object.freeze({
|
|
577
|
+
PENDING: "pending",
|
|
578
|
+
ACTIVE: "active",
|
|
579
|
+
PAUSED: "paused",
|
|
580
|
+
ARCHIVED: "archived",
|
|
581
|
+
});
|
|
582
|
+
export const CWWF_STEP_LIFECYCLE_V2 = Object.freeze({
|
|
583
|
+
QUEUED: "queued",
|
|
584
|
+
RUNNING: "running",
|
|
585
|
+
COMPLETED: "completed",
|
|
586
|
+
FAILED: "failed",
|
|
587
|
+
CANCELLED: "cancelled",
|
|
588
|
+
});
|
|
589
|
+
const _cwwfPTrans = new Map([
|
|
590
|
+
[
|
|
591
|
+
CWWF_PROFILE_MATURITY_V2.PENDING,
|
|
592
|
+
new Set([
|
|
593
|
+
CWWF_PROFILE_MATURITY_V2.ACTIVE,
|
|
594
|
+
CWWF_PROFILE_MATURITY_V2.ARCHIVED,
|
|
595
|
+
]),
|
|
596
|
+
],
|
|
597
|
+
[
|
|
598
|
+
CWWF_PROFILE_MATURITY_V2.ACTIVE,
|
|
599
|
+
new Set([
|
|
600
|
+
CWWF_PROFILE_MATURITY_V2.PAUSED,
|
|
601
|
+
CWWF_PROFILE_MATURITY_V2.ARCHIVED,
|
|
602
|
+
]),
|
|
603
|
+
],
|
|
604
|
+
[
|
|
605
|
+
CWWF_PROFILE_MATURITY_V2.PAUSED,
|
|
606
|
+
new Set([
|
|
607
|
+
CWWF_PROFILE_MATURITY_V2.ACTIVE,
|
|
608
|
+
CWWF_PROFILE_MATURITY_V2.ARCHIVED,
|
|
609
|
+
]),
|
|
610
|
+
],
|
|
611
|
+
[CWWF_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
612
|
+
]);
|
|
613
|
+
const _cwwfPTerminal = new Set([CWWF_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
614
|
+
const _cwwfJTrans = new Map([
|
|
615
|
+
[
|
|
616
|
+
CWWF_STEP_LIFECYCLE_V2.QUEUED,
|
|
617
|
+
new Set([CWWF_STEP_LIFECYCLE_V2.RUNNING, CWWF_STEP_LIFECYCLE_V2.CANCELLED]),
|
|
618
|
+
],
|
|
619
|
+
[
|
|
620
|
+
CWWF_STEP_LIFECYCLE_V2.RUNNING,
|
|
621
|
+
new Set([
|
|
622
|
+
CWWF_STEP_LIFECYCLE_V2.COMPLETED,
|
|
623
|
+
CWWF_STEP_LIFECYCLE_V2.FAILED,
|
|
624
|
+
CWWF_STEP_LIFECYCLE_V2.CANCELLED,
|
|
625
|
+
]),
|
|
626
|
+
],
|
|
627
|
+
[CWWF_STEP_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
628
|
+
[CWWF_STEP_LIFECYCLE_V2.FAILED, new Set()],
|
|
629
|
+
[CWWF_STEP_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
630
|
+
]);
|
|
631
|
+
const _cwwfPsV2 = new Map();
|
|
632
|
+
const _cwwfJsV2 = new Map();
|
|
633
|
+
let _cwwfMaxActive = 8,
|
|
634
|
+
_cwwfMaxPending = 20,
|
|
635
|
+
_cwwfIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
636
|
+
_cwwfStuckMs = 60 * 1000;
|
|
637
|
+
function _cwwfPos(n, label) {
|
|
638
|
+
const v = Math.floor(Number(n));
|
|
639
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
640
|
+
throw new Error(`${label} must be positive integer`);
|
|
641
|
+
return v;
|
|
642
|
+
}
|
|
643
|
+
function _cwwfCheckP(from, to) {
|
|
644
|
+
const a = _cwwfPTrans.get(from);
|
|
645
|
+
if (!a || !a.has(to))
|
|
646
|
+
throw new Error(`invalid cwwf profile transition ${from} → ${to}`);
|
|
647
|
+
}
|
|
648
|
+
function _cwwfCheckJ(from, to) {
|
|
649
|
+
const a = _cwwfJTrans.get(from);
|
|
650
|
+
if (!a || !a.has(to))
|
|
651
|
+
throw new Error(`invalid cwwf step transition ${from} → ${to}`);
|
|
652
|
+
}
|
|
653
|
+
function _cwwfCountActive(owner) {
|
|
654
|
+
let c = 0;
|
|
655
|
+
for (const p of _cwwfPsV2.values())
|
|
656
|
+
if (p.owner === owner && p.status === CWWF_PROFILE_MATURITY_V2.ACTIVE) c++;
|
|
657
|
+
return c;
|
|
658
|
+
}
|
|
659
|
+
function _cwwfCountPending(profileId) {
|
|
660
|
+
let c = 0;
|
|
661
|
+
for (const j of _cwwfJsV2.values())
|
|
662
|
+
if (
|
|
663
|
+
j.profileId === profileId &&
|
|
664
|
+
(j.status === CWWF_STEP_LIFECYCLE_V2.QUEUED ||
|
|
665
|
+
j.status === CWWF_STEP_LIFECYCLE_V2.RUNNING)
|
|
666
|
+
)
|
|
667
|
+
c++;
|
|
668
|
+
return c;
|
|
669
|
+
}
|
|
670
|
+
export function setMaxActiveCwwfProfilesPerOwnerV2(n) {
|
|
671
|
+
_cwwfMaxActive = _cwwfPos(n, "maxActiveCwwfProfilesPerOwner");
|
|
672
|
+
}
|
|
673
|
+
export function getMaxActiveCwwfProfilesPerOwnerV2() {
|
|
674
|
+
return _cwwfMaxActive;
|
|
675
|
+
}
|
|
676
|
+
export function setMaxPendingCwwfStepsPerProfileV2(n) {
|
|
677
|
+
_cwwfMaxPending = _cwwfPos(n, "maxPendingCwwfStepsPerProfile");
|
|
678
|
+
}
|
|
679
|
+
export function getMaxPendingCwwfStepsPerProfileV2() {
|
|
680
|
+
return _cwwfMaxPending;
|
|
681
|
+
}
|
|
682
|
+
export function setCwwfProfileIdleMsV2(n) {
|
|
683
|
+
_cwwfIdleMs = _cwwfPos(n, "cwwfProfileIdleMs");
|
|
684
|
+
}
|
|
685
|
+
export function getCwwfProfileIdleMsV2() {
|
|
686
|
+
return _cwwfIdleMs;
|
|
687
|
+
}
|
|
688
|
+
export function setCwwfStepStuckMsV2(n) {
|
|
689
|
+
_cwwfStuckMs = _cwwfPos(n, "cwwfStepStuckMs");
|
|
690
|
+
}
|
|
691
|
+
export function getCwwfStepStuckMsV2() {
|
|
692
|
+
return _cwwfStuckMs;
|
|
693
|
+
}
|
|
694
|
+
export function _resetStateCoworkWorkflowV2() {
|
|
695
|
+
_cwwfPsV2.clear();
|
|
696
|
+
_cwwfJsV2.clear();
|
|
697
|
+
_cwwfMaxActive = 8;
|
|
698
|
+
_cwwfMaxPending = 20;
|
|
699
|
+
_cwwfIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
700
|
+
_cwwfStuckMs = 60 * 1000;
|
|
701
|
+
}
|
|
702
|
+
export function registerCwwfProfileV2({ id, owner, mode, metadata } = {}) {
|
|
703
|
+
if (!id || !owner) throw new Error("id and owner required");
|
|
704
|
+
if (_cwwfPsV2.has(id)) throw new Error(`cwwf profile ${id} already exists`);
|
|
705
|
+
const now = Date.now();
|
|
706
|
+
const p = {
|
|
707
|
+
id,
|
|
708
|
+
owner,
|
|
709
|
+
mode: mode || "sequential",
|
|
710
|
+
status: CWWF_PROFILE_MATURITY_V2.PENDING,
|
|
711
|
+
createdAt: now,
|
|
712
|
+
updatedAt: now,
|
|
713
|
+
lastTouchedAt: now,
|
|
714
|
+
activatedAt: null,
|
|
715
|
+
archivedAt: null,
|
|
716
|
+
metadata: { ...(metadata || {}) },
|
|
717
|
+
};
|
|
718
|
+
_cwwfPsV2.set(id, p);
|
|
719
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
720
|
+
}
|
|
721
|
+
export function activateCwwfProfileV2(id) {
|
|
722
|
+
const p = _cwwfPsV2.get(id);
|
|
723
|
+
if (!p) throw new Error(`cwwf profile ${id} not found`);
|
|
724
|
+
const isInitial = p.status === CWWF_PROFILE_MATURITY_V2.PENDING;
|
|
725
|
+
_cwwfCheckP(p.status, CWWF_PROFILE_MATURITY_V2.ACTIVE);
|
|
726
|
+
if (isInitial && _cwwfCountActive(p.owner) >= _cwwfMaxActive)
|
|
727
|
+
throw new Error(`max active cwwf profiles for owner ${p.owner} reached`);
|
|
728
|
+
const now = Date.now();
|
|
729
|
+
p.status = CWWF_PROFILE_MATURITY_V2.ACTIVE;
|
|
730
|
+
p.updatedAt = now;
|
|
731
|
+
p.lastTouchedAt = now;
|
|
732
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
733
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
734
|
+
}
|
|
735
|
+
export function pauseCwwfProfileV2(id) {
|
|
736
|
+
const p = _cwwfPsV2.get(id);
|
|
737
|
+
if (!p) throw new Error(`cwwf profile ${id} not found`);
|
|
738
|
+
_cwwfCheckP(p.status, CWWF_PROFILE_MATURITY_V2.PAUSED);
|
|
739
|
+
p.status = CWWF_PROFILE_MATURITY_V2.PAUSED;
|
|
740
|
+
p.updatedAt = Date.now();
|
|
741
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
742
|
+
}
|
|
743
|
+
export function archiveCwwfProfileV2(id) {
|
|
744
|
+
const p = _cwwfPsV2.get(id);
|
|
745
|
+
if (!p) throw new Error(`cwwf profile ${id} not found`);
|
|
746
|
+
_cwwfCheckP(p.status, CWWF_PROFILE_MATURITY_V2.ARCHIVED);
|
|
747
|
+
const now = Date.now();
|
|
748
|
+
p.status = CWWF_PROFILE_MATURITY_V2.ARCHIVED;
|
|
749
|
+
p.updatedAt = now;
|
|
750
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
751
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
752
|
+
}
|
|
753
|
+
export function touchCwwfProfileV2(id) {
|
|
754
|
+
const p = _cwwfPsV2.get(id);
|
|
755
|
+
if (!p) throw new Error(`cwwf profile ${id} not found`);
|
|
756
|
+
if (_cwwfPTerminal.has(p.status))
|
|
757
|
+
throw new Error(`cannot touch terminal cwwf profile ${id}`);
|
|
758
|
+
const now = Date.now();
|
|
759
|
+
p.lastTouchedAt = now;
|
|
760
|
+
p.updatedAt = now;
|
|
761
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
762
|
+
}
|
|
763
|
+
export function getCwwfProfileV2(id) {
|
|
764
|
+
const p = _cwwfPsV2.get(id);
|
|
765
|
+
if (!p) return null;
|
|
766
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
767
|
+
}
|
|
768
|
+
export function listCwwfProfilesV2() {
|
|
769
|
+
return [..._cwwfPsV2.values()].map((p) => ({
|
|
770
|
+
...p,
|
|
771
|
+
metadata: { ...p.metadata },
|
|
772
|
+
}));
|
|
773
|
+
}
|
|
774
|
+
export function createCwwfStepV2({ id, profileId, task, metadata } = {}) {
|
|
775
|
+
if (!id || !profileId) throw new Error("id and profileId required");
|
|
776
|
+
if (_cwwfJsV2.has(id)) throw new Error(`cwwf step ${id} already exists`);
|
|
777
|
+
if (!_cwwfPsV2.has(profileId))
|
|
778
|
+
throw new Error(`cwwf profile ${profileId} not found`);
|
|
779
|
+
if (_cwwfCountPending(profileId) >= _cwwfMaxPending)
|
|
780
|
+
throw new Error(`max pending cwwf steps for profile ${profileId} reached`);
|
|
781
|
+
const now = Date.now();
|
|
782
|
+
const j = {
|
|
783
|
+
id,
|
|
784
|
+
profileId,
|
|
785
|
+
task: task || "",
|
|
786
|
+
status: CWWF_STEP_LIFECYCLE_V2.QUEUED,
|
|
787
|
+
createdAt: now,
|
|
788
|
+
updatedAt: now,
|
|
789
|
+
startedAt: null,
|
|
790
|
+
settledAt: null,
|
|
791
|
+
metadata: { ...(metadata || {}) },
|
|
792
|
+
};
|
|
793
|
+
_cwwfJsV2.set(id, j);
|
|
794
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
795
|
+
}
|
|
796
|
+
export function runningCwwfStepV2(id) {
|
|
797
|
+
const j = _cwwfJsV2.get(id);
|
|
798
|
+
if (!j) throw new Error(`cwwf step ${id} not found`);
|
|
799
|
+
_cwwfCheckJ(j.status, CWWF_STEP_LIFECYCLE_V2.RUNNING);
|
|
800
|
+
const now = Date.now();
|
|
801
|
+
j.status = CWWF_STEP_LIFECYCLE_V2.RUNNING;
|
|
802
|
+
j.updatedAt = now;
|
|
803
|
+
if (!j.startedAt) j.startedAt = now;
|
|
804
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
805
|
+
}
|
|
806
|
+
export function completeStepCwwfV2(id) {
|
|
807
|
+
const j = _cwwfJsV2.get(id);
|
|
808
|
+
if (!j) throw new Error(`cwwf step ${id} not found`);
|
|
809
|
+
_cwwfCheckJ(j.status, CWWF_STEP_LIFECYCLE_V2.COMPLETED);
|
|
810
|
+
const now = Date.now();
|
|
811
|
+
j.status = CWWF_STEP_LIFECYCLE_V2.COMPLETED;
|
|
812
|
+
j.updatedAt = now;
|
|
813
|
+
if (!j.settledAt) j.settledAt = now;
|
|
814
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
815
|
+
}
|
|
816
|
+
export function failCwwfStepV2(id, reason) {
|
|
817
|
+
const j = _cwwfJsV2.get(id);
|
|
818
|
+
if (!j) throw new Error(`cwwf step ${id} not found`);
|
|
819
|
+
_cwwfCheckJ(j.status, CWWF_STEP_LIFECYCLE_V2.FAILED);
|
|
820
|
+
const now = Date.now();
|
|
821
|
+
j.status = CWWF_STEP_LIFECYCLE_V2.FAILED;
|
|
822
|
+
j.updatedAt = now;
|
|
823
|
+
if (!j.settledAt) j.settledAt = now;
|
|
824
|
+
if (reason) j.metadata.failReason = String(reason);
|
|
825
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
826
|
+
}
|
|
827
|
+
export function cancelCwwfStepV2(id, reason) {
|
|
828
|
+
const j = _cwwfJsV2.get(id);
|
|
829
|
+
if (!j) throw new Error(`cwwf step ${id} not found`);
|
|
830
|
+
_cwwfCheckJ(j.status, CWWF_STEP_LIFECYCLE_V2.CANCELLED);
|
|
831
|
+
const now = Date.now();
|
|
832
|
+
j.status = CWWF_STEP_LIFECYCLE_V2.CANCELLED;
|
|
833
|
+
j.updatedAt = now;
|
|
834
|
+
if (!j.settledAt) j.settledAt = now;
|
|
835
|
+
if (reason) j.metadata.cancelReason = String(reason);
|
|
836
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
837
|
+
}
|
|
838
|
+
export function getCwwfStepV2(id) {
|
|
839
|
+
const j = _cwwfJsV2.get(id);
|
|
840
|
+
if (!j) return null;
|
|
841
|
+
return { ...j, metadata: { ...j.metadata } };
|
|
842
|
+
}
|
|
843
|
+
export function listCwwfStepsV2() {
|
|
844
|
+
return [..._cwwfJsV2.values()].map((j) => ({
|
|
845
|
+
...j,
|
|
846
|
+
metadata: { ...j.metadata },
|
|
847
|
+
}));
|
|
848
|
+
}
|
|
849
|
+
export function autoPauseIdleCwwfProfilesV2({ now } = {}) {
|
|
850
|
+
const t = now ?? Date.now();
|
|
851
|
+
const flipped = [];
|
|
852
|
+
for (const p of _cwwfPsV2.values())
|
|
853
|
+
if (
|
|
854
|
+
p.status === CWWF_PROFILE_MATURITY_V2.ACTIVE &&
|
|
855
|
+
t - p.lastTouchedAt >= _cwwfIdleMs
|
|
856
|
+
) {
|
|
857
|
+
p.status = CWWF_PROFILE_MATURITY_V2.PAUSED;
|
|
858
|
+
p.updatedAt = t;
|
|
859
|
+
flipped.push(p.id);
|
|
860
|
+
}
|
|
861
|
+
return { flipped, count: flipped.length };
|
|
862
|
+
}
|
|
863
|
+
export function autoFailStuckCwwfStepsV2({ now } = {}) {
|
|
864
|
+
const t = now ?? Date.now();
|
|
865
|
+
const flipped = [];
|
|
866
|
+
for (const j of _cwwfJsV2.values())
|
|
867
|
+
if (
|
|
868
|
+
j.status === CWWF_STEP_LIFECYCLE_V2.RUNNING &&
|
|
869
|
+
j.startedAt != null &&
|
|
870
|
+
t - j.startedAt >= _cwwfStuckMs
|
|
871
|
+
) {
|
|
872
|
+
j.status = CWWF_STEP_LIFECYCLE_V2.FAILED;
|
|
873
|
+
j.updatedAt = t;
|
|
874
|
+
if (!j.settledAt) j.settledAt = t;
|
|
875
|
+
j.metadata.failReason = "auto-fail-stuck";
|
|
876
|
+
flipped.push(j.id);
|
|
877
|
+
}
|
|
878
|
+
return { flipped, count: flipped.length };
|
|
879
|
+
}
|
|
880
|
+
export function getCoworkWorkflowGovStatsV2() {
|
|
881
|
+
const profilesByStatus = {};
|
|
882
|
+
for (const v of Object.values(CWWF_PROFILE_MATURITY_V2))
|
|
883
|
+
profilesByStatus[v] = 0;
|
|
884
|
+
for (const p of _cwwfPsV2.values()) profilesByStatus[p.status]++;
|
|
885
|
+
const stepsByStatus = {};
|
|
886
|
+
for (const v of Object.values(CWWF_STEP_LIFECYCLE_V2)) stepsByStatus[v] = 0;
|
|
887
|
+
for (const j of _cwwfJsV2.values()) stepsByStatus[j.status]++;
|
|
888
|
+
return {
|
|
889
|
+
totalCwwfProfilesV2: _cwwfPsV2.size,
|
|
890
|
+
totalCwwfStepsV2: _cwwfJsV2.size,
|
|
891
|
+
maxActiveCwwfProfilesPerOwner: _cwwfMaxActive,
|
|
892
|
+
maxPendingCwwfStepsPerProfile: _cwwfMaxPending,
|
|
893
|
+
cwwfProfileIdleMs: _cwwfIdleMs,
|
|
894
|
+
cwwfStepStuckMs: _cwwfStuckMs,
|
|
895
|
+
profilesByStatus,
|
|
896
|
+
stepsByStatus,
|
|
897
|
+
};
|
|
898
|
+
}
|