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
@@ -33,6 +33,37 @@ import {
33
33
  FLOW_STATUS,
34
34
  EXECUTION_STATUS,
35
35
  TRIGGER_TYPE,
36
+ AUTOMATION_MATURITY_V2,
37
+ EXECUTION_LIFECYCLE_V2,
38
+ getMaxActiveAutomationsPerOwnerV2,
39
+ setMaxActiveAutomationsPerOwnerV2,
40
+ getMaxRunningExecutionsPerAutomationV2,
41
+ setMaxRunningExecutionsPerAutomationV2,
42
+ getAutomationIdleMsV2,
43
+ setAutomationIdleMsV2,
44
+ getExecutionStuckMsV2,
45
+ setExecutionStuckMsV2,
46
+ registerAutomationV2,
47
+ getAutomationV2,
48
+ listAutomationsV2,
49
+ setAutomationStatusV2,
50
+ activateAutomationV2,
51
+ pauseAutomationV2,
52
+ retireAutomationV2,
53
+ touchAutomationV2,
54
+ getActiveAutomationCountV2,
55
+ createExecutionV2,
56
+ getExecutionV2 as getExecutionV2Surface,
57
+ listExecutionsV2,
58
+ setExecutionStatusV2,
59
+ startExecutionV2,
60
+ succeedExecutionV2,
61
+ failExecutionV2,
62
+ cancelExecutionV2,
63
+ getRunningExecutionCountV2,
64
+ autoPauseIdleAutomationsV2,
65
+ autoFailStuckExecutionsV2,
66
+ getAutomationEngineStatsV2,
36
67
  } from "../lib/automation-engine.js";
37
68
 
