replicas-cli 0.3.642 → 0.3.643

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.
Files changed (2) hide show
  1. package/dist/index.cjs +41 -14
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -28866,10 +28866,11 @@ function injectVisualBootstrap(html) {
28866
28866
  const at = htmlOpen ? htmlOpen.index + htmlOpen[0].length : doctype ? doctype[0].length : 0;
28867
28867
  return `${prefix}${html.slice(0, at)}<head>${markup}</head>${html.slice(at)}`;
28868
28868
  }
28869
- var VISUAL_MEASURE_WIDTHS, VISUAL_COLUMN_WIDTH, VISUAL_PHONE_WIDTH, VISUAL_MIN_HEIGHT, VISUAL_MAX_HEIGHT, VISUAL_FONT_PATH, FONT_FAMILIES, FONT_SANS, FONT_MONO, VISUAL_PAGE_RULES, THEME_FRAGMENT_KEY, HOST_CONTEXT_CHANGED_METHOD, SIZE_CHANGED_METHOD, OPEN_LINK_METHOD, OPEN_IMAGE_METHOD, VISUAL_CONTENT_HEIGHT_EXPRESSION, BASE_CSS, THEME_STYLE_ID, BOOTSTRAP_SCRIPT, blankNonMarkup;
28869
+ var VISUAL_MEASURE_WIDTHS, VISUAL_COLUMN_WIDTH, VISUAL_PHONE_WIDTH, VISUAL_MIN_HEIGHT, VISUAL_MAX_HEIGHT, VISUAL_FONT_PATH, FONT_FAMILIES, FONT_SANS, FONT_MONO, VISUAL_PAGE_RULES, THEME_FRAGMENT_KEY, HOST_CONTEXT_CHANGED_METHOD, SIZE_CHANGED_METHOD, OPEN_LINK_METHOD, OPEN_IMAGE_METHOD, visualHeightsSchema, VISUAL_CONTENT_HEIGHT_EXPRESSION, BASE_CSS, THEME_STYLE_ID, BOOTSTRAP_SCRIPT, blankNonMarkup;
28870
28870
  var init_visuals = __esm({
28871
28871
  "../shared/src/visuals.ts"() {
28872
28872
  "use strict";
28873
+ init_zod();
28873
28874
  init_design_tokens();
28874
28875
  init_type_guards();
28875
28876
  VISUAL_MEASURE_WIDTHS = [320, 375, 430, 520, 640, 760, 880, 952];
@@ -28894,6 +28895,10 @@ var init_visuals = __esm({
28894
28895
  SIZE_CHANGED_METHOD = "ui/notifications/size-changed";
28895
28896
  OPEN_LINK_METHOD = "ui/open-link";
28896
28897
  OPEN_IMAGE_METHOD = "replicas/open-image";
28898
+ visualHeightsSchema = external_exports.array(external_exports.tuple([
28899
+ external_exports.number().int().min(1).max(1e4),
28900
+ external_exports.number().int().min(0).max(1e5)
28901
+ ])).max(VISUAL_MEASURE_WIDTHS.length).transform((heights) => heights.sort((left, right) => left[0] - right[0]));
28897
28902
  VISUAL_CONTENT_HEIGHT_EXPRESSION = "(function(){var r=document.documentElement;return Math.ceil(r.scrollHeight>r.clientHeight?r.scrollHeight:r.getBoundingClientRect().height)})()";
28898
28903
  BASE_CSS = "html{color:var(--foreground);font-family:var(--font-sans);font-size:13px;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;scrollbar-width:none}html::-webkit-scrollbar{display:none}body{margin:0}:where(*,*::before,*::after){box-sizing:border-box}code,kbd,pre,samp{font-family:var(--font-mono)}:where(:focus-visible){outline:2px solid var(--ring);outline-offset:-2px}";
28899
28904
  THEME_STYLE_ID = "replicas-visual-theme";
@@ -43239,7 +43244,7 @@ var CLI_VERSION;
43239
43244
  var init_cli_version = __esm({
43240
43245
  "../shared/src/cli-version.ts"() {
43241
43246
  "use strict";
43242
- CLI_VERSION = "0.3.642";
43247
+ CLI_VERSION = "0.3.643";
43243
43248
  }
43244
43249
  });
43245
43250
 
@@ -43792,17 +43797,21 @@ var init_web_auth = __esm({
43792
43797
  });
43793
43798
 
43794
43799
  // ../shared/src/routes/artifacts.ts
43795
- var ARTIFACT_KINDS, ARTIFACT_MUTABILITIES, ARTIFACT_PERMISSIONS, ARTIFACT_LIST_OWNERS, ARTIFACT_DISPLAY_NAME_MAX_LENGTH, listArtifactsQuerySchema, updateArtifactRequestSchema, setArtifactShareRequestSchema;
43800
+ var ARTIFACT_KINDS, ARTIFACT_MUTABILITIES, ARTIFACT_PERMISSIONS, ARTIFACT_LIST_OWNERS, ARTIFACT_DISPLAY_NAME_MAX_LENGTH, artifactMetadataSchema, listArtifactsQuerySchema, updateArtifactRequestSchema, setArtifactShareRequestSchema;
43796
43801
  var init_artifacts2 = __esm({
43797
43802
  "../shared/src/routes/artifacts.ts"() {
43798
43803
  "use strict";
43799
43804
  init_zod();
43800
43805
  init_types4();
43806
+ init_visuals();
43801
43807
  ARTIFACT_KINDS = CANVAS_ITEM_KINDS.filter((kind) => kind !== "other");
43802
43808
  ARTIFACT_MUTABILITIES = ["mutable", "immutable"];
43803
43809
  ARTIFACT_PERMISSIONS = ["view", "edit"];
43804
43810
  ARTIFACT_LIST_OWNERS = ["me", "others", "organization"];
43805
43811
  ARTIFACT_DISPLAY_NAME_MAX_LENGTH = 200;
43812
+ artifactMetadataSchema = external_exports.object({
43813
+ visual_heights: visualHeightsSchema.optional()
43814
+ });
43806
43815
  listArtifactsQuerySchema = external_exports.object({
43807
43816
  mutability: external_exports.enum([...ARTIFACT_MUTABILITIES, "all"]).optional(),
43808
43817
  owner: external_exports.array(external_exports.enum(ARTIFACT_LIST_OWNERS)),
@@ -55527,6 +55536,10 @@ function requireNamePerFile(filePaths, names) {
55527
55536
  if (names.some((name) => !name.trim())) throw new Error("--name must not be empty.");
55528
55537
  return names;
55529
55538
  }
55539
+ function formatMediaEmbed(name, media2, publicUrl) {
55540
+ if (publicUrl) return `${media2.kind === MEDIA_KIND.IMAGE ? "!" : ""}[${markdownLabel(name)}](${publicUrl})`;
55541
+ return `Replicas chat embed: ![${markdownLabel(name)}](${MONOLITH_URL}/v1/media/${media2.id})`;
55542
+ }
55530
55543
  var import_chalk6, import_fs2, import_path2, import_prompts10, markdownLabel;
55531
55544
  var init_command_utils = __esm({
55532
55545
  "src/lib/command-utils.ts"() {
@@ -55537,6 +55550,7 @@ var init_command_utils = __esm({
55537
55550
  init_src();
55538
55551
  import_prompts10 = __toESM(require("prompts"));
55539
55552
  init_config();
55553
+ init_monolith_url();
55540
55554
  init_output();
55541
55555
  markdownLabel = (name) => name.replace(/[[\]]/g, "");
55542
55556
  }
@@ -59888,10 +59902,6 @@ var init_media_url = __esm({
59888
59902
  function publicMediaUrl(mediaId, token) {
59889
59903
  return `${MONOLITH_URL}/v1/media/public/${mediaId}/${token}`;
59890
59904
  }
59891
- function formatMediaEmbed(name, media2, publicUrl) {
59892
- if (publicUrl) return `${media2.kind === MEDIA_KIND.IMAGE ? "!" : ""}[${markdownLabel(name)}](${publicUrl})`;
59893
- return `Replicas chat embed: ![${markdownLabel(name)}](${MONOLITH_URL}/v1/media/${media2.id})`;
59894
- }
59895
59905
  async function shareMedia(mediaId) {
59896
59906
  const { token } = await agentFetch(`/v1/engine/media/${mediaId}/share`, {
59897
59907
  method: "POST"
@@ -60191,7 +60201,9 @@ async function artifactUploadCommand(filePaths, options) {
60191
60201
  const size = formatBytes(artifact2.size_bytes);
60192
60202
  const visibility = artifact2.owner ? `Private to ${artifact2.owner.display_name} until shared.` : "This workspace has no owner, so it belongs to the organization: everyone in it can see, rename and delete it.";
60193
60203
  console.log(`Saved artifact "${artifact2.display_name}" (${artifact2.kind}, ${size}). ${visibility}`);
60194
- console.log(`[${markdownLabel(artifact2.display_name)}](${getArtifactUrl(artifact2.id)})`);
60204
+ const mediaKind = MEDIA_KINDS.find((kind) => kind === artifact2.kind);
60205
+ if (mediaKind) console.log(formatMediaEmbed(artifact2.display_name, { id: artifact2.id, kind: mediaKind }));
60206
+ else console.log(`[${markdownLabel(artifact2.display_name)}](${getArtifactUrl(artifact2.id)})`);
60195
60207
  }
60196
60208
  });
60197
60209
  if (failures.length > 0) throw new Error(`${failures.length} artifact upload(s) failed \u2014 ${failures.join("; ")}`);
@@ -60238,17 +60250,28 @@ async function artifactDeleteCommand(artifactId) {
60238
60250
  outputSuccess(`Deleted artifact ${artifactId}`);
60239
60251
  }
60240
60252
  async function resolveGrantPath(artifactId, grantee) {
60241
- if (grantee.organization && grantee.user) throw new Error("Pass either --user <email> or --organization, not both.");
60253
+ if (grantee.public && (grantee.user || grantee.organization)) {
60254
+ throw new Error("Pass --public on its own, without --user or --organization.");
60255
+ }
60256
+ if (grantee.user && grantee.organization) throw new Error("Pass either --user <email> or --organization, not both.");
60257
+ if (grantee.public) return { path: `/v1/artifacts/${artifactId}/public-link`, granteeName: "a public link" };
60242
60258
  if (grantee.organization) {
60243
60259
  return { path: `/v1/artifacts/${artifactId}/shares/organization`, granteeName: "the organization" };
60244
60260
  }
60245
60261
  const email3 = grantee.user;
60246
- if (!email3) throw new Error("Pass --user <email> or --organization.");
60262
+ if (!email3) throw new Error("Pass --user <email>, --organization or --public.");
60247
60263
  const userId = await findMemberUserId(email3);
60248
60264
  if (!userId) throw new Error(`No member of this organization has the email "${email3}".`);
60249
60265
  return { path: `/v1/artifacts/${artifactId}/shares/users/${userId}`, granteeName: email3 };
60250
60266
  }
60251
60267
  async function artifactShareCommand(artifactId, options) {
60268
+ if (options.public) {
60269
+ if (options.permission) throw new Error("A public link is always view only, so --permission doesn't apply.");
60270
+ const { path: path15 } = await resolveGrantPath(artifactId, options);
60271
+ const response = await orgAuthenticatedFetch(path15, { method: "PUT" });
60272
+ output2(response, ({ url: url2 }) => console.log(url2));
60273
+ return;
60274
+ }
60252
60275
  const permission = ARTIFACT_PERMISSIONS.find((value) => value === (options.permission ?? "view"));
60253
60276
  if (!permission) {
60254
60277
  throw new Error(`Invalid permission '${options.permission}'. Must be one of: ${ARTIFACT_PERMISSIONS.join(", ")}`);
@@ -60263,8 +60286,12 @@ async function artifactUnshareCommand(artifactId, options) {
60263
60286
  outputSuccess(`Artifact ${artifactId} is no longer shared with ${granteeName}.`);
60264
60287
  }
60265
60288
  async function artifactSharesCommand(artifactId) {
60266
- const shares = await orgAuthenticatedFetch(`/v1/artifacts/${artifactId}/shares`);
60267
- output2(shares, ({ organization, users }) => {
60289
+ const [shares, { artifact: artifact2 }] = await Promise.all([
60290
+ orgAuthenticatedFetch(`/v1/artifacts/${artifactId}/shares`),
60291
+ orgAuthenticatedFetch(`/v1/artifacts/${artifactId}`)
60292
+ ]);
60293
+ output2({ ...shares, has_public_link: artifact2.has_public_link }, ({ organization, users, has_public_link }) => {
60294
+ console.log(`Public link: ${has_public_link ? "on" : "off"}`);
60268
60295
  console.log(`Organization: ${organization ? organization.permission : "not shared"}`);
60269
60296
  if (users.length === 0) console.log("No people.");
60270
60297
  for (const share2 of users) console.log(`${share2.user?.email} ${share2.permission}`);
@@ -62454,8 +62481,8 @@ var init_src2 = __esm({
62454
62481
  artifact.command("list").description("List your artifacts and those shared with you (mutable only unless --immutable or --all)").option("--immutable", "Only immutable artifacts").option("--all", "Mutable and immutable artifacts").option("--owner <owner>", "me, others or organization (repeatable)", collect, []).option("-k, --kind <kind>", "Viewer kind such as markdown, html or image (repeatable)", collect, []).option("-w, --workspace [id]", "Everything a workspace made that you can open (this workspace if no id)").option("-l, --limit <n>", "Page size (default 50, max 200)").option("-p, --page <n>", "Page number (default 1)").action(run(artifactListCommand));
62455
62482
  artifact.command("url <artifactId>").description("Print a short-lived download URL for an artifact").action(run(artifactUrlCommand));
62456
62483
  artifact.command("rename <artifactId> <name>").description("Rename an artifact (needs edit access)").action(run(artifactRenameCommand));
62457
- artifact.command("share <artifactId>").description("Share an artifact with a member or the whole organization (needs edit access)").option("-u, --user <email>", "Member to share with").option("--organization", "Share with everyone in the organization").option("--permission <permission>", "view or edit (default view)").action(run(artifactShareCommand));
62458
- artifact.command("unshare <artifactId>").description("Stop sharing an artifact with a member or the organization (anyone can remove their own access)").option("-u, --user <email>", "Member to remove").option("--organization", "Stop sharing with the organization").action(run(artifactUnshareCommand));
62484
+ artifact.command("share <artifactId>").description("Share an artifact with a member, the whole organization, or anyone with a public link (needs edit access)").option("-u, --user <email>", "Member to share with").option("--organization", "Share with everyone in the organization").option("--public", "Print a public link anyone can open without signing in, for images, videos and audio (replaces any earlier link)").option("--permission <permission>", "view or edit (default view)").action(run(artifactShareCommand));
62485
+ artifact.command("unshare <artifactId>").description("Stop sharing an artifact with a member, the organization, or its public link (anyone can remove their own access)").option("-u, --user <email>", "Member to remove").option("--organization", "Stop sharing with the organization").option("--public", "Turn off the public link").action(run(artifactUnshareCommand));
62459
62486
  artifact.command("shares <artifactId>").description("List who an artifact is shared with").action(run(artifactSharesCommand));
62460
62487
  artifact.command("delete <artifactId>").description("Permanently delete an artifact (owner only; anyone in the organization for organization-owned ones)").action(run(artifactDeleteCommand));
62461
62488
  media = program.command("media").description("Share workspace media and HTML pages");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.642",
3
+ "version": "0.3.643",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {