@rudderhq/cli 0.3.4-canary.13 → 0.3.4-canary.15
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 +67 -37
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11170,9 +11170,9 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
11170
11170
|
},
|
|
11171
11171
|
{
|
|
11172
11172
|
id: "chat.messages",
|
|
11173
|
-
command: "rudder chat messages <chat-id>",
|
|
11173
|
+
command: "rudder chat messages <chat-id> [--limit <n>] [--cursor <cursor>] [--include-transcript]",
|
|
11174
11174
|
category: "chat",
|
|
11175
|
-
description: "Read bounded chat messages
|
|
11175
|
+
description: "Read bounded chat messages with page cursors; transcript output is omitted unless requested.",
|
|
11176
11176
|
mutating: false,
|
|
11177
11177
|
contract: "agent-v1",
|
|
11178
11178
|
requiresOrgId: false,
|
|
@@ -11182,9 +11182,9 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
11182
11182
|
},
|
|
11183
11183
|
{
|
|
11184
11184
|
id: "chat.transcript",
|
|
11185
|
-
command: "rudder chat transcript <chat-id>",
|
|
11185
|
+
command: "rudder chat transcript <chat-id> [--limit <n>] [--cursor <cursor>] [--max-output-chars <n>]",
|
|
11186
11186
|
category: "chat",
|
|
11187
|
-
description: "Read chat messages with assistant transcript entries clipped in human output.",
|
|
11187
|
+
description: "Read paginated chat messages with assistant transcript entries clipped in human output.",
|
|
11188
11188
|
mutating: false,
|
|
11189
11189
|
contract: "agent-v1",
|
|
11190
11190
|
requiresOrgId: false,
|
|
@@ -11194,9 +11194,9 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
11194
11194
|
},
|
|
11195
11195
|
{
|
|
11196
11196
|
id: "chat.read",
|
|
11197
|
-
command: "rudder chat read <chat-id>",
|
|
11197
|
+
command: "rudder chat read <chat-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
|
|
11198
11198
|
category: "chat",
|
|
11199
|
-
description: "Read a bounded recent-message snapshot for one chat.",
|
|
11199
|
+
description: "Read a bounded recent-message snapshot for one chat with page cursors.",
|
|
11200
11200
|
mutating: false,
|
|
11201
11201
|
contract: "agent-v1",
|
|
11202
11202
|
requiresOrgId: false,
|
|
@@ -11290,9 +11290,9 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
11290
11290
|
},
|
|
11291
11291
|
{
|
|
11292
11292
|
id: "runs.transcript",
|
|
11293
|
-
command: "rudder runs transcript <run-id>",
|
|
11293
|
+
command: "rudder runs transcript <run-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
|
|
11294
11294
|
category: "runs",
|
|
11295
|
-
description: "Read the server-normalized run transcript
|
|
11295
|
+
description: "Read the server-normalized run transcript; human output is compact and JSON includes full entries.",
|
|
11296
11296
|
mutating: false,
|
|
11297
11297
|
contract: "agent-v1",
|
|
11298
11298
|
requiresOrgId: false,
|
|
@@ -13464,25 +13464,35 @@ function registerChatCommands(program) {
|
|
|
13464
13464
|
})
|
|
13465
13465
|
);
|
|
13466
13466
|
addCommonClientOptions(
|
|
13467
|
-
chat.command("messages").description(getAgentCliCapabilityById("chat.messages").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--limit <n>", "Maximum messages to print").action(async (chatId, opts) => {
|
|
13467
|
+
chat.command("messages").description(getAgentCliCapabilityById("chat.messages").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").action(async (chatId, opts) => {
|
|
13468
13468
|
try {
|
|
13469
13469
|
const ctx = resolveCommandContext(opts);
|
|
13470
|
-
const
|
|
13471
|
-
|
|
13472
|
-
|
|
13470
|
+
const page = await getChatMessagesPage(ctx, chatId, {
|
|
13471
|
+
includeTranscript: includesChatTranscript(opts),
|
|
13472
|
+
limit: opts.limit,
|
|
13473
|
+
cursor: opts.cursor
|
|
13474
|
+
});
|
|
13475
|
+
printOutput(
|
|
13476
|
+
ctx.json ? page : page.messages.map((message) => formatChatMessage(message, parseLimit(opts.maxOutputChars, 1200))),
|
|
13477
|
+
{ json: ctx.json }
|
|
13478
|
+
);
|
|
13473
13479
|
} catch (err) {
|
|
13474
13480
|
handleCommandError(err);
|
|
13475
13481
|
}
|
|
13476
13482
|
})
|
|
13477
13483
|
);
|
|
13478
13484
|
addCommonClientOptions(
|
|
13479
|
-
chat.command("transcript").description(getAgentCliCapabilityById("chat.transcript").description).argument("<chatId>", "Chat conversation ID").option("--limit <n>", "Maximum messages to print").option("--max-chars <n>", "Maximum transcript chars per message", "1200").action(async (chatId, opts) => {
|
|
13485
|
+
chat.command("transcript").description(getAgentCliCapabilityById("chat.transcript").description).argument("<chatId>", "Chat conversation ID").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-chars <n>", "Maximum transcript chars per message", "1200").option("--max-output-chars <n>", "Alias for --max-chars").action(async (chatId, opts) => {
|
|
13480
13486
|
try {
|
|
13481
13487
|
const ctx = resolveCommandContext(opts);
|
|
13482
|
-
const
|
|
13483
|
-
|
|
13488
|
+
const page = await getChatMessagesPage(ctx, chatId, {
|
|
13489
|
+
includeTranscript: true,
|
|
13490
|
+
limit: opts.limit,
|
|
13491
|
+
cursor: opts.cursor
|
|
13492
|
+
});
|
|
13493
|
+
const maxChars = parseLimit(opts.maxOutputChars ?? opts.maxChars, 1200);
|
|
13484
13494
|
printOutput(
|
|
13485
|
-
ctx.json ?
|
|
13495
|
+
ctx.json ? page : page.messages.flatMap((message) => formatChatTranscriptMessage(message, maxChars)),
|
|
13486
13496
|
{ json: ctx.json }
|
|
13487
13497
|
);
|
|
13488
13498
|
} catch (err) {
|
|
@@ -13491,19 +13501,26 @@ function registerChatCommands(program) {
|
|
|
13491
13501
|
})
|
|
13492
13502
|
);
|
|
13493
13503
|
addCommonClientOptions(
|
|
13494
|
-
chat.command("read").description(getAgentCliCapabilityById("chat.read").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--limit <n>", "Maximum recent messages", "20").action(async (chatId, opts) => {
|
|
13504
|
+
chat.command("read").description(getAgentCliCapabilityById("chat.read").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum recent messages", "20").option("--turn-limit <n>", "Alias for --limit for chat turn snapshots").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").action(async (chatId, opts) => {
|
|
13495
13505
|
try {
|
|
13496
13506
|
const ctx = resolveCommandContext(opts);
|
|
13497
|
-
const [conversation,
|
|
13507
|
+
const [conversation, page] = await Promise.all([
|
|
13498
13508
|
ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}`),
|
|
13499
|
-
|
|
13509
|
+
getChatMessagesPage(ctx, chatId, {
|
|
13510
|
+
includeTranscript: includesChatTranscript(opts),
|
|
13511
|
+
limit: opts.turnLimit ?? opts.limit,
|
|
13512
|
+
cursor: opts.cursor
|
|
13513
|
+
})
|
|
13500
13514
|
]);
|
|
13501
|
-
const recentMessages = limitNewest(messages, opts.limit);
|
|
13502
13515
|
const payload = {
|
|
13503
13516
|
conversation,
|
|
13504
|
-
messages:
|
|
13517
|
+
messages: page.messages,
|
|
13518
|
+
page: page.page
|
|
13505
13519
|
};
|
|
13506
|
-
printOutput(
|
|
13520
|
+
printOutput(
|
|
13521
|
+
ctx.json ? payload : page.messages.map((message) => formatChatMessage(message, parseLimit(opts.maxOutputChars, 1200))),
|
|
13522
|
+
{ json: ctx.json }
|
|
13523
|
+
);
|
|
13507
13524
|
} catch (err) {
|
|
13508
13525
|
handleCommandError(err);
|
|
13509
13526
|
}
|
|
@@ -13567,10 +13584,18 @@ async function listChats(ctx, opts) {
|
|
|
13567
13584
|
const rows = await ctx.api.get(`/api/orgs/${ctx.orgId}/chats?${params.toString()}`) ?? [];
|
|
13568
13585
|
return rows.slice(0, parseLimit(opts.limit, rows.length));
|
|
13569
13586
|
}
|
|
13570
|
-
async function
|
|
13587
|
+
async function getChatMessagesPage(ctx, chatId, opts) {
|
|
13571
13588
|
const params = new URLSearchParams();
|
|
13572
|
-
|
|
13573
|
-
|
|
13589
|
+
params.set("envelope", "true");
|
|
13590
|
+
params.set("order", "newest");
|
|
13591
|
+
params.set("limit", String(parseLimit(opts.limit, 50)));
|
|
13592
|
+
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
13593
|
+
if (opts.includeTranscript) params.set("includeTranscript", "true");
|
|
13594
|
+
const page = await ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}/messages?${params.toString()}`);
|
|
13595
|
+
if (!page) {
|
|
13596
|
+
throw new Error("Chat messages response was empty");
|
|
13597
|
+
}
|
|
13598
|
+
return page;
|
|
13574
13599
|
}
|
|
13575
13600
|
function filterChatSearchRows(rows, query, scope) {
|
|
13576
13601
|
const normalized = query.toLowerCase();
|
|
@@ -13602,7 +13627,7 @@ function formatChatSearchResult(row, maxChars) {
|
|
|
13602
13627
|
snippet: clip(row.searchPreview ?? row.latestReplyPreview ?? row.latestUserMessagePreview ?? row.summary ?? "", maxChars)
|
|
13603
13628
|
};
|
|
13604
13629
|
}
|
|
13605
|
-
function formatChatMessage(row) {
|
|
13630
|
+
function formatChatMessage(row, maxOutputChars = 1200) {
|
|
13606
13631
|
return {
|
|
13607
13632
|
id: row.id,
|
|
13608
13633
|
role: row.role,
|
|
@@ -13610,7 +13635,8 @@ function formatChatMessage(row) {
|
|
|
13610
13635
|
status: row.status,
|
|
13611
13636
|
createdAt: row.createdAt,
|
|
13612
13637
|
body: clip(row.body, 220),
|
|
13613
|
-
transcriptEntries: row.transcriptSummary?.entryCount ?? row.transcript?.length ?? 0
|
|
13638
|
+
transcriptEntries: row.transcriptSummary?.entryCount ?? row.transcript?.length ?? 0,
|
|
13639
|
+
...row.transcript?.length ? { transcriptPreview: clip(row.transcript.map((entry) => formatTranscriptEntry(entry, maxOutputChars)).join(" "), maxOutputChars) } : {}
|
|
13614
13640
|
};
|
|
13615
13641
|
}
|
|
13616
13642
|
function formatChatTranscriptMessage(row, maxChars) {
|
|
@@ -13642,9 +13668,8 @@ function parseLimit(value, fallback) {
|
|
|
13642
13668
|
if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
|
|
13643
13669
|
return Math.floor(parsed);
|
|
13644
13670
|
}
|
|
13645
|
-
function
|
|
13646
|
-
|
|
13647
|
-
return rows.slice(-parseLimit(limit, rows.length));
|
|
13671
|
+
function includesChatTranscript(opts) {
|
|
13672
|
+
return Boolean(opts.includeTranscript || opts.includeOutput || opts.includeOutputs);
|
|
13648
13673
|
}
|
|
13649
13674
|
function clip(value, maxChars) {
|
|
13650
13675
|
const text6 = value.replace(/\s+/g, " ").trim();
|
|
@@ -13728,11 +13753,11 @@ function registerRunsCommands(program) {
|
|
|
13728
13753
|
})
|
|
13729
13754
|
);
|
|
13730
13755
|
addCommonClientOptions(
|
|
13731
|
-
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("--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").action(async (runId, opts) => {
|
|
13756
|
+
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) => {
|
|
13732
13757
|
try {
|
|
13733
13758
|
const ctx = resolveCommandContext(opts);
|
|
13734
13759
|
const payload = await ctx.api.get(
|
|
13735
|
-
`/api/run-intelligence/runs/${encodeURIComponent(runId)}/transcript?${buildTranscriptQuery(opts)}`
|
|
13760
|
+
`/api/run-intelligence/runs/${encodeURIComponent(runId)}/transcript?${buildTranscriptQuery(opts, { json: ctx.json })}`
|
|
13736
13761
|
);
|
|
13737
13762
|
if (ctx.json) {
|
|
13738
13763
|
printOutput(payload, { json: true });
|
|
@@ -13796,13 +13821,18 @@ function buildRunsListQuery(opts) {
|
|
|
13796
13821
|
if (opts.limit) params.set("limit", opts.limit);
|
|
13797
13822
|
return params.toString();
|
|
13798
13823
|
}
|
|
13799
|
-
function buildTranscriptQuery(opts) {
|
|
13824
|
+
function buildTranscriptQuery(opts, output) {
|
|
13800
13825
|
const params = new URLSearchParams();
|
|
13801
13826
|
if (opts.errorsOnly) params.set("errorsOnly", "true");
|
|
13802
13827
|
if (opts.aroundError) params.set("aroundError", opts.aroundError);
|
|
13828
|
+
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
13829
|
+
if (opts.turnLimit) params.set("turnLimit", String(parseLimit2(opts.turnLimit, 20)));
|
|
13803
13830
|
params.set("contextTurns", String(parseLimit2(opts.contextTurns, 1)));
|
|
13804
13831
|
params.set("order", opts.chronological || opts.narrative ? "oldest" : "newest");
|
|
13805
|
-
params.set("
|
|
13832
|
+
params.set("output", output.json ? "full" : "compact");
|
|
13833
|
+
const includeOutputs = output.json || Boolean(opts.includeOutput || opts.includeOutputs || opts.narrative);
|
|
13834
|
+
params.set("includeOutputs", includeOutputs ? "true" : "false");
|
|
13835
|
+
params.set("maxChars", String(parseLimit2(opts.maxOutputChars ?? opts.maxChars, 1200)));
|
|
13806
13836
|
return params.toString();
|
|
13807
13837
|
}
|
|
13808
13838
|
function formatRunListRow(row) {
|
|
@@ -13832,13 +13862,13 @@ function formatRunTranscriptRow(row) {
|
|
|
13832
13862
|
ts: row.ts,
|
|
13833
13863
|
error: row.isError ? "yes" : "no",
|
|
13834
13864
|
preview: row.preview || row.detailPreview,
|
|
13835
|
-
output: row.output.text
|
|
13865
|
+
...row.output ? { output: row.output.text } : {}
|
|
13836
13866
|
};
|
|
13837
13867
|
}
|
|
13838
13868
|
function formatRunTranscriptNarrative(row) {
|
|
13839
13869
|
const marker = row.isError ? "ERROR " : "";
|
|
13840
|
-
return `${row.id} ${row.ts} ${marker}${row.kind}: ${row.preview || row.detailPreview}
|
|
13841
|
-
${row.output.text}`;
|
|
13870
|
+
return `${row.id} ${row.ts} ${marker}${row.kind}: ${row.preview || row.detailPreview}${row.output ? `
|
|
13871
|
+
${row.output.text}` : ""}`;
|
|
13842
13872
|
}
|
|
13843
13873
|
function formatRunError(row) {
|
|
13844
13874
|
return {
|