@rudderhq/cli 0.3.5-canary.21 → 0.3.5-canary.23

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/dist/index.js CHANGED
@@ -2850,9 +2850,16 @@ var init_validators = __esm({
2850
2850
  });
2851
2851
 
2852
2852
  // ../packages/shared/dist/agent-url-key.js
2853
+ function isUuidLike(value) {
2854
+ if (typeof value !== "string")
2855
+ return false;
2856
+ return UUID_RE.test(value.trim());
2857
+ }
2858
+ var UUID_RE;
2853
2859
  var init_agent_url_key = __esm({
2854
2860
  "../packages/shared/dist/agent-url-key.js"() {
2855
2861
  "use strict";
2862
+ UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2856
2863
  }
2857
2864
  });
2858
2865
 
@@ -6308,6 +6315,7 @@ async function addAllowedHostname(host, opts) {
6308
6315
  init_auth_bootstrap_ceo();
6309
6316
 
6310
6317
  // src/commands/client/common.ts
6318
+ init_dist();
6311
6319
  import pc4 from "picocolors";
6312
6320
 
6313
6321
  // src/client/board-auth.ts
@@ -6811,8 +6819,11 @@ function toStringRecord(headers) {
6811
6819
 
6812
6820
  // src/commands/client/common.ts
6813
6821
  init_store();
6822
+ var currentCommandFullIds = false;
6823
+ var CLI_SHORT_UUID_LENGTH = 12;
6824
+ var UUID_SUBSTRING_RE = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/giu;
6814
6825
  function addCommonClientOptions(command, opts) {
6815
- command.option("-c, --config <path>", "Path to Rudder config file").option("-d, --data-dir <path>", "Rudder data directory root (isolates state from ~/.rudder)").option("--context <path>", "Path to CLI context file").option("--profile <name>", "CLI context profile name").option("--api-base <url>", "Base URL for the Rudder API").option("--api-key <token>", "Bearer token for agent-authenticated calls").option("--run-id <id>", "Run ID to attach on mutating agent requests").option("--json", "Output raw JSON");
6826
+ command.option("-c, --config <path>", "Path to Rudder config file").option("-d, --data-dir <path>", "Rudder data directory root (isolates state from ~/.rudder)").option("--context <path>", "Path to CLI context file").option("--profile <name>", "CLI context profile name").option("--api-base <url>", "Base URL for the Rudder API").option("--api-key <token>", "Bearer token for agent-authenticated calls").option("--run-id <id>", "Run ID to attach on mutating agent requests").option("--json", "Output JSON").option("--full-ids", "Show full UUIDs in output instead of CLI short IDs");
6816
6827
  if (opts?.includeCompany) {
6817
6828
  command.option("-O, --org-id <id>", "Organization ID (overrides context default)");
6818
6829
  }
@@ -6833,6 +6844,8 @@ function resolveCommandContext(options, opts) {
6833
6844
  "Organization ID is required. Pass --org-id, set RUDDER_ORG_ID, or set context profile orgId via `rudder context set`."
6834
6845
  );
6835
6846
  }
6847
+ const fullIds = Boolean(options.fullIds);
6848
+ currentCommandFullIds = fullIds;
6836
6849
  const api = new RudderApiClient({
6837
6850
  apiBase,
6838
6851
  apiKey,
@@ -6859,7 +6872,8 @@ function resolveCommandContext(options, opts) {
6859
6872
  runId,
6860
6873
  profileName,
6861
6874
  profile,
6862
- json: Boolean(options.json)
6875
+ json: Boolean(options.json),
6876
+ fullIds
6863
6877
  };
6864
6878
  }
6865
6879
  function shouldRecoverBoardAuth(error) {
@@ -6871,54 +6885,149 @@ function canAttemptInteractiveBoardAuth() {
6871
6885
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
6872
6886
  }
6873
6887
  function printOutput(data, opts = {}) {
6888
+ const outputData = shouldShowFullIds(opts.fullIds) ? data : toCliShortIdOutput(data);
6874
6889
  if (opts.json) {
6875
- const output = JSON.stringify(data, null, 2);
6890
+ const output = JSON.stringify(outputData, null, 2);
6876
6891
  process.stdout.write(output + "\n");
6877
6892
  return;
6878
6893
  }
6879
6894
  if (opts.label) {
6880
6895
  console.log(pc4.bold(opts.label));
6881
6896
  }
6882
- if (Array.isArray(data)) {
6883
- if (data.length === 0) {
6897
+ if (Array.isArray(outputData)) {
6898
+ if (outputData.length === 0) {
6884
6899
  console.log(pc4.dim("(empty)"));
6885
6900
  return;
6886
6901
  }
6887
- for (const item of data) {
6902
+ for (const item of outputData) {
6888
6903
  if (typeof item === "object" && item !== null) {
6889
- console.log(formatInlineRecord(item));
6904
+ console.log(formatInlineRecord(item, { fullIds: true }));
6890
6905
  } else {
6891
6906
  console.log(String(item));
6892
6907
  }
6893
6908
  }
6894
6909
  return;
6895
6910
  }
6896
- if (typeof data === "object" && data !== null) {
6897
- console.log(JSON.stringify(data, null, 2));
6911
+ if (typeof outputData === "object" && outputData !== null) {
6912
+ console.log(JSON.stringify(outputData, null, 2));
6898
6913
  return;
6899
6914
  }
6900
- if (data === void 0 || data === null) {
6915
+ if (outputData === void 0 || outputData === null) {
6901
6916
  console.log(pc4.dim("(null)"));
6902
6917
  return;
6903
6918
  }
6904
- console.log(String(data));
6919
+ console.log(String(outputData));
6905
6920
  }
6906
- function formatInlineRecord(record) {
6921
+ function formatInlineRecord(record, opts = {}) {
6922
+ const displayRecord = shouldShowFullIds(opts.fullIds) ? record : toCliShortIdOutput(record);
6907
6923
  const keyOrder = ["identifier", "id", "name", "status", "priority", "title", "action"];
6908
6924
  const seen = /* @__PURE__ */ new Set();
6909
6925
  const parts = [];
6910
6926
  for (const key of keyOrder) {
6911
- if (!(key in record)) continue;
6912
- parts.push(`${key}=${renderValue(record[key])}`);
6927
+ if (!(key in displayRecord)) continue;
6928
+ parts.push(`${key}=${renderValue(displayRecord[key])}`);
6913
6929
  seen.add(key);
6914
6930
  }
6915
- for (const [key, value] of Object.entries(record)) {
6931
+ for (const [key, value] of Object.entries(displayRecord)) {
6916
6932
  if (seen.has(key)) continue;
6917
6933
  if (typeof value === "object") continue;
6918
6934
  parts.push(`${key}=${renderValue(value)}`);
6919
6935
  }
6920
6936
  return parts.join(" ");
6921
6937
  }
6938
+ function toCliShortIdOutput(value) {
6939
+ if (Array.isArray(value)) {
6940
+ return value.map((item) => toCliShortIdOutput(item));
6941
+ }
6942
+ if (typeof value !== "object" || value === null) {
6943
+ return value;
6944
+ }
6945
+ const source = value;
6946
+ const output = {};
6947
+ for (const [key, childValue] of Object.entries(source)) {
6948
+ output[key] = shortenCliValueForKey(key, childValue, source);
6949
+ }
6950
+ return output;
6951
+ }
6952
+ function formatCliRunId(runId) {
6953
+ return isUuidLike(runId) ? shortUuid(runId) : runId;
6954
+ }
6955
+ function shortenCliValueForKey(key, value, parent) {
6956
+ if (typeof value === "string" && isCliIdKey(key) && isUuidLike(value)) {
6957
+ return displayIdForCli(key, value, parent);
6958
+ }
6959
+ if (typeof value === "string" && isCliReferenceStringKey(key)) {
6960
+ return value.replace(UUID_SUBSTRING_RE, (uuid) => shortUuid(uuid));
6961
+ }
6962
+ if (Array.isArray(value) && isCliIdListKey(key)) {
6963
+ return value.map(
6964
+ (item) => typeof item === "string" && isUuidLike(item) ? displayIdForCli(singularizeIdListKey(key), item, parent) : toCliShortIdOutput(item)
6965
+ );
6966
+ }
6967
+ return toCliShortIdOutput(value);
6968
+ }
6969
+ function displayIdForCli(key, uuid, parent) {
6970
+ if (key === "id") {
6971
+ const directShortRef = readString(parent.shortRef);
6972
+ if (directShortRef) return directShortRef;
6973
+ const issueIdentifier = readDirectIssueIdentifier(parent);
6974
+ if (issueIdentifier) return issueIdentifier;
6975
+ }
6976
+ if (isAgentIdKey(key, parent)) {
6977
+ return formatTypedShortRef("agent", uuid);
6978
+ }
6979
+ if (isIssueCommentIdKey(key)) {
6980
+ return formatTypedShortRef("issue_comment", uuid);
6981
+ }
6982
+ if (key === "entityId" && parent.entityType === "issue") {
6983
+ return readIssueIdentifier(parent) ?? shortUuid(uuid);
6984
+ }
6985
+ return shortUuid(uuid);
6986
+ }
6987
+ function shouldShowFullIds(explicit) {
6988
+ return Boolean((explicit ?? currentCommandFullIds) || process.argv.includes("--full-ids"));
6989
+ }
6990
+ function isCliIdKey(key) {
6991
+ return key === "id" || key.endsWith("Id");
6992
+ }
6993
+ function isCliIdListKey(key) {
6994
+ return key.endsWith("Ids");
6995
+ }
6996
+ function isCliReferenceStringKey(key) {
6997
+ const lowerKey = key.toLowerCase();
6998
+ return lowerKey.endsWith("ref") || lowerKey.endsWith("path");
6999
+ }
7000
+ function singularizeIdListKey(key) {
7001
+ return `${key.slice(0, -3)}Id`;
7002
+ }
7003
+ function isAgentIdKey(key, parent) {
7004
+ const lowerKey = key.toLowerCase();
7005
+ return lowerKey.includes("agentid") || key === "actorId" && parent.actorType === "agent";
7006
+ }
7007
+ function isIssueCommentIdKey(key) {
7008
+ return key.toLowerCase().includes("commentid");
7009
+ }
7010
+ function formatTypedShortRef(kind, uuid) {
7011
+ const prefix = kind === "agent" ? "agt" : "cmt";
7012
+ return `${prefix}_${shortUuid(uuid)}`;
7013
+ }
7014
+ function shortUuid(uuid) {
7015
+ return uuid.replace(/-/g, "").slice(0, CLI_SHORT_UUID_LENGTH).toLowerCase();
7016
+ }
7017
+ function readIssueIdentifier(parent) {
7018
+ const direct = readDirectIssueIdentifier(parent);
7019
+ if (direct) return direct;
7020
+ const details = parent.details;
7021
+ if (typeof details !== "object" || details === null) return null;
7022
+ const detailsRecord = details;
7023
+ return readString(detailsRecord.identifier) ?? readString(detailsRecord.issueIdentifier);
7024
+ }
7025
+ function readDirectIssueIdentifier(parent) {
7026
+ return readString(parent.identifier) ?? readString(parent.issueIdentifier);
7027
+ }
7028
+ function readString(value) {
7029
+ return typeof value === "string" && value.trim().length > 0 ? value : null;
7030
+ }
6922
7031
  function renderValue(value) {
6923
7032
  if (value === null || value === void 0) return "-";
6924
7033
  if (typeof value === "string") {
@@ -9507,15 +9616,16 @@ function formatChatSearchResult(row, maxChars) {
9507
9616
  };
9508
9617
  }
9509
9618
  function formatChatMessage(row, maxOutputChars = 1200) {
9619
+ const runId = row.runId ? formatCliRunId(row.runId) : null;
9510
9620
  return {
9511
9621
  id: row.id,
9512
9622
  role: row.role,
9513
9623
  kind: row.kind,
9514
9624
  status: row.status,
9515
- ...row.runId ? {
9516
- runId: row.runId,
9517
- runCommand: `rudder runs get ${row.runId}`,
9518
- transcriptCommand: `rudder runs transcript ${row.runId}`
9625
+ ...runId ? {
9626
+ runId,
9627
+ runCommand: `rudder runs get ${runId}`,
9628
+ transcriptCommand: `rudder runs transcript ${runId}`
9519
9629
  } : {},
9520
9630
  createdAt: row.createdAt,
9521
9631
  body: clip(row.body, 220),
@@ -9524,15 +9634,16 @@ function formatChatMessage(row, maxOutputChars = 1200) {
9524
9634
  };
9525
9635
  }
9526
9636
  function formatChatTranscriptMessage(row, maxChars) {
9637
+ const runId = row.runId ? formatCliRunId(row.runId) : null;
9527
9638
  const header = {
9528
9639
  id: row.id,
9529
9640
  role: row.role,
9530
9641
  kind: row.kind,
9531
9642
  status: row.status,
9532
- ...row.runId ? {
9533
- runId: row.runId,
9534
- runCommand: `rudder runs get ${row.runId}`,
9535
- transcriptCommand: `rudder runs transcript ${row.runId}`
9643
+ ...runId ? {
9644
+ runId,
9645
+ runCommand: `rudder runs get ${runId}`,
9646
+ transcriptCommand: `rudder runs transcript ${runId}`
9536
9647
  } : {},
9537
9648
  createdAt: row.createdAt,
9538
9649
  body: clip(row.body, 220)
@@ -11857,7 +11968,7 @@ function registerRunsCommands(program) {
11857
11968
  { includeCompany: false }
11858
11969
  );
11859
11970
  addCommonClientOptions(
11860
- runs.command("get").description(getAgentCliCapabilityById("runs.get").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
11971
+ runs.command("get").description(getAgentCliCapabilityById("runs.get").description).argument("<runId>", "Run ID or short run ID").action(async (runId, opts) => {
11861
11972
  try {
11862
11973
  const ctx = resolveCommandContext(opts);
11863
11974
  const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}`);
@@ -11868,7 +11979,7 @@ function registerRunsCommands(program) {
11868
11979
  })
11869
11980
  );
11870
11981
  addCommonClientOptions(
11871
- runs.command("events").description(getAgentCliCapabilityById("runs.events").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
11982
+ runs.command("events").description(getAgentCliCapabilityById("runs.events").description).argument("<runId>", "Run ID or short run ID").action(async (runId, opts) => {
11872
11983
  try {
11873
11984
  const ctx = resolveCommandContext(opts);
11874
11985
  const rows = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}/events`) ?? [];
@@ -11879,7 +11990,7 @@ function registerRunsCommands(program) {
11879
11990
  })
11880
11991
  );
11881
11992
  addCommonClientOptions(
11882
- runs.command("log").description(getAgentCliCapabilityById("runs.log").description).argument("<runId>", "Run ID").option("--max-chars <n>", "Maximum log characters for human output", "12000").action(async (runId, opts) => {
11993
+ runs.command("log").description(getAgentCliCapabilityById("runs.log").description).argument("<runId>", "Run ID or short run ID").option("--max-chars <n>", "Maximum log characters for human output", "12000").action(async (runId, opts) => {
11883
11994
  try {
11884
11995
  const ctx = resolveCommandContext(opts);
11885
11996
  const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}/log`);
@@ -11894,7 +12005,7 @@ function registerRunsCommands(program) {
11894
12005
  })
11895
12006
  );
11896
12007
  addCommonClientOptions(
11897
- runs.command("transcript").description(getAgentCliCapabilityById("runs.transcript").description).argument("<runId>", "Run ID").option("--errors-only", "Show only error transcript rows").option("--around-error <id>", "Show context around a run error id such as step-12").option("--context-turns <n>", "Turns around --around-error", "1").option("--cursor <cursor>", "Stable transcript cursor returned in page.nextCursor").option("--turn-limit <n>", "Maximum turns to return", "20").option("--chronological", "Show oldest-first instead of default newest-first").option("--narrative", "Use a narrative human layout").option("--max-chars <n>", "Maximum output characters per row", "1200").option("--max-output-chars <n>", "Alias for --max-chars").option("--include-output", "Include row output in compact human transcript rows").option("--include-outputs", "Alias for --include-output").action(async (runId, opts) => {
12008
+ runs.command("transcript").description(getAgentCliCapabilityById("runs.transcript").description).argument("<runId>", "Run ID or short run ID").option("--errors-only", "Show only error transcript rows").option("--around-error <id>", "Show context around a run error id such as step-12").option("--context-turns <n>", "Turns around --around-error", "1").option("--cursor <cursor>", "Stable transcript cursor returned in page.nextCursor").option("--turn-limit <n>", "Maximum turns to return", "20").option("--chronological", "Show oldest-first instead of default newest-first").option("--narrative", "Use a narrative human layout").option("--max-chars <n>", "Maximum output characters per row", "1200").option("--max-output-chars <n>", "Alias for --max-chars").option("--include-output", "Include row output in compact human transcript rows").option("--include-outputs", "Alias for --include-output").action(async (runId, opts) => {
11898
12009
  try {
11899
12010
  const ctx = resolveCommandContext(opts);
11900
12011
  const payload = await ctx.api.get(
@@ -11913,7 +12024,7 @@ function registerRunsCommands(program) {
11913
12024
  })
11914
12025
  );
11915
12026
  addCommonClientOptions(
11916
- runs.command("errors").description(getAgentCliCapabilityById("runs.errors").description).argument("<runId>", "Run ID").option("--max-chars <n>", "Maximum output characters per error", "1200").action(async (runId, opts) => {
12027
+ runs.command("errors").description(getAgentCliCapabilityById("runs.errors").description).argument("<runId>", "Run ID or short run ID").option("--max-chars <n>", "Maximum output characters per error", "1200").action(async (runId, opts) => {
11917
12028
  try {
11918
12029
  const ctx = resolveCommandContext(opts);
11919
12030
  const params = new URLSearchParams();
@@ -11928,7 +12039,7 @@ function registerRunsCommands(program) {
11928
12039
  })
11929
12040
  );
11930
12041
  addCommonClientOptions(
11931
- runs.command("cancel").description(getAgentCliCapabilityById("runs.cancel").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
12042
+ runs.command("cancel").description(getAgentCliCapabilityById("runs.cancel").description).argument("<runId>", "Run ID or short run ID").action(async (runId, opts) => {
11932
12043
  try {
11933
12044
  const ctx = resolveCommandContext(opts);
11934
12045
  const row = await ctx.api.post(`/api/heartbeat-runs/${encodeURIComponent(runId)}/cancel`, {});
@@ -11939,7 +12050,7 @@ function registerRunsCommands(program) {
11939
12050
  })
11940
12051
  );
11941
12052
  addCommonClientOptions(
11942
- runs.command("retry").description(getAgentCliCapabilityById("runs.retry").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
12053
+ runs.command("retry").description(getAgentCliCapabilityById("runs.retry").description).argument("<runId>", "Run ID or short run ID").action(async (runId, opts) => {
11943
12054
  try {
11944
12055
  const ctx = resolveCommandContext(opts);
11945
12056
  const row = await ctx.api.post(`/api/heartbeat-runs/${encodeURIComponent(runId)}/retry`, {});
@@ -12000,8 +12111,9 @@ function buildTranscriptQuery(opts, output) {
12000
12111
  return params.toString();
12001
12112
  }
12002
12113
  function formatRunListRow(row) {
12114
+ const runId = formatCliRunId(row.run.id);
12003
12115
  return {
12004
- id: row.run.id,
12116
+ id: runId,
12005
12117
  status: row.run.status,
12006
12118
  agent: row.agentName ?? row.run.agentId,
12007
12119
  runtime: row.bundle.agentRuntimeType,
@@ -12012,7 +12124,7 @@ function formatRunListRow(row) {
12012
12124
  skill: row.skillEvidence?.matchedSkillKey ?? "-",
12013
12125
  langfuse: readLangfuseTraceUrl(row.langfuse) ?? "-",
12014
12126
  error: row.errorSummary ?? "-",
12015
- next: row.run.status === "failed" ? `rudder runs errors ${row.run.id}` : `rudder runs transcript ${row.run.id}`
12127
+ next: row.run.status === "failed" ? `rudder runs errors ${runId}` : `rudder runs transcript ${runId}`
12016
12128
  };
12017
12129
  }
12018
12130
  function buildSkillRunReport(skill, evidenceType, rows) {
@@ -12058,7 +12170,10 @@ function buildSkillRunReport(skill, evidenceType, rows) {
12058
12170
  commonErrors: [...errors.entries()].map(([summary, count]) => ({ summary, count })).sort((a, b) => b.count - a.count).slice(0, 5)
12059
12171
  },
12060
12172
  rows,
12061
- nextCommands: rows.slice(0, 5).map((row) => row.run.status === "failed" ? `rudder runs errors ${row.run.id}` : `rudder runs transcript ${row.run.id}`)
12173
+ nextCommands: rows.slice(0, 5).map((row) => {
12174
+ const runId = formatCliRunId(row.run.id);
12175
+ return row.run.status === "failed" ? `rudder runs errors ${runId}` : `rudder runs transcript ${runId}`;
12176
+ })
12062
12177
  };
12063
12178
  }
12064
12179
  function formatSkillRunReport(report) {
@@ -12082,11 +12197,12 @@ function formatSkillRunReport(report) {
12082
12197
  return lines;
12083
12198
  }
12084
12199
  function formatInlineSkillRun(row) {
12200
+ const runId = formatCliRunId(row.run.id);
12085
12201
  const issue = formatIssueRef(row.issue);
12086
12202
  const label = row.skillEvidence?.matchedSkillLabel && row.skillEvidence.matchedSkillLabel !== row.skillEvidence.matchedSkillKey ? ` label=${row.skillEvidence.matchedSkillLabel}` : "";
12087
12203
  const langfuse = readLangfuseTraceUrl(row.langfuse);
12088
12204
  return [
12089
- `id=${row.run.id}`,
12205
+ `id=${runId}`,
12090
12206
  `status=${row.run.status}`,
12091
12207
  `agent=${row.agentName ?? row.run.agentId}`,
12092
12208
  `issue=${issue}`,
@@ -12097,7 +12213,7 @@ function formatInlineSkillRun(row) {
12097
12213
  `skill=${row.skillEvidence?.matchedSkillKey ?? "-"}${label}`,
12098
12214
  `langfuse=${langfuse ?? "-"}`,
12099
12215
  `error=${row.errorSummary ?? "-"}`,
12100
- `next=${row.run.status === "failed" ? `rudder runs errors ${row.run.id}` : `rudder runs transcript ${row.run.id}`}`
12216
+ `next=${row.run.status === "failed" ? `rudder runs errors ${runId}` : `rudder runs transcript ${runId}`}`
12101
12217
  ].join(" ");
12102
12218
  }
12103
12219
  function formatIssueRef(issue) {
@@ -12909,7 +13025,7 @@ async function heartbeatRun(opts) {
12909
13025
  return;
12910
13026
  }
12911
13027
  const run = invokeRes;
12912
- console.log(pc12.cyan(`Invoked heartbeat run ${run.id} for agent ${agent.name} (${agent.id})`));
13028
+ console.log(pc12.cyan(`Invoked heartbeat run ${formatCliRunId(run.id)} for agent ${agent.name} (${formatCliRunId(agent.id)})`));
12913
13029
  const runId = run.id;
12914
13030
  let activeRunId = null;
12915
13031
  let lastEventSeq = 0;