chainlesschain 0.66.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 (143) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +380 -0
  4. package/src/commands/agent-network.js +254 -1
  5. package/src/commands/audit.js +302 -0
  6. package/src/commands/automation.js +271 -1
  7. package/src/commands/bi.js +348 -0
  8. package/src/commands/codegen.js +224 -0
  9. package/src/commands/collab.js +341 -0
  10. package/src/commands/compliance.js +1035 -0
  11. package/src/commands/cowork.js +221 -0
  12. package/src/commands/crosschain.js +218 -0
  13. package/src/commands/dbevo.js +284 -0
  14. package/src/commands/dev.js +252 -0
  15. package/src/commands/did.js +358 -0
  16. package/src/commands/dlp.js +341 -0
  17. package/src/commands/encrypt.js +341 -0
  18. package/src/commands/evomap.js +394 -0
  19. package/src/commands/export.js +256 -1
  20. package/src/commands/federation.js +283 -0
  21. package/src/commands/fusion.js +258 -0
  22. package/src/commands/governance.js +325 -0
  23. package/src/commands/hardening.js +411 -0
  24. package/src/commands/hook.js +148 -0
  25. package/src/commands/import.js +252 -0
  26. package/src/commands/incentive.js +322 -0
  27. package/src/commands/inference.js +318 -0
  28. package/src/commands/infra.js +244 -0
  29. package/src/commands/instinct.js +260 -0
  30. package/src/commands/ipfs.js +318 -0
  31. package/src/commands/kg.js +387 -0
  32. package/src/commands/llm.js +263 -0
  33. package/src/commands/lowcode.js +356 -0
  34. package/src/commands/marketplace.js +256 -0
  35. package/src/commands/mcp.js +221 -0
  36. package/src/commands/memory.js +248 -0
  37. package/src/commands/multimodal.js +296 -0
  38. package/src/commands/nlprog.js +356 -0
  39. package/src/commands/note.js +244 -0
  40. package/src/commands/ops.js +354 -0
  41. package/src/commands/orchestrate.js +166 -0
  42. package/src/commands/org.js +277 -0
  43. package/src/commands/p2p.js +390 -0
  44. package/src/commands/perception.js +290 -0
  45. package/src/commands/permmem.js +251 -0
  46. package/src/commands/plugin-ecosystem.js +273 -0
  47. package/src/commands/pqc.js +393 -0
  48. package/src/commands/privacy.js +321 -0
  49. package/src/commands/quantization.js +351 -0
  50. package/src/commands/rcache.js +271 -0
  51. package/src/commands/recommend.js +340 -0
  52. package/src/commands/reputation.js +261 -0
  53. package/src/commands/runtime.js +307 -0
  54. package/src/commands/scim.js +262 -0
  55. package/src/commands/session.js +258 -0
  56. package/src/commands/siem.js +246 -0
  57. package/src/commands/skill.js +267 -1
  58. package/src/commands/sla.js +259 -0
  59. package/src/commands/social.js +256 -0
  60. package/src/commands/sso.js +186 -1
  61. package/src/commands/stress.js +230 -0
  62. package/src/commands/sync.js +256 -0
  63. package/src/commands/tech.js +338 -0
  64. package/src/commands/tenant.js +351 -0
  65. package/src/commands/terraform.js +245 -0
  66. package/src/commands/tokens.js +269 -0
  67. package/src/commands/trust.js +249 -0
  68. package/src/commands/wallet.js +277 -0
  69. package/src/commands/workflow.js +171 -0
  70. package/src/commands/zkp.js +335 -0
  71. package/src/index.js +4 -0
  72. package/src/lib/a2a-protocol.js +451 -0
  73. package/src/lib/agent-coordinator.js +325 -0
  74. package/src/lib/agent-network.js +387 -0
  75. package/src/lib/agent-router.js +395 -0
  76. package/src/lib/aiops.js +478 -0
  77. package/src/lib/app-builder.js +239 -0
  78. package/src/lib/audit-logger.js +379 -0
  79. package/src/lib/automation-engine.js +330 -0
  80. package/src/lib/autonomous-developer.js +350 -0
  81. package/src/lib/bi-engine.js +338 -0
  82. package/src/lib/code-agent.js +323 -0
  83. package/src/lib/collaboration-governance.js +364 -0
  84. package/src/lib/community-governance.js +436 -0
  85. package/src/lib/compliance-manager.js +434 -0
  86. package/src/lib/content-recommendation.js +469 -0
  87. package/src/lib/cross-chain.js +345 -0
  88. package/src/lib/crypto-manager.js +350 -0
  89. package/src/lib/dbevo.js +338 -0
  90. package/src/lib/decentral-infra.js +340 -0
  91. package/src/lib/did-manager.js +367 -0
  92. package/src/lib/dlp-engine.js +389 -0
  93. package/src/lib/evomap-federation.js +177 -0
  94. package/src/lib/evomap-governance.js +276 -0
  95. package/src/lib/federation-hardening.js +259 -0
  96. package/src/lib/hardening-manager.js +348 -0
  97. package/src/lib/hook-manager.js +380 -0
  98. package/src/lib/inference-network.js +330 -0
  99. package/src/lib/instinct-manager.js +332 -0
  100. package/src/lib/ipfs-storage.js +334 -0
  101. package/src/lib/knowledge-exporter.js +381 -0
  102. package/src/lib/knowledge-graph.js +432 -0
  103. package/src/lib/knowledge-importer.js +379 -0
  104. package/src/lib/llm-providers.js +391 -0
  105. package/src/lib/mcp-registry.js +333 -0
  106. package/src/lib/memory-manager.js +330 -0
  107. package/src/lib/multimodal.js +346 -0
  108. package/src/lib/nl-programming.js +343 -0
  109. package/src/lib/note-versioning.js +327 -0
  110. package/src/lib/org-manager.js +323 -0
  111. package/src/lib/p2p-manager.js +387 -0
  112. package/src/lib/perception.js +346 -0
  113. package/src/lib/perf-tuning.js +4 -1
  114. package/src/lib/permanent-memory.js +320 -0
  115. package/src/lib/plugin-ecosystem.js +377 -0
  116. package/src/lib/pqc-manager.js +368 -0
  117. package/src/lib/privacy-computing.js +427 -0
  118. package/src/lib/protocol-fusion.js +417 -0
  119. package/src/lib/quantization.js +325 -0
  120. package/src/lib/reputation-optimizer.js +299 -0
  121. package/src/lib/response-cache.js +327 -0
  122. package/src/lib/scim-manager.js +329 -0
  123. package/src/lib/session-manager.js +329 -0
  124. package/src/lib/siem-exporter.js +333 -0
  125. package/src/lib/skill-loader.js +377 -0
  126. package/src/lib/skill-marketplace.js +325 -0
  127. package/src/lib/sla-manager.js +275 -0
  128. package/src/lib/social-manager.js +326 -0
  129. package/src/lib/sso-manager.js +332 -0
  130. package/src/lib/stress-tester.js +330 -0
  131. package/src/lib/sync-manager.js +326 -0
  132. package/src/lib/tech-learning-engine.js +369 -0
  133. package/src/lib/tenant-saas.js +460 -0
  134. package/src/lib/terraform-manager.js +363 -0
  135. package/src/lib/threat-intel.js +335 -0
  136. package/src/lib/token-incentive.js +293 -0
  137. package/src/lib/token-tracker.js +329 -0
  138. package/src/lib/trust-security.js +390 -0
  139. package/src/lib/ueba.js +389 -0
  140. package/src/lib/universal-runtime.js +325 -0
  141. package/src/lib/wallet-manager.js +326 -0
  142. package/src/lib/workflow-engine.js +322 -0
  143. package/src/lib/zkp-engine.js +274 -0
