@koda-sl/baker-cli 0.537.0 → 0.538.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.
package/README.md CHANGED
@@ -143,7 +143,7 @@ that prints its result beside `ok` rather than under `data` (`canvas validate`,
143
143
  ### The complete record: `--full`
144
144
 
145
145
  Commands with a compact default view declare `--full` to return every field
146
- (`baker ads meta ads|adsets|campaigns`, `images`, `winning-ads`, …). Every other command that
146
+ (`baker ads meta ads|adsets|campaigns|audiences|creatives`, `images`, `winning-ads`, …). Every other command that
147
147
  prints the JSON envelope accepts `--full` too: it already prints everything it returns, so
148
148
  the flag changes nothing and a hint in the envelope says so (on stderr when the command
149
149
  printed a readable view instead). Commands that print no data envelope (`canvas run`,
@@ -3,7 +3,7 @@ import {
3
3
  registerMetaListSchema,
4
4
  shapeMetaListRows,
5
5
  writeMetaListRows
6
- } from "./chunk-MFAFGQ7Z.js";
6
+ } from "./chunk-AGEWPMBR.js";
7
7
  import {
8
8
  csvOrJson,
9
9
  handleMetaError,
@@ -72,4 +72,4 @@ Examples:
72
72
  export {
73
73
  activitiesCommand
74
74
  };
75
- //# sourceMappingURL=activities-FXYVPCRJ.js.map
75
+ //# sourceMappingURL=activities-OC3CJX4I.js.map
@@ -3,7 +3,7 @@ import {
3
3
  registerMetaListSchema,
4
4
  shapeMetaListRows,
5
5
  writeMetaListRows
6
- } from "./chunk-MFAFGQ7Z.js";
6
+ } from "./chunk-AGEWPMBR.js";
7
7
  import {
8
8
  NAME_CONTAINS_ARG,
9
9
  csvOrJson,
@@ -117,4 +117,4 @@ Examples:
117
117
  export {
118
118
  adsListCommand
119
119
  };
120
- //# sourceMappingURL=ads-4O4TPDAU.js.map
120
+ //# sourceMappingURL=ads-HCK2GF2V.js.map
@@ -34,7 +34,7 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
34
34
  },
35
35
  subCommands: {
36
36
  google: () => import("./google-ZT3J3G4Z.js").then((m) => m.googleCommand),
37
- meta: () => import("./meta-CTKXBVXT.js").then((m) => m.metaCommand),
37
+ meta: () => import("./meta-MBW5LM5V.js").then((m) => m.metaCommand),
38
38
  linkedin: () => import("./linkedin-4BKZ5KUE.js").then((m) => m.linkedinCommand),
39
39
  x: () => import("./x-FPRMRQLQ.js").then((m) => m.xCommand),
40
40
  chatgpt: () => import("./chatgpt-GINMQJBI.js").then((m) => m.chatgptCommand),
@@ -45,4 +45,4 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
45
45
  export {
46
46
  adsCommand
47
47
  };
48
- //# sourceMappingURL=ads-CDA6DGGZ.js.map
48
+ //# sourceMappingURL=ads-LVAVF4QI.js.map
@@ -11,7 +11,7 @@ import {
11
11
  registerMetaListSchema,
12
12
  shapeMetaListRows,
13
13
  writeMetaListRows
14
- } from "./chunk-MFAFGQ7Z.js";
14
+ } from "./chunk-AGEWPMBR.js";
15
15
  import {
16
16
  NAME_CONTAINS_ARG,
17
17
  csvOrJson,
@@ -179,4 +179,4 @@ Examples:
179
179
  export {
180
180
  adsetsCommand
181
181
  };
182
- //# sourceMappingURL=adsets-OVFVN5NX.js.map
182
+ //# sourceMappingURL=adsets-TC2VPFXW.js.map
@@ -1,16 +1,20 @@
1
+ import {
2
+ META_LIST_SHAPE_ARGS,
3
+ registerMetaListSchema,
4
+ shapeMetaListRows,
5
+ writeMetaListRows
6
+ } from "./chunk-AGEWPMBR.js";
1
7
  import {
2
8
  csvOrJson,
3
9
  handleMetaError,
4
10
  resolveAccountIdArg
5
11
  } from "./chunk-KDDHMKTU.js";
6
12
  import "./chunk-QALAJNBG.js";
7
- import {
8
- writeAdsJson,
9
- writeAdsOutput
10
- } from "./chunk-EAHBTBVR.js";
13
+ import "./chunk-EAHBTBVR.js";
11
14
  import {
12
15
  NO_CACHE_ARG
13
16
  } from "./chunk-3PG7O3ZW.js";
17
+ import "./chunk-65Y3RCWP.js";
14
18
  import {
15
19
  apiGet
16
20
  } from "./chunk-C35UMKYG.js";
@@ -23,29 +27,39 @@ import "./chunk-YQSBHWOI.js";
23
27
  import { defineCommand } from "citty";
24
28
  var listArgs = {
25
29
  "account-id": { type: "string", description: "Meta ad account ID" },
26
- limit: { type: "string", description: "Max rows" },
30
+ "name-contains": {
31
+ type: "string",
32
+ description: "Only audiences whose name contains this text, matched by Meta before anything is returned: --name-contains Cerradas. A lookalike can be named anything, so find one audience's lookalikes with --seed <its id>"
33
+ },
34
+ seed: {
35
+ type: "string",
36
+ description: "Only the lookalikes built from this source audience id, whatever they are named: --seed 120240480760260208"
37
+ },
38
+ limit: { type: "string", description: "Max rows (default 500)" },
27
39
  "no-cache": NO_CACHE_ARG,
28
- output: { type: "string", description: "Output format: json|csv|jsonl|md", default: "json" }
40
+ ...META_LIST_SHAPE_ARGS
29
41
  };
42
+ registerMetaListSchema(
43
+ "audiences",
44
+ "List custom and lookalike audiences, as a table by default: id, name, subtype, size_min, size_max, retention_days, updated_date \u2014 plus delivery (why Meta says it cannot be used) and seed_id (the audience a lookalike was built from) when a row has one. The rule, data source and pixel are one --fields away (--fields id,name,rule) or --full. Start here to find one audience: baker ads meta audiences --name-contains <text>; then its lookalikes, whatever they are named: --seed <its id>. --output json returns the rows in the envelope.",
45
+ listArgs
46
+ );
30
47
  var listCommand = defineCommand({
31
48
  meta: {
32
49
  name: "list",
33
- description: "List custom audiences. Runs by default when no subcommand is given. Example: baker ads meta audiences --account-id act_123"
50
+ description: "List custom audiences. Runs by default when no subcommand is given. Example: baker ads meta audiences --name-contains buyers"
34
51
  },
35
52
  args: listArgs,
36
53
  run: async ({ args }) => {
37
54
  const accountId = await resolveAccountIdArg(args);
38
55
  try {
39
56
  const params = { "account-id": accountId };
57
+ if (args["name-contains"]) params["name-contains"] = args["name-contains"];
58
+ if (args.seed) params.seed = args.seed;
40
59
  if (args.limit) params.limit = args.limit;
41
60
  if (args["no-cache"]) params["skip-cache"] = "true";
42
61
  const data = await apiGet("/api/ads/meta/audiences", params);
43
- const fmt = csvOrJson(args);
44
- if (fmt !== "json") {
45
- writeAdsOutput(data, fmt);
46
- return;
47
- }
48
- writeAdsJson({ ok: true, data });
62
+ writeMetaListRows("audiences", shapeMetaListRows("audiences", data, args), csvOrJson(args));
49
63
  } catch (err) {
50
64
  handleMetaError(err);
51
65
  }
@@ -57,8 +71,14 @@ var audiencesCommand = defineCommand({
57
71
  description: `List custom audiences, or stage writes (create/update/delete, members add|remove|replace). Write subcommands stage ops on this chat's draft.
58
72
  Includes lookalikes, website-pixel audiences, customer-file audiences. Meta hides exact size when count < 1000.
59
73
 
74
+ Listings print a table by default: id, name, subtype, size_min, size_max, retention_days, updated_date, plus
75
+ delivery and seed_id when a row has one. The rule and data source are --fields (dotted paths) or --full away.
76
+
60
77
  Examples:
61
78
  baker ads meta audiences --account-id act_123
79
+ baker ads meta audiences --name-contains Cerradas \u2014 find one audience by name
80
+ baker ads meta audiences --seed 120240480760260208 \u2014 the lookalikes built from that audience
81
+ baker ads meta audiences --name-contains Leads --fields id,name,rule,retention_days --output json
62
82
  baker ads meta audiences create --name "Site 30d" --subtype WEBSITE --file rule.json
63
83
  baker ads meta audiences create --name "Past buyers" --subtype CUSTOM --file buyers.json # {"members":[{"email":"\u2026"}]}
64
84
  baker ads meta audiences create --name "Customers" --subtype CUSTOM --customer-file-source USER_PROVIDED_ONLY
@@ -83,4 +103,4 @@ Examples:
83
103
  export {
84
104
  audiencesCommand
85
105
  };
86
- //# sourceMappingURL=audiences-O464BZ6J.js.map
106
+ //# sourceMappingURL=audiences-UJCOT423.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/ads/meta/audiences.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { META_LIST_SHAPE_ARGS, registerMetaListSchema, shapeMetaListRows, writeMetaListRows } from \"./list-rows.ts\";\nimport { csvOrJson, handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\nconst listArgs = {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n \"name-contains\": {\n type: \"string\",\n description:\n \"Only audiences whose name contains this text, matched by Meta before anything is returned: --name-contains Cerradas. A lookalike can be named anything, so find one audience's lookalikes with --seed <its id>\",\n },\n seed: {\n type: \"string\",\n description:\n \"Only the lookalikes built from this source audience id, whatever they are named: --seed 120240480760260208\",\n },\n limit: { type: \"string\", description: \"Max rows (default 500)\" },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"audiences\",\n \"List custom and lookalike audiences, as a table by default: id, name, subtype, size_min, size_max, retention_days, updated_date — plus delivery (why Meta says it cannot be used) and seed_id (the audience a lookalike was built from) when a row has one. The rule, data source and pixel are one --fields away (--fields id,name,rule) or --full. Start here to find one audience: baker ads meta audiences --name-contains <text>; then its lookalikes, whatever they are named: --seed <its id>. --output json returns the rows in the envelope.\",\n listArgs,\n);\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List custom audiences. Runs by default when no subcommand is given. Example: baker ads meta audiences --name-contains buyers\",\n },\n args: listArgs,\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const params: Record<string, string> = { \"account-id\": accountId };\n if (args[\"name-contains\"]) params[\"name-contains\"] = args[\"name-contains\"] as string;\n if (args.seed) params.seed = args.seed as string;\n if (args.limit) params.limit = args.limit as string;\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const data = await apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/audiences\", params);\n writeMetaListRows(\"audiences\", shapeMetaListRows(\"audiences\", data, args), csvOrJson(args));\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const audiencesCommand = defineCommand({\n meta: {\n name: \"audiences\",\n description: `List custom audiences, or stage writes (create/update/delete, members add|remove|replace). Write subcommands stage ops on this chat's draft.\nIncludes lookalikes, website-pixel audiences, customer-file audiences. Meta hides exact size when count < 1000.\n\nListings print a table by default: id, name, subtype, size_min, size_max, retention_days, updated_date, plus\ndelivery and seed_id when a row has one. The rule and data source are --fields (dotted paths) or --full away.\n\nExamples:\n baker ads meta audiences --account-id act_123\n baker ads meta audiences --name-contains Cerradas — find one audience by name\n baker ads meta audiences --seed 120240480760260208 — the lookalikes built from that audience\n baker ads meta audiences --name-contains Leads --fields id,name,rule,retention_days --output json\n baker ads meta audiences create --name \"Site 30d\" --subtype WEBSITE --file rule.json\n baker ads meta audiences create --name \"Past buyers\" --subtype CUSTOM --file buyers.json # {\"members\":[{\"email\":\"…\"}]}\n baker ads meta audiences create --name \"Customers\" --subtype CUSTOM --customer-file-source USER_PROVIDED_ONLY\n baker ads meta audiences members add meta_temp_ab12 --file customers.csv --country ES\n baker ads meta audiences saved --account-id act_123 — saved audiences (read-only)`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./write-commands.ts\").then((m) => m.audiencesCreateCommand),\n update: () => import(\"./write-commands.ts\").then((m) => m.audiencesUpdateCommand),\n delete: () => import(\"./audience-writes.ts\").then((m) => m.audiencesDeleteCommand),\n members: () => import(\"./audience-writes.ts\").then((m) => m.audiencesMembersCommand),\n saved: () => import(\"./audience-writes.ts\").then((m) => m.savedAudiencesCommand),\n },\n // `args` stays even though the parent has no `run`: citty scans rawArgs for the\n // subcommand name using THIS command's arg defs, so without them `--account-id act_1`\n // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare\n // invocation — citty falls through to `run` after a subcommand, double-executing it.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAM9B,IAAM,WAAW;AAAA,EACf,cAAc,EAAE,MAAM,UAAU,aAAa,qBAAqB;AAAA,EAClE,iBAAiB;AAAA,IACf,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;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M,OAAO,+BAAsB,EAAE,KAAK,CAAC,MAAM,EAAE,uBAAuB;AAAA,IACnF,OAAO,MAAM,OAAO,+BAAsB,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM;AAAA,EACN,SAAS;AACX,CAAC;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  registerMetaListSchema,
5
5
  shapeMetaListRows,
6
6
  writeMetaListRows
7
- } from "./chunk-MFAFGQ7Z.js";
7
+ } from "./chunk-AGEWPMBR.js";
8
8
  import {
9
9
  NAME_CONTAINS_ARG,
10
10
  csvOrJson,
@@ -127,4 +127,4 @@ export {
127
127
  advantagePlusHints,
128
128
  campaignsCommand
129
129
  };
130
- //# sourceMappingURL=campaigns-N75G2BDU.js.map
130
+ //# sourceMappingURL=campaigns-JCKEU2NC.js.map
@@ -129,6 +129,90 @@ function compactActivity(row) {
129
129
  ...change !== void 0 ? { change } : {}
130
130
  };
131
131
  }
132
+ var AUDIENCE_COLUMNS = ["id", "name", "subtype", "size_min", "size_max", "retention_days", "updated_date"];
133
+ var AUDIENCE_WHEN_PRESENT = ["delivery", "seed_id"];
134
+ function compactAudience(row) {
135
+ const updated = row.time_updated;
136
+ const delivery = asRecord(row.delivery_status);
137
+ const origin = asRecord(row.lookalike_spec)?.origin;
138
+ const seed = Array.isArray(origin) ? asRecord(origin[0])?.id : void 0;
139
+ return {
140
+ ...pick(row, ["id", "name", "subtype"]),
141
+ ...row.approximate_count_lower_bound !== void 0 ? { size_min: row.approximate_count_lower_bound } : {},
142
+ ...row.approximate_count_upper_bound !== void 0 ? { size_max: row.approximate_count_upper_bound } : {},
143
+ ...pick(row, ["retention_days"]),
144
+ ...typeof updated === "number" ? { updated_date: new Date(updated * 1e3).toISOString().slice(0, 10) } : {},
145
+ ...delivery && delivery.code !== 200 && typeof delivery.description === "string" ? { delivery: delivery.description } : {},
146
+ ...seed !== void 0 ? { seed_id: seed } : {}
147
+ };
148
+ }
149
+ var CREATIVE_COLUMNS = [
150
+ "id",
151
+ "name",
152
+ "status",
153
+ "object_type",
154
+ "dynamic",
155
+ "body",
156
+ "title",
157
+ "description",
158
+ "link",
159
+ "cta",
160
+ "url_tags",
161
+ "image_hash",
162
+ "video_id",
163
+ "page_id",
164
+ "instagram_user_id",
165
+ "effective_object_story_id"
166
+ ];
167
+ function texts(value, key) {
168
+ return Array.isArray(value) ? value.map((entry) => asRecord(entry)?.[key]) : [];
169
+ }
170
+ function oneOrMany(...candidates) {
171
+ const values = [...new Set(candidates.flat().filter((v) => typeof v === "string" && v !== ""))];
172
+ if (values.length === 0) return void 0;
173
+ return values.length === 1 ? values[0] : values;
174
+ }
175
+ function compactCreative(row) {
176
+ const story = asRecord(row.object_story_spec);
177
+ const link = asRecord(story?.link_data);
178
+ const video = asRecord(story?.video_data);
179
+ const feed = asRecord(row.asset_feed_spec);
180
+ const cards = link?.child_attachments;
181
+ const derived = {
182
+ dynamic: feed ? typeof feed.optimization_type === "string" ? feed.optimization_type : "ASSET_FEED" : void 0,
183
+ body: oneOrMany(row.body, link?.message, video?.message, texts(feed?.bodies, "text")),
184
+ title: oneOrMany(row.title, link?.name, video?.title, texts(feed?.titles, "text"), texts(cards, "name")),
185
+ description: oneOrMany(
186
+ link?.description,
187
+ video?.link_description,
188
+ texts(feed?.descriptions, "text"),
189
+ texts(cards, "description")
190
+ ),
191
+ link: oneOrMany(
192
+ row.link_url,
193
+ link?.link,
194
+ asRecord(asRecord(video?.call_to_action)?.value)?.link,
195
+ texts(feed?.link_urls, "website_url"),
196
+ texts(cards, "link")
197
+ ),
198
+ cta: oneOrMany(row.call_to_action_type, feed?.call_to_action_types),
199
+ url_tags: row.url_tags,
200
+ image_hash: oneOrMany(
201
+ row.image_hash,
202
+ link?.image_hash,
203
+ video?.image_hash,
204
+ texts(feed?.images, "hash"),
205
+ texts(cards, "image_hash")
206
+ ),
207
+ video_id: oneOrMany(row.video_id, video?.video_id, texts(feed?.videos, "video_id"), texts(cards, "video_id")),
208
+ page_id: story?.page_id,
209
+ instagram_user_id: row.instagram_user_id ?? story?.instagram_user_id,
210
+ effective_object_story_id: row.effective_object_story_id
211
+ };
212
+ const compact = pick(row, ["id", "name", "status", "object_type"]);
213
+ for (const [key, value] of Object.entries(derived)) if (value !== void 0) compact[key] = value;
214
+ return compact;
215
+ }
132
216
  function budgetUnitHints(rows) {
133
217
  const listed = rows.map((row) => Number(row.daily_budget ?? row.lifetime_budget)).find((amount) => Number.isFinite(amount) && amount > 0);
134
218
  if (listed === void 0) return [];
@@ -141,7 +225,9 @@ var PROJECTIONS = {
141
225
  campaigns: { row: compactCampaign, columns: CAMPAIGN_COLUMNS, whenPresent: DIAGNOSTIC_COLUMNS },
142
226
  adsets: { row: compactAdSet, columns: ADSET_COLUMNS, whenPresent: DIAGNOSTIC_COLUMNS },
143
227
  ads: { row: compactAd, columns: AD_COLUMNS },
144
- activities: { row: compactActivity, columns: ACTIVITY_COLUMNS }
228
+ activities: { row: compactActivity, columns: ACTIVITY_COLUMNS },
229
+ audiences: { row: compactAudience, columns: AUDIENCE_COLUMNS, whenPresent: AUDIENCE_WHEN_PRESENT },
230
+ creatives: { row: compactCreative, columns: CREATIVE_COLUMNS }
145
231
  };
146
232
  function shapeMetaListRows(kind, rows, args) {
147
233
  return shapeListRows(rows, args, PROJECTIONS[kind]);
@@ -150,7 +236,9 @@ var NOUNS = {
150
236
  campaigns: "campaigns",
151
237
  adsets: "ad sets",
152
238
  ads: "ads",
153
- activities: "activities"
239
+ activities: "activities",
240
+ audiences: "audiences",
241
+ creatives: "creatives"
154
242
  };
155
243
  function writeMetaListRows(kind, shaped, format, hints = []) {
156
244
  if (format === "md" && shaped.rows.length === 0) {
@@ -197,4 +285,4 @@ export {
197
285
  META_LIST_SHAPE_ARGS,
198
286
  registerMetaListSchema
199
287
  };
200
- //# sourceMappingURL=chunk-MFAFGQ7Z.js.map
288
+ //# sourceMappingURL=chunk-AGEWPMBR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/ads/meta/list-rows.ts"],"sourcesContent":["import { registerSchema } from \"../../../schemas.ts\";\nimport { asRecord, type CompactProjection, type ShapedRows, shapeListRows } from \"../list-rows.ts\";\nimport { writeAdsOutput } from \"../output.ts\";\n\n/**\n * The compact row of each Meta listing. The backend asks Graph for every field a\n * write or an audit might need (targeting, tracking specs, three status fields),\n * and 100 campaigns or two days of activity passed through whole ran to 55–78 KB.\n * A compact row carries what an agent decides with; `--fields` reaches any other\n * path and `--full` returns the record Graph sent.\n *\n * `effective_status` is the one status kept: it is what Ads Manager shows, and\n * `status`/`configured_status` only restate the toggle it already folds in.\n *\n * Listings print a table by default: keyed JSON repeats every column name on\n * every row, and 100 campaigns stayed near 30 KB even compact. `--output json`\n * returns the same rows in the envelope.\n */\n\ntype MetaRow = Record<string, unknown>;\n\nexport type MetaListKind = \"campaigns\" | \"adsets\" | \"ads\" | \"activities\" | \"audiences\" | \"creatives\";\n\nfunction pick(row: MetaRow, keys: readonly string[]): MetaRow {\n const picked: MetaRow = {};\n for (const key of keys) {\n if (row[key] !== undefined) picked[key] = row[key];\n }\n return picked;\n}\n\n/**\n * An account's campaign list is the widest listing an agent reads (100+ rows), so\n * its row is the narrowest: what a campaign is called, whether it runs and what\n * it spends. Objective, bid strategy and Special Ad Category are one `--fields`\n * away; the creation day is enough to order by, and `--fields created_time` has\n * the timestamp.\n */\nconst CAMPAIGN_COLUMNS = [\"id\", \"name\", \"effective_status\", \"daily_budget\", \"lifetime_budget\", \"created_date\"] as const;\n\n/** Why delivery stops and what Meta suggests: columns only when a row has one. */\nconst DIAGNOSTIC_COLUMNS = [\"issues\", \"suggestions\"] as const;\n\nfunction compactCampaign(row: MetaRow): MetaRow {\n const created = row.created_time;\n return {\n ...pick(row, [\"id\", \"name\", \"effective_status\", \"daily_budget\", \"lifetime_budget\"]),\n ...(typeof created === \"string\" ? { created_date: created.slice(0, 10) } : {}),\n ...diagnostics(row),\n };\n}\n\nconst ADSET_KEYS = [\n \"id\",\n \"name\",\n \"campaign_id\",\n \"effective_status\",\n \"optimization_goal\",\n \"billing_event\",\n \"bid_strategy\",\n \"daily_budget\",\n \"lifetime_budget\",\n \"destination_type\",\n // A Dynamic Creative ad set refuses every new ad, which changes the plan before anything is staged.\n \"is_dynamic_creative\",\n] as const;\n\nconst ADSET_COLUMNS = [...ADSET_KEYS, \"learning_stage\", \"end_time\", \"created_time\"] as const;\n\nfunction compactAdSet(row: MetaRow): MetaRow {\n const learning = asRecord(row.learning_stage_info)?.status;\n return {\n ...pick(row, ADSET_KEYS),\n ...(typeof learning === \"string\" ? { learning_stage: learning } : {}),\n ...pick(row, [\"end_time\", \"created_time\"]),\n ...diagnostics(row),\n };\n}\n\nconst AD_COLUMNS = [\n \"id\",\n \"name\",\n \"adset_id\",\n \"campaign_id\",\n \"effective_status\",\n \"creative_id\",\n \"issues\",\n \"created_time\",\n] as const;\n\n/** Why an ad is WITH_ISSUES — the one reason to open `issues_info`, in its own words. */\nfunction adIssues(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.flatMap((entry) => {\n const issue = asRecord(entry);\n const text = issue?.error_summary ?? issue?.error_message;\n return typeof text === \"string\" && text ? [text] : [];\n });\n}\n\n/** Meta's suggestions for a campaign or ad set (`recommendations`), by their titles. */\nfunction suggestions(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.flatMap((entry) => {\n const recommendation = asRecord(entry);\n const text = recommendation?.title ?? recommendation?.message;\n return typeof text === \"string\" && text ? [text] : [];\n });\n}\n\n/** Why a campaign or ad set cannot deliver, and what Meta suggests — only when Meta says something. */\nfunction diagnostics(row: MetaRow): MetaRow {\n const issues = adIssues(row.issues_info);\n const suggested = suggestions(row.recommendations);\n return {\n ...(issues.length > 0 ? { issues } : {}),\n ...(suggested.length > 0 ? { suggestions: suggested } : {}),\n };\n}\n\nfunction compactAd(row: MetaRow): MetaRow {\n const creativeId = asRecord(row.creative)?.id;\n const issues = adIssues(row.issues_info);\n return {\n ...pick(row, [\"id\", \"name\", \"adset_id\", \"campaign_id\", \"effective_status\"]),\n ...(creativeId !== undefined ? { creative_id: creativeId } : {}),\n ...(issues.length > 0 ? { issues } : {}),\n ...pick(row, [\"created_time\"]),\n };\n}\n\nconst ACTIVITY_COLUMNS = [\n \"event_time\",\n \"event_type\",\n \"actor_name\",\n \"object_type\",\n \"object_name\",\n \"object_id\",\n \"change\",\n] as const;\n\nfunction isScalar(value: unknown): value is string | number | null {\n return value === null || typeof value === \"string\" || typeof value === \"number\";\n}\n\n/**\n * `extra_data` is a JSON string whose shape varies by event type and carries most\n * of an activity's bytes (image URLs, whole targeting specs). A status, name,\n * budget or goal change stores its before and after as two plain values — those\n * read as one line; any richer change stays behind `--fields extra_data`.\n */\nexport function activityChange(extraData: unknown): string | undefined {\n if (typeof extraData !== \"string\") return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(extraData);\n } catch {\n return undefined;\n }\n const data = asRecord(parsed);\n // An absent old_value is one this read did not observe, not an unset one — only `null` means \"none\".\n if (!data || !(\"new_value\" in data) || !(\"old_value\" in data)) return undefined;\n const { old_value: before, new_value: after } = data;\n if (!isScalar(before) || !isScalar(after)) return undefined;\n const show = (value: string | number | null) => (value === null ? \"(none)\" : String(value));\n return `${show(before)} → ${show(after)}`;\n}\n\nfunction compactActivity(row: MetaRow): MetaRow {\n const change = activityChange(row.extra_data);\n return {\n ...pick(row, [\"event_time\", \"event_type\", \"actor_name\", \"object_type\", \"object_name\", \"object_id\"]),\n ...(change !== undefined ? { change } : {}),\n };\n}\n\n/**\n * An account can hold hundreds of audiences (one held 414, ~424 KB printed), and a\n * lookup is usually for one of them and its lookalikes. The row says what the audience\n * is, how big, and — only when it is so — why it cannot be used and which audience a\n * lookalike was built from. Its rule and data source are one `--fields` away.\n */\nconst AUDIENCE_COLUMNS = [\"id\", \"name\", \"subtype\", \"size_min\", \"size_max\", \"retention_days\", \"updated_date\"] as const;\nconst AUDIENCE_WHEN_PRESENT = [\"delivery\", \"seed_id\"] as const;\n\nfunction compactAudience(row: MetaRow): MetaRow {\n const updated = row.time_updated;\n const delivery = asRecord(row.delivery_status);\n const origin = asRecord(row.lookalike_spec)?.origin;\n const seed = Array.isArray(origin) ? asRecord(origin[0])?.id : undefined;\n return {\n ...pick(row, [\"id\", \"name\", \"subtype\"]),\n ...(row.approximate_count_lower_bound !== undefined ? { size_min: row.approximate_count_lower_bound } : {}),\n ...(row.approximate_count_upper_bound !== undefined ? { size_max: row.approximate_count_upper_bound } : {}),\n ...pick(row, [\"retention_days\"]),\n ...(typeof updated === \"number\" ? { updated_date: new Date(updated * 1000).toISOString().slice(0, 10) } : {}),\n ...(delivery && delivery.code !== 200 && typeof delivery.description === \"string\"\n ? { delivery: delivery.description }\n : {}),\n ...(seed !== undefined ? { seed_id: seed } : {}),\n };\n}\n\n/**\n * A creative's copy, destination and assets live in one of three places — the\n * top-level fields Meta derives, `object_story_spec`, or a dynamic creative's\n * `asset_feed_spec`, a carousel's cards in `link_data.child_attachments` — next to specs that carry most of its bytes and none of its\n * meaning (`degrees_of_freedom_spec`, per-placement rules, signed image URLs). The\n * row reads each value from wherever the creative keeps it: one value as itself,\n * several (a dynamic creative's variants) as a list.\n */\nconst CREATIVE_COLUMNS = [\n \"id\",\n \"name\",\n \"status\",\n \"object_type\",\n \"dynamic\",\n \"body\",\n \"title\",\n \"description\",\n \"link\",\n \"cta\",\n \"url_tags\",\n \"image_hash\",\n \"video_id\",\n \"page_id\",\n \"instagram_user_id\",\n \"effective_object_story_id\",\n] as const;\n\nfunction texts(value: unknown, key: string): unknown[] {\n return Array.isArray(value) ? value.map((entry) => asRecord(entry)?.[key]) : [];\n}\n\nfunction oneOrMany(...candidates: unknown[]): MetaRow[string] {\n const values = [...new Set(candidates.flat().filter((v) => typeof v === \"string\" && v !== \"\"))];\n if (values.length === 0) return undefined;\n return values.length === 1 ? values[0] : values;\n}\n\nfunction compactCreative(row: MetaRow): MetaRow {\n const story = asRecord(row.object_story_spec);\n const link = asRecord(story?.link_data);\n const video = asRecord(story?.video_data);\n const feed = asRecord(row.asset_feed_spec);\n // A carousel's cards: each one's headline, description, destination and media.\n const cards = link?.child_attachments;\n const derived: MetaRow = {\n dynamic: feed ? (typeof feed.optimization_type === \"string\" ? feed.optimization_type : \"ASSET_FEED\") : undefined,\n body: oneOrMany(row.body, link?.message, video?.message, texts(feed?.bodies, \"text\")),\n title: oneOrMany(row.title, link?.name, video?.title, texts(feed?.titles, \"text\"), texts(cards, \"name\")),\n description: oneOrMany(\n link?.description,\n video?.link_description,\n texts(feed?.descriptions, \"text\"),\n texts(cards, \"description\"),\n ),\n link: oneOrMany(\n row.link_url,\n link?.link,\n asRecord(asRecord(video?.call_to_action)?.value)?.link,\n texts(feed?.link_urls, \"website_url\"),\n texts(cards, \"link\"),\n ),\n cta: oneOrMany(row.call_to_action_type, feed?.call_to_action_types),\n url_tags: row.url_tags,\n image_hash: oneOrMany(\n row.image_hash,\n link?.image_hash,\n video?.image_hash,\n texts(feed?.images, \"hash\"),\n texts(cards, \"image_hash\"),\n ),\n video_id: oneOrMany(row.video_id, video?.video_id, texts(feed?.videos, \"video_id\"), texts(cards, \"video_id\")),\n page_id: story?.page_id,\n instagram_user_id: row.instagram_user_id ?? story?.instagram_user_id,\n effective_object_story_id: row.effective_object_story_id,\n };\n const compact: MetaRow = pick(row, [\"id\", \"name\", \"status\", \"object_type\"]);\n for (const [key, value] of Object.entries(derived)) if (value !== undefined) compact[key] = value;\n return compact;\n}\n\n/**\n * The unit a listing's budgets are in, said once rather than as a column (a\n * 100-campaign table stays small). Meta lists money in the account currency's\n * smallest unit and Baker passes it through unchanged (published reports read\n * it that way), while every money flag takes whole currency. An agent that once\n * took a listed \"8000\" for the flag's unit staged 10,000 EUR a day instead of 100.\n */\nexport function budgetUnitHints(rows: ReadonlyArray<Record<string, unknown>>): string[] {\n const listed = rows\n .map((row) => Number(row.daily_budget ?? row.lifetime_budget))\n .find((amount) => Number.isFinite(amount) && amount > 0);\n if (listed === undefined) return [];\n const whole = listed / 100;\n return [\n `Budgets here are in the account currency's smallest unit, as Meta sends them: daily_budget ${listed} is ${whole} in EUR or USD (currencies without cents, such as JPY, are not divided). Money flags take whole currency: --daily-budget ${whole}, never ${listed}.`,\n ];\n}\n\nconst PROJECTIONS: Record<MetaListKind, CompactProjection<MetaRow>> = {\n campaigns: { row: compactCampaign, columns: CAMPAIGN_COLUMNS, whenPresent: DIAGNOSTIC_COLUMNS },\n adsets: { row: compactAdSet, columns: ADSET_COLUMNS, whenPresent: DIAGNOSTIC_COLUMNS },\n ads: { row: compactAd, columns: AD_COLUMNS },\n activities: { row: compactActivity, columns: ACTIVITY_COLUMNS },\n audiences: { row: compactAudience, columns: AUDIENCE_COLUMNS, whenPresent: AUDIENCE_WHEN_PRESENT },\n creatives: { row: compactCreative, columns: CREATIVE_COLUMNS },\n};\n\nexport function shapeMetaListRows(kind: MetaListKind, rows: MetaRow[], args: Record<string, unknown>): ShapedRows {\n return shapeListRows(rows, args, PROJECTIONS[kind]);\n}\n\nconst NOUNS: Record<MetaListKind, string> = {\n campaigns: \"campaigns\",\n adsets: \"ad sets\",\n ads: \"ads\",\n activities: \"activities\",\n audiences: \"audiences\",\n creatives: \"creatives\",\n};\n\n/**\n * A table of no rows prints nothing at all, which reads as a failed call — so an empty\n * listing says so, and says why when a status filter may be hiding rows.\n */\nexport function writeMetaListRows(kind: MetaListKind, shaped: ShapedRows, format: string, hints: string[] = []): void {\n if (format === \"md\" && shaped.rows.length === 0) {\n process.stdout.write(`${hints.length > 0 ? hints.join(\"\\n\") : `No ${NOUNS[kind]} matched.`}\\n`);\n return;\n }\n writeAdsOutput(shaped.rows, format, shaped.fields, [...hints, ...(shaped.hints ?? [])]);\n}\n\n/** The projection flags every Meta listing shares, worded once for help and `baker schema`. */\nexport const META_LIST_SHAPE_ARGS = {\n fields: {\n type: \"string\",\n description: \"CSV of dotted paths to return instead of the compact row, e.g. id,name,targeting.geo_locations\",\n },\n full: { type: \"boolean\", description: \"Return every field Meta sent (targeting, tracking specs, raw extra_data)\" },\n output: {\n type: \"string\",\n description: \"md|json|csv|jsonl — md (default) prints a table; json returns the rows in the { ok, data } envelope\",\n default: \"md\",\n },\n} as const;\n\ninterface ListArgDef {\n type: string;\n description?: string;\n default?: unknown;\n}\n\n/**\n * `baker schema ads.meta.<list>`, read off the same arg defs the command parses,\n * so the introspection an agent checks before a call cannot promise a flag the\n * command refuses — `--full` on `adsets` was guessed three times in one Session.\n */\nexport function registerMetaListSchema(\n kind: MetaListKind,\n description: string,\n args: Record<string, ListArgDef>,\n): void {\n registerSchema({\n command: `ads.meta.${kind}`,\n description,\n args: Object.fromEntries(\n Object.entries(args).map(([name, def]) => [\n name,\n {\n type: def.type,\n description: def.description ?? \"\",\n required: false,\n ...(def.default !== undefined ? { default: def.default } : {}),\n },\n ]),\n ),\n });\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAS,KAAK,KAAc,MAAkC;AAC5D,QAAM,SAAkB,CAAC;AACzB,aAAW,OAAO,MAAM;AACtB,QAAI,IAAI,GAAG,MAAM,OAAW,QAAO,GAAG,IAAI,IAAI,GAAG;AAAA,EACnD;AACA,SAAO;AACT;AASA,IAAM,mBAAmB,CAAC,MAAM,QAAQ,oBAAoB,gBAAgB,mBAAmB,cAAc;AAG7G,IAAM,qBAAqB,CAAC,UAAU,aAAa;AAEnD,SAAS,gBAAgB,KAAuB;AAC9C,QAAM,UAAU,IAAI;AACpB,SAAO;AAAA,IACL,GAAG,KAAK,KAAK,CAAC,MAAM,QAAQ,oBAAoB,gBAAgB,iBAAiB,CAAC;AAAA,IAClF,GAAI,OAAO,YAAY,WAAW,EAAE,cAAc,QAAQ,MAAM,GAAG,EAAE,EAAE,IAAI,CAAC;AAAA,IAC5E,GAAG,YAAY,GAAG;AAAA,EACpB;AACF;AAEA,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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AC;AAAA,QAC9D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
package/dist/cli.js CHANGED
@@ -463,7 +463,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
463
463
  capabilities: () => import("./capabilities-O5UVQ4KK.js").then((m) => m.capabilitiesCommand),
464
464
  actions: () => import("./actions-LRJRQXC3.js").then((m) => m.actionsCommand),
465
465
  "scheduled-agents": () => import("./scheduled-agents-ICXFV7NP.js").then((m) => m.scheduledAgentsCommand),
466
- ads: () => import("./ads-CDA6DGGZ.js").then((m) => m.adsCommand),
466
+ ads: () => import("./ads-LVAVF4QI.js").then((m) => m.adsCommand),
467
467
  brand: () => import("./brand-XY7EVNPW.js").then((m) => m.brandCommand),
468
468
  analytics: () => import("./analytics-MDIE5CPL.js").then((m) => m.analyticsCommand),
469
469
  experiment: () => import("./experiment-2TTMKPVC.js").then((m) => m.experimentCommand),
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/closed-pipe.ts","../src/company-flag.ts","../src/full-flag.ts","../src/help-output.ts","../src/md-output.ts","../src/out-flag.ts","../src/root-command.ts","../src/version.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { runCommand, runMain } from \"citty\";\nimport { agentProfile, applyAgentProfile } from \"./agent-profile.ts\";\nimport { cacheFlagForCommand, cacheFlagForParser, normalizeCacheFlag } from \"./cache-flag.ts\";\nimport { exitQuietlyOnClosedPipe } from \"./closed-pipe.ts\";\nimport { loadCommands } from \"./command-loading.ts\";\nimport { takeCompanyFlag } from \"./company-flag.ts\";\nimport { installExitRecord, installStreamTaps, logInvocation } from \"./debugLog.ts\";\nimport { setTargetCompany } from \"./env.ts\";\nimport { installFieldMask, takeFieldsFlag } from \"./field-mask.ts\";\nimport { installFullNote, takeFullFlag } from \"./full-flag.ts\";\nimport { printHelpTo } from \"./help-output.ts\";\nimport { installMdRendering, takeMdOutput } from \"./md-output.ts\";\nimport { installOutFile, takeOutFlag } from \"./out-flag.ts\";\nimport { writeJson } from \"./output.ts\";\nimport { asksForEnvelopeAlone, envelopeAloneOnStdout, outputFlagForCommand } from \"./output-flag.ts\";\nimport { rootCommand } from \"./root-command.ts\";\nimport { registerCommandTree } from \"./schemas.ts\";\nimport {\n commandPathOf,\n parseRefusalEnvelope,\n refuseStrayPositionals,\n refuseUnknownFlags,\n unknownSubCommandRefusal,\n} from \"./unknown-flags.ts\";\n\nconst main = rootCommand;\n// The call as typed, before the rewrites below: a refusal's corrected call is built from it.\nconst typedArgv = process.argv.slice(2);\n\nawait loadCommands(main, process.argv.slice(2));\nregisterCommandTree(main);\n\nexitQuietlyOnClosedPipe(process.stdout, (code) => process.exit(code));\n\n// The legacy `--skip-cache` spelling becomes `--no-cache` before anything reads\n// argv — citty parses `process.argv` itself, so the rewrite has to land there.\nprocess.argv = [...process.argv.slice(0, 2), ...normalizeCacheFlag(process.argv.slice(2))];\n\n// When BAKER_DEBUG_LOG is set, mirror all output and record the invocation\n// before any command runs. No-op otherwise.\ninstallStreamTaps();\nlogInvocation(process.argv.slice(2));\ninstallExitRecord();\n\n// `--output json` asks for the envelope, which almost every command prints\n// without declaring the option — translated here so the guard below does not\n// refuse a flag that asked for what the command was about to print.\n// `canvas run` prints progress before its envelope: asked for the envelope, it\n// prints that alone on stdout and the progress on stderr.\nif (asksForEnvelopeAlone(main, process.argv.slice(2))) {\n envelopeAloneOnStdout(process.stdout, process.stderr);\n}\nprocess.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];\n\n// `--output md` and `--out <file>` act on the envelope a command prints when it\n// has no Markdown view or export of its own. Installed before the mask and the `--full` note, so\n// each envelope is narrowed first, then written to the file, then rendered.\nconst mdOutput = takeMdOutput(main, process.argv.slice(2));\nprocess.argv = [...process.argv.slice(0, 2), ...mdOutput.argv];\nif (mdOutput.render) {\n installMdRendering();\n}\n// A command with its own Markdown view asked for `--output md --out <file>` is\n// asked for its envelope instead, and the summary is what gets rendered.\nconst outFlag = takeOutFlag(main, process.argv.slice(2));\nif (outFlag.file) {\n process.argv = [...process.argv.slice(0, 2), ...outFlag.argv];\n if (outFlag.summaryMd && !mdOutput.render) {\n installMdRendering();\n }\n installOutFile(outFlag.file, commandPathOf(main, outFlag.argv), outFlag);\n}\n\n// `--fields` narrows the envelope on every command that prints one; where the\n// command does not declare it, it is applied to what the command prints.\nconst fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));\nif (fieldsFlag.fields) {\n process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];\n installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));\n}\n\n// `--full` on a command with no shorter view asks for what it already prints:\n// taken off here, and said back in the envelope's hints.\nconst fullFlag = takeFullFlag(main, process.argv.slice(2));\nif (fullFlag.taken) {\n process.argv = [...process.argv.slice(0, 2), ...fullFlag.argv];\n installFullNote(commandPathOf(main, fullFlag.argv));\n}\n\n// `--company <id>` names the company a read is about (the organization\n// workspace's Reports read every company of its organization). It travels as a\n// header on every request, so it is taken off here, before the guard.\nconst companyFlag = takeCompanyFlag(main, process.argv.slice(2));\nif (companyFlag.company) {\n process.argv = [...process.argv.slice(0, 2), ...companyFlag.argv];\n setTargetCompany(companyFlag.company);\n}\n\n// What this agent is offered: the organization workspace's agent only reads\n// (`agent-profile.ts`). Here, after `--company` is taken off, so the command it\n// judges is the one typed.\nconst profileRefusal = await applyAgentProfile(main, agentProfile(), process.argv.slice(2));\nif (profileRefusal) {\n writeJson({ ok: false, error: { code: \"FORBIDDEN\", message: profileRefusal } });\n process.exit(1);\n}\n\n// A report's Refresh appends `--no-cache` to every read; a command with no cache\n// already reads fresh, so it is dropped there rather than refused.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForCommand(main, process.argv.slice(2))];\n\nrefuseUnknownFlags(main, process.argv.slice(2), typedArgv);\nrefuseStrayPositionals(main, process.argv.slice(2));\n\n// Last, so the guard above quotes back the spelling the caller typed: citty\n// resolves a bare `--no-cache` to `cache: false` instead of filling the declared\n// `no-cache` arg, and only the camelCase spelling survives its parser intact.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];\n\n// `--help` and `--version` stay citty's own, the help rendered for an agent\n// reading it (`help-output.ts`), except help on a subcommand that does not\n// exist, which is refused like a call to it. Everything else runs here rather\n// than through `runMain`, whose refusal of a missing argument or an unknown\n// subcommand is usage text on stderr and nothing on stdout: that becomes the\n// envelope every other failure prints.\nconst rawArgs = process.argv.slice(2);\nif (\n rawArgs.some((arg) => arg === \"--help\" || arg === \"-h\") ||\n (rawArgs.length === 1 && /^(--version|-v)$/.test(rawArgs[0] ?? \"\"))\n) {\n const unknown = unknownSubCommandRefusal(main, rawArgs);\n if (unknown) {\n writeJson(unknown);\n process.exit(1);\n }\n runMain(main, { showUsage: printHelpTo(process.stdout) });\n} else {\n try {\n await runCommand(main, { rawArgs });\n } catch (error) {\n const refusal = parseRefusalEnvelope(error, main, rawArgs);\n if (refusal) {\n writeJson(refusal);\n } else {\n console.error(error, \"\\n\");\n }\n process.exit(1);\n }\n}\n","interface ErrorSource {\n on(event: \"error\", listener: (err: NodeJS.ErrnoException) => void): unknown;\n}\n\n/**\n * `baker … | head` closes the pipe once it has its lines. Node reports the next\n * write as an unhandled EPIPE and prints a stack trace, which reads as a crash of\n * a command that did its job. A closed reader wants nothing more, so exit cleanly,\n * as Unix tools do; any other write error still surfaces.\n */\nexport function exitQuietlyOnClosedPipe(stream: ErrorSource, exit: (code: number) => void): void {\n stream.on(\"error\", (err) => {\n if (err.code === \"EPIPE\") {\n exit(0);\n return;\n }\n throw err;\n });\n}\n","/**\n * `--company <id>` on every command: the company the call reads, for the\n * organization workspace, whose Reports read every company of its organization.\n *\n * It is a header, not an argument of each command (`x-baker-company`, sent by\n * `client.ts`), so every read the CLI has works across companies unchanged, and\n * the backend alone decides what it opens: reads of a company of the same\n * organization, for the organization workspace's credential, and nothing else.\n *\n * A command that declares `--company` itself keeps its own meaning — on\n * `avatars research` it is the person's employer. A positional named `company`\n * (`accounts company acme.com`) is not a flag, so the flag stays the header.\n */\n\nimport { declaredArg } from \"./output-flag.ts\";\nimport { commandFor, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--company\";\n\n/** The command reads `--company` itself; a positional of that name is no flag, so it is not. */\nfunction ownsCompanyFlag(command: IntrospectableCommand): boolean {\n const own = declaredArg(command, \"company\");\n return own !== null && own.type !== \"positional\";\n}\n\n/**\n * `argv` without `--company`, and the company it named, when the addressed\n * command does not declare the option itself. Otherwise `argv` is returned\n * untouched with `company: null`, for the command or the guard to judge.\n */\nexport function takeCompanyFlag(\n root: IntrospectableCommand,\n argv: string[],\n): { argv: string[]; company: string | null } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n for (let index = 0; index < limit; index++) {\n const token = argv[index] ?? \"\";\n let company: string | undefined;\n let width = 1;\n if (token.startsWith(`${FLAG}=`)) {\n company = token.slice(FLAG.length + 1).trim();\n } else if (token === FLAG) {\n const value = argv[index + 1];\n if (value === undefined || index + 1 >= limit || value.startsWith(\"-\")) {\n return { argv, company: null };\n }\n company = value.trim();\n width = 2;\n } else {\n continue;\n }\n const command = commandFor(root, argv);\n if (!company || !command || ownsCompanyFlag(command)) {\n return { argv, company: null };\n }\n return { argv: [...argv.slice(0, index), ...argv.slice(index + width)], company };\n }\n return { argv, company: null };\n}\n","/**\n * `--full` on every command that prints the JSON envelope.\n *\n * The conventions doc tells the agent that reads are compact and `--full` gives\n * the complete record, and the families that have a compact view declare it\n * (`ads meta ads|adsets|campaigns`, `images`, `winning-ads`, …). Everywhere\n * else the unknown-option guard (`unknown-flags.ts`) refused it, although those\n * commands already print everything they return: `ads meta creatives` loops,\n * `actions get`, `posts list` and `tags list` each lost calls and a retry to a\n * flag that asked for what the command was about to print (BAKER-1412, -182).\n *\n * So a command that does not declare `--full` has it taken off the command line\n * here, and every envelope it prints says so in `hints` — a dropped flag the\n * caller cannot see would read as \"this is the full record\" on a list whose\n * rows are summaries. A command that declares `--full` keeps its own meaning;\n * one that prints no envelope is left to the guard, as with `--output json`.\n */\n\nimport { declaredArg, printsDataEnvelope } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, reprint, rewriteWrites, withHint } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--full\";\n\n/**\n * The command a call to `command` runs: a group with a `default` hands the call,\n * flags and all, to that subcommand (`creatives rules` runs `list`).\n */\nexport function commandThatRuns(command: IntrospectableCommand): IntrospectableCommand {\n const name = (command as { default?: unknown }).default;\n const subCommands = command.subCommands;\n const next =\n typeof name === \"string\" && subCommands && typeof subCommands === \"object\"\n ? (subCommands as Record<string, unknown>)[name]\n : undefined;\n return next && typeof next === \"object\" ? commandThatRuns(next as IntrospectableCommand) : command;\n}\n\n/**\n * `argv` without `--full`, and whether it was there, when the addressed command\n * prints the envelope and does not declare the option itself. Otherwise `argv`\n * is returned untouched, for the command or the guard to judge.\n */\nexport function takeFullFlag(root: IntrospectableCommand, argv: string[]): { argv: string[]; taken: boolean } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n const taken = argv.flatMap((token, index) => (index < limit && token === FLAG ? [index] : []));\n if (taken.length === 0) {\n return { argv, taken: false };\n }\n const command = commandFor(root, argv);\n if (!command || declaredArg(commandThatRuns(command), \"full\") || !printsDataEnvelope(commandPathOf(root, argv))) {\n return { argv, taken: false };\n }\n return { argv: argv.filter((_, index) => !taken.includes(index)), taken: true };\n}\n\nfunction fullHint(commandPath: string): string {\n return (\n `--full changes nothing on \\`baker ${commandPath}\\`: it has no shorter view, so this is everything it returns. ` +\n \"Where its rows are summaries, read one record whole with the family's get or show command. Drop --full here.\"\n );\n}\n\n/**\n * The text a command printed, with a success envelope's `hints` saying `--full`\n * was taken and changed nothing; an error or a dry run comes back as printed,\n * and anything that is not an envelope (a readable view) is null.\n */\nexport function noteFullOnPrinted(text: string, commandPath: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n return reprint(text, withHint(envelope, fullHint(commandPath)));\n}\n\n/**\n * The note on the CLI's own stdout, and on stderr when the command printed no\n * envelope to carry it — a readable view such as `tags list` without `--json`.\n */\nexport function installFullNote(commandPath: string): void {\n const note = rewriteWrites(process.stdout, (text) => noteFullOnPrinted(text, commandPath));\n process.on(\"exit\", () => {\n if (!note.sawEnvelope()) {\n process.stderr.write(`${fullHint(commandPath)}\\n`);\n }\n });\n}\n","/**\n * What `--help` prints, for an agent that reads every byte of it.\n *\n * citty's renderer pads each table column to its widest cell, so one\n * paragraph-long description pads every other row of its table with thousands\n * of spaces (`baker analytics --help` printed 163 KB, 80% of it padding). And it\n * lists each subcommand with its whole description, so a family's help repeats\n * every command's own help. Here a COMMANDS row carries the first sentence (the\n * rest is one `--help` away), and no line ends in padding.\n */\n\nimport { type ArgsDef, type CommandDef, type CommandMeta, type Resolvable, renderUsage } from \"citty\";\n\nconst sentences = new Intl.Segmenter(\"en\", { granularity: \"sentence\" });\n/** ICU's sentence rules end a sentence at these; none of them ends one here. */\nconst abbreviation = /\\b(?:e\\.g|i\\.e|vs|etc)\\.$/i;\n\nfunction resolved<T>(value: Resolvable<T>): Promise<T> {\n return Promise.resolve(typeof value === \"function\" ? (value as () => T | Promise<T>)() : value);\n}\n\n/**\n * The description's first sentence. A line wrapped by hand continues on the\n * next one; a blank line, an indented example or a list item ends the prose.\n */\nfunction firstSentence(description: string): string {\n const [first = \"\", ...rest] = description.trim().split(\"\\n\");\n let prose = first.trim();\n for (const line of rest) {\n if (/[.:!?]$/.test(prose) || line.trim() === \"\" || /^(\\s|[-*•])/.test(line)) break;\n prose += ` ${line.trim()}`;\n }\n let sentence = \"\";\n for (const { segment } of sentences.segment(prose)) {\n sentence += segment;\n if (!abbreviation.test(sentence.trim())) break;\n }\n return (sentence || prose).trim();\n}\n\nasync function summarized(cmd: CommandDef<ArgsDef>): Promise<CommandDef<ArgsDef>> {\n if (!cmd.subCommands) return cmd;\n const subCommands = await resolved(cmd.subCommands);\n const listed: Record<string, CommandDef<ArgsDef>> = {};\n for (const [name, sub] of Object.entries(subCommands)) {\n const command: CommandDef<ArgsDef> = await resolved(sub);\n const meta: CommandMeta = (command.meta ? await resolved(command.meta) : undefined) ?? {};\n listed[name] = { meta: meta.description ? { ...meta, description: firstSentence(meta.description) } : meta };\n }\n return { ...cmd, subCommands: listed };\n}\n\nexport async function renderHelp<T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string> {\n const usage = await renderUsage(await summarized(cmd as CommandDef<ArgsDef>), parent as CommandDef<ArgsDef>);\n return usage\n .split(\"\\n\")\n .map((line) => line.trimEnd())\n .join(\"\\n\");\n}\n\ntype HelpSink = { write(chunk: string, done: () => void): unknown };\n\n/**\n * citty's `runMain` exits as soon as the help is printed. Piped, stdout writes\n * asynchronously, so an exit then cut the help at whatever had been flushed\n * (`baker --help | wc -c` read 65,536). This resolves once the write is done.\n */\nexport function printHelpTo(stdout: HelpSink) {\n return async <T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void> => {\n const help = await renderHelp(cmd, parent);\n await new Promise<void>((done) => stdout.write(`${help}\\n`, done));\n };\n}\n","/**\n * `--output md` on every command that prints the JSON envelope.\n *\n * The docs teach `--output md` as the way to read numbers, and the agent\n * carries the habit to sibling commands. Only the commands that built their own\n * Markdown view declared it, so `actions get`, `analytics map`, `analytics\n * sends` and the image provider searches refused it, and the agent paid a call\n * and then grepped the JSON instead (BAKER-2534, BAKER-1963).\n *\n * So a command that does not declare `--output` gets a generic rendering of what\n * it prints: a table for a list of records, `key: value` lines for one record,\n * and `meta`, warnings and `hints` kept below it. A command with its own\n * Markdown view keeps it, one whose own `--output` prints only other formats is\n * asked for `json` and rendered, one whose default is already a readable view\n * prints that view untouched, and one that prints no envelope is left to the\n * guard, as with `--fields`.\n */\n\nimport { commandThatRuns } from \"./full-flag.ts\";\nimport { outputRequests, ownOutput, printsDataEnvelope, withOutput } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, rewriteWrites } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FORMAT = \"md\";\n\n/**\n * `argv` without `--output md` when the addressed command prints the envelope\n * and has no Markdown view of its own: none declared, or a declared `--output`\n * that names only other formats (`linkedin demographics` prints `json` alone),\n * which is asked for `json` instead. `render` says the printed envelope is to be\n * rendered; a readable view printed instead passes through as it was. Otherwise\n * `argv` comes back untouched, for the command or the guard to judge.\n */\nexport function takeMdOutput(root: IntrospectableCommand, argv: string[]): { argv: string[]; render: boolean } {\n const requests = outputRequests(argv);\n const asked = requests.at(-1)?.value === FORMAT;\n const command = asked ? commandFor(root, argv) : null;\n if (!command) {\n return { argv, render: false };\n }\n const path = commandPathOf(root, argv);\n const own = ownOutput(commandThatRuns(command), path);\n const ownView =\n own.kind === \"not-a-format\" || (own.kind === \"formats\" && (own.formats.has(FORMAT) || !own.formats.has(\"json\")));\n if (ownView || !printsDataEnvelope(path)) {\n return { argv, render: false };\n }\n const taken = new Set(requests.filter((request) => request.value === FORMAT).flatMap((request) => request.indices));\n const rest = argv.filter((_, index) => !taken.has(index));\n return { argv: own.kind === \"formats\" ? withOutput(rest, \"json\") : rest, render: true };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isRecordList(value: unknown): value is Record<string, unknown>[] {\n return Array.isArray(value) && value.length > 0 && value.every(isRecord);\n}\n\n/** One table cell: nested values as JSON, on one line, with no `|` to break the row. */\nfunction cell(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n const text = typeof value === \"object\" ? JSON.stringify(value) : String(value);\n return text.replace(/\\|/g, \"\\\\|\").replace(/\\r?\\n/g, \" \");\n}\n\nfunction table(rows: Record<string, unknown>[]): string {\n const columns = [...new Set(rows.flatMap((row) => Object.keys(row)))];\n const line = (cells: string[]) => `| ${cells.join(\" | \")} |`;\n return `${[line(columns), line(columns.map(() => \"---\")), ...rows.map((row) => line(columns.map((c) => cell(row[c]))))].join(\"\\n\")}\\n`;\n}\n\n/** A value on one `key: value` line: a list joined, a nested record as its own `key: value` pairs. */\nfunction inline(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (Array.isArray(value)) {\n return value.length === 0 ? \"(none)\" : value.map(cell).join(\", \");\n }\n if (isRecord(value)) {\n return Object.entries(value)\n .map(([key, nested]) => `${key}: ${cell(nested)}`)\n .join(\", \");\n }\n return String(value);\n}\n\n/**\n * A record's values as lines, then each list of records it holds as a table\n * under its own heading — and, at the top, each record it holds as well.\n */\nfunction recordMd(record: Record<string, unknown>, nested = false): string {\n const lines: string[] = [];\n const sections: string[] = [];\n const heading = nested ? \"####\" : \"###\";\n for (const [key, value] of Object.entries(record)) {\n if (isRecordList(value)) {\n sections.push(`${heading} ${key}\\n\\n${table(value)}`);\n } else if (!nested && isRecord(value) && Object.keys(value).length > 0) {\n sections.push(`${heading} ${key}\\n\\n${recordMd(value, true)}`);\n } else {\n lines.push(`- **${key}:** ${inline(value)}`);\n }\n }\n return [...(lines.length > 0 ? [`${lines.join(\"\\n\")}\\n`] : []), ...sections].join(\"\\n\");\n}\n\nfunction dataMd(data: unknown): string {\n if (isRecordList(data)) return table(data);\n if (Array.isArray(data))\n return data.length === 0 ? \"(no rows)\\n\" : `${data.map((item) => `- ${cell(item)}`).join(\"\\n\")}\\n`;\n if (isRecord(data)) return Object.keys(data).length === 0 ? \"(empty)\\n\" : recordMd(data);\n return `${inline(data)}\\n`;\n}\n\n/**\n * A success envelope as Markdown: `data` rendered, then every other key\n * (`meta`, warnings, a notice) and the hints, which say whether the rows can be\n * trusted. A result printed beside `ok` rather than under `data` is the record.\n */\nexport function renderEnvelopeMd(envelope: Record<string, unknown>): string {\n const { ok: _ok, data, hints, ...rest } = envelope;\n const hasData = \"data\" in envelope;\n const parts = [hasData ? dataMd(data) : recordMd(rest)];\n const around = hasData ? Object.entries(rest) : [];\n if (around.length > 0) {\n parts.push(`${around.map(([key, value]) => `- **${key}:** ${inline(value)}`).join(\"\\n\")}\\n`);\n }\n if (Array.isArray(hints) && hints.length > 0) {\n parts.push(`${hints.map((hint) => `> ${String(hint).replace(/\\r?\\n/g, \"\\n> \")}`).join(\"\\n\")}\\n`);\n }\n return parts.join(\"\\n\");\n}\n\n/**\n * The text a command printed, rendered as Markdown when it is a success\n * envelope; an error or a dry run comes back as printed, and anything that is\n * not an envelope is null.\n */\nexport function renderPrintedMd(text: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n return renderEnvelopeMd(envelope);\n}\n\n/** The rendering on the CLI's own stdout. */\nexport function installMdRendering(): void {\n rewriteWrites(process.stdout, renderPrintedMd);\n}\n","/**\n * `--out <file>` on every command that prints the JSON envelope.\n *\n * The conventions doc teaches `--out <file>` as the way to take a big read whole\n * (\"one spelling on every family\"), but only the commands that wrote their own\n * export declared it. `analytics releases`, `ads meta insights`, `ads google\n * changes`, `history list` and the research reads refused it, and the agent\n * redirected stdout and grepped pretty JSON instead (BAKER-2415, -936, -497).\n *\n * So a command that does not declare `--out` gets it here: its envelope goes to\n * the file whole, and stdout carries a summary — the file, its size, the row\n * count, and the `meta`, warnings and `hints` that say whether the read can be\n * trusted. A command whose own `--output` prints csv, jsonl or files writes that\n * text to the file instead. A command that declares `--out` keeps its own\n * export, and one that prints no envelope is left to the guard, as with\n * `--fields`.\n */\n\nimport { appendFileSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { commandThatRuns } from \"./full-flag.ts\";\nimport { declaredArg, outputRequests, ownOutput, printsDataEnvelope, withOutput } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, reprint, rewriteWrites, type WriteTarget } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--out\";\n\n/** What stays in the summary of an envelope whose result sits beside `ok` rather than under `data`. */\nconst TRUST_KEYS = [\"meta\", \"warnings\", \"notice\", \"hints\"];\n\n/**\n * Where `--out <file>` sits in `argv` before `--`, and the file it names; null\n * when it is absent, or bare and naming no file — the guard says so.\n */\nfunction outRequest(argv: string[]): { taken: Set<number>; file: string } | null {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n const taken = new Set<number>();\n let file: string | null = null;\n for (let index = 0; index < limit; index++) {\n const token = argv[index] ?? \"\";\n if (token.startsWith(`${FLAG}=`) && token.length > FLAG.length + 1) {\n taken.add(index);\n file = token.slice(FLAG.length + 1);\n } else if (token === FLAG) {\n const value = argv[index + 1];\n if (value === undefined || index + 1 >= limit || value.startsWith(\"-\")) {\n return null;\n }\n taken.add(index).add(index + 1);\n file = value;\n index++;\n }\n }\n return file === null ? null : { taken, file };\n}\n\n/**\n * What `--out` asks of the command it addresses: `argv` to run it with, the\n * file (null when `argv` comes back untouched, for the command or the guard),\n * whether the file takes the envelope or the text the command prints in a\n * format of its own (csv, jsonl, files), and whether the summary is to be\n * rendered as Markdown because the call asked for `--output md`.\n */\nexport type OutTarget = {\n argv: string[];\n file: string | null;\n writes: \"envelope\" | \"printed\";\n summaryMd: boolean;\n};\n\n/**\n * `argv` without `--out <file>`, and the file, when the addressed command prints\n * the envelope and does not declare the option. A command whose default is a\n * readable view — its own `--json` switch, or an own `--output` defaulting to\n * `md` — is asked for its envelope, and so is an explicit `--output md`, whose\n * summary is then rendered. Another format the command prints itself is written\n * to the file as printed.\n */\nexport function takeOutFlag(root: IntrospectableCommand, argv: string[]): OutTarget {\n const untouched: OutTarget = { argv, file: null, writes: \"envelope\", summaryMd: false };\n const request = outRequest(argv);\n const command = request === null ? null : commandFor(root, argv);\n if (request === null || !command) {\n return untouched;\n }\n const path = commandPathOf(root, argv);\n const runs = commandThatRuns(command);\n if (declaredArg(runs, \"out\") !== null || !printsDataEnvelope(path)) {\n return untouched;\n }\n const rest = argv.filter((_, index) => !request.taken.has(index));\n const own = ownOutput(runs, path);\n if (own.kind === \"formats\") {\n const formats = outputRequests(rest);\n const asked = formats.at(-1)?.value ?? own.default;\n if (asked === \"json\") {\n return { argv: rest, file: request.file, writes: \"envelope\", summaryMd: false };\n }\n if (asked === \"md\" && own.formats.has(\"json\")) {\n const dropped = new Set(formats.flatMap((format) => format.indices));\n return {\n argv: withOutput(\n rest.filter((_, index) => !dropped.has(index)),\n \"json\",\n ),\n file: request.file,\n writes: \"envelope\",\n summaryMd: formats.length > 0,\n };\n }\n return { argv: rest, file: request.file, writes: \"printed\", summaryMd: false };\n }\n const needsJson = declaredArg(runs, \"json\")?.type === \"boolean\" && !rest.includes(\"--json\");\n return { argv: needsJson ? [...rest, \"--json\"] : rest, file: request.file, writes: \"envelope\", summaryMd: false };\n}\n\n/**\n * The text a command printed, with a success envelope written whole to `file`\n * and replaced by its summary. An error or a dry run comes back as printed and\n * writes nothing; anything that is not an envelope is null.\n */\nexport function writePrintedToFile(text: string, file: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n const path = resolve(file);\n const body = `${JSON.stringify(envelope, null, 2)}\\n`;\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, body);\n const { ok: _ok, data, ...rest } = envelope;\n const around =\n \"data\" in envelope ? rest : Object.fromEntries(TRUST_KEYS.filter((k) => k in rest).map((k) => [k, rest[k]]));\n return reprint(text, {\n ok: true,\n file: path,\n bytes: Buffer.byteLength(body),\n ...(Array.isArray(data) ? { rows: data.length } : {}),\n ...around,\n });\n}\n\n/**\n * The text a command prints in a format of its own (csv, jsonl, files), written\n * to `file` as it comes instead of to `stream`. An error envelope still reaches\n * `stream`. `finish()` is the summary to print once the command is done, or\n * null when it printed nothing to write.\n */\nexport function capturePrintedText(stream: WriteTarget, file: string, format: string): { finish: () => string | null } {\n const path = resolve(file);\n const write = stream.write.bind(stream);\n let bytes: number | null = null;\n stream.write = (chunk: string | Uint8Array, ...rest: never[]): boolean => {\n const text = typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(\"utf8\");\n if (parsePrintedEnvelope(text)?.ok === false) {\n return write(chunk, ...rest);\n }\n if (bytes === null) {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, text);\n bytes = 0;\n } else {\n appendFileSync(path, text);\n }\n bytes += Buffer.byteLength(text);\n const done = (rest as unknown[]).find((arg) => typeof arg === \"function\");\n if (typeof done === \"function\") {\n process.nextTick(() => done());\n }\n return true;\n };\n return {\n finish: () => (bytes === null ? null : `${JSON.stringify({ ok: true, file: path, bytes, format })}\\n`),\n };\n}\n\n/**\n * The file on the CLI's own stdout, and a note on stderr when the command\n * printed nothing to write, so the agent does not go looking for a file.\n */\nexport function installOutFile(file: string, commandPath: string, target: Pick<OutTarget, \"writes\" | \"argv\">): void {\n if (target.writes === \"printed\") {\n const print = process.stdout.write.bind(process.stdout);\n const format = outputRequests(target.argv).at(-1)?.value ?? \"its default format\";\n const captured = capturePrintedText(process.stdout, file, format);\n process.on(\"exit\", () => {\n const summary = captured.finish();\n if (summary === null) {\n process.stderr.write(`--out wrote no file: \\`baker ${commandPath}\\` printed nothing to write.\\n`);\n } else {\n print(summary);\n }\n });\n return;\n }\n const out = rewriteWrites(process.stdout, (text) => writePrintedToFile(text, file));\n process.on(\"exit\", () => {\n if (!out.sawEnvelope()) {\n process.stderr.write(`--out wrote no file: \\`baker ${commandPath}\\` printed no JSON envelope to write.\\n`);\n }\n });\n}\n","import { defineCommand } from \"citty\";\nimport { getCliVersion } from \"./version.ts\";\n\n// Every command is declared lazily and only the one being run is loaded\n// (`command-loading.ts`): loading all of them made each `baker` process hold\n// ~135 MB of heap while it waited on one request.\nexport const rootCommand = defineCommand({\n meta: {\n name: \"baker\",\n version: getCliVersion(),\n description: `AI-agent CLI for finding and managing images, videos, social posts, avatars, testimonials, action items, scheduled agents, marketing tags, Tag Manager containers, account history, credentials, and ad platform data in Baker.\n\nAuth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.\nChat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.\nOutput: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.\nFields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.\nFull: --full returns the complete record where a command has a compact view; elsewhere it is accepted and changes nothing (a hint says so), except on 'canvas run' and 'canvas rerun', which refuse it.\nCompany: --company <id> runs a read against another company of the organization (organization workspace only; ids from 'baker organization companies').\nFormats: --output json and --output md work on every command that prints the envelope (md: a table for a list, key: value lines for a record). --output files only where 'baker schema <command>' lists output. (The research commands additionally accept csv and jsonl.)\nFile: --out <file> writes the whole envelope to a file and prints a summary (file, bytes, rows, meta, hints), on every command that prints the envelope (with --output csv|jsonl|files, the text that format prints); a command with its own --out (ads google query, ga4 query, ...) writes its rows instead.\nIntrospection: Run 'baker schema <command>' to inspect argument schemas.`,\n },\n subCommands: {\n capabilities: () => import(\"./commands/capabilities/index.ts\").then((m) => m.capabilitiesCommand),\n actions: () => import(\"./commands/actions/index.ts\").then((m) => m.actionsCommand),\n \"scheduled-agents\": () => import(\"./commands/scheduled-agents/index.ts\").then((m) => m.scheduledAgentsCommand),\n ads: () => import(\"./commands/ads/index.ts\").then((m) => m.adsCommand),\n brand: () => import(\"./commands/brand/index.ts\").then((m) => m.brandCommand),\n analytics: () => import(\"./commands/analytics/index.ts\").then((m) => m.analyticsCommand),\n experiment: () => import(\"./commands/experiment/index.ts\").then((m) => m.experimentCommand),\n ga4: () => import(\"./commands/ga4/index.ts\").then((m) => m.ga4Command),\n gsc: () => import(\"./commands/gsc/index.ts\").then((m) => m.gscCommand),\n research: () => import(\"./commands/research/index.ts\").then((m) => m.researchCommand),\n decide: () => import(\"./commands/decide/index.ts\").then((m) => m.decideCommand),\n knowledge: () => import(\"./commands/knowledge/index.ts\").then((m) => m.knowledgeCommand),\n creatives: () => import(\"./commands/creatives/index.ts\").then((m) => m.creativesCommand),\n flows: () => import(\"./commands/flows/index.ts\").then((m) => m.flowsCommand),\n funnel: () => import(\"./commands/funnel/index.ts\").then((m) => m.funnelCommand),\n images: () => import(\"./commands/images/index.ts\").then((m) => m.imagesCommand),\n studio: () => import(\"./commands/studio/index.ts\").then((m) => m.studioCommand),\n avatars: () => import(\"./commands/avatars/index.ts\").then((m) => m.avatarsCommand),\n landing: () => import(\"./commands/landing/index.ts\").then((m) => m.landingCommand),\n videos: () => import(\"./commands/videos/index.ts\").then((m) => m.videosCommand),\n testimonials: () => import(\"./commands/testimonials/index.ts\").then((m) => m.testimonialsCommand),\n canvas: () => import(\"./commands/canvas/index.ts\").then((m) => m.canvasCommand),\n tags: () => import(\"./commands/tags/index.ts\").then((m) => m.tagsCommand),\n \"tag-manager\": () => import(\"./commands/tag-manager/index.ts\").then((m) => m.tagManagerCommand),\n chats: () => import(\"./commands/chats/index.ts\").then((m) => m.chatsCommand),\n history: () => import(\"./commands/history/index.ts\").then((m) => m.historyCommand),\n credentials: () => import(\"./commands/credentials/index.ts\").then((m) => m.credentialsCommand),\n hubspot: () => import(\"./commands/hubspot/index.ts\").then((m) => m.hubspotCommand),\n activecampaign: () => import(\"./commands/activecampaign/index.ts\").then((m) => m.activecampaignCommand),\n accounts: () => import(\"./commands/accounts/index.ts\").then((m) => m.accountsCommand),\n shopify: () => import(\"./commands/shopify/index.ts\").then((m) => m.shopifyCommand),\n \"winning-ads\": () => import(\"./commands/winning-ads/index.ts\").then((m) => m.winningAdsCommand),\n \"media-sources\": () => import(\"./commands/media-sources/index.ts\").then((m) => m.mediaSourcesCommand),\n posts: () => import(\"./commands/posts/index.ts\").then((m) => m.postsCommand),\n site: () => import(\"./commands/site/index.ts\").then((m) => m.siteCommand),\n \"lead-routes\": () => import(\"./commands/lead-routes/index.ts\").then((m) => m.leadRoutesCommand),\n mcp: () => import(\"./commands/mcp/index.ts\").then((m) => m.mcpCommand),\n \"setup-links\": () => import(\"./commands/setup-links/index.ts\").then((m) => m.setupLinksCommand),\n organization: () => import(\"./commands/organization/index.ts\").then((m) => m.organizationCommand),\n schema: () => import(\"./commands/schema.ts\").then((m) => m.schemaCommand),\n },\n});\n","import { readFileSync } from \"node:fs\";\n\nfunction packageJsonUrl(): URL {\n return new URL(\"../package.json\", import.meta.url);\n}\n\nfunction parsePackageVersion(raw: string): string {\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n \"version\" in parsed &&\n typeof parsed.version === \"string\" &&\n parsed.version.length > 0\n ) {\n return parsed.version;\n }\n throw new Error(\"Invalid CLI package.json: missing version\");\n}\n\nexport function getCliVersion(): string {\n return parsePackageVersion(readFileSync(packageJsonUrl(), \"utf8\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,eAAe;;;ACS7B,SAAS,wBAAwB,QAAqB,MAAoC;AAC/F,SAAO,GAAG,SAAS,CAAC,QAAQ;AAC1B,QAAI,IAAI,SAAS,SAAS;AACxB,WAAK,CAAC;AACN;AAAA,IACF;AACA,UAAM;AAAA,EACR,CAAC;AACH;;;ACDA,IAAM,OAAO;AAGb,SAAS,gBAAgB,SAAyC;AAChE,QAAM,MAAM,YAAY,SAAS,SAAS;AAC1C,SAAO,QAAQ,QAAQ,IAAI,SAAS;AACtC;AAOO,SAAS,gBACd,MACA,MAC4C;AAC5C,QAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,QAAM,QAAQ,QAAQ,KAAK,KAAK,SAAS;AACzC,WAAS,QAAQ,GAAG,QAAQ,OAAO,SAAS;AAC1C,UAAM,QAAQ,KAAK,KAAK,KAAK;AAC7B,QAAI;AACJ,QAAI,QAAQ;AACZ,QAAI,MAAM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AACpC,IACE,QAAQ,KAAK,CAAC,QAAQ,QAAQ,YAAY,QAAQ,IAAI,KACrD,QAAQ,WAAW,KAAK,mBAAmB,KAAK,QAAQ,CAAC,KAAK,EAAE,GACjE;AACA,QAAM,UAAU,yBAAyB,MAAM,OAAO;AACtD,MAAI,SAAS;AACX,cAAU,OAAO;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,UAAQ,MAAM,EAAE,WAAW,YAAY,QAAQ,MAAM,EAAE,CAAC;AAC1D,OAAO;AACL,MAAI;AACF,UAAM,WAAW,MAAM,EAAE,QAAQ,CAAC;AAAA,EACpC,SAAS,OAAO;AACd,UAAM,UAAU,qBAAqB,OAAO,MAAM,OAAO;AACzD,QAAI,SAAS;AACX,gBAAU,OAAO;AAAA,IACnB,OAAO;AACL,cAAQ,MAAM,OAAO,IAAI;AAAA,IAC3B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":["FLAG","FLAG"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/closed-pipe.ts","../src/company-flag.ts","../src/full-flag.ts","../src/help-output.ts","../src/md-output.ts","../src/out-flag.ts","../src/root-command.ts","../src/version.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { runCommand, runMain } from \"citty\";\nimport { agentProfile, applyAgentProfile } from \"./agent-profile.ts\";\nimport { cacheFlagForCommand, cacheFlagForParser, normalizeCacheFlag } from \"./cache-flag.ts\";\nimport { exitQuietlyOnClosedPipe } from \"./closed-pipe.ts\";\nimport { loadCommands } from \"./command-loading.ts\";\nimport { takeCompanyFlag } from \"./company-flag.ts\";\nimport { installExitRecord, installStreamTaps, logInvocation } from \"./debugLog.ts\";\nimport { setTargetCompany } from \"./env.ts\";\nimport { installFieldMask, takeFieldsFlag } from \"./field-mask.ts\";\nimport { installFullNote, takeFullFlag } from \"./full-flag.ts\";\nimport { printHelpTo } from \"./help-output.ts\";\nimport { installMdRendering, takeMdOutput } from \"./md-output.ts\";\nimport { installOutFile, takeOutFlag } from \"./out-flag.ts\";\nimport { writeJson } from \"./output.ts\";\nimport { asksForEnvelopeAlone, envelopeAloneOnStdout, outputFlagForCommand } from \"./output-flag.ts\";\nimport { rootCommand } from \"./root-command.ts\";\nimport { registerCommandTree } from \"./schemas.ts\";\nimport {\n commandPathOf,\n parseRefusalEnvelope,\n refuseStrayPositionals,\n refuseUnknownFlags,\n unknownSubCommandRefusal,\n} from \"./unknown-flags.ts\";\n\nconst main = rootCommand;\n// The call as typed, before the rewrites below: a refusal's corrected call is built from it.\nconst typedArgv = process.argv.slice(2);\n\nawait loadCommands(main, process.argv.slice(2));\nregisterCommandTree(main);\n\nexitQuietlyOnClosedPipe(process.stdout, (code) => process.exit(code));\n\n// The legacy `--skip-cache` spelling becomes `--no-cache` before anything reads\n// argv — citty parses `process.argv` itself, so the rewrite has to land there.\nprocess.argv = [...process.argv.slice(0, 2), ...normalizeCacheFlag(process.argv.slice(2))];\n\n// When BAKER_DEBUG_LOG is set, mirror all output and record the invocation\n// before any command runs. No-op otherwise.\ninstallStreamTaps();\nlogInvocation(process.argv.slice(2));\ninstallExitRecord();\n\n// `--output json` asks for the envelope, which almost every command prints\n// without declaring the option — translated here so the guard below does not\n// refuse a flag that asked for what the command was about to print.\n// `canvas run` prints progress before its envelope: asked for the envelope, it\n// prints that alone on stdout and the progress on stderr.\nif (asksForEnvelopeAlone(main, process.argv.slice(2))) {\n envelopeAloneOnStdout(process.stdout, process.stderr);\n}\nprocess.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];\n\n// `--output md` and `--out <file>` act on the envelope a command prints when it\n// has no Markdown view or export of its own. Installed before the mask and the `--full` note, so\n// each envelope is narrowed first, then written to the file, then rendered.\nconst mdOutput = takeMdOutput(main, process.argv.slice(2));\nprocess.argv = [...process.argv.slice(0, 2), ...mdOutput.argv];\nif (mdOutput.render) {\n installMdRendering();\n}\n// A command with its own Markdown view asked for `--output md --out <file>` is\n// asked for its envelope instead, and the summary is what gets rendered.\nconst outFlag = takeOutFlag(main, process.argv.slice(2));\nif (outFlag.file) {\n process.argv = [...process.argv.slice(0, 2), ...outFlag.argv];\n if (outFlag.summaryMd && !mdOutput.render) {\n installMdRendering();\n }\n installOutFile(outFlag.file, commandPathOf(main, outFlag.argv), outFlag);\n}\n\n// `--fields` narrows the envelope on every command that prints one; where the\n// command does not declare it, it is applied to what the command prints.\nconst fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));\nif (fieldsFlag.fields) {\n process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];\n installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));\n}\n\n// `--full` on a command with no shorter view asks for what it already prints:\n// taken off here, and said back in the envelope's hints.\nconst fullFlag = takeFullFlag(main, process.argv.slice(2));\nif (fullFlag.taken) {\n process.argv = [...process.argv.slice(0, 2), ...fullFlag.argv];\n installFullNote(commandPathOf(main, fullFlag.argv));\n}\n\n// `--company <id>` names the company a read is about (the organization\n// workspace's Reports read every company of its organization). It travels as a\n// header on every request, so it is taken off here, before the guard.\nconst companyFlag = takeCompanyFlag(main, process.argv.slice(2));\nif (companyFlag.company) {\n process.argv = [...process.argv.slice(0, 2), ...companyFlag.argv];\n setTargetCompany(companyFlag.company);\n}\n\n// What this agent is offered: the organization workspace's agent only reads\n// (`agent-profile.ts`). Here, after `--company` is taken off, so the command it\n// judges is the one typed.\nconst profileRefusal = await applyAgentProfile(main, agentProfile(), process.argv.slice(2));\nif (profileRefusal) {\n writeJson({ ok: false, error: { code: \"FORBIDDEN\", message: profileRefusal } });\n process.exit(1);\n}\n\n// A report's Refresh appends `--no-cache` to every read; a command with no cache\n// already reads fresh, so it is dropped there rather than refused.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForCommand(main, process.argv.slice(2))];\n\nrefuseUnknownFlags(main, process.argv.slice(2), typedArgv);\nrefuseStrayPositionals(main, process.argv.slice(2));\n\n// Last, so the guard above quotes back the spelling the caller typed: citty\n// resolves a bare `--no-cache` to `cache: false` instead of filling the declared\n// `no-cache` arg, and only the camelCase spelling survives its parser intact.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];\n\n// `--help` and `--version` stay citty's own, the help rendered for an agent\n// reading it (`help-output.ts`), except help on a subcommand that does not\n// exist, which is refused like a call to it. Everything else runs here rather\n// than through `runMain`, whose refusal of a missing argument or an unknown\n// subcommand is usage text on stderr and nothing on stdout: that becomes the\n// envelope every other failure prints.\nconst rawArgs = process.argv.slice(2);\nif (\n rawArgs.some((arg) => arg === \"--help\" || arg === \"-h\") ||\n (rawArgs.length === 1 && /^(--version|-v)$/.test(rawArgs[0] ?? \"\"))\n) {\n const unknown = unknownSubCommandRefusal(main, rawArgs);\n if (unknown) {\n writeJson(unknown);\n process.exit(1);\n }\n runMain(main, { showUsage: printHelpTo(process.stdout) });\n} else {\n try {\n await runCommand(main, { rawArgs });\n } catch (error) {\n const refusal = parseRefusalEnvelope(error, main, rawArgs);\n if (refusal) {\n writeJson(refusal);\n } else {\n console.error(error, \"\\n\");\n }\n process.exit(1);\n }\n}\n","interface ErrorSource {\n on(event: \"error\", listener: (err: NodeJS.ErrnoException) => void): unknown;\n}\n\n/**\n * `baker … | head` closes the pipe once it has its lines. Node reports the next\n * write as an unhandled EPIPE and prints a stack trace, which reads as a crash of\n * a command that did its job. A closed reader wants nothing more, so exit cleanly,\n * as Unix tools do; any other write error still surfaces.\n */\nexport function exitQuietlyOnClosedPipe(stream: ErrorSource, exit: (code: number) => void): void {\n stream.on(\"error\", (err) => {\n if (err.code === \"EPIPE\") {\n exit(0);\n return;\n }\n throw err;\n });\n}\n","/**\n * `--company <id>` on every command: the company the call reads, for the\n * organization workspace, whose Reports read every company of its organization.\n *\n * It is a header, not an argument of each command (`x-baker-company`, sent by\n * `client.ts`), so every read the CLI has works across companies unchanged, and\n * the backend alone decides what it opens: reads of a company of the same\n * organization, for the organization workspace's credential, and nothing else.\n *\n * A command that declares `--company` itself keeps its own meaning — on\n * `avatars research` it is the person's employer. A positional named `company`\n * (`accounts company acme.com`) is not a flag, so the flag stays the header.\n */\n\nimport { declaredArg } from \"./output-flag.ts\";\nimport { commandFor, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--company\";\n\n/** The command reads `--company` itself; a positional of that name is no flag, so it is not. */\nfunction ownsCompanyFlag(command: IntrospectableCommand): boolean {\n const own = declaredArg(command, \"company\");\n return own !== null && own.type !== \"positional\";\n}\n\n/**\n * `argv` without `--company`, and the company it named, when the addressed\n * command does not declare the option itself. Otherwise `argv` is returned\n * untouched with `company: null`, for the command or the guard to judge.\n */\nexport function takeCompanyFlag(\n root: IntrospectableCommand,\n argv: string[],\n): { argv: string[]; company: string | null } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n for (let index = 0; index < limit; index++) {\n const token = argv[index] ?? \"\";\n let company: string | undefined;\n let width = 1;\n if (token.startsWith(`${FLAG}=`)) {\n company = token.slice(FLAG.length + 1).trim();\n } else if (token === FLAG) {\n const value = argv[index + 1];\n if (value === undefined || index + 1 >= limit || value.startsWith(\"-\")) {\n return { argv, company: null };\n }\n company = value.trim();\n width = 2;\n } else {\n continue;\n }\n const command = commandFor(root, argv);\n if (!company || !command || ownsCompanyFlag(command)) {\n return { argv, company: null };\n }\n return { argv: [...argv.slice(0, index), ...argv.slice(index + width)], company };\n }\n return { argv, company: null };\n}\n","/**\n * `--full` on every command that prints the JSON envelope.\n *\n * The conventions doc tells the agent that reads are compact and `--full` gives\n * the complete record, and the families that have a compact view declare it\n * (`ads meta ads|adsets|campaigns`, `images`, `winning-ads`, …). Everywhere\n * else the unknown-option guard (`unknown-flags.ts`) refused it, although those\n * commands already print everything they return: `ads meta creatives` loops\n * (before its rows became compact), `actions get`, `posts list` and `tags list` each lost calls and a retry to a\n * flag that asked for what the command was about to print (BAKER-1412, -182).\n *\n * So a command that does not declare `--full` has it taken off the command line\n * here, and every envelope it prints says so in `hints` — a dropped flag the\n * caller cannot see would read as \"this is the full record\" on a list whose\n * rows are summaries. A command that declares `--full` keeps its own meaning;\n * one that prints no envelope is left to the guard, as with `--output json`.\n */\n\nimport { declaredArg, printsDataEnvelope } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, reprint, rewriteWrites, withHint } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--full\";\n\n/**\n * The command a call to `command` runs: a group with a `default` hands the call,\n * flags and all, to that subcommand (`creatives rules` runs `list`).\n */\nexport function commandThatRuns(command: IntrospectableCommand): IntrospectableCommand {\n const name = (command as { default?: unknown }).default;\n const subCommands = command.subCommands;\n const next =\n typeof name === \"string\" && subCommands && typeof subCommands === \"object\"\n ? (subCommands as Record<string, unknown>)[name]\n : undefined;\n return next && typeof next === \"object\" ? commandThatRuns(next as IntrospectableCommand) : command;\n}\n\n/**\n * `argv` without `--full`, and whether it was there, when the addressed command\n * prints the envelope and does not declare the option itself. Otherwise `argv`\n * is returned untouched, for the command or the guard to judge.\n */\nexport function takeFullFlag(root: IntrospectableCommand, argv: string[]): { argv: string[]; taken: boolean } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n const taken = argv.flatMap((token, index) => (index < limit && token === FLAG ? [index] : []));\n if (taken.length === 0) {\n return { argv, taken: false };\n }\n const command = commandFor(root, argv);\n if (!command || declaredArg(commandThatRuns(command), \"full\") || !printsDataEnvelope(commandPathOf(root, argv))) {\n return { argv, taken: false };\n }\n return { argv: argv.filter((_, index) => !taken.includes(index)), taken: true };\n}\n\nfunction fullHint(commandPath: string): string {\n return (\n `--full changes nothing on \\`baker ${commandPath}\\`: it has no shorter view, so this is everything it returns. ` +\n \"Where its rows are summaries, read one record whole with the family's get or show command. Drop --full here.\"\n );\n}\n\n/**\n * The text a command printed, with a success envelope's `hints` saying `--full`\n * was taken and changed nothing; an error or a dry run comes back as printed,\n * and anything that is not an envelope (a readable view) is null.\n */\nexport function noteFullOnPrinted(text: string, commandPath: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n return reprint(text, withHint(envelope, fullHint(commandPath)));\n}\n\n/**\n * The note on the CLI's own stdout, and on stderr when the command printed no\n * envelope to carry it — a readable view such as `tags list` without `--json`.\n */\nexport function installFullNote(commandPath: string): void {\n const note = rewriteWrites(process.stdout, (text) => noteFullOnPrinted(text, commandPath));\n process.on(\"exit\", () => {\n if (!note.sawEnvelope()) {\n process.stderr.write(`${fullHint(commandPath)}\\n`);\n }\n });\n}\n","/**\n * What `--help` prints, for an agent that reads every byte of it.\n *\n * citty's renderer pads each table column to its widest cell, so one\n * paragraph-long description pads every other row of its table with thousands\n * of spaces (`baker analytics --help` printed 163 KB, 80% of it padding). And it\n * lists each subcommand with its whole description, so a family's help repeats\n * every command's own help. Here a COMMANDS row carries the first sentence (the\n * rest is one `--help` away), and no line ends in padding.\n */\n\nimport { type ArgsDef, type CommandDef, type CommandMeta, type Resolvable, renderUsage } from \"citty\";\n\nconst sentences = new Intl.Segmenter(\"en\", { granularity: \"sentence\" });\n/** ICU's sentence rules end a sentence at these; none of them ends one here. */\nconst abbreviation = /\\b(?:e\\.g|i\\.e|vs|etc)\\.$/i;\n\nfunction resolved<T>(value: Resolvable<T>): Promise<T> {\n return Promise.resolve(typeof value === \"function\" ? (value as () => T | Promise<T>)() : value);\n}\n\n/**\n * The description's first sentence. A line wrapped by hand continues on the\n * next one; a blank line, an indented example or a list item ends the prose.\n */\nfunction firstSentence(description: string): string {\n const [first = \"\", ...rest] = description.trim().split(\"\\n\");\n let prose = first.trim();\n for (const line of rest) {\n if (/[.:!?]$/.test(prose) || line.trim() === \"\" || /^(\\s|[-*•])/.test(line)) break;\n prose += ` ${line.trim()}`;\n }\n let sentence = \"\";\n for (const { segment } of sentences.segment(prose)) {\n sentence += segment;\n if (!abbreviation.test(sentence.trim())) break;\n }\n return (sentence || prose).trim();\n}\n\nasync function summarized(cmd: CommandDef<ArgsDef>): Promise<CommandDef<ArgsDef>> {\n if (!cmd.subCommands) return cmd;\n const subCommands = await resolved(cmd.subCommands);\n const listed: Record<string, CommandDef<ArgsDef>> = {};\n for (const [name, sub] of Object.entries(subCommands)) {\n const command: CommandDef<ArgsDef> = await resolved(sub);\n const meta: CommandMeta = (command.meta ? await resolved(command.meta) : undefined) ?? {};\n listed[name] = { meta: meta.description ? { ...meta, description: firstSentence(meta.description) } : meta };\n }\n return { ...cmd, subCommands: listed };\n}\n\nexport async function renderHelp<T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string> {\n const usage = await renderUsage(await summarized(cmd as CommandDef<ArgsDef>), parent as CommandDef<ArgsDef>);\n return usage\n .split(\"\\n\")\n .map((line) => line.trimEnd())\n .join(\"\\n\");\n}\n\ntype HelpSink = { write(chunk: string, done: () => void): unknown };\n\n/**\n * citty's `runMain` exits as soon as the help is printed. Piped, stdout writes\n * asynchronously, so an exit then cut the help at whatever had been flushed\n * (`baker --help | wc -c` read 65,536). This resolves once the write is done.\n */\nexport function printHelpTo(stdout: HelpSink) {\n return async <T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void> => {\n const help = await renderHelp(cmd, parent);\n await new Promise<void>((done) => stdout.write(`${help}\\n`, done));\n };\n}\n","/**\n * `--output md` on every command that prints the JSON envelope.\n *\n * The docs teach `--output md` as the way to read numbers, and the agent\n * carries the habit to sibling commands. Only the commands that built their own\n * Markdown view declared it, so `actions get`, `analytics map`, `analytics\n * sends` and the image provider searches refused it, and the agent paid a call\n * and then grepped the JSON instead (BAKER-2534, BAKER-1963).\n *\n * So a command that does not declare `--output` gets a generic rendering of what\n * it prints: a table for a list of records, `key: value` lines for one record,\n * and `meta`, warnings and `hints` kept below it. A command with its own\n * Markdown view keeps it, one whose own `--output` prints only other formats is\n * asked for `json` and rendered, one whose default is already a readable view\n * prints that view untouched, and one that prints no envelope is left to the\n * guard, as with `--fields`.\n */\n\nimport { commandThatRuns } from \"./full-flag.ts\";\nimport { outputRequests, ownOutput, printsDataEnvelope, withOutput } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, rewriteWrites } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FORMAT = \"md\";\n\n/**\n * `argv` without `--output md` when the addressed command prints the envelope\n * and has no Markdown view of its own: none declared, or a declared `--output`\n * that names only other formats (`linkedin demographics` prints `json` alone),\n * which is asked for `json` instead. `render` says the printed envelope is to be\n * rendered; a readable view printed instead passes through as it was. Otherwise\n * `argv` comes back untouched, for the command or the guard to judge.\n */\nexport function takeMdOutput(root: IntrospectableCommand, argv: string[]): { argv: string[]; render: boolean } {\n const requests = outputRequests(argv);\n const asked = requests.at(-1)?.value === FORMAT;\n const command = asked ? commandFor(root, argv) : null;\n if (!command) {\n return { argv, render: false };\n }\n const path = commandPathOf(root, argv);\n const own = ownOutput(commandThatRuns(command), path);\n const ownView =\n own.kind === \"not-a-format\" || (own.kind === \"formats\" && (own.formats.has(FORMAT) || !own.formats.has(\"json\")));\n if (ownView || !printsDataEnvelope(path)) {\n return { argv, render: false };\n }\n const taken = new Set(requests.filter((request) => request.value === FORMAT).flatMap((request) => request.indices));\n const rest = argv.filter((_, index) => !taken.has(index));\n return { argv: own.kind === \"formats\" ? withOutput(rest, \"json\") : rest, render: true };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isRecordList(value: unknown): value is Record<string, unknown>[] {\n return Array.isArray(value) && value.length > 0 && value.every(isRecord);\n}\n\n/** One table cell: nested values as JSON, on one line, with no `|` to break the row. */\nfunction cell(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n const text = typeof value === \"object\" ? JSON.stringify(value) : String(value);\n return text.replace(/\\|/g, \"\\\\|\").replace(/\\r?\\n/g, \" \");\n}\n\nfunction table(rows: Record<string, unknown>[]): string {\n const columns = [...new Set(rows.flatMap((row) => Object.keys(row)))];\n const line = (cells: string[]) => `| ${cells.join(\" | \")} |`;\n return `${[line(columns), line(columns.map(() => \"---\")), ...rows.map((row) => line(columns.map((c) => cell(row[c]))))].join(\"\\n\")}\\n`;\n}\n\n/** A value on one `key: value` line: a list joined, a nested record as its own `key: value` pairs. */\nfunction inline(value: unknown): string {\n if (value === null || value === undefined) return \"\";\n if (Array.isArray(value)) {\n return value.length === 0 ? \"(none)\" : value.map(cell).join(\", \");\n }\n if (isRecord(value)) {\n return Object.entries(value)\n .map(([key, nested]) => `${key}: ${cell(nested)}`)\n .join(\", \");\n }\n return String(value);\n}\n\n/**\n * A record's values as lines, then each list of records it holds as a table\n * under its own heading — and, at the top, each record it holds as well.\n */\nfunction recordMd(record: Record<string, unknown>, nested = false): string {\n const lines: string[] = [];\n const sections: string[] = [];\n const heading = nested ? \"####\" : \"###\";\n for (const [key, value] of Object.entries(record)) {\n if (isRecordList(value)) {\n sections.push(`${heading} ${key}\\n\\n${table(value)}`);\n } else if (!nested && isRecord(value) && Object.keys(value).length > 0) {\n sections.push(`${heading} ${key}\\n\\n${recordMd(value, true)}`);\n } else {\n lines.push(`- **${key}:** ${inline(value)}`);\n }\n }\n return [...(lines.length > 0 ? [`${lines.join(\"\\n\")}\\n`] : []), ...sections].join(\"\\n\");\n}\n\nfunction dataMd(data: unknown): string {\n if (isRecordList(data)) return table(data);\n if (Array.isArray(data))\n return data.length === 0 ? \"(no rows)\\n\" : `${data.map((item) => `- ${cell(item)}`).join(\"\\n\")}\\n`;\n if (isRecord(data)) return Object.keys(data).length === 0 ? \"(empty)\\n\" : recordMd(data);\n return `${inline(data)}\\n`;\n}\n\n/**\n * A success envelope as Markdown: `data` rendered, then every other key\n * (`meta`, warnings, a notice) and the hints, which say whether the rows can be\n * trusted. A result printed beside `ok` rather than under `data` is the record.\n */\nexport function renderEnvelopeMd(envelope: Record<string, unknown>): string {\n const { ok: _ok, data, hints, ...rest } = envelope;\n const hasData = \"data\" in envelope;\n const parts = [hasData ? dataMd(data) : recordMd(rest)];\n const around = hasData ? Object.entries(rest) : [];\n if (around.length > 0) {\n parts.push(`${around.map(([key, value]) => `- **${key}:** ${inline(value)}`).join(\"\\n\")}\\n`);\n }\n if (Array.isArray(hints) && hints.length > 0) {\n parts.push(`${hints.map((hint) => `> ${String(hint).replace(/\\r?\\n/g, \"\\n> \")}`).join(\"\\n\")}\\n`);\n }\n return parts.join(\"\\n\");\n}\n\n/**\n * The text a command printed, rendered as Markdown when it is a success\n * envelope; an error or a dry run comes back as printed, and anything that is\n * not an envelope is null.\n */\nexport function renderPrintedMd(text: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n return renderEnvelopeMd(envelope);\n}\n\n/** The rendering on the CLI's own stdout. */\nexport function installMdRendering(): void {\n rewriteWrites(process.stdout, renderPrintedMd);\n}\n","/**\n * `--out <file>` on every command that prints the JSON envelope.\n *\n * The conventions doc teaches `--out <file>` as the way to take a big read whole\n * (\"one spelling on every family\"), but only the commands that wrote their own\n * export declared it. `analytics releases`, `ads meta insights`, `ads google\n * changes`, `history list` and the research reads refused it, and the agent\n * redirected stdout and grepped pretty JSON instead (BAKER-2415, -936, -497).\n *\n * So a command that does not declare `--out` gets it here: its envelope goes to\n * the file whole, and stdout carries a summary — the file, its size, the row\n * count, and the `meta`, warnings and `hints` that say whether the read can be\n * trusted. A command whose own `--output` prints csv, jsonl or files writes that\n * text to the file instead. A command that declares `--out` keeps its own\n * export, and one that prints no envelope is left to the guard, as with\n * `--fields`.\n */\n\nimport { appendFileSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { commandThatRuns } from \"./full-flag.ts\";\nimport { declaredArg, outputRequests, ownOutput, printsDataEnvelope, withOutput } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, reprint, rewriteWrites, type WriteTarget } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--out\";\n\n/** What stays in the summary of an envelope whose result sits beside `ok` rather than under `data`. */\nconst TRUST_KEYS = [\"meta\", \"warnings\", \"notice\", \"hints\"];\n\n/**\n * Where `--out <file>` sits in `argv` before `--`, and the file it names; null\n * when it is absent, or bare and naming no file — the guard says so.\n */\nfunction outRequest(argv: string[]): { taken: Set<number>; file: string } | null {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n const taken = new Set<number>();\n let file: string | null = null;\n for (let index = 0; index < limit; index++) {\n const token = argv[index] ?? \"\";\n if (token.startsWith(`${FLAG}=`) && token.length > FLAG.length + 1) {\n taken.add(index);\n file = token.slice(FLAG.length + 1);\n } else if (token === FLAG) {\n const value = argv[index + 1];\n if (value === undefined || index + 1 >= limit || value.startsWith(\"-\")) {\n return null;\n }\n taken.add(index).add(index + 1);\n file = value;\n index++;\n }\n }\n return file === null ? null : { taken, file };\n}\n\n/**\n * What `--out` asks of the command it addresses: `argv` to run it with, the\n * file (null when `argv` comes back untouched, for the command or the guard),\n * whether the file takes the envelope or the text the command prints in a\n * format of its own (csv, jsonl, files), and whether the summary is to be\n * rendered as Markdown because the call asked for `--output md`.\n */\nexport type OutTarget = {\n argv: string[];\n file: string | null;\n writes: \"envelope\" | \"printed\";\n summaryMd: boolean;\n};\n\n/**\n * `argv` without `--out <file>`, and the file, when the addressed command prints\n * the envelope and does not declare the option. A command whose default is a\n * readable view — its own `--json` switch, or an own `--output` defaulting to\n * `md` — is asked for its envelope, and so is an explicit `--output md`, whose\n * summary is then rendered. Another format the command prints itself is written\n * to the file as printed.\n */\nexport function takeOutFlag(root: IntrospectableCommand, argv: string[]): OutTarget {\n const untouched: OutTarget = { argv, file: null, writes: \"envelope\", summaryMd: false };\n const request = outRequest(argv);\n const command = request === null ? null : commandFor(root, argv);\n if (request === null || !command) {\n return untouched;\n }\n const path = commandPathOf(root, argv);\n const runs = commandThatRuns(command);\n if (declaredArg(runs, \"out\") !== null || !printsDataEnvelope(path)) {\n return untouched;\n }\n const rest = argv.filter((_, index) => !request.taken.has(index));\n const own = ownOutput(runs, path);\n if (own.kind === \"formats\") {\n const formats = outputRequests(rest);\n const asked = formats.at(-1)?.value ?? own.default;\n if (asked === \"json\") {\n return { argv: rest, file: request.file, writes: \"envelope\", summaryMd: false };\n }\n if (asked === \"md\" && own.formats.has(\"json\")) {\n const dropped = new Set(formats.flatMap((format) => format.indices));\n return {\n argv: withOutput(\n rest.filter((_, index) => !dropped.has(index)),\n \"json\",\n ),\n file: request.file,\n writes: \"envelope\",\n summaryMd: formats.length > 0,\n };\n }\n return { argv: rest, file: request.file, writes: \"printed\", summaryMd: false };\n }\n const needsJson = declaredArg(runs, \"json\")?.type === \"boolean\" && !rest.includes(\"--json\");\n return { argv: needsJson ? [...rest, \"--json\"] : rest, file: request.file, writes: \"envelope\", summaryMd: false };\n}\n\n/**\n * The text a command printed, with a success envelope written whole to `file`\n * and replaced by its summary. An error or a dry run comes back as printed and\n * writes nothing; anything that is not an envelope is null.\n */\nexport function writePrintedToFile(text: string, file: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n const path = resolve(file);\n const body = `${JSON.stringify(envelope, null, 2)}\\n`;\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, body);\n const { ok: _ok, data, ...rest } = envelope;\n const around =\n \"data\" in envelope ? rest : Object.fromEntries(TRUST_KEYS.filter((k) => k in rest).map((k) => [k, rest[k]]));\n return reprint(text, {\n ok: true,\n file: path,\n bytes: Buffer.byteLength(body),\n ...(Array.isArray(data) ? { rows: data.length } : {}),\n ...around,\n });\n}\n\n/**\n * The text a command prints in a format of its own (csv, jsonl, files), written\n * to `file` as it comes instead of to `stream`. An error envelope still reaches\n * `stream`. `finish()` is the summary to print once the command is done, or\n * null when it printed nothing to write.\n */\nexport function capturePrintedText(stream: WriteTarget, file: string, format: string): { finish: () => string | null } {\n const path = resolve(file);\n const write = stream.write.bind(stream);\n let bytes: number | null = null;\n stream.write = (chunk: string | Uint8Array, ...rest: never[]): boolean => {\n const text = typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(\"utf8\");\n if (parsePrintedEnvelope(text)?.ok === false) {\n return write(chunk, ...rest);\n }\n if (bytes === null) {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, text);\n bytes = 0;\n } else {\n appendFileSync(path, text);\n }\n bytes += Buffer.byteLength(text);\n const done = (rest as unknown[]).find((arg) => typeof arg === \"function\");\n if (typeof done === \"function\") {\n process.nextTick(() => done());\n }\n return true;\n };\n return {\n finish: () => (bytes === null ? null : `${JSON.stringify({ ok: true, file: path, bytes, format })}\\n`),\n };\n}\n\n/**\n * The file on the CLI's own stdout, and a note on stderr when the command\n * printed nothing to write, so the agent does not go looking for a file.\n */\nexport function installOutFile(file: string, commandPath: string, target: Pick<OutTarget, \"writes\" | \"argv\">): void {\n if (target.writes === \"printed\") {\n const print = process.stdout.write.bind(process.stdout);\n const format = outputRequests(target.argv).at(-1)?.value ?? \"its default format\";\n const captured = capturePrintedText(process.stdout, file, format);\n process.on(\"exit\", () => {\n const summary = captured.finish();\n if (summary === null) {\n process.stderr.write(`--out wrote no file: \\`baker ${commandPath}\\` printed nothing to write.\\n`);\n } else {\n print(summary);\n }\n });\n return;\n }\n const out = rewriteWrites(process.stdout, (text) => writePrintedToFile(text, file));\n process.on(\"exit\", () => {\n if (!out.sawEnvelope()) {\n process.stderr.write(`--out wrote no file: \\`baker ${commandPath}\\` printed no JSON envelope to write.\\n`);\n }\n });\n}\n","import { defineCommand } from \"citty\";\nimport { getCliVersion } from \"./version.ts\";\n\n// Every command is declared lazily and only the one being run is loaded\n// (`command-loading.ts`): loading all of them made each `baker` process hold\n// ~135 MB of heap while it waited on one request.\nexport const rootCommand = defineCommand({\n meta: {\n name: \"baker\",\n version: getCliVersion(),\n description: `AI-agent CLI for finding and managing images, videos, social posts, avatars, testimonials, action items, scheduled agents, marketing tags, Tag Manager containers, account history, credentials, and ad platform data in Baker.\n\nAuth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.\nChat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.\nOutput: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.\nFields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.\nFull: --full returns the complete record where a command has a compact view; elsewhere it is accepted and changes nothing (a hint says so), except on 'canvas run' and 'canvas rerun', which refuse it.\nCompany: --company <id> runs a read against another company of the organization (organization workspace only; ids from 'baker organization companies').\nFormats: --output json and --output md work on every command that prints the envelope (md: a table for a list, key: value lines for a record). --output files only where 'baker schema <command>' lists output. (The research commands additionally accept csv and jsonl.)\nFile: --out <file> writes the whole envelope to a file and prints a summary (file, bytes, rows, meta, hints), on every command that prints the envelope (with --output csv|jsonl|files, the text that format prints); a command with its own --out (ads google query, ga4 query, ...) writes its rows instead.\nIntrospection: Run 'baker schema <command>' to inspect argument schemas.`,\n },\n subCommands: {\n capabilities: () => import(\"./commands/capabilities/index.ts\").then((m) => m.capabilitiesCommand),\n actions: () => import(\"./commands/actions/index.ts\").then((m) => m.actionsCommand),\n \"scheduled-agents\": () => import(\"./commands/scheduled-agents/index.ts\").then((m) => m.scheduledAgentsCommand),\n ads: () => import(\"./commands/ads/index.ts\").then((m) => m.adsCommand),\n brand: () => import(\"./commands/brand/index.ts\").then((m) => m.brandCommand),\n analytics: () => import(\"./commands/analytics/index.ts\").then((m) => m.analyticsCommand),\n experiment: () => import(\"./commands/experiment/index.ts\").then((m) => m.experimentCommand),\n ga4: () => import(\"./commands/ga4/index.ts\").then((m) => m.ga4Command),\n gsc: () => import(\"./commands/gsc/index.ts\").then((m) => m.gscCommand),\n research: () => import(\"./commands/research/index.ts\").then((m) => m.researchCommand),\n decide: () => import(\"./commands/decide/index.ts\").then((m) => m.decideCommand),\n knowledge: () => import(\"./commands/knowledge/index.ts\").then((m) => m.knowledgeCommand),\n creatives: () => import(\"./commands/creatives/index.ts\").then((m) => m.creativesCommand),\n flows: () => import(\"./commands/flows/index.ts\").then((m) => m.flowsCommand),\n funnel: () => import(\"./commands/funnel/index.ts\").then((m) => m.funnelCommand),\n images: () => import(\"./commands/images/index.ts\").then((m) => m.imagesCommand),\n studio: () => import(\"./commands/studio/index.ts\").then((m) => m.studioCommand),\n avatars: () => import(\"./commands/avatars/index.ts\").then((m) => m.avatarsCommand),\n landing: () => import(\"./commands/landing/index.ts\").then((m) => m.landingCommand),\n videos: () => import(\"./commands/videos/index.ts\").then((m) => m.videosCommand),\n testimonials: () => import(\"./commands/testimonials/index.ts\").then((m) => m.testimonialsCommand),\n canvas: () => import(\"./commands/canvas/index.ts\").then((m) => m.canvasCommand),\n tags: () => import(\"./commands/tags/index.ts\").then((m) => m.tagsCommand),\n \"tag-manager\": () => import(\"./commands/tag-manager/index.ts\").then((m) => m.tagManagerCommand),\n chats: () => import(\"./commands/chats/index.ts\").then((m) => m.chatsCommand),\n history: () => import(\"./commands/history/index.ts\").then((m) => m.historyCommand),\n credentials: () => import(\"./commands/credentials/index.ts\").then((m) => m.credentialsCommand),\n hubspot: () => import(\"./commands/hubspot/index.ts\").then((m) => m.hubspotCommand),\n activecampaign: () => import(\"./commands/activecampaign/index.ts\").then((m) => m.activecampaignCommand),\n accounts: () => import(\"./commands/accounts/index.ts\").then((m) => m.accountsCommand),\n shopify: () => import(\"./commands/shopify/index.ts\").then((m) => m.shopifyCommand),\n \"winning-ads\": () => import(\"./commands/winning-ads/index.ts\").then((m) => m.winningAdsCommand),\n \"media-sources\": () => import(\"./commands/media-sources/index.ts\").then((m) => m.mediaSourcesCommand),\n posts: () => import(\"./commands/posts/index.ts\").then((m) => m.postsCommand),\n site: () => import(\"./commands/site/index.ts\").then((m) => m.siteCommand),\n \"lead-routes\": () => import(\"./commands/lead-routes/index.ts\").then((m) => m.leadRoutesCommand),\n mcp: () => import(\"./commands/mcp/index.ts\").then((m) => m.mcpCommand),\n \"setup-links\": () => import(\"./commands/setup-links/index.ts\").then((m) => m.setupLinksCommand),\n organization: () => import(\"./commands/organization/index.ts\").then((m) => m.organizationCommand),\n schema: () => import(\"./commands/schema.ts\").then((m) => m.schemaCommand),\n },\n});\n","import { readFileSync } from \"node:fs\";\n\nfunction packageJsonUrl(): URL {\n return new URL(\"../package.json\", import.meta.url);\n}\n\nfunction parsePackageVersion(raw: string): string {\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n \"version\" in parsed &&\n typeof parsed.version === \"string\" &&\n parsed.version.length > 0\n ) {\n return parsed.version;\n }\n throw new Error(\"Invalid CLI package.json: missing version\");\n}\n\nexport function getCliVersion(): string {\n return parsePackageVersion(readFileSync(packageJsonUrl(), \"utf8\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,eAAe;;;ACS7B,SAAS,wBAAwB,QAAqB,MAAoC;AAC/F,SAAO,GAAG,SAAS,CAAC,QAAQ;AAC1B,QAAI,IAAI,SAAS,SAAS;AACxB,WAAK,CAAC;AACN;AAAA,IACF;AACA,UAAM;AAAA,EACR,CAAC;AACH;;;ACDA,IAAM,OAAO;AAGb,SAAS,gBAAgB,SAAyC;AAChE,QAAM,MAAM,YAAY,SAAS,SAAS;AAC1C,SAAO,QAAQ,QAAQ,IAAI,SAAS;AACtC;AAOO,SAAS,gBACd,MACA,MAC4C;AAC5C,QAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,QAAM,QAAQ,QAAQ,KAAK,KAAK,SAAS;AACzC,WAAS,QAAQ,GAAG,QAAQ,OAAO,SAAS;AAC1C,UAAM,QAAQ,KAAK,KAAK,KAAK;AAC7B,QAAI;AACJ,QAAI,QAAQ;AACZ,QAAI,MAAM,WAAW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IACE,QAAQ,KAAK,CAAC,QAAQ,QAAQ,YAAY,QAAQ,IAAI,KACrD,QAAQ,WAAW,KAAK,mBAAmB,KAAK,QAAQ,CAAC,KAAK,EAAE,GACjE;AACA,QAAM,UAAU,yBAAyB,MAAM,OAAO;AACtD,MAAI,SAAS;AACX,cAAU,OAAO;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,UAAQ,MAAM,EAAE,WAAW,YAAY,QAAQ,MAAM,EAAE,CAAC;AAC1D,OAAO;AACL,MAAI;AACF,UAAM,WAAW,MAAM,EAAE,QAAQ,CAAC;AAAA,EACpC,SAAS,OAAO;AACd,UAAM,UAAU,qBAAqB,OAAO,MAAM,OAAO;AACzD,QAAI,SAAS;AACX,gBAAU,OAAO;AAAA,IACnB,OAAO;AACL,cAAQ,MAAM,OAAO,IAAI;AAAA,IAC3B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":["FLAG","FLAG"]}
@@ -0,0 +1,118 @@
1
+ import {
2
+ META_LIST_SHAPE_ARGS,
3
+ registerMetaListSchema,
4
+ shapeMetaListRows,
5
+ writeMetaListRows
6
+ } from "./chunk-AGEWPMBR.js";
7
+ import {
8
+ csvOrJson,
9
+ handleMetaError,
10
+ resolveAccountIdArg
11
+ } from "./chunk-KDDHMKTU.js";
12
+ import "./chunk-QALAJNBG.js";
13
+ import "./chunk-EAHBTBVR.js";
14
+ import {
15
+ NO_CACHE_ARG
16
+ } from "./chunk-3PG7O3ZW.js";
17
+ import "./chunk-65Y3RCWP.js";
18
+ import {
19
+ apiGet
20
+ } from "./chunk-C35UMKYG.js";
21
+ import "./chunk-ELAYD7O3.js";
22
+ import "./chunk-LBIF6FJY.js";
23
+ import "./chunk-TRXGJZDL.js";
24
+ import "./chunk-YQSBHWOI.js";
25
+
26
+ // src/commands/ads/meta/creatives.ts
27
+ import { defineCommand } from "citty";
28
+ var listArgs = {
29
+ "account-id": { type: "string", description: "Meta ad account ID (required if no --creative-id)" },
30
+ "creative-id": {
31
+ type: "string",
32
+ description: "One creative ID, or several comma-separated, read in one call: --creative-id 2394\u2026,2395\u2026"
33
+ },
34
+ "name-contains": {
35
+ type: "string",
36
+ description: "Only creatives whose name contains this text (any case), matched by Baker while it reads the account; --limit counts the matches. Start here to find a creative by name: --name-contains octubre"
37
+ },
38
+ limit: { type: "string", description: "Max rows (default 500)" },
39
+ "no-cache": NO_CACHE_ARG,
40
+ ...META_LIST_SHAPE_ARGS
41
+ };
42
+ registerMetaListSchema(
43
+ "creatives",
44
+ "List ad creatives, or read some by id, as a table by default: id, name, status, object_type, dynamic (the asset feed's optimization_type), body, title, description, link, cta, url_tags, image_hash, video_id, page_id, instagram_user_id, effective_object_story_id. Copy and assets are read from wherever the creative keeps them (top level, object_story_spec, its carousel cards or asset_feed_spec); a dynamic creative's variants and a carousel's cards come back as lists. Per-placement rules and enhancement toggles are --fields (asset_feed_spec.asset_customization_rules, degrees_of_freedom_spec) or --full. Start here: baker ads meta creatives --creative-id 2394\u2026,2395\u2026 --output json.",
45
+ listArgs
46
+ );
47
+ async function readCreatives(ids, skipCache) {
48
+ const rows = [];
49
+ for (const id of ids) {
50
+ rows.push(
51
+ await apiGet("/api/ads/meta/creatives", {
52
+ "creative-id": id,
53
+ ...skipCache ? { "skip-cache": "true" } : {}
54
+ })
55
+ );
56
+ }
57
+ return rows;
58
+ }
59
+ var listCommand = defineCommand({
60
+ meta: {
61
+ name: "list",
62
+ description: "List ad creatives, or read some by ID. Runs by default when no subcommand is given. Example: baker ads meta creatives --creative-id 2394\u2026,2395\u2026"
63
+ },
64
+ args: listArgs,
65
+ run: async ({ args }) => {
66
+ try {
67
+ const ids = (args["creative-id"] ?? "").split(",").map((id) => id.trim()).filter(Boolean);
68
+ let data;
69
+ if (ids.length > 0) {
70
+ data = await readCreatives(ids, Boolean(args["no-cache"]));
71
+ } else {
72
+ const params = { "account-id": await resolveAccountIdArg(args) };
73
+ if (args["name-contains"]) params["name-contains"] = args["name-contains"];
74
+ if (args.limit) params.limit = args.limit;
75
+ if (args["no-cache"]) params["skip-cache"] = "true";
76
+ data = await apiGet("/api/ads/meta/creatives", params);
77
+ }
78
+ writeMetaListRows("creatives", shapeMetaListRows("creatives", data, args), csvOrJson(args));
79
+ } catch (err) {
80
+ handleMetaError(err);
81
+ }
82
+ }
83
+ });
84
+ var creativesCommand = defineCommand({
85
+ meta: {
86
+ name: "creatives",
87
+ description: `List ad creatives, fetch one by ID, or stage writes (create/update). Write subcommands stage ops on this chat's draft.
88
+
89
+ Important: Meta creatives are effectively immutable once attached to an ad. Editing copy/image/CTA = create
90
+ a new creative + repoint the ad (baker ads meta ads update <adId> --creative <ref>).
91
+
92
+ Reads print a table by default: id, name, status, object_type, dynamic, body, title, description, link, cta,
93
+ url_tags, image_hash, video_id, page_id, instagram_user_id, effective_object_story_id \u2014 read from wherever the
94
+ creative keeps them; a dynamic creative's variants and a carousel's cards come back as lists. --fields (dotted paths) or --full for the rest.
95
+
96
+ Examples:
97
+ baker ads meta creatives --account-id act_123 --name-contains octubre \u2014 find creatives by name
98
+ baker ads meta creatives --creative-id 23842...,23843... --output json # read several at once
99
+ baker ads meta creatives --creative-id 23842... --fields id,asset_feed_spec.asset_customization_rules --output json
100
+ baker ads meta creatives create --page 555 --message "Save now" --link https://x.com --image-hash abc\u2026 --cta SHOP_NOW`
101
+ },
102
+ subCommands: {
103
+ list: listCommand,
104
+ create: () => import("./write-commands-TPPJHGMT.js").then((m) => m.adCreativesCreateCommand),
105
+ update: () => import("./write-commands-TPPJHGMT.js").then((m) => m.adCreativesUpdateCommand),
106
+ delete: () => import("./asset-writes-ZMSJSFTD.js").then((m) => m.creativesDeleteCommand)
107
+ },
108
+ // `args` stays even though the parent has no `run`: citty scans rawArgs for the
109
+ // subcommand name using THIS command's arg defs, so without them `--account-id act_1`
110
+ // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare
111
+ // invocation — citty falls through to `run` after a subcommand, double-executing it.
112
+ args: listArgs,
113
+ default: "list"
114
+ });
115
+ export {
116
+ creativesCommand
117
+ };
118
+ //# sourceMappingURL=creatives-ARJMZYXM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/ads/meta/creatives.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { META_LIST_SHAPE_ARGS, registerMetaListSchema, shapeMetaListRows, writeMetaListRows } from \"./list-rows.ts\";\nimport { csvOrJson, handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\nconst listArgs = {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID (required if no --creative-id)\" },\n \"creative-id\": {\n type: \"string\",\n description: \"One creative ID, or several comma-separated, read in one call: --creative-id 2394…,2395…\",\n },\n \"name-contains\": {\n type: \"string\",\n description:\n \"Only creatives whose name contains this text (any case), matched by Baker while it reads the account; --limit counts the matches. Start here to find a creative by name: --name-contains octubre\",\n },\n limit: { type: \"string\", description: \"Max rows (default 500)\" },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"creatives\",\n \"List ad creatives, or read some by id, as a table by default: id, name, status, object_type, dynamic (the asset feed's optimization_type), body, title, description, link, cta, url_tags, image_hash, video_id, page_id, instagram_user_id, effective_object_story_id. Copy and assets are read from wherever the creative keeps them (top level, object_story_spec, its carousel cards or asset_feed_spec); a dynamic creative's variants and a carousel's cards come back as lists. Per-placement rules and enhancement toggles are --fields (asset_feed_spec.asset_customization_rules, degrees_of_freedom_spec) or --full. Start here: baker ads meta creatives --creative-id 2394…,2395… --output json.\",\n listArgs,\n);\n\n/**\n * Each id is its own scope-checked, cached read, so several ids cost one call of the agent's, not one each.\n * They run one after another: the company's request budget (a burst of 4, then 2 a second) refuses a\n * parallel batch past ~10 ids, and the client's retries then wait each refused read back in turn.\n */\nasync function readCreatives(ids: string[], skipCache: boolean): Promise<Array<Record<string, unknown>>> {\n const rows: Array<Record<string, unknown>> = [];\n for (const id of ids) {\n rows.push(\n await apiGet<Record<string, unknown>>(\"/api/ads/meta/creatives\", {\n \"creative-id\": id,\n ...(skipCache ? { \"skip-cache\": \"true\" } : {}),\n }),\n );\n }\n return rows;\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List ad creatives, or read some by ID. Runs by default when no subcommand is given. Example: baker ads meta creatives --creative-id 2394…,2395…\",\n },\n args: listArgs,\n run: async ({ args }) => {\n try {\n const ids = ((args[\"creative-id\"] as string | undefined) ?? \"\")\n .split(\",\")\n .map((id) => id.trim())\n .filter(Boolean);\n let data: Array<Record<string, unknown>>;\n if (ids.length > 0) {\n data = await readCreatives(ids, Boolean(args[\"no-cache\"]));\n } else {\n const params: Record<string, string> = { \"account-id\": await resolveAccountIdArg(args) };\n if (args[\"name-contains\"]) params[\"name-contains\"] = args[\"name-contains\"] as string;\n if (args.limit) params.limit = args.limit as string;\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n data = await apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/creatives\", params);\n }\n writeMetaListRows(\"creatives\", shapeMetaListRows(\"creatives\", data, args), csvOrJson(args));\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const creativesCommand = defineCommand({\n meta: {\n name: \"creatives\",\n description: `List ad creatives, fetch one by ID, or stage writes (create/update). Write subcommands stage ops on this chat's draft.\n\nImportant: Meta creatives are effectively immutable once attached to an ad. Editing copy/image/CTA = create\na new creative + repoint the ad (baker ads meta ads update <adId> --creative <ref>).\n\nReads print a table by default: id, name, status, object_type, dynamic, body, title, description, link, cta,\nurl_tags, image_hash, video_id, page_id, instagram_user_id, effective_object_story_id — read from wherever the\ncreative keeps them; a dynamic creative's variants and a carousel's cards come back as lists. --fields (dotted paths) or --full for the rest.\n\nExamples:\n baker ads meta creatives --account-id act_123 --name-contains octubre — find creatives by name\n baker ads meta creatives --creative-id 23842...,23843... --output json # read several at once\n baker ads meta creatives --creative-id 23842... --fields id,asset_feed_spec.asset_customization_rules --output json\n baker ads meta creatives create --page 555 --message \"Save now\" --link https://x.com --image-hash abc… --cta SHOP_NOW`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./write-commands.ts\").then((m) => m.adCreativesCreateCommand),\n update: () => import(\"./write-commands.ts\").then((m) => m.adCreativesUpdateCommand),\n delete: () => import(\"./asset-writes.ts\").then((m) => m.creativesDeleteCommand),\n },\n // `args` stays even though the parent has no `run`: citty scans rawArgs for the\n // subcommand name using THIS command's arg defs, so without them `--account-id act_1`\n // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare\n // invocation — citty falls through to `run` after a subcommand, double-executing it.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAM9B,IAAM,WAAW;AAAA,EACf,cAAc,EAAE,MAAM,UAAU,aAAa,oDAAoD;AAAA,EACjG,eAAe;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,OAAO,EAAE,MAAM,UAAU,aAAa,yBAAyB;AAAA,EAC/D,YAAY;AAAA,EACZ,GAAG;AACL;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;AAOA,eAAe,cAAc,KAAe,WAA6D;AACvG,QAAM,OAAuC,CAAC;AAC9C,aAAW,MAAM,KAAK;AACpB,SAAK;AAAA,MACH,MAAM,OAAgC,2BAA2B;AAAA,QAC/D,eAAe;AAAA,QACf,GAAI,YAAY,EAAE,cAAc,OAAO,IAAI,CAAC;AAAA,MAC9C,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAM,cAAc,cAAc;AAAA,EAChC,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,EACN,KAAK,OAAO,E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:
48
48
 
49
49
  Drill in:
50
50
  baker ads meta account --account-id act_123 \u2014 currency, balance, business, whether it can deliver
51
- baker ads meta creatives --creative-id 9988 \u2014 single creative detail
52
- baker ads meta audiences --account-id act_123
51
+ baker ads meta creatives --creative-id 9988,9989 \u2014 creatives' copy, link and assets, several at once
52
+ baker ads meta audiences --name-contains buyers \u2014 one audience and its lookalikes
53
53
  baker ads meta custom-conversions --account-id act_123 \u2014 the marketer's own conversions ("my conversions")
54
54
  baker ads meta pixels --account-id act_123 \u2014 pixel list
55
55
  baker ads meta pixels --pixel-id 9988 --stats --days 7 \u2014 firing health
@@ -84,14 +84,14 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
84
84
  "lead-forms": () => import("./leads-GZ7RFM7D.js").then((m) => m.leadFormsCommand),
85
85
  "instant-experiences": () => import("./instant-experiences-3E6RRUHF.js").then((m) => m.instantExperiencesCommand),
86
86
  leads: () => import("./leads-GZ7RFM7D.js").then((m) => m.leadsCommand),
87
- campaigns: () => import("./campaigns-N75G2BDU.js").then((m) => m.campaignsCommand),
88
- adsets: () => import("./adsets-OVFVN5NX.js").then((m) => m.adsetsCommand),
89
- ads: () => import("./ads-4O4TPDAU.js").then((m) => m.adsListCommand),
90
- creatives: () => import("./creatives-HRA4X22I.js").then((m) => m.creativesCommand),
91
- audiences: () => import("./audiences-O464BZ6J.js").then((m) => m.audiencesCommand),
87
+ campaigns: () => import("./campaigns-JCKEU2NC.js").then((m) => m.campaignsCommand),
88
+ adsets: () => import("./adsets-TC2VPFXW.js").then((m) => m.adsetsCommand),
89
+ ads: () => import("./ads-HCK2GF2V.js").then((m) => m.adsListCommand),
90
+ creatives: () => import("./creatives-ARJMZYXM.js").then((m) => m.creativesCommand),
91
+ audiences: () => import("./audiences-UJCOT423.js").then((m) => m.audiencesCommand),
92
92
  "custom-conversions": () => import("./custom-conversions-OVUDN3HH.js").then((m) => m.customConversionsCommand),
93
93
  pixels: () => import("./pixels-6PKYGSQ4.js").then((m) => m.pixelsCommand),
94
- activities: () => import("./activities-FXYVPCRJ.js").then((m) => m.activitiesCommand),
94
+ activities: () => import("./activities-OC3CJX4I.js").then((m) => m.activitiesCommand),
95
95
  insights: () => import("./insights-UOO6OK3U.js").then((m) => m.insightsCommand),
96
96
  preview: () => import("./preview-CD2QADBJ.js").then((m) => m.previewCommand),
97
97
  targeting: () => import("./targeting-II4CQUPW.js").then((m) => m.targetingCommand),
@@ -119,4 +119,4 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
119
119
  export {
120
120
  metaCommand
121
121
  };
122
- //# sourceMappingURL=meta-CTKXBVXT.js.map
122
+ //# sourceMappingURL=meta-MBW5LM5V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/ads/meta/index.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\n\n/**\n * Meta Ads command surface — curated for AI agents, not 1:1 with the Marketing API.\n *\n * Every backend read route has a command except `/currency`: `account` already\n * returns the currency and time zone, so a second command for two of its\n * fields would only be a second place to look.\n *\n * Default behaviors that matter:\n * - Listings (campaigns/adsets/ads) filter to ACTIVE — pass --all-statuses to widen.\n * - Insights filter out non-delivered rows (impressions=0) and sort by spend desc.\n * - Insights pick a smart field bundle via --intent (baseline|revenue|funnel|ranking|video|identity).\n * - Heavy insights queries auto-fall to async (poll loop hidden).\n * - Attribution defaults to 7d_click,1d_view — the only windows still working as of Jan 2026.\n */\nexport const metaCommand = defineCommand({\n meta: {\n name: \"meta\",\n description: `Meta Marketing API — AI-first command surface (Facebook + Instagram ads).\n\nDiscovery:\n baker ads meta accounts — accounts in this company's connected scope\n baker ads meta businesses — Business Manager IDs\n baker ads meta pages — Facebook Pages the selected ad accounts can promote (an ad's identity)\n baker ads meta lead-forms --page-id 100635183117758 — instant (lead) forms on a Page, with lead counts\n baker ads meta lead-forms create --account-id act_123 --page-id 555 --file form.json — stage a new form\n baker ads meta leads --form-id 987654321 — the leads one form collected (contact details masked)\n\nSnapshot a running account (default = ACTIVE only):\n baker ads meta campaigns --account-id act_123\n baker ads meta adsets --campaign-id 6123\n baker ads meta ads --adset-id 6123\n baker ads meta campaigns --account-id act_123 --all-statuses — include paused, archived\n\nBuild targeting (Meta takes ids, never names — look them up first):\n baker ads meta targeting search --account-id act_123 --q \"solar energy\" — interest/behavior/employer… ids\n baker ads meta targeting geo --account-id act_123 --q Madrid — location keys\n baker ads meta targeting validate --account-id act_123 --targeting-file t.json\n baker ads meta targeting estimate --account-id act_123 --targeting-file t.json --optimization-goal LEAD_GENERATION\n baker ads meta targeting describe --account-id act_123 --adset-id 6123 — the audience in Meta's words\n\nIdentities and libraries:\n baker ads meta instagram-accounts --account-id act_123 — the --instagram-user an ad can run as\n baker ads meta apps --account-id act_123 — apps it can promote\n baker ads meta dsa-recommendations --account-id act_123 — EU DSA beneficiary/payor names\n baker ads meta images --account-id act_123 — image hashes already on Meta\n baker ads meta labels --account-id act_123\n baker ads meta catalogs --business-id 601050769212882 — product catalogs; --catalog-id for product sets; products/sets/feeds/diagnostics\n baker ads meta page-photos upload --page-id … --image-id … — a photo on a Page, not posted (Instant Experiences)\n baker ads meta instant-experiences --page-id 904238019441800 — full-screen pages an ad can open (collection ads)\n baker ads meta studies --account-id act_123 — A/B tests; --study-id for results\n baker ads meta high-demand-periods --campaign-id 6123 — budget boosts\n baker ads meta page-posts --page-id 904238019441800 — posts an ad can boost; instagram-media for Instagram\n baker ads meta block-lists --account-id act_123 — sites and apps ads stay off (brand safety)\n baker ads meta reach-frequency --account-id act_123 — reach & frequency quotes; predict | reserve | cancel\n baker ads meta account-settings --account-id act_123 --spending-limit 5000 — account name / spending limit (staged)\n baker ads meta comments --ad-id 120211234567890 — comments on an ad's post\n baker ads meta account-details --account-id act_123 --show users — people, Meta's suggestions, Advantage+ controls, playables, page sets\n\nDrill in:\n baker ads meta account --account-id act_123 — currency, balance, business, whether it can deliver\n baker ads meta creatives --creative-id 9988,9989 — creatives' copy, link and assets, several at once\n baker ads meta audiences --name-contains buyers — one audience and its lookalikes\n baker ads meta custom-conversions --account-id act_123 — the marketer's own conversions (\"my conversions\")\n baker ads meta pixels --account-id act_123 — pixel list\n baker ads meta pixels --pixel-id 9988 --stats --days 7 — firing health\n\nPerformance (the workhorse):\n baker ads meta insights --object act_123 — defaults: level=account, intent=baseline, last_7d\n baker ads meta insights --object act_123 --intent revenue --date-preset last_28d\n baker ads meta insights --object act_123 --level ad --intent ranking — flag creatives to refresh\n baker ads meta insights --object act_123 --level adset --breakdowns publisher_platform,age — placement × age\n baker ads meta insights --object act_123 --level ad --since 2026-01-01 --until 2026-03-31 — auto-async\n baker ads meta insights --list-intents\n\nAutomated rules (run on Meta, unattended, once published):\n baker ads meta rules --account-id act_123 — every rule and what it does\n baker ads meta rules history --rule-id 1132635173044914 — what a rule did and when\n baker ads meta rules create --name \"Stop expensive ads\" --apply-to ad --when \"cost_per_result>20\" --action pause\n\nA/B tests (Meta splits the audience between versions and calls the winner):\n baker ads meta adsets duplicate 6123 --name \"… – lookalike\" — then change ONE thing on the copy\n baker ads meta studies create --name \"Broad vs lookalike\" --adsets 6123,meta_temp_ab12 --start 2026-10-20T08:00Z --days 14\n\nAudit & review:\n baker ads meta activities --account-id act_123 --days 14\n baker ads meta preview --creative-id 9988 --ad-format MOBILE_FEED_STANDARD --out-file /tmp/p.html\nFull guide: __tooling__/docs/tools/baker/ads-meta.md`,\n },\n subCommands: {\n accounts: () => import(\"./accounts.ts\").then((m) => m.accountsCommand),\n account: () => import(\"./account.ts\").then((m) => m.accountCommand),\n businesses: () => import(\"./businesses.ts\").then((m) => m.businessesCommand),\n pages: () => import(\"./pages.ts\").then((m) => m.pagesCommand),\n \"lead-forms\": () => import(\"./leads.ts\").then((m) => m.leadFormsCommand),\n \"instant-experiences\": () => import(\"./instant-experiences.ts\").then((m) => m.instantExperiencesCommand),\n leads: () => import(\"./leads.ts\").then((m) => m.leadsCommand),\n campaigns: () => import(\"./campaigns.ts\").then((m) => m.campaignsCommand),\n adsets: () => import(\"./adsets.ts\").then((m) => m.adsetsCommand),\n ads: () => import(\"./ads.ts\").then((m) => m.adsListCommand),\n creatives: () => import(\"./creatives.ts\").then((m) => m.creativesCommand),\n audiences: () => import(\"./audiences.ts\").then((m) => m.audiencesCommand),\n \"custom-conversions\": () => import(\"./custom-conversions.ts\").then((m) => m.customConversionsCommand),\n pixels: () => import(\"./pixels.ts\").then((m) => m.pixelsCommand),\n activities: () => import(\"./activities.ts\").then((m) => m.activitiesCommand),\n insights: () => import(\"./insights.ts\").then((m) => m.insightsCommand),\n preview: () => import(\"./preview.ts\").then((m) => m.previewCommand),\n targeting: () => import(\"./targeting.ts\").then((m) => m.targetingCommand),\n \"instagram-accounts\": () => import(\"./account-assets.ts\").then((m) => m.instagramAccountsCommand),\n apps: () => import(\"./account-assets.ts\").then((m) => m.appsCommand),\n \"dsa-recommendations\": () => import(\"./account-assets.ts\").then((m) => m.dsaRecommendationsCommand),\n images: () => import(\"./account-assets.ts\").then((m) => m.imagesCommand),\n labels: () => import(\"./account-assets.ts\").then((m) => m.labelsCommand),\n studies: () => import(\"./studies.ts\").then((m) => m.studiesCommand),\n catalogs: () => import(\"./catalogs.ts\").then((m) => m.catalogsCommand),\n \"page-photos\": () => import(\"./page-photos.ts\").then((m) => m.pagePhotosCommand),\n \"page-posts\": () => import(\"./account-level.ts\").then((m) => m.pagePostsCommand),\n \"instagram-media\": () => import(\"./account-level.ts\").then((m) => m.instagramMediaCommand),\n comments: () => import(\"./account-level.ts\").then((m) => m.commentsCommand),\n \"account-settings\": () => import(\"./account-level.ts\").then((m) => m.accountSettingsCommand),\n \"account-details\": () => import(\"./account-level.ts\").then((m) => m.accountDetailsCommand),\n \"block-lists\": () => import(\"./account-level.ts\").then((m) => m.blockListsCommand),\n \"reach-frequency\": () => import(\"./account-level.ts\").then((m) => m.reachFrequencyCommand),\n \"high-demand-periods\": () => import(\"./account-assets.ts\").then((m) => m.highDemandPeriodsCommand),\n rules: () => import(\"./rules.ts\").then((m) => m.rulesCommand),\n media: () => import(\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AAA,IAClE,UAAU,MAAM,OAAO,wBAAe,EAAE,KAAK,CAAC,MAAM,EAAE,eAAe;AAAA,IACrE,eAAe,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB;AAAA,IAC/E,cAAc,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB;AAAA,IAC/E,mBAAmB,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB;AAAA,IACzF,UAAU,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,eAAe;AAAA,IAC1E,oBAAoB,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,sBAAsB;AAAA,IAC3F,mBAAmB,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB;AAAA,IACzF,eAAe,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB;AAAA,IACjF,mBAAmB,MAAM,OAAO,6BAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB;AAAA,IACzF,uBAAuB,MAAM,OAAO,8BAAqB,EAAE,KAAK,CAAC,MAAM,EAAE,wBAAwB;AAAA,IACjG,OAAO,MAAM,OAAO,qBAAY,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY;AAAA,IAC5D,OAAO,MAAM,OAAO,qBAAY,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB;AAAA,IAChE,OAAO,MAAM,OAAO,qBAAY,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB;AAAA,EAClE;AACF,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koda-sl/baker-cli",
3
- "version": "0.537.0",
3
+ "version": "0.538.0",
4
4
  "description": "AI-agent-first CLI for interacting with Baker, including the Baker creative canvas.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/ads/meta/audiences.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { writeAdsJson, writeAdsOutput } from \"../output.ts\";\nimport { csvOrJson, handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\nconst listArgs = {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n limit: { type: \"string\", description: \"Max rows\" },\n \"no-cache\": NO_CACHE_ARG,\n output: { type: \"string\", description: \"Output format: json|csv|jsonl|md\", default: \"json\" },\n} as const;\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List custom audiences. Runs by default when no subcommand is given. Example: baker ads meta audiences --account-id act_123\",\n },\n args: listArgs,\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const params: Record<string, string> = { \"account-id\": accountId };\n if (args.limit) params.limit = args.limit as string;\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const data = await apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/audiences\", params);\n const fmt = csvOrJson(args);\n if (fmt !== \"json\") {\n writeAdsOutput(data, fmt);\n return;\n }\n writeAdsJson({ ok: true, data });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const audiencesCommand = defineCommand({\n meta: {\n name: \"audiences\",\n description: `List custom audiences, or stage writes (create/update/delete, members add|remove|replace). Write subcommands stage ops on this chat's draft.\nIncludes lookalikes, website-pixel audiences, customer-file audiences. Meta hides exact size when count < 1000.\n\nExamples:\n baker ads meta audiences --account-id act_123\n baker ads meta audiences create --name \"Site 30d\" --subtype WEBSITE --file rule.json\n baker ads meta audiences create --name \"Past buyers\" --subtype CUSTOM --file buyers.json # {\"members\":[{\"email\":\"…\"}]}\n baker ads meta audiences create --name \"Customers\" --subtype CUSTOM --customer-file-source USER_PROVIDED_ONLY\n baker ads meta audiences members add meta_temp_ab12 --file customers.csv --country ES\n baker ads meta audiences saved --account-id act_123 — saved audiences (read-only)`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./write-commands.ts\").then((m) => m.audiencesCreateCommand),\n update: () => import(\"./write-commands.ts\").then((m) => m.audiencesUpdateCommand),\n delete: () => import(\"./audience-writes.ts\").then((m) => m.audiencesDeleteCommand),\n members: () => import(\"./audience-writes.ts\").then((m) => m.audiencesMembersCommand),\n saved: () => import(\"./audience-writes.ts\").then((m) => m.savedAudiencesCommand),\n },\n // `args` stays even though the parent has no `run`: citty scans rawArgs for the\n // subcommand name using THIS command's arg defs, so without them `--account-id act_1`\n // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare\n // invocation — citty falls through to `run` after a subcommand, double-executing it.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAM9B,IAAM,WAAW;AAAA,EACf,cAAc,EAAE,MAAM,UAAU,aAAa,qBAAqB;AAAA,EAClE,OAAO,EAAE,MAAM,UAAU,aAAa,WAAW;AAAA,EACjD,YAAY;AAAA,EACZ,QAAQ,EAAE,MAAM,UAAU,aAAa,oCAAoC,SAAS,OAAO;AAC7F;AAEA,IAAM,cAAc,cAAc;AAAA,EAChC,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,EACN,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,UAAM,YAAY,MAAM,oBAAoB,IAAI;AAChD,QAAI;AACF,YAAM,SAAiC,EAAE,cAAc,UAAU;AACjE,UAAI,KAAK,MAAO,QAAO,QAAQ,KAAK;AACpC,UAAI,KAAK,UAAU,EAAG,QAAO,YAAY,IAAI;AAC7C,YAAM,OAAO,MAAM,OAAuC,2BAA2B,MAAM;AAC3F,YAAM,MAAM,UAAU,IAAI;AAC1B,UAAI,QAAQ,QAAQ;AAClB,uBAAe,MAAM,GAAG;AACxB;AAAA,MACF;AACA,mBAAa,EAAE,IAAI,MAAM,KAAK,CAAC;AAAA,IACjC,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;AAEM,IAAM,mBAAmB,cAAc;AAAA,EAC5C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUf;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,QAAQ,MAAM,OAAO,8BAAqB,EAAE,KAAK,CAAC,MAAM,EAAE,sBAAsB;AAAA,IAChF,QAAQ,MAAM,OAAO,8BAAqB,EAAE,KAAK,CAAC,MAAM,EAAE,sBAAsB;AAAA,IAChF,QAAQ,MAAM,OAAO,+BAAsB,EAAE,KAAK,CAAC,MAAM,EAAE,sBAAsB;AAAA,IACjF,SAAS,MAAM,OAAO,+BAAsB,EAAE,KAAK,CAAC,MAAM,EAAE,uBAAuB;AAAA,IACnF,OAAO,MAAM,OAAO,+BAAsB,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM;AAAA,EACN,SAAS;AACX,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/ads/meta/list-rows.ts"],"sourcesContent":["import { registerSchema } from \"../../../schemas.ts\";\nimport { asRecord, type CompactProjection, type ShapedRows, shapeListRows } from \"../list-rows.ts\";\nimport { writeAdsOutput } from \"../output.ts\";\n\n/**\n * The compact row of each Meta listing. The backend asks Graph for every field a\n * write or an audit might need (targeting, tracking specs, three status fields),\n * and 100 campaigns or two days of activity passed through whole ran to 55–78 KB.\n * A compact row carries what an agent decides with; `--fields` reaches any other\n * path and `--full` returns the record Graph sent.\n *\n * `effective_status` is the one status kept: it is what Ads Manager shows, and\n * `status`/`configured_status` only restate the toggle it already folds in.\n *\n * Listings print a table by default: keyed JSON repeats every column name on\n * every row, and 100 campaigns stayed near 30 KB even compact. `--output json`\n * returns the same rows in the envelope.\n */\n\ntype MetaRow = Record<string, unknown>;\n\nexport type MetaListKind = \"campaigns\" | \"adsets\" | \"ads\" | \"activities\";\n\nfunction pick(row: MetaRow, keys: readonly string[]): MetaRow {\n const picked: MetaRow = {};\n for (const key of keys) {\n if (row[key] !== undefined) picked[key] = row[key];\n }\n return picked;\n}\n\n/**\n * An account's campaign list is the widest listing an agent reads (100+ rows), so\n * its row is the narrowest: what a campaign is called, whether it runs and what\n * it spends. Objective, bid strategy and Special Ad Category are one `--fields`\n * away; the creation day is enough to order by, and `--fields created_time` has\n * the timestamp.\n */\nconst CAMPAIGN_COLUMNS = [\"id\", \"name\", \"effective_status\", \"daily_budget\", \"lifetime_budget\", \"created_date\"] as const;\n\n/** Why delivery stops and what Meta suggests: columns only when a row has one. */\nconst DIAGNOSTIC_COLUMNS = [\"issues\", \"suggestions\"] as const;\n\nfunction compactCampaign(row: MetaRow): MetaRow {\n const created = row.created_time;\n return {\n ...pick(row, [\"id\", \"name\", \"effective_status\", \"daily_budget\", \"lifetime_budget\"]),\n ...(typeof created === \"string\" ? { created_date: created.slice(0, 10) } : {}),\n ...diagnostics(row),\n };\n}\n\nconst ADSET_KEYS = [\n \"id\",\n \"name\",\n \"campaign_id\",\n \"effective_status\",\n \"optimization_goal\",\n \"billing_event\",\n \"bid_strategy\",\n \"daily_budget\",\n \"lifetime_budget\",\n \"destination_type\",\n // A Dynamic Creative ad set refuses every new ad, which changes the plan before anything is staged.\n \"is_dynamic_creative\",\n] as const;\n\nconst ADSET_COLUMNS = [...ADSET_KEYS, \"learning_stage\", \"end_time\", \"created_time\"] as const;\n\nfunction compactAdSet(row: MetaRow): MetaRow {\n const learning = asRecord(row.learning_stage_info)?.status;\n return {\n ...pick(row, ADSET_KEYS),\n ...(typeof learning === \"string\" ? { learning_stage: learning } : {}),\n ...pick(row, [\"end_time\", \"created_time\"]),\n ...diagnostics(row),\n };\n}\n\nconst AD_COLUMNS = [\n \"id\",\n \"name\",\n \"adset_id\",\n \"campaign_id\",\n \"effective_status\",\n \"creative_id\",\n \"issues\",\n \"created_time\",\n] as const;\n\n/** Why an ad is WITH_ISSUES — the one reason to open `issues_info`, in its own words. */\nfunction adIssues(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.flatMap((entry) => {\n const issue = asRecord(entry);\n const text = issue?.error_summary ?? issue?.error_message;\n return typeof text === \"string\" && text ? [text] : [];\n });\n}\n\n/** Meta's suggestions for a campaign or ad set (`recommendations`), by their titles. */\nfunction suggestions(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.flatMap((entry) => {\n const recommendation = asRecord(entry);\n const text = recommendation?.title ?? recommendation?.message;\n return typeof text === \"string\" && text ? [text] : [];\n });\n}\n\n/** Why a campaign or ad set cannot deliver, and what Meta suggests — only when Meta says something. */\nfunction diagnostics(row: MetaRow): MetaRow {\n const issues = adIssues(row.issues_info);\n const suggested = suggestions(row.recommendations);\n return {\n ...(issues.length > 0 ? { issues } : {}),\n ...(suggested.length > 0 ? { suggestions: suggested } : {}),\n };\n}\n\nfunction compactAd(row: MetaRow): MetaRow {\n const creativeId = asRecord(row.creative)?.id;\n const issues = adIssues(row.issues_info);\n return {\n ...pick(row, [\"id\", \"name\", \"adset_id\", \"campaign_id\", \"effective_status\"]),\n ...(creativeId !== undefined ? { creative_id: creativeId } : {}),\n ...(issues.length > 0 ? { issues } : {}),\n ...pick(row, [\"created_time\"]),\n };\n}\n\nconst ACTIVITY_COLUMNS = [\n \"event_time\",\n \"event_type\",\n \"actor_name\",\n \"object_type\",\n \"object_name\",\n \"object_id\",\n \"change\",\n] as const;\n\nfunction isScalar(value: unknown): value is string | number | null {\n return value === null || typeof value === \"string\" || typeof value === \"number\";\n}\n\n/**\n * `extra_data` is a JSON string whose shape varies by event type and carries most\n * of an activity's bytes (image URLs, whole targeting specs). A status, name,\n * budget or goal change stores its before and after as two plain values — those\n * read as one line; any richer change stays behind `--fields extra_data`.\n */\nexport function activityChange(extraData: unknown): string | undefined {\n if (typeof extraData !== \"string\") return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(extraData);\n } catch {\n return undefined;\n }\n const data = asRecord(parsed);\n // An absent old_value is one this read did not observe, not an unset one — only `null` means \"none\".\n if (!data || !(\"new_value\" in data) || !(\"old_value\" in data)) return undefined;\n const { old_value: before, new_value: after } = data;\n if (!isScalar(before) || !isScalar(after)) return undefined;\n const show = (value: string | number | null) => (value === null ? \"(none)\" : String(value));\n return `${show(before)} → ${show(after)}`;\n}\n\nfunction compactActivity(row: MetaRow): MetaRow {\n const change = activityChange(row.extra_data);\n return {\n ...pick(row, [\"event_time\", \"event_type\", \"actor_name\", \"object_type\", \"object_name\", \"object_id\"]),\n ...(change !== undefined ? { change } : {}),\n };\n}\n\n/**\n * The unit a listing's budgets are in, said once rather than as a column (a\n * 100-campaign table stays small). Meta lists money in the account currency's\n * smallest unit and Baker passes it through unchanged (published reports read\n * it that way), while every money flag takes whole currency. An agent that once\n * took a listed \"8000\" for the flag's unit staged 10,000 EUR a day instead of 100.\n */\nexport function budgetUnitHints(rows: ReadonlyArray<Record<string, unknown>>): string[] {\n const listed = rows\n .map((row) => Number(row.daily_budget ?? row.lifetime_budget))\n .find((amount) => Number.isFinite(amount) && amount > 0);\n if (listed === undefined) return [];\n const whole = listed / 100;\n return [\n `Budgets here are in the account currency's smallest unit, as Meta sends them: daily_budget ${listed} is ${whole} in EUR or USD (currencies without cents, such as JPY, are not divided). Money flags take whole currency: --daily-budget ${whole}, never ${listed}.`,\n ];\n}\n\nconst PROJECTIONS: Record<MetaListKind, CompactProjection<MetaRow>> = {\n campaigns: { row: compactCampaign, columns: CAMPAIGN_COLUMNS, whenPresent: DIAGNOSTIC_COLUMNS },\n adsets: { row: compactAdSet, columns: ADSET_COLUMNS, whenPresent: DIAGNOSTIC_COLUMNS },\n ads: { row: compactAd, columns: AD_COLUMNS },\n activities: { row: compactActivity, columns: ACTIVITY_COLUMNS },\n};\n\nexport function shapeMetaListRows(kind: MetaListKind, rows: MetaRow[], args: Record<string, unknown>): ShapedRows {\n return shapeListRows(rows, args, PROJECTIONS[kind]);\n}\n\nconst NOUNS: Record<MetaListKind, string> = {\n campaigns: \"campaigns\",\n adsets: \"ad sets\",\n ads: \"ads\",\n activities: \"activities\",\n};\n\n/**\n * A table of no rows prints nothing at all, which reads as a failed call — so an empty\n * listing says so, and says why when a status filter may be hiding rows.\n */\nexport function writeMetaListRows(kind: MetaListKind, shaped: ShapedRows, format: string, hints: string[] = []): void {\n if (format === \"md\" && shaped.rows.length === 0) {\n process.stdout.write(`${hints.length > 0 ? hints.join(\"\\n\") : `No ${NOUNS[kind]} matched.`}\\n`);\n return;\n }\n writeAdsOutput(shaped.rows, format, shaped.fields, [...hints, ...(shaped.hints ?? [])]);\n}\n\n/** The projection flags every Meta listing shares, worded once for help and `baker schema`. */\nexport const META_LIST_SHAPE_ARGS = {\n fields: {\n type: \"string\",\n description: \"CSV of dotted paths to return instead of the compact row, e.g. id,name,targeting.geo_locations\",\n },\n full: { type: \"boolean\", description: \"Return every field Meta sent (targeting, tracking specs, raw extra_data)\" },\n output: {\n type: \"string\",\n description: \"md|json|csv|jsonl — md (default) prints a table; json returns the rows in the { ok, data } envelope\",\n default: \"md\",\n },\n} as const;\n\ninterface ListArgDef {\n type: string;\n description?: string;\n default?: unknown;\n}\n\n/**\n * `baker schema ads.meta.<list>`, read off the same arg defs the command parses,\n * so the introspection an agent checks before a call cannot promise a flag the\n * command refuses — `--full` on `adsets` was guessed three times in one Session.\n */\nexport function registerMetaListSchema(\n kind: MetaListKind,\n description: string,\n args: Record<string, ListArgDef>,\n): void {\n registerSchema({\n command: `ads.meta.${kind}`,\n description,\n args: Object.fromEntries(\n Object.entries(args).map(([name, def]) => [\n name,\n {\n type: def.type,\n description: def.description ?? \"\",\n required: false,\n ...(def.default !== undefined ? { default: def.default } : {}),\n },\n ]),\n ),\n });\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAS,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AAS,IAAI,QAAQ,IAAI,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,89 +0,0 @@
1
- import {
2
- csvOrJson,
3
- handleMetaError,
4
- resolveAccountIdArg
5
- } from "./chunk-KDDHMKTU.js";
6
- import "./chunk-QALAJNBG.js";
7
- import {
8
- writeAdsJson,
9
- writeAdsOutput
10
- } from "./chunk-EAHBTBVR.js";
11
- import {
12
- NO_CACHE_ARG
13
- } from "./chunk-3PG7O3ZW.js";
14
- import {
15
- apiGet
16
- } from "./chunk-C35UMKYG.js";
17
- import "./chunk-ELAYD7O3.js";
18
- import "./chunk-LBIF6FJY.js";
19
- import "./chunk-TRXGJZDL.js";
20
- import "./chunk-YQSBHWOI.js";
21
-
22
- // src/commands/ads/meta/creatives.ts
23
- import { defineCommand } from "citty";
24
- var listArgs = {
25
- "account-id": { type: "string", description: "Meta ad account ID (required if no --creative-id)" },
26
- "creative-id": { type: "string", description: "Single creative ID" },
27
- limit: { type: "string", description: "Max rows (default 500)" },
28
- "no-cache": NO_CACHE_ARG,
29
- output: { type: "string", description: "Output format: json|csv|jsonl|md", default: "json" }
30
- };
31
- var listCommand = defineCommand({
32
- meta: {
33
- name: "list",
34
- description: "List ad creatives, or fetch one by ID. Runs by default when no subcommand is given. Example: baker ads meta creatives --account-id act_123"
35
- },
36
- args: listArgs,
37
- run: async ({ args }) => {
38
- try {
39
- const params = {};
40
- if (args["creative-id"]) {
41
- params["creative-id"] = args["creative-id"];
42
- } else {
43
- const accountId = await resolveAccountIdArg(args);
44
- params["account-id"] = accountId;
45
- }
46
- if (args.limit) params.limit = args.limit;
47
- if (args["no-cache"]) params["skip-cache"] = "true";
48
- const data = await apiGet("/api/ads/meta/creatives", params);
49
- const fmt = csvOrJson(args);
50
- if (Array.isArray(data) && fmt !== "json") {
51
- writeAdsOutput(data, fmt);
52
- return;
53
- }
54
- writeAdsJson({ ok: true, data });
55
- } catch (err) {
56
- handleMetaError(err);
57
- }
58
- }
59
- });
60
- var creativesCommand = defineCommand({
61
- meta: {
62
- name: "creatives",
63
- description: `List ad creatives, fetch one by ID, or stage writes (create/update). Write subcommands stage ops on this chat's draft.
64
-
65
- Important: Meta creatives are effectively immutable once attached to an ad. Editing copy/image/CTA = create
66
- a new creative + repoint the ad (baker ads meta ads update <adId> --creative <ref>).
67
-
68
- Examples:
69
- baker ads meta creatives --account-id act_123
70
- baker ads meta creatives --creative-id 23842... # fetch one
71
- baker ads meta creatives create --page 555 --message "Save now" --link https://x.com --image-hash abc\u2026 --cta SHOP_NOW`
72
- },
73
- subCommands: {
74
- list: listCommand,
75
- create: () => import("./write-commands-TPPJHGMT.js").then((m) => m.adCreativesCreateCommand),
76
- update: () => import("./write-commands-TPPJHGMT.js").then((m) => m.adCreativesUpdateCommand),
77
- delete: () => import("./asset-writes-ZMSJSFTD.js").then((m) => m.creativesDeleteCommand)
78
- },
79
- // `args` stays even though the parent has no `run`: citty scans rawArgs for the
80
- // subcommand name using THIS command's arg defs, so without them `--account-id act_1`
81
- // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare
82
- // invocation — citty falls through to `run` after a subcommand, double-executing it.
83
- args: listArgs,
84
- default: "list"
85
- });
86
- export {
87
- creativesCommand
88
- };
89
- //# sourceMappingURL=creatives-HRA4X22I.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/ads/meta/creatives.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { writeAdsJson, writeAdsOutput } from \"../output.ts\";\nimport { csvOrJson, handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\nconst listArgs = {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID (required if no --creative-id)\" },\n \"creative-id\": { type: \"string\", description: \"Single creative ID\" },\n limit: { type: \"string\", description: \"Max rows (default 500)\" },\n \"no-cache\": NO_CACHE_ARG,\n output: { type: \"string\", description: \"Output format: json|csv|jsonl|md\", default: \"json\" },\n} as const;\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List ad creatives, or fetch one by ID. Runs by default when no subcommand is given. Example: baker ads meta creatives --account-id act_123\",\n },\n args: listArgs,\n run: async ({ args }) => {\n try {\n const params: Record<string, string> = {};\n if (args[\"creative-id\"]) {\n params[\"creative-id\"] = args[\"creative-id\"] as string;\n } else {\n const accountId = await resolveAccountIdArg(args);\n params[\"account-id\"] = accountId;\n }\n if (args.limit) params.limit = args.limit as string;\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const data = await apiGet<unknown>(\"/api/ads/meta/creatives\", params);\n const fmt = csvOrJson(args);\n if (Array.isArray(data) && fmt !== \"json\") {\n writeAdsOutput(data as Array<Record<string, unknown>>, fmt);\n return;\n }\n writeAdsJson({ ok: true, data });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const creativesCommand = defineCommand({\n meta: {\n name: \"creatives\",\n description: `List ad creatives, fetch one by ID, or stage writes (create/update). Write subcommands stage ops on this chat's draft.\n\nImportant: Meta creatives are effectively immutable once attached to an ad. Editing copy/image/CTA = create\na new creative + repoint the ad (baker ads meta ads update <adId> --creative <ref>).\n\nExamples:\n baker ads meta creatives --account-id act_123\n baker ads meta creatives --creative-id 23842... # fetch one\n baker ads meta creatives create --page 555 --message \"Save now\" --link https://x.com --image-hash abc… --cta SHOP_NOW`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./write-commands.ts\").then((m) => m.adCreativesCreateCommand),\n update: () => import(\"./write-commands.ts\").then((m) => m.adCreativesUpdateCommand),\n delete: () => import(\"./asset-writes.ts\").then((m) => m.creativesDeleteCommand),\n },\n // `args` stays even though the parent has no `run`: citty scans rawArgs for the\n // subcommand name using THIS command's arg defs, so without them `--account-id act_1`\n // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare\n // invocation — citty falls through to `run` after a subcommand, double-executing it.\n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,MAAM;AAAA,IACN,QAAQ,MAAM,OAAO,8BAAqB,EAAE,KAAK,CAAC,MAAM,EAAE,wBAAwB;AAAA,IAClF,QAAQ,MAAM,OAAO,8BAAqB,EAAE,KAAK,CAAC,MAAM,EAAE,wBAAwB;AAAA,IAClF,QAAQ,MAAM,OAAO,4BAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,sBAAsB;AAAA,EAChF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM;AAAA,EACN,SAAS;AACX,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/ads/meta/index.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\n\n/**\n * Meta Ads command surface — curated for AI agents, not 1:1 with the Marketing API.\n *\n * Every backend read route has a command except `/currency`: `account` already\n * returns the currency and time zone, so a second command for two of its\n * fields would only be a second place to look.\n *\n * Default behaviors that matter:\n * - Listings (campaigns/adsets/ads) filter to ACTIVE — pass --all-statuses to widen.\n * - Insights filter out non-delivered rows (impressions=0) and sort by spend desc.\n * - Insights pick a smart field bundle via --intent (baseline|revenue|funnel|ranking|video|identity).\n * - Heavy insights queries auto-fall to async (poll loop hidden).\n * - Attribution defaults to 7d_click,1d_view — the only windows still working as of Jan 2026.\n */\nexport const metaCommand = defineCommand({\n meta: {\n name: \"meta\",\n description: `Meta Marketing API — AI-first command surface (Facebook + Instagram ads).\n\nDiscovery:\n baker ads meta accounts — accounts in this company's connected scope\n baker ads meta businesses — Business Manager IDs\n baker ads meta pages — Facebook Pages the selected ad accounts can promote (an ad's identity)\n baker ads meta lead-forms --page-id 100635183117758 — instant (lead) forms on a Page, with lead counts\n baker ads meta lead-forms create --account-id act_123 --page-id 555 --file form.json — stage a new form\n baker ads meta leads --form-id 987654321 — the leads one form collected (contact details masked)\n\nSnapshot a running account (default = ACTIVE only):\n baker ads meta campaigns --account-id act_123\n baker ads meta adsets --campaign-id 6123\n baker ads meta ads --adset-id 6123\n baker ads meta campaigns --account-id act_123 --all-statuses — include paused, archived\n\nBuild targeting (Meta takes ids, never names — look them up first):\n baker ads meta targeting search --account-id act_123 --q \"solar energy\" — interest/behavior/employer… ids\n baker ads meta targeting geo --account-id act_123 --q Madrid — location keys\n baker ads meta targeting validate --account-id act_123 --targeting-file t.json\n baker ads meta targeting estimate --account-id act_123 --targeting-file t.json --optimization-goal LEAD_GENERATION\n baker ads meta targeting describe --account-id act_123 --adset-id 6123 — the audience in Meta's words\n\nIdentities and libraries:\n baker ads meta instagram-accounts --account-id act_123 — the --instagram-user an ad can run as\n baker ads meta apps --account-id act_123 — apps it can promote\n baker ads meta dsa-recommendations --account-id act_123 — EU DSA beneficiary/payor names\n baker ads meta images --account-id act_123 — image hashes already on Meta\n baker ads meta labels --account-id act_123\n baker ads meta catalogs --business-id 601050769212882 — product catalogs; --catalog-id for product sets; products/sets/feeds/diagnostics\n baker ads meta page-photos upload --page-id … --image-id … — a photo on a Page, not posted (Instant Experiences)\n baker ads meta instant-experiences --page-id 904238019441800 — full-screen pages an ad can open (collection ads)\n baker ads meta studies --account-id act_123 — A/B tests; --study-id for results\n baker ads meta high-demand-periods --campaign-id 6123 — budget boosts\n baker ads meta page-posts --page-id 904238019441800 — posts an ad can boost; instagram-media for Instagram\n baker ads meta block-lists --account-id act_123 — sites and apps ads stay off (brand safety)\n baker ads meta reach-frequency --account-id act_123 — reach & frequency quotes; predict | reserve | cancel\n baker ads meta account-settings --account-id act_123 --spending-limit 5000 — account name / spending limit (staged)\n baker ads meta comments --ad-id 120211234567890 — comments on an ad's post\n baker ads meta account-details --account-id act_123 --show users — people, Meta's suggestions, Advantage+ controls, playables, page sets\n\nDrill in:\n baker ads meta account --account-id act_123 — currency, balance, business, whether it can deliver\n baker ads meta creatives --creative-id 9988 — single creative detail\n baker ads meta audiences --account-id act_123\n baker ads meta custom-conversions --account-id act_123 — the marketer's own conversions (\"my conversions\")\n baker ads meta pixels --account-id act_123 — pixel list\n baker ads meta pixels --pixel-id 9988 --stats --days 7 — firing health\n\nPerformance (the workhorse):\n baker ads meta insights --object act_123 — defaults: level=account, intent=baseline, last_7d\n baker ads meta insights --object act_123 --intent revenue --date-preset last_28d\n baker ads meta insights --object act_123 --level ad --intent ranking — flag creatives to refresh\n baker ads meta insights --object act_123 --level adset --breakdowns publisher_platform,age — placement × age\n baker ads meta insights --object act_123 --level ad --since 2026-01-01 --until 2026-03-31 — auto-async\n baker ads meta insights --list-intents\n\nAutomated rules (run on Meta, unattended, once published):\n baker ads meta rules --account-id act_123 — every rule and what it does\n baker ads meta rules history --rule-id 1132635173044914 — what a rule did and when\n baker ads meta rules create --name \"Stop expensive ads\" --apply-to ad --when \"cost_per_result>20\" --action pause\n\nA/B tests (Meta splits the audience between versions and calls the winner):\n baker ads meta adsets duplicate 6123 --name \"… – lookalike\" — then change ONE thing on the copy\n baker ads meta studies create --name \"Broad vs lookalike\" --adsets 6123,meta_temp_ab12 --start 2026-10-20T08:00Z --days 14\n\nAudit & review:\n baker ads meta activities --account-id act_123 --days 14\n baker ads meta preview --creative-id 9988 --ad-format MOBILE_FEED_STANDARD --out-file /tmp/p.html\nFull guide: __tooling__/docs/tools/baker/ads-meta.md`,\n },\n subCommands: {\n accounts: () => import(\"./accounts.ts\").then((m) => m.accountsCommand),\n account: () => import(\"./account.ts\").then((m) => m.accountCommand),\n businesses: () => import(\"./businesses.ts\").then((m) => m.businessesCommand),\n pages: () => import(\"./pages.ts\").then((m) => m.pagesCommand),\n \"lead-forms\": () => import(\"./leads.ts\").then((m) => m.leadFormsCommand),\n \"instant-experiences\": () => import(\"./instant-experiences.ts\").then((m) => m.instantExperiencesCommand),\n leads: () => import(\"./leads.ts\").then((m) => m.leadsCommand),\n campaigns: () => import(\"./campaigns.ts\").then((m) => m.campaignsCommand),\n adsets: () => import(\"./adsets.ts\").then((m) => m.adsetsCommand),\n ads: () => import(\"./ads.ts\").then((m) => m.adsListCommand),\n creatives: () => import(\"./creatives.ts\").then((m) => m.creativesCommand),\n audiences: () => import(\"./audiences.ts\").then((m) => m.audiencesCommand),\n \"custom-conversions\": () => import(\"./custom-conversions.ts\").then((m) => m.customConversionsCommand),\n pixels: () => import(\"./pixels.ts\").then((m) => m.pixelsCommand),\n activities: () => import(\"./activities.ts\").then((m) => m.activitiesCommand),\n insights: () => import(\"./insights.ts\").then((m) => m.insightsCommand),\n preview: () => import(\"./preview.ts\").then((m) => m.previewCommand),\n targeting: () => import(\"./targeting.ts\").then((m) => m.targetingCommand),\n \"instagram-accounts\": () => import(\"./account-assets.ts\").then((m) => m.instagramAccountsCommand),\n apps: () => import(\"./account-assets.ts\").then((m) => m.appsCommand),\n \"dsa-recommendations\": () => import(\"./account-assets.ts\").then((m) => m.dsaRecommendationsCommand),\n images: () => import(\"./account-assets.ts\").then((m) => m.imagesCommand),\n labels: () => import(\"./account-assets.ts\").then((m) => m.labelsCommand),\n studies: () => import(\"./studies.ts\").then((m) => m.studiesCommand),\n catalogs: () => import(\"./catalogs.ts\").then((m) => m.catalogsCommand),\n \"page-photos\": () => import(\"./page-photos.ts\").then((m) => m.pagePhotosCommand),\n \"page-posts\": () => import(\"./account-level.ts\").then((m) => m.pagePostsCommand),\n \"instagram-media\": () => import(\"./account-level.ts\").then((m) => m.instagramMediaCommand),\n comments: () => import(\"./account-level.ts\").then((m) => m.commentsCommand),\n \"account-settings\": () => import(\"./account-level.ts\").then((m) => m.accountSettingsCommand),\n \"account-details\": () => import(\"./account-level.ts\").then((m) => m.accountDetailsCommand),\n \"block-lists\": () => import(\"./account-level.ts\").then((m) => m.blockListsCommand),\n \"reach-frequency\": () => import(\"./account-level.ts\").then((m) => m.reachFrequencyCommand),\n \"high-demand-periods\": () => import(\"./account-assets.ts\").then((m) => m.highDemandPeriodsCommand),\n rules: () => import(\"./rules.ts\").then((m) => m.rulesCommand),\n media: () => import(\"./media.ts\").then((m) => m.metaMediaCommand),\n draft: () => import(\"./draft.ts\").then((m) => m.metaDraftCommand),\n },\n});\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAgBvB,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