chainlesschain 0.143.0 → 0.152.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 +364 -27
- package/src/commands/agent-network.js +217 -0
- package/src/commands/agent.js +587 -103
- package/src/commands/audit.js +206 -0
- package/src/commands/automation.js +201 -0
- package/src/commands/bi.js +355 -27
- package/src/commands/bm25.js +111 -27
- package/src/commands/browse.js +403 -29
- package/src/commands/ccron.js +128 -28
- package/src/commands/chat.js +207 -0
- package/src/commands/codegen.js +207 -0
- package/src/commands/collab.js +211 -0
- package/src/commands/compliance.js +824 -34
- package/src/commands/compt.js +127 -29
- package/src/commands/consol.js +8 -2
- package/src/commands/cowork.js +783 -34
- package/src/commands/crosschain.js +182 -28
- package/src/commands/dao.js +182 -28
- package/src/commands/dbevo.js +227 -0
- package/src/commands/dev.js +207 -0
- package/src/commands/did-v2.js +217 -0
- package/src/commands/did.js +221 -0
- package/src/commands/dlp.js +385 -27
- package/src/commands/economy.js +205 -50
- package/src/commands/evolution.js +203 -50
- package/src/commands/evomap.js +387 -27
- package/src/commands/export.js +213 -0
- package/src/commands/federation.js +209 -0
- package/src/commands/fflag.js +74 -22
- package/src/commands/fusion.js +205 -0
- package/src/commands/git.js +177 -37
- package/src/commands/governance.js +209 -0
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +204 -50
- package/src/commands/hook.js +209 -0
- package/src/commands/import.js +209 -0
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +170 -34
- package/src/commands/infra.js +203 -0
- package/src/commands/instinct.js +209 -0
- package/src/commands/ipfs.js +207 -0
- package/src/commands/itbudget.js +149 -33
- package/src/commands/kg.js +206 -0
- package/src/commands/llm.js +217 -0
- package/src/commands/lowcode.js +195 -38
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +386 -27
- package/src/commands/mcp.js +217 -0
- package/src/commands/mcpscaf.js +145 -33
- package/src/commands/meminj.js +145 -33
- package/src/commands/memory.js +209 -0
- package/src/commands/multimodal.js +203 -0
- package/src/commands/nlprog.js +225 -0
- package/src/commands/nostr.js +387 -27
- package/src/commands/note.js +205 -0
- package/src/commands/ops.js +219 -0
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +144 -33
- package/src/commands/org.js +209 -0
- package/src/commands/p2p.js +209 -0
- package/src/commands/pdfp.js +109 -27
- package/src/commands/perception.js +209 -0
- package/src/commands/perf.js +169 -32
- package/src/commands/perm.js +144 -33
- package/src/commands/permmem.js +203 -0
- package/src/commands/pipeline.js +207 -52
- package/src/commands/planmode.js +141 -32
- package/src/commands/plugin-ecosystem.js +209 -0
- package/src/commands/pqc.js +213 -0
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +111 -27
- package/src/commands/quantization.js +207 -0
- package/src/commands/rcache.js +205 -0
- package/src/commands/recommend.js +410 -34
- package/src/commands/reputation.js +208 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/scim.js +209 -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/session.js +209 -0
- package/src/commands/sganal.js +123 -29
- package/src/commands/siem.js +201 -34
- package/src/commands/skill.js +207 -0
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +146 -33
- package/src/commands/social.js +358 -32
- package/src/commands/sso.js +209 -0
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +145 -33
- package/src/commands/sync.js +209 -0
- package/src/commands/tech.js +209 -0
- package/src/commands/tenant.js +217 -0
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +171 -33
- package/src/commands/tokens.js +209 -0
- package/src/commands/topiccls.js +146 -33
- package/src/commands/trust.js +217 -0
- package/src/commands/uprof.js +141 -32
- package/src/commands/vcheck.js +122 -28
- package/src/commands/wallet.js +209 -0
- package/src/commands/webfetch.js +141 -32
- package/src/commands/workflow.js +203 -0
- package/src/commands/zkp.js +184 -28
- package/src/index.js +180 -0
- package/src/lib/a2a-protocol.js +319 -51
- package/src/lib/activitypub-bridge.js +622 -50
- package/src/lib/agent-economy.js +304 -51
- package/src/lib/agent-network.js +341 -0
- package/src/lib/aiops.js +346 -0
- package/src/lib/app-builder.js +279 -46
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/automation-engine.js +335 -0
- package/src/lib/autonomous-agent.js +284 -48
- package/src/lib/autonomous-developer.js +332 -0
- package/src/lib/bi-engine.js +616 -49
- package/src/lib/bm25-search.js +301 -49
- package/src/lib/browser-automation.js +630 -49
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/code-agent.js +339 -0
- package/src/lib/collaboration-governance.js +334 -0
- package/src/lib/community-governance.js +346 -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-recommendation.js +351 -0
- 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-share.js +338 -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/dbevo.js +351 -0
- package/src/lib/decentral-infra.js +330 -0
- package/src/lib/did-manager.js +341 -0
- package/src/lib/did-v2-manager.js +341 -0
- package/src/lib/dlp-engine.js +626 -49
- package/src/lib/evolution-system.js +278 -47
- package/src/lib/evomap-governance.js +334 -0
- 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/federation-hardening.js +340 -0
- 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/hook-manager.js +341 -0
- package/src/lib/inference-network.js +308 -51
- package/src/lib/instinct-manager.js +346 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/iteration-budget.js +302 -50
- package/src/lib/knowledge-exporter.js +341 -0
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/knowledge-importer.js +341 -0
- package/src/lib/llm-providers.js +346 -0
- package/src/lib/matrix-bridge.js +620 -47
- package/src/lib/mcp-registry.js +346 -0
- package/src/lib/mcp-scaffold.js +318 -54
- package/src/lib/memory-injection.js +288 -49
- package/src/lib/memory-manager.js +336 -0
- package/src/lib/multimodal.js +330 -0
- package/src/lib/nl-programming.js +341 -0
- package/src/lib/nostr-bridge.js +622 -49
- package/src/lib/note-versioning.js +339 -0
- package/src/lib/orchestrator.js +293 -48
- package/src/lib/org-manager.js +336 -0
- package/src/lib/p2p-manager.js +341 -0
- package/src/lib/pdf-parser.js +298 -49
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +309 -50
- package/src/lib/permanent-memory.js +327 -0
- 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/plugin-ecosystem.js +346 -0
- package/src/lib/pqc-manager.js +346 -0
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/protocol-fusion.js +338 -0
- package/src/lib/quantization.js +337 -0
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/response-cache.js +333 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/scim-manager.js +346 -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-manager.js +334 -0
- 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-loader.js +334 -0
- 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/social-manager.js +330 -0
- package/src/lib/sso-manager.js +340 -0
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +302 -53
- package/src/lib/sync-manager.js +336 -0
- package/src/lib/task-model-selector.js +302 -50
- package/src/lib/tech-learning-engine.js +341 -0
- package/src/lib/tenant-saas.js +341 -0
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/threat-intel.js +330 -0
- package/src/lib/todo-manager.js +281 -47
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/token-tracker.js +336 -0
- package/src/lib/topic-classifier.js +297 -49
- package/src/lib/trust-security.js +343 -0
- package/src/lib/ueba.js +340 -0
- package/src/lib/universal-runtime.js +330 -0
- package/src/lib/user-profile.js +294 -50
- package/src/lib/version-checker.js +304 -50
- package/src/lib/wallet-manager.js +336 -0
- package/src/lib/web-fetch.js +292 -51
- package/src/lib/workflow-engine.js +330 -0
- package/src/lib/zkp-engine.js +286 -49
|
@@ -99,83 +99,337 @@ function filterByChannel(releases, channel) {
|
|
|
99
99
|
|
|
100
100
|
export { fetchReleases, filterByChannel };
|
|
101
101
|
|
|
102
|
-
|
|
103
102
|
// =====================================================================
|
|
104
103
|
// Version Checker V2 governance overlay
|
|
105
104
|
// =====================================================================
|
|
106
|
-
export const VCHK_PROFILE_MATURITY_V2 = Object.freeze({
|
|
107
|
-
|
|
105
|
+
export const VCHK_PROFILE_MATURITY_V2 = Object.freeze({
|
|
106
|
+
PENDING: "pending",
|
|
107
|
+
ACTIVE: "active",
|
|
108
|
+
STALE: "stale",
|
|
109
|
+
ARCHIVED: "archived",
|
|
110
|
+
});
|
|
111
|
+
export const VCHK_CHECK_LIFECYCLE_V2 = Object.freeze({
|
|
112
|
+
QUEUED: "queued",
|
|
113
|
+
CHECKING: "checking",
|
|
114
|
+
COMPLETED: "completed",
|
|
115
|
+
FAILED: "failed",
|
|
116
|
+
CANCELLED: "cancelled",
|
|
117
|
+
});
|
|
108
118
|
const _vchkPTrans = new Map([
|
|
109
|
-
[
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
[
|
|
120
|
+
VCHK_PROFILE_MATURITY_V2.PENDING,
|
|
121
|
+
new Set([
|
|
122
|
+
VCHK_PROFILE_MATURITY_V2.ACTIVE,
|
|
123
|
+
VCHK_PROFILE_MATURITY_V2.ARCHIVED,
|
|
124
|
+
]),
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
VCHK_PROFILE_MATURITY_V2.ACTIVE,
|
|
128
|
+
new Set([
|
|
129
|
+
VCHK_PROFILE_MATURITY_V2.STALE,
|
|
130
|
+
VCHK_PROFILE_MATURITY_V2.ARCHIVED,
|
|
131
|
+
]),
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
VCHK_PROFILE_MATURITY_V2.STALE,
|
|
135
|
+
new Set([
|
|
136
|
+
VCHK_PROFILE_MATURITY_V2.ACTIVE,
|
|
137
|
+
VCHK_PROFILE_MATURITY_V2.ARCHIVED,
|
|
138
|
+
]),
|
|
139
|
+
],
|
|
112
140
|
[VCHK_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
|
|
113
141
|
]);
|
|
114
142
|
const _vchkPTerminal = new Set([VCHK_PROFILE_MATURITY_V2.ARCHIVED]);
|
|
115
143
|
const _vchkCTrans = new Map([
|
|
116
|
-
[
|
|
117
|
-
|
|
144
|
+
[
|
|
145
|
+
VCHK_CHECK_LIFECYCLE_V2.QUEUED,
|
|
146
|
+
new Set([
|
|
147
|
+
VCHK_CHECK_LIFECYCLE_V2.CHECKING,
|
|
148
|
+
VCHK_CHECK_LIFECYCLE_V2.CANCELLED,
|
|
149
|
+
]),
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
VCHK_CHECK_LIFECYCLE_V2.CHECKING,
|
|
153
|
+
new Set([
|
|
154
|
+
VCHK_CHECK_LIFECYCLE_V2.COMPLETED,
|
|
155
|
+
VCHK_CHECK_LIFECYCLE_V2.FAILED,
|
|
156
|
+
VCHK_CHECK_LIFECYCLE_V2.CANCELLED,
|
|
157
|
+
]),
|
|
158
|
+
],
|
|
118
159
|
[VCHK_CHECK_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
119
160
|
[VCHK_CHECK_LIFECYCLE_V2.FAILED, new Set()],
|
|
120
161
|
[VCHK_CHECK_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
121
162
|
]);
|
|
122
163
|
const _vchkPsV2 = new Map();
|
|
123
164
|
const _vchkCsV2 = new Map();
|
|
124
|
-
let _vchkMaxActive = 5,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
165
|
+
let _vchkMaxActive = 5,
|
|
166
|
+
_vchkMaxPending = 10,
|
|
167
|
+
_vchkIdleMs = 30 * 24 * 60 * 60 * 1000,
|
|
168
|
+
_vchkStuckMs = 30 * 1000;
|
|
169
|
+
function _vchkPos(n, label) {
|
|
170
|
+
const v = Math.floor(Number(n));
|
|
171
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
172
|
+
throw new Error(`${label} must be positive integer`);
|
|
173
|
+
return v;
|
|
174
|
+
}
|
|
175
|
+
function _vchkCheckP(from, to) {
|
|
176
|
+
const a = _vchkPTrans.get(from);
|
|
177
|
+
if (!a || !a.has(to))
|
|
178
|
+
throw new Error(`invalid vchk profile transition ${from} → ${to}`);
|
|
179
|
+
}
|
|
180
|
+
function _vchkCheckC(from, to) {
|
|
181
|
+
const a = _vchkCTrans.get(from);
|
|
182
|
+
if (!a || !a.has(to))
|
|
183
|
+
throw new Error(`invalid vchk check transition ${from} → ${to}`);
|
|
184
|
+
}
|
|
185
|
+
function _vchkCountActive(owner) {
|
|
186
|
+
let c = 0;
|
|
187
|
+
for (const p of _vchkPsV2.values())
|
|
188
|
+
if (p.owner === owner && p.status === VCHK_PROFILE_MATURITY_V2.ACTIVE) c++;
|
|
189
|
+
return c;
|
|
190
|
+
}
|
|
191
|
+
function _vchkCountPending(profileId) {
|
|
192
|
+
let c = 0;
|
|
193
|
+
for (const x of _vchkCsV2.values())
|
|
194
|
+
if (
|
|
195
|
+
x.profileId === profileId &&
|
|
196
|
+
(x.status === VCHK_CHECK_LIFECYCLE_V2.QUEUED ||
|
|
197
|
+
x.status === VCHK_CHECK_LIFECYCLE_V2.CHECKING)
|
|
198
|
+
)
|
|
199
|
+
c++;
|
|
200
|
+
return c;
|
|
201
|
+
}
|
|
202
|
+
export function setMaxActiveVchkProfilesPerOwnerV2(n) {
|
|
203
|
+
_vchkMaxActive = _vchkPos(n, "maxActiveVchkProfilesPerOwner");
|
|
204
|
+
}
|
|
205
|
+
export function getMaxActiveVchkProfilesPerOwnerV2() {
|
|
206
|
+
return _vchkMaxActive;
|
|
207
|
+
}
|
|
208
|
+
export function setMaxPendingVchkChecksPerProfileV2(n) {
|
|
209
|
+
_vchkMaxPending = _vchkPos(n, "maxPendingVchkChecksPerProfile");
|
|
210
|
+
}
|
|
211
|
+
export function getMaxPendingVchkChecksPerProfileV2() {
|
|
212
|
+
return _vchkMaxPending;
|
|
213
|
+
}
|
|
214
|
+
export function setVchkProfileIdleMsV2(n) {
|
|
215
|
+
_vchkIdleMs = _vchkPos(n, "vchkProfileIdleMs");
|
|
216
|
+
}
|
|
217
|
+
export function getVchkProfileIdleMsV2() {
|
|
218
|
+
return _vchkIdleMs;
|
|
219
|
+
}
|
|
220
|
+
export function setVchkCheckStuckMsV2(n) {
|
|
221
|
+
_vchkStuckMs = _vchkPos(n, "vchkCheckStuckMs");
|
|
222
|
+
}
|
|
223
|
+
export function getVchkCheckStuckMsV2() {
|
|
224
|
+
return _vchkStuckMs;
|
|
225
|
+
}
|
|
226
|
+
export function _resetStateVersionCheckerV2() {
|
|
227
|
+
_vchkPsV2.clear();
|
|
228
|
+
_vchkCsV2.clear();
|
|
229
|
+
_vchkMaxActive = 5;
|
|
230
|
+
_vchkMaxPending = 10;
|
|
231
|
+
_vchkIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
232
|
+
_vchkStuckMs = 30 * 1000;
|
|
233
|
+
}
|
|
139
234
|
export function registerVchkProfileV2({ id, owner, channel, metadata } = {}) {
|
|
140
235
|
if (!id || !owner) throw new Error("id and owner required");
|
|
141
236
|
if (_vchkPsV2.has(id)) throw new Error(`vchk profile ${id} already exists`);
|
|
142
237
|
const now = Date.now();
|
|
143
|
-
const p = {
|
|
144
|
-
|
|
238
|
+
const p = {
|
|
239
|
+
id,
|
|
240
|
+
owner,
|
|
241
|
+
channel: channel || "stable",
|
|
242
|
+
status: VCHK_PROFILE_MATURITY_V2.PENDING,
|
|
243
|
+
createdAt: now,
|
|
244
|
+
updatedAt: now,
|
|
245
|
+
lastTouchedAt: now,
|
|
246
|
+
activatedAt: null,
|
|
247
|
+
archivedAt: null,
|
|
248
|
+
metadata: { ...(metadata || {}) },
|
|
249
|
+
};
|
|
250
|
+
_vchkPsV2.set(id, p);
|
|
251
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
145
252
|
}
|
|
146
253
|
export function activateVchkProfileV2(id) {
|
|
147
|
-
const p = _vchkPsV2.get(id);
|
|
254
|
+
const p = _vchkPsV2.get(id);
|
|
255
|
+
if (!p) throw new Error(`vchk profile ${id} not found`);
|
|
148
256
|
const isInitial = p.status === VCHK_PROFILE_MATURITY_V2.PENDING;
|
|
149
257
|
_vchkCheckP(p.status, VCHK_PROFILE_MATURITY_V2.ACTIVE);
|
|
150
|
-
if (isInitial && _vchkCountActive(p.owner) >= _vchkMaxActive)
|
|
151
|
-
|
|
258
|
+
if (isInitial && _vchkCountActive(p.owner) >= _vchkMaxActive)
|
|
259
|
+
throw new Error(`max active vchk profiles for owner ${p.owner} reached`);
|
|
260
|
+
const now = Date.now();
|
|
261
|
+
p.status = VCHK_PROFILE_MATURITY_V2.ACTIVE;
|
|
262
|
+
p.updatedAt = now;
|
|
263
|
+
p.lastTouchedAt = now;
|
|
152
264
|
if (!p.activatedAt) p.activatedAt = now;
|
|
153
265
|
return { ...p, metadata: { ...p.metadata } };
|
|
154
266
|
}
|
|
155
|
-
export function staleVchkProfileV2(id) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
267
|
+
export function staleVchkProfileV2(id) {
|
|
268
|
+
const p = _vchkPsV2.get(id);
|
|
269
|
+
if (!p) throw new Error(`vchk profile ${id} not found`);
|
|
270
|
+
_vchkCheckP(p.status, VCHK_PROFILE_MATURITY_V2.STALE);
|
|
271
|
+
p.status = VCHK_PROFILE_MATURITY_V2.STALE;
|
|
272
|
+
p.updatedAt = Date.now();
|
|
273
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
274
|
+
}
|
|
275
|
+
export function archiveVchkProfileV2(id) {
|
|
276
|
+
const p = _vchkPsV2.get(id);
|
|
277
|
+
if (!p) throw new Error(`vchk profile ${id} not found`);
|
|
278
|
+
_vchkCheckP(p.status, VCHK_PROFILE_MATURITY_V2.ARCHIVED);
|
|
279
|
+
const now = Date.now();
|
|
280
|
+
p.status = VCHK_PROFILE_MATURITY_V2.ARCHIVED;
|
|
281
|
+
p.updatedAt = now;
|
|
282
|
+
if (!p.archivedAt) p.archivedAt = now;
|
|
283
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
284
|
+
}
|
|
285
|
+
export function touchVchkProfileV2(id) {
|
|
286
|
+
const p = _vchkPsV2.get(id);
|
|
287
|
+
if (!p) throw new Error(`vchk profile ${id} not found`);
|
|
288
|
+
if (_vchkPTerminal.has(p.status))
|
|
289
|
+
throw new Error(`cannot touch terminal vchk profile ${id}`);
|
|
290
|
+
const now = Date.now();
|
|
291
|
+
p.lastTouchedAt = now;
|
|
292
|
+
p.updatedAt = now;
|
|
293
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
294
|
+
}
|
|
295
|
+
export function getVchkProfileV2(id) {
|
|
296
|
+
const p = _vchkPsV2.get(id);
|
|
297
|
+
if (!p) return null;
|
|
298
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
299
|
+
}
|
|
300
|
+
export function listVchkProfilesV2() {
|
|
301
|
+
return [..._vchkPsV2.values()].map((p) => ({
|
|
302
|
+
...p,
|
|
303
|
+
metadata: { ...p.metadata },
|
|
304
|
+
}));
|
|
305
|
+
}
|
|
306
|
+
export function createVchkCheckV2({
|
|
307
|
+
id,
|
|
308
|
+
profileId,
|
|
309
|
+
currentVersion,
|
|
310
|
+
metadata,
|
|
311
|
+
} = {}) {
|
|
161
312
|
if (!id || !profileId) throw new Error("id and profileId required");
|
|
162
313
|
if (_vchkCsV2.has(id)) throw new Error(`vchk check ${id} already exists`);
|
|
163
|
-
if (!_vchkPsV2.has(profileId))
|
|
164
|
-
|
|
314
|
+
if (!_vchkPsV2.has(profileId))
|
|
315
|
+
throw new Error(`vchk profile ${profileId} not found`);
|
|
316
|
+
if (_vchkCountPending(profileId) >= _vchkMaxPending)
|
|
317
|
+
throw new Error(`max pending vchk checks for profile ${profileId} reached`);
|
|
318
|
+
const now = Date.now();
|
|
319
|
+
const c = {
|
|
320
|
+
id,
|
|
321
|
+
profileId,
|
|
322
|
+
currentVersion: currentVersion || "",
|
|
323
|
+
status: VCHK_CHECK_LIFECYCLE_V2.QUEUED,
|
|
324
|
+
createdAt: now,
|
|
325
|
+
updatedAt: now,
|
|
326
|
+
startedAt: null,
|
|
327
|
+
settledAt: null,
|
|
328
|
+
metadata: { ...(metadata || {}) },
|
|
329
|
+
};
|
|
330
|
+
_vchkCsV2.set(id, c);
|
|
331
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
332
|
+
}
|
|
333
|
+
export function checkingVchkCheckV2(id) {
|
|
334
|
+
const c = _vchkCsV2.get(id);
|
|
335
|
+
if (!c) throw new Error(`vchk check ${id} not found`);
|
|
336
|
+
_vchkCheckC(c.status, VCHK_CHECK_LIFECYCLE_V2.CHECKING);
|
|
337
|
+
const now = Date.now();
|
|
338
|
+
c.status = VCHK_CHECK_LIFECYCLE_V2.CHECKING;
|
|
339
|
+
c.updatedAt = now;
|
|
340
|
+
if (!c.startedAt) c.startedAt = now;
|
|
341
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
342
|
+
}
|
|
343
|
+
export function completeVchkCheckV2(id) {
|
|
344
|
+
const c = _vchkCsV2.get(id);
|
|
345
|
+
if (!c) throw new Error(`vchk check ${id} not found`);
|
|
346
|
+
_vchkCheckC(c.status, VCHK_CHECK_LIFECYCLE_V2.COMPLETED);
|
|
347
|
+
const now = Date.now();
|
|
348
|
+
c.status = VCHK_CHECK_LIFECYCLE_V2.COMPLETED;
|
|
349
|
+
c.updatedAt = now;
|
|
350
|
+
if (!c.settledAt) c.settledAt = now;
|
|
351
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
352
|
+
}
|
|
353
|
+
export function failVchkCheckV2(id, reason) {
|
|
354
|
+
const c = _vchkCsV2.get(id);
|
|
355
|
+
if (!c) throw new Error(`vchk check ${id} not found`);
|
|
356
|
+
_vchkCheckC(c.status, VCHK_CHECK_LIFECYCLE_V2.FAILED);
|
|
165
357
|
const now = Date.now();
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
export function cancelVchkCheckV2(id, reason) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
358
|
+
c.status = VCHK_CHECK_LIFECYCLE_V2.FAILED;
|
|
359
|
+
c.updatedAt = now;
|
|
360
|
+
if (!c.settledAt) c.settledAt = now;
|
|
361
|
+
if (reason) c.metadata.failReason = String(reason);
|
|
362
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
363
|
+
}
|
|
364
|
+
export function cancelVchkCheckV2(id, reason) {
|
|
365
|
+
const c = _vchkCsV2.get(id);
|
|
366
|
+
if (!c) throw new Error(`vchk check ${id} not found`);
|
|
367
|
+
_vchkCheckC(c.status, VCHK_CHECK_LIFECYCLE_V2.CANCELLED);
|
|
368
|
+
const now = Date.now();
|
|
369
|
+
c.status = VCHK_CHECK_LIFECYCLE_V2.CANCELLED;
|
|
370
|
+
c.updatedAt = now;
|
|
371
|
+
if (!c.settledAt) c.settledAt = now;
|
|
372
|
+
if (reason) c.metadata.cancelReason = String(reason);
|
|
373
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
374
|
+
}
|
|
375
|
+
export function getVchkCheckV2(id) {
|
|
376
|
+
const c = _vchkCsV2.get(id);
|
|
377
|
+
if (!c) return null;
|
|
378
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
379
|
+
}
|
|
380
|
+
export function listVchkChecksV2() {
|
|
381
|
+
return [..._vchkCsV2.values()].map((c) => ({
|
|
382
|
+
...c,
|
|
383
|
+
metadata: { ...c.metadata },
|
|
384
|
+
}));
|
|
385
|
+
}
|
|
386
|
+
export function autoStaleIdleVchkProfilesV2({ now } = {}) {
|
|
387
|
+
const t = now ?? Date.now();
|
|
388
|
+
const flipped = [];
|
|
389
|
+
for (const p of _vchkPsV2.values())
|
|
390
|
+
if (
|
|
391
|
+
p.status === VCHK_PROFILE_MATURITY_V2.ACTIVE &&
|
|
392
|
+
t - p.lastTouchedAt >= _vchkIdleMs
|
|
393
|
+
) {
|
|
394
|
+
p.status = VCHK_PROFILE_MATURITY_V2.STALE;
|
|
395
|
+
p.updatedAt = t;
|
|
396
|
+
flipped.push(p.id);
|
|
397
|
+
}
|
|
398
|
+
return { flipped, count: flipped.length };
|
|
399
|
+
}
|
|
400
|
+
export function autoFailStuckVchkChecksV2({ now } = {}) {
|
|
401
|
+
const t = now ?? Date.now();
|
|
402
|
+
const flipped = [];
|
|
403
|
+
for (const c of _vchkCsV2.values())
|
|
404
|
+
if (
|
|
405
|
+
c.status === VCHK_CHECK_LIFECYCLE_V2.CHECKING &&
|
|
406
|
+
c.startedAt != null &&
|
|
407
|
+
t - c.startedAt >= _vchkStuckMs
|
|
408
|
+
) {
|
|
409
|
+
c.status = VCHK_CHECK_LIFECYCLE_V2.FAILED;
|
|
410
|
+
c.updatedAt = t;
|
|
411
|
+
if (!c.settledAt) c.settledAt = t;
|
|
412
|
+
c.metadata.failReason = "auto-fail-stuck";
|
|
413
|
+
flipped.push(c.id);
|
|
414
|
+
}
|
|
415
|
+
return { flipped, count: flipped.length };
|
|
416
|
+
}
|
|
177
417
|
export function getVersionCheckerGovStatsV2() {
|
|
178
|
-
const profilesByStatus = {};
|
|
179
|
-
|
|
180
|
-
|
|
418
|
+
const profilesByStatus = {};
|
|
419
|
+
for (const v of Object.values(VCHK_PROFILE_MATURITY_V2))
|
|
420
|
+
profilesByStatus[v] = 0;
|
|
421
|
+
for (const p of _vchkPsV2.values()) profilesByStatus[p.status]++;
|
|
422
|
+
const checksByStatus = {};
|
|
423
|
+
for (const v of Object.values(VCHK_CHECK_LIFECYCLE_V2)) checksByStatus[v] = 0;
|
|
424
|
+
for (const c of _vchkCsV2.values()) checksByStatus[c.status]++;
|
|
425
|
+
return {
|
|
426
|
+
totalVchkProfilesV2: _vchkPsV2.size,
|
|
427
|
+
totalVchkChecksV2: _vchkCsV2.size,
|
|
428
|
+
maxActiveVchkProfilesPerOwner: _vchkMaxActive,
|
|
429
|
+
maxPendingVchkChecksPerProfile: _vchkMaxPending,
|
|
430
|
+
vchkProfileIdleMs: _vchkIdleMs,
|
|
431
|
+
vchkCheckStuckMs: _vchkStuckMs,
|
|
432
|
+
profilesByStatus,
|
|
433
|
+
checksByStatus,
|
|
434
|
+
};
|
|
181
435
|
}
|