@@ -16,6 +16,39 @@ import {
16
16
  addConnector,
17
17
  syncProvision,
18
18
  getStatus,
19
+ IDENTITY_LIFECYCLE_V2,
20
+ SYNC_JOB_V2,
21
+ SCIM_DEFAULT_MAX_PROVISIONED_PER_CONNECTOR,
22
+ SCIM_DEFAULT_MAX_RUNNING_SYNC_PER_CONNECTOR,
23
+ SCIM_DEFAULT_IDENTITY_IDLE_MS,
24
+ SCIM_DEFAULT_SYNC_STUCK_MS,
25
+ getMaxProvisionedPerConnectorV2,
26
+ setMaxProvisionedPerConnectorV2,
27
+ getMaxRunningSyncPerConnectorV2,
28
+ setMaxRunningSyncPerConnectorV2,
29
+ getIdentityIdleMsV2,
30
+ setIdentityIdleMsV2,
31
+ getSyncStuckMsV2,
32
+ setSyncStuckMsV2,
33
+ getProvisionedCountV2,
34
+ getRunningSyncCountV2,
35
+ registerIdentityV2,
36
+ getIdentityV2,
37
+ listIdentitiesV2,
38
+ provisionIdentityV2,
39
+ suspendIdentityV2,
40
+ deprovisionIdentityV2,
41
+ touchIdentityV2,
42
+ createSyncJobV2,
43
+ getSyncJobV2,
44
+ listSyncJobsV2,
45
+ startSyncJobV2,
46
+ succeedSyncJobV2,
47
+ failSyncJobV2,
48
+ cancelSyncJobV2,
49
+ autoDeprovisionIdleIdentitiesV2,
50
+ autoFailStuckSyncJobsV2,
51
+ getScimManagerStatsV2,
19
52
  } from "../lib/scim-manager.js";
