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
|
@@ -218,3 +218,362 @@ export class SubAgentRegistry {
|
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
+
|
|
222
|
+
// ===== V2 Surface: Sub-Agent Registry governance overlay (CLI v0.133.0) =====
|
|
223
|
+
export const SUBAGENT_PROFILE_MATURITY_V2 = Object.freeze({
|
|
224
|
+
PENDING: "pending",
|
|
225
|
+
ACTIVE: "active",
|
|
226
|
+
PAUSED: "paused",
|
|
227
|
+
RETIRED: "retired",
|
|
228
|
+
});
|
|
229
|
+
export const SUBAGENT_TASK_LIFECYCLE_V2 = Object.freeze({
|
|
230
|
+
QUEUED: "queued",
|
|
231
|
+
RUNNING: "running",
|
|
232
|
+
COMPLETED: "completed",
|
|
233
|
+
FAILED: "failed",
|
|
234
|
+
CANCELLED: "cancelled",
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const _saProfileTrans = new Map([
|
|
238
|
+
[
|
|
239
|
+
SUBAGENT_PROFILE_MATURITY_V2.PENDING,
|
|
240
|
+
new Set([
|
|
241
|
+
SUBAGENT_PROFILE_MATURITY_V2.ACTIVE,
|
|
242
|
+
SUBAGENT_PROFILE_MATURITY_V2.RETIRED,
|
|
243
|
+
]),
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
SUBAGENT_PROFILE_MATURITY_V2.ACTIVE,
|
|
247
|
+
new Set([
|
|
248
|
+
SUBAGENT_PROFILE_MATURITY_V2.PAUSED,
|
|
249
|
+
SUBAGENT_PROFILE_MATURITY_V2.RETIRED,
|
|
250
|
+
]),
|
|
251
|
+
],
|
|
252
|
+
[
|
|
253
|
+
SUBAGENT_PROFILE_MATURITY_V2.PAUSED,
|
|
254
|
+
new Set([
|
|
255
|
+
SUBAGENT_PROFILE_MATURITY_V2.ACTIVE,
|
|
256
|
+
SUBAGENT_PROFILE_MATURITY_V2.RETIRED,
|
|
257
|
+
]),
|
|
258
|
+
],
|
|
259
|
+
[SUBAGENT_PROFILE_MATURITY_V2.RETIRED, new Set()],
|
|
260
|
+
]);
|
|
261
|
+
const _saProfileTerminal = new Set([SUBAGENT_PROFILE_MATURITY_V2.RETIRED]);
|
|
262
|
+
const _saTaskTrans = new Map([
|
|
263
|
+
[
|
|
264
|
+
SUBAGENT_TASK_LIFECYCLE_V2.QUEUED,
|
|
265
|
+
new Set([
|
|
266
|
+
SUBAGENT_TASK_LIFECYCLE_V2.RUNNING,
|
|
267
|
+
SUBAGENT_TASK_LIFECYCLE_V2.CANCELLED,
|
|
268
|
+
]),
|
|
269
|
+
],
|
|
270
|
+
[
|
|
271
|
+
SUBAGENT_TASK_LIFECYCLE_V2.RUNNING,
|
|
272
|
+
new Set([
|
|
273
|
+
SUBAGENT_TASK_LIFECYCLE_V2.COMPLETED,
|
|
274
|
+
SUBAGENT_TASK_LIFECYCLE_V2.FAILED,
|
|
275
|
+
SUBAGENT_TASK_LIFECYCLE_V2.CANCELLED,
|
|
276
|
+
]),
|
|
277
|
+
],
|
|
278
|
+
[SUBAGENT_TASK_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
279
|
+
[SUBAGENT_TASK_LIFECYCLE_V2.FAILED, new Set()],
|
|
280
|
+
[SUBAGENT_TASK_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
281
|
+
]);
|
|
282
|
+
|
|
283
|
+
const _saProfiles = new Map();
|
|
284
|
+
const _saTasks = new Map();
|
|
285
|
+
let _saMaxActivePerOwner = 12;
|
|
286
|
+
let _saMaxPendingPerProfile = 24;
|
|
287
|
+
let _saProfileIdleMs = 2 * 60 * 60 * 1000;
|
|
288
|
+
let _saTaskStuckMs = 5 * 60 * 1000;
|
|
289
|
+
|
|
290
|
+
function _saPos(n, lbl) {
|
|
291
|
+
const v = Math.floor(Number(n));
|
|
292
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
293
|
+
throw new Error(`${lbl} must be positive integer`);
|
|
294
|
+
return v;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function setMaxActiveSubagentsPerOwnerV2(n) {
|
|
298
|
+
_saMaxActivePerOwner = _saPos(n, "maxActiveSubagentsPerOwner");
|
|
299
|
+
}
|
|
300
|
+
export function getMaxActiveSubagentsPerOwnerV2() {
|
|
301
|
+
return _saMaxActivePerOwner;
|
|
302
|
+
}
|
|
303
|
+
export function setMaxPendingTasksPerSubagentV2(n) {
|
|
304
|
+
_saMaxPendingPerProfile = _saPos(n, "maxPendingTasksPerSubagent");
|
|
305
|
+
}
|
|
306
|
+
export function getMaxPendingTasksPerSubagentV2() {
|
|
307
|
+
return _saMaxPendingPerProfile;
|
|
308
|
+
}
|
|
309
|
+
export function setSubagentIdleMsV2(n) {
|
|
310
|
+
_saProfileIdleMs = _saPos(n, "subagentIdleMs");
|
|
311
|
+
}
|
|
312
|
+
export function getSubagentIdleMsV2() {
|
|
313
|
+
return _saProfileIdleMs;
|
|
314
|
+
}
|
|
315
|
+
export function setSubagentTaskStuckMsV2(n) {
|
|
316
|
+
_saTaskStuckMs = _saPos(n, "subagentTaskStuckMs");
|
|
317
|
+
}
|
|
318
|
+
export function getSubagentTaskStuckMsV2() {
|
|
319
|
+
return _saTaskStuckMs;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function _resetStateSubAgentRegistryV2() {
|
|
323
|
+
_saProfiles.clear();
|
|
324
|
+
_saTasks.clear();
|
|
325
|
+
_saMaxActivePerOwner = 12;
|
|
326
|
+
_saMaxPendingPerProfile = 24;
|
|
327
|
+
_saProfileIdleMs = 2 * 60 * 60 * 1000;
|
|
328
|
+
_saTaskStuckMs = 5 * 60 * 1000;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function registerSubagentProfileV2({ id, owner, role, metadata } = {}) {
|
|
332
|
+
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
333
|
+
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
334
|
+
if (_saProfiles.has(id))
|
|
335
|
+
throw new Error(`subagent profile ${id} already registered`);
|
|
336
|
+
const now = Date.now();
|
|
337
|
+
const p = {
|
|
338
|
+
id,
|
|
339
|
+
owner,
|
|
340
|
+
role: role || "generic",
|
|
341
|
+
status: SUBAGENT_PROFILE_MATURITY_V2.PENDING,
|
|
342
|
+
createdAt: now,
|
|
343
|
+
updatedAt: now,
|
|
344
|
+
activatedAt: null,
|
|
345
|
+
retiredAt: null,
|
|
346
|
+
lastTouchedAt: now,
|
|
347
|
+
metadata: { ...(metadata || {}) },
|
|
348
|
+
};
|
|
349
|
+
_saProfiles.set(id, p);
|
|
350
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function _saCheckP(from, to) {
|
|
354
|
+
const allowed = _saProfileTrans.get(from);
|
|
355
|
+
if (!allowed || !allowed.has(to))
|
|
356
|
+
throw new Error(`invalid subagent profile transition ${from} → ${to}`);
|
|
357
|
+
}
|
|
358
|
+
function _saCountActiveByOwner(owner) {
|
|
359
|
+
let n = 0;
|
|
360
|
+
for (const p of _saProfiles.values())
|
|
361
|
+
if (p.owner === owner && p.status === SUBAGENT_PROFILE_MATURITY_V2.ACTIVE)
|
|
362
|
+
n++;
|
|
363
|
+
return n;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function activateSubagentProfileV2(id) {
|
|
367
|
+
const p = _saProfiles.get(id);
|
|
368
|
+
if (!p) throw new Error(`subagent profile ${id} not found`);
|
|
369
|
+
_saCheckP(p.status, SUBAGENT_PROFILE_MATURITY_V2.ACTIVE);
|
|
370
|
+
const recovery = p.status === SUBAGENT_PROFILE_MATURITY_V2.PAUSED;
|
|
371
|
+
if (!recovery) {
|
|
372
|
+
const a = _saCountActiveByOwner(p.owner);
|
|
373
|
+
if (a >= _saMaxActivePerOwner)
|
|
374
|
+
throw new Error(
|
|
375
|
+
`max active subagents per owner (${_saMaxActivePerOwner}) reached for ${p.owner}`,
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
const now = Date.now();
|
|
379
|
+
p.status = SUBAGENT_PROFILE_MATURITY_V2.ACTIVE;
|
|
380
|
+
p.updatedAt = now;
|
|
381
|
+
p.lastTouchedAt = now;
|
|
382
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
383
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
384
|
+
}
|
|
385
|
+
export function pauseSubagentProfileV2(id) {
|
|
386
|
+
const p = _saProfiles.get(id);
|
|
387
|
+
if (!p) throw new Error(`subagent profile ${id} not found`);
|
|
388
|
+
_saCheckP(p.status, SUBAGENT_PROFILE_MATURITY_V2.PAUSED);
|
|
389
|
+
p.status = SUBAGENT_PROFILE_MATURITY_V2.PAUSED;
|
|
390
|
+
p.updatedAt = Date.now();
|
|
391
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
392
|
+
}
|
|
393
|
+
export function retireSubagentProfileV2(id) {
|
|
394
|
+
const p = _saProfiles.get(id);
|
|
395
|
+
if (!p) throw new Error(`subagent profile ${id} not found`);
|
|
396
|
+
_saCheckP(p.status, SUBAGENT_PROFILE_MATURITY_V2.RETIRED);
|
|
397
|
+
const now = Date.now();
|
|
398
|
+
p.status = SUBAGENT_PROFILE_MATURITY_V2.RETIRED;
|
|
399
|
+
p.updatedAt = now;
|
|
400
|
+
if (!p.retiredAt) p.retiredAt = now;
|
|
401
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
402
|
+
}
|
|
403
|
+
export function touchSubagentProfileV2(id) {
|
|
404
|
+
const p = _saProfiles.get(id);
|
|
405
|
+
if (!p) throw new Error(`subagent profile ${id} not found`);
|
|
406
|
+
if (_saProfileTerminal.has(p.status))
|
|
407
|
+
throw new Error(`cannot touch terminal subagent profile ${id}`);
|
|
408
|
+
const now = Date.now();
|
|
409
|
+
p.lastTouchedAt = now;
|
|
410
|
+
p.updatedAt = now;
|
|
411
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
412
|
+
}
|
|
413
|
+
export function getSubagentProfileV2(id) {
|
|
414
|
+
const p = _saProfiles.get(id);
|
|
415
|
+
if (!p) return null;
|
|
416
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
417
|
+
}
|
|
418
|
+
export function listSubagentProfilesV2() {
|
|
419
|
+
return [..._saProfiles.values()].map((p) => ({
|
|
420
|
+
...p,
|
|
421
|
+
metadata: { ...p.metadata },
|
|
422
|
+
}));
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function _saCountPendingByProfile(pid) {
|
|
426
|
+
let n = 0;
|
|
427
|
+
for (const t of _saTasks.values())
|
|
428
|
+
if (
|
|
429
|
+
t.profileId === pid &&
|
|
430
|
+
(t.status === SUBAGENT_TASK_LIFECYCLE_V2.QUEUED ||
|
|
431
|
+
t.status === SUBAGENT_TASK_LIFECYCLE_V2.RUNNING)
|
|
432
|
+
)
|
|
433
|
+
n++;
|
|
434
|
+
return n;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export function createSubagentTaskV2({
|
|
438
|
+
id,
|
|
439
|
+
profileId,
|
|
440
|
+
description,
|
|
441
|
+
metadata,
|
|
442
|
+
} = {}) {
|
|
443
|
+
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
444
|
+
if (!profileId || typeof profileId !== "string")
|
|
445
|
+
throw new Error("profileId is required");
|
|
446
|
+
if (_saTasks.has(id)) throw new Error(`subagent task ${id} already exists`);
|
|
447
|
+
if (!_saProfiles.has(profileId))
|
|
448
|
+
throw new Error(`subagent profile ${profileId} not found`);
|
|
449
|
+
const pending = _saCountPendingByProfile(profileId);
|
|
450
|
+
if (pending >= _saMaxPendingPerProfile)
|
|
451
|
+
throw new Error(
|
|
452
|
+
`max pending tasks per subagent (${_saMaxPendingPerProfile}) reached for ${profileId}`,
|
|
453
|
+
);
|
|
454
|
+
const now = Date.now();
|
|
455
|
+
const t = {
|
|
456
|
+
id,
|
|
457
|
+
profileId,
|
|
458
|
+
description: description || "",
|
|
459
|
+
status: SUBAGENT_TASK_LIFECYCLE_V2.QUEUED,
|
|
460
|
+
createdAt: now,
|
|
461
|
+
updatedAt: now,
|
|
462
|
+
startedAt: null,
|
|
463
|
+
settledAt: null,
|
|
464
|
+
metadata: { ...(metadata || {}) },
|
|
465
|
+
};
|
|
466
|
+
_saTasks.set(id, t);
|
|
467
|
+
return { ...t, metadata: { ...t.metadata } };
|
|
468
|
+
}
|
|
469
|
+
function _saCheckT(from, to) {
|
|
470
|
+
const allowed = _saTaskTrans.get(from);
|
|
471
|
+
if (!allowed || !allowed.has(to))
|
|
472
|
+
throw new Error(`invalid subagent task transition ${from} → ${to}`);
|
|
473
|
+
}
|
|
474
|
+
export function startSubagentTaskV2(id) {
|
|
475
|
+
const t = _saTasks.get(id);
|
|
476
|
+
if (!t) throw new Error(`subagent task ${id} not found`);
|
|
477
|
+
_saCheckT(t.status, SUBAGENT_TASK_LIFECYCLE_V2.RUNNING);
|
|
478
|
+
const now = Date.now();
|
|
479
|
+
t.status = SUBAGENT_TASK_LIFECYCLE_V2.RUNNING;
|
|
480
|
+
t.updatedAt = now;
|
|
481
|
+
if (!t.startedAt) t.startedAt = now;
|
|
482
|
+
return { ...t, metadata: { ...t.metadata } };
|
|
483
|
+
}
|
|
484
|
+
export function completeSubagentTaskV2(id) {
|
|
485
|
+
const t = _saTasks.get(id);
|
|
486
|
+
if (!t) throw new Error(`subagent task ${id} not found`);
|
|
487
|
+
_saCheckT(t.status, SUBAGENT_TASK_LIFECYCLE_V2.COMPLETED);
|
|
488
|
+
const now = Date.now();
|
|
489
|
+
t.status = SUBAGENT_TASK_LIFECYCLE_V2.COMPLETED;
|
|
490
|
+
t.updatedAt = now;
|
|
491
|
+
if (!t.settledAt) t.settledAt = now;
|
|
492
|
+
return { ...t, metadata: { ...t.metadata } };
|
|
493
|
+
}
|
|
494
|
+
export function failSubagentTaskV2(id, reason) {
|
|
495
|
+
const t = _saTasks.get(id);
|
|
496
|
+
if (!t) throw new Error(`subagent task ${id} not found`);
|
|
497
|
+
_saCheckT(t.status, SUBAGENT_TASK_LIFECYCLE_V2.FAILED);
|
|
498
|
+
const now = Date.now();
|
|
499
|
+
t.status = SUBAGENT_TASK_LIFECYCLE_V2.FAILED;
|
|
500
|
+
t.updatedAt = now;
|
|
501
|
+
if (!t.settledAt) t.settledAt = now;
|
|
502
|
+
if (reason) t.metadata.failReason = String(reason);
|
|
503
|
+
return { ...t, metadata: { ...t.metadata } };
|
|
504
|
+
}
|
|
505
|
+
export function cancelSubagentTaskV2(id, reason) {
|
|
506
|
+
const t = _saTasks.get(id);
|
|
507
|
+
if (!t) throw new Error(`subagent task ${id} not found`);
|
|
508
|
+
_saCheckT(t.status, SUBAGENT_TASK_LIFECYCLE_V2.CANCELLED);
|
|
509
|
+
const now = Date.now();
|
|
510
|
+
t.status = SUBAGENT_TASK_LIFECYCLE_V2.CANCELLED;
|
|
511
|
+
t.updatedAt = now;
|
|
512
|
+
if (!t.settledAt) t.settledAt = now;
|
|
513
|
+
if (reason) t.metadata.cancelReason = String(reason);
|
|
514
|
+
return { ...t, metadata: { ...t.metadata } };
|
|
515
|
+
}
|
|
516
|
+
export function getSubagentTaskV2(id) {
|
|
517
|
+
const t = _saTasks.get(id);
|
|
518
|
+
if (!t) return null;
|
|
519
|
+
return { ...t, metadata: { ...t.metadata } };
|
|
520
|
+
}
|
|
521
|
+
export function listSubagentTasksV2() {
|
|
522
|
+
return [..._saTasks.values()].map((t) => ({
|
|
523
|
+
...t,
|
|
524
|
+
metadata: { ...t.metadata },
|
|
525
|
+
}));
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export function autoPauseIdleSubagentsV2({ now } = {}) {
|
|
529
|
+
const t = now ?? Date.now();
|
|
530
|
+
const flipped = [];
|
|
531
|
+
for (const p of _saProfiles.values())
|
|
532
|
+
if (
|
|
533
|
+
p.status === SUBAGENT_PROFILE_MATURITY_V2.ACTIVE &&
|
|
534
|
+
t - p.lastTouchedAt >= _saProfileIdleMs
|
|
535
|
+
) {
|
|
536
|
+
p.status = SUBAGENT_PROFILE_MATURITY_V2.PAUSED;
|
|
537
|
+
p.updatedAt = t;
|
|
538
|
+
flipped.push(p.id);
|
|
539
|
+
}
|
|
540
|
+
return { flipped, count: flipped.length };
|
|
541
|
+
}
|
|
542
|
+
export function autoFailStuckSubagentTasksV2({ now } = {}) {
|
|
543
|
+
const t = now ?? Date.now();
|
|
544
|
+
const flipped = [];
|
|
545
|
+
for (const k of _saTasks.values())
|
|
546
|
+
if (
|
|
547
|
+
k.status === SUBAGENT_TASK_LIFECYCLE_V2.RUNNING &&
|
|
548
|
+
k.startedAt != null &&
|
|
549
|
+
t - k.startedAt >= _saTaskStuckMs
|
|
550
|
+
) {
|
|
551
|
+
k.status = SUBAGENT_TASK_LIFECYCLE_V2.FAILED;
|
|
552
|
+
k.updatedAt = t;
|
|
553
|
+
if (!k.settledAt) k.settledAt = t;
|
|
554
|
+
k.metadata.failReason = "auto-fail-stuck";
|
|
555
|
+
flipped.push(k.id);
|
|
556
|
+
}
|
|
557
|
+
return { flipped, count: flipped.length };
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export function getSubAgentRegistryStatsV2() {
|
|
561
|
+
const profilesByStatus = {};
|
|
562
|
+
for (const s of Object.values(SUBAGENT_PROFILE_MATURITY_V2))
|
|
563
|
+
profilesByStatus[s] = 0;
|
|
564
|
+
for (const p of _saProfiles.values()) profilesByStatus[p.status]++;
|
|
565
|
+
const tasksByStatus = {};
|
|
566
|
+
for (const s of Object.values(SUBAGENT_TASK_LIFECYCLE_V2))
|
|
567
|
+
tasksByStatus[s] = 0;
|
|
568
|
+
for (const t of _saTasks.values()) tasksByStatus[t.status]++;
|
|
569
|
+
return {
|
|
570
|
+
totalProfilesV2: _saProfiles.size,
|
|
571
|
+
totalTasksV2: _saTasks.size,
|
|
572
|
+
maxActiveSubagentsPerOwner: _saMaxActivePerOwner,
|
|
573
|
+
maxPendingTasksPerSubagent: _saMaxPendingPerProfile,
|
|
574
|
+
subagentIdleMs: _saProfileIdleMs,
|
|
575
|
+
subagentTaskStuckMs: _saTaskStuckMs,
|
|
576
|
+
profilesByStatus,
|
|
577
|
+
tasksByStatus,
|
|
578
|
+
};
|
|
579
|
+
}
|
|
@@ -242,3 +242,336 @@ export function getTaskName(taskType) {
|
|
|
242
242
|
export function getTaskTypes() {
|
|
243
243
|
return { ...TaskType };
|
|
244
244
|
}
|
|
245
|
+
|
|
246
|
+
// ===== V2 Surface: Task Model Selector governance overlay (CLI v0.141.0) =====
|
|
247
|
+
export const TMS_PROFILE_MATURITY_V2 = Object.freeze({
|
|
248
|
+
PENDING: "pending",
|
|
249
|
+
ACTIVE: "active",
|
|
250
|
+
STALE: "stale",
|
|
251
|
+
DECOMMISSIONED: "decommissioned",
|
|
252
|
+
});
|
|
253
|
+
export const TMS_SELECTION_LIFECYCLE_V2 = Object.freeze({
|
|
254
|
+
QUEUED: "queued",
|
|
255
|
+
SCORING: "scoring",
|
|
256
|
+
COMPLETED: "completed",
|
|
257
|
+
FAILED: "failed",
|
|
258
|
+
CANCELLED: "cancelled",
|
|
259
|
+
});
|
|
260
|
+
const _tmsPTrans = new Map([
|
|
261
|
+
[
|
|
262
|
+
TMS_PROFILE_MATURITY_V2.PENDING,
|
|
263
|
+
new Set([
|
|
264
|
+
TMS_PROFILE_MATURITY_V2.ACTIVE,
|
|
265
|
+
TMS_PROFILE_MATURITY_V2.DECOMMISSIONED,
|
|
266
|
+
]),
|
|
267
|
+
],
|
|
268
|
+
[
|
|
269
|
+
TMS_PROFILE_MATURITY_V2.ACTIVE,
|
|
270
|
+
new Set([
|
|
271
|
+
TMS_PROFILE_MATURITY_V2.STALE,
|
|
272
|
+
TMS_PROFILE_MATURITY_V2.DECOMMISSIONED,
|
|
273
|
+
]),
|
|
274
|
+
],
|
|
275
|
+
[
|
|
276
|
+
TMS_PROFILE_MATURITY_V2.STALE,
|
|
277
|
+
new Set([
|
|
278
|
+
TMS_PROFILE_MATURITY_V2.ACTIVE,
|
|
279
|
+
TMS_PROFILE_MATURITY_V2.DECOMMISSIONED,
|
|
280
|
+
]),
|
|
281
|
+
],
|
|
282
|
+
[TMS_PROFILE_MATURITY_V2.DECOMMISSIONED, new Set()],
|
|
283
|
+
]);
|
|
284
|
+
const _tmsPTerminal = new Set([TMS_PROFILE_MATURITY_V2.DECOMMISSIONED]);
|
|
285
|
+
const _tmsSTrans = new Map([
|
|
286
|
+
[
|
|
287
|
+
TMS_SELECTION_LIFECYCLE_V2.QUEUED,
|
|
288
|
+
new Set([
|
|
289
|
+
TMS_SELECTION_LIFECYCLE_V2.SCORING,
|
|
290
|
+
TMS_SELECTION_LIFECYCLE_V2.CANCELLED,
|
|
291
|
+
]),
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
TMS_SELECTION_LIFECYCLE_V2.SCORING,
|
|
295
|
+
new Set([
|
|
296
|
+
TMS_SELECTION_LIFECYCLE_V2.COMPLETED,
|
|
297
|
+
TMS_SELECTION_LIFECYCLE_V2.FAILED,
|
|
298
|
+
TMS_SELECTION_LIFECYCLE_V2.CANCELLED,
|
|
299
|
+
]),
|
|
300
|
+
],
|
|
301
|
+
[TMS_SELECTION_LIFECYCLE_V2.COMPLETED, new Set()],
|
|
302
|
+
[TMS_SELECTION_LIFECYCLE_V2.FAILED, new Set()],
|
|
303
|
+
[TMS_SELECTION_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
304
|
+
]);
|
|
305
|
+
const _tmsPsV2 = new Map();
|
|
306
|
+
const _tmsSsV2 = new Map();
|
|
307
|
+
let _tmsMaxActivePerOwner = 8,
|
|
308
|
+
_tmsMaxPendingSelPerProfile = 16,
|
|
309
|
+
_tmsIdleMs = 14 * 24 * 60 * 60 * 1000,
|
|
310
|
+
_tmsStuckMs = 2 * 60 * 1000;
|
|
311
|
+
function _tmsPos(n, label) {
|
|
312
|
+
const v = Math.floor(Number(n));
|
|
313
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
314
|
+
throw new Error(`${label} must be positive integer`);
|
|
315
|
+
return v;
|
|
316
|
+
}
|
|
317
|
+
function _tmsCheckP(from, to) {
|
|
318
|
+
const a = _tmsPTrans.get(from);
|
|
319
|
+
if (!a || !a.has(to))
|
|
320
|
+
throw new Error(`invalid tms profile transition ${from} → ${to}`);
|
|
321
|
+
}
|
|
322
|
+
function _tmsCheckS(from, to) {
|
|
323
|
+
const a = _tmsSTrans.get(from);
|
|
324
|
+
if (!a || !a.has(to))
|
|
325
|
+
throw new Error(`invalid tms selection transition ${from} → ${to}`);
|
|
326
|
+
}
|
|
327
|
+
export function setMaxActiveTmsProfilesPerOwnerV2(n) {
|
|
328
|
+
_tmsMaxActivePerOwner = _tmsPos(n, "maxActiveTmsProfilesPerOwner");
|
|
329
|
+
}
|
|
330
|
+
export function getMaxActiveTmsProfilesPerOwnerV2() {
|
|
331
|
+
return _tmsMaxActivePerOwner;
|
|
332
|
+
}
|
|
333
|
+
export function setMaxPendingTmsSelectionsPerProfileV2(n) {
|
|
334
|
+
_tmsMaxPendingSelPerProfile = _tmsPos(n, "maxPendingTmsSelectionsPerProfile");
|
|
335
|
+
}
|
|
336
|
+
export function getMaxPendingTmsSelectionsPerProfileV2() {
|
|
337
|
+
return _tmsMaxPendingSelPerProfile;
|
|
338
|
+
}
|
|
339
|
+
export function setTmsProfileIdleMsV2(n) {
|
|
340
|
+
_tmsIdleMs = _tmsPos(n, "tmsProfileIdleMs");
|
|
341
|
+
}
|
|
342
|
+
export function getTmsProfileIdleMsV2() {
|
|
343
|
+
return _tmsIdleMs;
|
|
344
|
+
}
|
|
345
|
+
export function setTmsSelectionStuckMsV2(n) {
|
|
346
|
+
_tmsStuckMs = _tmsPos(n, "tmsSelectionStuckMs");
|
|
347
|
+
}
|
|
348
|
+
export function getTmsSelectionStuckMsV2() {
|
|
349
|
+
return _tmsStuckMs;
|
|
350
|
+
}
|
|
351
|
+
export function _resetStateTaskModelSelectorV2() {
|
|
352
|
+
_tmsPsV2.clear();
|
|
353
|
+
_tmsSsV2.clear();
|
|
354
|
+
_tmsMaxActivePerOwner = 8;
|
|
355
|
+
_tmsMaxPendingSelPerProfile = 16;
|
|
356
|
+
_tmsIdleMs = 14 * 24 * 60 * 60 * 1000;
|
|
357
|
+
_tmsStuckMs = 2 * 60 * 1000;
|
|
358
|
+
}
|
|
359
|
+
export function registerTmsProfileV2({ id, owner, strategy, metadata } = {}) {
|
|
360
|
+
if (!id) throw new Error("tms profile id required");
|
|
361
|
+
if (!owner) throw new Error("tms profile owner required");
|
|
362
|
+
if (_tmsPsV2.has(id)) throw new Error(`tms profile ${id} already registered`);
|
|
363
|
+
const now = Date.now();
|
|
364
|
+
const p = {
|
|
365
|
+
id,
|
|
366
|
+
owner,
|
|
367
|
+
strategy: strategy || "default",
|
|
368
|
+
status: TMS_PROFILE_MATURITY_V2.PENDING,
|
|
369
|
+
createdAt: now,
|
|
370
|
+
updatedAt: now,
|
|
371
|
+
activatedAt: null,
|
|
372
|
+
decommissionedAt: null,
|
|
373
|
+
lastTouchedAt: now,
|
|
374
|
+
metadata: { ...(metadata || {}) },
|
|
375
|
+
};
|
|
376
|
+
_tmsPsV2.set(id, p);
|
|
377
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
378
|
+
}
|
|
379
|
+
function _tmsCountActive(owner) {
|
|
380
|
+
let n = 0;
|
|
381
|
+
for (const p of _tmsPsV2.values())
|
|
382
|
+
if (p.owner === owner && p.status === TMS_PROFILE_MATURITY_V2.ACTIVE) n++;
|
|
383
|
+
return n;
|
|
384
|
+
}
|
|
385
|
+
export function activateTmsProfileV2(id) {
|
|
386
|
+
const p = _tmsPsV2.get(id);
|
|
387
|
+
if (!p) throw new Error(`tms profile ${id} not found`);
|
|
388
|
+
_tmsCheckP(p.status, TMS_PROFILE_MATURITY_V2.ACTIVE);
|
|
389
|
+
const recovery = p.status === TMS_PROFILE_MATURITY_V2.STALE;
|
|
390
|
+
if (!recovery && _tmsCountActive(p.owner) >= _tmsMaxActivePerOwner)
|
|
391
|
+
throw new Error(`max active tms profiles for owner ${p.owner} reached`);
|
|
392
|
+
const now = Date.now();
|
|
393
|
+
p.status = TMS_PROFILE_MATURITY_V2.ACTIVE;
|
|
394
|
+
p.updatedAt = now;
|
|
395
|
+
p.lastTouchedAt = now;
|
|
396
|
+
if (!p.activatedAt) p.activatedAt = now;
|
|
397
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
398
|
+
}
|
|
399
|
+
export function staleTmsProfileV2(id) {
|
|
400
|
+
const p = _tmsPsV2.get(id);
|
|
401
|
+
if (!p) throw new Error(`tms profile ${id} not found`);
|
|
402
|
+
_tmsCheckP(p.status, TMS_PROFILE_MATURITY_V2.STALE);
|
|
403
|
+
p.status = TMS_PROFILE_MATURITY_V2.STALE;
|
|
404
|
+
p.updatedAt = Date.now();
|
|
405
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
406
|
+
}
|
|
407
|
+
export function decommissionTmsProfileV2(id) {
|
|
408
|
+
const p = _tmsPsV2.get(id);
|
|
409
|
+
if (!p) throw new Error(`tms profile ${id} not found`);
|
|
410
|
+
_tmsCheckP(p.status, TMS_PROFILE_MATURITY_V2.DECOMMISSIONED);
|
|
411
|
+
const now = Date.now();
|
|
412
|
+
p.status = TMS_PROFILE_MATURITY_V2.DECOMMISSIONED;
|
|
413
|
+
p.updatedAt = now;
|
|
414
|
+
if (!p.decommissionedAt) p.decommissionedAt = now;
|
|
415
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
416
|
+
}
|
|
417
|
+
export function touchTmsProfileV2(id) {
|
|
418
|
+
const p = _tmsPsV2.get(id);
|
|
419
|
+
if (!p) throw new Error(`tms profile ${id} not found`);
|
|
420
|
+
if (_tmsPTerminal.has(p.status))
|
|
421
|
+
throw new Error(`cannot touch terminal tms profile ${id}`);
|
|
422
|
+
const now = Date.now();
|
|
423
|
+
p.lastTouchedAt = now;
|
|
424
|
+
p.updatedAt = now;
|
|
425
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
426
|
+
}
|
|
427
|
+
export function getTmsProfileV2(id) {
|
|
428
|
+
const p = _tmsPsV2.get(id);
|
|
429
|
+
if (!p) return null;
|
|
430
|
+
return { ...p, metadata: { ...p.metadata } };
|
|
431
|
+
}
|
|
432
|
+
export function listTmsProfilesV2() {
|
|
433
|
+
return [..._tmsPsV2.values()].map((p) => ({
|
|
434
|
+
...p,
|
|
435
|
+
metadata: { ...p.metadata },
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
438
|
+
function _tmsCountPending(profileId) {
|
|
439
|
+
let n = 0;
|
|
440
|
+
for (const s of _tmsSsV2.values())
|
|
441
|
+
if (
|
|
442
|
+
s.profileId === profileId &&
|
|
443
|
+
(s.status === TMS_SELECTION_LIFECYCLE_V2.QUEUED ||
|
|
444
|
+
s.status === TMS_SELECTION_LIFECYCLE_V2.SCORING)
|
|
445
|
+
)
|
|
446
|
+
n++;
|
|
447
|
+
return n;
|
|
448
|
+
}
|
|
449
|
+
export function createTmsSelectionV2({ id, profileId, task, metadata } = {}) {
|
|
450
|
+
if (!id) throw new Error("tms selection id required");
|
|
451
|
+
if (!profileId) throw new Error("tms selection profileId required");
|
|
452
|
+
if (_tmsSsV2.has(id)) throw new Error(`tms selection ${id} already exists`);
|
|
453
|
+
if (!_tmsPsV2.has(profileId))
|
|
454
|
+
throw new Error(`tms profile ${profileId} not found`);
|
|
455
|
+
if (_tmsCountPending(profileId) >= _tmsMaxPendingSelPerProfile)
|
|
456
|
+
throw new Error(
|
|
457
|
+
`max pending tms selections for profile ${profileId} reached`,
|
|
458
|
+
);
|
|
459
|
+
const now = Date.now();
|
|
460
|
+
const s = {
|
|
461
|
+
id,
|
|
462
|
+
profileId,
|
|
463
|
+
task: task || "",
|
|
464
|
+
status: TMS_SELECTION_LIFECYCLE_V2.QUEUED,
|
|
465
|
+
createdAt: now,
|
|
466
|
+
updatedAt: now,
|
|
467
|
+
startedAt: null,
|
|
468
|
+
settledAt: null,
|
|
469
|
+
metadata: { ...(metadata || {}) },
|
|
470
|
+
};
|
|
471
|
+
_tmsSsV2.set(id, s);
|
|
472
|
+
return { ...s, metadata: { ...s.metadata } };
|
|
473
|
+
}
|
|
474
|
+
export function scoreTmsSelectionV2(id) {
|
|
475
|
+
const s = _tmsSsV2.get(id);
|
|
476
|
+
if (!s) throw new Error(`tms selection ${id} not found`);
|
|
477
|
+
_tmsCheckS(s.status, TMS_SELECTION_LIFECYCLE_V2.SCORING);
|
|
478
|
+
const now = Date.now();
|
|
479
|
+
s.status = TMS_SELECTION_LIFECYCLE_V2.SCORING;
|
|
480
|
+
s.updatedAt = now;
|
|
481
|
+
if (!s.startedAt) s.startedAt = now;
|
|
482
|
+
return { ...s, metadata: { ...s.metadata } };
|
|
483
|
+
}
|
|
484
|
+
export function completeTmsSelectionV2(id) {
|
|
485
|
+
const s = _tmsSsV2.get(id);
|
|
486
|
+
if (!s) throw new Error(`tms selection ${id} not found`);
|
|
487
|
+
_tmsCheckS(s.status, TMS_SELECTION_LIFECYCLE_V2.COMPLETED);
|
|
488
|
+
const now = Date.now();
|
|
489
|
+
s.status = TMS_SELECTION_LIFECYCLE_V2.COMPLETED;
|
|
490
|
+
s.updatedAt = now;
|
|
491
|
+
if (!s.settledAt) s.settledAt = now;
|
|
492
|
+
return { ...s, metadata: { ...s.metadata } };
|
|
493
|
+
}
|
|
494
|
+
export function failTmsSelectionV2(id, reason) {
|
|
495
|
+
const s = _tmsSsV2.get(id);
|
|
496
|
+
if (!s) throw new Error(`tms selection ${id} not found`);
|
|
497
|
+
_tmsCheckS(s.status, TMS_SELECTION_LIFECYCLE_V2.FAILED);
|
|
498
|
+
const now = Date.now();
|
|
499
|
+
s.status = TMS_SELECTION_LIFECYCLE_V2.FAILED;
|
|
500
|
+
s.updatedAt = now;
|
|
501
|
+
if (!s.settledAt) s.settledAt = now;
|
|
502
|
+
if (reason) s.metadata.failReason = String(reason);
|
|
503
|
+
return { ...s, metadata: { ...s.metadata } };
|
|
504
|
+
}
|
|
505
|
+
export function cancelTmsSelectionV2(id, reason) {
|
|
506
|
+
const s = _tmsSsV2.get(id);
|
|
507
|
+
if (!s) throw new Error(`tms selection ${id} not found`);
|
|
508
|
+
_tmsCheckS(s.status, TMS_SELECTION_LIFECYCLE_V2.CANCELLED);
|
|
509
|
+
const now = Date.now();
|
|
510
|
+
s.status = TMS_SELECTION_LIFECYCLE_V2.CANCELLED;
|
|
511
|
+
s.updatedAt = now;
|
|
512
|
+
if (!s.settledAt) s.settledAt = now;
|
|
513
|
+
if (reason) s.metadata.cancelReason = String(reason);
|
|
514
|
+
return { ...s, metadata: { ...s.metadata } };
|
|
515
|
+
}
|
|
516
|
+
export function getTmsSelectionV2(id) {
|
|
517
|
+
const s = _tmsSsV2.get(id);
|
|
518
|
+
if (!s) return null;
|
|
519
|
+
return { ...s, metadata: { ...s.metadata } };
|
|
520
|
+
}
|
|
521
|
+
export function listTmsSelectionsV2() {
|
|
522
|
+
return [..._tmsSsV2.values()].map((s) => ({
|
|
523
|
+
...s,
|
|
524
|
+
metadata: { ...s.metadata },
|
|
525
|
+
}));
|
|
526
|
+
}
|
|
527
|
+
export function autoStaleIdleTmsProfilesV2({ now } = {}) {
|
|
528
|
+
const t = now ?? Date.now();
|
|
529
|
+
const flipped = [];
|
|
530
|
+
for (const p of _tmsPsV2.values())
|
|
531
|
+
if (
|
|
532
|
+
p.status === TMS_PROFILE_MATURITY_V2.ACTIVE &&
|
|
533
|
+
t - p.lastTouchedAt >= _tmsIdleMs
|
|
534
|
+
) {
|
|
535
|
+
p.status = TMS_PROFILE_MATURITY_V2.STALE;
|
|
536
|
+
p.updatedAt = t;
|
|
537
|
+
flipped.push(p.id);
|
|
538
|
+
}
|
|
539
|
+
return { flipped, count: flipped.length };
|
|
540
|
+
}
|
|
541
|
+
export function autoFailStuckTmsSelectionsV2({ now } = {}) {
|
|
542
|
+
const t = now ?? Date.now();
|
|
543
|
+
const flipped = [];
|
|
544
|
+
for (const s of _tmsSsV2.values())
|
|
545
|
+
if (
|
|
546
|
+
s.status === TMS_SELECTION_LIFECYCLE_V2.SCORING &&
|
|
547
|
+
s.startedAt != null &&
|
|
548
|
+
t - s.startedAt >= _tmsStuckMs
|
|
549
|
+
) {
|
|
550
|
+
s.status = TMS_SELECTION_LIFECYCLE_V2.FAILED;
|
|
551
|
+
s.updatedAt = t;
|
|
552
|
+
if (!s.settledAt) s.settledAt = t;
|
|
553
|
+
s.metadata.failReason = "auto-fail-stuck";
|
|
554
|
+
flipped.push(s.id);
|
|
555
|
+
}
|
|
556
|
+
return { flipped, count: flipped.length };
|
|
557
|
+
}
|
|
558
|
+
export function getTaskModelSelectorGovStatsV2() {
|
|
559
|
+
const profilesByStatus = {};
|
|
560
|
+
for (const v of Object.values(TMS_PROFILE_MATURITY_V2))
|
|
561
|
+
profilesByStatus[v] = 0;
|
|
562
|
+
for (const p of _tmsPsV2.values()) profilesByStatus[p.status]++;
|
|
563
|
+
const selectionsByStatus = {};
|
|
564
|
+
for (const v of Object.values(TMS_SELECTION_LIFECYCLE_V2))
|
|
565
|
+
selectionsByStatus[v] = 0;
|
|
566
|
+
for (const s of _tmsSsV2.values()) selectionsByStatus[s.status]++;
|
|
567
|
+
return {
|
|
568
|
+
totalTmsProfilesV2: _tmsPsV2.size,
|
|
569
|
+
totalTmsSelectionsV2: _tmsSsV2.size,
|
|
570
|
+
maxActiveTmsProfilesPerOwner: _tmsMaxActivePerOwner,
|
|
571
|
+
maxPendingTmsSelectionsPerProfile: _tmsMaxPendingSelPerProfile,
|
|
572
|
+
tmsProfileIdleMs: _tmsIdleMs,
|
|
573
|
+
tmsSelectionStuckMs: _tmsStuckMs,
|
|
574
|
+
profilesByStatus,
|
|
575
|
+
selectionsByStatus,
|
|
576
|
+
};
|
|
577
|
+
}
|