38
69
  function _dbFromCtx(cmd) {
@@ -68,7 +99,8 @@ export function registerAutomationCommand(program) {
68
99
  .description(
69
100
  "Workflow automation engine — 12 SaaS connectors + triggers (Phase 96)",
70
101
  )
71
- .hook("preAction", async (thisCommand) => {
102
+ .hook("preAction", async (thisCommand, actionCommand) => {
103
+ if (actionCommand && actionCommand.name().endsWith("-v2")) return;
72
104
  const db = await _prepare(thisCommand);
73
105
  thisCommand._db = db;
74
106
  });
@@ -651,4 +683,242 @@ function _wire(root) {
651
683
  await shutdown();
652
684
  }
653
685
  });
686
+
687
+ // ── V2 Surface ──
688
+
689
+ const outV2 = (obj) => console.log(JSON.stringify(obj, null, 2));
690
+ const tryRunV2 = (fn) => {
691
+ try {
692
+ fn();
693
+ } catch (err) {
694
+ logger.error(err.message);
695
+ process.exit(1);
696
+ }
697
+ };
698
+
699
+ root
700
+ .command("automation-maturities-v2")
701
+ .description("List V2 automation maturity states")
702
+ .action(() => outV2(Object.values(AUTOMATION_MATURITY_V2)));
703
+
704
+ root
705
+ .command("execution-lifecycles-v2")
706
+ .description("List V2 execution lifecycle states")
707
+ .action(() => outV2(Object.values(EXECUTION_LIFECYCLE_V2)));
708
+
709
+ root
710
+ .command("stats-v2")
711
+ .description("V2 automation engine stats")
712
+ .action(() => outV2(getAutomationEngineStatsV2()));
713
+
714
+ root
715
+ .command("get-max-active-automations-v2")
716
+ .description("Get max active automations per owner (V2)")
717
+ .action(() =>
718
+ outV2({
719
+ maxActiveAutomationsPerOwner: getMaxActiveAutomationsPerOwnerV2(),
720
+ }),
721
+ );
722
+
723
+ root
724
+ .command("set-max-active-automations-v2 <n>")
725
+ .description("Set max active automations per owner (V2)")
726
+ .action((n) =>
727
+ tryRunV2(() => {
728
+ setMaxActiveAutomationsPerOwnerV2(Number(n));
729
+ outV2({
730
+ maxActiveAutomationsPerOwner: getMaxActiveAutomationsPerOwnerV2(),
731
+ });
732
+ }),
733
+ );
734
+
735
+ root
736
+ .command("get-max-running-executions-v2")
737
+ .description("Get max running executions per automation (V2)")
738
+ .action(() =>
739
+ outV2({
740
+ maxRunningExecutionsPerAutomation:
741
+ getMaxRunningExecutionsPerAutomationV2(),
742
+ }),
743
+ );
744
+
745
+ root
746
+ .command("set-max-running-executions-v2 <n>")
747
+ .description("Set max running executions per automation (V2)")
748
+ .action((n) =>
749
+ tryRunV2(() => {
750
+ setMaxRunningExecutionsPerAutomationV2(Number(n));
751
+ outV2({
752
+ maxRunningExecutionsPerAutomation:
753
+ getMaxRunningExecutionsPerAutomationV2(),
754
+ });
755
+ }),
756
+ );
757
+
758
+ root
759
+ .command("get-automation-idle-ms-v2")
760
+ .description("Get automation idle threshold (V2)")
761
+ .action(() => outV2({ automationIdleMs: getAutomationIdleMsV2() }));
762
+
763
+ root
764
+ .command("set-automation-idle-ms-v2 <ms>")
765
+ .description("Set automation idle threshold (V2)")
766
+ .action((ms) =>
767
+ tryRunV2(() => {
768
+ setAutomationIdleMsV2(Number(ms));
769
+ outV2({ automationIdleMs: getAutomationIdleMsV2() });
770
+ }),
771
+ );
772
+
773
+ root
774
+ .command("get-execution-stuck-ms-v2")
775
+ .description("Get execution stuck threshold (V2)")
776
+ .action(() => outV2({ executionStuckMs: getExecutionStuckMsV2() }));
777
+
778
+ root
779
+ .command("set-execution-stuck-ms-v2 <ms>")
780
+ .description("Set execution stuck threshold (V2)")
781
+ .action((ms) =>
782
+ tryRunV2(() => {
783
+ setExecutionStuckMsV2(Number(ms));
784
+ outV2({ executionStuckMs: getExecutionStuckMsV2() });
785
+ }),
786
+ );
787
+
788
+ root
789
+ .command("active-automation-count-v2 <ownerId>")
790
+ .description("Active automation count for owner (V2)")
791
+ .action((ownerId) =>
792
+ outV2({ ownerId, count: getActiveAutomationCountV2(ownerId) }),
793
+ );
794
+
795
+ root
796
+ .command("running-execution-count-v2 <automationId>")
797
+ .description("Running execution count for automation (V2)")
798
+ .action((automationId) =>
799
+ outV2({
800
+ automationId,
801
+ count: getRunningExecutionCountV2(automationId),
802
+ }),
803
+ );
804
+
805
+ root
806
+ .command("register-automation-v2 <id>")
807
+ .description("Register a V2 automation")
808
+ .requiredOption("-o, --owner <id>", "owner id")
809
+ .requiredOption("-n, --name <name>", "automation name")
810
+ .action((id, opts) =>
811
+ tryRunV2(() =>
812
+ outV2(
813
+ registerAutomationV2(id, { ownerId: opts.owner, name: opts.name }),
814
+ ),
815
+ ),
816
+ );
817
+
818
+ root
819
+ .command("get-automation-v2 <id>")
820
+ .description("Get a V2 automation")
821
+ .action((id) => outV2(getAutomationV2(id)));
822
+
823
+ root
824
+ .command("list-automations-v2")
825
+ .description("List V2 automations")
826
+ .option("-o, --owner <id>", "filter by owner")
827
+ .option("-s, --status <status>", "filter by status")
828
+ .action((opts) =>
829
+ outV2(listAutomationsV2({ ownerId: opts.owner, status: opts.status })),
830
+ );
831
+
832
+ root
833
+ .command("set-automation-status-v2 <id> <next>")
834
+ .description("Set V2 automation status")
835
+ .action((id, next) =>
836
+ tryRunV2(() => outV2(setAutomationStatusV2(id, next))),
837
+ );
838
+
839
+ root
840
+ .command("activate-automation-v2 <id>")
841
+ .description("Activate a V2 automation")
842
+ .action((id) => tryRunV2(() => outV2(activateAutomationV2(id))));
843
+
844
+ root
845
+ .command("pause-automation-v2 <id>")
846
+ .description("Pause a V2 automation")
847
+ .action((id) => tryRunV2(() => outV2(pauseAutomationV2(id))));
848
+
849
+ root
850
+ .command("retire-automation-v2 <id>")
851
+ .description("Retire a V2 automation")
852
+ .action((id) => tryRunV2(() => outV2(retireAutomationV2(id))));
853
+
854
+ root
855
+ .command("touch-automation-v2 <id>")
856
+ .description("Touch a V2 automation")
857
+ .action((id) => tryRunV2(() => outV2(touchAutomationV2(id))));
858
+
859
+ root
860
+ .command("create-execution-v2 <id>")
861
+ .description("Create a V2 execution")
862
+ .requiredOption("-a, --automation <id>", "automation id")
863
+ .action((id, opts) =>
864
+ tryRunV2(() =>
865
+ outV2(createExecutionV2(id, { automationId: opts.automation })),
866
+ ),
867
+ );
868
+
869
+ root
870
+ .command("get-execution-v2 <id>")
871
+ .description("Get a V2 execution")
872
+ .action((id) => outV2(getExecutionV2Surface(id)));
873
+
874
+ root
875
+ .command("list-executions-v2")
876
+ .description("List V2 executions")
877
+ .option("-a, --automation <id>", "filter by automation")
878
+ .option("-s, --status <status>", "filter by status")
879
+ .action((opts) =>
880
+ outV2(
881
+ listExecutionsV2({
882
+ automationId: opts.automation,
883
+ status: opts.status,
884
+ }),
885
+ ),
886
+ );
887
+
888
+ root
889
+ .command("set-execution-status-v2 <id> <next>")
890
+ .description("Set V2 execution status")
891
+ .action((id, next) =>
892
+ tryRunV2(() => outV2(setExecutionStatusV2(id, next))),
893
+ );
894
+
895
+ root
896
+ .command("start-execution-v2 <id>")
897
+ .description("Start a V2 execution")
898
+ .action((id) => tryRunV2(() => outV2(startExecutionV2(id))));
899
+
900
+ root
901
+ .command("succeed-execution-v2 <id>")
902
+ .description("Succeed a V2 execution")
903
+ .action((id) => tryRunV2(() => outV2(succeedExecutionV2(id))));
904
+
905
+ root
906
+ .command("fail-execution-v2 <id>")
907
+ .description("Fail a V2 execution")
908
+ .action((id) => tryRunV2(() => outV2(failExecutionV2(id))));
909
+
910
+ root
911
+ .command("cancel-execution-v2 <id>")
912
+ .description("Cancel a V2 execution")
913
+ .action((id) => tryRunV2(() => outV2(cancelExecutionV2(id))));
914
+
915
+ root
916
+ .command("auto-pause-idle-automations-v2")
917
+ .description("Auto-pause idle V2 automations")
918
+ .action(() => outV2(autoPauseIdleAutomationsV2()));
919
+
920
+ root
921
+ .command("auto-fail-stuck-executions-v2")
922
+ .description("Auto-fail stuck V2 executions")
923
+ .action(() => outV2(autoFailStuckExecutionsV2()));
654
924
  }
@@ -20,8 +20,52 @@ import {
20
20
  getScaffold,
21
21
  listScaffolds,
22
22
  getCodeAgentStats,
23
+
24
+ // Phase 86 V2
25
+ AGENT_MATURITY_V2,
26
+ GEN_JOB_V2,
27
+ getDefaultMaxActiveAgentsPerOwnerV2,
28
+ getMaxActiveAgentsPerOwnerV2,
29
+ setMaxActiveAgentsPerOwnerV2,
30
+ getDefaultMaxRunningJobsPerOwnerV2,
31
+ getMaxRunningJobsPerOwnerV2,
32
+ setMaxRunningJobsPerOwnerV2,
33
+ getDefaultAgentIdleMsV2,
34
+ getAgentIdleMsV2,
35
+ setAgentIdleMsV2,
36
+ getDefaultJobStuckMsV2,
37
+ getJobStuckMsV2,
38
+ setJobStuckMsV2,
39
+ registerAgentV2,
40
+ getAgentV2,
41
+ setAgentMaturityV2,
42
+ activateAgent,
43
+ deprecateAgent,
44
+ retireAgent,
45
+ touchAgentInvocation,
46
+ enqueueGenJobV2,
47
+ getGenJobV2,
48
+ setGenJobStatusV2,
49
+ startGenJob,
50
+ succeedGenJob,
51
+ failGenJob,
52
+ cancelGenJob,
53
+ getActiveAgentCount,
54
+ getRunningJobCount,
55
+ autoRetireIdleAgents,
56
+ autoFailStuckGenJobs,
57
+ getCodeAgentStatsV2,
23
58
  } from "../lib/code-agent.js";
24
59
 
60
+ function _parseMetaV2(raw) {
61
+ if (!raw) return undefined;
62
+ try {
63
+ return JSON.parse(raw);
64
+ } catch {
65
+ throw new Error("--metadata must be valid JSON");
66
+ }
67
+ }
68
+
25
69
  function _dbFromCtx(cmd) {
26
70
  const root = cmd?.parent?.parent ?? cmd?.parent;
27
71
  return root?._db;
@@ -299,5 +343,185 @@ export function registerCodegenCommand(program) {
299
343
  }
300
344
  });