20
53
 
21
54
  export function registerScimCommand(program) {
@@ -215,4 +248,233 @@ export function registerScimCommand(program) {
215
248
  process.exit(1);
216
249
  }
217
250
  });
251
+
252
+ // ─────────────────────────────────────────────────────────────
253
+ // V2 Surface — identity + sync-job lifecycle (in-memory, throwing API)
254
+ // ─────────────────────────────────────────────────────────────
255
+
256
+ scim
257
+ .command("identity-lifecycles-v2")
258
+ .description("List V2 identity lifecycle states")
259
+ .option("--json", "Output as JSON")
260
+ .action((options) => {
261
+ const v = Object.values(IDENTITY_LIFECYCLE_V2);
262
+ if (options.json) console.log(JSON.stringify(v));
263
+ else logger.log(v.join(", "));
264
+ });
265
+
266
+ scim
267
+ .command("sync-lifecycles-v2")
268
+ .description("List V2 sync-job lifecycle states")
269
+ .option("--json", "Output as JSON")
270
+ .action((options) => {
271
+ const v = Object.values(SYNC_JOB_V2);
272
+ if (options.json) console.log(JSON.stringify(v));
273
+ else logger.log(v.join(", "));
274
+ });
275
+
276
+ scim
277
+ .command("stats-v2")
278
+ .description("Show V2 SCIM stats")
279
+ .option("--json", "Output as JSON")
280
+ .action((options) => {
281
+ const stats = getScimManagerStatsV2();
282
+ if (options.json) console.log(JSON.stringify(stats, null, 2));
283
+ else logger.log(JSON.stringify(stats, null, 2));
284
+ });
285
+
286
+ scim
287
+ .command("get-max-provisioned-v2")
288
+ .description("Get max provisioned identities per connector")
289
+ .action(() => logger.log(String(getMaxProvisionedPerConnectorV2())));
290
+ scim
291
+ .command("set-max-provisioned-v2 <n>")
292
+ .description("Set max provisioned identities per connector")
293
+ .action((n) => {
294
+ setMaxProvisionedPerConnectorV2(Number(n));
295
+ logger.log(String(getMaxProvisionedPerConnectorV2()));
296
+ });
297
+ scim
298
+ .command("get-max-running-sync-v2")
299
+ .description("Get max running sync jobs per connector")
300
+ .action(() => logger.log(String(getMaxRunningSyncPerConnectorV2())));
301
+ scim
302
+ .command("set-max-running-sync-v2 <n>")
303
+ .description("Set max running sync jobs per connector")
304
+ .action((n) => {
305
+ setMaxRunningSyncPerConnectorV2(Number(n));
306
+ logger.log(String(getMaxRunningSyncPerConnectorV2()));
307
+ });
308
+ scim
309
+ .command("get-identity-idle-ms-v2")
310
+ .description("Get identity idle ms")
311
+ .action(() => logger.log(String(getIdentityIdleMsV2())));
312
+ scim
313
+ .command("set-identity-idle-ms-v2 <ms>")
314
+ .description("Set identity idle ms")
315
+ .action((ms) => {
316
+ setIdentityIdleMsV2(Number(ms));
317
+ logger.log(String(getIdentityIdleMsV2()));
318
+ });
319
+ scim
320
+ .command("get-sync-stuck-ms-v2")
321
+ .description("Get sync-job stuck ms")
322
+ .action(() => logger.log(String(getSyncStuckMsV2())));
323
+ scim
324
+ .command("set-sync-stuck-ms-v2 <ms>")
325
+ .description("Set sync-job stuck ms")
326
+ .action((ms) => {
327
+ setSyncStuckMsV2(Number(ms));
328
+ logger.log(String(getSyncStuckMsV2()));
329
+ });
330
+
331
+ scim
332
+ .command("provisioned-count-v2 <connectorId>")
333
+ .description("Count provisioned identities for connector")
334
+ .action((connectorId) =>
335
+ logger.log(String(getProvisionedCountV2(connectorId))),
336
+ );
337
+ scim
338
+ .command("running-sync-count-v2 <connectorId>")
339
+ .description("Count running sync jobs for connector")
340
+ .action((connectorId) =>
341
+ logger.log(String(getRunningSyncCountV2(connectorId))),
342
+ );
343
+
344
+ scim
345
+ .command("register-identity-v2 <id>")
346
+ .description("Register V2 identity (initial=pending)")
347
+ .requiredOption("-c, --connector <id>", "connector id")
348
+ .requiredOption("-e, --external <id>", "external id")
349
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
350
+ .action((id, opts) => {
351
+ const meta = JSON.parse(opts.metadata);
352
+ const i = registerIdentityV2(id, {
353
+ connectorId: opts.connector,
354
+ externalId: opts.external,
355
+ metadata: meta,
356
+ });
357
+ console.log(JSON.stringify(i, null, 2));
358
+ });
359
+
360
+ scim
361
+ .command("get-identity-v2 <id>")
362
+ .description("Get V2 identity by id")
363
+ .action((id) => {
364
+ const i = getIdentityV2(id);
365
+ if (!i) {
366
+ logger.error(`identity ${id} not found`);
367
+ process.exit(1);
368
+ }
369
+ console.log(JSON.stringify(i, null, 2));
370
+ });
371
+
372
+ scim
373
+ .command("list-identities-v2")
374
+ .description("List V2 identities")
375
+ .option("-c, --connector <id>", "filter by connector")
376
+ .option("-s, --status <state>", "filter by status")
377
+ .action((opts) => {
378
+ const out = listIdentitiesV2({
379
+ connectorId: opts.connector,
380
+ status: opts.status,
381
+ });
382
+ console.log(JSON.stringify(out, null, 2));
383
+ });
384
+
385
+ scim
386
+ .command("provision-identity-v2 <id>")
387
+ .description("Transition identity → provisioned")
388
+ .action((id) =>
389
+ console.log(JSON.stringify(provisionIdentityV2(id), null, 2)),
390
+ );
391
+ scim
392
+ .command("suspend-identity-v2 <id>")
393
+ .description("Transition identity → suspended")
394
+ .action((id) =>
395
+ console.log(JSON.stringify(suspendIdentityV2(id), null, 2)),
396
+ );
397
+ scim
398
+ .command("deprovision-identity-v2 <id>")
399
+ .description("Transition identity → deprovisioned (terminal)")
400
+ .action((id) =>
401
+ console.log(JSON.stringify(deprovisionIdentityV2(id), null, 2)),
402
+ );
403
+ scim
404
+ .command("touch-identity-v2 <id>")
405
+ .description("Update identity lastSeenAt")
406
+ .action((id) => console.log(JSON.stringify(touchIdentityV2(id), null, 2)));
407
+
408
+ scim
409
+ .command("create-sync-job-v2 <id>")
410
+ .description("Create V2 sync job (initial=queued)")
411
+ .requiredOption("-c, --connector <id>", "connector id")
412
+ .option("-k, --kind <kind>", "job kind", "full")
413
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
414
+ .action((id, opts) => {
415
+ const meta = JSON.parse(opts.metadata);
416
+ const j = createSyncJobV2(id, {
417
+ connectorId: opts.connector,
418
+ kind: opts.kind,
419
+ metadata: meta,
420
+ });
421
+ console.log(JSON.stringify(j, null, 2));
422
+ });
423
+
424
+ scim
425
+ .command("get-sync-job-v2 <id>")
426
+ .description("Get V2 sync job by id")
427
+ .action((id) => {
428
+ const j = getSyncJobV2(id);
429
+ if (!j) {
430
+ logger.error(`syncJob ${id} not found`);
431
+ process.exit(1);
432
+ }
433
+ console.log(JSON.stringify(j, null, 2));
434
+ });
435
+
436
+ scim
437
+ .command("list-sync-jobs-v2")
438
+ .description("List V2 sync jobs")
439
+ .option("-c, --connector <id>", "filter by connector")
440
+ .option("-s, --status <state>", "filter by status")
441
+ .action((opts) => {
442
+ const out = listSyncJobsV2({
443
+ connectorId: opts.connector,
444
+ status: opts.status,
445
+ });
446
+ console.log(JSON.stringify(out, null, 2));
447
+ });
448
+
449
+ scim
450
+ .command("start-sync-job-v2 <id>")
451
+ .description("Transition sync job → running")
452
+ .action((id) => console.log(JSON.stringify(startSyncJobV2(id), null, 2)));
453
+ scim
454
+ .command("succeed-sync-job-v2 <id>")
455
+ .description("Transition sync job → succeeded (terminal)")
456
+ .action((id) => console.log(JSON.stringify(succeedSyncJobV2(id), null, 2)));
457
+ scim
458
+ .command("fail-sync-job-v2 <id>")
459
+ .description("Transition sync job → failed (terminal)")
460
+ .action((id) => console.log(JSON.stringify(failSyncJobV2(id), null, 2)));
461
+ scim
462
+ .command("cancel-sync-job-v2 <id>")
463
+ .description("Transition sync job → cancelled (terminal)")
464
+ .action((id) => console.log(JSON.stringify(cancelSyncJobV2(id), null, 2)));
465
+
466
+ scim
467
+ .command("auto-deprovision-idle-v2")
468
+ .description("Auto-deprovision idle identities; output flipped")
469
+ .action(() => {
470
+ const flipped = autoDeprovisionIdleIdentitiesV2();
471
+ console.log(JSON.stringify(flipped, null, 2));
472
+ });
473
+ scim
474
+ .command("auto-fail-stuck-sync-v2")
475
+ .description("Auto-fail stuck running syncs; output flipped")
476
+ .action(() => {
477
+ const flipped = autoFailStuckSyncJobsV2();
478
+ console.log(JSON.stringify(flipped, null, 2));
479
+ });
218
480
  }
