chainlesschain 0.81.0 → 0.132.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.
Files changed (110) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/agent-network.js +254 -1
  4. package/src/commands/audit.js +302 -0
  5. package/src/commands/automation.js +271 -1
  6. package/src/commands/codegen.js +224 -0
  7. package/src/commands/collab.js +341 -0
  8. package/src/commands/compliance.js +1035 -0
  9. package/src/commands/cowork.js +221 -0
  10. package/src/commands/dbevo.js +284 -0
  11. package/src/commands/dev.js +252 -0
  12. package/src/commands/did.js +358 -0
  13. package/src/commands/encrypt.js +341 -0
  14. package/src/commands/export.js +256 -1
  15. package/src/commands/fusion.js +258 -0
  16. package/src/commands/governance.js +325 -0
  17. package/src/commands/hardening.js +411 -0
  18. package/src/commands/hook.js +148 -0
  19. package/src/commands/import.js +252 -0
  20. package/src/commands/incentive.js +322 -0
  21. package/src/commands/infra.js +244 -0
  22. package/src/commands/instinct.js +260 -0
  23. package/src/commands/ipfs.js +318 -0
  24. package/src/commands/kg.js +387 -0
  25. package/src/commands/llm.js +263 -0
  26. package/src/commands/mcp.js +221 -0
  27. package/src/commands/memory.js +248 -0
  28. package/src/commands/multimodal.js +296 -0
  29. package/src/commands/nlprog.js +356 -0
  30. package/src/commands/note.js +244 -0
  31. package/src/commands/ops.js +354 -0
  32. package/src/commands/orchestrate.js +166 -0
  33. package/src/commands/org.js +277 -0
  34. package/src/commands/p2p.js +390 -0
  35. package/src/commands/perception.js +290 -0
  36. package/src/commands/permmem.js +251 -0
  37. package/src/commands/plugin-ecosystem.js +273 -0
  38. package/src/commands/pqc.js +393 -0
  39. package/src/commands/quantization.js +351 -0
  40. package/src/commands/rcache.js +271 -0
  41. package/src/commands/recommend.js +340 -0
  42. package/src/commands/runtime.js +307 -0
  43. package/src/commands/scim.js +262 -0
  44. package/src/commands/session.js +258 -0
  45. package/src/commands/skill.js +267 -1
  46. package/src/commands/social.js +256 -0
  47. package/src/commands/sso.js +186 -1
  48. package/src/commands/sync.js +256 -0
  49. package/src/commands/tech.js +338 -0
  50. package/src/commands/tenant.js +351 -0
  51. package/src/commands/tokens.js +269 -0
  52. package/src/commands/trust.js +249 -0
  53. package/src/commands/wallet.js +277 -0
  54. package/src/commands/workflow.js +171 -0
  55. package/src/index.js +4 -0
  56. package/src/lib/agent-coordinator.js +325 -0
  57. package/src/lib/agent-network.js +387 -0
  58. package/src/lib/agent-router.js +395 -0
  59. package/src/lib/aiops.js +478 -0
  60. package/src/lib/audit-logger.js +379 -0
  61. package/src/lib/automation-engine.js +330 -0
  62. package/src/lib/autonomous-developer.js +350 -0
  63. package/src/lib/code-agent.js +323 -0
  64. package/src/lib/collaboration-governance.js +364 -0
  65. package/src/lib/community-governance.js +436 -0
  66. package/src/lib/compliance-manager.js +434 -0
  67. package/src/lib/content-recommendation.js +469 -0
  68. package/src/lib/crypto-manager.js +350 -0
  69. package/src/lib/dbevo.js +338 -0
  70. package/src/lib/decentral-infra.js +340 -0
  71. package/src/lib/did-manager.js +367 -0
  72. package/src/lib/hardening-manager.js +348 -0
  73. package/src/lib/hook-manager.js +380 -0
  74. package/src/lib/instinct-manager.js +332 -0
  75. package/src/lib/ipfs-storage.js +334 -0
  76. package/src/lib/knowledge-exporter.js +381 -0
  77. package/src/lib/knowledge-graph.js +432 -0
  78. package/src/lib/knowledge-importer.js +379 -0
  79. package/src/lib/llm-providers.js +391 -0
  80. package/src/lib/mcp-registry.js +333 -0
  81. package/src/lib/memory-manager.js +330 -0
  82. package/src/lib/multimodal.js +346 -0
  83. package/src/lib/nl-programming.js +343 -0
  84. package/src/lib/note-versioning.js +327 -0
  85. package/src/lib/org-manager.js +323 -0
  86. package/src/lib/p2p-manager.js +387 -0
  87. package/src/lib/perception.js +346 -0
  88. package/src/lib/perf-tuning.js +4 -1
  89. package/src/lib/permanent-memory.js +320 -0
  90. package/src/lib/plugin-ecosystem.js +377 -0
  91. package/src/lib/pqc-manager.js +368 -0
  92. package/src/lib/protocol-fusion.js +417 -0
  93. package/src/lib/quantization.js +325 -0
  94. package/src/lib/response-cache.js +327 -0
  95. package/src/lib/scim-manager.js +329 -0
  96. package/src/lib/session-manager.js +329 -0
  97. package/src/lib/skill-loader.js +377 -0
  98. package/src/lib/social-manager.js +326 -0
  99. package/src/lib/sso-manager.js +332 -0
  100. package/src/lib/sync-manager.js +326 -0
  101. package/src/lib/tech-learning-engine.js +369 -0
  102. package/src/lib/tenant-saas.js +460 -0
  103. package/src/lib/threat-intel.js +335 -0
  104. package/src/lib/token-incentive.js +293 -0
  105. package/src/lib/token-tracker.js +329 -0
  106. package/src/lib/trust-security.js +390 -0
  107. package/src/lib/ueba.js +389 -0
  108. package/src/lib/universal-runtime.js +325 -0
  109. package/src/lib/wallet-manager.js +326 -0
  110. package/src/lib/workflow-engine.js +322 -0
