@rudderhq/cli 0.2.1-canary.2 → 0.2.1-canary.4

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/README.md CHANGED
@@ -8,8 +8,6 @@ Rudder began from a fork of an early version of Paperclip. That gave us a practi
8
8
 
9
9
  Rudder is built for the moment when agent work stops looking like a single prompt and starts looking like a real team.
10
10
 
11
- Current status: V1 is under active development. The current north-star metric is the weekly count of real agent-work loops completed end-to-end through Rudder.
12
-
13
11
  ## The Design Idea
14
12
 
15
13
  Rudder is shaped by a simple belief: the most useful way to work with agents is closer to the way humans coordinate with each other.
package/dist/index.js CHANGED
@@ -117,6 +117,7 @@ var init_constants = __esm({
117
117
  CHAT_MESSAGE_ROLES = ["user", "assistant", "system"];
118
118
  CHAT_MESSAGE_KINDS = [
119
119
  "message",
120
+ "ask_user",
120
121
  "issue_proposal",
121
122
  "operation_proposal",
122
123
  "system_event"
@@ -579,7 +580,7 @@ var init_resource = __esm({
579
580
 
580
581
  // ../packages/shared/src/validators/chat.ts
581
582
  import { z as z5 } from "zod";
582
- var chatConversationStatusSchema, chatIssueCreationModeSchema, chatMessageRoleSchema, chatMessageKindSchema, chatMessageStatusSchema, chatContextEntityTypeSchema, createChatContextLinkSchema, createChatConversationSchema, setChatProjectContextSchema, updateChatConversationSchema, addChatMessageSchema, createChatAttachmentMetadataSchema, chatIssueProposalSchema, convertChatToIssueSchema, chatOperationProposalSchema, resolveChatOperationProposalSchema, updateChatConversationUserStateSchema;
583
+ var chatConversationStatusSchema, chatIssueCreationModeSchema, chatMessageRoleSchema, chatMessageKindSchema, chatMessageStatusSchema, chatContextEntityTypeSchema, createChatContextLinkSchema, createChatConversationSchema, setChatProjectContextSchema, updateChatConversationSchema, addChatMessageSchema, chatRichReferenceDisplaySchema, chatIssueIdentifierSchema, chatAskUserIdentifierSchema, chatAskUserOptionSchema, chatAskUserQuestionSchema, chatAskUserRequestSchema, chatIssueRichReferenceSchema, chatIssueCommentRichReferenceSchema, chatRichReferenceSchema, chatRichReferencesSchema, createChatAttachmentMetadataSchema, chatIssueProposalSchema, convertChatToIssueSchema, chatOperationProposalSchema, resolveChatOperationProposalSchema, updateChatConversationUserStateSchema;
583
584
  var init_chat = __esm({
584
585
  "../packages/shared/src/validators/chat.ts"() {
585
586
  "use strict";
@@ -616,6 +617,47 @@ var init_chat = __esm({
616
617
  body: z5.string().trim().min(1).max(2e4),
617
618
  editUserMessageId: z5.string().uuid().optional().nullable()
618
619
  });
620
+ chatRichReferenceDisplaySchema = z5.enum(["card", "inline"]);
621
+ chatIssueIdentifierSchema = z5.string().trim().min(1).max(64).regex(/^[A-Z0-9][A-Z0-9-]*$/i);
622
+ chatAskUserIdentifierSchema = z5.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/);
623
+ chatAskUserOptionSchema = z5.object({
624
+ id: chatAskUserIdentifierSchema,
625
+ label: z5.string().trim().min(1).max(80),
626
+ description: z5.string().trim().min(1).max(220).optional(),
627
+ recommended: z5.boolean().optional()
628
+ });
629
+ chatAskUserQuestionSchema = z5.object({
630
+ id: chatAskUserIdentifierSchema,
631
+ header: z5.string().trim().min(1).max(32).optional(),
632
+ question: z5.string().trim().min(1).max(240),
633
+ options: z5.array(chatAskUserOptionSchema).min(2).max(3),
634
+ allowFreeform: z5.boolean().optional()
635
+ });
636
+ chatAskUserRequestSchema = z5.object({
637
+ questions: z5.array(chatAskUserQuestionSchema).min(1).max(3)
638
+ });
639
+ chatIssueRichReferenceSchema = z5.object({
640
+ type: z5.literal("issue"),
641
+ issueId: z5.string().uuid().optional(),
642
+ identifier: chatIssueIdentifierSchema.optional(),
643
+ display: chatRichReferenceDisplaySchema.optional()
644
+ }).refine((value) => Boolean(value.issueId || value.identifier), {
645
+ message: "issueId or identifier is required"
646
+ });
647
+ chatIssueCommentRichReferenceSchema = z5.object({
648
+ type: z5.literal("issue_comment"),
649
+ issueId: z5.string().uuid().optional(),
650
+ identifier: chatIssueIdentifierSchema.optional(),
651
+ commentId: z5.string().uuid(),
652
+ display: chatRichReferenceDisplaySchema.optional()
653
+ }).refine((value) => Boolean(value.issueId || value.identifier), {
654
+ message: "issueId or identifier is required"
655
+ });
656
+ chatRichReferenceSchema = z5.union([
657
+ chatIssueRichReferenceSchema,
658
+ chatIssueCommentRichReferenceSchema
659
+ ]);
660
+ chatRichReferencesSchema = z5.array(chatRichReferenceSchema).max(5);
619
661
  createChatAttachmentMetadataSchema = z5.object({
620
662
  messageId: z5.string().uuid()
621
663
  });
@@ -2491,7 +2533,10 @@ var init_organization_skill_reference = __esm({
2491
2533
  "para-memory-files",
2492
2534
  "rudder",
2493
2535
  "rudder-create-agent",
2494
- "rudder-create-plugin"
2536
+ "rudder-create-plugin",
2537
+ "skill-creator",
2538
+ "skill-optimizer",
2539
+ "conversation-to-skill"
2495
2540
  ];
2496
2541
  RUDDER_BUNDLED_SKILL_KEYS = new Set(
2497
2542
  RUDDER_BUNDLED_SKILL_SLUGS.map((slug) => `rudder/${slug}`)
@@ -6133,6 +6178,70 @@ var DESKTOP_APP_NAME = "Rudder";
6133
6178
  var DESKTOP_METADATA_FILE = ".rudder-desktop-install.json";
6134
6179
  var DESKTOP_CHECKSUM_ASSET_NAME = "SHASUMS256.txt";
6135
6180
  var GITHUB_ASSET_DOWNLOAD_ACCEPT = "application/octet-stream";
6181
+ function normalizeProgressTotal(totalBytes) {
6182
+ return typeof totalBytes === "number" && Number.isFinite(totalBytes) && totalBytes > 0 ? totalBytes : null;
6183
+ }
6184
+ function writeDesktopProgress(event) {
6185
+ const payload = {
6186
+ source: "rudder-desktop-update",
6187
+ ...event,
6188
+ at: (/* @__PURE__ */ new Date()).toISOString()
6189
+ };
6190
+ try {
6191
+ process.stdout.write(`${JSON.stringify(payload)}
6192
+ `);
6193
+ } catch (error) {
6194
+ const code = typeof error === "object" && error && "code" in error ? String(error.code) : "";
6195
+ if (code !== "EPIPE") throw error;
6196
+ }
6197
+ }
6198
+ function desktopDownloadPhase(label) {
6199
+ return label.toLowerCase().includes("shasums") ? "downloading_checksums" : "downloading_asset";
6200
+ }
6201
+ function createDesktopProgressFactory() {
6202
+ return (label) => {
6203
+ const phase = desktopDownloadPhase(label);
6204
+ let latestReceivedBytes = 0;
6205
+ let latestTotalBytes = null;
6206
+ function emitByteProgress(message, receivedBytes, totalBytes) {
6207
+ const total = normalizeProgressTotal(totalBytes);
6208
+ writeDesktopProgress({
6209
+ phase,
6210
+ message,
6211
+ transferredBytes: Math.max(0, receivedBytes),
6212
+ ...total === null ? {} : {
6213
+ totalBytes: total,
6214
+ percent: Math.max(0, Math.min(100, Math.floor(Math.max(0, receivedBytes) / total * 100)))
6215
+ }
6216
+ });
6217
+ }
6218
+ return {
6219
+ start(totalBytes) {
6220
+ latestReceivedBytes = 0;
6221
+ latestTotalBytes = totalBytes;
6222
+ emitByteProgress(label, 0, totalBytes);
6223
+ },
6224
+ update(receivedBytes, totalBytes) {
6225
+ latestReceivedBytes = receivedBytes;
6226
+ latestTotalBytes = totalBytes;
6227
+ emitByteProgress(label, receivedBytes, totalBytes);
6228
+ },
6229
+ finish(receivedBytes = latestReceivedBytes, totalBytes = latestTotalBytes) {
6230
+ latestReceivedBytes = receivedBytes;
6231
+ latestTotalBytes = totalBytes;
6232
+ emitByteProgress(`${label} complete`, receivedBytes, totalBytes);
6233
+ },
6234
+ fail() {
6235
+ writeDesktopProgress({
6236
+ phase,
6237
+ message: `${label} failed`,
6238
+ transferredBytes: Math.max(0, latestReceivedBytes),
6239
+ error: `${label} failed`
6240
+ });
6241
+ }
6242
+ };
6243
+ };
6244
+ }
6136
6245
  function resolveCurrentCliVersion(env = process.env) {
6137
6246
  const version = resolveCliVersion(import.meta.url, env);
6138
6247
  return version === "0.0.0" ? "latest" : version;
@@ -6685,15 +6794,28 @@ async function writeInstallMetadata(paths, releaseTag, assetName, assetChecksum)
6685
6794
  await writeFile2(paths.metadataPath, `${JSON.stringify(metadata, null, 2)}
6686
6795
  `, "utf8");
6687
6796
  }
6688
- async function runStartPhase(message, successMessage, task) {
6797
+ async function runStartPhase(message, successMessage, task, progressPhase) {
6798
+ if (progressPhase) {
6799
+ writeDesktopProgress({ phase: progressPhase, message });
6800
+ }
6689
6801
  const spinner3 = p13.spinner();
6690
6802
  spinner3.start(message);
6691
6803
  try {
6692
6804
  const result = await task();
6693
6805
  spinner3.stop(successMessage);
6806
+ if (progressPhase) {
6807
+ writeDesktopProgress({ phase: progressPhase, message: successMessage });
6808
+ }
6694
6809
  return result;
6695
6810
  } catch (error) {
6696
6811
  spinner3.stop(pc8.red(`${message} failed.`));
6812
+ if (progressPhase) {
6813
+ writeDesktopProgress({
6814
+ phase: "failed",
6815
+ message: `${message} failed.`,
6816
+ error: error instanceof Error ? error.message : String(error)
6817
+ });
6818
+ }
6697
6819
  throw error;
6698
6820
  }
6699
6821
  }
@@ -6704,6 +6826,12 @@ async function startCommand(opts) {
6704
6826
  const repo = opts.repo?.trim() || DEFAULT_DESKTOP_RELEASE_REPO;
6705
6827
  const version = opts.targetVersion?.trim() || opts.version?.trim() || resolveCurrentCliVersion();
6706
6828
  const dryRun = opts.dryRun === true;
6829
+ const desktopProgressJson = opts.desktopProgressJson === true;
6830
+ if (desktopProgressJson) {
6831
+ process.stdout.on("error", (error) => {
6832
+ if (error.code !== "EPIPE") throw error;
6833
+ });
6834
+ }
6707
6835
  if (!installCli && !installDesktop && !installRuntime) {
6708
6836
  throw new Error("Nothing to start. Remove --no-cli, --no-runtime, or --no-desktop.");
6709
6837
  }
@@ -6777,13 +6905,14 @@ async function startCommand(opts) {
6777
6905
  return;
6778
6906
  }
6779
6907
  const directReleaseVersion = resolveDesktopReleaseVersion(tag);
6780
- const progressFactory = createByteProgress;
6908
+ const progressFactory = desktopProgressJson ? createDesktopProgressFactory() : createByteProgress;
6781
6909
  let release = null;
6782
6910
  try {
6783
6911
  release = await runStartPhase(
6784
6912
  "Resolving Desktop release...",
6785
6913
  "Desktop release resolved.",
6786
- () => fetchGithubRelease(repo, tag)
6914
+ () => fetchGithubRelease(repo, tag),
6915
+ desktopProgressJson ? "resolving_release" : null
6787
6916
  );
6788
6917
  } catch (error) {
6789
6918
  if (!directReleaseVersion) throw error;
@@ -6811,24 +6940,28 @@ async function startCommand(opts) {
6811
6940
  async () => {
6812
6941
  await removeMacQuarantine(installPaths, target);
6813
6942
  await createPlatformLaunchers(installPaths, target);
6814
- }
6943
+ },
6944
+ desktopProgressJson ? "preparing_restart" : null
6815
6945
  );
6816
6946
  } else {
6817
6947
  const installerPath = await downloadAsset(asset, outputDir, progressFactory);
6818
6948
  const checksum = await runStartPhase(
6819
6949
  "Verifying Desktop checksum...",
6820
6950
  `Verified ${pc8.cyan(path11.basename(installerPath))}.`,
6821
- () => assertChecksumMatch(installerPath, expectedChecksum)
6951
+ () => assertChecksumMatch(installerPath, expectedChecksum),
6952
+ desktopProgressJson ? "verifying_checksum" : null
6822
6953
  );
6823
6954
  await runStartPhase(
6824
6955
  "Replacing existing Rudder Desktop if needed...",
6825
6956
  "Existing Desktop install is ready for replacement.",
6826
- () => prepareForDesktopReplace(installPaths, target, { waitForActiveRuns: opts.waitForActiveRuns === true })
6957
+ () => prepareForDesktopReplace(installPaths, target, { waitForActiveRuns: opts.waitForActiveRuns === true }),
6958
+ desktopProgressJson ? opts.waitForActiveRuns === true ? "waiting_for_active_runs" : "preparing_restart" : null
6827
6959
  );
6828
6960
  await runStartPhase(
6829
6961
  "Installing portable Desktop app...",
6830
6962
  `Installed Rudder Desktop to ${pc8.cyan(installPaths.appPath)}.`,
6831
- () => installPortableDesktop(installerPath, installPaths, target)
6963
+ () => installPortableDesktop(installerPath, installPaths, target),
6964
+ desktopProgressJson ? "preparing_restart" : null
6832
6965
  );
6833
6966
  await runStartPhase(
6834
6967
  "Preparing Desktop launchers...",
@@ -6836,7 +6969,8 @@ async function startCommand(opts) {
6836
6969
  async () => {
6837
6970
  await removeMacQuarantine(installPaths, target);
6838
6971
  await createPlatformLaunchers(installPaths, target);
6839
- }
6972
+ },
6973
+ desktopProgressJson ? "preparing_restart" : null
6840
6974
  );
6841
6975
  await writeInstallMetadata(installPaths, releaseTag, asset.name, checksum);
6842
6976
  }
@@ -6844,7 +6978,8 @@ async function startCommand(opts) {
6844
6978
  await runStartPhase(
6845
6979
  "Launching Rudder Desktop...",
6846
6980
  "Rudder Desktop launched.",
6847
- () => launchDesktop(installPaths, target)
6981
+ () => launchDesktop(installPaths, target),
6982
+ desktopProgressJson ? "closing" : null
6848
6983
  );
6849
6984
  }
6850
6985
  }
@@ -11399,7 +11534,7 @@ function createProgram() {
11399
11534
  });
11400
11535
  loadRudderEnvFile(options.config);
11401
11536
  });
11402
- program.command("start").description("Start Rudder Desktop and prepare the matching persistent CLI").option("--no-cli", "Skip persistent CLI installation").option("--no-runtime", "Skip Rudder runtime installation").option("--no-desktop", "Skip desktop app installation").option("--version <version>", "Rudder version to start (default: current CLI version)").option("--target-version <version>", "Rudder version to start; avoids the root CLI version flag").option("--repo <owner/repo>", "GitHub repository that hosts desktop releases").option("--output-dir <path>", "Directory for downloaded desktop release assets").option("--desktop-install-dir <path>", "Directory for the portable Desktop install").option("--no-open", "Install Desktop without launching it").option("--wait-for-active-runs", "Wait for active Rudder runs to finish before replacing Desktop", false).option("--no-version-check", "Skip checking npm for a newer Rudder CLI version").option("--dry-run", "Print the start actions without changing the machine", false).action(startCommand);
11537
+ program.command("start").description("Start Rudder Desktop and prepare the matching persistent CLI").option("--no-cli", "Skip persistent CLI installation").option("--no-runtime", "Skip Rudder runtime installation").option("--no-desktop", "Skip desktop app installation").option("--version <version>", "Rudder version to start (default: current CLI version)").option("--target-version <version>", "Rudder version to start; avoids the root CLI version flag").option("--repo <owner/repo>", "GitHub repository that hosts desktop releases").option("--output-dir <path>", "Directory for downloaded desktop release assets").option("--desktop-install-dir <path>", "Directory for the portable Desktop install").option("--no-open", "Install Desktop without launching it").option("--wait-for-active-runs", "Wait for active Rudder runs to finish before replacing Desktop", false).option("--desktop-progress-json", "Emit newline-delimited Desktop update progress events").option("--no-version-check", "Skip checking npm for a newer Rudder CLI version").option("--dry-run", "Print the start actions without changing the machine", false).action(startCommand);
11403
11538
  program.command("onboard").description("Interactive first-run setup wizard").option("-c, --config <path>", "Path to config file").option("-d, --data-dir <path>", DATA_DIR_OPTION_HELP).option("-y, --yes", "Accept defaults (quickstart + start immediately)", false).option("--run", "Start Rudder immediately after saving config", false).action(onboard);
11404
11539
  program.command("doctor").description("Run diagnostic checks on your Rudder setup").option("-c, --config <path>", "Path to config file").option("-d, --data-dir <path>", DATA_DIR_OPTION_HELP).option("--repair", "Attempt to repair issues automatically").alias("--fix").option("-y, --yes", "Skip repair confirmation prompts").action(async (opts) => {
11405
11540
  await doctor(opts);