@@ -13,6 +13,35 @@ import {
13
13
  getSession,
14
14
  deleteSession,
15
15
  exportSessionMarkdown,
16
+ CONVERSATION_MATURITY_V2,
17
+ TURN_LIFECYCLE_V2,
18
+ getMaxActiveConvPerUserV2,
19
+ setMaxActiveConvPerUserV2,
20
+ getMaxPendingTurnsPerConvV2,
21
+ setMaxPendingTurnsPerConvV2,
22
+ getConvIdleMsV2,
23
+ setConvIdleMsV2,
24
+ getTurnStuckMsV2,
25
+ setTurnStuckMsV2,
26
+ getActiveConvCountV2,
27
+ getPendingTurnCountV2,
28
+ registerConversationV2,
29
+ getConversationV2,
30
+ listConversationsV2,
31
+ activateConversationV2,
32
+ pauseConversationV2,
33
+ archiveConversationV2,
34
+ touchConversationV2,
35
+ createTurnV2,
36
+ getTurnV2,
37
+ listTurnsV2,
38
+ streamTurnV2,
39
+ completeTurnV2,
40
+ failTurnV2,
41
+ cancelTurnV2,
42
+ autoArchiveIdleConversationsV2,
43
+ autoFailStuckTurnsV2,
44
+ getSessionManagerStatsV2,
16
45
  } from "../lib/session-manager.js";
