@rudderhq/cli 0.4.6-canary.10 → 0.4.6-canary.11

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
@@ -7897,9 +7897,9 @@ var AGENT_CLI_CAPABILITIES = [
7897
7897
  },
7898
7898
  {
7899
7899
  id: "runs.get",
7900
- command: "rudder runs get <run-id>",
7900
+ command: "rudder runs get <run-id> [--full]",
7901
7901
  category: "runs",
7902
- description: "Read one observed run detail.",
7902
+ description: "Read one bounded run summary; use --full only from a direct trusted CLI for raw detail.",
7903
7903
  mutating: false,
7904
7904
  contract: "agent-v1",
7905
7905
  requiresOrgId: false,
@@ -7909,9 +7909,9 @@ var AGENT_CLI_CAPABILITIES = [
7909
7909
  },
7910
7910
  {
7911
7911
  id: "runs.events",
7912
- command: "rudder runs events <run-id> [--after-seq <n>] [--limit <n>]",
7912
+ command: "rudder runs events <run-id> [--cursor <cursor>] [--after-seq <n>] [--limit <n>] [--full]",
7913
7913
  category: "runs",
7914
- description: "List a bounded page of persisted run events with a sequence cursor.",
7914
+ description: "List a bounded page of persisted run events with a lossless opaque cursor and clipped payload previews.",
7915
7915
  mutating: false,
7916
7916
  contract: "agent-v1",
7917
7917
  requiresOrgId: false,
@@ -7933,9 +7933,9 @@ var AGENT_CLI_CAPABILITIES = [
7933
7933
  },
7934
7934
  {
7935
7935
  id: "runs.transcript",
7936
- command: "rudder runs transcript <run-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
7936
+ command: "rudder runs transcript <run-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output] [--full]",
7937
7937
  category: "runs",
7938
- description: "Read the server-normalized run transcript; human output is compact and JSON includes full entries.",
7938
+ description: "Read a compact server-normalized transcript; --json changes encoding only and --full is direct-CLI-only raw access.",
7939
7939
  mutating: false,
7940
7940
  contract: "agent-v1",
7941
7941
  requiresOrgId: false,
@@ -8040,6 +8040,75 @@ function mcpInputSchemaForCapability(id) {
8040
8040
  const add = (key, value) => {
8041
8041
  properties[key] = value;
8042
8042
  };
8043
+ if (id.startsWith("runs.")) {
8044
+ const addString = (key, description) => add(key, mcpString(description));
8045
+ const addNumber = (key, description) => add(key, mcpNumber(description));
8046
+ const addBoolean = (key, description) => add(key, mcpBoolean(description));
8047
+ switch (id) {
8048
+ case "runs.list":
8049
+ addString("updatedAfter", "Only runs updated after this timestamp.");
8050
+ addString("runIdPrefix", "Run id prefix filter.");
8051
+ addString("relatedAgentId", "Agent id filter.");
8052
+ addString("status", "Run status filter.");
8053
+ addString("runtime", "Runtime type filter.");
8054
+ addString("issueId", "Linked issue id filter.");
8055
+ addString("usedSkill", "Used skill filter.");
8056
+ addString("loadedSkill", "Loaded skill filter.");
8057
+ addString("createdBefore", "Only runs created before this timestamp.");
8058
+ addString("cursor", "Stable summary cursor.");
8059
+ addNumber("limit", "Summary page size, capped by the server.");
8060
+ break;
8061
+ case "runs.by-skill":
8062
+ addString("skill", "Skill key or display name.");
8063
+ addString("evidence", "Evidence type: used or loaded.");
8064
+ addString("relatedAgentId", "Agent id filter.");
8065
+ addString("status", "Run status filter.");
8066
+ addString("runtime", "Runtime type filter.");
8067
+ addString("issueId", "Linked issue id filter.");
8068
+ addString("createdBefore", "Only runs created before this timestamp.");
8069
+ addString("cursor", "Stable summary cursor.");
8070
+ addNumber("limit", "Summary page size, capped by the server.");
8071
+ break;
8072
+ case "runs.events":
8073
+ addString("run", "Run id or short run id.");
8074
+ addString("cursor", "Opaque total-order event cursor.");
8075
+ addNumber("afterSeq", "Legacy sequence-only cursor.");
8076
+ addNumber("limit", "Event page size, capped by the server.");
8077
+ addNumber("maxChars", "Maximum payload preview characters per event.");
8078
+ break;
8079
+ case "runs.log":
8080
+ addString("run", "Run id or short run id.");
8081
+ addNumber("maxChars", "Maximum log characters for display.");
8082
+ addNumber("offset", "Byte offset for the ranged read.");
8083
+ addNumber("limitBytes", "Maximum bytes for the ranged read.");
8084
+ break;
8085
+ case "runs.transcript":
8086
+ addString("run", "Run id or short run id.");
8087
+ addBoolean("errorsOnly", "Return only error rows.");
8088
+ addString("aroundError", "Transcript error step id.");
8089
+ addNumber("contextTurns", "Turns around the selected error.");
8090
+ addString("cursor", "Stable transcript cursor.");
8091
+ addNumber("turnLimit", "Maximum turns to return.");
8092
+ addBoolean("chronological", "Return oldest-first rows.");
8093
+ addBoolean("narrative", "Use narrative row formatting.");
8094
+ addNumber("maxChars", "Maximum output characters per row.");
8095
+ addBoolean("includeOutput", "Include clipped row output.");
8096
+ break;
8097
+ case "runs.errors":
8098
+ addString("run", "Run id or short run id.");
8099
+ addString("cursor", "Error page cursor.");
8100
+ addNumber("maxChars", "Maximum output characters per error.");
8101
+ break;
8102
+ default:
8103
+ addString("run", "Run id or short run id.");
8104
+ break;
8105
+ }
8106
+ return {
8107
+ type: "object",
8108
+ additionalProperties: false,
8109
+ properties
8110
+ };
8111
+ }
8043
8112
  if (id.startsWith("issue.")) {
8044
8113
  add("issue", mcpString("Issue UUID, identifier, or short reference."));
8045
8114
  add("body", mcpString("Direct Markdown body for issue comments or close-out notes."));
@@ -8077,7 +8146,6 @@ function mcpInputSchemaForCapability(id) {
8077
8146
  add("chat", mcpString("Chat conversation id."));
8078
8147
  add("body", mcpString("Agent-authored chat message body."));
8079
8148
  }
8080
- if (id.startsWith("runs.")) add("run", mcpString("Run id or short run id."));
8081
8149
  if (id.startsWith("agent.skills.")) {
8082
8150
  add("selectionRefs", { type: "array", items: { type: "string" }, description: "Skill selection refs." });
8083
8151
  add("skills", { type: "array", items: { type: "string" }, description: "Skill selection refs alias." });
@@ -8395,6 +8463,8 @@ function toStringRecord(headers) {
8395
8463
 
8396
8464
  // src/agent-v1-mcp-server.ts
8397
8465
  var RUDDER_MCP_SERVER_NAME = "rudder-control-plane";
8466
+ var RUDDER_MCP_MAX_TOOL_RESULT_BYTES = 1e6;
8467
+ var RUDDER_MCP_MAX_INLINE_TEXT_BYTES = 32e3;
8398
8468
  var RESERVED_MODEL_ARGUMENTS = /* @__PURE__ */ new Set([
8399
8469
  "orgId",
8400
8470
  "org_id",
@@ -8441,6 +8511,7 @@ function buildAgentV1ToolCallPlan(toolName, rawArgs, env = buildMcpServerEnv())
8441
8511
  }
8442
8512
  const capability = getAgentCliCapabilityById(capabilityId);
8443
8513
  rejectModelProvidedRuntimeIdentity(input);
8514
+ rejectUnsupportedToolArguments(toolName, input);
8444
8515
  assertBrowserCapabilityEnabled(capabilityId, env);
8445
8516
  assertRuntimeMcpContext(capability, env);
8446
8517
  const tempFiles = [];
@@ -8482,7 +8553,7 @@ async function runAgentV1McpJsonRpcMessage(message, env = buildMcpServerEnv()) {
8482
8553
  }).tools.map(toMcpToolListEntry)
8483
8554
  });
8484
8555
  case "tools/call":
8485
- return rpcResult(id, await callToolSafely(message.params, env));
8556
+ return boundedToolCallRpcResponse(id, await callToolSafely(message.params, env));
8486
8557
  default:
8487
8558
  if (isNotification) return null;
8488
8559
  return rpcError(id, -32601, `Unsupported JSON-RPC method: ${String(message.method ?? "")}`);
@@ -8595,11 +8666,7 @@ async function callTool(params, env) {
8595
8666
  const result = await runRudderCli(materializedArgs, plan.env);
8596
8667
  if (result.exitCode === 0) {
8597
8668
  const text6 = result.stdout.trim() || "{}";
8598
- return {
8599
- content: [{ type: "text", text: text6 }],
8600
- ...structuredContentFromJsonText(text6),
8601
- isError: false
8602
- };
8669
+ return mcpSuccessFromJsonText(text6);
8603
8670
  }
8604
8671
  const payload = {
8605
8672
  status: "error",
@@ -8722,12 +8789,47 @@ function mcpApiClient(env) {
8722
8789
  });
8723
8790
  }
8724
8791
  function mcpSuccess(data) {
8725
- const text6 = JSON.stringify(data ?? {});
8726
- return {
8727
- content: [{ type: "text", text: text6 }],
8728
- ...structuredContentFromJsonText(text6),
8792
+ return mcpSuccessFromJsonText(JSON.stringify(data ?? {}));
8793
+ }
8794
+ function mcpSuccessFromJsonText(text6) {
8795
+ const structured = structuredContentFromJsonText(text6);
8796
+ const textBytes = Buffer.byteLength(text6, "utf8");
8797
+ const inlineText = textBytes <= RUDDER_MCP_MAX_INLINE_TEXT_BYTES ? text6 : JSON.stringify({
8798
+ status: "ok",
8799
+ output: "structuredContent",
8800
+ originalLength: text6.length,
8801
+ originalBytes: textBytes
8802
+ });
8803
+ const result = {
8804
+ content: [{ type: "text", text: inlineText }],
8805
+ ...structured,
8729
8806
  isError: false
8730
8807
  };
8808
+ const resultBytes = Buffer.byteLength(JSON.stringify(result), "utf8");
8809
+ if (resultBytes <= RUDDER_MCP_MAX_TOOL_RESULT_BYTES) return result;
8810
+ return mcpResponseTooLarge(resultBytes);
8811
+ }
8812
+ function boundedToolCallRpcResponse(id, result) {
8813
+ const response = rpcResult(id, result);
8814
+ const responseBytes = Buffer.byteLength(JSON.stringify(response), "utf8");
8815
+ if (responseBytes <= RUDDER_MCP_MAX_TOOL_RESULT_BYTES) return response;
8816
+ return rpcResult(id, mcpResponseTooLarge(responseBytes));
8817
+ }
8818
+ function mcpResponseTooLarge(responseBytes) {
8819
+ const payload = {
8820
+ status: "error",
8821
+ code: "rudder_mcp_response_too_large",
8822
+ message: "Rudder MCP response exceeded the bounded tool-result budget. Use pagination or a ranged log read.",
8823
+ details: {
8824
+ maxBytes: RUDDER_MCP_MAX_TOOL_RESULT_BYTES,
8825
+ responseBytes
8826
+ }
8827
+ };
8828
+ return {
8829
+ content: [{ type: "text", text: JSON.stringify(payload) }],
8830
+ structuredContent: payload,
8831
+ isError: true
8832
+ };
8731
8833
  }
8732
8834
  function parseCsvInput(value, fallback) {
8733
8835
  const source = Array.isArray(value) ? value.map((entry) => optionalString(entry)).filter(Boolean).join(",") : optionalString(value) || fallback;
@@ -9124,7 +9226,6 @@ function cliArgsForCapability(capabilityId, input, tempFiles, env) {
9124
9226
  pushOptional(args, "--created-before", input.createdBefore);
9125
9227
  pushOptional(args, "--cursor", input.cursor);
9126
9228
  pushOptional(args, "--limit", input.limit);
9127
- pushBoolean(args, "--full", input.full);
9128
9229
  return args;
9129
9230
  }
9130
9231
  case "runs.by-skill": {
@@ -9137,15 +9238,16 @@ function cliArgsForCapability(capabilityId, input, tempFiles, env) {
9137
9238
  pushOptional(args, "--created-before", input.createdBefore);
9138
9239
  pushOptional(args, "--cursor", input.cursor);
9139
9240
  pushOptional(args, "--limit", input.limit);
9140
- pushBoolean(args, "--full", input.full);
9141
9241
  return args;
9142
9242
  }
9143
9243
  case "runs.get":
9144
9244
  return ["runs", "get", requiredString(input, "run")];
9145
9245
  case "runs.events": {
9146
9246
  const args = ["runs", "events", requiredString(input, "run")];
9247
+ pushOptional(args, "--cursor", input.cursor);
9147
9248
  pushOptional(args, "--after-seq", input.afterSeq);
9148
9249
  pushOptional(args, "--limit", input.limit);
9250
+ pushOptional(args, "--max-chars", input.maxChars);
9149
9251
  return args;
9150
9252
  }
9151
9253
  case "runs.log": {
@@ -9171,6 +9273,7 @@ function cliArgsForCapability(capabilityId, input, tempFiles, env) {
9171
9273
  case "runs.errors": {
9172
9274
  const args = ["runs", "errors", requiredString(input, "run")];
9173
9275
  pushOptional(args, "--max-chars", input.maxChars);
9276
+ pushOptional(args, "--cursor", input.cursor);
9174
9277
  return args;
9175
9278
  }
9176
9279
  case "runs.cancel":
@@ -9270,6 +9373,16 @@ function rejectModelProvidedRuntimeIdentity(input) {
9270
9373
  err.code = "rudder_mcp_reserved_identity_argument";
9271
9374
  throw err;
9272
9375
  }
9376
+ function rejectUnsupportedToolArguments(toolName, input) {
9377
+ const tool = buildAgentV1McpToolsManifest("agent-v1").tools.find((entry) => entry.name === toolName);
9378
+ if (!tool) return;
9379
+ const supported = new Set(Object.keys(tool.inputSchema.properties));
9380
+ const unsupported = Object.keys(input).filter((key) => !supported.has(key)).sort();
9381
+ if (unsupported.length === 0) return;
9382
+ const err = new Error(`Unsupported argument${unsupported.length === 1 ? "" : "s"} for ${toolName}: ${unsupported.join(", ")}`);
9383
+ err.code = "rudder_mcp_invalid_arguments";
9384
+ throw err;
9385
+ }
9273
9386
  function normalizeRuntimeIdentityKey(key) {
9274
9387
  return key.replace(/[^a-z0-9]/giu, "").toLowerCase();
9275
9388
  }
@@ -14208,10 +14321,13 @@ function registerRunsCommands(program) {
14208
14321
  { includeCompany: false }
14209
14322
  );
14210
14323
  addCommonClientOptions(
14211
- runs.command("get").description(getAgentCliCapabilityById("runs.get").description).argument("<runId>", "Run ID or short run ID").action(async (runId, opts) => {
14324
+ runs.command("get").description(getAgentCliCapabilityById("runs.get").description).argument("<runId>", "Run ID or short run ID").option("--full", "Include raw run result, context, excerpts, and session fields").action(async (runId, opts) => {
14212
14325
  try {
14213
14326
  const ctx = resolveCommandContext(opts);
14214
- const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}`);
14327
+ const projection = opts.full ? "full" : "summary";
14328
+ const row = await ctx.api.get(
14329
+ `/api/run-intelligence/runs/${encodeURIComponent(runId)}?projection=${projection}`
14330
+ );
14215
14331
  printOutput(row, { json: ctx.json });
14216
14332
  } catch (err) {
14217
14333
  handleCommandError(err);
@@ -14219,13 +14335,16 @@ function registerRunsCommands(program) {
14219
14335
  })
14220
14336
  );
14221
14337
  addCommonClientOptions(
14222
- runs.command("events").description(getAgentCliCapabilityById("runs.events").description).argument("<runId>", "Run ID or short run ID").option("--after-seq <n>", "Return events after this sequence number", "0").option("--limit <n>", "Maximum events to return", "200").action(async (runId, opts) => {
14338
+ runs.command("events").description(getAgentCliCapabilityById("runs.events").description).argument("<runId>", "Run ID or short run ID").option("--cursor <cursor>", "Opaque total-order cursor returned in page.nextCursor").option("--after-seq <n>", "Legacy sequence-only cursor; prefer --cursor", "0").option("--limit <n>", "Maximum events to return", "200").option("--max-chars <n>", "Maximum payload preview characters per event", "1200").option("--full", "Include raw event payloads; unavailable through MCP").action(async (runId, opts) => {
14223
14339
  try {
14224
14340
  const ctx = resolveCommandContext(opts);
14225
14341
  const params = new URLSearchParams({
14226
14342
  afterSeq: String(parseNonNegativeInteger(opts.afterSeq, 0)),
14227
- limit: String(parseLimit2(opts.limit, 200))
14343
+ limit: String(parseLimit2(opts.limit, 200)),
14344
+ maxChars: String(parseLimit2(opts.maxChars, 1200)),
14345
+ projection: opts.full ? "full" : "compact"
14228
14346
  });
14347
+ if (opts.cursor) params.set("cursor", opts.cursor);
14229
14348
  const page = await ctx.api.get(
14230
14349
  `/api/run-intelligence/runs/${encodeURIComponent(runId)}/events?${params}`
14231
14350
  );
@@ -14257,7 +14376,7 @@ function registerRunsCommands(program) {
14257
14376
  })
14258
14377
  );
14259
14378
  addCommonClientOptions(
14260
- 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").addHelpText("after", formatExamplesAndCautions({
14379
+ 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").option("--full", "Return raw lossless transcript entries; unavailable through MCP").addHelpText("after", formatExamplesAndCautions({
14261
14380
  examples: [
14262
14381
  {
14263
14382
  description: "Inspect the neighborhood around a failing step:",
@@ -14269,14 +14388,15 @@ function registerRunsCommands(program) {
14269
14388
  }
14270
14389
  ],
14271
14390
  cautions: [
14272
- "Human output is compact and clipped by default; use --json only when a script needs the full payload.",
14391
+ "Human and JSON output use the same compact projection; --json changes encoding only.",
14392
+ "Use --full only from a direct trusted CLI when lossless provider entries are required.",
14273
14393
  "Use --around-error from runs errors when investigating a failure instead of reading the entire run first."
14274
14394
  ]
14275
14395
  })).action(async (runId, opts) => {
14276
14396
  try {
14277
14397
  const ctx = resolveCommandContext(opts);
14278
14398
  const payload = await ctx.api.get(
14279
- `/api/run-intelligence/runs/${encodeURIComponent(runId)}/transcript?${buildTranscriptQuery(opts, { json: ctx.json })}`
14399
+ `/api/run-intelligence/runs/${encodeURIComponent(runId)}/transcript?${buildTranscriptQuery(opts)}`
14280
14400
  );
14281
14401
  if (ctx.json) {
14282
14402
  printOutput(payload, { json: true });
@@ -14291,7 +14411,7 @@ function registerRunsCommands(program) {
14291
14411
  })
14292
14412
  );
14293
14413
  addCommonClientOptions(
14294
- 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").addHelpText("after", formatExamplesAndCautions({
14414
+ 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").option("--cursor <cursor>", "Cursor returned in page.nextCursor").addHelpText("after", formatExamplesAndCautions({
14295
14415
  examples: [
14296
14416
  {
14297
14417
  description: "Start failed-run investigation with error summaries:",
@@ -14311,6 +14431,7 @@ function registerRunsCommands(program) {
14311
14431
  const ctx = resolveCommandContext(opts);
14312
14432
  const params = new URLSearchParams();
14313
14433
  params.set("maxChars", String(parseLimit2(opts.maxChars, 1200)));
14434
+ if (opts.cursor) params.set("cursor", opts.cursor);
14314
14435
  const payload = await ctx.api.get(
14315
14436
  `/api/run-intelligence/runs/${encodeURIComponent(runId)}/errors?${params.toString()}`
14316
14437
  );
@@ -14382,7 +14503,7 @@ function parseSkillEvidenceType(value) {
14382
14503
  if (normalized === "used" || normalized === "loaded") return normalized;
14383
14504
  throw new Error("--evidence must be either 'used' or 'loaded'.");
14384
14505
  }
14385
- function buildTranscriptQuery(opts, output) {
14506
+ function buildTranscriptQuery(opts) {
14386
14507
  const params = new URLSearchParams();
14387
14508
  if (opts.errorsOnly) params.set("errorsOnly", "true");
14388
14509
  if (opts.aroundError) params.set("aroundError", opts.aroundError);
@@ -14390,8 +14511,8 @@ function buildTranscriptQuery(opts, output) {
14390
14511
  if (opts.turnLimit) params.set("turnLimit", String(parseLimit2(opts.turnLimit, 20)));
14391
14512
  params.set("contextTurns", String(parseLimit2(opts.contextTurns, 1)));
14392
14513
  params.set("order", opts.chronological || opts.narrative ? "oldest" : "newest");
14393
- params.set("output", output.json ? "full" : "compact");
14394
- const includeOutputs = output.json || Boolean(opts.includeOutput || opts.includeOutputs || opts.narrative);
14514
+ params.set("output", opts.full ? "full" : "compact");
14515
+ const includeOutputs = Boolean(opts.full || opts.includeOutput || opts.includeOutputs || opts.narrative);
14395
14516
  params.set("includeOutputs", includeOutputs ? "true" : "false");
14396
14517
  params.set("maxChars", String(parseLimit2(opts.maxOutputChars ?? opts.maxChars, 1200)));
14397
14518
  return params.toString();