@@ -14,6 +14,35 @@ import {
14
14
  getDbEncryptionStatus,
15
15
  setDbEncryptionStatus,
16
16
  hashPassword,
17
+ KEY_MATURITY_V2 as CRYPTO_KEY_MATURITY_V2,
18
+ CRYPTO_JOB_LIFECYCLE_V2,
19
+ getMaxActiveKeysPerOwnerV2 as cryptoGetMaxActiveKeys,
20
+ setMaxActiveKeysPerOwnerV2 as cryptoSetMaxActiveKeys,
21
+ getMaxPendingJobsPerKeyV2 as cryptoGetMaxPendingJobs,
22
+ setMaxPendingJobsPerKeyV2 as cryptoSetMaxPendingJobs,
23
+ getKeyIdleMsV2 as cryptoGetKeyIdleMs,
24
+ setKeyIdleMsV2 as cryptoSetKeyIdleMs,
25
+ getJobStuckMsV2,
26
+ setJobStuckMsV2,
27
+ registerKeyV2 as cryptoRegisterKey,
28
+ getKeyV2 as cryptoGetKey,
29
+ listKeysV2 as cryptoListKeys,
30
+ activateKeyV2 as cryptoActivateKey,
31
+ rotateKeyV2,
32
+ retireKeyV2,
33
+ touchKeyV2 as cryptoTouchKey,
34
+ createJobV2,
35
+ getJobV2,
36
+ listJobsV2,
37
+ startJobV2,
38
+ completeJobV2,
39
+ failJobV2,
40
+ cancelJobV2,
41
+ getActiveKeyCountV2 as cryptoGetActiveKeyCount,
42
+ getPendingJobCountV2,
43
+ autoRotateIdleKeysV2,
44
+ autoFailStuckJobsV2,
45
+ getCryptoManagerStatsV2,
17
46
  } from "../lib/crypto-manager.js";
