@cmo-so/cli 0.4.0 → 0.5.0

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/cmo.mjs +177 -15
  2. package/package.json +1 -1
package/dist/cmo.mjs CHANGED
@@ -7480,7 +7480,8 @@ var MEMORY_CHANNELS = [
7480
7480
  "facebook",
7481
7481
  "instagram",
7482
7482
  "google_business",
7483
- "youtube"
7483
+ "youtube",
7484
+ "tiktok"
7484
7485
  ];
7485
7486
  function addWebsite(api2, url) {
7486
7487
  return api2.request("/v1/domains", {
@@ -7732,6 +7733,20 @@ function domainApi(api2, domain) {
7732
7733
  ),
7733
7734
  /** Disconnect: the token is deleted and Google's access revoked (YouTube's policy). */
7734
7735
  disconnectYouTube: (connectionId) => api2.request(`${base}/social/youtube/${connectionId}`, { method: "DELETE" }),
7736
+ /** A TikTok sign-in link for this website (docs/prd/tiktok.md §7); back with ?tiktok=connected (error&message=…). */
7737
+ connectTikTok: (returnTo = "close") => post(`${base}/social/tiktok/connect`, { return_to: returnTo }),
7738
+ /** What the TikTok account allows right now: show it in the TikTok post editor (TikTok's guidelines). */
7739
+ tiktokCreator: () => api2.request(`${base}/social/tiktok/creator`),
7740
+ /** Disconnect: TikTok's access is revoked and the token deleted. */
7741
+ disconnectTikTok: (connectionId) => api2.request(`${base}/social/tiktok/${connectionId}`, { method: "DELETE" }),
7742
+ /** A TikTok post's settings: who can view it, comments / Duet / Stitch, content disclosure, AI label. */
7743
+ setSocialTikTok: (id, answers) => api2.request(`${base}/social/${id}`, {
7744
+ method: "PATCH",
7745
+ headers: { "Content-Type": "application/json" },
7746
+ body: JSON.stringify({ tiktok: answers })
7747
+ }),
7748
+ /** Ask to join the beta of these channels: an email says what we need (reply or WhatsApp); the team is told. */
7749
+ requestBeta: (req) => post(`${base}/social/beta-request`, req),
7735
7750
  /** One channel's own pause switch (pauseSocial / resumeSocial hold every channel). */
7736
7751
  setChannelPaused: (channel, paused) => post(`${base}/social/channels/${channel}/${paused ? "pause" : "resume"}`),
7737
7752
  /** How often one channel posts. */
@@ -7914,7 +7929,8 @@ function domainApi(api2, domain) {
7914
7929
  video: (videoId) => api2.request(`${base}/social/video/${videoId}`),
7915
7930
  /** Another part or framing; prepared again in the background. */
7916
7931
  editVideo: (videoId, edit) => post(`${base}/social/video/${videoId}/edit`, { edit }),
7917
- /** A YouTube post from a ready video, waiting in Review; Maggie writes the details unless write is false. */
7932
+ /** A post on one video channel (YouTube by default, or TikTok) from a ready video, waiting in Review; Maggie
7933
+ * writes the details (YouTube) or the caption (TikTok) unless write is false. */
7918
7934
  postFromVideo: (videoId, opts = {}) => post(`${base}/social/video/${videoId}/post`, opts),
7919
7935
  youtubeSettings: () => api2.request(`${base}/social/youtube/settings`),
7920
7936
  setYouTubeSettings: (s) => put(`${base}/social/youtube/settings`, s),
@@ -8163,6 +8179,9 @@ var list = (xs, n = 5) => {
8163
8179
  };
8164
8180
  var ids = (a) => (Array.isArray(a.ids) && a.ids.length ? a.ids : a.id != null ? [a.id] : []).map(Number);
8165
8181
  var keys = (a) => Object.keys(a ?? {}).filter((k) => a[k] !== void 0);
8182
+ var videoChannels = (a) => (Array.isArray(a.channels) && a.channels.length ? a.channels : ["youtube"]).map(
8183
+ (c) => c === "tiktok" ? "TikTok" : "YouTube"
8184
+ );
8166
8185
  var confirmCopy = {
8167
8186
  // --------------------------------------------------------- account / setup
8168
8187
  website_add: {
@@ -8348,9 +8367,23 @@ var confirmCopy = {
8348
8367
  en: () => "Make a link to connect your YouTube channel.",
8349
8368
  "zh-Hant": () => "\u7522\u751F\u9023\u63A5\u4F60 YouTube \u983B\u9053\u7684\u9023\u7D50\u3002"
8350
8369
  },
8370
+ tiktok_connect_link: {
8371
+ en: () => "Make a link to connect your TikTok account.",
8372
+ "zh-Hant": () => "\u7522\u751F\u9023\u63A5\u4F60 TikTok \u5E33\u865F\u7684\u9023\u7D50\u3002"
8373
+ },
8351
8374
  social_video_add: {
8352
- en: (a) => `Make a YouTube post from ${a.url}${a.write === false ? "" : " (Maggie writes the title and description: one AI generation)"}; it waits for your OK.`,
8353
- "zh-Hant": (a) => `\u7528 ${a.url} \u505A\u4E00\u5247 YouTube \u5F71\u7247\u8CBC\u6587${a.write === false ? "" : "\uFF08Maggie \u5BEB\u6A19\u984C\u548C\u8AAA\u660E\uFF1A\u7528\u4E00\u6B21 AI \u751F\u6210\uFF09"}\uFF0C\u7B49\u4F60\u78BA\u8A8D\u5F8C\u624D\u767C\u3002`
8375
+ en: (a) => {
8376
+ const names = videoChannels(a).join(" and ");
8377
+ return `Make a ${names} post from ${a.url}${a.write === false ? "" : ` (Maggie writes it: one AI generation per channel)`}; it waits for your OK.`;
8378
+ },
8379
+ "zh-Hant": (a) => {
8380
+ const names = videoChannels(a).join(" \u548C ");
8381
+ return `\u7528 ${a.url} \u505A ${names} \u5F71\u7247\u8CBC\u6587${a.write === false ? "" : "\uFF08Maggie \u4F86\u5BEB\uFF1A\u6BCF\u500B\u6E20\u9053\u7528\u4E00\u6B21 AI \u751F\u6210\uFF09"}\uFF0C\u7B49\u4F60\u78BA\u8A8D\u5F8C\u624D\u767C\u3002`;
8382
+ }
8383
+ },
8384
+ social_tiktok_set: {
8385
+ en: (a) => `Set TikTok post #${a.id}: ${keys(a).filter((k) => k !== "id").map((k) => `${k} ${String(a[k])}`).join(", ") || "its settings"}.`,
8386
+ "zh-Hant": (a) => `\u8A2D\u5B9A TikTok \u8CBC\u6587 #${a.id}\uFF1A${keys(a).filter((k) => k !== "id").map((k) => `${k} ${String(a[k])}`).join("\u3001") || "\u8A2D\u5B9A"}\u3002`
8354
8387
  },
8355
8388
  social_youtube_set: {
8356
8389
  en: (a) => `Change YouTube post #${a.id}: ${keys(a).filter((k) => k !== "id").join(", ") || "its details"}.`,
@@ -10373,11 +10406,13 @@ var read5 = { resource: "autopilot", level: "read" };
10373
10406
  var write5 = { resource: "autopilot", level: "write" };
10374
10407
  var moves2 = ["up", "down", "top"];
10375
10408
  var CHANNEL_KEYS = ["linkedin", "facebook", "instagram", "google_business"];
10376
- var ALL_CHANNEL_KEYS = [...CHANNEL_KEYS, "youtube"];
10409
+ var ALL_CHANNEL_KEYS = [...CHANNEL_KEYS, "youtube", "tiktok"];
10410
+ var VIDEO_KEYS = ["youtube", "tiktok"];
10411
+ var TIKTOK_PRIVACY = ["PUBLIC_TO_EVERYONE", "MUTUAL_FOLLOW_FRIENDS", "FOLLOWER_OF_CREATOR", "SELF_ONLY"];
10377
10412
  var channelsParam = {
10378
10413
  type: "array",
10379
10414
  items: { type: "string", enum: CHANNEL_KEYS },
10380
- description: "Which channels to write for: linkedin, facebook, instagram, google_business. Leave out to write for every connected channel (one post each, one credit each); give one only when the user names it. YouTube takes a video: use social_video_add."
10415
+ description: "Which channels to write for: linkedin, facebook, instagram, google_business. Leave out to write for every connected channel (one post each, one credit each); give one only when the user names it. YouTube and TikTok take a video: use social_video_add."
10381
10416
  };
10382
10417
  var channelsOf = (value) => {
10383
10418
  const list2 = Array.isArray(value) ? value.map((v) => String(v).toLowerCase()).filter((v) => CHANNEL_KEYS.includes(v)) : [];
@@ -10404,6 +10439,10 @@ var item = (i) => ({
10404
10439
  ...i.provider === "youtube" ? {
10405
10440
  youtube: i.youtube ?? null,
10406
10441
  video: i.video ? { status: i.video.status, seconds: i.video.duration, shape: i.video.shape, error: i.video.error } : null
10442
+ } : {},
10443
+ ...i.provider === "tiktok" ? {
10444
+ tiktok: i.tiktok ?? null,
10445
+ video: i.video ? { status: i.video.status, seconds: i.video.duration, shape: i.video.shape, error: i.video.error } : null
10407
10446
  } : {}
10408
10447
  });
10409
10448
  var socialTools = [
@@ -11382,13 +11421,72 @@ var socialTools = [
11382
11421
  return { url: out.url, expires_in_seconds: out.expires_in_seconds };
11383
11422
  }
11384
11423
  }),
11424
+ tool({
11425
+ name: "tiktok_connect_link",
11426
+ description: "A link for the user to connect their TikTok account (or reconnect): they sign in to TikTok and allow Maggie to see their profile and post videos. Give them the link to open; never ask for a password. TikTok is in beta (testers only; until TikTok reviews our app, videos post as 'Only me' and the account must be private). TikTok posts are short videos (5-30 seconds) that the user approves one by one.",
11427
+ parameters: none,
11428
+ group: "social",
11429
+ need: write5,
11430
+ risk: "W1",
11431
+ gates: ["VER"],
11432
+ run: async (ctx) => {
11433
+ const out = await ws(ctx).connectTikTok("close");
11434
+ return { url: out.url, expires_in_seconds: out.expires_in_seconds };
11435
+ }
11436
+ }),
11437
+ tool({
11438
+ name: "tiktok_creator",
11439
+ description: "What the user's TikTok account allows right now (TikTok asks to check before every post): its name and @username, who a video can be shown to (privacy_options), whether comments / Duet / Stitch are turned off on the account, the longest video it can post, and whether it can post now (problem). Read it before asking the user the TikTok settings of a post.",
11440
+ parameters: none,
11441
+ group: "social",
11442
+ need: read5,
11443
+ risk: "R0",
11444
+ run: async (ctx) => ws(ctx).tiktokCreator()
11445
+ }),
11446
+ tool({
11447
+ name: "social_tiktok_set",
11448
+ description: "Set a TikTok post's settings, ONLY as the user chose them (TikTok's rules: never pick for them, nothing is preset): privacy (one of the account's privacy_options from tiktok_creator: PUBLIC_TO_EVERYONE, MUTUAL_FOLLOW_FRIENDS, FOLLOWER_OF_CREATOR, SELF_ONLY), allow_comment / allow_duet / allow_stitch (off unless the user turns them on; not possible when the account turned them off), disclose (the video promotes a brand, product or service) with your_brand (their own: labelled 'Promotional content') and / or branded (a third party: labelled 'Paid partnership'; can't be SELF_ONLY), is_aigc (AI-generated content label). The caption is the post's text (social_update_copy). Before the user approves, tell them: 'By posting, you agree to TikTok's Music Usage Confirmation' (with branded content: 'TikTok's Branded Content Policy and Music Usage Confirmation'). Preview first.",
11449
+ parameters: {
11450
+ type: "object",
11451
+ properties: {
11452
+ id: { type: "integer", description: "A TikTok post (from social_list)" },
11453
+ privacy: { type: "string", enum: TIKTOK_PRIVACY },
11454
+ allow_comment: { type: "boolean" },
11455
+ allow_duet: { type: "boolean" },
11456
+ allow_stitch: { type: "boolean" },
11457
+ disclose: { type: "boolean" },
11458
+ your_brand: { type: "boolean" },
11459
+ branded: { type: "boolean" },
11460
+ is_aigc: { type: "boolean" }
11461
+ },
11462
+ required: ["id"]
11463
+ },
11464
+ group: "social",
11465
+ need: write5,
11466
+ risk: "W1",
11467
+ gates: ["VER"],
11468
+ run: async (ctx, { id, privacy, ...rest }) => {
11469
+ const answers = Object.fromEntries(
11470
+ Object.entries(rest).filter(([, v]) => v !== void 0)
11471
+ );
11472
+ if (privacy) answers.privacy = privacy;
11473
+ const out = await ws(ctx).setSocialTikTok(Number(id), answers);
11474
+ return item(out);
11475
+ }
11476
+ }),
11385
11477
  tool({
11386
11478
  name: "social_video_add",
11387
- description: "Make a YouTube post from a video: a DIRECT link to a video file (an .mp4 on their website, a public Dropbox link), never a YouTube / TikTok / Instagram page (we never download those; tell the user to upload the video in the app instead). The video must be 5-30 seconds: give start/end (seconds) to use a part of a longer one. vertical: make a wide video vertical (a Short) cropped at left, middle or right. Maggie writes the title, description and tags from the video and the note (one AI generation) unless write is false. The post waits in Review: YouTube posts are always approved by the user, who must also answer whether it's made for kids. Preview first.",
11479
+ description: "Make a YouTube and / or TikTok post (channels; default youtube) from a video: a DIRECT link to a video file (an .mp4 on their website, a public Dropbox link), never a YouTube / TikTok / Instagram page (we never download those; tell the user to upload the video in the app instead). The video must be 5-30 seconds: give start/end (seconds) to use a part of a longer one. vertical: make a wide video vertical (a Short) cropped at left, middle or right. Maggie writes YouTube's title, description and tags, or TikTok's caption, from the video and the note (one AI generation per channel) unless write is false. Each post waits in Review: video posts are always approved by the user. YouTube asks whether it's made for kids; TikTok asks who can view it and the other TikTok settings (social_tiktok_set, as the user chooses). is_aigc: TikTok's AI-generated label, only when the user says the video was made with AI. Preview first.",
11388
11480
  parameters: {
11389
11481
  type: "object",
11390
11482
  properties: {
11391
11483
  url: { type: "string", description: "Direct https link to the video file" },
11484
+ channels: {
11485
+ type: "array",
11486
+ items: { type: "string", enum: [...VIDEO_KEYS] },
11487
+ description: "youtube, tiktok or both (one post each); default youtube"
11488
+ },
11489
+ is_aigc: { type: "boolean", description: "TikTok: the video is AI-generated (the user said so)" },
11392
11490
  note: { type: "string", description: "What the video is about, in the user's words" },
11393
11491
  write: { type: "boolean", description: "Let Maggie write the details (default true)" },
11394
11492
  start: { type: "number", description: "Start of the part to use, seconds" },
@@ -11416,11 +11514,28 @@ var socialTools = [
11416
11514
  }
11417
11515
  if (v.status !== "ready")
11418
11516
  return { ok: false, video: { status: v.status, error: v.error, seconds: v.source_duration } };
11419
- const post = await d.postFromVideo(v.id, { note: a.note ?? "", write: a.write !== false });
11517
+ const wanted = (a.channels ?? ["youtube"]).filter(
11518
+ (c) => VIDEO_KEYS.includes(c)
11519
+ );
11520
+ const posts2 = [];
11521
+ for (const channel of wanted.length ? wanted : ["youtube"]) {
11522
+ posts2.push(
11523
+ await d.postFromVideo(v.id, {
11524
+ channel,
11525
+ note: a.note ?? "",
11526
+ write: a.write !== false,
11527
+ ...channel === "tiktok" && a.is_aigc != null ? { is_aigc: a.is_aigc } : {}
11528
+ })
11529
+ );
11530
+ }
11420
11531
  return {
11421
11532
  ok: true,
11422
- post: item(post),
11423
- next: "Show the title and description; ask whether it's made for kids and which visibility, then social_youtube_set; the user approves it."
11533
+ ...posts2.length === 1 ? { post: item(posts2[0]) } : { posts: posts2.map(item) },
11534
+ next: [
11535
+ posts2.some((p) => p.provider === "youtube") ? "YouTube: show the title and description; ask whether it's made for kids and which visibility, then social_youtube_set." : "",
11536
+ posts2.some((p) => p.provider === "tiktok") ? "TikTok: show the caption; read tiktok_creator and ask who can view it, whether to allow comments / Duet / Stitch and whether it promotes a brand, then social_tiktok_set exactly as they say; tell them the Music Usage Confirmation line." : "",
11537
+ "The user approves each post."
11538
+ ].filter(Boolean).join(" ")
11424
11539
  };
11425
11540
  }
11426
11541
  }),
@@ -15094,7 +15209,7 @@ var program = new Command();
15094
15209
  // package.json
15095
15210
  var package_default = {
15096
15211
  name: "@cmo-so/cli",
15097
- version: "0.4.0",
15212
+ version: "0.5.0",
15098
15213
  description: "CMO.so on the command line: your websites, ideas, blog posts, LinkedIn queue and results, plus a local MCP server for Claude Desktop, Cursor and other MCP clients.",
15099
15214
  type: "module",
15100
15215
  license: "MIT",
@@ -23236,10 +23351,14 @@ posts.command("ls", { isDefault: true }).description("planned, draft or publishe
23236
23351
  posts.command("show <id>").description("one post in full").action(act(async (opts, id) => tool2(opts, "post_get", { id })));
23237
23352
  posts.command("publish <id>").description("publish a draft now (uses a post credit)").action(act(async (opts, id) => tool2(opts, "post_publish_now", { id })));
23238
23353
  posts.command("delete <id>").description("delete a draft").action(act(async (opts, id) => tool2(opts, "draft_delete", { id })));
23239
- var social = program2.command("social").description("your social posts: LinkedIn, your Facebook Page, Instagram, your Google Business Profile and YouTube");
23240
- var CHANNELS = ["linkedin", "facebook", "instagram", "google_business", "youtube"];
23354
+ var social = program2.command("social").description(
23355
+ "your social posts: LinkedIn, your Facebook Page, Instagram, your Google Business Profile, YouTube and TikTok"
23356
+ );
23357
+ var CHANNELS = ["linkedin", "facebook", "instagram", "google_business", "youtube", "tiktok"];
23241
23358
  var channelsOpt = (value) => {
23242
- const list2 = (value ?? "").split(",").map((v) => v.trim().toLowerCase()).map((v) => v === "google" || v === "gbp" ? "google_business" : v === "yt" || v === "shorts" ? "youtube" : v).filter((v) => CHANNELS.includes(v));
23359
+ const list2 = (value ?? "").split(",").map((v) => v.trim().toLowerCase()).map(
23360
+ (v) => v === "google" || v === "gbp" ? "google_business" : v === "yt" || v === "shorts" ? "youtube" : v === "tt" ? "tiktok" : v
23361
+ ).filter((v) => CHANNELS.includes(v));
23243
23362
  return list2.length ? list2 : void 0;
23244
23363
  };
23245
23364
  social.command("ls", { isDefault: true }).description("drafts to review and queued posts").action(
@@ -23270,7 +23389,7 @@ for (const [cmd, paused] of [
23270
23389
  ["resume", false]
23271
23390
  ])
23272
23391
  social.command(cmd).description(
23273
- `${cmd} posting (every channel, or --channel linkedin | facebook | instagram | google_business | youtube)`
23392
+ `${cmd} posting (every channel, or --channel linkedin | facebook | instagram | google_business | youtube | tiktok)`
23274
23393
  ).option("--channel <name>", "only this channel").action(
23275
23394
  act(
23276
23395
  async (opts) => tool2(opts, "social_set_paused", {
@@ -23308,6 +23427,49 @@ youtube.command("set <id>").description("a YouTube post's title, tags, visibilit
23308
23427
  )
23309
23428
  );
23310
23429
  youtube.command("settings").description("your YouTube defaults (visibility, made for kids)").action(act(async (opts) => tool2(opts, "youtube_settings")));
23430
+ var tiktok = social.command("tiktok").description("your TikTok account (beta): short videos you approve one by one");
23431
+ tiktok.command("connect").description("a link to connect your TikTok account").action(act(async (opts) => tool2(opts, "tiktok_connect_link")));
23432
+ tiktok.command("account").description("what your TikTok account allows now: who can view, comments / Duet / Stitch, longest video").action(act(async (opts) => tool2(opts, "tiktok_creator")));
23433
+ tiktok.command("add <url>").description("a TikTok post from a direct link to a video file (5-30 s): Maggie writes the caption").option("--note <text>", "what the video is about").option("--start <seconds>", "use the part from here").option("--end <seconds>", "use the part up to here").option("--vertical <where>", "make a wide video vertical: left, middle or right").option("--ai", "the video is AI-generated (TikTok labels it)").option("--no-write", "write the caption yourself").action(
23434
+ act(
23435
+ async (opts, url) => tool2(opts, "social_video_add", {
23436
+ url,
23437
+ channels: ["tiktok"],
23438
+ ...opts.note ? { note: opts.note } : {},
23439
+ ...opts.start ? { start: Number(opts.start) } : {},
23440
+ ...opts.end ? { end: Number(opts.end) } : {},
23441
+ ...opts.vertical ? { vertical: opts.vertical } : {},
23442
+ ...opts.ai ? { is_aigc: true } : {},
23443
+ write: opts.write !== false
23444
+ })
23445
+ )
23446
+ );
23447
+ tiktok.command("set <id>").description("a TikTok post's settings, as you choose them (nothing is preset)").option("--privacy <p>", "everyone, friends, followers or only-me (what your account offers)").option("--comment <yes|no>").option("--duet <yes|no>").option("--stitch <yes|no>").option("--promotes <what>", "none, your-brand, branded or both (content disclosure)").option("--ai <yes|no>", "AI-generated content label").action(
23448
+ act(
23449
+ async (opts, id) => {
23450
+ const privacy = {
23451
+ everyone: "PUBLIC_TO_EVERYONE",
23452
+ friends: "MUTUAL_FOLLOW_FRIENDS",
23453
+ followers: "FOLLOWER_OF_CREATOR",
23454
+ "only-me": "SELF_ONLY"
23455
+ }[String(opts.privacy ?? "").toLowerCase()];
23456
+ const p = opts.promotes?.toLowerCase();
23457
+ return tool2(opts, "social_tiktok_set", {
23458
+ id: ids2([id])[0],
23459
+ ...privacy ? { privacy } : {},
23460
+ ...opts.comment ? { allow_comment: opts.comment === "yes" } : {},
23461
+ ...opts.duet ? { allow_duet: opts.duet === "yes" } : {},
23462
+ ...opts.stitch ? { allow_stitch: opts.stitch === "yes" } : {},
23463
+ ...opts.ai ? { is_aigc: opts.ai === "yes" } : {},
23464
+ ...p ? {
23465
+ disclose: p !== "none",
23466
+ your_brand: p === "your-brand" || p === "both",
23467
+ branded: p === "branded" || p === "both"
23468
+ } : {}
23469
+ });
23470
+ }
23471
+ )
23472
+ );
23311
23473
  var autopilot = program2.command("autopilot").description("the blog autopilot");
23312
23474
  autopilot.command("status", { isDefault: true }).description("on or paused, posts per day, where it publishes").action(act(async (opts) => tool2(opts, "publish_settings_get")));
23313
23475
  for (const [cmd, paused] of [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmo-so/cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "CMO.so on the command line: your websites, ideas, blog posts, LinkedIn queue and results, plus a local MCP server for Claude Desktop, Cursor and other MCP clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",