301
345
 
346
+ /* ═══════════════════════════════════════════════════ *
347
+ * Phase 86 V2
348
+ * ═══════════════════════════════════════════════════ */
349
+
350
+ cg.command("agent-maturities-v2")
351
+ .description("List V2 agent maturity states")
352
+ .option("--json", "JSON")
353
+ .action((opts) => {
354
+ const xs = Object.values(AGENT_MATURITY_V2);
355
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
356
+ for (const x of xs) console.log(` ${x}`);
357
+ });
358
+
359
+ cg.command("gen-jobs-v2")
360
+ .description("List V2 generation-job states")
361
+ .option("--json", "JSON")
362
+ .action((opts) => {
363
+ const xs = Object.values(GEN_JOB_V2);
364
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
365
+ for (const x of xs) console.log(` ${x}`);
366
+ });
367
+
368
+ cg.command("default-max-active-agents-per-owner").action(() =>
369
+ console.log(getDefaultMaxActiveAgentsPerOwnerV2()),
370
+ );
371
+ cg.command("max-active-agents-per-owner").action(() =>
372
+ console.log(getMaxActiveAgentsPerOwnerV2()),
373
+ );
374
+ cg.command("set-max-active-agents-per-owner <n>").action((n) =>
375
+ console.log(setMaxActiveAgentsPerOwnerV2(n)),
376
+ );
377
+
378
+ cg.command("default-max-running-jobs-per-owner").action(() =>
379
+ console.log(getDefaultMaxRunningJobsPerOwnerV2()),
380
+ );
381
+ cg.command("max-running-jobs-per-owner").action(() =>
382
+ console.log(getMaxRunningJobsPerOwnerV2()),
383
+ );
384
+ cg.command("set-max-running-jobs-per-owner <n>").action((n) =>
385
+ console.log(setMaxRunningJobsPerOwnerV2(n)),
386
+ );
387
+
388
+ cg.command("default-agent-idle-ms").action(() =>
389
+ console.log(getDefaultAgentIdleMsV2()),
390
+ );
391
+ cg.command("agent-idle-ms").action(() => console.log(getAgentIdleMsV2()));
392
+ cg.command("set-agent-idle-ms <ms>").action((ms) =>
393
+ console.log(setAgentIdleMsV2(ms)),
394
+ );
395
+
396
+ cg.command("default-job-stuck-ms").action(() =>
397
+ console.log(getDefaultJobStuckMsV2()),
398
+ );
399
+ cg.command("job-stuck-ms").action(() => console.log(getJobStuckMsV2()));
400
+ cg.command("set-job-stuck-ms <ms>").action((ms) =>
401
+ console.log(setJobStuckMsV2(ms)),
402
+ );
403
+
404
+ cg.command("active-agent-count")
405
+ .option("-o, --owner <id>")
406
+ .action((opts) => console.log(getActiveAgentCount(opts.owner)));
407
+ cg.command("running-job-count")
408
+ .option("-o, --owner <id>")
409
+ .action((opts) => console.log(getRunningJobCount(opts.owner)));
410
+
411
+ cg.command("register-agent-v2 <agent-id>")
412
+ .requiredOption("-o, --owner <id>")
413
+ .option("-n, --name <name>")
414
+ .option("-i, --initial-status <s>")
415
+ .option("--metadata <json>")
416
+ .action((id, opts) => {
417
+ const r = registerAgentV2(null, {
418
+ agentId: id,
419
+ ownerId: opts.owner,
420
+ name: opts.name,
421
+ initialStatus: opts.initialStatus,
422
+ metadata: _parseMetaV2(opts.metadata),
423
+ });
424
+ console.log(JSON.stringify(r, null, 2));
425
+ });
426
+
427
+ cg.command("agent-v2 <agent-id>").action((id) => {
428
+ const r = getAgentV2(id);
429
+ if (!r) {
430
+ console.error(`Unknown agent: ${id}`);
431
+ process.exitCode = 1;
432
+ return;
433
+ }
434
+ console.log(JSON.stringify(r, null, 2));
435
+ });
436
+
437
+ cg.command("set-agent-maturity-v2 <agent-id> <status>")
438
+ .option("-r, --reason <text>")
439
+ .option("--metadata <json>")
440
+ .action((id, status, opts) => {
441
+ const r = setAgentMaturityV2(null, id, status, {
442
+ reason: opts.reason,
443
+ metadata: _parseMetaV2(opts.metadata),
444
+ });
445
+ console.log(JSON.stringify(r, null, 2));
446
+ });
447
+
448
+ for (const [name, fn] of [
449
+ ["activate-agent", activateAgent],
450
+ ["deprecate-agent", deprecateAgent],
451
+ ["retire-agent", retireAgent],
452
+ ]) {
453
+ cg.command(`${name} <agent-id>`)
454
+ .option("-r, --reason <text>")
455
+ .action((id, opts) => {
456
+ const r = fn(null, id, opts.reason);
457
+ console.log(JSON.stringify(r, null, 2));
458
+ });
459
+ }
460
+
461
+ cg.command("touch-agent-invocation <agent-id>").action((id) =>
462
+ console.log(JSON.stringify(touchAgentInvocation(id), null, 2)),
463
+ );
464
+
465
+ cg.command("enqueue-gen-job-v2 <job-id>")
466
+ .requiredOption("-o, --owner <id>")
467
+ .requiredOption("-a, --agent <id>")
468
+ .requiredOption("-p, --prompt <text>")
469
+ .option("--metadata <json>")
470
+ .action((id, opts) => {
471
+ const r = enqueueGenJobV2(null, {
472
+ jobId: id,
473
+ ownerId: opts.owner,
474
+ agentId: opts.agent,
475
+ prompt: opts.prompt,
476
+ metadata: _parseMetaV2(opts.metadata),
477
+ });
478
+ console.log(JSON.stringify(r, null, 2));
479
+ });
480
+
481
+ cg.command("gen-job-v2 <job-id>").action((id) => {
482
+ const r = getGenJobV2(id);
483
+ if (!r) {
484
+ console.error(`Unknown job: ${id}`);
485
+ process.exitCode = 1;
486
+ return;
487
+ }
488
+ console.log(JSON.stringify(r, null, 2));
489
+ });
490
+
491
+ cg.command("set-gen-job-status-v2 <job-id> <status>")
492
+ .option("-r, --reason <text>")
493
+ .option("--metadata <json>")
494
+ .action((id, status, opts) => {
495
+ const r = setGenJobStatusV2(null, id, status, {
496
+ reason: opts.reason,
497
+ metadata: _parseMetaV2(opts.metadata),
498
+ });
499
+ console.log(JSON.stringify(r, null, 2));
500
+ });
501
+
502
+ for (const [name, fn] of [
503
+ ["start-gen-job", startGenJob],
504
+ ["succeed-gen-job", succeedGenJob],
505
+ ["fail-gen-job", failGenJob],
506
+ ["cancel-gen-job", cancelGenJob],
507
+ ]) {
508
+ cg.command(`${name} <job-id>`)
509
+ .option("-r, --reason <text>")
510
+ .action((id, opts) => {
511
+ const r = fn(null, id, opts.reason);
512
+ console.log(JSON.stringify(r, null, 2));
513
+ });
514
+ }
515
+
516
+ cg.command("auto-retire-idle-agents").action(() =>
517
+ console.log(JSON.stringify(autoRetireIdleAgents(null), null, 2)),
518
+ );
519
+ cg.command("auto-fail-stuck-gen-jobs").action(() =>
520
+ console.log(JSON.stringify(autoFailStuckGenJobs(null), null, 2)),
521
+ );
522
+ cg.command("stats-v2").action(() =>
523
+ console.log(JSON.stringify(getCodeAgentStatsV2(), null, 2)),
524
+ );
525
+
302
526
  program.addCommand(cg);
303
527
  }