18
47
 
19
48
  async function promptPassword(message = "Password:") {
@@ -230,4 +259,316 @@ export function registerEncryptCommand(program) {
230
259
  process.exit(1);
231
260
  }
232
261
  });
262
+
263
+ // ===== V2 in-memory governance surface (no DB, no bootstrap) =====
264
+
265
+ enc
266
+ .command("key-maturities-v2")
267
+ .description("[V2] List crypto key maturity states")
268
+ .option("--json")
269
+ .action((o) => {
270
+ const s = Object.values(CRYPTO_KEY_MATURITY_V2);
271
+ if (o.json) console.log(JSON.stringify(s, null, 2));
272
+ else for (const v of s) logger.log(v);
273
+ });
274
+ enc
275
+ .command("job-lifecycles-v2")
276
+ .description("[V2] List crypto job lifecycle states")
277
+ .option("--json")
278
+ .action((o) => {
279
+ const s = Object.values(CRYPTO_JOB_LIFECYCLE_V2);
280
+ if (o.json) console.log(JSON.stringify(s, null, 2));
281
+ else for (const v of s) logger.log(v);
282
+ });
283
+ enc
284
+ .command("config-v2")
285
+ .description("[V2] Show governance config")
286
+ .option("--json")
287
+ .action((o) => {
288
+ const cfg = {
289
+ maxActiveKeysPerOwner: cryptoGetMaxActiveKeys(),
290
+ maxPendingJobsPerKey: cryptoGetMaxPendingJobs(),
291
+ keyIdleMs: cryptoGetKeyIdleMs(),
292
+ jobStuckMs: getJobStuckMsV2(),
293
+ };
294
+ if (o.json) console.log(JSON.stringify(cfg, null, 2));
295
+ else for (const [k, v] of Object.entries(cfg)) logger.log(`${k}: ${v}`);
296
+ });
297
+ enc
298
+ .command("set-max-active-keys-per-owner-v2 <n>")
299
+ .description("[V2] Set per-owner active key cap")
300
+ .action((n) => {
301
+ try {
302
+ cryptoSetMaxActiveKeys(Number(n));
303
+ logger.success(`= ${cryptoGetMaxActiveKeys()}`);
304
+ } catch (e) {
305
+ logger.error(e.message);
306
+ process.exit(1);
307
+ }
308
+ });
309
+ enc
310
+ .command("set-max-pending-jobs-per-key-v2 <n>")
311
+ .description("[V2] Set per-key pending job cap")
312
+ .action((n) => {
313
+ try {
314
+ cryptoSetMaxPendingJobs(Number(n));
315
+ logger.success(`= ${cryptoGetMaxPendingJobs()}`);
316
+ } catch (e) {
317
+ logger.error(e.message);
318
+ process.exit(1);
319
+ }
320
+ });
321
+ enc
322
+ .command("set-key-idle-ms-v2 <ms>")
323
+ .description("[V2] Set key idle threshold (ms)")
324
+ .action((m) => {
325
+ try {
326
+ cryptoSetKeyIdleMs(Number(m));
327
+ logger.success(`= ${cryptoGetKeyIdleMs()}`);
328
+ } catch (e) {
329
+ logger.error(e.message);
330
+ process.exit(1);
331
+ }
332
+ });
333
+ enc
334
+ .command("set-job-stuck-ms-v2 <ms>")
335
+ .description("[V2] Set job stuck threshold (ms)")
336
+ .action((m) => {
337
+ try {
338
+ setJobStuckMsV2(Number(m));
339
+ logger.success(`= ${getJobStuckMsV2()}`);
340
+ } catch (e) {
341
+ logger.error(e.message);
342
+ process.exit(1);
343
+ }
344
+ });
345
+
346
+ enc
347
+ .command("register-key-v2 <id>")
348
+ .description("[V2] Register a crypto key profile (PENDING)")
349
+ .requiredOption("-o, --owner <id>")
350
+ .requiredOption("-a, --algorithm <algo>")
351
+ .option("-p, --purpose <p>", "Purpose", "encryption")
352
+ .action((id, o) => {
353
+ try {
354
+ const k = cryptoRegisterKey(id, {
355
+ ownerId: o.owner,
356
+ algorithm: o.algorithm,
357
+ purpose: o.purpose,
358
+ });
359
+ logger.success(`key ${k.id} registered (status=${k.status})`);
360
+ } catch (e) {
361
+ logger.error(e.message);
362
+ process.exit(1);
363
+ }
364
+ });
365
+ enc
366
+ .command("activate-key-v2 <id>")
367
+ .description("[V2] Activate key (pending|rotated -> active)")
368
+ .action((id) => {
369
+ try {
370
+ cryptoActivateKey(id);
371
+ logger.success(`key ${id} active`);
372
+ } catch (e) {
373
+ logger.error(e.message);
374
+ process.exit(1);
375
+ }
376
+ });
377
+ enc
378
+ .command("rotate-key-v2 <id>")
379
+ .description("[V2] Rotate key (active -> rotated)")
380
+ .action((id) => {
381
+ try {
382
+ rotateKeyV2(id);
383
+ logger.success(`key ${id} rotated`);
384
+ } catch (e) {
385
+ logger.error(e.message);
386
+ process.exit(1);
387
+ }
388
+ });
389
+ enc
390
+ .command("retire-key-v2 <id>")
391
+ .description("[V2] Retire key (terminal)")
392
+ .action((id) => {
393
+ try {
394
+ retireKeyV2(id);
395
+ logger.success(`key ${id} retired`);
396
+ } catch (e) {
397
+ logger.error(e.message);
398
+ process.exit(1);
399
+ }
400
+ });
401
+ enc
402
+ .command("touch-key-v2 <id>")
403
+ .description("[V2] Bump key lastSeenAt")
404
+ .action((id) => {
405
+ try {
406
+ cryptoTouchKey(id);
407
+ logger.success(`key ${id} touched`);
408
+ } catch (e) {
409
+ logger.error(e.message);
410
+ process.exit(1);
411
+ }
412
+ });
413
+ enc
414
+ .command("get-key-v2 <id>")
415
+ .description("[V2] Show crypto key profile")
416
+ .option("--json")
417
+ .action((id) => {
418
+ const k = cryptoGetKey(id);
419
+ if (!k) {
420
+ logger.info("key not found");
421
+ return;
422
+ }
423
+ console.log(JSON.stringify(k, null, 2));
424
+ });
425
+ enc
426
+ .command("list-keys-v2")
427
+ .description("[V2] List crypto key profiles")
428
+ .option("-o, --owner <id>")
429
+ .option("-s, --status <s>")
430
+ .option("-a, --algorithm <algo>")
431
+ .option("--json")
432
+ .action((o) => {
433
+ const list = cryptoListKeys({
434
+ ownerId: o.owner,
435
+ status: o.status,
436
+ algorithm: o.algorithm,
437
+ });
438
+ if (o.json) console.log(JSON.stringify(list, null, 2));
439
+ else
440
+ for (const k of list)
441
+ logger.log(`${k.id}\t${k.ownerId}\t${k.status}\t${k.algorithm}`);
442
+ });
443
+
444
+ enc
445
+ .command("create-job-v2 <id>")
446
+ .description("[V2] Create a queued V2 crypto job")
447
+ .requiredOption("-k, --key <keyId>")
448
+ .option("-K, --kind <kind>", "Job kind", "encrypt")
449
+ .action((id, o) => {
450
+ try {
451
+ const j = createJobV2(id, { keyId: o.key, kind: o.kind });
452
+ logger.success(`job ${j.id} queued (key=${j.keyId} kind=${j.kind})`);
453
+ } catch (e) {
454
+ logger.error(e.message);
455
+ process.exit(1);
456
+ }
457
+ });
458
+ enc
459
+ .command("start-job-v2 <id>")
460
+ .description("[V2] Start crypto job (queued -> running)")
461
+ .action((id) => {
462
+ try {
463
+ startJobV2(id);
464
+ logger.success(`job ${id} running`);
465
+ } catch (e) {
466
+ logger.error(e.message);
467
+ process.exit(1);
468
+ }
469
+ });
470
+ enc
471
+ .command("complete-job-v2 <id>")
472
+ .description("[V2] Complete crypto job (running -> completed)")
473
+ .action((id) => {
474
+ try {
475
+ completeJobV2(id);
476
+ logger.success(`job ${id} completed`);
477
+ } catch (e) {
478
+ logger.error(e.message);
479
+ process.exit(1);
480
+ }
481
+ });
482
+ enc
483
+ .command("fail-job-v2 <id>")
484
+ .description("[V2] Fail crypto job (running -> failed)")
485
+ .action((id) => {
486
+ try {
487
+ failJobV2(id);
488
+ logger.success(`job ${id} failed`);
489
+ } catch (e) {
490
+ logger.error(e.message);
491
+ process.exit(1);
492
+ }
493
+ });
494
+ enc
495
+ .command("cancel-job-v2 <id>")
496
+ .description("[V2] Cancel crypto job (queued|running -> cancelled)")
497
+ .action((id) => {
498
+ try {
499
+ cancelJobV2(id);
500
+ logger.success(`job ${id} cancelled`);
501
+ } catch (e) {
502
+ logger.error(e.message);
503
+ process.exit(1);
504
+ }
505
+ });
506
+ enc
507
+ .command("get-job-v2 <id>")
508
+ .description("[V2] Show crypto job")
509
+ .option("--json")
510
+ .action((id) => {
511
+ const j = getJobV2(id);
512
+ if (!j) {
513
+ logger.info("job not found");
514
+ return;
515
+ }
516
+ console.log(JSON.stringify(j, null, 2));
517
+ });
518
+ enc
519
+ .command("list-jobs-v2")
520
+ .description("[V2] List V2 crypto jobs")
521
+ .option("-k, --key <keyId>")
522
+ .option("-s, --status <s>")
523
+ .option("-K, --kind <kind>")
524
+ .option("--json")
525
+ .action((o) => {
526
+ const list = listJobsV2({ keyId: o.key, status: o.status, kind: o.kind });
527
+ if (o.json) console.log(JSON.stringify(list, null, 2));
528
+ else
529
+ for (const j of list)
530
+ logger.log(`${j.id}\t${j.keyId}\t${j.status}\t${j.kind}`);
531
+ });
532
+
533
+ enc
534
+ .command("active-key-count-v2")
535
+ .description("[V2] Count active crypto keys (optional --owner)")
536
+ .option("-o, --owner <id>")
537
+ .action((o) => logger.log(String(cryptoGetActiveKeyCount(o.owner))));
538
+ enc
539
+ .command("pending-job-count-v2")
540
+ .description("[V2] Count pending crypto jobs (queued+running)")
541
+ .option("-k, --key <keyId>")
542
+ .action((o) => logger.log(String(getPendingJobCountV2(o.key))));
543
+ enc
544
+ .command("auto-rotate-idle-keys-v2")
545
+ .description("[V2] Rotate idle active keys")
546
+ .option("--now <ms>")
547
+ .option("--json")
548
+ .action((o) => {
549
+ const list = autoRotateIdleKeysV2(
550
+ o.now ? { now: Number(o.now) } : undefined,
551
+ );
552
+ if (o.json) console.log(JSON.stringify(list, null, 2));
553
+ else logger.success(`rotated ${list.length}`);
554
+ });
555
+ enc
556
+ .command("auto-fail-stuck-jobs-v2")
557
+ .description("[V2] Fail stuck running crypto jobs")
558
+ .option("--now <ms>")
559
+ .option("--json")
560
+ .action((o) => {
561
+ const list = autoFailStuckJobsV2(
562
+ o.now ? { now: Number(o.now) } : undefined,
563
+ );
564
+ if (o.json) console.log(JSON.stringify(list, null, 2));
565
+ else logger.success(`failed ${list.length}`);
566
+ });
567
+ enc
568
+ .command("stats-v2")
569
+ .description("[V2] Show governance stats")
570
+ .option("--json")
571
+ .action(() =>
572
+ console.log(JSON.stringify(getCryptoManagerStatsV2(), null, 2)),
573
+ );
233
574
  }
