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.
- package/bin/chainlesschain.js +0 -0
- package/package.json +1 -1
- package/src/commands/a2a.js +380 -0
- package/src/commands/agent-network.js +254 -1
- package/src/commands/audit.js +302 -0
- package/src/commands/automation.js +271 -1
- package/src/commands/bi.js +348 -0
- package/src/commands/codegen.js +224 -0
- package/src/commands/collab.js +341 -0
- package/src/commands/compliance.js +1035 -0
- package/src/commands/cowork.js +221 -0
- package/src/commands/crosschain.js +218 -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 +341 -0
- package/src/commands/encrypt.js +341 -0
- package/src/commands/evomap.js +394 -0
- package/src/commands/export.js +256 -1
- package/src/commands/federation.js +283 -0
- package/src/commands/fusion.js +258 -0
- package/src/commands/governance.js +325 -0
- package/src/commands/hardening.js +411 -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 +318 -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/kg.js +387 -0
- package/src/commands/llm.js +263 -0
- package/src/commands/lowcode.js +356 -0
- package/src/commands/marketplace.js +256 -0
- package/src/commands/mcp.js +221 -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/note.js +244 -0
- package/src/commands/ops.js +354 -0
- package/src/commands/orchestrate.js +166 -0
- package/src/commands/org.js +277 -0
- package/src/commands/p2p.js +390 -0
- package/src/commands/perception.js +290 -0
- package/src/commands/permmem.js +251 -0
- package/src/commands/plugin-ecosystem.js +273 -0
- package/src/commands/pqc.js +393 -0
- package/src/commands/privacy.js +321 -0
- package/src/commands/quantization.js +351 -0
- package/src/commands/rcache.js +271 -0
- package/src/commands/recommend.js +340 -0
- package/src/commands/reputation.js +261 -0
- package/src/commands/runtime.js +307 -0
- package/src/commands/scim.js +262 -0
- package/src/commands/session.js +258 -0
- package/src/commands/siem.js +246 -0
- package/src/commands/skill.js +267 -1
- package/src/commands/sla.js +259 -0
- package/src/commands/social.js +256 -0
- package/src/commands/sso.js +186 -1
- package/src/commands/stress.js +230 -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/terraform.js +245 -0
- package/src/commands/tokens.js +269 -0
- package/src/commands/trust.js +249 -0
- package/src/commands/wallet.js +277 -0
- package/src/commands/workflow.js +171 -0
- package/src/commands/zkp.js +335 -0
- package/src/index.js +4 -0
- package/src/lib/a2a-protocol.js +451 -0
- package/src/lib/agent-coordinator.js +325 -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 +239 -0
- package/src/lib/audit-logger.js +379 -0
- package/src/lib/automation-engine.js +330 -0
- package/src/lib/autonomous-developer.js +350 -0
- package/src/lib/bi-engine.js +338 -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-manager.js +434 -0
- package/src/lib/content-recommendation.js +469 -0
- package/src/lib/cross-chain.js +345 -0
- package/src/lib/crypto-manager.js +350 -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 +389 -0
- package/src/lib/evomap-federation.js +177 -0
- package/src/lib/evomap-governance.js +276 -0
- package/src/lib/federation-hardening.js +259 -0
- package/src/lib/hardening-manager.js +348 -0
- package/src/lib/hook-manager.js +380 -0
- package/src/lib/inference-network.js +330 -0
- package/src/lib/instinct-manager.js +332 -0
- package/src/lib/ipfs-storage.js +334 -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/mcp-registry.js +333 -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/note-versioning.js +327 -0
- package/src/lib/org-manager.js +323 -0
- package/src/lib/p2p-manager.js +387 -0
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +4 -1
- package/src/lib/permanent-memory.js +320 -0
- package/src/lib/plugin-ecosystem.js +377 -0
- package/src/lib/pqc-manager.js +368 -0
- package/src/lib/privacy-computing.js +427 -0
- package/src/lib/protocol-fusion.js +417 -0
- package/src/lib/quantization.js +325 -0
- package/src/lib/reputation-optimizer.js +299 -0
- package/src/lib/response-cache.js +327 -0
- package/src/lib/scim-manager.js +329 -0
- package/src/lib/session-manager.js +329 -0
- package/src/lib/siem-exporter.js +333 -0
- package/src/lib/skill-loader.js +377 -0
- package/src/lib/skill-marketplace.js +325 -0
- package/src/lib/sla-manager.js +275 -0
- package/src/lib/social-manager.js +326 -0
- package/src/lib/sso-manager.js +332 -0
- package/src/lib/stress-tester.js +330 -0
- package/src/lib/sync-manager.js +326 -0
- package/src/lib/tech-learning-engine.js +369 -0
- package/src/lib/tenant-saas.js +460 -0
- package/src/lib/terraform-manager.js +363 -0
- package/src/lib/threat-intel.js +335 -0
- package/src/lib/token-incentive.js +293 -0
- package/src/lib/token-tracker.js +329 -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/wallet-manager.js +326 -0
- package/src/lib/workflow-engine.js +322 -0
- package/src/lib/zkp-engine.js +274 -0
package/src/commands/bi.js
CHANGED
|
@@ -15,6 +15,21 @@ import {
|
|
|
15
15
|
detectAnomaly,
|
|
16
16
|
predictTrend,
|
|
17
17
|
listTemplates,
|
|
18
|
+
// Phase 95 V2
|
|
19
|
+
CHART_TYPE,
|
|
20
|
+
ANOMALY_METHOD,
|
|
21
|
+
REPORT_FORMAT,
|
|
22
|
+
REPORT_STATUS,
|
|
23
|
+
DASHBOARD_LAYOUT,
|
|
24
|
+
nlQueryV2,
|
|
25
|
+
detectAnomalyV2,
|
|
26
|
+
predictTrendV2,
|
|
27
|
+
recommendChart,
|
|
28
|
+
createDashboardV2,
|
|
29
|
+
updateReportStatus,
|
|
30
|
+
getReportStatus,
|
|
31
|
+
getReportStatusHistory,
|
|
32
|
+
getBIStatsV2,
|
|
18
33
|
} from "../lib/bi-engine.js";
|
|
19
34
|
|
|
20
35
|
export function registerBiCommand(program) {
|
|
@@ -216,6 +231,339 @@ export function registerBiCommand(program) {
|
|
|
216
231
|
}
|
|
217
232
|
});
|
|
218
233
|
|
|
234
|
+
// ─── Phase 95 V2 subcommands ──────────────────────────────
|
|
235
|
+
|
|
236
|
+
// bi chart-types
|
|
237
|
+
bi.command("chart-types")
|
|
238
|
+
.description("List supported chart types (V2)")
|
|
239
|
+
.option("--json", "Output as JSON")
|
|
240
|
+
.action((options) => {
|
|
241
|
+
const types = Object.values(CHART_TYPE);
|
|
242
|
+
if (options.json) {
|
|
243
|
+
console.log(JSON.stringify(types, null, 2));
|
|
244
|
+
} else {
|
|
245
|
+
logger.log(chalk.bold("Chart Types:"));
|
|
246
|
+
for (const t of types) logger.log(` ${chalk.cyan(t)}`);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// bi anomaly-methods
|
|
251
|
+
bi.command("anomaly-methods")
|
|
252
|
+
.description("List supported anomaly detection methods (V2)")
|
|
253
|
+
.option("--json", "Output as JSON")
|
|
254
|
+
.action((options) => {
|
|
255
|
+
const methods = Object.values(ANOMALY_METHOD);
|
|
256
|
+
if (options.json) {
|
|
257
|
+
console.log(JSON.stringify(methods, null, 2));
|
|
258
|
+
} else {
|
|
259
|
+
logger.log(chalk.bold("Anomaly Methods:"));
|
|
260
|
+
for (const m of methods) logger.log(` ${chalk.cyan(m)}`);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// bi report-formats
|
|
265
|
+
bi.command("report-formats")
|
|
266
|
+
.description("List supported report formats (V2)")
|
|
267
|
+
.option("--json", "Output as JSON")
|
|
268
|
+
.action((options) => {
|
|
269
|
+
const formats = Object.values(REPORT_FORMAT);
|
|
270
|
+
if (options.json) {
|
|
271
|
+
console.log(JSON.stringify(formats, null, 2));
|
|
272
|
+
} else {
|
|
273
|
+
logger.log(chalk.bold("Report Formats:"));
|
|
274
|
+
for (const f of formats) logger.log(` ${chalk.cyan(f)}`);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// bi report-statuses
|
|
279
|
+
bi.command("report-statuses")
|
|
280
|
+
.description("List canonical report statuses (V2)")
|
|
281
|
+
.option("--json", "Output as JSON")
|
|
282
|
+
.action((options) => {
|
|
283
|
+
const statuses = Object.values(REPORT_STATUS);
|
|
284
|
+
if (options.json) {
|
|
285
|
+
console.log(JSON.stringify(statuses, null, 2));
|
|
286
|
+
} else {
|
|
287
|
+
logger.log(chalk.bold("Report Statuses:"));
|
|
288
|
+
for (const s of statuses) logger.log(` ${chalk.cyan(s)}`);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// bi dashboard-layouts
|
|
293
|
+
bi.command("dashboard-layouts")
|
|
294
|
+
.description("List supported dashboard layouts (V2)")
|
|
295
|
+
.option("--json", "Output as JSON")
|
|
296
|
+
.action((options) => {
|
|
297
|
+
const layouts = Object.values(DASHBOARD_LAYOUT);
|
|
298
|
+
if (options.json) {
|
|
299
|
+
console.log(JSON.stringify(layouts, null, 2));
|
|
300
|
+
} else {
|
|
301
|
+
logger.log(chalk.bold("Dashboard Layouts:"));
|
|
302
|
+
for (const l of layouts) logger.log(` ${chalk.cyan(l)}`);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// bi query-v2 <question>
|
|
307
|
+
bi.command("query-v2 <question>")
|
|
308
|
+
.description("Heuristic NL→SQL with intent detection (V2)")
|
|
309
|
+
.option("--schema <json>", "Schema hint as JSON, e.g. '{\"tables\":[...]}'")
|
|
310
|
+
.option("--json", "Output as JSON")
|
|
311
|
+
.action((question, options) => {
|
|
312
|
+
try {
|
|
313
|
+
const schema = options.schema ? JSON.parse(options.schema) : undefined;
|
|
314
|
+
const result = nlQueryV2({ query: question, schema });
|
|
315
|
+
if (options.json) {
|
|
316
|
+
console.log(JSON.stringify(result, null, 2));
|
|
317
|
+
} else {
|
|
318
|
+
logger.success(`Intent: ${chalk.cyan(result.intent)}`);
|
|
319
|
+
logger.log(` ${chalk.bold("SQL:")} ${result.sql}`);
|
|
320
|
+
logger.log(` ${chalk.bold("Table:")} ${result.table}`);
|
|
321
|
+
logger.log(` ${chalk.bold("Visual:")} ${result.visualization}`);
|
|
322
|
+
if (result.aggregate)
|
|
323
|
+
logger.log(` ${chalk.bold("Agg:")} ${result.aggregate}`);
|
|
324
|
+
if (result.limit !== null)
|
|
325
|
+
logger.log(` ${chalk.bold("Limit:")} ${result.limit}`);
|
|
326
|
+
}
|
|
327
|
+
} catch (err) {
|
|
328
|
+
logger.error(`Failed: ${err.message}`);
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
// bi anomaly-v2
|
|
334
|
+
bi.command("anomaly-v2")
|
|
335
|
+
.description("Anomaly detection with method choice (V2)")
|
|
336
|
+
.option("--data <json>", "Data as JSON array of numbers")
|
|
337
|
+
.option("--method <m>", "Method: z_score|iqr", "z_score")
|
|
338
|
+
.option("--threshold <n>", "Threshold (z_score σ or iqr multiplier)")
|
|
339
|
+
.option("--json", "Output as JSON")
|
|
340
|
+
.action((options) => {
|
|
341
|
+
try {
|
|
342
|
+
const data = options.data ? JSON.parse(options.data) : [];
|
|
343
|
+
const threshold =
|
|
344
|
+
options.threshold !== undefined
|
|
345
|
+
? parseFloat(options.threshold)
|
|
346
|
+
: undefined;
|
|
347
|
+
const result = detectAnomalyV2({
|
|
348
|
+
data,
|
|
349
|
+
method: options.method,
|
|
350
|
+
threshold,
|
|
351
|
+
});
|
|
352
|
+
if (options.json) {
|
|
353
|
+
console.log(JSON.stringify(result, null, 2));
|
|
354
|
+
} else {
|
|
355
|
+
logger.log(chalk.bold(`Method: ${result.method}`));
|
|
356
|
+
logger.log(` ${chalk.bold("Threshold:")} ${result.threshold}`);
|
|
357
|
+
if (result.method === "iqr") {
|
|
358
|
+
logger.log(
|
|
359
|
+
` ${chalk.bold("Q1/Q3/IQR:")} ${result.q1} / ${result.q3} / ${result.iqr}`,
|
|
360
|
+
);
|
|
361
|
+
logger.log(
|
|
362
|
+
` ${chalk.bold("Bounds:")} [${result.lowerBound}, ${result.upperBound}]`,
|
|
363
|
+
);
|
|
364
|
+
} else {
|
|
365
|
+
logger.log(` ${chalk.bold("Mean:")} ${result.mean}`);
|
|
366
|
+
logger.log(` ${chalk.bold("Std:")} ${result.std}`);
|
|
367
|
+
}
|
|
368
|
+
logger.log(
|
|
369
|
+
` ${chalk.bold("Anomalies:")} ${result.anomalies.length}`,
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
} catch (err) {
|
|
373
|
+
logger.error(`Failed: ${err.message}`);
|
|
374
|
+
process.exit(1);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// bi predict-v2
|
|
379
|
+
bi.command("predict-v2")
|
|
380
|
+
.description("Trend prediction with r² confidence (V2)")
|
|
381
|
+
.option("--data <json>", "Data as JSON array of numbers")
|
|
382
|
+
.option("--periods <n>", "Number of periods to predict", "3")
|
|
383
|
+
.option("--json", "Output as JSON")
|
|
384
|
+
.action((options) => {
|
|
385
|
+
try {
|
|
386
|
+
const data = options.data ? JSON.parse(options.data) : [];
|
|
387
|
+
const result = predictTrendV2({
|
|
388
|
+
data,
|
|
389
|
+
periods: parseInt(options.periods, 10),
|
|
390
|
+
});
|
|
391
|
+
if (options.json) {
|
|
392
|
+
console.log(JSON.stringify(result, null, 2));
|
|
393
|
+
} else {
|
|
394
|
+
logger.log(chalk.bold(`Trend: ${chalk.cyan(result.trend)}`));
|
|
395
|
+
logger.log(` ${chalk.bold("Slope:")} ${result.slope}`);
|
|
396
|
+
logger.log(
|
|
397
|
+
` ${chalk.bold("R²:")} ${result.r2} (${result.confidence})`,
|
|
398
|
+
);
|
|
399
|
+
logger.log(
|
|
400
|
+
` ${chalk.bold("Predictions:")} ${result.predictions.join(", ")}`,
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
} catch (err) {
|
|
404
|
+
logger.error(`Failed: ${err.message}`);
|
|
405
|
+
process.exit(1);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// bi recommend-chart
|
|
410
|
+
bi.command("recommend-chart")
|
|
411
|
+
.description("Recommend chart type from intent or data shape (V2)")
|
|
412
|
+
.option("--intent <text>", "User intent description")
|
|
413
|
+
.option("--shape <json>", "Data shape hint as JSON")
|
|
414
|
+
.option("--json", "Output as JSON")
|
|
415
|
+
.action((options) => {
|
|
416
|
+
try {
|
|
417
|
+
const shape = options.shape ? JSON.parse(options.shape) : undefined;
|
|
418
|
+
const chart = recommendChart({
|
|
419
|
+
intent: options.intent,
|
|
420
|
+
dataShape: shape,
|
|
421
|
+
});
|
|
422
|
+
if (options.json) {
|
|
423
|
+
console.log(JSON.stringify({ chart }, null, 2));
|
|
424
|
+
} else {
|
|
425
|
+
logger.log(`Recommended chart: ${chalk.cyan(chart)}`);
|
|
426
|
+
}
|
|
427
|
+
} catch (err) {
|
|
428
|
+
logger.error(`Failed: ${err.message}`);
|
|
429
|
+
process.exit(1);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
// bi dashboard-v2 <name>
|
|
434
|
+
bi.command("dashboard-v2 <name>")
|
|
435
|
+
.description("Create dashboard with validated layout (V2)")
|
|
436
|
+
.option("--widgets <json>", "Widgets as JSON array", "[]")
|
|
437
|
+
.option("--layout <spec>", "Layout: grid|flow|tabs OR JSON object")
|
|
438
|
+
.option("--json", "Output as JSON")
|
|
439
|
+
.action(async (name, options) => {
|
|
440
|
+
try {
|
|
441
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
442
|
+
if (!ctx.db) {
|
|
443
|
+
logger.error("Database not available");
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
446
|
+
const db = ctx.db.getDatabase();
|
|
447
|
+
ensureBITables(db);
|
|
448
|
+
|
|
449
|
+
const widgets = JSON.parse(options.widgets);
|
|
450
|
+
let layout;
|
|
451
|
+
if (options.layout) {
|
|
452
|
+
try {
|
|
453
|
+
layout = JSON.parse(options.layout);
|
|
454
|
+
} catch (_err) {
|
|
455
|
+
layout = options.layout;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
const dashboard = createDashboardV2(db, { name, widgets, layout });
|
|
459
|
+
if (options.json) {
|
|
460
|
+
console.log(JSON.stringify(dashboard, null, 2));
|
|
461
|
+
} else {
|
|
462
|
+
logger.success(`Dashboard created: ${chalk.cyan(name)}`);
|
|
463
|
+
logger.log(` ${chalk.bold("ID:")} ${dashboard.id}`);
|
|
464
|
+
logger.log(` ${chalk.bold("Layout:")} ${dashboard.layout.type}`);
|
|
465
|
+
}
|
|
466
|
+
await shutdown();
|
|
467
|
+
} catch (err) {
|
|
468
|
+
logger.error(`Failed: ${err.message}`);
|
|
469
|
+
process.exit(1);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// bi set-report-status <report-id> <status>
|
|
474
|
+
bi.command("set-report-status <report-id> <status>")
|
|
475
|
+
.description("Update report status with validated transition (V2)")
|
|
476
|
+
.option("--json", "Output as JSON")
|
|
477
|
+
.action(async (reportId, status, options) => {
|
|
478
|
+
try {
|
|
479
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
480
|
+
if (!ctx.db) {
|
|
481
|
+
logger.error("Database not available");
|
|
482
|
+
process.exit(1);
|
|
483
|
+
}
|
|
484
|
+
const db = ctx.db.getDatabase();
|
|
485
|
+
ensureBITables(db);
|
|
486
|
+
|
|
487
|
+
const result = updateReportStatus(db, { reportId, status });
|
|
488
|
+
if (options.json) {
|
|
489
|
+
console.log(JSON.stringify(result, null, 2));
|
|
490
|
+
} else {
|
|
491
|
+
logger.success(
|
|
492
|
+
`${chalk.cyan(reportId)}: ${result.previous} → ${chalk.bold(result.status)}`,
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
await shutdown();
|
|
496
|
+
} catch (err) {
|
|
497
|
+
logger.error(`Failed: ${err.message}`);
|
|
498
|
+
process.exit(1);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// bi report-status <report-id>
|
|
503
|
+
bi.command("report-status <report-id>")
|
|
504
|
+
.description("Show current report status (V2)")
|
|
505
|
+
.option("--json", "Output as JSON")
|
|
506
|
+
.action((reportId, options) => {
|
|
507
|
+
const status = getReportStatus(reportId);
|
|
508
|
+
if (options.json) {
|
|
509
|
+
console.log(JSON.stringify({ reportId, status }, null, 2));
|
|
510
|
+
} else {
|
|
511
|
+
logger.log(`${chalk.cyan(reportId)}: ${chalk.bold(status)}`);
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// bi report-history <report-id>
|
|
516
|
+
bi.command("report-history <report-id>")
|
|
517
|
+
.description("Show report status transition history (V2)")
|
|
518
|
+
.option("--json", "Output as JSON")
|
|
519
|
+
.action((reportId, options) => {
|
|
520
|
+
const hist = getReportStatusHistory(reportId);
|
|
521
|
+
if (options.json) {
|
|
522
|
+
console.log(JSON.stringify(hist, null, 2));
|
|
523
|
+
} else if (hist.length === 0) {
|
|
524
|
+
logger.info("No transitions recorded");
|
|
525
|
+
} else {
|
|
526
|
+
logger.log(chalk.bold(`History (${hist.length}):`));
|
|
527
|
+
for (const h of hist) {
|
|
528
|
+
logger.log(` ${chalk.gray(h.at)} ${h.from} → ${chalk.cyan(h.to)}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// bi stats-v2
|
|
534
|
+
bi.command("stats-v2")
|
|
535
|
+
.description("BI platform statistics (V2)")
|
|
536
|
+
.option("--json", "Output as JSON")
|
|
537
|
+
.action(async (options) => {
|
|
538
|
+
try {
|
|
539
|
+
const ctx = await bootstrap({ verbose: program.opts().verbose });
|
|
540
|
+
if (!ctx.db) {
|
|
541
|
+
logger.error("Database not available");
|
|
542
|
+
process.exit(1);
|
|
543
|
+
}
|
|
544
|
+
const db = ctx.db.getDatabase();
|
|
545
|
+
ensureBITables(db);
|
|
546
|
+
|
|
547
|
+
const stats = getBIStatsV2(db);
|
|
548
|
+
if (options.json) {
|
|
549
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
550
|
+
} else {
|
|
551
|
+
logger.log(chalk.bold("BI Stats (V2):"));
|
|
552
|
+
logger.log(` Dashboards: ${stats.dashboards}`);
|
|
553
|
+
logger.log(
|
|
554
|
+
` Reports: ${stats.reports.total} byStatus=${JSON.stringify(stats.reports.byStatus)}`,
|
|
555
|
+
);
|
|
556
|
+
logger.log(` Scheduled: ${stats.scheduled}`);
|
|
557
|
+
logger.log(` Templates: ${stats.templates}`);
|
|
558
|
+
logger.log(` Chart types: ${stats.chartTypes}`);
|
|
559
|
+
}
|
|
560
|
+
await shutdown();
|
|
561
|
+
} catch (err) {
|
|
562
|
+
logger.error(`Failed: ${err.message}`);
|
|
563
|
+
process.exit(1);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
|
|
219
567
|
// bi templates
|
|
220
568
|
bi.command("templates")
|
|
221
569
|
.description("List available BI templates")
|
package/src/commands/codegen.js
CHANGED
|
@@ -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
|
}
|