chainlesschain 0.143.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 +196 -28
- package/src/commands/activitypub.js +157 -27
- package/src/commands/agent.js +587 -103
- package/src/commands/audit.js +206 -0
- package/src/commands/bi.js +152 -27
- package/src/commands/bm25.js +111 -27
- package/src/commands/browse.js +190 -29
- package/src/commands/ccron.js +128 -28
- package/src/commands/chat.js +207 -0
- package/src/commands/compliance.js +414 -34
- package/src/commands/compt.js +127 -29
- package/src/commands/consol.js +8 -2
- package/src/commands/cowork.js +580 -34
- package/src/commands/crosschain.js +182 -28
- package/src/commands/dao.js +182 -28
- package/src/commands/dlp.js +172 -27
- package/src/commands/economy.js +205 -50
- package/src/commands/evolution.js +203 -50
- package/src/commands/evomap.js +182 -27
- package/src/commands/fflag.js +74 -22
- package/src/commands/git.js +177 -37
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +204 -50
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +170 -34
- package/src/commands/itbudget.js +149 -33
- package/src/commands/kg.js +206 -0
- package/src/commands/lowcode.js +195 -38
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +179 -27
- package/src/commands/mcpscaf.js +145 -33
- package/src/commands/meminj.js +145 -33
- package/src/commands/nostr.js +178 -27
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +144 -33
- package/src/commands/pdfp.js +109 -27
- package/src/commands/perf.js +169 -32
- package/src/commands/perm.js +144 -33
- package/src/commands/pipeline.js +207 -52
- package/src/commands/planmode.js +141 -32
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +111 -27
- package/src/commands/recommend.js +177 -34
- package/src/commands/reputation.js +208 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/seshhook.js +145 -33
- package/src/commands/seshsearch.js +141 -33
- package/src/commands/seshtail.js +144 -33
- package/src/commands/seshu.js +152 -33
- package/src/commands/sganal.js +123 -29
- package/src/commands/siem.js +201 -34
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +146 -33
- package/src/commands/social.js +157 -32
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +145 -33
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +171 -33
- package/src/commands/topiccls.js +146 -33
- package/src/commands/uprof.js +141 -32
- package/src/commands/vcheck.js +122 -28
- package/src/commands/webfetch.js +141 -32
- package/src/commands/zkp.js +184 -28
- package/src/index.js +40 -0
- package/src/lib/a2a-protocol.js +319 -51
- package/src/lib/activitypub-bridge.js +288 -50
- package/src/lib/agent-economy.js +304 -51
- package/src/lib/app-builder.js +279 -46
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/autonomous-agent.js +284 -48
- package/src/lib/bi-engine.js +283 -49
- package/src/lib/bm25-search.js +301 -49
- package/src/lib/browser-automation.js +296 -49
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/compliance-framework-reporter.js +305 -51
- package/src/lib/compliance-manager.js +330 -0
- package/src/lib/compression-telemetry.js +301 -49
- package/src/lib/content-recommender.js +317 -52
- package/src/lib/cowork-cron.js +298 -49
- package/src/lib/cowork-learning.js +333 -0
- package/src/lib/cowork-task-runner.js +308 -51
- package/src/lib/cowork-workflow.js +327 -0
- package/src/lib/cross-chain.js +311 -51
- package/src/lib/dao-governance.js +280 -46
- package/src/lib/dlp-engine.js +287 -49
- package/src/lib/evolution-system.js +278 -47
- package/src/lib/evomap-manager.js +280 -46
- package/src/lib/execution-backend.js +294 -48
- package/src/lib/feature-flags.js +294 -49
- package/src/lib/git-integration.js +285 -47
- package/src/lib/hardening-manager.js +341 -0
- package/src/lib/hierarchical-memory.js +284 -48
- package/src/lib/inference-network.js +308 -51
- package/src/lib/iteration-budget.js +302 -50
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/matrix-bridge.js +281 -47
- package/src/lib/mcp-scaffold.js +318 -54
- package/src/lib/memory-injection.js +288 -49
- package/src/lib/nostr-bridge.js +286 -49
- package/src/lib/orchestrator.js +293 -48
- package/src/lib/pdf-parser.js +298 -49
- package/src/lib/perf-tuning.js +309 -50
- package/src/lib/permission-engine.js +287 -49
- package/src/lib/pipeline-orchestrator.js +289 -49
- package/src/lib/plan-mode.js +298 -51
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/service-container.js +313 -52
- package/src/lib/session-consolidator.js +296 -49
- package/src/lib/session-hooks.js +312 -53
- package/src/lib/session-search.js +304 -51
- package/src/lib/session-tail.js +288 -49
- package/src/lib/session-usage.js +298 -52
- package/src/lib/siem-exporter.js +298 -51
- package/src/lib/skill-marketplace.js +345 -0
- package/src/lib/sla-manager.js +341 -0
- package/src/lib/slot-filler.js +303 -51
- package/src/lib/social-graph-analytics.js +295 -49
- package/src/lib/social-graph.js +272 -49
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +302 -53
- package/src/lib/task-model-selector.js +302 -50
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/todo-manager.js +281 -47
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/topic-classifier.js +297 -49
- package/src/lib/user-profile.js +294 -50
- package/src/lib/version-checker.js +304 -50
- package/src/lib/web-fetch.js +292 -51
- package/src/lib/zkp-engine.js +286 -49
|
@@ -927,25 +927,53 @@ export function getStats(db) {
|
|
|
927
927
|
};
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
-
|
|
931
930
|
// ===== V2 Surface: Pipeline Orchestrator governance overlay (CLI v0.137.0) =====
|
|
932
931
|
export const PIPELINE_MATURITY_V2 = Object.freeze({
|
|
933
|
-
PENDING: "pending",
|
|
932
|
+
PENDING: "pending",
|
|
933
|
+
ACTIVE: "active",
|
|
934
|
+
PAUSED: "paused",
|
|
935
|
+
ARCHIVED: "archived",
|
|
934
936
|
});
|
|
935
937
|
export const PIPELINE_RUN_LIFECYCLE_V2 = Object.freeze({
|
|
936
|
-
QUEUED: "queued",
|
|
938
|
+
QUEUED: "queued",
|
|
939
|
+
RUNNING: "running",
|
|
940
|
+
COMPLETED: "completed",
|
|
941
|
+
FAILED: "failed",
|
|
942
|
+
CANCELLED: "cancelled",
|
|
937
943
|
});
|
|
938
944
|
|
|
939
945
|
const _pipTrans = new Map([
|
|
940
|
-
[
|
|
941
|
-
|
|
942
|
-
|
|
946
|
+
[
|
|
947
|
+
PIPELINE_MATURITY_V2.PENDING,
|
|
948
|
+
new Set([PIPELINE_MATURITY_V2.ACTIVE, PIPELINE_MATURITY_V2.ARCHIVED]),
|
|
949
|
+
],
|
|
950
|
+
[
|
|
951
|
+
PIPELINE_MATURITY_V2.ACTIVE,
|
|
952
|
+
new Set([PIPELINE_MATURITY_V2.PAUSED, PIPELINE_MATURITY_V2.ARCHIVED]),
|
|
953
|
+
],
|
|
954
|
+
[
|
|
955
|
+
PIPELINE_MATURITY_V2.PAUSED,
|
|
956
|
+
new Set([PIPELINE_MATURITY_V2.ACTIVE, PIPELINE_MATURITY_V2.ARCHIVED]),
|
|
957
|
+
],
|
|
943
958
|
[PIPELINE_MATURITY_V2.ARCHIVED, new Set()],
|
|
944
959
|
]);
|
|
945
960
|
const _pipTerminal = new Set([PIPELINE_MATURITY_V2.ARCHIVED]);
|
|
946
961
|
const _pipRunTrans = new Map([
|
|
947
|
-
[
|
|
948
|
-
|
|
962
|
+
[
|
|
963
|
+
PIPELINE_RUN_LIFECYCLE_V2.QUEUED,
|
|
964
|
+
new Set([
|
|
965
|
+
PIPELINE_RUN_LIFECYCLE_V2.RUNNING,
|
|
966
|
+
PIPELINE_RUN_LIFECYCLE_V2.CANCELLED,
|
|
967
|
+
]),
|
|
968
|
+
],
|
|
969
|
+
[
|
|
970
|
+
PIPELINE_RUN_LIFECYCLE_V2.RUNNING,
|
|
971
|
+
new Set([
|
|
972
|
+
PIPELINE_RUN_LIFECYCLE_V2.COMPLETED,
|
|
973
|
+
PIPELINE_RUN_LIFECYCLE_V2.FAILED,
|
|
974
|
+
PIPELINE_RUN_LIFECYCLE_V2.CANCELLED,
|
|
975
|
+
]),
|
|
976
|
+
],
|
|
949
977
|
[PIPELINE_RUN_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
950
978
|
[PIPELINE_RUN_LIFECYCLE_V2.FAILED, new Set()],
|
|
951
979
|
[PIPELINE_RUN_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
@@ -958,21 +986,45 @@ let _pipMaxPendingPerPip = 20;
|
|
|
958
986
|
let _pipIdleMs = 3 * 24 * 60 * 60 * 1000;
|
|
959
987
|
let _pipRunStuckMs = 10 * 60 * 1000;
|
|
960
988
|
|
|
961
|
-
function _pipPos(n, lbl) {
|
|
989
|
+
function _pipPos(n, lbl) {
|
|
990
|
+
const v = Math.floor(Number(n));
|
|
991
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
992
|
+
throw new Error(`${lbl} must be positive integer`);
|
|
993
|
+
return v;
|
|
994
|
+
}
|
|
962
995
|
|
|
963
|
-
export function setMaxActivePipelinesPerOwnerV2(n) {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
export function
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
export function
|
|
970
|
-
|
|
996
|
+
export function setMaxActivePipelinesPerOwnerV2(n) {
|
|
997
|
+
_pipMaxActivePerOwner = _pipPos(n, "maxActivePipelinesPerOwner");
|
|
998
|
+
}
|
|
999
|
+
export function getMaxActivePipelinesPerOwnerV2() {
|
|
1000
|
+
return _pipMaxActivePerOwner;
|
|
1001
|
+
}
|
|
1002
|
+
export function setMaxPendingPipelineRunsPerPipelineV2(n) {
|
|
1003
|
+
_pipMaxPendingPerPip = _pipPos(n, "maxPendingPipelineRunsPerPipeline");
|
|
1004
|
+
}
|
|
1005
|
+
export function getMaxPendingPipelineRunsPerPipelineV2() {
|
|
1006
|
+
return _pipMaxPendingPerPip;
|
|
1007
|
+
}
|
|
1008
|
+
export function setPipelineIdleMsV2(n) {
|
|
1009
|
+
_pipIdleMs = _pipPos(n, "pipelineIdleMs");
|
|
1010
|
+
}
|
|
1011
|
+
export function getPipelineIdleMsV2() {
|
|
1012
|
+
return _pipIdleMs;
|
|
1013
|
+
}
|
|
1014
|
+
export function setPipelineRunStuckMsV2(n) {
|
|
1015
|
+
_pipRunStuckMs = _pipPos(n, "pipelineRunStuckMs");
|
|
1016
|
+
}
|
|
1017
|
+
export function getPipelineRunStuckMsV2() {
|
|
1018
|
+
return _pipRunStuckMs;
|
|
1019
|
+
}
|
|
971
1020
|
|
|
972
1021
|
export function _resetStatePipelineOrchestratorV2() {
|
|
973
|
-
_pips.clear();
|
|
974
|
-
|
|
975
|
-
|
|
1022
|
+
_pips.clear();
|
|
1023
|
+
_pipRuns.clear();
|
|
1024
|
+
_pipMaxActivePerOwner = 10;
|
|
1025
|
+
_pipMaxPendingPerPip = 20;
|
|
1026
|
+
_pipIdleMs = 3 * 24 * 60 * 60 * 1000;
|
|
1027
|
+
_pipRunStuckMs = 10 * 60 * 1000;
|
|
976
1028
|
}
|
|
977
1029
|
|
|
978
1030
|
export function registerPipelineV2({ id, owner, name, metadata } = {}) {
|
|
@@ -980,54 +1032,242 @@ export function registerPipelineV2({ id, owner, name, metadata } = {}) {
|
|
|
980
1032
|
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
981
1033
|
if (_pips.has(id)) throw new Error(`pipeline ${id} already registered`);
|
|
982
1034
|
const now = Date.now();
|
|
983
|
-
const p = {
|
|
1035
|
+
const p = {
|
|
1036
|
+
id,
|
|
1037
|
+
owner,
|
|
1038
|
+
name: name || id,
|
|
1039
|
+
status: PIPELINE_MATURITY_V2.PENDING,
|
|
1040
|
+
createdAt: now,
|
|
1041
|
+
updatedAt: now,
|
|
1042
|
+
activatedAt: null,
|
|
1043
|
+
archivedAt: null,
|
|
1044
|
+
lastTouchedAt: now,
|
|
1045
|
+
metadata: { ...(metadata || {}) },
|
|
1046
|
+
};
|
|
984
1047
|
_pips.set(id, p);
|
|
985
1048
|
return { ...p, metadata: { ...p.metadata } };
|
|
986
1049
|
}
|
|
987
|
-
function _pipCheckP(from, to) {
|
|
988
|
-
|
|
1050
|
+
function _pipCheckP(from, to) {
|
|
1051
|
+
const a = _pipTrans.get(from);
|
|
1052
|
+
if (!a || !a.has(to))
|
|
1053
|
+
throw new Error(`invalid pipeline transition ${from} → ${to}`);
|
|
1054
|
+
}
|
|
1055
|
+
function _pipCountActive(owner) {
|
|
1056
|
+
let n = 0;
|
|
1057
|
+
for (const p of _pips.values())
|
|
1058
|
+
if (p.owner === owner && p.status === PIPELINE_MATURITY_V2.ACTIVE) n++;
|
|
1059
|
+
return n;
|
|
1060
|
+
}
|
|
989
1061
|
|
|
990
1062
|
export function activatePipelineV2(id) {
|
|
991
|
-
const p = _pips.get(id);
|
|
1063
|
+
const p = _pips.get(id);
|
|
1064
|
+
if (!p) throw new Error(`pipeline ${id} not found`);
|
|
992
1065
|
_pipCheckP(p.status, PIPELINE_MATURITY_V2.ACTIVE);
|
|
993
1066
|
const recovery = p.status === PIPELINE_MATURITY_V2.PAUSED;
|
|
994
|
-
if (!recovery) {
|
|
995
|
-
|
|
1067
|
+
if (!recovery) {
|
|
1068
|
+
const c = _pipCountActive(p.owner);
|
|
1069
|
+
if (c >= _pipMaxActivePerOwner)
|
|
1070
|
+
throw new Error(
|
|
1071
|
+
`max active pipelines per owner (${_pipMaxActivePerOwner}) reached for ${p.owner}`,
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
const now = Date.now();
|
|
1075
|
+
p.status = PIPELINE_MATURITY_V2.ACTIVE;
|
|
1076
|
+
p.updatedAt = now;
|
|
1077
|
+
p.lastTouchedAt = now;
|
|
1078
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
1079
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1080
|
+
}
|
|
1081
|
+
export function pausePipelineV2(id) {
|
|
1082
|
+
const p = _pips.get(id);
|
|
1083
|
+
if (!p) throw new Error(`pipeline ${id} not found`);
|
|
1084
|
+
_pipCheckP(p.status, PIPELINE_MATURITY_V2.PAUSED);
|
|
1085
|
+
p.status = PIPELINE_MATURITY_V2.PAUSED;
|
|
1086
|
+
p.updatedAt = Date.now();
|
|
1087
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1088
|
+
}
|
|
1089
|
+
export function archivePipelineV2(id) {
|
|
1090
|
+
const p = _pips.get(id);
|
|
1091
|
+
if (!p) throw new Error(`pipeline ${id} not found`);
|
|
1092
|
+
_pipCheckP(p.status, PIPELINE_MATURITY_V2.ARCHIVED);
|
|
1093
|
+
const now = Date.now();
|
|
1094
|
+
p.status = PIPELINE_MATURITY_V2.ARCHIVED;
|
|
1095
|
+
p.updatedAt = now;
|
|
1096
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
1097
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1098
|
+
}
|
|
1099
|
+
export function touchPipelineV2(id) {
|
|
1100
|
+
const p = _pips.get(id);
|
|
1101
|
+
if (!p) throw new Error(`pipeline ${id} not found`);
|
|
1102
|
+
if (_pipTerminal.has(p.status))
|
|
1103
|
+
throw new Error(`cannot touch terminal pipeline ${id}`);
|
|
1104
|
+
const now = Date.now();
|
|
1105
|
+
p.lastTouchedAt = now;
|
|
1106
|
+
p.updatedAt = now;
|
|
1107
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
1108
|
+
}
|
|
1109
|
+
export function getPipelineV2(id) {
|
|
1110
|
+
const p = _pips.get(id);
|
|
1111
|
+
if (!p) return null;
|
|
996
1112
|
return { ...p, metadata: { ...p.metadata } };
|
|
997
1113
|
}
|
|
998
|
-
export function
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1114
|
+
export function listPipelinesV2() {
|
|
1115
|
+
return [..._pips.values()].map((p) => ({
|
|
1116
|
+
...p,
|
|
1117
|
+
metadata: { ...p.metadata },
|
|
1118
|
+
}));
|
|
1119
|
+
}
|
|
1003
1120
|
|
|
1004
|
-
function _pipCountPendingRuns(pid) {
|
|
1121
|
+
function _pipCountPendingRuns(pid) {
|
|
1122
|
+
let n = 0;
|
|
1123
|
+
for (const r of _pipRuns.values())
|
|
1124
|
+
if (
|
|
1125
|
+
r.pipelineId === pid &&
|
|
1126
|
+
(r.status === PIPELINE_RUN_LIFECYCLE_V2.QUEUED ||
|
|
1127
|
+
r.status === PIPELINE_RUN_LIFECYCLE_V2.RUNNING)
|
|
1128
|
+
)
|
|
1129
|
+
n++;
|
|
1130
|
+
return n;
|
|
1131
|
+
}
|
|
1005
1132
|
|
|
1006
|
-
export function createPipelineRunV2({
|
|
1133
|
+
export function createPipelineRunV2({
|
|
1134
|
+
id,
|
|
1135
|
+
pipelineId,
|
|
1136
|
+
trigger,
|
|
1137
|
+
metadata,
|
|
1138
|
+
} = {}) {
|
|
1007
1139
|
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
1008
|
-
if (!pipelineId || typeof pipelineId !== "string")
|
|
1140
|
+
if (!pipelineId || typeof pipelineId !== "string")
|
|
1141
|
+
throw new Error("pipelineId is required");
|
|
1009
1142
|
if (_pipRuns.has(id)) throw new Error(`pipeline run ${id} already exists`);
|
|
1010
|
-
if (!_pips.has(pipelineId))
|
|
1143
|
+
if (!_pips.has(pipelineId))
|
|
1144
|
+
throw new Error(`pipeline ${pipelineId} not found`);
|
|
1011
1145
|
const pending = _pipCountPendingRuns(pipelineId);
|
|
1012
|
-
if (pending >= _pipMaxPendingPerPip)
|
|
1146
|
+
if (pending >= _pipMaxPendingPerPip)
|
|
1147
|
+
throw new Error(
|
|
1148
|
+
`max pending pipeline runs per pipeline (${_pipMaxPendingPerPip}) reached for ${pipelineId}`,
|
|
1149
|
+
);
|
|
1013
1150
|
const now = Date.now();
|
|
1014
|
-
const r = {
|
|
1151
|
+
const r = {
|
|
1152
|
+
id,
|
|
1153
|
+
pipelineId,
|
|
1154
|
+
trigger: trigger || "manual",
|
|
1155
|
+
status: PIPELINE_RUN_LIFECYCLE_V2.QUEUED,
|
|
1156
|
+
createdAt: now,
|
|
1157
|
+
updatedAt: now,
|
|
1158
|
+
startedAt: null,
|
|
1159
|
+
settledAt: null,
|
|
1160
|
+
metadata: { ...(metadata || {}) },
|
|
1161
|
+
};
|
|
1015
1162
|
_pipRuns.set(id, r);
|
|
1016
1163
|
return { ...r, metadata: { ...r.metadata } };
|
|
1017
1164
|
}
|
|
1018
|
-
function _pipCheckR(from, to) {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
export function
|
|
1024
|
-
|
|
1165
|
+
function _pipCheckR(from, to) {
|
|
1166
|
+
const a = _pipRunTrans.get(from);
|
|
1167
|
+
if (!a || !a.has(to))
|
|
1168
|
+
throw new Error(`invalid pipeline run transition ${from} → ${to}`);
|
|
1169
|
+
}
|
|
1170
|
+
export function startPipelineRunV2(id) {
|
|
1171
|
+
const r = _pipRuns.get(id);
|
|
1172
|
+
if (!r) throw new Error(`pipeline run ${id} not found`);
|
|
1173
|
+
_pipCheckR(r.status, PIPELINE_RUN_LIFECYCLE_V2.RUNNING);
|
|
1174
|
+
const now = Date.now();
|
|
1175
|
+
r.status = PIPELINE_RUN_LIFECYCLE_V2.RUNNING;
|
|
1176
|
+
r.updatedAt = now;
|
|
1177
|
+
if (!r.startedAt) r.startedAt = now;
|
|
1178
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
1179
|
+
}
|
|
1180
|
+
export function completePipelineRunV2(id) {
|
|
1181
|
+
const r = _pipRuns.get(id);
|
|
1182
|
+
if (!r) throw new Error(`pipeline run ${id} not found`);
|
|
1183
|
+
_pipCheckR(r.status, PIPELINE_RUN_LIFECYCLE_V2.COMPLETED);
|
|
1184
|
+
const now = Date.now();
|
|
1185
|
+
r.status = PIPELINE_RUN_LIFECYCLE_V2.COMPLETED;
|
|
1186
|
+
r.updatedAt = now;
|
|
1187
|
+
if (!r.settledAt) r.settledAt = now;
|
|
1188
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
1189
|
+
}
|
|
1190
|
+
export function failPipelineRunV2(id, reason) {
|
|
1191
|
+
const r = _pipRuns.get(id);
|
|
1192
|
+
if (!r) throw new Error(`pipeline run ${id} not found`);
|
|
1193
|
+
_pipCheckR(r.status, PIPELINE_RUN_LIFECYCLE_V2.FAILED);
|
|
1194
|
+
const now = Date.now();
|
|
1195
|
+
r.status = PIPELINE_RUN_LIFECYCLE_V2.FAILED;
|
|
1196
|
+
r.updatedAt = now;
|
|
1197
|
+
if (!r.settledAt) r.settledAt = now;
|
|
1198
|
+
if (reason) r.metadata.failReason = String(reason);
|
|
1199
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
1200
|
+
}
|
|
1201
|
+
export function cancelPipelineRunV2(id, reason) {
|
|
1202
|
+
const r = _pipRuns.get(id);
|
|
1203
|
+
if (!r) throw new Error(`pipeline run ${id} not found`);
|
|
1204
|
+
_pipCheckR(r.status, PIPELINE_RUN_LIFECYCLE_V2.CANCELLED);
|
|
1205
|
+
const now = Date.now();
|
|
1206
|
+
r.status = PIPELINE_RUN_LIFECYCLE_V2.CANCELLED;
|
|
1207
|
+
r.updatedAt = now;
|
|
1208
|
+
if (!r.settledAt) r.settledAt = now;
|
|
1209
|
+
if (reason) r.metadata.cancelReason = String(reason);
|
|
1210
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
1211
|
+
}
|
|
1212
|
+
export function getPipelineRunV2(id) {
|
|
1213
|
+
const r = _pipRuns.get(id);
|
|
1214
|
+
if (!r) return null;
|
|
1215
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
1216
|
+
}
|
|
1217
|
+
export function listPipelineRunsV2() {
|
|
1218
|
+
return [..._pipRuns.values()].map((r) => ({
|
|
1219
|
+
...r,
|
|
1220
|
+
metadata: { ...r.metadata },
|
|
1221
|
+
}));
|
|
1222
|
+
}
|
|
1025
1223
|
|
|
1026
|
-
export function autoPauseIdlePipelinesV2({ now } = {}) {
|
|
1027
|
-
|
|
1224
|
+
export function autoPauseIdlePipelinesV2({ now } = {}) {
|
|
1225
|
+
const t = now ?? Date.now();
|
|
1226
|
+
const flipped = [];
|
|
1227
|
+
for (const p of _pips.values())
|
|
1228
|
+
if (
|
|
1229
|
+
p.status === PIPELINE_MATURITY_V2.ACTIVE &&
|
|
1230
|
+
t - p.lastTouchedAt >= _pipIdleMs
|
|
1231
|
+
) {
|
|
1232
|
+
p.status = PIPELINE_MATURITY_V2.PAUSED;
|
|
1233
|
+
p.updatedAt = t;
|
|
1234
|
+
flipped.push(p.id);
|
|
1235
|
+
}
|
|
1236
|
+
return { flipped, count: flipped.length };
|
|
1237
|
+
}
|
|
1238
|
+
export function autoFailStuckPipelineRunsV2({ now } = {}) {
|
|
1239
|
+
const t = now ?? Date.now();
|
|
1240
|
+
const flipped = [];
|
|
1241
|
+
for (const r of _pipRuns.values())
|
|
1242
|
+
if (
|
|
1243
|
+
r.status === PIPELINE_RUN_LIFECYCLE_V2.RUNNING &&
|
|
1244
|
+
r.startedAt != null &&
|
|
1245
|
+
t - r.startedAt >= _pipRunStuckMs
|
|
1246
|
+
) {
|
|
1247
|
+
r.status = PIPELINE_RUN_LIFECYCLE_V2.FAILED;
|
|
1248
|
+
r.updatedAt = t;
|
|
1249
|
+
if (!r.settledAt) r.settledAt = t;
|
|
1250
|
+
r.metadata.failReason = "auto-fail-stuck";
|
|
1251
|
+
flipped.push(r.id);
|
|
1252
|
+
}
|
|
1253
|
+
return { flipped, count: flipped.length };
|
|
1254
|
+
}
|
|
1028
1255
|
|
|
1029
1256
|
export function getPipelineOrchestratorGovStatsV2() {
|
|
1030
|
-
const pipelinesByStatus = {};
|
|
1031
|
-
|
|
1032
|
-
|
|
1257
|
+
const pipelinesByStatus = {};
|
|
1258
|
+
for (const s of Object.values(PIPELINE_MATURITY_V2)) pipelinesByStatus[s] = 0;
|
|
1259
|
+
for (const p of _pips.values()) pipelinesByStatus[p.status]++;
|
|
1260
|
+
const runsByStatus = {};
|
|
1261
|
+
for (const s of Object.values(PIPELINE_RUN_LIFECYCLE_V2)) runsByStatus[s] = 0;
|
|
1262
|
+
for (const r of _pipRuns.values()) runsByStatus[r.status]++;
|
|
1263
|
+
return {
|
|
1264
|
+
totalPipelinesV2: _pips.size,
|
|
1265
|
+
totalRunsV2: _pipRuns.size,
|
|
1266
|
+
maxActivePipelinesPerOwner: _pipMaxActivePerOwner,
|
|
1267
|
+
maxPendingPipelineRunsPerPipeline: _pipMaxPendingPerPip,
|
|
1268
|
+
pipelineIdleMs: _pipIdleMs,
|
|
1269
|
+
pipelineRunStuckMs: _pipRunStuckMs,
|
|
1270
|
+
pipelinesByStatus,
|
|
1271
|
+
runsByStatus,
|
|
1272
|
+
};
|
|
1033
1273
|
}
|