17
46
  import {
18
47
  listJsonlSessions,
@@ -785,4 +814,233 @@ export function registerSessionCommand(program) {
785
814
  process.exit(1);
786
815
  }
787
816
  });
817
+
818
+ // ─────────────────────────────────────────────────────────────
819
+ // V2 Surface — conversation + turn lifecycle (in-memory, throwing API)
820
+ // ─────────────────────────────────────────────────────────────
821
+
822
+ session
823
+ .command("conversation-maturities-v2")
824
+ .description("List V2 conversation maturity states")
825
+ .option("--json", "Output as JSON")
826
+ .action((options) => {
827
+ const v = Object.values(CONVERSATION_MATURITY_V2);
828
+ if (options.json) console.log(JSON.stringify(v));
829
+ else logger.log(v.join(", "));
830
+ });
831
+
832
+ session
833
+ .command("turn-lifecycles-v2")
834
+ .description("List V2 turn lifecycle states")
835
+ .option("--json", "Output as JSON")
836
+ .action((options) => {
837
+ const v = Object.values(TURN_LIFECYCLE_V2);
838
+ if (options.json) console.log(JSON.stringify(v));
839
+ else logger.log(v.join(", "));
840
+ });
841
+
842
+ session
843
+ .command("stats-v2")
844
+ .description("Show V2 session stats")
845
+ .option("--json", "Output as JSON")
846
+ .action((options) => {
847
+ const stats = getSessionManagerStatsV2();
848
+ if (options.json) console.log(JSON.stringify(stats, null, 2));
849
+ else logger.log(JSON.stringify(stats, null, 2));
850
+ });
851
+
852
+ session
853
+ .command("get-max-active-conv-v2")
854
+ .description("Get max active conversations per user")
855
+ .action(() => logger.log(String(getMaxActiveConvPerUserV2())));
856
+ session
857
+ .command("set-max-active-conv-v2 <n>")
858
+ .description("Set max active conversations per user")
859
+ .action((n) => {
860
+ setMaxActiveConvPerUserV2(Number(n));
861
+ logger.log(String(getMaxActiveConvPerUserV2()));
862
+ });
863
+ session
864
+ .command("get-max-pending-turns-v2")
865
+ .description("Get max pending turns per conversation")
866
+ .action(() => logger.log(String(getMaxPendingTurnsPerConvV2())));
867
+ session
868
+ .command("set-max-pending-turns-v2 <n>")
869
+ .description("Set max pending turns per conversation")
870
+ .action((n) => {
871
+ setMaxPendingTurnsPerConvV2(Number(n));
872
+ logger.log(String(getMaxPendingTurnsPerConvV2()));
873
+ });
874
+ session
875
+ .command("get-conv-idle-ms-v2")
876
+ .description("Get conversation idle ms")
877
+ .action(() => logger.log(String(getConvIdleMsV2())));
878
+ session
879
+ .command("set-conv-idle-ms-v2 <ms>")
880
+ .description("Set conversation idle ms")
881
+ .action((ms) => {
882
+ setConvIdleMsV2(Number(ms));
883
+ logger.log(String(getConvIdleMsV2()));
884
+ });
885
+ session
886
+ .command("get-turn-stuck-ms-v2")
887
+ .description("Get turn stuck ms")
888
+ .action(() => logger.log(String(getTurnStuckMsV2())));
889
+ session
890
+ .command("set-turn-stuck-ms-v2 <ms>")
891
+ .description("Set turn stuck ms")
892
+ .action((ms) => {
893
+ setTurnStuckMsV2(Number(ms));
894
+ logger.log(String(getTurnStuckMsV2()));
895
+ });
896
+
897
+ session
898
+ .command("active-conv-count-v2 <userId>")
899
+ .description("Count active conversations for user")
900
+ .action((userId) => logger.log(String(getActiveConvCountV2(userId))));
901
+ session
902
+ .command("pending-turn-count-v2 <conversationId>")
903
+ .description("Count pending+streaming turns for conversation")
904
+ .action((conversationId) =>
905
+ logger.log(String(getPendingTurnCountV2(conversationId))),
906
+ );
907
+
908
+ session
909
+ .command("register-conversation-v2 <id>")
910
+ .description("Register V2 conversation (initial=draft)")
911
+ .requiredOption("-u, --user <userId>", "user id")
912
+ .requiredOption("-m, --model <model>", "model")
913
+ .option("--metadata <json>", "metadata JSON", "{}")
914
+ .action((id, opts) => {
915
+ const meta = JSON.parse(opts.metadata);
916
+ const c = registerConversationV2(id, {
917
+ userId: opts.user,
918
+ model: opts.model,
919
+ metadata: meta,
920
+ });
921
+ console.log(JSON.stringify(c, null, 2));
922
+ });
923
+
924
+ session
925
+ .command("get-conversation-v2 <id>")
926
+ .description("Get V2 conversation by id")
927
+ .action((id) => {
928
+ const c = getConversationV2(id);
929
+ if (!c) {
930
+ logger.error(`conversation ${id} not found`);
931
+ process.exit(1);
932
+ }
933
+ console.log(JSON.stringify(c, null, 2));
934
+ });
935
+
936
+ session
937
+ .command("list-conversations-v2")
938
+ .description("List V2 conversations")
939
+ .option("-u, --user <userId>", "filter by user")
940
+ .option("-s, --status <state>", "filter by status")
941
+ .action((opts) => {
942
+ const out = listConversationsV2({
943
+ userId: opts.user,
944
+ status: opts.status,
945
+ });
946
+ console.log(JSON.stringify(out, null, 2));
947
+ });
948
+
949
+ session
950
+ .command("activate-conversation-v2 <id>")
951
+ .description("Transition conversation → active")
952
+ .action((id) =>
953
+ console.log(JSON.stringify(activateConversationV2(id), null, 2)),
954
+ );
955
+ session
956
+ .command("pause-conversation-v2 <id>")
957
+ .description("Transition conversation → paused")
958
+ .action((id) =>
959
+ console.log(JSON.stringify(pauseConversationV2(id), null, 2)),
960
+ );
961
+ session
962
+ .command("archive-conversation-v2 <id>")
963
+ .description("Transition conversation → archived (terminal)")
964
+ .action((id) =>
965
+ console.log(JSON.stringify(archiveConversationV2(id), null, 2)),
966
+ );
967
+ session
968
+ .command("touch-conversation-v2 <id>")
969
+ .description("Update conversation lastSeenAt")
970
+ .action((id) =>
971
+ console.log(JSON.stringify(touchConversationV2(id), null, 2)),
972
+ );
973
+
974
+ session
975
+ .command("create-turn-v2 <id>")
976
+ .description("Create V2 turn (initial=pending)")
977
+ .requiredOption("-c, --conversation <id>", "conversation id")
978
+ .option("-r, --role <role>", "role (user/assistant)", "user")
979
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
980
+ .action((id, opts) => {
981
+ const meta = JSON.parse(opts.metadata);
982
+ const t = createTurnV2(id, {
983
+ conversationId: opts.conversation,
984
+ role: opts.role,
985
+ metadata: meta,
986
+ });
987
+ console.log(JSON.stringify(t, null, 2));
988
+ });
989
+
990
+ session
991
+ .command("get-turn-v2 <id>")
992
+ .description("Get V2 turn by id")
993
+ .action((id) => {
994
+ const t = getTurnV2(id);
995
+ if (!t) {
996
+ logger.error(`turn ${id} not found`);
997
+ process.exit(1);
998
+ }
999
+ console.log(JSON.stringify(t, null, 2));
1000
+ });
1001
+
1002
+ session
1003
+ .command("list-turns-v2")
1004
+ .description("List V2 turns")
1005
+ .option("-c, --conversation <id>", "filter by conversation")
1006
+ .option("-s, --status <state>", "filter by status")
1007
+ .action((opts) => {
1008
+ const out = listTurnsV2({
1009
+ conversationId: opts.conversation,
1010
+ status: opts.status,
1011
+ });
1012
+ console.log(JSON.stringify(out, null, 2));
1013
+ });
1014
+
1015
+ session
1016
+ .command("stream-turn-v2 <id>")
1017
+ .description("Transition turn → streaming")
1018
+ .action((id) => console.log(JSON.stringify(streamTurnV2(id), null, 2)));
1019
+ session
1020
+ .command("complete-turn-v2 <id>")
1021
+ .description("Transition turn → completed (terminal)")
1022
+ .action((id) => console.log(JSON.stringify(completeTurnV2(id), null, 2)));
1023
+ session
1024
+ .command("fail-turn-v2 <id>")
1025
+ .description("Transition turn → failed (terminal)")
1026
+ .action((id) => console.log(JSON.stringify(failTurnV2(id), null, 2)));
1027
+ session
1028
+ .command("cancel-turn-v2 <id>")
1029
+ .description("Transition turn → cancelled (terminal)")
1030
+ .action((id) => console.log(JSON.stringify(cancelTurnV2(id), null, 2)));
1031
+
1032
+ session
1033
+ .command("auto-archive-idle-conv-v2")
1034
+ .description("Auto-archive idle conversations; output flipped")
1035
+ .action(() => {
1036
+ const flipped = autoArchiveIdleConversationsV2();
1037
+ console.log(JSON.stringify(flipped, null, 2));
1038
+ });
1039
+ session
1040
+ .command("auto-fail-stuck-turns-v2")
1041
+ .description("Auto-fail stuck streaming turns; output flipped")
1042
+ .action(() => {
1043
+ const flipped = autoFailStuckTurnsV2();
1044
+ console.log(JSON.stringify(flipped, null, 2));
1045
+ });
788
1046
  }