@@ -8,7 +8,41 @@ import ora from "ora";
8
8
  import { resolve } from "path";
9
9
  import { logger } from "../lib/logger.js";
10
10
  import { bootstrap, shutdown } from "../runtime/bootstrap.js";
11
- import { exportToMarkdown, exportToSite } from "../lib/knowledge-exporter.js";
11
+ import {
12
+ exportToMarkdown,
13
+ exportToSite,
14
+ TARGET_MATURITY_V2,
15
+ EXPORT_JOB_LIFECYCLE_V2,
16
+ getMaxActiveTargetsPerOwnerV2,
17
+ setMaxActiveTargetsPerOwnerV2,
18
+ getMaxPendingJobsPerTargetV2,
19
+ setMaxPendingJobsPerTargetV2,
20
+ getTargetIdleMsV2,
21
+ setTargetIdleMsV2,
22
+ getJobStuckMsV2,
23
+ setJobStuckMsV2,
24
+ registerTargetV2,
25
+ getTargetV2,
26
+ listTargetsV2,
27
+ setTargetStatusV2,
28
+ activateTargetV2,
29
+ pauseTargetV2,
30
+ archiveTargetV2,
31
+ touchTargetV2,
32
+ getActiveTargetCountV2,
33
+ createExportJobV2,
34
+ getExportJobV2,
35
+ listExportJobsV2,
36
+ setExportJobStatusV2,
37
+ startExportJobV2,
38
+ completeExportJobV2,
39
+ failExportJobV2,
40
+ cancelExportJobV2,
41
+ getPendingJobCountV2,
42
+ autoPauseIdleTargetsV2,
43
+ autoFailStuckExportJobsV2,
44
+ getKnowledgeExporterStatsV2,
45
+ } from "../lib/knowledge-exporter.js";
12
46
 
