@ai-setting/roy-agent-cli 1.7.34 → 1.7.35

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.
@@ -9461,7 +9461,7 @@ class CliQuietModeService {
9461
9461
  // package.json
9462
9462
  var package_default = {
9463
9463
  name: "@ai-setting/roy-agent-cli",
9464
- version: "1.7.34",
9464
+ version: "1.7.35",
9465
9465
  type: "module",
9466
9466
  description: "CLI for roy-agent - Non-interactive command execution",
9467
9467
  main: "./dist/index.js",
@@ -22229,26 +22229,54 @@ import * as os2 from "os";
22229
22229
  import { SQLiteSpanStorage } from "@ai-setting/roy-agent-core";
22230
22230
  var TraceCommand = {
22231
22231
  command: "trace",
22232
- describe: "以 tree 方式查看 trace 的 spans",
22232
+ describe: "以 tree 方式查看 trace 的 spans,或用 --list 列出最近的 trace",
22233
22233
  builder: (yargs) => yargs.positional("traceId", {
22234
22234
  type: "string",
22235
- describe: "Trace ID",
22236
- demandOption: true
22235
+ describe: "Trace ID(--list 时可省略)"
22236
+ }).option("list", {
22237
+ type: "boolean",
22238
+ default: false,
22239
+ describe: "列出最近的 trace"
22240
+ }).option("limit", {
22241
+ alias: "n",
22242
+ type: "number",
22243
+ default: 20,
22244
+ describe: "配合 --list 使用,返回最近 N 条 trace"
22245
+ }).option("json", {
22246
+ alias: "j",
22247
+ type: "boolean",
22248
+ default: false,
22249
+ describe: "以 JSON 输出(配合 --list)"
22237
22250
  }).option("db", {
22238
22251
  type: "string",
22239
22252
  describe: "SQLite 数据库路径(可选,默认使用配置路径)"
22240
22253
  }),
22241
22254
  async handler(args) {
22242
22255
  const traceId = args._[2] || args.traceId;
22243
- if (!traceId) {
22244
- console.error("Error: traceId is required");
22256
+ if (!args.list && !traceId) {
22257
+ console.error("Error: traceId is required (or use --list)");
22245
22258
  console.error("Usage: roy debug trace <traceId>");
22259
+ console.error(" roy debug trace --list [--limit N]");
22246
22260
  process.exit(1);
22247
22261
  }
22248
22262
  const dbPath = args.db || getDefaultSpanDbPath();
22249
22263
  const storage = new SQLiteSpanStorage(dbPath);
22250
22264
  await storage.initialize();
22251
22265
  try {
22266
+ if (args.list) {
22267
+ const limit = args.limit ?? 20;
22268
+ const traces = storage.listTraces(limit);
22269
+ if (args.json) {
22270
+ console.log(JSON.stringify({
22271
+ count: traces.length,
22272
+ limit,
22273
+ traces
22274
+ }, null, 2));
22275
+ } else {
22276
+ console.log(formatTraceList(traces));
22277
+ }
22278
+ return;
22279
+ }
22252
22280
  const spans = storage.findByTraceId(traceId);
22253
22281
  if (spans.length === 0) {
22254
22282
  console.log(`Trace ${traceId} not found.`);
@@ -22264,6 +22292,28 @@ var TraceCommand = {
22264
22292
  }
22265
22293
  }
22266
22294
  };
22295
+ function formatTraceList(traces) {
22296
+ if (traces.length === 0) {
22297
+ return "(no traces)";
22298
+ }
22299
+ const header = ["#", "TRACE ID", "ROOT", "STARTED", "DURATION", "SPANS", "STATUS"].join(" │ ");
22300
+ const rows = traces.map((t, i) => {
22301
+ const started = new Date(t.startTime).toLocaleString();
22302
+ const duration = t.duration !== undefined ? `${t.duration}ms` : "(running)";
22303
+ const root = t.rootSpanName.length > 24 ? t.rootSpanName.slice(0, 21) + "..." : t.rootSpanName;
22304
+ return [
22305
+ (i + 1).toString(),
22306
+ t.traceId,
22307
+ root,
22308
+ started,
22309
+ duration,
22310
+ t.spanCount.toString(),
22311
+ t.status
22312
+ ].join(" │ ");
22313
+ });
22314
+ return [header, ...rows, "", `Showing ${traces.length} traces`].join(`
22315
+ `);
22316
+ }
22267
22317
  function getDefaultSpanDbPath() {
22268
22318
  if (process.env.LOG_TRACE_TRACING_DB_PATH) {
22269
22319
  return process.env.LOG_TRACE_TRACING_DB_PATH;
package/dist/index.js CHANGED
@@ -9460,7 +9460,7 @@ class CliQuietModeService {
9460
9460
  // package.json
9461
9461
  var package_default = {
9462
9462
  name: "@ai-setting/roy-agent-cli",
9463
- version: "1.7.34",
9463
+ version: "1.7.35",
9464
9464
  type: "module",
9465
9465
  description: "CLI for roy-agent - Non-interactive command execution",
9466
9466
  main: "./dist/index.js",
@@ -22228,26 +22228,54 @@ import * as os2 from "os";
22228
22228
  import { SQLiteSpanStorage } from "@ai-setting/roy-agent-core";
22229
22229
  var TraceCommand = {
22230
22230
  command: "trace",
22231
- describe: "以 tree 方式查看 trace 的 spans",
22231
+ describe: "以 tree 方式查看 trace 的 spans,或用 --list 列出最近的 trace",
22232
22232
  builder: (yargs) => yargs.positional("traceId", {
22233
22233
  type: "string",
22234
- describe: "Trace ID",
22235
- demandOption: true
22234
+ describe: "Trace ID(--list 时可省略)"
22235
+ }).option("list", {
22236
+ type: "boolean",
22237
+ default: false,
22238
+ describe: "列出最近的 trace"
22239
+ }).option("limit", {
22240
+ alias: "n",
22241
+ type: "number",
22242
+ default: 20,
22243
+ describe: "配合 --list 使用,返回最近 N 条 trace"
22244
+ }).option("json", {
22245
+ alias: "j",
22246
+ type: "boolean",
22247
+ default: false,
22248
+ describe: "以 JSON 输出(配合 --list)"
22236
22249
  }).option("db", {
22237
22250
  type: "string",
22238
22251
  describe: "SQLite 数据库路径(可选,默认使用配置路径)"
22239
22252
  }),
22240
22253
  async handler(args) {
22241
22254
  const traceId = args._[2] || args.traceId;
22242
- if (!traceId) {
22243
- console.error("Error: traceId is required");
22255
+ if (!args.list && !traceId) {
22256
+ console.error("Error: traceId is required (or use --list)");
22244
22257
  console.error("Usage: roy debug trace <traceId>");
22258
+ console.error(" roy debug trace --list [--limit N]");
22245
22259
  process.exit(1);
22246
22260
  }
22247
22261
  const dbPath = args.db || getDefaultSpanDbPath();
22248
22262
  const storage = new SQLiteSpanStorage(dbPath);
22249
22263
  await storage.initialize();
22250
22264
  try {
22265
+ if (args.list) {
22266
+ const limit = args.limit ?? 20;
22267
+ const traces = storage.listTraces(limit);
22268
+ if (args.json) {
22269
+ console.log(JSON.stringify({
22270
+ count: traces.length,
22271
+ limit,
22272
+ traces
22273
+ }, null, 2));
22274
+ } else {
22275
+ console.log(formatTraceList(traces));
22276
+ }
22277
+ return;
22278
+ }
22251
22279
  const spans = storage.findByTraceId(traceId);
22252
22280
  if (spans.length === 0) {
22253
22281
  console.log(`Trace ${traceId} not found.`);
@@ -22263,6 +22291,28 @@ var TraceCommand = {
22263
22291
  }
22264
22292
  }
22265
22293
  };
22294
+ function formatTraceList(traces) {
22295
+ if (traces.length === 0) {
22296
+ return "(no traces)";
22297
+ }
22298
+ const header = ["#", "TRACE ID", "ROOT", "STARTED", "DURATION", "SPANS", "STATUS"].join(" │ ");
22299
+ const rows = traces.map((t, i) => {
22300
+ const started = new Date(t.startTime).toLocaleString();
22301
+ const duration = t.duration !== undefined ? `${t.duration}ms` : "(running)";
22302
+ const root = t.rootSpanName.length > 24 ? t.rootSpanName.slice(0, 21) + "..." : t.rootSpanName;
22303
+ return [
22304
+ (i + 1).toString(),
22305
+ t.traceId,
22306
+ root,
22307
+ started,
22308
+ duration,
22309
+ t.spanCount.toString(),
22310
+ t.status
22311
+ ].join(" │ ");
22312
+ });
22313
+ return [header, ...rows, "", `Showing ${traces.length} traces`].join(`
22314
+ `);
22315
+ }
22266
22316
  function getDefaultSpanDbPath() {
22267
22317
  if (process.env.LOG_TRACE_TRACING_DB_PATH) {
22268
22318
  return process.env.LOG_TRACE_TRACING_DB_PATH;
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/roy-agent-linux-x64/bin/roy-agent
3
- size: 109566080 bytes
4
- sha256: 250b0cf87521b485bac22da2261bd167f5aa33b658f4ae0a84d3ce7975fce72b
3
+ size: 109570176 bytes
4
+ sha256: 2f11e708ea2db8cc9df6f97cab346d49f8d6dd811fe8bd294898f693fb31451b
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-cli",
3
- "version": "1.7.34",
3
+ "version": "1.7.35",
4
4
  "type": "module",
5
5
  "description": "CLI for roy-agent - Non-interactive command execution",
6
6
  "main": "./dist/index.js",