@cmo-so/cli 0.2.0 → 0.4.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 +716 -44
  2. package/package.json +1 -1
package/dist/cmo.mjs CHANGED
@@ -7473,7 +7473,15 @@ function dataUrl(type, bytes) {
7473
7473
  }
7474
7474
 
7475
7475
  // ../../packages/api-client/src/domains.ts
7476
- var MEMORY_CHANNELS = ["general", "blog", "linkedin", "facebook"];
7476
+ var MEMORY_CHANNELS = [
7477
+ "general",
7478
+ "blog",
7479
+ "linkedin",
7480
+ "facebook",
7481
+ "instagram",
7482
+ "google_business",
7483
+ "youtube"
7484
+ ];
7477
7485
  function addWebsite(api2, url) {
7478
7486
  return api2.request("/v1/domains", {
7479
7487
  method: "POST",
@@ -7592,8 +7600,15 @@ function domainApi(api2, domain) {
7592
7600
  approveSocial: (id) => post(`${base}/social/${id}/approve`),
7593
7601
  skipSocial: (id) => post(`${base}/social/${id}/skip`),
7594
7602
  /** Post it on LinkedIn now, not at the next posting time (even while posting is paused). */
7595
- publishSocialNow: (id) => post(`${base}/social/${id}/publish`),
7603
+ /** Post it now. `background`: the reply comes at once (status "publishing") and it goes out behind the
7604
+ * scenes (a notice when it's out); 409 `picture_busy` while its picture is being made. */
7605
+ publishSocialNow: (id, opts = {}) => post(
7606
+ `${base}/social/${id}/publish`,
7607
+ opts.background ? { background: true } : void 0
7608
+ ),
7596
7609
  /** Take a posted LinkedIn post down (its likes and comments go with it). */
7610
+ /** How a posted Instagram post is doing (read from Instagram, kept 15 minutes; `refresh` reads again). */
7611
+ socialInsights: (id, refresh = false) => api2.request(`${base}/social/${id}/insights${refresh ? "?refresh=true" : ""}`),
7597
7612
  deletePostedSocial: (id) => api2.request(`${base}/social/${id}/published`, { method: "DELETE" }),
7598
7613
  /** Change a posted LinkedIn post and put it up again: the old one comes down, the new text goes out now. */
7599
7614
  republishSocial: (id, socialCopy) => post(`${base}/social/${id}/republish`, socialCopy ? { social_copy: socialCopy } : {}),
@@ -7629,10 +7644,10 @@ function domainApi(api2, domain) {
7629
7644
  /** The template library, searchable. */
7630
7645
  socialTemplates: (search = "") => api2.request(`${base}/social/templates?search=${encodeURIComponent(search)}`),
7631
7646
  socialTemplatePreview: (key) => api2.request(`${base}/social/templates/${encodeURIComponent(key)}/preview`),
7632
- socialSetupTemplates: (keys3, writing) => api2.request(`${base}/social/setup/templates`, {
7647
+ socialSetupTemplates: (keys3, writing2) => api2.request(`${base}/social/setup/templates`, {
7633
7648
  method: "PUT",
7634
7649
  headers: { "Content-Type": "application/json" },
7635
- body: JSON.stringify({ keys: keys3, writing })
7650
+ body: JSON.stringify({ keys: keys3, writing: writing2 })
7636
7651
  }),
7637
7652
  socialSetupSchedule: (schedule) => api2.request(`${base}/social/setup/schedule`, {
7638
7653
  method: "PUT",
@@ -7674,6 +7689,49 @@ function domainApi(api2, domain) {
7674
7689
  }
7675
7690
  ),
7676
7691
  disconnectFacebook: (connectionId) => api2.request(`${base}/social/facebook/${connectionId}`, { method: "DELETE" }),
7692
+ /** Instagram connects through the Facebook sign-in (the accounts linked to your Pages): the same link;
7693
+ * back with ?facebook=connected, then `channels` says whether an Instagram account was found. */
7694
+ connectInstagram: (returnTo = "close") => post(`${base}/social/instagram/connect`, { return_to: returnTo }),
7695
+ /** Your Instagram accounts here (each with the Facebook Page it posts through), and the chosen one. */
7696
+ instagramAccounts: () => api2.request(`${base}/social/instagram/accounts`),
7697
+ chooseInstagramAccount: (connectionId) => api2.request(
7698
+ `${base}/social/instagram/account`,
7699
+ {
7700
+ method: "PUT",
7701
+ headers: { "Content-Type": "application/json" },
7702
+ body: JSON.stringify({ connection_id: connectionId })
7703
+ }
7704
+ ),
7705
+ disconnectInstagram: (connectionId) => api2.request(`${base}/social/instagram/${connectionId}`, { method: "DELETE" }),
7706
+ /** A Google sign-in link for this website's Google Business Profile; back with ?google_business=connected
7707
+ * (or none / error&message=…). Every profile the account can post to is saved; this website's is picked. */
7708
+ connectGoogleBusiness: (returnTo = "close") => post(`${base}/social/google_business/connect`, {
7709
+ return_to: returnTo
7710
+ }),
7711
+ /** Your Google Business profiles here (name, address, website), and the one this website posts to. */
7712
+ googleBusinessLocations: () => api2.request(`${base}/social/google_business/locations`),
7713
+ chooseGoogleBusinessLocation: (connectionId) => put(
7714
+ `${base}/social/google_business/location`,
7715
+ { connection_id: connectionId }
7716
+ ),
7717
+ /** How the Google Business Profile is doing: the last 28 days and the 28 before (Google lags 2-3 days). */
7718
+ googleBusinessPerformance: (refresh = false) => api2.request(`${base}/social/google_business/performance${refresh ? "?refresh=true" : ""}`),
7719
+ disconnectGoogleBusiness: (connectionId) => api2.request(`${base}/social/google_business/${connectionId}`, { method: "DELETE" }),
7720
+ /** A Google sign-in link for this website's YouTube channel (docs/prd/youtube.md §7); back with ?youtube=connected
7721
+ * (or none when the Google account has no channel, error&message=…). */
7722
+ connectYouTube: (returnTo = "close") => post(`${base}/social/youtube/connect`, { return_to: returnTo }),
7723
+ /** Your YouTube channels here (name, @handle, picture, subscribers), and the one this website posts to. */
7724
+ youtubeChannels: () => api2.request(
7725
+ `${base}/social/youtube/channels`
7726
+ ),
7727
+ chooseYouTubeChannel: (connectionId) => put(
7728
+ `${base}/social/youtube/channel`,
7729
+ {
7730
+ connection_id: connectionId
7731
+ }
7732
+ ),
7733
+ /** Disconnect: the token is deleted and Google's access revoked (YouTube's policy). */
7734
+ disconnectYouTube: (connectionId) => api2.request(`${base}/social/youtube/${connectionId}`, { method: "DELETE" }),
7677
7735
  /** One channel's own pause switch (pauseSocial / resumeSocial hold every channel). */
7678
7736
  setChannelPaused: (channel, paused) => post(`${base}/social/channels/${channel}/${paused ? "pause" : "resume"}`),
7679
7737
  /** How often one channel posts. */
@@ -7683,14 +7741,56 @@ function domainApi(api2, domain) {
7683
7741
  ),
7684
7742
  /** Start a new picture for the post in the background (one AI generation); `replace` stops the one
7685
7743
  * already running; `instruction` (up to 300 characters) steers it: "gold border, our logo". */
7744
+ // `mode: "edit"` changes the post's current picture as `instruction` says. Another picture
7745
+ // being made here: this one waits its turn (status queued).
7746
+ // `count: 4` makes a set of 4 pictures from one storyboard (one AI generation), with words on each in
7747
+ // `textEffect` (an id from socialTextEffects; omit = Maggie picks).
7686
7748
  regenerateSocialImage: (id, opts = {}) => post(`${base}/social/${id}/image/regenerate`, {
7749
+ ...opts.style ? { style: opts.style } : {},
7687
7750
  ...opts.replace ? { replace: true } : {},
7751
+ ...opts.instruction?.trim() ? { instruction: opts.instruction.trim() } : {},
7752
+ ...opts.mode === "edit" ? { mode: "edit" } : {},
7753
+ ...opts.count && opts.count > 1 ? { count: opts.count } : {},
7754
+ ...opts.textEffect ? { text_effect: opts.textEffect } : {}
7755
+ }),
7756
+ /** Change a picture Maggie made without a new one (free): the words on each picture, its style, its text
7757
+ * style, the order of a set, or drop pictures from it. `words` follow the new order when `order` is given. */
7758
+ editSocialPicture: (id, changes) => api2.request(`${base}/social/${id}/picture`, {
7759
+ method: "PATCH",
7760
+ headers: { "Content-Type": "application/json" },
7761
+ body: JSON.stringify(changes)
7762
+ }),
7763
+ /** A title and a line on your own photo(s) in your look (Maggie plans the words; no AI picture, free). */
7764
+ wordsOnPhoto: (id, style = "real_photo") => post(`${base}/social/${id}/picture/words`, { style }),
7765
+ /** The brand's picture look (made the first time it's asked for). */
7766
+ socialLook: () => api2.request(`${base}/social/look`),
7767
+ updateSocialLook: (changes) => put(`${base}/social/look`, changes),
7768
+ /** Maggie looks again and suggests a new look (one AI generation). */
7769
+ suggestSocialLook: () => post(`${base}/social/look/suggest`, {}),
7770
+ /** A sample picture of a style in the brand's look: a data: URL. */
7771
+ socialLookSample: (style) => api2.request(`${base}/social/look/sample?style=${encodeURIComponent(style)}`),
7772
+ /** The text effects for the words on a set of pictures, each with a sample picture. */
7773
+ socialTextEffects: () => api2.request(`${base}/social/text-effects`),
7774
+ /** Your own photo (base64 JPEG) as the post's picture: no AI, no charge; only before it goes out.
7775
+ * With `instruction`, Maggie changes the photo as it says, in the background (one AI generation). */
7776
+ uploadSocialPhoto: (id, photo, opts = {}) => post(`${base}/social/${id}/image`, {
7777
+ photo,
7688
7778
  ...opts.instruction?.trim() ? { instruction: opts.instruction.trim() } : {}
7689
7779
  }),
7690
- /** Your own photo (base64 JPEG) as the post's picture: no AI, no charge; only before it goes out. */
7691
- uploadSocialPhoto: (id, photo) => post(`${base}/social/${id}/image`, { photo }),
7692
- /** Stop the picture being made (it's thrown away). */
7693
- stopSocialImage: () => api2.request(`${base}/social/image-job`, { method: "DELETE" }),
7780
+ /** A new picture for every post here without one (or these), one after another in the background. */
7781
+ fillSocialImages: (opts = {}) => post(
7782
+ `${base}/social/images/fill`,
7783
+ {
7784
+ ...opts.item_ids ? { item_ids: opts.item_ids } : {},
7785
+ ...opts.instruction?.trim() ? { instruction: opts.instruction.trim() } : {},
7786
+ ...opts.count && opts.count > 1 ? { count: opts.count } : {},
7787
+ ...opts.textEffect ? { text_effect: opts.textEffect } : {}
7788
+ }
7789
+ ),
7790
+ /** Stop the picture being made (it's thrown away; the next in line starts). `all` empties the line too. */
7791
+ stopSocialImage: (all = false) => api2.request(`${base}/social/image-job${all ? "?all=true" : ""}`, {
7792
+ method: "DELETE"
7793
+ }),
7694
7794
  /** Maggie changes the post as asked, in 3-255 characters (one AI generation). */
7695
7795
  rewriteSocial: (id, instruction) => post(`${base}/social/${id}/rewrite`, { instruction }),
7696
7796
  /** Maggie plans and writes a series; it waits for one OK. */
@@ -7703,13 +7803,35 @@ function domainApi(api2, domain) {
7703
7803
  brief: brief2,
7704
7804
  ...channels ? { channels } : {}
7705
7805
  }),
7806
+ // In the background: the answer is the job at once; watch `write_jobs` in GET /social.
7807
+ startSocialFromPhotos: (photos, brief2 = "", channels) => post(`${base}/social/from-photos`, {
7808
+ photos,
7809
+ brief: brief2,
7810
+ background: true,
7811
+ ...channels ? { channels } : {}
7812
+ }),
7813
+ startSocialFromPost: (sourcePostId, channels) => post(`${base}/social/from-post`, {
7814
+ source_post_id: sourcePostId,
7815
+ background: true,
7816
+ ...channels ? { channels } : {}
7817
+ }),
7818
+ startSocialPlan: (days, timezone, channels) => post(`${base}/social/plan`, {
7819
+ days,
7820
+ timezone,
7821
+ background: true,
7822
+ ...channels ? { channels } : {}
7823
+ }),
7824
+ startWriteSocialIdea: (id, channels) => post(`${base}/social/ideas/${id}/write`, {
7825
+ background: true,
7826
+ ...channels ? { channels } : {}
7827
+ }),
7706
7828
  /** Disconnect the website's LinkedIn account. */
7707
7829
  disconnectLinkedIn: (connectionId) => api2.request(`${base}/social/linkedin/${connectionId}`, { method: "DELETE" }),
7708
7830
  /** Published articles a LinkedIn post can be made from. */
7709
7831
  socialSources: (search = "") => api2.request(
7710
7832
  `${base}/social/sources?search=${encodeURIComponent(search)}`
7711
7833
  ),
7712
- /** Maggie writes a LinkedIn draft about one article. */
7834
+ /** Maggie writes a post about one article for each channel; `failed` lists a channel that could not be written while the others were. */
7713
7835
  socialFromPost: (sourcePostId, channels) => post(`${base}/social/from-post`, {
7714
7836
  source_post_id: sourcePostId,
7715
7837
  ...channels ? { channels } : {}
@@ -7768,13 +7890,49 @@ function domainApi(api2, domain) {
7768
7890
  headers: { "Content-Type": "application/json" },
7769
7891
  body: JSON.stringify({ publish_mode: mode })
7770
7892
  }),
7893
+ /** A Google Business post's button (LEARN_MORE, BOOK, ORDER, SHOP, SIGN_UP, CALL); "" = Learn more. */
7894
+ setSocialButton: (id, ctaType) => api2.request(`${base}/social/${id}`, {
7895
+ method: "PATCH",
7896
+ headers: { "Content-Type": "application/json" },
7897
+ body: JSON.stringify({ cta_type: ctaType })
7898
+ }),
7899
+ /** Make a Google Business post an Event or Offer (or back to an update with { type: "STANDARD" }). */
7900
+ setSocialGooglePost: (id, googlePost) => api2.request(`${base}/social/${id}`, {
7901
+ method: "PATCH",
7902
+ headers: { "Content-Type": "application/json" },
7903
+ body: JSON.stringify({ google_post: googlePost })
7904
+ }),
7771
7905
  resumeSocial: () => post(`${base}/social/resume`),
7906
+ /** Start a video upload: PUT each part_size slice of the file to its url, keep the ETags, then completeVideoUpload. */
7907
+ startVideoUpload: (file) => post(
7908
+ `${base}/social/video/upload`,
7909
+ file
7910
+ ),
7911
+ completeVideoUpload: (videoId, parts, edit) => post(`${base}/social/video/${videoId}/complete`, { parts, edit }),
7912
+ /** A direct link to a video file (not a YouTube / TikTok page). */
7913
+ videoFromLink: (url, edit) => post(`${base}/social/video/link`, { url, edit }),
7914
+ video: (videoId) => api2.request(`${base}/social/video/${videoId}`),
7915
+ /** Another part or framing; prepared again in the background. */
7916
+ 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. */
7918
+ postFromVideo: (videoId, opts = {}) => post(`${base}/social/video/${videoId}/post`, opts),
7919
+ youtubeSettings: () => api2.request(`${base}/social/youtube/settings`),
7920
+ setYouTubeSettings: (s) => put(`${base}/social/youtube/settings`, s),
7921
+ /** A YouTube post's title, tags, visibility, made-for-kids or altered-content answer. */
7922
+ setSocialYouTube: (id, answers) => api2.request(`${base}/social/${id}`, {
7923
+ method: "PATCH",
7924
+ headers: { "Content-Type": "application/json" },
7925
+ body: JSON.stringify({ youtube: answers })
7926
+ }),
7772
7927
  pauseAutopilot: () => post(`${base}/autopilot/pause`),
7773
7928
  resumeAutopilot: () => post(`${base}/autopilot/resume`),
7774
7929
  // Reports (docs/18 §6): report:read with the user's own key.
7775
7930
  visibility: () => api2.request(`${base}/visibility`),
7776
7931
  searchConsole: (period2 = "30d") => api2.request(`${base}/search-console?period=${period2}`),
7777
7932
  searchConsoleQueries: (period2 = "30d", filter = "top", limit = 20) => api2.request(`${base}/search-console/queries?period=${period2}&filter=${filter}&limit=${limit}`),
7933
+ /** A Google sign-in link that connects Search Console for this website (open it in a
7934
+ * browser; back at returnTo with ?gsc=connected or ?gsc=error&message=…). 10 minutes. */
7935
+ connectSearchConsole: (returnTo = "close") => post(`${base}/search-console/connect`, { return_to: returnTo }),
7778
7936
  /** Fresh numbers from Google now; at most once an hour per website. */
7779
7937
  syncSearchConsole: () => post(`${base}/search-console/sync`),
7780
7938
  contentPerformance: (sort = "clicks", band, limit = 20) => api2.request(
@@ -8186,6 +8344,22 @@ var confirmCopy = {
8186
8344
  en: (a) => `Bring back LinkedIn post #${a.id}.`,
8187
8345
  "zh-Hant": (a) => `\u6062\u5FA9 LinkedIn \u8CBC\u6587 #${a.id}\u3002`
8188
8346
  },
8347
+ youtube_connect_link: {
8348
+ en: () => "Make a link to connect your YouTube channel.",
8349
+ "zh-Hant": () => "\u7522\u751F\u9023\u63A5\u4F60 YouTube \u983B\u9053\u7684\u9023\u7D50\u3002"
8350
+ },
8351
+ 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`
8354
+ },
8355
+ social_youtube_set: {
8356
+ en: (a) => `Change YouTube post #${a.id}: ${keys(a).filter((k) => k !== "id").join(", ") || "its details"}.`,
8357
+ "zh-Hant": (a) => `\u4FEE\u6539 YouTube \u8CBC\u6587 #${a.id}\uFF1A${keys(a).filter((k) => k !== "id").join("\u3001") || "\u7D30\u7BC0"}\u3002`
8358
+ },
8359
+ youtube_settings_set: {
8360
+ en: (a) => `Change your YouTube defaults: ${keys(a).join(", ") || "nothing"}.`,
8361
+ "zh-Hant": (a) => `\u4FEE\u6539 YouTube \u9810\u8A2D\uFF1A${keys(a).join("\u3001") || "\u7121"}\u3002`
8362
+ },
8189
8363
  social_image_new: {
8190
8364
  en: (a) => `Make a new picture for LinkedIn post #${a.id}${a.instruction ? `: ${String(a.instruction).slice(0, 300)}` : ""} (1 AI generation, in the background)${a.replace ? ", stopping the one being made for another post" : ""}.`,
8191
8365
  "zh-Hant": (a) => `\u70BA LinkedIn \u8CBC\u6587 #${a.id} \u751F\u6210\u65B0\u5716\u7247${a.instruction ? `\uFF1A${String(a.instruction).slice(0, 300)}` : ""}\uFF08\u7528 1 \u6B21 AI \u751F\u6210\uFF0C\u5728\u80CC\u666F\u9032\u884C\uFF09${a.replace ? "\uFF0C\u4E26\u505C\u6B62\u6B63\u5728\u70BA\u53E6\u4E00\u7BC7\u751F\u6210\u7684\u5716\u7247" : ""}\u3002`
@@ -9719,7 +9893,7 @@ var brief = (m) => ({
9719
9893
  var memoryTools = [
9720
9894
  tool({
9721
9895
  name: "memory_get",
9722
- description: "The user's Maggie Memory on this website: their saved taste per channel (general, blog, linkedin, facebook) as prefer / always / never items, each with an id. Already in your instructions when it is on; read it to answer what you remember or to find an id to forget.",
9896
+ description: "The user's Maggie Memory on this website: their saved taste per channel (general, blog, linkedin, facebook, instagram, google_business) as prefer / always / never items, each with an id. Already in your instructions when it is on; read it to answer what you remember or to find an id to forget.",
9723
9897
  parameters: none,
9724
9898
  group: "memory",
9725
9899
  need: own,
@@ -10017,9 +10191,21 @@ var reportTools = [
10017
10191
  };
10018
10192
  }
10019
10193
  }),
10194
+ tool({
10195
+ name: "gsc_connect_link",
10196
+ description: "A Google sign-in link for the user to connect Google Search Console for this website (or reconnect). Give them the link to open; never ask for their Google password. They must sign in with a Google account that can see this website in Search Console; if it can't, the page says which account and how to add it.",
10197
+ parameters: none,
10198
+ group: "reports",
10199
+ need: { resource: "autopilot", level: "write" },
10200
+ risk: "W1",
10201
+ run: async (ctx) => {
10202
+ const out = await ws(ctx).connectSearchConsole("close");
10203
+ return { url: out.url, expires_in_seconds: out.expires_in_seconds };
10204
+ }
10205
+ }),
10020
10206
  tool({
10021
10207
  name: "gsc_performance_get",
10022
- description: "Google Search Console for the period (30d, 90d or 12m): clicks, impressions, CTR and average position, with the change against the period before, the daily trend and the top pages.",
10208
+ description: "Google Search Console for the period (30d, 90d or 12m): clicks, impressions, CTR and average position, with the change against the period before (clicks and impressions as a ratio: -0.25 = 25% fewer, null when there was nothing before; ctr in points as a fraction; position in places, lower is better), the daily trend and the top pages.",
10023
10209
  parameters: { type: "object", properties: { period: { type: "string", enum: periods } } },
10024
10210
  group: "reports",
10025
10211
  need: read4,
@@ -10186,16 +10372,24 @@ var reportTools = [
10186
10372
  var read5 = { resource: "autopilot", level: "read" };
10187
10373
  var write5 = { resource: "autopilot", level: "write" };
10188
10374
  var moves2 = ["up", "down", "top"];
10189
- var CHANNEL_KEYS = ["linkedin", "facebook"];
10375
+ var CHANNEL_KEYS = ["linkedin", "facebook", "instagram", "google_business"];
10376
+ var ALL_CHANNEL_KEYS = [...CHANNEL_KEYS, "youtube"];
10190
10377
  var channelsParam = {
10191
10378
  type: "array",
10192
10379
  items: { type: "string", enum: CHANNEL_KEYS },
10193
- description: "Which channels to write for: linkedin, facebook. Leave out to write for every connected channel (one post each, one credit each); give one only when the user names it."
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."
10194
10381
  };
10195
10382
  var channelsOf = (value) => {
10196
10383
  const list2 = Array.isArray(value) ? value.map((v) => String(v).toLowerCase()).filter((v) => CHANNEL_KEYS.includes(v)) : [];
10197
10384
  return list2.length ? list2 : void 0;
10198
10385
  };
10386
+ var writing = (job) => ({
10387
+ job_id: job.id,
10388
+ status: "writing",
10389
+ posts_expected: job.expected,
10390
+ channels: job.channels,
10391
+ note: "Maggie is writing in the background (a minute or two). Tell the user they'll be told when it's ready; social_write_status says when it's done."
10392
+ });
10199
10393
  var item = (i) => ({
10200
10394
  id: i.id,
10201
10395
  channel: i.provider || "linkedin",
@@ -10206,7 +10400,11 @@ var item = (i) => ({
10206
10400
  campaign: i.campaign ?? null,
10207
10401
  failure: i.failure_message ?? null,
10208
10402
  link: i.provider_permalink ?? null,
10209
- text: clip(i.social_copy, 300)
10403
+ text: clip(i.social_copy, 300),
10404
+ ...i.provider === "youtube" ? {
10405
+ youtube: i.youtube ?? null,
10406
+ video: i.video ? { status: i.video.status, seconds: i.video.duration, shape: i.video.shape, error: i.video.error } : null
10407
+ } : {}
10210
10408
  });
10211
10409
  var socialTools = [
10212
10410
  tool({
@@ -10314,7 +10512,7 @@ var socialTools = [
10314
10512
  }),
10315
10513
  tool({
10316
10514
  name: "social_image_new",
10317
- description: "Make a new picture for a LinkedIn post that hasn't gone out (uses 1 AI generation). It is made in the background, on the user's own ChatGPT when their Maggie Bridge has images on, else by CMO.so; it takes up to a couple of minutes and appears on the post by itself (check with social_image_status). One picture is made at a time per website: if another is being made this fails with image_busy; only pass replace: true when the user agrees to stop that one. A post written from an article gets its own picture (from its text and the article's title) and then goes out as that picture.",
10515
+ description: "Make a new picture for a social post that hasn't gone out, or change its current one (mode: edit, as `instruction` says). Uses 1 AI generation. It is made in the background, on the user's own ChatGPT when their Maggie Bridge has images on, else by CMO.so; it takes up to a couple of minutes and appears on the post by itself (check with social_image_status). One picture is made at a time per website: while another is being made this one waits in line (status queued). It fails with image_busy only when this post already has one being made or in line; pass replace: true only when the user agrees to stop the one being made and make this one now. A post written from an article gets its own picture (from its text and the article's title) and then goes out as that picture. Every new picture carries a short title and line set on it; count: 4 makes a set of 4 pictures that tell one story (still 1 AI generation, drawn as one storyboard and cut); LinkedIn and Facebook post a set together as a collage. text_effect picks the style of those words (an id from social_text_effects); leave it out to let Maggie pick. style picks the picture style (an id from social_look: photo_headline, editorial, duotone, illustrated, bold_type, infographic); leave it out and Maggie takes turns with the brand's 3. bold_type and infographic make no AI picture (big words or a list in the brand's look) and cost nothing.",
10318
10516
  parameters: {
10319
10517
  type: "object",
10320
10518
  properties: {
@@ -10323,6 +10521,23 @@ var socialTools = [
10323
10521
  instruction: {
10324
10522
  type: "string",
10325
10523
  description: "What the user wants in the picture, in their words (up to 300 characters), e.g. 'gold border, our logo, Future 100 \xB7 2025'. Leave out when they gave no direction."
10524
+ },
10525
+ mode: {
10526
+ type: "string",
10527
+ enum: ["new", "edit"],
10528
+ description: "edit: change the post's current picture as the instruction says (it must have one)"
10529
+ },
10530
+ count: {
10531
+ type: "integer",
10532
+ description: "1 (default) or 4: a set of 4 pictures telling one story, a line of words on each"
10533
+ },
10534
+ text_effect: {
10535
+ type: "string",
10536
+ description: "For a set: the words' style id from social_text_effects (omit = Maggie picks)"
10537
+ },
10538
+ style: {
10539
+ type: "string",
10540
+ description: "Picture style id from social_look (omit = Maggie picks from the brand's 3)"
10326
10541
  }
10327
10542
  },
10328
10543
  required: ["id"]
@@ -10331,36 +10546,253 @@ var socialTools = [
10331
10546
  need: write5,
10332
10547
  risk: "W2",
10333
10548
  gates: ["VER", "CR"],
10334
- run: async (ctx, { id, replace, instruction }) => {
10549
+ run: async (ctx, { id, replace, instruction, mode, count, text_effect, style }) => {
10335
10550
  const out = await ws(ctx).regenerateSocialImage(Number(id), {
10336
10551
  replace: replace === true,
10552
+ ...typeof style === "string" && style.trim() && mode !== "edit" ? { style: style.trim() } : {},
10553
+ ...mode === "edit" ? { mode: "edit" } : {},
10554
+ ...Number(count) === 4 && mode !== "edit" ? { count: 4 } : {},
10555
+ ...typeof text_effect === "string" && text_effect.trim() ? { textEffect: text_effect.trim() } : {},
10337
10556
  ...typeof instruction === "string" && instruction.trim() ? { instruction: instruction.trim().slice(0, 300) } : {}
10338
10557
  });
10339
10558
  return {
10340
10559
  id: out.id,
10341
10560
  image_job: out.image_job,
10342
- note: "Making it in the background; it shows on the post when ready."
10561
+ note: out.image_job?.status === "queued" ? "In line after the picture being made now; it shows on the post when ready." : "Making it in the background; it shows on the post when ready."
10562
+ };
10563
+ }
10564
+ }),
10565
+ tool({
10566
+ name: "social_images_fill",
10567
+ description: "A new picture for every social post here that hasn't gone out and has none (or only these ids), made one after another in the background: 1 AI generation each. A LinkedIn and a Facebook post of the same idea share one picture. Says how many are in line, how many already were, and why it stopped early (the line is full, or the day's AI generations ran out). Preview the count first.",
10568
+ parameters: {
10569
+ type: "object",
10570
+ properties: {
10571
+ ids: { type: "array", items: { type: "integer" }, description: "Only these posts (from social_list)" },
10572
+ instruction: { type: "string", description: "What the user wants in every picture, up to 300 characters" }
10573
+ }
10574
+ },
10575
+ group: "social",
10576
+ need: write5,
10577
+ risk: "W2",
10578
+ gates: ["VER", "CR"],
10579
+ run: async (ctx, { ids: ids3, instruction }) => {
10580
+ const out = await ws(ctx).fillSocialImages({
10581
+ ...Array.isArray(ids3) && ids3.length ? { item_ids: ids3.map(Number) } : {},
10582
+ ...typeof instruction === "string" && instruction.trim() ? { instruction: instruction.trim().slice(0, 300) } : {}
10583
+ });
10584
+ return { queued: out.queued, already: out.skipped, stopped_because: out.message, line: out.image_jobs.length };
10585
+ }
10586
+ }),
10587
+ tool({
10588
+ name: "social_text_effects",
10589
+ description: "The styles for the words on a set of pictures (social_image_new with count 4): id, name, family and a sample picture URL. Use when the user wants to choose how the words look ('bold sticker', 'neon', 'gold').",
10590
+ parameters: none,
10591
+ group: "social",
10592
+ need: read5,
10593
+ risk: "R0",
10594
+ run: async (ctx) => {
10595
+ const out = await ws(ctx).socialTextEffects();
10596
+ return { effects: out.effects.map(({ id, name, family }) => ({ id, name, family })), auto: out.auto };
10597
+ }
10598
+ }),
10599
+ tool({
10600
+ name: "social_look",
10601
+ description: "The brand's picture look on this website (made the first time it's asked for): the 3 picture styles Maggie takes turns with, the 5 text styles she picks from per picture, two fonts, the colours (ink, paper, primary, accent, muted), a short description of how its photos look, and things never to show; plus every style, font and text style that can be chosen. Read it before changing the look or when the user asks how their pictures look.",
10602
+ parameters: none,
10603
+ group: "social",
10604
+ need: read5,
10605
+ risk: "R0",
10606
+ run: async (ctx) => {
10607
+ const l = await ws(ctx).socialLook();
10608
+ return {
10609
+ styles: l.styles.map((s) => ({ id: s.id, name: s.name, about: s.about })),
10610
+ text_effects: l.text_effects.map((e) => ({ id: e.id, name: e.name, family: e.family })),
10611
+ fonts: l.fonts,
10612
+ colours: l.colours,
10613
+ description: l.brand_suffix,
10614
+ never: l.never,
10615
+ why: l.suggested.reason ?? null,
10616
+ can_choose: {
10617
+ styles: l.catalogue.styles.map((s) => ({ id: s.id, name: s.name, led: s.led, needs_photo: s.needs_photo })),
10618
+ fonts: l.catalogue.fonts,
10619
+ text_effect_families: [...new Set(l.catalogue.text_effects.map((e) => e.family))]
10620
+ }
10343
10621
  };
10344
10622
  }
10345
10623
  }),
10624
+ tool({
10625
+ name: "social_look_update",
10626
+ description: "Change the brand's picture look: the 3 styles Maggie takes turns with (style_ids, 1-3), the text styles (text_effect_ids, 1-5, ids from social_text_effects), fonts, colours (hex), the description of how photos look, things never to show, or reset: true (back to Maggie's suggestion). New pictures use it; pictures already made keep theirs (social_picture_edit changes one). Preview the change first.",
10627
+ parameters: {
10628
+ type: "object",
10629
+ properties: {
10630
+ style_ids: { type: "array", items: { type: "string" }, description: "1-3 picture style ids" },
10631
+ text_effect_ids: { type: "array", items: { type: "string" }, description: "1-5 text style ids" },
10632
+ font_display: { type: "string", description: "Font for big words (from social_look can_choose.fonts)" },
10633
+ font_body: { type: "string", description: "Font for lines and lists" },
10634
+ colours: {
10635
+ type: "object",
10636
+ description: "Any of these as #RRGGBB",
10637
+ properties: {
10638
+ ink: { type: "string", description: "Text on paper" },
10639
+ paper: { type: "string", description: "The light ground" },
10640
+ primary: { type: "string", description: "The brand colour" },
10641
+ accent: { type: "string", description: "A second colour" },
10642
+ muted: { type: "string", description: "Small text" }
10643
+ }
10644
+ },
10645
+ description: { type: "string", description: "How the brand's photos look, up to 600 characters" },
10646
+ never: { type: "array", items: { type: "string" }, description: "Things never to show (the whole list)" },
10647
+ reset: { type: "boolean", description: "Back to Maggie's suggested look" }
10648
+ }
10649
+ },
10650
+ group: "social",
10651
+ need: write5,
10652
+ risk: "W1",
10653
+ gates: ["VER"],
10654
+ run: async (ctx, a) => {
10655
+ const fonts = {
10656
+ ...a.font_display ? { display: a.font_display } : {},
10657
+ ...a.font_body ? { body: a.font_body } : {}
10658
+ };
10659
+ const l = await ws(ctx).updateSocialLook({
10660
+ ...a.style_ids ? { style_ids: a.style_ids } : {},
10661
+ ...a.text_effect_ids ? { text_effect_ids: a.text_effect_ids } : {},
10662
+ ...Object.keys(fonts).length ? { fonts } : {},
10663
+ ...a.colours ? { colours: a.colours } : {},
10664
+ ...typeof a.description === "string" ? { brand_suffix: a.description } : {},
10665
+ ...a.never ? { never: a.never } : {},
10666
+ ...a.reset ? { reset: true } : {}
10667
+ });
10668
+ return {
10669
+ styles: l.styles.map((s) => s.id),
10670
+ text_effects: l.text_effects.map((e) => e.id),
10671
+ fonts: l.fonts,
10672
+ colours: l.colours
10673
+ };
10674
+ }
10675
+ }),
10676
+ tool({
10677
+ name: "social_picture_edit",
10678
+ description: "Change a picture Maggie made for a post that hasn't gone out, without making a new one (free, a few seconds): the words on each picture (title up to 60 characters, line up to 90), its picture style, its text style, or for a set the order (indexes, 0 = first) or pictures to drop. Only posts whose picture says editable in social_list; a photo style needs the picture's photos (has_photos). Changing the words of one picture: send every picture's words in order. Preview first.",
10679
+ parameters: {
10680
+ type: "object",
10681
+ properties: {
10682
+ id: { type: "integer", description: "The post (from social_list)" },
10683
+ words: {
10684
+ type: "array",
10685
+ items: {
10686
+ type: "object",
10687
+ properties: { headline: { type: "string" }, sub: { type: "string" } },
10688
+ required: ["headline"]
10689
+ },
10690
+ description: "The words on each picture, in order (in the new order when order is given)"
10691
+ },
10692
+ style: { type: "string", description: "A picture style id from social_look" },
10693
+ text_effect: { type: "string", description: "A text style id from social_text_effects" },
10694
+ order: { type: "array", items: { type: "integer" }, description: "The pictures in their new order" },
10695
+ remove: { type: "array", items: { type: "integer" }, description: "Pictures to drop from a set" }
10696
+ },
10697
+ required: ["id"]
10698
+ },
10699
+ group: "social",
10700
+ need: write5,
10701
+ risk: "W1",
10702
+ gates: ["VER"],
10703
+ run: async (ctx, { id, words, style, text_effect, order, remove: remove2 }) => {
10704
+ const out = await ws(ctx).editSocialPicture(Number(id), {
10705
+ ...Array.isArray(words) ? { words: words.map((w) => ({ headline: String(w.headline ?? ""), sub: String(w.sub ?? "") })) } : {},
10706
+ ...style ? { style } : {},
10707
+ ...text_effect ? { text_effect } : {},
10708
+ ...Array.isArray(order) ? { order: order.map(Number) } : {},
10709
+ ...Array.isArray(remove2) ? { remove: remove2.map(Number) } : {}
10710
+ });
10711
+ return { id: out.id, pictures: out.image_urls?.length ? out.image_urls : [out.image_url], picture: out.picture };
10712
+ }
10713
+ }),
10714
+ tool({
10715
+ name: "social_photo_words",
10716
+ description: "Put a title and a line on the user's own photo(s) on a post, in the brand's look: Maggie writes the words from the post (no AI picture, free). Only for a post whose picture is the user's own photo (own_photo in social_list). style: real_photo (default, the photo framed with the words below), product_hero (the words on a card), or another photo style. Then social_picture_edit changes the words. Preview first.",
10717
+ parameters: {
10718
+ type: "object",
10719
+ properties: {
10720
+ id: { type: "integer", description: "The post (from social_list)" },
10721
+ style: {
10722
+ type: "string",
10723
+ description: "real_photo (default), product_hero, photo_headline, editorial, duotone"
10724
+ }
10725
+ },
10726
+ required: ["id"]
10727
+ },
10728
+ group: "social",
10729
+ need: write5,
10730
+ risk: "W1",
10731
+ gates: ["VER"],
10732
+ run: async (ctx, { id, style }) => {
10733
+ const out = await ws(ctx).wordsOnPhoto(Number(id), style || "real_photo");
10734
+ return { id: out.id, picture: out.picture, pictures: out.image_urls?.length ? out.image_urls : [out.image_url] };
10735
+ }
10736
+ }),
10737
+ tool({
10738
+ name: "social_post_insights",
10739
+ description: "How a posted Instagram post is doing: views, reach, likes, comments, saves and shares, read from Instagram (kept 15 minutes; refresh: true reads again). Saves and shares per reach are the best signs of a good post. available: false says why (not posted yet, deleted on Instagram, the account needs reconnecting).",
10740
+ parameters: {
10741
+ type: "object",
10742
+ properties: {
10743
+ id: { type: "integer", description: "A posted Instagram post (from social_list posted)" },
10744
+ refresh: { type: "boolean", description: "Read the numbers again now" }
10745
+ },
10746
+ required: ["id"]
10747
+ },
10748
+ group: "social",
10749
+ need: read5,
10750
+ risk: "R0",
10751
+ run: async (ctx, { id, refresh }) => ws(ctx).socialInsights(Number(id), refresh === true)
10752
+ }),
10753
+ tool({
10754
+ name: "social_write_status",
10755
+ description: "Posts Maggie is writing in the background for this user on this website (from social_from_article, social_plan_days, social_idea_write or the app), and the ones finished in the last 10 minutes: running, done (the new post ids) or failed (why), and any channel that couldn't be written. Look once when the user asks, not in a loop.",
10756
+ parameters: none,
10757
+ group: "social",
10758
+ need: read5,
10759
+ risk: "R0",
10760
+ run: async (ctx) => ({
10761
+ jobs: ((await ws(ctx).social()).write_jobs ?? []).map((j) => ({
10762
+ id: j.id,
10763
+ kind: j.kind,
10764
+ status: j.status,
10765
+ channels: j.channels,
10766
+ expected: j.expected,
10767
+ written: j.item_ids,
10768
+ queued: j.queued,
10769
+ ...j.failed?.length ? { failed: j.failed } : {},
10770
+ ...j.error ? { error: j.error } : {},
10771
+ started_at: j.started_at
10772
+ }))
10773
+ })
10774
+ }),
10346
10775
  tool({
10347
10776
  name: "social_image_status",
10348
- description: "Whether a new LinkedIn picture is being made on this website (which post, since when), or how the last one ended (done, failed with why, stopped) and who drew it (chatgpt or gemini).",
10777
+ description: "The picture being made on this website and those waiting in line (which post, new or edit), or how the last one ended (done, failed with why, stopped) and who drew it (chatgpt or gemini).",
10349
10778
  parameters: none,
10350
10779
  group: "social",
10351
10780
  need: read5,
10352
10781
  risk: "R0",
10353
- run: async (ctx) => ({ image_job: (await ws(ctx).social()).image_job ?? null })
10782
+ run: async (ctx) => {
10783
+ const s = await ws(ctx).social();
10784
+ return { image_job: s.image_job ?? null, line: s.image_jobs ?? [] };
10785
+ }
10354
10786
  }),
10355
10787
  tool({
10356
10788
  name: "social_image_stop",
10357
- description: "Stop the LinkedIn picture being made on this website; the post keeps the picture it had.",
10358
- parameters: none,
10789
+ description: "Stop the picture being made on this website (the post keeps the picture it had; the next in line starts). all: true also empties the line.",
10790
+ parameters: { type: "object", properties: { all: { type: "boolean" } } },
10359
10791
  group: "social",
10360
10792
  need: write5,
10361
10793
  risk: "W1",
10362
10794
  gates: ["VER"],
10363
- run: async (ctx) => ws(ctx).stopSocialImage()
10795
+ run: async (ctx, { all }) => ws(ctx).stopSocialImage(all === true)
10364
10796
  }),
10365
10797
  tool({
10366
10798
  name: "social_move",
@@ -10381,7 +10813,7 @@ var socialTools = [
10381
10813
  description: "Pause or resume the user's social posting: one channel (linkedin or facebook), or every channel when no channel is given.",
10382
10814
  parameters: {
10383
10815
  type: "object",
10384
- properties: { paused: { type: "boolean" }, channel: { type: "string", enum: CHANNEL_KEYS } },
10816
+ properties: { paused: { type: "boolean" }, channel: { type: "string", enum: ALL_CHANNEL_KEYS } },
10385
10817
  required: ["paused"]
10386
10818
  },
10387
10819
  group: "social",
@@ -10404,7 +10836,7 @@ var socialTools = [
10404
10836
  }),
10405
10837
  tool({
10406
10838
  name: "social_from_article",
10407
- description: "Maggie writes a post about one published article (id from social_sources_list) for each channel. It waits for the user's OK as a draft, unless their approval mode is auto (then it goes to the front of the queue).",
10839
+ description: "Maggie writes a post about one published article (id from social_sources_list) for each channel. It waits for the user's OK as a draft, unless their approval mode is auto (then it goes to the front of the queue). Written in the background (a minute or two): this returns at once with a job. Tell the user Maggie is writing and they will be told when it's ready; before saying what was written, check social_write_status (then social_list for the posts).",
10408
10840
  parameters: {
10409
10841
  type: "object",
10410
10842
  properties: {
@@ -10418,14 +10850,11 @@ var socialTools = [
10418
10850
  need: write5,
10419
10851
  risk: "W2",
10420
10852
  gates: ["VER", "LI", "LLM"],
10421
- run: async (ctx, { source_id, channels }) => {
10422
- const out = await ws(ctx).socialFromPost(String(source_id), channelsOf(channels));
10423
- return { id: out.id, status: out.status, queued: Boolean(out.queued), text: clip(out.social_copy, 300) };
10424
- }
10853
+ run: async (ctx, { source_id, channels }) => writing((await ws(ctx).startSocialFromPost(String(source_id), channelsOf(channels))).job)
10425
10854
  }),
10426
10855
  tool({
10427
10856
  name: "social_plan_days",
10428
- description: "Maggie writes posts for the next 1\u20137 days from the best recent articles, on each channel. They wait for the user's OK as drafts, unless the user's approval mode is auto (then they are queued in order).",
10857
+ description: "Maggie writes posts for the next 1\u20137 days from the best recent articles, on each channel. They wait for the user's OK as drafts, unless the user's approval mode is auto (then they are queued in order). Written in the background (a minute or two): this returns at once with a job. Tell the user Maggie is writing and they will be told when it's ready; before saying what was written, check social_write_status (then social_list for the posts).",
10429
10858
  parameters: {
10430
10859
  type: "object",
10431
10860
  properties: {
@@ -10439,10 +10868,7 @@ var socialTools = [
10439
10868
  need: write5,
10440
10869
  risk: "W2",
10441
10870
  gates: ["VER", "LI", "LLM"],
10442
- run: async (ctx, { days, timezone, channels }) => {
10443
- const out = await ws(ctx).socialPlan(int(days, 1, 7, 3), timezone || "UTC", channelsOf(channels));
10444
- return { written: out.items.length, queued: Boolean(out.queued), items: out.items.map(item) };
10445
- }
10871
+ run: async (ctx, { days, timezone, channels }) => writing((await ws(ctx).startSocialPlan(int(days, 1, 7, 3), timezone || "UTC", channelsOf(channels))).job)
10446
10872
  }),
10447
10873
  tool({
10448
10874
  name: "social_ideas_list",
@@ -10515,7 +10941,7 @@ var socialTools = [
10515
10941
  }),
10516
10942
  tool({
10517
10943
  name: "social_idea_write",
10518
- description: "Maggie writes one idea's post for each channel (1 credit per post). The user's own idea's posts wait for their OK (queued straight away only in approval mode auto); a campaign's wait for the campaign to start.",
10944
+ description: "Maggie writes one idea's post for each channel (1 credit per post). The user's own idea's posts wait for their OK (queued straight away only in approval mode auto); a campaign's wait for the campaign to start. Written in the background (a minute or two): this returns at once with a job. Tell the user Maggie is writing and they will be told when it's ready; before saying what was written, check social_write_status (then social_list for the posts).",
10519
10945
  parameters: {
10520
10946
  type: "object",
10521
10947
  properties: {
@@ -10529,7 +10955,7 @@ var socialTools = [
10529
10955
  need: write5,
10530
10956
  risk: "W2",
10531
10957
  gates: ["VER", "LI", "CR", "LLM"],
10532
- run: async (ctx, { id, channels }) => ws(ctx).writeSocialIdea(Number(id), void 0, channelsOf(channels))
10958
+ run: async (ctx, { id, channels }) => writing((await ws(ctx).startWriteSocialIdea(Number(id), channelsOf(channels))).job)
10533
10959
  }),
10534
10960
  tool({
10535
10961
  name: "social_idea_brief",
@@ -10826,9 +11252,9 @@ var socialTools = [
10826
11252
  run: async (ctx, { keys: keys3, ...options }) => {
10827
11253
  const api2 = ws(ctx);
10828
11254
  const current = (await api2.socialSetup()).writing;
10829
- const writing = { ...current };
10830
- for (const [k, v] of Object.entries(options)) if (v !== void 0) writing[k] = v;
10831
- return api2.socialSetupTemplates((keys3 ?? []).slice(0, 10), writing);
11255
+ const writing2 = { ...current };
11256
+ for (const [k, v] of Object.entries(options)) if (v !== void 0) writing2[k] = v;
11257
+ return api2.socialSetupTemplates((keys3 ?? []).slice(0, 10), writing2);
10832
11258
  }
10833
11259
  }),
10834
11260
  tool({
@@ -10909,6 +11335,220 @@ var socialTools = [
10909
11335
  const out = await ws(ctx).connectFacebook("close");
10910
11336
  return { url: out.url, expires_in_seconds: out.expires_in_seconds };
10911
11337
  }
11338
+ }),
11339
+ tool({
11340
+ name: "google_business_connect_link",
11341
+ description: "A link for the user to connect their Google Business Profile (or reconnect): they sign in with the Google account that manages the profile; every profile it can post to is saved and the one whose website is this site is picked (else they pick it in the app). Only verified profiles can post. Give them the link to open; never ask for a password. Google posts are short local updates with one photo and a button; Google checks each one before it shows.",
11342
+ parameters: none,
11343
+ group: "social",
11344
+ need: write5,
11345
+ risk: "W1",
11346
+ gates: ["VER"],
11347
+ run: async (ctx) => {
11348
+ const out = await ws(ctx).connectGoogleBusiness("close");
11349
+ return { url: out.url, expires_in_seconds: out.expires_in_seconds };
11350
+ }
11351
+ }),
11352
+ tool({
11353
+ name: "social_google_button",
11354
+ description: "Set the button on a Google Business post that hasn't gone out: LEARN_MORE (default, opens the post's link), BOOK (a booking link), ORDER, SHOP, SIGN_UP, or CALL (calls the profile's phone number; needs no link). Pick the one that matches what the post asks people to do. Preview first.",
11355
+ parameters: {
11356
+ type: "object",
11357
+ properties: {
11358
+ id: { type: "integer", description: "A Google Business post (from social_list)" },
11359
+ button: { type: "string", enum: ["LEARN_MORE", "BOOK", "ORDER", "SHOP", "SIGN_UP", "CALL"] }
11360
+ },
11361
+ required: ["id", "button"]
11362
+ },
11363
+ group: "social",
11364
+ need: write5,
11365
+ risk: "W1",
11366
+ gates: ["VER"],
11367
+ run: async (ctx, { id, button }) => {
11368
+ const out = await ws(ctx).setSocialButton(Number(id), button);
11369
+ return { id: out.id, button: out.cta_type ?? "LEARN_MORE", link: out.cta_url ?? null };
11370
+ }
11371
+ }),
11372
+ tool({
11373
+ name: "youtube_connect_link",
11374
+ description: "A link for the user to connect their YouTube channel (or reconnect): they sign in with the Google account that owns the channel and allow Maggie to upload videos and see the channel. Give them the link to open; never ask for a password. YouTube posts are short videos (5-30 seconds now) that the user approves one by one.",
11375
+ parameters: none,
11376
+ group: "social",
11377
+ need: write5,
11378
+ risk: "W1",
11379
+ gates: ["VER"],
11380
+ run: async (ctx) => {
11381
+ const out = await ws(ctx).connectYouTube("close");
11382
+ return { url: out.url, expires_in_seconds: out.expires_in_seconds };
11383
+ }
11384
+ }),
11385
+ tool({
11386
+ 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.",
11388
+ parameters: {
11389
+ type: "object",
11390
+ properties: {
11391
+ url: { type: "string", description: "Direct https link to the video file" },
11392
+ note: { type: "string", description: "What the video is about, in the user's words" },
11393
+ write: { type: "boolean", description: "Let Maggie write the details (default true)" },
11394
+ start: { type: "number", description: "Start of the part to use, seconds" },
11395
+ end: { type: "number", description: "End of the part to use, seconds" },
11396
+ vertical: { type: "string", enum: ["left", "middle", "right"] }
11397
+ },
11398
+ required: ["url"]
11399
+ },
11400
+ group: "social",
11401
+ need: write5,
11402
+ risk: "W2",
11403
+ gates: ["VER", "LLM"],
11404
+ run: async (ctx, a) => {
11405
+ const d = ws(ctx);
11406
+ const edit = {
11407
+ ...a.start != null ? { start: Number(a.start) } : {},
11408
+ ...a.end != null ? { end: Number(a.end) } : {},
11409
+ ...a.vertical ? { aspect: "9:16", crop_x: a.vertical === "left" ? 0 : a.vertical === "right" ? 1 : 0.5 } : {}
11410
+ };
11411
+ let v = await d.videoFromLink(String(a.url), Object.keys(edit).length ? edit : void 0);
11412
+ const until = Date.now() + 15e4;
11413
+ while ((v.status === "checking" || v.status === "uploading") && Date.now() < until) {
11414
+ await new Promise((r) => setTimeout(r, 3e3));
11415
+ v = await d.video(v.id);
11416
+ }
11417
+ if (v.status !== "ready")
11418
+ 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 });
11420
+ return {
11421
+ 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."
11424
+ };
11425
+ }
11426
+ }),
11427
+ tool({
11428
+ name: "social_youtube_set",
11429
+ description: "Change a YouTube post that hasn't gone out: title (at most 100 characters, aim 40-60), tags, visibility (public, unlisted, private), made_for_kids (YouTube asks for every video: ask the user, never guess) or synthetic (realistic AI-made or altered content). The description is the post's text (social_update_copy). Preview first.",
11430
+ parameters: {
11431
+ type: "object",
11432
+ properties: {
11433
+ id: { type: "integer", description: "A YouTube post (from social_list)" },
11434
+ title: { type: "string" },
11435
+ tags: { type: "array", items: { type: "string" } },
11436
+ privacy: { type: "string", enum: ["public", "unlisted", "private"] },
11437
+ made_for_kids: { type: "boolean" },
11438
+ synthetic: { type: "boolean" }
11439
+ },
11440
+ required: ["id"]
11441
+ },
11442
+ group: "social",
11443
+ need: write5,
11444
+ risk: "W1",
11445
+ gates: ["VER"],
11446
+ run: async (ctx, { id, ...rest }) => {
11447
+ const answers = Object.fromEntries(
11448
+ Object.entries(rest).filter(([, v]) => v !== void 0)
11449
+ );
11450
+ const out = await ws(ctx).setSocialYouTube(Number(id), answers);
11451
+ return item(out);
11452
+ }
11453
+ }),
11454
+ tool({
11455
+ name: "youtube_settings",
11456
+ description: "The user's YouTube defaults for new posts on this website: visibility, made_for_kids (null = asked each time), category and altered content.",
11457
+ parameters: none,
11458
+ group: "social",
11459
+ need: read5,
11460
+ risk: "R0",
11461
+ run: async (ctx) => ws(ctx).youtubeSettings()
11462
+ }),
11463
+ tool({
11464
+ name: "youtube_settings_set",
11465
+ description: "Change the YouTube defaults for new posts: privacy (public, unlisted, private), made_for_kids (yes / no for every video, or ask per video) and synthetic. Only what the user says. Preview first.",
11466
+ parameters: {
11467
+ type: "object",
11468
+ properties: {
11469
+ privacy: { type: "string", enum: ["public", "unlisted", "private"] },
11470
+ made_for_kids: {
11471
+ type: "string",
11472
+ enum: ["yes", "no", "ask"],
11473
+ description: "yes / no for every new video, or ask (answer per video)"
11474
+ },
11475
+ synthetic: { type: "boolean" }
11476
+ }
11477
+ },
11478
+ group: "social",
11479
+ need: write5,
11480
+ risk: "W1",
11481
+ gates: ["VER"],
11482
+ run: async (ctx, a) => ws(ctx).setYouTubeSettings({
11483
+ ...a.privacy ? { privacy: a.privacy } : {},
11484
+ ...a.made_for_kids ? { made_for_kids: a.made_for_kids === "ask" ? null : a.made_for_kids === "yes" } : {},
11485
+ ...a.synthetic != null ? { synthetic: a.synthetic } : {}
11486
+ })
11487
+ }),
11488
+ tool({
11489
+ name: "google_business_performance",
11490
+ description: "How the website's Google Business Profile is doing: views on Google Search and Maps, website clicks, calls and direction requests for the last 28 days next to the 28 before (Google's numbers lag 2-3 days). Use it when the user asks how their Google listing or local presence is doing, or to show what Google posts are worth. Compare with the previous 28 days; don't invent reasons for changes.",
11491
+ parameters: {
11492
+ type: "object",
11493
+ properties: { refresh: { type: "boolean", description: "Read Google again now (else up to 6 hours old)" } }
11494
+ },
11495
+ group: "social",
11496
+ need: read5,
11497
+ risk: "R0",
11498
+ run: async (ctx, { refresh }) => ws(ctx).googleBusinessPerformance(refresh === true)
11499
+ }),
11500
+ tool({
11501
+ name: "social_google_post_type",
11502
+ description: "Make a Google Business post that hasn't gone out an EVENT (an open day, a workshop: title up to 58 characters, start and end dates YYYY-MM-DD, optional times HH:MM) or an OFFER (title, dates, optional coupon code, terms and redeem link; Google adds a View offer button), or back to STANDARD (an update). Offers are refused for regulated categories (finance, health, alcohol, gambling) and hotels: use an update or an event. Only real dates and offers the user gave. Preview first.",
11503
+ parameters: {
11504
+ type: "object",
11505
+ properties: {
11506
+ id: { type: "integer", description: "A Google Business post (from social_list)" },
11507
+ type: { type: "string", enum: ["STANDARD", "EVENT", "OFFER"] },
11508
+ title: { type: "string", description: "Event or offer title, up to 58 characters" },
11509
+ start: { type: "string", description: "YYYY-MM-DD" },
11510
+ end: { type: "string", description: "YYYY-MM-DD (defaults to start)" },
11511
+ start_time: { type: "string", description: "HH:MM (optional)" },
11512
+ end_time: { type: "string", description: "HH:MM (optional)" },
11513
+ coupon: { type: "string", description: "Offer code (optional)" },
11514
+ terms: { type: "string", description: "Offer terms (optional)" },
11515
+ redeem_url: { type: "string", description: "Where to redeem the offer online (optional)" }
11516
+ },
11517
+ required: ["id", "type"]
11518
+ },
11519
+ group: "social",
11520
+ need: write5,
11521
+ risk: "W1",
11522
+ gates: ["VER"],
11523
+ run: async (ctx, a) => {
11524
+ const type = String(a.type).toUpperCase();
11525
+ const body = type === "STANDARD" ? { type: "STANDARD" } : {
11526
+ type,
11527
+ title: String(a.title ?? ""),
11528
+ start: String(a.start ?? ""),
11529
+ ...a.end ? { end: a.end } : {},
11530
+ ...a.start_time ? { start_time: a.start_time } : {},
11531
+ ...a.end_time ? { end_time: a.end_time } : {},
11532
+ ...a.coupon ? { coupon: a.coupon } : {},
11533
+ ...a.terms ? { terms: a.terms } : {},
11534
+ ...a.redeem_url ? { redeem_url: a.redeem_url } : {}
11535
+ };
11536
+ const out = await ws(ctx).setSocialGooglePost(Number(a.id), body);
11537
+ return { id: out.id, google_post: out.google_post ?? null };
11538
+ }
11539
+ }),
11540
+ tool({
11541
+ name: "instagram_connect_link",
11542
+ description: "A link for the user to connect Instagram (or reconnect). Instagram connects through the Facebook sign-in: only an Instagram professional account (Business or Creator) linked to one of their Facebook Pages can be posted to, so tell them that first. Give them the link to open; never ask for a password. Every Instagram post goes out with its picture (no links in it).",
11543
+ parameters: none,
11544
+ group: "social",
11545
+ need: write5,
11546
+ risk: "W1",
11547
+ gates: ["VER"],
11548
+ run: async (ctx) => {
11549
+ const out = await ws(ctx).connectInstagram("close");
11550
+ return { url: out.url, expires_in_seconds: out.expires_in_seconds };
11551
+ }
10912
11552
  })
10913
11553
  ];
10914
11554
 
@@ -14454,7 +15094,7 @@ var program = new Command();
14454
15094
  // package.json
14455
15095
  var package_default = {
14456
15096
  name: "@cmo-so/cli",
14457
- version: "0.2.0",
15097
+ version: "0.4.0",
14458
15098
  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.",
14459
15099
  type: "module",
14460
15100
  license: "MIT",
@@ -22596,9 +23236,10 @@ posts.command("ls", { isDefault: true }).description("planned, draft or publishe
22596
23236
  posts.command("show <id>").description("one post in full").action(act(async (opts, id) => tool2(opts, "post_get", { id })));
22597
23237
  posts.command("publish <id>").description("publish a draft now (uses a post credit)").action(act(async (opts, id) => tool2(opts, "post_publish_now", { id })));
22598
23238
  posts.command("delete <id>").description("delete a draft").action(act(async (opts, id) => tool2(opts, "draft_delete", { id })));
22599
- var social = program2.command("social").description("your social posts: LinkedIn and your Facebook Page");
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"];
22600
23241
  var channelsOpt = (value) => {
22601
- const list2 = (value ?? "").split(",").map((v) => v.trim().toLowerCase()).filter((v) => v === "linkedin" || v === "facebook");
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));
22602
23243
  return list2.length ? list2 : void 0;
22603
23244
  };
22604
23245
  social.command("ls", { isDefault: true }).description("drafts to review and queued posts").action(
@@ -22606,7 +23247,7 @@ social.command("ls", { isDefault: true }).description("drafts to review and queu
22606
23247
  async (opts) => tool2(opts, "social_list", {}, (v) => {
22607
23248
  const s = v;
22608
23249
  const live = (s.channels ?? []).filter((c) => c.connected);
22609
- const head = !s.connected ? "No social channel is connected (LinkedIn or a Facebook Page)." : s.posting_paused ? "Posting is paused on every channel." : live.length ? live.map((c) => `${c.channel}: ${c.paused ? "paused" : "on"}${c.account ? ` (${c.account})` : ""}`).join(" \xB7 ") : "Posting is on.";
23250
+ const head = !s.connected ? "No social channel is connected (LinkedIn, a Facebook Page, Instagram or a Google Business Profile)." : s.posting_paused ? "Posting is paused on every channel." : live.length ? live.map((c) => `${c.channel}: ${c.paused ? "paused" : "on"}${c.account ? ` (${c.account})` : ""}`).join(" \xB7 ") : "Posting is on.";
22610
23251
  return `${head}
22611
23252
  ${table(s.queue ?? [], ["id", "channel", "status", "eta", "text"])}`;
22612
23253
  })
@@ -22615,7 +23256,7 @@ ${table(s.queue ?? [], ["id", "channel", "status", "eta", "text"])}`;
22615
23256
  social.command("approve <ids...>").description("approve drafts: they go out at the next posting times").action(act(async (opts, list2) => tool2(opts, "social_approve", { ids: ids2(list2) })));
22616
23257
  social.command("skip <id>").description("skip a draft").action(act(async (opts, id) => tool2(opts, "social_skip", { id: ids2([id])[0] })));
22617
23258
  social.command("restore <id>").description("bring a skipped draft back").action(act(async (opts, id) => tool2(opts, "social_restore", { id: ids2([id])[0] })));
22618
- social.command("draft <topic...>").description("add a post idea for Maggie to write (every connected channel unless --channel)").option("--summary <text>", "what the post should say").option("--channel <names>", "linkedin, facebook or both (comma-separated)").action(
23259
+ social.command("draft <topic...>").description("add a post idea for Maggie to write (every connected channel unless --channel)").option("--summary <text>", "what the post should say").option("--channel <names>", "linkedin, facebook, instagram, google_business (comma-separated)").action(
22619
23260
  act(
22620
23261
  async (opts, topic) => tool2(opts, "social_idea_add", {
22621
23262
  title: topic.join(" "),
@@ -22628,7 +23269,9 @@ for (const [cmd, paused] of [
22628
23269
  ["pause", true],
22629
23270
  ["resume", false]
22630
23271
  ])
22631
- social.command(cmd).description(`${cmd} posting (every channel, or --channel linkedin | facebook)`).option("--channel <name>", "only this channel").action(
23272
+ social.command(cmd).description(
23273
+ `${cmd} posting (every channel, or --channel linkedin | facebook | instagram | google_business | youtube)`
23274
+ ).option("--channel <name>", "only this channel").action(
22632
23275
  act(
22633
23276
  async (opts) => tool2(opts, "social_set_paused", {
22634
23277
  paused,
@@ -22636,6 +23279,35 @@ for (const [cmd, paused] of [
22636
23279
  })
22637
23280
  )
22638
23281
  );
23282
+ var youtube = social.command("youtube").description("your YouTube channel: short videos you approve one by one");
23283
+ youtube.command("connect").description("a link to connect your YouTube channel").action(act(async (opts) => tool2(opts, "youtube_connect_link")));
23284
+ youtube.command("add <url>").description("a YouTube post from a direct link to a video file (5-30 s): Maggie writes the title and description").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("--no-write", "write the title and description yourself").action(
23285
+ act(
23286
+ async (opts, url) => tool2(opts, "social_video_add", {
23287
+ url,
23288
+ ...opts.note ? { note: opts.note } : {},
23289
+ ...opts.start ? { start: Number(opts.start) } : {},
23290
+ ...opts.end ? { end: Number(opts.end) } : {},
23291
+ ...opts.vertical ? { vertical: opts.vertical } : {},
23292
+ write: opts.write !== false
23293
+ })
23294
+ )
23295
+ );
23296
+ youtube.command("set <id>").description("a YouTube post's title, tags, visibility, made-for-kids or altered-content answer").option("--title <text>").option("--tags <list>", "comma-separated").option("--privacy <p>", "public, unlisted or private").option("--kids <yes|no>", "made for kids").option("--synthetic <yes|no>", "realistic AI-made or altered content").action(
23297
+ act(
23298
+ async (opts, id) => tool2(opts, "social_youtube_set", {
23299
+ id: ids2([id])[0],
23300
+ ...opts.title ? { title: opts.title } : {},
23301
+ ...opts.tags ? {
23302
+ tags: opts.tags.split(",").map((t) => t.trim()).filter(Boolean)
23303
+ } : {},
23304
+ ...opts.privacy ? { privacy: opts.privacy } : {},
23305
+ ...opts.kids ? { made_for_kids: opts.kids === "yes" } : {},
23306
+ ...opts.synthetic ? { synthetic: opts.synthetic === "yes" } : {}
23307
+ })
23308
+ )
23309
+ );
23310
+ youtube.command("settings").description("your YouTube defaults (visibility, made for kids)").action(act(async (opts) => tool2(opts, "youtube_settings")));
22639
23311
  var autopilot = program2.command("autopilot").description("the blog autopilot");
22640
23312
  autopilot.command("status", { isDefault: true }).description("on or paused, posts per day, where it publishes").action(act(async (opts) => tool2(opts, "publish_settings_get")));
22641
23313
  for (const [cmd, paused] of [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmo-so/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.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",