13
47
  export function registerExportCommand(program) {
14
48
  const exp = program
@@ -122,4 +156,225 @@ export function registerExportCommand(program) {
122
156
  process.exit(1);
123
157
  }
124
158
  });
159
+
160
+ // ─── V2 Governance Layer ──────────────────────────────────────────
161
+ const out = (obj) => console.log(JSON.stringify(obj, null, 2));
162
+ const tryRun = (fn) => {
163
+ try {
164
+ fn();
165
+ } catch (err) {
166
+ logger.error(err.message);
167
+ process.exit(1);
168
+ }
169
+ };
170
+
171
+ exp
172
+ .command("target-maturities-v2")
173
+ .description("List V2 target maturity states")
174
+ .action(() => out(Object.values(TARGET_MATURITY_V2)));
175
+
176
+ exp
177
+ .command("export-job-lifecycles-v2")
178
+ .description("List V2 export-job lifecycle states")
179
+ .action(() => out(Object.values(EXPORT_JOB_LIFECYCLE_V2)));
180
+
181
+ exp
182
+ .command("stats-v2")
183
+ .description("V2 knowledge-exporter stats")
184
+ .action(() => out(getKnowledgeExporterStatsV2()));
185
+
186
+ exp
187
+ .command("get-max-active-targets-v2")
188
+ .description("Get max active targets per owner (V2)")
189
+ .action(() =>
190
+ out({ maxActiveTargetsPerOwner: getMaxActiveTargetsPerOwnerV2() }),
191
+ );
192
+
193
+ exp
194
+ .command("set-max-active-targets-v2 <n>")
195
+ .description("Set max active targets per owner (V2)")
196
+ .action((n) =>
197
+ tryRun(() => {
198
+ setMaxActiveTargetsPerOwnerV2(Number(n));
199
+ out({ maxActiveTargetsPerOwner: getMaxActiveTargetsPerOwnerV2() });
200
+ }),
201
+ );
202
+
203
+ exp
204
+ .command("get-max-pending-jobs-v2")
205
+ .description("Get max pending jobs per target (V2)")
206
+ .action(() =>
207
+ out({ maxPendingJobsPerTarget: getMaxPendingJobsPerTargetV2() }),
208
+ );
209
+
210
+ exp
211
+ .command("set-max-pending-jobs-v2 <n>")
212
+ .description("Set max pending jobs per target (V2)")
213
+ .action((n) =>
214
+ tryRun(() => {
215
+ setMaxPendingJobsPerTargetV2(Number(n));
216
+ out({ maxPendingJobsPerTarget: getMaxPendingJobsPerTargetV2() });
217
+ }),
218
+ );
219
+
220
+ exp
221
+ .command("get-target-idle-ms-v2")
222
+ .description("Get target idle threshold (V2)")
223
+ .action(() => out({ targetIdleMs: getTargetIdleMsV2() }));
224
+
225
+ exp
226
+ .command("set-target-idle-ms-v2 <ms>")
227
+ .description("Set target idle threshold (V2)")
228
+ .action((ms) =>
229
+ tryRun(() => {
230
+ setTargetIdleMsV2(Number(ms));
231
+ out({ targetIdleMs: getTargetIdleMsV2() });
232
+ }),
233
+ );
234
+
235
+ exp
236
+ .command("get-job-stuck-ms-v2")
237
+ .description("Get export-job stuck threshold (V2)")
238
+ .action(() => out({ jobStuckMs: getJobStuckMsV2() }));
239
+
240
+ exp
241
+ .command("set-job-stuck-ms-v2 <ms>")
242
+ .description("Set export-job stuck threshold (V2)")
243
+ .action((ms) =>
244
+ tryRun(() => {
245
+ setJobStuckMsV2(Number(ms));
246
+ out({ jobStuckMs: getJobStuckMsV2() });
247
+ }),
248
+ );
249
+
250
+ exp
251
+ .command("active-target-count-v2 <ownerId>")
252
+ .description("Active target count for owner (V2)")
253
+ .action((ownerId) =>
254
+ out({ ownerId, count: getActiveTargetCountV2(ownerId) }),
255
+ );
256
+
257
+ exp
258
+ .command("pending-job-count-v2 <targetId>")
259
+ .description("Pending export-job count for target (V2)")
260
+ .action((targetId) =>
261
+ out({ targetId, count: getPendingJobCountV2(targetId) }),
262
+ );
263
+
264
+ exp
265
+ .command("register-target-v2 <id>")
266
+ .description("Register a V2 export target")
267
+ .requiredOption("-o, --owner <id>", "owner id")
268
+ .requiredOption("-l, --label <label>", "target label")
269
+ .option("-f, --format <format>", "target format", "markdown")
270
+ .action((id, opts) =>
271
+ tryRun(() =>
272
+ out(
273
+ registerTargetV2(id, {
274
+ ownerId: opts.owner,
275
+ label: opts.label,
276
+ format: opts.format,
277
+ }),
278
+ ),
279
+ ),
280
+ );
281
+
282
+ exp
283
+ .command("get-target-v2 <id>")
284
+ .description("Get a V2 target")
285
+ .action((id) => out(getTargetV2(id)));
286
+
287
+ exp
288
+ .command("list-targets-v2")
289
+ .description("List V2 targets")
290
+ .option("-o, --owner <id>", "filter by owner")
291
+ .option("-s, --status <status>", "filter by status")
292
+ .action((opts) =>
293
+ out(listTargetsV2({ ownerId: opts.owner, status: opts.status })),
294
+ );
295
+
296
+ exp
297
+ .command("set-target-status-v2 <id> <next>")
298
+ .description("Set V2 target status")
299
+ .action((id, next) => tryRun(() => out(setTargetStatusV2(id, next))));
300
+
301
+ exp
302
+ .command("activate-target-v2 <id>")
303
+ .description("Activate a V2 target")
304
+ .action((id) => tryRun(() => out(activateTargetV2(id))));
305
+
306
+ exp
307
+ .command("pause-target-v2 <id>")
308
+ .description("Pause a V2 target")
309
+ .action((id) => tryRun(() => out(pauseTargetV2(id))));
310
+
311
+ exp
312
+ .command("archive-target-v2 <id>")
313
+ .description("Archive a V2 target")
314
+ .action((id) => tryRun(() => out(archiveTargetV2(id))));
315
+
316
+ exp
317
+ .command("touch-target-v2 <id>")
318
+ .description("Touch a V2 target")
319
+ .action((id) => tryRun(() => out(touchTargetV2(id))));
320
+
321
+ exp
322
+ .command("create-export-job-v2 <id>")
323
+ .description("Create a V2 export job")
324
+ .requiredOption("-t, --target <id>", "target id")
325
+ .option("-k, --kind <kind>", "job kind", "snapshot")
326
+ .action((id, opts) =>
327
+ tryRun(() =>
328
+ out(createExportJobV2(id, { targetId: opts.target, kind: opts.kind })),
329
+ ),
330
+ );
331
+
332
+ exp
333
+ .command("get-export-job-v2 <id>")
334
+ .description("Get a V2 export job")
335
+ .action((id) => out(getExportJobV2(id)));
336
+
337
+ exp
338
+ .command("list-export-jobs-v2")
339
+ .description("List V2 export jobs")
340
+ .option("-t, --target <id>", "filter by target")
341
+ .option("-s, --status <status>", "filter by status")
342
+ .action((opts) =>
343
+ out(listExportJobsV2({ targetId: opts.target, status: opts.status })),
344
+ );
345
+
346
+ exp
347
+ .command("set-export-job-status-v2 <id> <next>")
348
+ .description("Set V2 export-job status")
349
+ .action((id, next) => tryRun(() => out(setExportJobStatusV2(id, next))));
350
+
351
+ exp
352
+ .command("start-export-job-v2 <id>")
353
+ .description("Start a V2 export job")
354
+ .action((id) => tryRun(() => out(startExportJobV2(id))));
355
+
356
+ exp
357
+ .command("complete-export-job-v2 <id>")
358
+ .description("Complete a V2 export job")
359
+ .action((id) => tryRun(() => out(completeExportJobV2(id))));
360
+
361
+ exp
362
+ .command("fail-export-job-v2 <id>")
363
+ .description("Fail a V2 export job")
364
+ .action((id) => tryRun(() => out(failExportJobV2(id))));
365
+
366
+ exp
367
+ .command("cancel-export-job-v2 <id>")
368
+ .description("Cancel a V2 export job")
369
+ .action((id) => tryRun(() => out(cancelExportJobV2(id))));
370
+
371
+ exp
372
+ .command("auto-pause-idle-targets-v2")
373
+ .description("Auto-pause idle V2 targets")
374
+ .action(() => out(autoPauseIdleTargetsV2()));
375
+
376
+ exp
377
+ .command("auto-fail-stuck-export-jobs-v2")
378
+ .description("Auto-fail stuck V2 export jobs")
379
+ .action(() => out(autoFailStuckExportJobsV2()));
125
380
  }