chainlesschain 0.81.0 → 0.143.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/bin/chainlesschain.js +0 -0
- package/package.json +1 -1
- package/src/commands/a2a.js +62 -0
- package/src/commands/activitypub.js +61 -0
- package/src/commands/agent-network.js +254 -1
- package/src/commands/agent.js +117 -0
- package/src/commands/audit.js +302 -0
- package/src/commands/automation.js +271 -1
- package/src/commands/bi.js +61 -0
- package/src/commands/bm25.js +78 -0
- package/src/commands/browse.js +64 -0
- package/src/commands/ccron.js +78 -0
- package/src/commands/codegen.js +224 -0
- package/src/commands/collab.js +341 -0
- package/src/commands/compliance.js +1075 -0
- package/src/commands/compt.js +78 -0
- package/src/commands/consol.js +231 -0
- package/src/commands/cowork.js +263 -0
- package/src/commands/crosschain.js +62 -0
- package/src/commands/dao.js +62 -0
- package/src/commands/dbevo.js +284 -0
- package/src/commands/dev.js +252 -0
- package/src/commands/did.js +358 -0
- package/src/commands/dlp.js +61 -0
- package/src/commands/economy.js +56 -0
- package/src/commands/encrypt.js +341 -0
- package/src/commands/evolution.js +56 -0
- package/src/commands/evomap.js +61 -0
- package/src/commands/export.js +256 -1
- package/src/commands/fflag.js +178 -0
- package/src/commands/fusion.js +258 -0
- package/src/commands/git.js +45 -0
- package/src/commands/governance.js +325 -0
- package/src/commands/hardening.js +411 -0
- package/src/commands/hmemory.js +56 -0
- package/src/commands/hook.js +148 -0
- package/src/commands/import.js +252 -0
- package/src/commands/incentive.js +322 -0
- package/src/commands/inference.js +42 -0
- package/src/commands/infra.js +244 -0
- package/src/commands/instinct.js +260 -0
- package/src/commands/ipfs.js +318 -0
- package/src/commands/itbudget.js +45 -0
- package/src/commands/kg.js +387 -0
- package/src/commands/llm.js +263 -0
- package/src/commands/lowcode.js +44 -0
- package/src/commands/matrix.js +62 -0
- package/src/commands/mcp.js +221 -0
- package/src/commands/mcpscaf.js +41 -0
- package/src/commands/meminj.js +41 -0
- package/src/commands/memory.js +248 -0
- package/src/commands/multimodal.js +296 -0
- package/src/commands/nlprog.js +356 -0
- package/src/commands/nostr.js +62 -0
- package/src/commands/note.js +244 -0
- package/src/commands/ops.js +354 -0
- package/src/commands/orchestrate.js +166 -0
- package/src/commands/orchgov.js +45 -0
- package/src/commands/org.js +277 -0
- package/src/commands/p2p.js +390 -0
- package/src/commands/pdfp.js +78 -0
- package/src/commands/perception.js +290 -0
- package/src/commands/perf.js +39 -0
- package/src/commands/perm.js +45 -0
- package/src/commands/permmem.js +251 -0
- package/src/commands/pipeline.js +57 -1
- package/src/commands/planmode.js +45 -0
- package/src/commands/plugin-ecosystem.js +273 -0
- package/src/commands/pqc.js +393 -0
- package/src/commands/promcomp.js +82 -0
- package/src/commands/quantization.js +351 -0
- package/src/commands/rcache.js +271 -0
- package/src/commands/recommend.js +382 -0
- package/src/commands/runtime.js +307 -0
- package/src/commands/scim.js +262 -0
- package/src/commands/seshhook.js +41 -0
- package/src/commands/seshsearch.js +41 -0
- package/src/commands/seshtail.js +41 -0
- package/src/commands/seshu.js +41 -0
- package/src/commands/session.js +258 -0
- package/src/commands/sganal.js +78 -0
- package/src/commands/siem.js +40 -0
- package/src/commands/skill.js +267 -1
- package/src/commands/slotfill.js +41 -0
- package/src/commands/social.js +290 -0
- package/src/commands/sso.js +186 -1
- package/src/commands/svccont.js +45 -0
- package/src/commands/sync.js +256 -0
- package/src/commands/tech.js +338 -0
- package/src/commands/tenant.js +351 -0
- package/src/commands/tms.js +45 -0
- package/src/commands/tokens.js +269 -0
- package/src/commands/topiccls.js +45 -0
- package/src/commands/trust.js +249 -0
- package/src/commands/uprof.js +45 -0
- package/src/commands/vcheck.js +78 -0
- package/src/commands/wallet.js +277 -0
- package/src/commands/webfetch.js +41 -0
- package/src/commands/workflow.js +171 -0
- package/src/commands/zkp.js +62 -0
- package/src/harness/prompt-compressor.js +331 -0
- package/src/index.js +65 -1
- package/src/lib/a2a-protocol.js +105 -0
- package/src/lib/activitypub-bridge.js +105 -0
- package/src/lib/agent-coordinator.js +325 -0
- package/src/lib/agent-economy.js +105 -0
- package/src/lib/agent-network.js +387 -0
- package/src/lib/agent-router.js +395 -0
- package/src/lib/aiops.js +478 -0
- package/src/lib/app-builder.js +105 -0
- package/src/lib/audit-logger.js +379 -0
- package/src/lib/automation-engine.js +330 -0
- package/src/lib/autonomous-agent.js +105 -0
- package/src/lib/autonomous-developer.js +350 -0
- package/src/lib/bi-engine.js +105 -0
- package/src/lib/bm25-search.js +81 -0
- package/src/lib/browser-automation.js +105 -0
- package/src/lib/code-agent.js +323 -0
- package/src/lib/collaboration-governance.js +364 -0
- package/src/lib/community-governance.js +436 -0
- package/src/lib/compliance-framework-reporter.js +105 -0
- package/src/lib/compliance-manager.js +434 -0
- package/src/lib/compression-telemetry.js +81 -0
- package/src/lib/content-recommendation.js +469 -0
- package/src/lib/content-recommender.js +105 -0
- package/src/lib/cowork-cron.js +81 -0
- package/src/lib/cowork-task-runner.js +105 -0
- package/src/lib/cross-chain.js +105 -0
- package/src/lib/crypto-manager.js +350 -0
- package/src/lib/dao-governance.js +105 -0
- package/src/lib/dbevo.js +338 -0
- package/src/lib/decentral-infra.js +340 -0
- package/src/lib/did-manager.js +367 -0
- package/src/lib/dlp-engine.js +105 -0
- package/src/lib/evolution-system.js +105 -0
- package/src/lib/evomap-manager.js +105 -0
- package/src/lib/execution-backend.js +105 -0
- package/src/lib/feature-flags.js +85 -0
- package/src/lib/git-integration.js +105 -0
- package/src/lib/hardening-manager.js +348 -0
- package/src/lib/hierarchical-memory.js +105 -0
- package/src/lib/hook-manager.js +380 -0
- package/src/lib/inference-network.js +105 -0
- package/src/lib/instinct-manager.js +332 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/iteration-budget.js +105 -0
- package/src/lib/knowledge-exporter.js +381 -0
- package/src/lib/knowledge-graph.js +432 -0
- package/src/lib/knowledge-importer.js +379 -0
- package/src/lib/llm-providers.js +391 -0
- package/src/lib/matrix-bridge.js +105 -0
- package/src/lib/mcp-registry.js +333 -0
- package/src/lib/mcp-scaffold.js +81 -0
- package/src/lib/memory-injection.js +81 -0
- package/src/lib/memory-manager.js +330 -0
- package/src/lib/multimodal.js +346 -0
- package/src/lib/nl-programming.js +343 -0
- package/src/lib/nostr-bridge.js +105 -0
- package/src/lib/note-versioning.js +327 -0
- package/src/lib/orchestrator.js +105 -0
- package/src/lib/org-manager.js +323 -0
- package/src/lib/p2p-manager.js +387 -0
- package/src/lib/pdf-parser.js +81 -0
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +109 -1
- package/src/lib/permanent-memory.js +320 -0
- package/src/lib/permission-engine.js +81 -0
- package/src/lib/pipeline-orchestrator.js +105 -0
- package/src/lib/plan-mode.js +81 -0
- package/src/lib/plugin-ecosystem.js +377 -0
- package/src/lib/pqc-manager.js +368 -0
- package/src/lib/prompt-compressor.js +1 -10
- package/src/lib/protocol-fusion.js +417 -0
- package/src/lib/quantization.js +325 -0
- package/src/lib/response-cache.js +327 -0
- package/src/lib/scim-manager.js +329 -0
- package/src/lib/service-container.js +81 -0
- package/src/lib/session-consolidator.js +105 -0
- package/src/lib/session-hooks.js +81 -0
- package/src/lib/session-manager.js +329 -0
- package/src/lib/session-search.js +81 -0
- package/src/lib/session-tail.js +81 -0
- package/src/lib/session-usage.js +83 -0
- package/src/lib/siem-exporter.js +105 -0
- package/src/lib/skill-loader.js +377 -0
- package/src/lib/slot-filler.js +81 -0
- package/src/lib/social-graph-analytics.js +81 -0
- package/src/lib/social-graph.js +81 -0
- package/src/lib/social-manager.js +326 -0
- package/src/lib/sso-manager.js +332 -0
- package/src/lib/sub-agent-registry.js +110 -0
- package/src/lib/sync-manager.js +326 -0
- package/src/lib/task-model-selector.js +81 -0
- package/src/lib/tech-learning-engine.js +369 -0
- package/src/lib/tenant-saas.js +460 -0
- package/src/lib/threat-intel.js +335 -0
- package/src/lib/todo-manager.js +105 -0
- package/src/lib/token-incentive.js +293 -0
- package/src/lib/token-tracker.js +329 -0
- package/src/lib/topic-classifier.js +105 -0
- package/src/lib/trust-security.js +390 -0
- package/src/lib/ueba.js +389 -0
- package/src/lib/universal-runtime.js +325 -0
- package/src/lib/user-profile.js +81 -0
- package/src/lib/version-checker.js +81 -0
- package/src/lib/wallet-manager.js +326 -0
- package/src/lib/web-fetch.js +81 -0
- package/src/lib/workflow-engine.js +322 -0
- package/src/lib/zkp-engine.js +105 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cc tms` — Task Model Selector V2 governance overlay.
|
|
3
|
+
*
|
|
4
|
+
* In-memory governance for selector profiles + selection lifecycle, layered atop
|
|
5
|
+
* `lib/task-model-selector.js`. Independent of legacy heuristic selector helpers.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
TMS_PROFILE_MATURITY_V2, TMS_SELECTION_LIFECYCLE_V2,
|
|
10
|
+
setMaxActiveTmsProfilesPerOwnerV2, getMaxActiveTmsProfilesPerOwnerV2,
|
|
11
|
+
setMaxPendingTmsSelectionsPerProfileV2, getMaxPendingTmsSelectionsPerProfileV2,
|
|
12
|
+
setTmsProfileIdleMsV2, getTmsProfileIdleMsV2,
|
|
13
|
+
setTmsSelectionStuckMsV2, getTmsSelectionStuckMsV2,
|
|
14
|
+
registerTmsProfileV2, activateTmsProfileV2, staleTmsProfileV2, decommissionTmsProfileV2, touchTmsProfileV2, getTmsProfileV2, listTmsProfilesV2,
|
|
15
|
+
createTmsSelectionV2, scoreTmsSelectionV2, completeTmsSelectionV2, failTmsSelectionV2, cancelTmsSelectionV2, getTmsSelectionV2, listTmsSelectionsV2,
|
|
16
|
+
autoStaleIdleTmsProfilesV2, autoFailStuckTmsSelectionsV2, getTaskModelSelectorGovStatsV2, _resetStateTaskModelSelectorV2,
|
|
17
|
+
} from "../lib/task-model-selector.js";
|
|
18
|
+
|
|
19
|
+
export function registerTmsCommand(program) {
|
|
20
|
+
const tms = program.command("tms").description("Task Model Selector V2 governance");
|
|
21
|
+
tms.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: TMS_PROFILE_MATURITY_V2, selectionLifecycle: TMS_SELECTION_LIFECYCLE_V2 }, null, 2)));
|
|
22
|
+
tms.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveTmsProfilesPerOwner: getMaxActiveTmsProfilesPerOwnerV2(), maxPendingTmsSelectionsPerProfile: getMaxPendingTmsSelectionsPerProfileV2(), tmsProfileIdleMs: getTmsProfileIdleMsV2(), tmsSelectionStuckMs: getTmsSelectionStuckMsV2() }, null, 2)));
|
|
23
|
+
tms.command("set-max-active-v2 <n>").action((n) => { setMaxActiveTmsProfilesPerOwnerV2(Number(n)); console.log("ok"); });
|
|
24
|
+
tms.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingTmsSelectionsPerProfileV2(Number(n)); console.log("ok"); });
|
|
25
|
+
tms.command("set-idle-ms-v2 <n>").action((n) => { setTmsProfileIdleMsV2(Number(n)); console.log("ok"); });
|
|
26
|
+
tms.command("set-stuck-ms-v2 <n>").action((n) => { setTmsSelectionStuckMsV2(Number(n)); console.log("ok"); });
|
|
27
|
+
tms.command("register-profile-v2 <id> <owner>").option("--strategy <s>", "strategy").action((id, owner, o) => console.log(JSON.stringify(registerTmsProfileV2({ id, owner, strategy: o.strategy }), null, 2)));
|
|
28
|
+
tms.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activateTmsProfileV2(id), null, 2)));
|
|
29
|
+
tms.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(staleTmsProfileV2(id), null, 2)));
|
|
30
|
+
tms.command("decommission-profile-v2 <id>").action((id) => console.log(JSON.stringify(decommissionTmsProfileV2(id), null, 2)));
|
|
31
|
+
tms.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchTmsProfileV2(id), null, 2)));
|
|
32
|
+
tms.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getTmsProfileV2(id), null, 2)));
|
|
33
|
+
tms.command("list-profiles-v2").action(() => console.log(JSON.stringify(listTmsProfilesV2(), null, 2)));
|
|
34
|
+
tms.command("create-selection-v2 <id> <profileId>").option("--task <t>", "task").action((id, profileId, o) => console.log(JSON.stringify(createTmsSelectionV2({ id, profileId, task: o.task }), null, 2)));
|
|
35
|
+
tms.command("score-selection-v2 <id>").action((id) => console.log(JSON.stringify(scoreTmsSelectionV2(id), null, 2)));
|
|
36
|
+
tms.command("complete-selection-v2 <id>").action((id) => console.log(JSON.stringify(completeTmsSelectionV2(id), null, 2)));
|
|
37
|
+
tms.command("fail-selection-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failTmsSelectionV2(id, reason), null, 2)));
|
|
38
|
+
tms.command("cancel-selection-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelTmsSelectionV2(id, reason), null, 2)));
|
|
39
|
+
tms.command("get-selection-v2 <id>").action((id) => console.log(JSON.stringify(getTmsSelectionV2(id), null, 2)));
|
|
40
|
+
tms.command("list-selections-v2").action(() => console.log(JSON.stringify(listTmsSelectionsV2(), null, 2)));
|
|
41
|
+
tms.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdleTmsProfilesV2(), null, 2)));
|
|
42
|
+
tms.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckTmsSelectionsV2(), null, 2)));
|
|
43
|
+
tms.command("gov-stats-v2").action(() => console.log(JSON.stringify(getTaskModelSelectorGovStatsV2(), null, 2)));
|
|
44
|
+
tms.command("reset-state-v2").action(() => { _resetStateTaskModelSelectorV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
|
|
45
|
+
}
|
package/src/commands/tokens.js
CHANGED
|
@@ -11,6 +11,37 @@ import {
|
|
|
11
11
|
getTodayStats,
|
|
12
12
|
getCostBreakdown,
|
|
13
13
|
getRecentUsage,
|
|
14
|
+
BUDGET_MATURITY_V2,
|
|
15
|
+
USAGE_RECORD_LIFECYCLE_V2,
|
|
16
|
+
getMaxActiveBudgetsPerOwnerV2,
|
|
17
|
+
setMaxActiveBudgetsPerOwnerV2,
|
|
18
|
+
getMaxPendingRecordsPerBudgetV2,
|
|
19
|
+
setMaxPendingRecordsPerBudgetV2,
|
|
20
|
+
getBudgetIdleMsV2,
|
|
21
|
+
setBudgetIdleMsV2,
|
|
22
|
+
getRecordStuckMsV2,
|
|
23
|
+
setRecordStuckMsV2,
|
|
24
|
+
registerBudgetV2,
|
|
25
|
+
getBudgetV2,
|
|
26
|
+
listBudgetsV2,
|
|
27
|
+
setBudgetStatusV2,
|
|
28
|
+
activateBudgetV2,
|
|
29
|
+
suspendBudgetV2,
|
|
30
|
+
archiveBudgetV2,
|
|
31
|
+
touchBudgetV2,
|
|
32
|
+
getActiveBudgetCountV2,
|
|
33
|
+
createUsageRecordV2,
|
|
34
|
+
getUsageRecordV2,
|
|
35
|
+
listUsageRecordsV2,
|
|
36
|
+
setUsageRecordStatusV2,
|
|
37
|
+
recordUsageV2,
|
|
38
|
+
billUsageV2,
|
|
39
|
+
rejectUsageV2,
|
|
40
|
+
refundUsageV2,
|
|
41
|
+
getPendingRecordCountV2,
|
|
42
|
+
autoSuspendIdleBudgetsV2,
|
|
43
|
+
autoRejectStaleRecordsV2,
|
|
44
|
+
getTokenTrackerStatsV2,
|
|
14
45
|
} from "../lib/token-tracker.js";
|
|
15
46
|
import {
|
|
16
47
|
getCacheStats,
|
|
@@ -211,4 +242,242 @@ export function registerTokensCommand(program) {
|
|
|
211
242
|
process.exit(1);
|
|
212
243
|
}
|
|
213
244
|
});
|
|
245
|
+
|
|
246
|
+
// ── V2 Surface ──
|
|
247
|
+
|
|
248
|
+
const out = (json, obj) => {
|
|
249
|
+
if (json) console.log(JSON.stringify(obj, null, 2));
|
|
250
|
+
else console.log(JSON.stringify(obj, null, 2));
|
|
251
|
+
};
|
|
252
|
+
const tryRun = (fn) => {
|
|
253
|
+
try {
|
|
254
|
+
fn();
|
|
255
|
+
} catch (err) {
|
|
256
|
+
logger.error(err.message);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
tokens
|
|
262
|
+
.command("budget-maturities-v2")
|
|
263
|
+
.description("List V2 budget maturity states")
|
|
264
|
+
.action(() => out(true, Object.values(BUDGET_MATURITY_V2)));
|
|
265
|
+
|
|
266
|
+
tokens
|
|
267
|
+
.command("usage-record-lifecycles-v2")
|
|
268
|
+
.description("List V2 usage record lifecycle states")
|
|
269
|
+
.action(() => out(true, Object.values(USAGE_RECORD_LIFECYCLE_V2)));
|
|
270
|
+
|
|
271
|
+
tokens
|
|
272
|
+
.command("stats-v2")
|
|
273
|
+
.description("V2 token-tracker stats")
|
|
274
|
+
.action(() => out(true, getTokenTrackerStatsV2()));
|
|
275
|
+
|
|
276
|
+
tokens
|
|
277
|
+
.command("get-max-active-budgets-v2")
|
|
278
|
+
.description("Get max active budgets per owner (V2)")
|
|
279
|
+
.action(() =>
|
|
280
|
+
out(true, { maxActiveBudgetsPerOwner: getMaxActiveBudgetsPerOwnerV2() }),
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
tokens
|
|
284
|
+
.command("set-max-active-budgets-v2 <n>")
|
|
285
|
+
.description("Set max active budgets per owner (V2)")
|
|
286
|
+
.action((n) =>
|
|
287
|
+
tryRun(() => {
|
|
288
|
+
setMaxActiveBudgetsPerOwnerV2(Number(n));
|
|
289
|
+
out(true, {
|
|
290
|
+
maxActiveBudgetsPerOwner: getMaxActiveBudgetsPerOwnerV2(),
|
|
291
|
+
});
|
|
292
|
+
}),
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
tokens
|
|
296
|
+
.command("get-max-pending-records-v2")
|
|
297
|
+
.description("Get max pending records per budget (V2)")
|
|
298
|
+
.action(() =>
|
|
299
|
+
out(true, {
|
|
300
|
+
maxPendingRecordsPerBudget: getMaxPendingRecordsPerBudgetV2(),
|
|
301
|
+
}),
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
tokens
|
|
305
|
+
.command("set-max-pending-records-v2 <n>")
|
|
306
|
+
.description("Set max pending records per budget (V2)")
|
|
307
|
+
.action((n) =>
|
|
308
|
+
tryRun(() => {
|
|
309
|
+
setMaxPendingRecordsPerBudgetV2(Number(n));
|
|
310
|
+
out(true, {
|
|
311
|
+
maxPendingRecordsPerBudget: getMaxPendingRecordsPerBudgetV2(),
|
|
312
|
+
});
|
|
313
|
+
}),
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
tokens
|
|
317
|
+
.command("get-budget-idle-ms-v2")
|
|
318
|
+
.description("Get budget idle threshold (V2)")
|
|
319
|
+
.action(() => out(true, { budgetIdleMs: getBudgetIdleMsV2() }));
|
|
320
|
+
|
|
321
|
+
tokens
|
|
322
|
+
.command("set-budget-idle-ms-v2 <ms>")
|
|
323
|
+
.description("Set budget idle threshold (V2)")
|
|
324
|
+
.action((ms) =>
|
|
325
|
+
tryRun(() => {
|
|
326
|
+
setBudgetIdleMsV2(Number(ms));
|
|
327
|
+
out(true, { budgetIdleMs: getBudgetIdleMsV2() });
|
|
328
|
+
}),
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
tokens
|
|
332
|
+
.command("get-record-stuck-ms-v2")
|
|
333
|
+
.description("Get record stuck threshold (V2)")
|
|
334
|
+
.action(() => out(true, { recordStuckMs: getRecordStuckMsV2() }));
|
|
335
|
+
|
|
336
|
+
tokens
|
|
337
|
+
.command("set-record-stuck-ms-v2 <ms>")
|
|
338
|
+
.description("Set record stuck threshold (V2)")
|
|
339
|
+
.action((ms) =>
|
|
340
|
+
tryRun(() => {
|
|
341
|
+
setRecordStuckMsV2(Number(ms));
|
|
342
|
+
out(true, { recordStuckMs: getRecordStuckMsV2() });
|
|
343
|
+
}),
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
tokens
|
|
347
|
+
.command("active-budget-count-v2 <ownerId>")
|
|
348
|
+
.description("Active budget count for owner (V2)")
|
|
349
|
+
.action((ownerId) =>
|
|
350
|
+
out(true, { ownerId, count: getActiveBudgetCountV2(ownerId) }),
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
tokens
|
|
354
|
+
.command("pending-record-count-v2 <budgetId>")
|
|
355
|
+
.description("Pending record count for budget (V2)")
|
|
356
|
+
.action((budgetId) =>
|
|
357
|
+
out(true, { budgetId, count: getPendingRecordCountV2(budgetId) }),
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
tokens
|
|
361
|
+
.command("register-budget-v2 <id>")
|
|
362
|
+
.description("Register a V2 budget")
|
|
363
|
+
.requiredOption("-o, --owner <id>", "owner id")
|
|
364
|
+
.requiredOption("-l, --label <label>", "budget label")
|
|
365
|
+
.action((id, opts) =>
|
|
366
|
+
tryRun(() =>
|
|
367
|
+
out(
|
|
368
|
+
true,
|
|
369
|
+
registerBudgetV2(id, { ownerId: opts.owner, label: opts.label }),
|
|
370
|
+
),
|
|
371
|
+
),
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
tokens
|
|
375
|
+
.command("get-budget-v2 <id>")
|
|
376
|
+
.description("Get a V2 budget")
|
|
377
|
+
.action((id) => out(true, getBudgetV2(id)));
|
|
378
|
+
|
|
379
|
+
tokens
|
|
380
|
+
.command("list-budgets-v2")
|
|
381
|
+
.description("List V2 budgets")
|
|
382
|
+
.option("-o, --owner <id>", "filter by owner")
|
|
383
|
+
.option("-s, --status <status>", "filter by status")
|
|
384
|
+
.action((opts) =>
|
|
385
|
+
out(true, listBudgetsV2({ ownerId: opts.owner, status: opts.status })),
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
tokens
|
|
389
|
+
.command("set-budget-status-v2 <id> <next>")
|
|
390
|
+
.description("Set V2 budget status")
|
|
391
|
+
.action((id, next) => tryRun(() => out(true, setBudgetStatusV2(id, next))));
|
|
392
|
+
|
|
393
|
+
tokens
|
|
394
|
+
.command("activate-budget-v2 <id>")
|
|
395
|
+
.description("Activate a V2 budget")
|
|
396
|
+
.action((id) => tryRun(() => out(true, activateBudgetV2(id))));
|
|
397
|
+
|
|
398
|
+
tokens
|
|
399
|
+
.command("suspend-budget-v2 <id>")
|
|
400
|
+
.description("Suspend a V2 budget")
|
|
401
|
+
.action((id) => tryRun(() => out(true, suspendBudgetV2(id))));
|
|
402
|
+
|
|
403
|
+
tokens
|
|
404
|
+
.command("archive-budget-v2 <id>")
|
|
405
|
+
.description("Archive a V2 budget")
|
|
406
|
+
.action((id) => tryRun(() => out(true, archiveBudgetV2(id))));
|
|
407
|
+
|
|
408
|
+
tokens
|
|
409
|
+
.command("touch-budget-v2 <id>")
|
|
410
|
+
.description("Touch a V2 budget")
|
|
411
|
+
.action((id) => tryRun(() => out(true, touchBudgetV2(id))));
|
|
412
|
+
|
|
413
|
+
tokens
|
|
414
|
+
.command("create-usage-record-v2 <id>")
|
|
415
|
+
.description("Create a V2 usage record")
|
|
416
|
+
.requiredOption("-b, --budget <id>", "budget id")
|
|
417
|
+
.requiredOption("-u, --units <n>", "usage units")
|
|
418
|
+
.action((id, opts) =>
|
|
419
|
+
tryRun(() =>
|
|
420
|
+
out(
|
|
421
|
+
true,
|
|
422
|
+
createUsageRecordV2(id, {
|
|
423
|
+
budgetId: opts.budget,
|
|
424
|
+
units: Number(opts.units),
|
|
425
|
+
}),
|
|
426
|
+
),
|
|
427
|
+
),
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
tokens
|
|
431
|
+
.command("get-usage-record-v2 <id>")
|
|
432
|
+
.description("Get a V2 usage record")
|
|
433
|
+
.action((id) => out(true, getUsageRecordV2(id)));
|
|
434
|
+
|
|
435
|
+
tokens
|
|
436
|
+
.command("list-usage-records-v2")
|
|
437
|
+
.description("List V2 usage records")
|
|
438
|
+
.option("-b, --budget <id>", "filter by budget")
|
|
439
|
+
.option("-s, --status <status>", "filter by status")
|
|
440
|
+
.action((opts) =>
|
|
441
|
+
out(
|
|
442
|
+
true,
|
|
443
|
+
listUsageRecordsV2({ budgetId: opts.budget, status: opts.status }),
|
|
444
|
+
),
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
tokens
|
|
448
|
+
.command("set-usage-record-status-v2 <id> <next>")
|
|
449
|
+
.description("Set V2 usage record status")
|
|
450
|
+
.action((id, next) =>
|
|
451
|
+
tryRun(() => out(true, setUsageRecordStatusV2(id, next))),
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
tokens
|
|
455
|
+
.command("record-usage-v2 <id>")
|
|
456
|
+
.description("Mark V2 usage record recorded")
|
|
457
|
+
.action((id) => tryRun(() => out(true, recordUsageV2(id))));
|
|
458
|
+
|
|
459
|
+
tokens
|
|
460
|
+
.command("bill-usage-v2 <id>")
|
|
461
|
+
.description("Bill V2 usage record")
|
|
462
|
+
.action((id) => tryRun(() => out(true, billUsageV2(id))));
|
|
463
|
+
|
|
464
|
+
tokens
|
|
465
|
+
.command("reject-usage-v2 <id>")
|
|
466
|
+
.description("Reject V2 usage record")
|
|
467
|
+
.action((id) => tryRun(() => out(true, rejectUsageV2(id))));
|
|
468
|
+
|
|
469
|
+
tokens
|
|
470
|
+
.command("refund-usage-v2 <id>")
|
|
471
|
+
.description("Refund V2 usage record")
|
|
472
|
+
.action((id) => tryRun(() => out(true, refundUsageV2(id))));
|
|
473
|
+
|
|
474
|
+
tokens
|
|
475
|
+
.command("auto-suspend-idle-budgets-v2")
|
|
476
|
+
.description("Auto-suspend idle V2 budgets")
|
|
477
|
+
.action(() => out(true, autoSuspendIdleBudgetsV2()));
|
|
478
|
+
|
|
479
|
+
tokens
|
|
480
|
+
.command("auto-reject-stale-records-v2")
|
|
481
|
+
.description("Auto-reject stale V2 records")
|
|
482
|
+
.action(() => out(true, autoRejectStaleRecordsV2()));
|
|
214
483
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cc topiccls` — Topic Classifier V2 governance overlay.
|
|
3
|
+
*
|
|
4
|
+
* In-memory governance for classifier profiles + job lifecycle, layered atop
|
|
5
|
+
* `lib/topic-classifier.js`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
TOPIC_CLS_PROFILE_MATURITY_V2, TOPIC_CLS_JOB_LIFECYCLE_V2,
|
|
10
|
+
setMaxActiveTopicClsProfilesPerOwnerV2, getMaxActiveTopicClsProfilesPerOwnerV2,
|
|
11
|
+
setMaxPendingTopicClsJobsPerProfileV2, getMaxPendingTopicClsJobsPerProfileV2,
|
|
12
|
+
setTopicClsProfileIdleMsV2, getTopicClsProfileIdleMsV2,
|
|
13
|
+
setTopicClsJobStuckMsV2, getTopicClsJobStuckMsV2,
|
|
14
|
+
registerTopicClsProfileV2, activateTopicClsProfileV2, staleTopicClsProfileV2, archiveTopicClsProfileV2, touchTopicClsProfileV2, getTopicClsProfileV2, listTopicClsProfilesV2,
|
|
15
|
+
createTopicClsJobV2, startTopicClsJobV2, completeTopicClsJobV2, failTopicClsJobV2, cancelTopicClsJobV2, getTopicClsJobV2, listTopicClsJobsV2,
|
|
16
|
+
autoStaleIdleTopicClsProfilesV2, autoFailStuckTopicClsJobsV2, getTopicClassifierGovStatsV2, _resetStateTopicClsV2,
|
|
17
|
+
} from "../lib/topic-classifier.js";
|
|
18
|
+
|
|
19
|
+
export function registerTopicClsCommand(program) {
|
|
20
|
+
const tc = program.command("topiccls").description("Topic Classifier V2 governance");
|
|
21
|
+
tc.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: TOPIC_CLS_PROFILE_MATURITY_V2, jobLifecycle: TOPIC_CLS_JOB_LIFECYCLE_V2 }, null, 2)));
|
|
22
|
+
tc.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveTopicClsProfilesPerOwner: getMaxActiveTopicClsProfilesPerOwnerV2(), maxPendingTopicClsJobsPerProfile: getMaxPendingTopicClsJobsPerProfileV2(), topicClsProfileIdleMs: getTopicClsProfileIdleMsV2(), topicClsJobStuckMs: getTopicClsJobStuckMsV2() }, null, 2)));
|
|
23
|
+
tc.command("set-max-active-v2 <n>").action((n) => { setMaxActiveTopicClsProfilesPerOwnerV2(Number(n)); console.log("ok"); });
|
|
24
|
+
tc.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingTopicClsJobsPerProfileV2(Number(n)); console.log("ok"); });
|
|
25
|
+
tc.command("set-idle-ms-v2 <n>").action((n) => { setTopicClsProfileIdleMsV2(Number(n)); console.log("ok"); });
|
|
26
|
+
tc.command("set-stuck-ms-v2 <n>").action((n) => { setTopicClsJobStuckMsV2(Number(n)); console.log("ok"); });
|
|
27
|
+
tc.command("register-profile-v2 <id> <owner>").option("--model <m>", "model").action((id, owner, o) => console.log(JSON.stringify(registerTopicClsProfileV2({ id, owner, model: o.model }), null, 2)));
|
|
28
|
+
tc.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activateTopicClsProfileV2(id), null, 2)));
|
|
29
|
+
tc.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(staleTopicClsProfileV2(id), null, 2)));
|
|
30
|
+
tc.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archiveTopicClsProfileV2(id), null, 2)));
|
|
31
|
+
tc.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchTopicClsProfileV2(id), null, 2)));
|
|
32
|
+
tc.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getTopicClsProfileV2(id), null, 2)));
|
|
33
|
+
tc.command("list-profiles-v2").action(() => console.log(JSON.stringify(listTopicClsProfilesV2(), null, 2)));
|
|
34
|
+
tc.command("create-job-v2 <id> <profileId>").option("--text <t>", "text").action((id, profileId, o) => console.log(JSON.stringify(createTopicClsJobV2({ id, profileId, text: o.text }), null, 2)));
|
|
35
|
+
tc.command("start-job-v2 <id>").action((id) => console.log(JSON.stringify(startTopicClsJobV2(id), null, 2)));
|
|
36
|
+
tc.command("complete-job-v2 <id>").action((id) => console.log(JSON.stringify(completeTopicClsJobV2(id), null, 2)));
|
|
37
|
+
tc.command("fail-job-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failTopicClsJobV2(id, reason), null, 2)));
|
|
38
|
+
tc.command("cancel-job-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelTopicClsJobV2(id, reason), null, 2)));
|
|
39
|
+
tc.command("get-job-v2 <id>").action((id) => console.log(JSON.stringify(getTopicClsJobV2(id), null, 2)));
|
|
40
|
+
tc.command("list-jobs-v2").action(() => console.log(JSON.stringify(listTopicClsJobsV2(), null, 2)));
|
|
41
|
+
tc.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdleTopicClsProfilesV2(), null, 2)));
|
|
42
|
+
tc.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckTopicClsJobsV2(), null, 2)));
|
|
43
|
+
tc.command("gov-stats-v2").action(() => console.log(JSON.stringify(getTopicClassifierGovStatsV2(), null, 2)));
|
|
44
|
+
tc.command("reset-state-v2").action(() => { _resetStateTopicClsV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
|
|
45
|
+
}
|
package/src/commands/trust.js
CHANGED
|
@@ -27,8 +27,48 @@ import {
|
|
|
27
27
|
listHsmDevices,
|
|
28
28
|
signWithHsm,
|
|
29
29
|
getTrustSecurityStats,
|
|
30
|
+
HSM_MATURITY_V2,
|
|
31
|
+
TRANSMISSION_V2,
|
|
32
|
+
getMaxActiveDevicesPerOperator,
|
|
33
|
+
setMaxActiveDevicesPerOperator,
|
|
34
|
+
getMaxPendingTransmissionsPerDevice,
|
|
35
|
+
setMaxPendingTransmissionsPerDevice,
|
|
36
|
+
getDeviceIdleMs,
|
|
37
|
+
setDeviceIdleMs,
|
|
38
|
+
getTransmissionStuckMs,
|
|
39
|
+
setTransmissionStuckMs,
|
|
40
|
+
getActiveDeviceCount,
|
|
41
|
+
getPendingTransmissionCount,
|
|
42
|
+
registerDeviceV2,
|
|
43
|
+
getDeviceV2,
|
|
44
|
+
listDevicesV2,
|
|
45
|
+
setDeviceMaturityV2,
|
|
46
|
+
activateDevice,
|
|
47
|
+
degradeDevice,
|
|
48
|
+
retireDevice,
|
|
49
|
+
touchDeviceUsage,
|
|
50
|
+
enqueueTransmissionV2,
|
|
51
|
+
getTransmissionV2,
|
|
52
|
+
listTransmissionsV2,
|
|
53
|
+
setTransmissionStatusV2,
|
|
54
|
+
startTransmission,
|
|
55
|
+
confirmTransmission,
|
|
56
|
+
failTransmission,
|
|
57
|
+
cancelTransmission,
|
|
58
|
+
autoRetireIdleDevices,
|
|
59
|
+
autoFailStuckTransmissions,
|
|
60
|
+
getTrustSecurityStatsV2,
|
|
30
61
|
} from "../lib/trust-security.js";
|
|
31
62
|
|
|
63
|
+
function _parseJsonV2(s) {
|
|
64
|
+
if (!s) return undefined;
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(s);
|
|
67
|
+
} catch {
|
|
68
|
+
throw new Error(`invalid JSON: ${s}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
32
72
|
function _dbFromCtx(cmd) {
|
|
33
73
|
const root = cmd?.parent?.parent ?? cmd?.parent;
|
|
34
74
|
return root?._db;
|
|
@@ -362,5 +402,214 @@ export function registerTrustCommand(program) {
|
|
|
362
402
|
console.log(`HSM Devices: ${s.hsm.total}`);
|
|
363
403
|
});
|
|
364
404
|
|
|
405
|
+
/* ── V2 Surface (Phase 68-71) ─────────────────────────── */
|
|
406
|
+
|
|
407
|
+
tr.command("hsm-maturities-v2")
|
|
408
|
+
.description("List HSM_MATURITY_V2 enum")
|
|
409
|
+
.action(() => {
|
|
410
|
+
for (const v of Object.values(HSM_MATURITY_V2)) console.log(` ${v}`);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
tr.command("transmissions-v2")
|
|
414
|
+
.description("List TRANSMISSION_V2 enum")
|
|
415
|
+
.action(() => {
|
|
416
|
+
for (const v of Object.values(TRANSMISSION_V2)) console.log(` ${v}`);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
tr.command("max-active-devices-per-operator")
|
|
420
|
+
.description("Get current max-active-devices-per-operator cap")
|
|
421
|
+
.action(() => console.log(getMaxActiveDevicesPerOperator()));
|
|
422
|
+
tr.command("set-max-active-devices-per-operator <n>").action((n) =>
|
|
423
|
+
console.log(setMaxActiveDevicesPerOperator(Number(n))),
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
tr.command("max-pending-transmissions-per-device")
|
|
427
|
+
.description("Get current max-pending-transmissions-per-device cap")
|
|
428
|
+
.action(() => console.log(getMaxPendingTransmissionsPerDevice()));
|
|
429
|
+
tr.command("set-max-pending-transmissions-per-device <n>").action((n) =>
|
|
430
|
+
console.log(setMaxPendingTransmissionsPerDevice(Number(n))),
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
tr.command("device-idle-ms")
|
|
434
|
+
.description("Get current device-idle-ms threshold")
|
|
435
|
+
.action(() => console.log(getDeviceIdleMs()));
|
|
436
|
+
tr.command("set-device-idle-ms <n>").action((n) =>
|
|
437
|
+
console.log(setDeviceIdleMs(Number(n))),
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
tr.command("transmission-stuck-ms")
|
|
441
|
+
.description("Get current transmission-stuck-ms threshold")
|
|
442
|
+
.action(() => console.log(getTransmissionStuckMs()));
|
|
443
|
+
tr.command("set-transmission-stuck-ms <n>").action((n) =>
|
|
444
|
+
console.log(setTransmissionStuckMs(Number(n))),
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
tr.command("active-device-count")
|
|
448
|
+
.description("Count active+degraded devices (optionally by operator)")
|
|
449
|
+
.option("-o, --operator <operator>", "scope to operator")
|
|
450
|
+
.action((opts) => console.log(getActiveDeviceCount(opts.operator)));
|
|
451
|
+
|
|
452
|
+
tr.command("pending-transmission-count")
|
|
453
|
+
.description("Count non-terminal transmissions (optionally by device)")
|
|
454
|
+
.option("-d, --device <device>", "scope to device")
|
|
455
|
+
.action((opts) => console.log(getPendingTransmissionCount(opts.device)));
|
|
456
|
+
|
|
457
|
+
tr.command("register-device-v2 <device-id>")
|
|
458
|
+
.description("Register V2 HSM device")
|
|
459
|
+
.requiredOption("-o, --operator <operator>", "operator id")
|
|
460
|
+
.requiredOption("-v, --vendor <vendor>", "HSM vendor")
|
|
461
|
+
.option(
|
|
462
|
+
"-i, --initial <status>",
|
|
463
|
+
"initial status",
|
|
464
|
+
HSM_MATURITY_V2.PROVISIONAL,
|
|
465
|
+
)
|
|
466
|
+
.option("--metadata <json>", "metadata JSON")
|
|
467
|
+
.action((id, opts) => {
|
|
468
|
+
const d = registerDeviceV2({
|
|
469
|
+
id,
|
|
470
|
+
operator: opts.operator,
|
|
471
|
+
vendor: opts.vendor,
|
|
472
|
+
initialStatus: opts.initial,
|
|
473
|
+
metadata: _parseJsonV2(opts.metadata),
|
|
474
|
+
});
|
|
475
|
+
console.log(JSON.stringify(d, null, 2));
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
tr.command("device-v2 <device-id>")
|
|
479
|
+
.description("Show V2 device")
|
|
480
|
+
.action((id) => {
|
|
481
|
+
const d = getDeviceV2(id);
|
|
482
|
+
if (!d) return console.error(`device ${id} not found`);
|
|
483
|
+
console.log(JSON.stringify(d, null, 2));
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
tr.command("list-devices-v2")
|
|
487
|
+
.description("List V2 devices")
|
|
488
|
+
.option("-o, --operator <operator>", "filter by operator")
|
|
489
|
+
.option("-s, --status <status>", "filter by status")
|
|
490
|
+
.action((opts) =>
|
|
491
|
+
console.log(JSON.stringify(listDevicesV2(opts), null, 2)),
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
tr.command("set-device-maturity-v2 <device-id> <status>")
|
|
495
|
+
.description("Transition V2 device maturity")
|
|
496
|
+
.option("-r, --reason <reason>", "transition reason")
|
|
497
|
+
.option("--metadata <json>", "metadata patch JSON")
|
|
498
|
+
.action((id, status, opts) => {
|
|
499
|
+
const d = setDeviceMaturityV2(id, status, {
|
|
500
|
+
reason: opts.reason,
|
|
501
|
+
metadata: _parseJsonV2(opts.metadata),
|
|
502
|
+
});
|
|
503
|
+
console.log(JSON.stringify(d, null, 2));
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
for (const [name, fn] of [
|
|
507
|
+
["activate-device", activateDevice],
|
|
508
|
+
["degrade-device", degradeDevice],
|
|
509
|
+
["retire-device", retireDevice],
|
|
510
|
+
]) {
|
|
511
|
+
tr.command(`${name} <device-id>`)
|
|
512
|
+
.description(`Shortcut for ${name.replace("-device", "")} transition`)
|
|
513
|
+
.option("-r, --reason <reason>", "transition reason")
|
|
514
|
+
.action((id, opts) => {
|
|
515
|
+
const d = fn(id, { reason: opts.reason });
|
|
516
|
+
console.log(JSON.stringify(d, null, 2));
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
tr.command("touch-device-usage <device-id>")
|
|
521
|
+
.description("Mark V2 device as used now")
|
|
522
|
+
.action((id) => {
|
|
523
|
+
const d = touchDeviceUsage(id);
|
|
524
|
+
console.log(JSON.stringify(d, null, 2));
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
tr.command("enqueue-transmission-v2 <transmission-id>")
|
|
528
|
+
.description("Enqueue V2 satellite transmission")
|
|
529
|
+
.requiredOption("-d, --device <device>", "device id")
|
|
530
|
+
.requiredOption("-p, --provider <provider>", "satellite provider")
|
|
531
|
+
.requiredOption("-x, --payload <payload>", "message payload")
|
|
532
|
+
.option("--metadata <json>", "metadata JSON")
|
|
533
|
+
.action((id, opts) => {
|
|
534
|
+
const t = enqueueTransmissionV2({
|
|
535
|
+
id,
|
|
536
|
+
deviceId: opts.device,
|
|
537
|
+
provider: opts.provider,
|
|
538
|
+
payload: opts.payload,
|
|
539
|
+
metadata: _parseJsonV2(opts.metadata),
|
|
540
|
+
});
|
|
541
|
+
console.log(JSON.stringify(t, null, 2));
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
tr.command("transmission-v2 <transmission-id>")
|
|
545
|
+
.description("Show V2 transmission")
|
|
546
|
+
.action((id) => {
|
|
547
|
+
const t = getTransmissionV2(id);
|
|
548
|
+
if (!t) return console.error(`transmission ${id} not found`);
|
|
549
|
+
console.log(JSON.stringify(t, null, 2));
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
tr.command("list-transmissions-v2")
|
|
553
|
+
.description("List V2 transmissions")
|
|
554
|
+
.option("-d, --device <device>", "filter by device")
|
|
555
|
+
.option("-s, --status <status>", "filter by status")
|
|
556
|
+
.action((opts) =>
|
|
557
|
+
console.log(JSON.stringify(listTransmissionsV2(opts), null, 2)),
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
tr.command("set-transmission-status-v2 <transmission-id> <status>")
|
|
561
|
+
.option("-r, --reason <reason>", "transition reason")
|
|
562
|
+
.option("--metadata <json>", "metadata patch JSON")
|
|
563
|
+
.action((id, status, opts) => {
|
|
564
|
+
const t = setTransmissionStatusV2(id, status, {
|
|
565
|
+
reason: opts.reason,
|
|
566
|
+
metadata: _parseJsonV2(opts.metadata),
|
|
567
|
+
});
|
|
568
|
+
console.log(JSON.stringify(t, null, 2));
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
for (const [name, fn] of [
|
|
572
|
+
["start-transmission", startTransmission],
|
|
573
|
+
["confirm-transmission", confirmTransmission],
|
|
574
|
+
["fail-transmission", failTransmission],
|
|
575
|
+
["cancel-transmission", cancelTransmission],
|
|
576
|
+
]) {
|
|
577
|
+
tr.command(`${name} <transmission-id>`)
|
|
578
|
+
.description(
|
|
579
|
+
`Shortcut for ${name.replace("-transmission", "")} transition`,
|
|
580
|
+
)
|
|
581
|
+
.option("-r, --reason <reason>", "transition reason")
|
|
582
|
+
.action((id, opts) => {
|
|
583
|
+
const t = fn(id, { reason: opts.reason });
|
|
584
|
+
console.log(JSON.stringify(t, null, 2));
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
tr.command("auto-retire-idle-devices")
|
|
589
|
+
.description(
|
|
590
|
+
"Bulk-retire ACTIVE/DEGRADED devices whose lastUsedAt is older than deviceIdleMs",
|
|
591
|
+
)
|
|
592
|
+
.action(() =>
|
|
593
|
+
console.log(
|
|
594
|
+
JSON.stringify({ flipped: autoRetireIdleDevices() }, null, 2),
|
|
595
|
+
),
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
tr.command("auto-fail-stuck-transmissions")
|
|
599
|
+
.description(
|
|
600
|
+
"Bulk-fail SENDING transmissions whose startedAt is older than transmissionStuckMs",
|
|
601
|
+
)
|
|
602
|
+
.action(() =>
|
|
603
|
+
console.log(
|
|
604
|
+
JSON.stringify({ flipped: autoFailStuckTransmissions() }, null, 2),
|
|
605
|
+
),
|
|
606
|
+
);
|
|
607
|
+
|
|
608
|
+
tr.command("stats-v2")
|
|
609
|
+
.description("Show V2 trust/security stats")
|
|
610
|
+
.action(() =>
|
|
611
|
+
console.log(JSON.stringify(getTrustSecurityStatsV2(), null, 2)),
|
|
612
|
+
);
|
|
613
|
+
|
|
365
614
|
program.addCommand(tr);
|
|
366
615
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cc uprof` — User Profile V2 governance overlay.
|
|
3
|
+
*
|
|
4
|
+
* In-memory governance for user profile maturity + preference lifecycle, layered
|
|
5
|
+
* atop `lib/user-profile.js`. Independent of legacy SQLite/file profile storage.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
USER_PROFILE_MATURITY_V2, USER_PREF_LIFECYCLE_V2,
|
|
10
|
+
setMaxActiveUserProfilesPerOwnerV2, getMaxActiveUserProfilesPerOwnerV2,
|
|
11
|
+
setMaxPendingUserPrefsPerProfileV2, getMaxPendingUserPrefsPerProfileV2,
|
|
12
|
+
setUserProfileIdleMsV2, getUserProfileIdleMsV2,
|
|
13
|
+
setUserPrefStuckMsV2, getUserPrefStuckMsV2,
|
|
14
|
+
registerUserProfileV2, activateUserProfileV2, dormantUserProfileV2, archiveUserProfileV2, touchUserProfileV2, getUserProfileV2, listUserProfilesV2,
|
|
15
|
+
createUserPrefV2, applyUserPrefV2, rejectUserPrefV2, supersedeUserPrefV2, cancelUserPrefV2, getUserPrefV2, listUserPrefsV2,
|
|
16
|
+
autoDormantIdleUserProfilesV2, autoCancelStaleUserPrefsV2, getUserProfileGovStatsV2, _resetStateUserProfileV2,
|
|
17
|
+
} from "../lib/user-profile.js";
|
|
18
|
+
|
|
19
|
+
export function registerUprofCommand(program) {
|
|
20
|
+
const up = program.command("uprof").description("User Profile V2 governance");
|
|
21
|
+
up.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: USER_PROFILE_MATURITY_V2, prefLifecycle: USER_PREF_LIFECYCLE_V2 }, null, 2)));
|
|
22
|
+
up.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveUserProfilesPerOwner: getMaxActiveUserProfilesPerOwnerV2(), maxPendingUserPrefsPerProfile: getMaxPendingUserPrefsPerProfileV2(), userProfileIdleMs: getUserProfileIdleMsV2(), userPrefStuckMs: getUserPrefStuckMsV2() }, null, 2)));
|
|
23
|
+
up.command("set-max-active-v2 <n>").action((n) => { setMaxActiveUserProfilesPerOwnerV2(Number(n)); console.log("ok"); });
|
|
24
|
+
up.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingUserPrefsPerProfileV2(Number(n)); console.log("ok"); });
|
|
25
|
+
up.command("set-idle-ms-v2 <n>").action((n) => { setUserProfileIdleMsV2(Number(n)); console.log("ok"); });
|
|
26
|
+
up.command("set-stuck-ms-v2 <n>").action((n) => { setUserPrefStuckMsV2(Number(n)); console.log("ok"); });
|
|
27
|
+
up.command("register-profile-v2 <id> <owner>").option("--handle <h>", "handle").action((id, owner, o) => console.log(JSON.stringify(registerUserProfileV2({ id, owner, handle: o.handle }), null, 2)));
|
|
28
|
+
up.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activateUserProfileV2(id), null, 2)));
|
|
29
|
+
up.command("dormant-profile-v2 <id>").action((id) => console.log(JSON.stringify(dormantUserProfileV2(id), null, 2)));
|
|
30
|
+
up.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archiveUserProfileV2(id), null, 2)));
|
|
31
|
+
up.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchUserProfileV2(id), null, 2)));
|
|
32
|
+
up.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getUserProfileV2(id), null, 2)));
|
|
33
|
+
up.command("list-profiles-v2").action(() => console.log(JSON.stringify(listUserProfilesV2(), null, 2)));
|
|
34
|
+
up.command("create-pref-v2 <id> <profileId>").option("--key <k>", "key").action((id, profileId, o) => console.log(JSON.stringify(createUserPrefV2({ id, profileId, key: o.key }), null, 2)));
|
|
35
|
+
up.command("apply-pref-v2 <id>").action((id) => console.log(JSON.stringify(applyUserPrefV2(id), null, 2)));
|
|
36
|
+
up.command("reject-pref-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(rejectUserPrefV2(id, reason), null, 2)));
|
|
37
|
+
up.command("supersede-pref-v2 <id>").action((id) => console.log(JSON.stringify(supersedeUserPrefV2(id), null, 2)));
|
|
38
|
+
up.command("cancel-pref-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelUserPrefV2(id, reason), null, 2)));
|
|
39
|
+
up.command("get-pref-v2 <id>").action((id) => console.log(JSON.stringify(getUserPrefV2(id), null, 2)));
|
|
40
|
+
up.command("list-prefs-v2").action(() => console.log(JSON.stringify(listUserPrefsV2(), null, 2)));
|
|
41
|
+
up.command("auto-dormant-idle-v2").action(() => console.log(JSON.stringify(autoDormantIdleUserProfilesV2(), null, 2)));
|
|
42
|
+
up.command("auto-cancel-stale-v2").action(() => console.log(JSON.stringify(autoCancelStaleUserPrefsV2(), null, 2)));
|
|
43
|
+
up.command("gov-stats-v2").action(() => console.log(JSON.stringify(getUserProfileGovStatsV2(), null, 2)));
|
|
44
|
+
up.command("reset-state-v2").action(() => { _resetStateUserProfileV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
|
|
45
|
+
}
|