@koda-sl/baker-cli 0.485.0 → 0.487.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 +13 -1
- package/dist/{account-VH2AATWI.js → account-EPVHKQEM.js} +2 -2
- package/dist/{ads-WPI3AMSR.js → ads-HHEB2LZG.js} +2 -2
- package/dist/{campaign-groups-5CMTEJZZ.js → campaign-groups-BJ53O3HV.js} +6 -6
- package/dist/{campaigns-PC7UAVXR.js → campaigns-KMCIZYKR.js} +9 -9
- package/dist/{chunk-ADSNY4KZ.js → chunk-DVA4DOBH.js} +2 -2
- package/dist/{chunk-CM6FCSWN.js → chunk-LCMIAWUZ.js} +3 -1
- package/dist/chunk-LCMIAWUZ.js.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/{conversions-ZLC6YTJ5.js → conversions-X5OWB6HQ.js} +5 -5
- package/dist/{create-B3QMYSIX.js → create-RBZJ27B2.js} +3 -3
- package/dist/{creatives-KD7MOCR3.js → creatives-2TE2DVC2.js} +6 -6
- package/dist/{delete-S4VKH7IS.js → delete-EJG3MRM2.js} +3 -3
- package/dist/{get-MGDY5JYZ.js → get-ZI6RB6K5.js} +3 -3
- package/dist/{linkedin-7F6YVXQL.js → linkedin-PHEYOHVG.js} +24 -12
- package/dist/{linkedin-7F6YVXQL.js.map → linkedin-PHEYOHVG.js.map} +1 -1
- package/dist/{list-SZH6TH74.js → list-VY4UTTRG.js} +3 -3
- package/dist/{mcp-T6SAG4XB.js → mcp-MTFBVKLX.js} +279 -28
- package/dist/mcp-MTFBVKLX.js.map +1 -0
- package/dist/{run-HCJKCEOL.js → run-IKGW7UPB.js} +3 -3
- package/dist/{scheduled-agents-MFLMG34I.js → scheduled-agents-MUCDCONT.js} +10 -10
- package/dist/{schema-EFR7NGJG.js → schema-YT2DBX6T.js} +2 -2
- package/dist/{targets-NI7TR4GV.js → targets-SF4AOFZ3.js} +3 -3
- package/dist/{triggers-WYFM7PAH.js → triggers-PJ3UJAHM.js} +3 -3
- package/dist/{unstage-MCM6EZWK.js → unstage-NPQ5JQ6S.js} +3 -3
- package/dist/{update-GUIP6G3N.js → update-77YN5JEJ.js} +3 -3
- package/dist/{write-commands-E7JOB4HX.js → write-commands-MPXJK2AD.js} +13 -4
- package/dist/write-commands-MPXJK2AD.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-CM6FCSWN.js.map +0 -1
- package/dist/mcp-T6SAG4XB.js.map +0 -1
- package/dist/write-commands-E7JOB4HX.js.map +0 -1
- /package/dist/{account-VH2AATWI.js.map → account-EPVHKQEM.js.map} +0 -0
- /package/dist/{ads-WPI3AMSR.js.map → ads-HHEB2LZG.js.map} +0 -0
- /package/dist/{campaign-groups-5CMTEJZZ.js.map → campaign-groups-BJ53O3HV.js.map} +0 -0
- /package/dist/{campaigns-PC7UAVXR.js.map → campaigns-KMCIZYKR.js.map} +0 -0
- /package/dist/{chunk-ADSNY4KZ.js.map → chunk-DVA4DOBH.js.map} +0 -0
- /package/dist/{conversions-ZLC6YTJ5.js.map → conversions-X5OWB6HQ.js.map} +0 -0
- /package/dist/{create-B3QMYSIX.js.map → create-RBZJ27B2.js.map} +0 -0
- /package/dist/{creatives-KD7MOCR3.js.map → creatives-2TE2DVC2.js.map} +0 -0
- /package/dist/{delete-S4VKH7IS.js.map → delete-EJG3MRM2.js.map} +0 -0
- /package/dist/{get-MGDY5JYZ.js.map → get-ZI6RB6K5.js.map} +0 -0
- /package/dist/{list-SZH6TH74.js.map → list-VY4UTTRG.js.map} +0 -0
- /package/dist/{run-HCJKCEOL.js.map → run-IKGW7UPB.js.map} +0 -0
- /package/dist/{scheduled-agents-MFLMG34I.js.map → scheduled-agents-MUCDCONT.js.map} +0 -0
- /package/dist/{schema-EFR7NGJG.js.map → schema-YT2DBX6T.js.map} +0 -0
- /package/dist/{targets-NI7TR4GV.js.map → targets-SF4AOFZ3.js.map} +0 -0
- /package/dist/{triggers-WYFM7PAH.js.map → triggers-PJ3UJAHM.js.map} +0 -0
- /package/dist/{unstage-MCM6EZWK.js.map → unstage-NPQ5JQ6S.js.map} +0 -0
- /package/dist/{update-GUIP6G3N.js.map → update-77YN5JEJ.js.map} +0 -0
|
@@ -33,18 +33,18 @@ Examples:
|
|
|
33
33
|
Full guide: __tooling__/docs/tools/baker/scheduled-agents.md`
|
|
34
34
|
},
|
|
35
35
|
subCommands: {
|
|
36
|
-
list: () => import("./list-
|
|
37
|
-
get: () => import("./get-
|
|
38
|
-
triggers: () => import("./triggers-
|
|
39
|
-
targets: () => import("./targets-
|
|
40
|
-
create: () => import("./create-
|
|
41
|
-
update: () => import("./update-
|
|
42
|
-
delete: () => import("./delete-
|
|
43
|
-
unstage: () => import("./unstage-
|
|
44
|
-
run: () => import("./run-
|
|
36
|
+
list: () => import("./list-VY4UTTRG.js").then((m) => m.listCommand),
|
|
37
|
+
get: () => import("./get-ZI6RB6K5.js").then((m) => m.getCommand),
|
|
38
|
+
triggers: () => import("./triggers-PJ3UJAHM.js").then((m) => m.triggersCommand),
|
|
39
|
+
targets: () => import("./targets-SF4AOFZ3.js").then((m) => m.targetsCommand),
|
|
40
|
+
create: () => import("./create-RBZJ27B2.js").then((m) => m.createCommand),
|
|
41
|
+
update: () => import("./update-77YN5JEJ.js").then((m) => m.updateCommand),
|
|
42
|
+
delete: () => import("./delete-EJG3MRM2.js").then((m) => m.deleteCommand),
|
|
43
|
+
unstage: () => import("./unstage-NPQ5JQ6S.js").then((m) => m.unstageCommand),
|
|
44
|
+
run: () => import("./run-IKGW7UPB.js").then((m) => m.runCommand)
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
export {
|
|
48
48
|
scheduledAgentsCommand
|
|
49
49
|
};
|
|
50
|
-
//# sourceMappingURL=scheduled-agents-
|
|
50
|
+
//# sourceMappingURL=scheduled-agents-MUCDCONT.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
agentProfile,
|
|
3
3
|
offers
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LCMIAWUZ.js";
|
|
5
5
|
import "./chunk-EE72SSB2.js";
|
|
6
6
|
import {
|
|
7
7
|
findSchema,
|
|
@@ -66,4 +66,4 @@ export {
|
|
|
66
66
|
narrowToFamily,
|
|
67
67
|
schemaCommand
|
|
68
68
|
};
|
|
69
|
-
//# sourceMappingURL=schema-
|
|
69
|
+
//# sourceMappingURL=schema-YT2DBX6T.js.map
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
chatBody,
|
|
3
3
|
failApi,
|
|
4
4
|
failValidation
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-DVA4DOBH.js";
|
|
6
|
+
import "./chunk-LCMIAWUZ.js";
|
|
7
7
|
import {
|
|
8
8
|
TRIGGER_KIND_IDS,
|
|
9
9
|
TRIGGER_TARGET_FIELD_IDS
|
|
@@ -100,4 +100,4 @@ Full guide: __tooling__/docs/tools/baker/scheduled-agents.md`
|
|
|
100
100
|
export {
|
|
101
101
|
targetsCommand
|
|
102
102
|
};
|
|
103
|
-
//# sourceMappingURL=targets-
|
|
103
|
+
//# sourceMappingURL=targets-SF4AOFZ3.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
failApi
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-DVA4DOBH.js";
|
|
4
|
+
import "./chunk-LCMIAWUZ.js";
|
|
5
5
|
import {
|
|
6
6
|
triggerCatalogSchema
|
|
7
7
|
} from "./chunk-FRK7SSEH.js";
|
|
@@ -139,4 +139,4 @@ export {
|
|
|
139
139
|
shapeTriggerCatalog,
|
|
140
140
|
triggersCommand
|
|
141
141
|
};
|
|
142
|
-
//# sourceMappingURL=triggers-
|
|
142
|
+
//# sourceMappingURL=triggers-PJ3UJAHM.js.map
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
failApi,
|
|
3
3
|
failValidation,
|
|
4
4
|
validateScheduledAgentRef
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-DVA4DOBH.js";
|
|
6
|
+
import "./chunk-LCMIAWUZ.js";
|
|
7
7
|
import "./chunk-FRK7SSEH.js";
|
|
8
8
|
import "./chunk-GXDLWBOY.js";
|
|
9
9
|
import "./chunk-GIWHHCD6.js";
|
|
@@ -82,4 +82,4 @@ export {
|
|
|
82
82
|
unstageBody,
|
|
83
83
|
unstageCommand
|
|
84
84
|
};
|
|
85
|
-
//# sourceMappingURL=unstage-
|
|
85
|
+
//# sourceMappingURL=unstage-NPQ5JQ6S.js.map
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
slackBody,
|
|
17
17
|
validateScheduledAgentRef,
|
|
18
18
|
writeOk
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-DVA4DOBH.js";
|
|
20
|
+
import "./chunk-LCMIAWUZ.js";
|
|
21
21
|
import "./chunk-FRK7SSEH.js";
|
|
22
22
|
import "./chunk-GXDLWBOY.js";
|
|
23
23
|
import "./chunk-GIWHHCD6.js";
|
|
@@ -149,4 +149,4 @@ var updateCommand = defineCommand({
|
|
|
149
149
|
export {
|
|
150
150
|
updateCommand
|
|
151
151
|
};
|
|
152
|
-
//# sourceMappingURL=update-
|
|
152
|
+
//# sourceMappingURL=update-77YN5JEJ.js.map
|
|
@@ -515,7 +515,10 @@ Examples:
|
|
|
515
515
|
"cta-label": { type: "string", description: "Spotlight custom CTA label" },
|
|
516
516
|
"image-id": { type: "string", description: "Baker image library id" },
|
|
517
517
|
"image-urn": { type: "string", description: "Existing urn:li:image:*" },
|
|
518
|
-
"video-id": {
|
|
518
|
+
"video-id": {
|
|
519
|
+
type: "string",
|
|
520
|
+
description: "Baker video library id \u2014 not sent to LinkedIn yet; staging refuses it, use --video-urn"
|
|
521
|
+
},
|
|
519
522
|
"video-urn": { type: "string", description: "Existing urn:li:video:*" },
|
|
520
523
|
"logo-image-id": { type: "string", description: "Baker image id for the logo" },
|
|
521
524
|
title: { type: "string", description: "Media title" },
|
|
@@ -578,7 +581,10 @@ Examples:
|
|
|
578
581
|
format: { type: "string", description: CREATIVE_FORMATS.join("|") },
|
|
579
582
|
"image-id": { type: "string", description: "Baker image library id (uploaded to LinkedIn at publish)" },
|
|
580
583
|
"image-urn": { type: "string", description: "Existing urn:li:image:*" },
|
|
581
|
-
"video-id": {
|
|
584
|
+
"video-id": {
|
|
585
|
+
type: "string",
|
|
586
|
+
description: "Baker video library id \u2014 not sent to LinkedIn yet; staging refuses it, use --video-urn"
|
|
587
|
+
},
|
|
582
588
|
"video-urn": { type: "string", description: "Existing urn:li:video:*" },
|
|
583
589
|
"logo-image-id": { type: "string", description: "Baker image id for logo (text/spotlight/follower/jobs)" },
|
|
584
590
|
intro: { type: "string", description: "Commentary / intro text (\u2264600 chars before feed truncation)" },
|
|
@@ -700,7 +706,10 @@ Examples:
|
|
|
700
706
|
"cta-label": { type: "string", description: "Spotlight custom CTA label" },
|
|
701
707
|
"image-id": { type: "string", description: "Baker image library id" },
|
|
702
708
|
"image-urn": { type: "string", description: "Existing urn:li:image:*" },
|
|
703
|
-
"video-id": {
|
|
709
|
+
"video-id": {
|
|
710
|
+
type: "string",
|
|
711
|
+
description: "Baker video library id \u2014 not sent to LinkedIn yet; staging refuses it, use --video-urn"
|
|
712
|
+
},
|
|
704
713
|
"video-urn": { type: "string", description: "Existing urn:li:video:*" },
|
|
705
714
|
"logo-image-id": { type: "string", description: "Baker image id for the logo" },
|
|
706
715
|
"thumbnail-image-id": { type: "string", description: "Baker image id for the article thumbnail" },
|
|
@@ -1012,4 +1021,4 @@ export {
|
|
|
1012
1021
|
leadFormsCommand,
|
|
1013
1022
|
trackingParamsPayload
|
|
1014
1023
|
};
|
|
1015
|
-
//# sourceMappingURL=write-commands-
|
|
1024
|
+
//# sourceMappingURL=write-commands-MPXJK2AD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/linkedin/write-commands.ts"],"sourcesContent":["import {\n campaignExcludeCompaniesSchema,\n type LinkedinDraftStageResponse,\n type LinkedinTrackingParamDynamicValue,\n TEMP_REF_PREFIX,\n TRACKING_PARAM_DYNAMIC_VALUES,\n} from \"@baker/api\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../../client.ts\";\nimport { requireChatId } from \"../../../env.ts\";\nimport { repeatedValues } from \"../../../lib/repeatedFlags.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleLinkedinError } from \"./shared.ts\";\nimport {\n bareAccountId,\n failWriteValidation,\n loadJsonFileArg,\n loadTargetingFileArg,\n mergePayload,\n parseDateFlag,\n parseListFileArg,\n parseLocaleFlag,\n parseMoneyFlag,\n parseOnOffFlag,\n requireTarget,\n requireTargets,\n stageLinkedinOps,\n stageOp,\n stageStatusChange,\n TOTAL_BUDGET_HELP,\n} from \"./write-shared.ts\";\n\n/**\n * Staged write subcommands. None of these touch the LinkedIn API — they stage\n * ops on this chat's draft; ops appear in the dashboard as pending LinkedIn\n * changes and apply when the chat is published. Review with\n * `baker ads linkedin draft`, undo with `draft remove <ref>`.\n */\n\nconst STAGED_NOTE = \"Staged until publish — review with `baker ads linkedin draft`.\";\n\nconst accountArgs = {\n \"account-id\": { type: \"string\", description: \"Numeric account ID or urn:li:sponsoredAccount:N\" },\n \"account-urn\": { type: \"string\", description: \"Alias for --account-id\" },\n} as const;\n\nfunction runScheduleFromFlags(args: Record<string, unknown>): { start?: number; end?: number } | undefined {\n const start = parseDateFlag(args.start, \"--start\");\n const end = parseDateFlag(args.end, \"--end\");\n if (start === undefined && end === undefined) {\n return undefined;\n }\n return { ...(start !== undefined ? { start } : {}), ...(end !== undefined ? { end } : {}) };\n}\n\n// --- Campaign groups ---\n\nexport const campaignGroupsCreateCommand = defineCommand({\n meta: {\n name: \"create\",\n description: `Stage a new campaign group. ${STAGED_NOTE}\nA group can't be created PAUSED, and a --total-budget needs an --end.\nExample: baker ads linkedin campaign-groups create --name \"Q3 ABM\" --start 2026-07-10 --end 2026-09-30 --total-budget 5000 --currency EUR`,\n },\n args: {\n ...accountArgs,\n name: { type: \"string\", description: \"Campaign group name (≤100 chars)\" },\n start: { type: \"string\", description: \"Run schedule start (ISO date or epoch ms)\" },\n end: { type: \"string\", description: \"Run schedule end\" },\n \"total-budget\": { type: \"string\", description: TOTAL_BUDGET_HELP },\n currency: { type: \"string\", description: \"3-letter currency code (defaults to the ad account currency)\" },\n status: {\n type: \"string\",\n description:\n \"DRAFT|ACTIVE (default DRAFT) — LinkedIn refuses a new group created PAUSED; pause it once it exists\",\n },\n file: { type: \"string\", description: \"JSON file with the full payload; flags override file keys\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload(loadJsonFileArg(args.file), {\n name: args.name,\n runSchedule: runScheduleFromFlags(args as Record<string, unknown>),\n totalBudget: parseMoneyFlag(args[\"total-budget\"], args.currency, \"--total-budget\"),\n status: args.status ? String(args.status).toUpperCase() : undefined,\n });\n await stageOp({ kind: \"campaignGroup.create\", accountId, payload });\n },\n});\n\nexport const campaignGroupsUpdateCommand = defineCommand({\n meta: {\n name: \"update\",\n description: `Stage changes to an existing campaign group. ${STAGED_NOTE}\nPass a li_temp_* ref to amend a group staged in this chat — fields merge into the staged create.\nExample: baker ads linkedin campaign-groups update 635137195 --total-budget 8000 --currency EUR`,\n },\n args: {\n id: { type: \"positional\", description: \"Campaign group id or URN\", required: true },\n ...accountArgs,\n name: { type: \"string\", description: \"New name\" },\n start: { type: \"string\", description: \"New run schedule start\" },\n end: { type: \"string\", description: \"New run schedule end\" },\n \"total-budget\": { type: \"string\", description: TOTAL_BUDGET_HELP },\n currency: { type: \"string\", description: \"3-letter currency code (defaults to the ad account currency)\" },\n status: { type: \"string\", description: \"ACTIVE|PAUSED|ARCHIVED|…\" },\n file: { type: \"string\", description: \"JSON file with fields to change\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload(loadJsonFileArg(args.file), {\n name: args.name,\n runSchedule: runScheduleFromFlags(args as Record<string, unknown>),\n totalBudget: parseMoneyFlag(args[\"total-budget\"], args.currency, \"--total-budget\"),\n status: args.status ? String(args.status).toUpperCase() : undefined,\n });\n await stageOp({\n kind: \"campaignGroup.update\",\n accountId,\n target: requireTarget(args as Record<string, unknown>, \"campaign group\"),\n payload,\n });\n },\n});\n\n// --- Campaigns ---\n\nfunction campaignPayloadFromFlags(args: Record<string, unknown>): Record<string, unknown> {\n return {\n name: args.name,\n campaignGroup: args.group,\n type: args.type ? String(args.type).toUpperCase() : undefined,\n objectiveType: args.objective ? String(args.objective).toUpperCase() : undefined,\n costType: args[\"cost-type\"] ? String(args[\"cost-type\"]).toUpperCase() : undefined,\n unitCost: parseMoneyFlag(args.bid, args.currency, \"--bid\"),\n dailyBudget: parseMoneyFlag(args[\"daily-budget\"], args.currency, \"--daily-budget\"),\n totalBudget: parseMoneyFlag(args[\"total-budget\"], args.currency, \"--total-budget\"),\n runSchedule: runScheduleFromFlags(args),\n locale: parseLocaleFlag(args.locale),\n targetingCriteria: loadTargetingFileArg(args[\"targeting-file\"]),\n audienceExpansionEnabled: parseOnOffFlag(args[\"audience-expansion\"], \"--audience-expansion\"),\n offsiteDeliveryEnabled: parseOnOffFlag(args.lan, \"--lan\"),\n connectedTelevisionOnly: parseOnOffFlag(args.ctv, \"--ctv\"),\n creativeSelection: args[\"creative-selection\"] ? String(args[\"creative-selection\"]).toUpperCase() : undefined,\n associatedEntity: args[\"associated-entity\"],\n politicalIntent: args[\"political-intent\"] ? String(args[\"political-intent\"]).toUpperCase() : undefined,\n status: args.status ? String(args.status).toUpperCase() : undefined,\n };\n}\n\nconst POLITICAL_INTENT_HELP =\n 'NOT_DECLARED (default)|NOT_POLITICAL|POLITICAL — the advertiser\\'s own declaration. Pass NOT_POLITICAL only after the user confirms: \"I confirm this is not political advertising. None of my ads qualify as political advertising under the law of the targeted countries, including EU law for ads targeted to the EU.\"';\n\nconst campaignFlagArgs = {\n ...accountArgs,\n name: { type: \"string\", description: \"Campaign name (≤255 chars)\" },\n group: { type: \"string\", description: \"Campaign group id/URN, or li_temp_* ref staged in this chat\" },\n type: { type: \"string\", description: \"SPONSORED_UPDATES|TEXT_AD|SPONSORED_INMAILS|DYNAMIC\" },\n objective: { type: \"string\", description: \"e.g. LEAD_GENERATION, WEBSITE_VISIT, BRAND_AWARENESS\" },\n \"cost-type\": { type: \"string\", description: \"CPC|CPM|CPV\" },\n bid: { type: \"string\", description: \"Manual bid (unitCost) — playbook mandates manual bidding\" },\n \"daily-budget\": { type: \"string\", description: \"Daily budget amount\" },\n \"total-budget\": { type: \"string\", description: TOTAL_BUDGET_HELP },\n currency: { type: \"string\", description: \"3-letter currency code (defaults to the ad account currency)\" },\n start: { type: \"string\", description: \"Run schedule start (ISO date or epoch ms)\" },\n end: { type: \"string\", description: \"Run schedule end\" },\n locale: { type: \"string\", description: \"Profile locale like en_US\" },\n \"targeting-file\": { type: \"string\", description: \"JSON file with targetingCriteria (include.and[].or facets)\" },\n \"audience-expansion\": { type: \"string\", description: \"on|off (playbook: off)\" },\n lan: { type: \"string\", description: \"LinkedIn Audience Network on|off (playbook: off)\" },\n ctv: { type: \"string\", description: \"Connected TV on|off\" },\n \"creative-selection\": { type: \"string\", description: \"OPTIMIZED|ROUND_ROBIN\" },\n \"associated-entity\": { type: \"string\", description: \"Organization URN\" },\n \"political-intent\": { type: \"string\", description: POLITICAL_INTENT_HELP },\n status: { type: \"string\", description: \"DRAFT|ACTIVE|PAUSED — PAUSED needs a group that is not DRAFT\" },\n file: { type: \"string\", description: \"JSON file with the full payload; flags override file keys\" },\n} as const;\n\nexport const campaignsCreateCommand = defineCommand({\n meta: {\n name: \"create\",\n description: `Stage a new campaign. ${STAGED_NOTE}\nTargeting goes in --targeting-file (facet URNs). --group accepts a li_temp_* ref from a campaign group staged in this chat.\nExample: baker ads linkedin campaigns create --name \"ABM Tier-1\" --group li_temp_x1 --objective WEBSITE_VISIT --type SPONSORED_UPDATES --cost-type CPC --bid 8.50 --daily-budget 75 --currency EUR --locale en_US --targeting-file targeting.json`,\n },\n args: campaignFlagArgs,\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload(loadJsonFileArg(args.file), campaignPayloadFromFlags(args as Record<string, unknown>));\n if (payload.locale === undefined) {\n payload.locale = { country: \"US\", language: \"en\" };\n }\n await stageOp({ kind: \"campaign.create\", accountId, payload });\n },\n});\n\n/**\n * `campaigns update`'s flags → payload. Create-only fields (campaignGroup/type/locale/\n * associatedEntity) are not updatable on a LIVE campaign, so they're stripped there; a\n * `li_temp_*` target amends the staged create in place, where those fields are still fair game\n * (the amend path re-validates the merged payload as a full create).\n */\nexport function campaignUpdatePayloadFromFlags(\n args: Record<string, unknown>,\n target: string,\n file: Record<string, unknown>,\n): Record<string, unknown> {\n const flags = campaignPayloadFromFlags(args);\n if (!target.startsWith(TEMP_REF_PREFIX)) {\n flags.campaignGroup = undefined;\n flags.type = undefined;\n flags.locale = undefined;\n flags.associatedEntity = undefined;\n }\n return mergePayload(file, flags);\n}\n\nexport const campaignsUpdateCommand = defineCommand({\n meta: {\n name: \"update\",\n description: `Stage changes to an existing campaign (budget, bid, targeting, flags, schedule, status). ${STAGED_NOTE}\nPass a li_temp_* ref to amend a campaign staged in this chat — fields merge into the staged create, and --group/--type/--locale/--associated-entity carry through too (they're create-only on a LIVE campaign, but fair game while it's still staged).\nExample: baker ads linkedin campaigns update 123456 --daily-budget 100 --currency EUR --audience-expansion off`,\n },\n args: {\n id: { type: \"positional\", description: \"Campaign id or URN\", required: true },\n ...campaignFlagArgs,\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const target = requireTarget(args as Record<string, unknown>, \"campaign\");\n const payload = campaignUpdatePayloadFromFlags(args as Record<string, unknown>, target, loadJsonFileArg(args.file));\n await stageOp({ kind: \"campaign.update\", accountId, target, payload });\n },\n});\n\nfunction commaList(value: unknown): string[] {\n return typeof value === \"string\"\n ? value\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0)\n : [];\n}\n\n/** `--org` takes the bare ids `companies`/`top-companies` print, or full organization URNs. */\nexport function excludeCompaniesPayload(args: Record<string, unknown>): {\n add: { employers?: string[]; segments?: string[] };\n} {\n const employers = commaList(args.org).map((org) => (org.startsWith(\"urn:\") ? org : `urn:li:organization:${org}`));\n const segments = commaList(args.segment);\n return {\n add: {\n ...(employers.length > 0 ? { employers } : {}),\n ...(segments.length > 0 ? { segments } : {}),\n },\n };\n}\n\nconst EXCLUSION_FLAG_BY_FIELD: Record<string, string> = { employers: \"--org\", segments: \"--segment\" };\n\n/**\n * Why these flags cannot stage, in the flags' own words — `--org: 0 is not a\n * LinkedIn company id …` rather than the contract path `payload.add.employers.1`\n * and a pointer at the capabilities catalogue, which is for unknown fields.\n */\nexport function excludeCompaniesRefusal(args: Record<string, unknown>): string | undefined {\n const payload = excludeCompaniesPayload(args);\n if (!payload.add.employers && !payload.add.segments) {\n return \"pass --org and/or --segment — the companies or audiences this ad set should stop reaching\";\n }\n const parsed = campaignExcludeCompaniesSchema.safeParse(payload);\n if (parsed.success) {\n return undefined;\n }\n return parsed.error.issues\n .map((issue) => {\n const flag = EXCLUSION_FLAG_BY_FIELD[String(issue.path[1])];\n return flag ? `${flag}: ${issue.message}` : issue.message;\n })\n .join(\"; \");\n}\n\nexport const campaignsExcludeCompaniesCommand = defineCommand({\n meta: {\n name: \"exclude-companies\",\n description: `Stop an ad set reaching some companies — customers, open deals, competitors. ${STAGED_NOTE}\nAdd-only: adds to the ad set's exclusions and never removes one. At publish Baker re-reads the ad set and merges into its targeting as it stands then, so audience, locations and existing exclusions are kept.\n--org takes company ids (as \\`companies\\` / \\`top-companies\\` print them) or urn:li:organization URNs, comma-separated, up to 200 per call. For a longer list, upload it as a company-list audience and pass it to --segment (an urn:li:dmpSegment/adSegment URN, or a li_temp_* audience staged in this chat).\nExample: baker ads linkedin campaigns exclude-companies 123456 --org 1035,1441`,\n },\n args: {\n id: {\n type: \"positional\",\n description: \"Ad set (campaign) id or URN — must already be on LinkedIn\",\n required: true,\n },\n ...accountArgs,\n org: { type: \"string\", description: \"Company ids or urn:li:organization URNs to exclude, comma-separated\" },\n segment: {\n type: \"string\",\n description:\n \"Matched audiences to exclude, comma-separated: urn:li:dmpSegment:N / urn:li:adSegment:N or a li_temp_* ref\",\n },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const target = requireTarget(args as Record<string, unknown>, \"campaign\");\n const refusal = excludeCompaniesRefusal(args as Record<string, unknown>);\n if (refusal) {\n failWriteValidation(refusal);\n }\n const payload = excludeCompaniesPayload(args as Record<string, unknown>);\n await stageOp({ kind: \"campaign.excludeCompanies\", accountId, target, payload });\n },\n});\n\nfunction statusSugarCommand(\n entity: \"campaign-groups\" | \"campaigns\" | \"creatives\",\n kind: \"campaignGroup.update\" | \"campaign.update\" | \"creative.update\",\n name: \"pause\" | \"resume\" | \"archive\",\n) {\n const status = name === \"pause\" ? \"PAUSED\" : name === \"resume\" ? \"ACTIVE\" : \"ARCHIVED\";\n return defineCommand({\n meta: {\n name,\n description: `Stage a status change to ${status}, for one id or many. ${STAGED_NOTE}\nExamples:\n baker ads linkedin ${entity} ${name} 123456\n baker ads linkedin ${entity} ${name} 123456,123457,123458\n baker ads linkedin ${entity} ${name} --ids-file ids.txt`,\n },\n args: {\n id: { type: \"positional\", description: \"Entity id or URN — comma-separate several\", required: false },\n \"ids-file\": { type: \"string\", description: \"File of ids, one per line or comma-separated\" },\n ...accountArgs,\n },\n run: async ({ args }) => {\n await stageStatusChange({\n kind,\n accountId: bareAccountId(args as Record<string, unknown>),\n targets: requireTargets(args as Record<string, unknown>, entity.replace(/-/g, \" \").replace(/s$/, \"\")),\n status,\n });\n },\n });\n}\n\n// --- Ad set URL tracking parameters ---\n\n/**\n * `--param`/`--dynamic` accept a repeated flag, an `&`-joined query string, or\n * both — agents reach for all three, and the parsed result is identical.\n */\nfunction trackingPairs(value: unknown, flag: string): Array<[string, string]> {\n const raw = value === undefined ? [] : Array.isArray(value) ? value : [value];\n return raw.flatMap((entry) =>\n String(entry)\n .split(\"&\")\n .filter((pair) => pair.length > 0)\n .map((pair): [string, string] => {\n const at = pair.indexOf(\"=\");\n if (at < 1 || at === pair.length - 1) {\n failWriteValidation(`${flag} expects key=value pairs — got \"${pair}\"`);\n }\n return [pair.slice(0, at).trim(), pair.slice(at + 1).trim()];\n }),\n );\n}\n\n/** A value that names one of LinkedIn's placeholders, however the agent wrote it. */\nfunction asDynamicValue(value: string): LinkedinTrackingParamDynamicValue | undefined {\n const bare = value.replace(/^\\{+|\\}+$/g, \"\").toUpperCase();\n return (TRACKING_PARAM_DYNAMIC_VALUES as readonly string[]).includes(bare)\n ? (bare as LinkedinTrackingParamDynamicValue)\n : undefined;\n}\n\n/**\n * `rawArgs` is the command line, and it is what the repeatable flags are read\n * from: citty keeps only a repeated flag's LAST value, so `--param a=1 --param\n * b=2` arrives here as `\"b=2\"`. Since this write REPLACES the entity's whole\n * parameter set, taking it from `args` would stage one pair, report success,\n * and delete the rest at publish.\n */\nexport function trackingParamsPayload(\n args: Record<string, unknown>,\n rawArgs?: readonly string[],\n): Record<string, unknown> {\n if (args.clear) {\n return { dynamicValueParameters: {}, customValueParameters: {} };\n }\n const customValueParameters: Record<string, string> = {};\n for (const [key, value] of trackingPairs(repeatedValues(rawArgs, \"param\", args.param), \"--param\")) {\n if (asDynamicValue(value)) {\n failWriteValidation(\n `--param ${key}=${value} names a value LinkedIn fills in per ad — pass it as --dynamic ${key}=${value.replace(/^\\{+|\\}+$/g, \"\").toUpperCase()}`,\n );\n }\n customValueParameters[key] = value;\n }\n const dynamicValueParameters: Record<string, string> = {};\n for (const [key, value] of trackingPairs(repeatedValues(rawArgs, \"dynamic\", args.dynamic), \"--dynamic\")) {\n const resolved = asDynamicValue(value);\n if (!resolved) {\n failWriteValidation(\n `--dynamic ${key}=${value} is not a value LinkedIn can fill in — use one of ${TRACKING_PARAM_DYNAMIC_VALUES.join(\", \")}, or pass a fixed value with --param`,\n );\n }\n dynamicValueParameters[key] = resolved;\n }\n return mergePayload(loadJsonFileArg(args.file), {\n customValueParameters: Object.keys(customValueParameters).length > 0 ? customValueParameters : undefined,\n dynamicValueParameters: Object.keys(dynamicValueParameters).length > 0 ? dynamicValueParameters : undefined,\n });\n}\n\nexport const campaignsUrlParamsCommand = defineCommand({\n meta: {\n name: \"url-params\",\n description: `Stage the URL tracking parameters on an ad set — LinkedIn appends them to the link of EVERY ad in it, including ads already running. ${STAGED_NOTE}\n\nStart here: set UTMs at this level, not per ad. A per-ad landing URL is only for a genuinely different destination — LinkedIn appends the ad set's parameters on top of whatever the ad's own URL carries, so the same key set in both places lands twice.\n\nThis REPLACES the ad set's whole parameter set — LinkedIn does not merge. Read what it carries first (\\`baker ads linkedin url-params --campaign-ids <ad-set-id>\\`) and re-send every pair that should survive; the drop is otherwise silent until traffic stops being attributable.\n\nValues LinkedIn fills in per ad (--dynamic): ACCOUNT_ID, ACCOUNT_NAME, CAMPAIGN_GROUP_ID, CAMPAIGN_GROUP_NAME, CAMPAIGN_ID, CAMPAIGN_NAME, CREATIVE_ID, CREATIVE_NAME.\n\nExamples:\n baker ads linkedin campaigns url-params 123456 --param \"utm_source=linkedin&utm_medium=paid-social\" --dynamic utm_campaign=CAMPAIGN_NAME --dynamic utm_content=CREATIVE_ID\n baker ads linkedin campaigns url-params 123456 --param utm_agency=baker\n baker ads linkedin campaigns url-params 123456 --clear`,\n },\n args: {\n id: { type: \"positional\", description: \"Ad set (campaign) id or URN\", required: true },\n ...accountArgs,\n param: {\n type: \"string\",\n description: 'Fixed key=value, repeatable or &-joined (e.g. --param \"utm_source=linkedin&utm_medium=paid\")',\n },\n dynamic: {\n type: \"string\",\n description: \"key=PLACEHOLDER LinkedIn fills in per ad, repeatable (e.g. --dynamic utm_campaign=CAMPAIGN_NAME)\",\n },\n clear: { type: \"boolean\", description: \"Remove every tracking parameter from this ad set\" },\n file: { type: \"string\", description: \"JSON file with the full payload; flags override file keys\" },\n },\n run: async ({ args, rawArgs }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n await stageOp({\n kind: \"trackingParams.set\",\n accountId,\n target: requireTarget(args as Record<string, unknown>, \"ad set\"),\n payload: trackingParamsPayload(args as Record<string, unknown>, rawArgs),\n });\n },\n});\n\n/**\n * The same parameters, one level up. The target is built from the RESOLVED\n * account rather than taken as a positional: `trackingParamsLevel` reads a bare\n * numeric id as an ad set, so an account id typed bare would silently stage an\n * ad-set write — and this command has no ad set to name.\n */\n/**\n * The op target for an account-level set. Built from the account the command\n * already resolved, never from a positional: `--account-id` accepts the URN\n * form too, so composing the prefix without stripping it first would produce\n * `urn:li:sponsoredAccount:urn:li:sponsoredAccount:N` and 400 at publish.\n */\nexport function accountTrackingTarget(args: Record<string, unknown>): { accountId: string; target: string } {\n const accountId = bareAccountId(args);\n return { accountId, target: `urn:li:sponsoredAccount:${accountId}` };\n}\n\nexport const accountUrlParamsCommand = defineCommand({\n meta: {\n name: \"url-params\",\n description: `Stage the URL tracking parameters on the whole AD ACCOUNT — LinkedIn appends them to the link of every ad in every ad set, including ads already running. ${STAGED_NOTE}\n\nUse this for the parameters that never vary across the account (utm_source, utm_medium, an agency tag). Anything that identifies a specific ad set belongs on the ad set (\\`campaigns url-params\\`) — LinkedIn appends BOTH levels, so a key set in both places lands in the URL twice.\n\nThis REPLACES the account's whole parameter set — LinkedIn does not merge. Read what it carries first with \\`baker ads linkedin url-params\\` and re-send every pair that should survive.\n\nValues LinkedIn fills in per ad (--dynamic): ACCOUNT_ID, ACCOUNT_NAME, CAMPAIGN_GROUP_ID, CAMPAIGN_GROUP_NAME, CAMPAIGN_ID, CAMPAIGN_NAME, CREATIVE_ID, CREATIVE_NAME.\n\nExamples:\n baker ads linkedin account url-params --param \"utm_source=linkedin&utm_medium=paid_social\"\n baker ads linkedin account url-params --param utm_source=linkedin --dynamic utm_campaign=CAMPAIGN_NAME\n baker ads linkedin account url-params --clear`,\n },\n args: {\n ...accountArgs,\n param: {\n type: \"string\",\n description: 'Fixed key=value, repeatable or &-joined (e.g. --param \"utm_source=linkedin&utm_medium=paid\")',\n },\n dynamic: {\n type: \"string\",\n description: \"key=PLACEHOLDER LinkedIn fills in per ad, repeatable (e.g. --dynamic utm_campaign=CAMPAIGN_NAME)\",\n },\n clear: { type: \"boolean\", description: \"Remove every tracking parameter set on the ad account\" },\n file: { type: \"string\", description: \"JSON file with the full payload; flags override file keys\" },\n },\n run: async ({ args, rawArgs }) => {\n const { accountId, target } = accountTrackingTarget(args as Record<string, unknown>);\n await stageOp({\n kind: \"trackingParams.set\",\n accountId,\n target,\n payload: trackingParamsPayload(args as Record<string, unknown>, rawArgs),\n });\n },\n});\n\nexport const campaignsPauseCommand = statusSugarCommand(\"campaigns\", \"campaign.update\", \"pause\");\nexport const campaignsResumeCommand = statusSugarCommand(\"campaigns\", \"campaign.update\", \"resume\");\nexport const campaignsArchiveCommand = statusSugarCommand(\"campaigns\", \"campaign.update\", \"archive\");\nexport const campaignGroupsPauseCommand = statusSugarCommand(\"campaign-groups\", \"campaignGroup.update\", \"pause\");\nexport const campaignGroupsResumeCommand = statusSugarCommand(\"campaign-groups\", \"campaignGroup.update\", \"resume\");\nexport const creativesPauseCommand = statusSugarCommand(\"creatives\", \"creative.update\", \"pause\");\nexport const creativesResumeCommand = statusSugarCommand(\"creatives\", \"creative.update\", \"resume\");\n\nfunction duplicateCommand(entity: \"campaignGroup\" | \"campaign\" | \"creative\", cliGroup: string) {\n return defineCommand({\n meta: {\n name: \"duplicate\",\n description: `Stage a copy of an existing ${entity} as a new DRAFT create (playbook: duplicate, never link-to-original). ${STAGED_NOTE}\nExample: baker ads linkedin ${cliGroup} duplicate 123456 --name \"New variant\"`,\n },\n args: {\n id: { type: \"positional\", description: \"Source id or URN\", required: true },\n ...accountArgs,\n name: { type: \"string\", description: \"Name for the copy\" },\n file: { type: \"string\", description: \"JSON file with field overrides for the copy\" },\n },\n run: async ({ args }) => {\n try {\n const chatId = requireChatId();\n const overrides = mergePayload(loadJsonFileArg(args.file), { name: args.name });\n const response = await apiPost<{ ok: true; data: LinkedinDraftStageResponse }>(\n \"/api/ads/linkedin/draft/duplicate\",\n {\n chatId,\n accountId: bareAccountId(args as Record<string, unknown>),\n entity,\n sourceId: requireTarget(args as Record<string, unknown>, entity),\n ...(Object.keys(overrides).length > 0 ? { overrides } : {}),\n },\n );\n writeJsonEnvelope(response);\n } catch (err) {\n handleLinkedinError(err);\n }\n },\n });\n}\n\nexport const campaignsDuplicateCommand = duplicateCommand(\"campaign\", \"campaigns\");\nexport const campaignGroupsDuplicateCommand = duplicateCommand(\"campaignGroup\", \"campaign-groups\");\n\nexport const creativesDuplicateCommand = defineCommand({\n meta: {\n name: \"duplicate\",\n description: `Stage a copy of an existing ad, optionally with new content. ${STAGED_NOTE}\nContent flags only apply to direct-content ads (text|spotlight|follower|jobs) — LinkedIn makes their content immutable, so a copy is how their copy/media/URL changes. Post-based ads (image|video|carousel|document|article|event|tla) sponsor a post that owns the copy, media and destination: a copy re-sponsors the SAME post, so content flags are rejected — stage \\`creatives create\\` with the new content instead, then pause the old ad.\n--replace also pauses the original once the new ad publishes (skipped if the new ad fails).\nExamples:\n baker ads linkedin creatives duplicate 1458413484 --headline \"10x Demos, Same Team\" --description \"AI handles every demo request.\" --replace\n baker ads linkedin creatives duplicate urn:li:sponsoredCreative:789 --campaign 799305464`,\n },\n args: {\n id: { type: \"positional\", description: \"Source creative id or URN\", required: true },\n ...accountArgs,\n campaign: { type: \"string\", description: \"Stage the copy under a different ad set (id/URN or li_temp_*)\" },\n \"intended-status\": {\n type: \"string\",\n description: \"Status for the copy (default DRAFT; with --replace, the source's status)\",\n },\n replace: {\n type: \"boolean\",\n description: \"Also pause the original once the new ad publishes; the copy inherits the source's status\",\n },\n intro: { type: \"string\", description: \"New commentary / intro text\" },\n headline: { type: \"string\", description: \"New headline\" },\n description: { type: \"string\", description: \"New description (text/spotlight ads)\" },\n \"landing-url\": {\n type: \"string\",\n description: \"New https destination URL (direct-content ads only — a post-based ad's URL lives in its post)\",\n },\n cta: { type: \"string\", description: \"New CTA (LEARN_MORE|REQUEST_DEMO|…)\" },\n \"cta-label\": { type: \"string\", description: \"Spotlight custom CTA label\" },\n \"image-id\": { type: \"string\", description: \"Baker image library id\" },\n \"image-urn\": { type: \"string\", description: \"Existing urn:li:image:*\" },\n \"video-id\": {\n type: \"string\",\n description: \"Baker video library id — not sent to LinkedIn yet; staging refuses it, use --video-urn\",\n },\n \"video-urn\": { type: \"string\", description: \"Existing urn:li:video:*\" },\n \"logo-image-id\": { type: \"string\", description: \"Baker image id for the logo\" },\n title: { type: \"string\", description: \"Media title\" },\n file: { type: \"string\", description: \"JSON file with field overrides for the copy\" },\n },\n run: async ({ args }) => {\n try {\n const chatId = requireChatId();\n const file = loadJsonFileArg(args.file);\n const fileContent =\n file.content !== null && typeof file.content === \"object\" && !Array.isArray(file.content)\n ? (file.content as Record<string, unknown>)\n : {};\n const content = { ...fileContent, ...creativeContentPatch(args as Record<string, unknown>) };\n const overrides = mergePayload(file, {\n campaign: args.campaign,\n intendedStatus: args[\"intended-status\"] ? String(args[\"intended-status\"]).toUpperCase() : undefined,\n content: Object.keys(content).length > 0 ? content : undefined,\n });\n const response = await apiPost<{ ok: true; data: LinkedinDraftStageResponse }>(\n \"/api/ads/linkedin/draft/duplicate\",\n {\n chatId,\n accountId: bareAccountId(args as Record<string, unknown>),\n entity: \"creative\",\n sourceId: requireTarget(args as Record<string, unknown>, \"creative\"),\n ...(Object.keys(overrides).length > 0 ? { overrides } : {}),\n ...(args.replace ? { replace: true } : {}),\n },\n );\n writeJsonEnvelope(response);\n } catch (err) {\n handleLinkedinError(err);\n }\n },\n});\n\n// --- Creatives ---\n\nconst CREATIVE_FORMATS = [\n \"image\",\n \"video\",\n \"text\",\n \"spotlight\",\n \"follower\",\n \"document\",\n \"carousel\",\n \"conversation\",\n \"tla\",\n \"jobs\",\n \"event\",\n \"article\",\n] as const;\n\nexport const creativesCreateCommand = defineCommand({\n meta: {\n name: \"create\",\n description: `Stage a new creative (ad). ${STAGED_NOTE}\nFormats: ${CREATIVE_FORMATS.join(\"|\")}. Media comes from the Baker library (--image-id / --video-id from \\`baker images\\`/\\`baker videos\\`) or as LinkedIn URNs. Complex formats (carousel, jobs) take --file with the full content object. Conversation ads take --file with the message flow ({message: {subject, body, buttons[]}} — buttons NESTED|LANDING_PAGE, nested messages recurse).\nExamples:\n baker ads linkedin creatives create --campaign li_temp_x2 --format image --image-id <bakerImageId> --intro \"Meet the platform…\" --headline \"Book a demo\" --landing-url https://example.com/demo --cta REQUEST_DEMO\n baker ads linkedin creatives create --campaign 123456 --format tla --post-urn urn:li:ugcPost:789`,\n },\n args: {\n ...accountArgs,\n campaign: { type: \"string\", description: \"Campaign id/URN, or li_temp_* ref staged in this chat\" },\n format: { type: \"string\", description: CREATIVE_FORMATS.join(\"|\") },\n \"image-id\": { type: \"string\", description: \"Baker image library id (uploaded to LinkedIn at publish)\" },\n \"image-urn\": { type: \"string\", description: \"Existing urn:li:image:*\" },\n \"video-id\": {\n type: \"string\",\n description: \"Baker video library id — not sent to LinkedIn yet; staging refuses it, use --video-urn\",\n },\n \"video-urn\": { type: \"string\", description: \"Existing urn:li:video:*\" },\n \"logo-image-id\": { type: \"string\", description: \"Baker image id for logo (text/spotlight/follower/jobs)\" },\n intro: { type: \"string\", description: \"Commentary / intro text (≤600 chars before feed truncation)\" },\n headline: { type: \"string\", description: \"Headline (≤70; text ads ≤25)\" },\n description: { type: \"string\", description: \"Description (text ads ≤75, spotlight ≤70)\" },\n \"landing-url\": { type: \"string\", description: \"https destination URL\" },\n cta: { type: \"string\", description: \"LEARN_MORE|REQUEST_DEMO|SIGN_UP|REGISTER|DOWNLOAD|…\" },\n \"cta-label\": { type: \"string\", description: \"Spotlight custom CTA label (≤18 chars)\" },\n \"post-urn\": { type: \"string\", description: \"TLA: existing post to sponsor (urn:li:share|ugcPost:*)\" },\n \"event-urn\": { type: \"string\", description: \"Event ads: the LinkedIn event to sponsor (urn:li:event:*)\" },\n \"article-url\": { type: \"string\", description: \"Article ads: https URL of the article/newsletter to sponsor\" },\n \"thumbnail-image-id\": { type: \"string\", description: \"Article ads: Baker image id for the link thumbnail\" },\n \"thumbnail-urn\": { type: \"string\", description: \"Article ads: existing urn:li:image:* thumbnail\" },\n \"intended-status\": { type: \"string\", description: \"DRAFT|ACTIVE|PAUSED (default DRAFT)\" },\n title: { type: \"string\", description: \"Media title (image/video) or article title\" },\n file: { type: \"string\", description: \"JSON file with the full content object; flags override\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n if (!args.campaign) {\n failWriteValidation(\"--campaign is required (id, URN, or li_temp_* ref)\");\n }\n const format = args.format ? String(args.format) : undefined;\n if (!format || !CREATIVE_FORMATS.includes(format as (typeof CREATIVE_FORMATS)[number])) {\n failWriteValidation(`--format must be one of ${CREATIVE_FORMATS.join(\"|\")}`);\n }\n const content = mergePayload(loadJsonFileArg(args.file), {\n format,\n commentary: args.intro,\n imageId: args[\"image-id\"],\n imageUrn: args[\"image-urn\"],\n videoId: args[\"video-id\"],\n videoUrn: args[\"video-urn\"],\n logoImageId: args[\"logo-image-id\"],\n headline: args.headline,\n description: args.description,\n landingUrl: args[\"landing-url\"],\n cta: args.cta ? String(args.cta).toUpperCase() : undefined,\n ctaLabel: args[\"cta-label\"],\n postUrn: args[\"post-urn\"],\n eventUrn: args[\"event-urn\"],\n source: args[\"article-url\"],\n thumbnailImageId: args[\"thumbnail-image-id\"],\n thumbnailUrn: args[\"thumbnail-urn\"],\n mediaTitle: args.title,\n title: args.title,\n });\n await stageOp({\n kind: \"creative.create\",\n accountId,\n payload: {\n campaign: args.campaign,\n intendedStatus: args[\"intended-status\"] ? String(args[\"intended-status\"]).toUpperCase() : undefined,\n content,\n },\n });\n },\n});\n\n/** Content fields `creatives update` can amend on a li_temp_* staged creative. */\nconst CREATIVE_AMEND_CONTENT_FLAGS = [\n [\"intro\", \"commentary\"],\n [\"headline\", \"headline\"],\n [\"description\", \"description\"],\n [\"landing-url\", \"landingUrl\"],\n [\"cta-label\", \"ctaLabel\"],\n [\"image-id\", \"imageId\"],\n [\"image-urn\", \"imageUrn\"],\n [\"video-id\", \"videoId\"],\n [\"video-urn\", \"videoUrn\"],\n [\"logo-image-id\", \"logoImageId\"],\n [\"thumbnail-image-id\", \"thumbnailImageId\"],\n [\"thumbnail-urn\", \"thumbnailUrn\"],\n [\"title\", \"title\"],\n] as const;\n\nfunction creativeContentPatch(args: Record<string, unknown>): Record<string, unknown> {\n const patch: Record<string, unknown> = {};\n for (const [flag, key] of CREATIVE_AMEND_CONTENT_FLAGS) {\n if (args[flag] !== undefined) {\n patch[key] = args[flag];\n }\n }\n if (args.cta !== undefined) {\n patch.cta = String(args.cta).toUpperCase();\n }\n return patch;\n}\n\nexport const creativesUpdateCommand = defineCommand({\n meta: {\n name: \"update\",\n description: `Stage changes to an existing creative, or amend a creative staged in this chat by passing its li_temp_* ref. ${STAGED_NOTE}\nDirect-content ads (text/spotlight/follower/jobs) update copy/media/URL IN PLACE — changed fields merge into the ad's current content. Post-based ads (image/video/carousel/…) sponsor a post that owns the copy, media and destination: neither this command nor \\`creatives duplicate\\` can change it — stage \\`creatives create\\` with the new content, then pause the old ad. Staged creatives (li_temp_*) accept all content flags and re-validate.\nApplies the same change to several ads at once: comma-separate the ids, or pass --ids-file. All of them stage together or none does. Live ids only — a li_temp_* amend has to be its own call.\n--campaign re-parents the ad to a different ad set — LinkedIn has no in-place move API, so this only works while the creative is still staged (li_temp_*); passing it against a live creative id/URN is rejected at stage time.\nExamples:\n baker ads linkedin creatives update 1458423674 --headline \"Sharper headline\" --description \"New copy.\"\n baker ads linkedin creatives update urn:li:sponsoredCreative:789 --intended-status PAUSED\n baker ads linkedin creatives update 1458423674,1458423675,1458423676 --intended-status PAUSED\n baker ads linkedin creatives update --ids-file ads.txt --intended-status PAUSED\n baker ads linkedin creatives update li_temp_x3 --campaign li_temp_x2`,\n },\n args: {\n id: {\n type: \"positional\",\n description:\n \"Creative id/URN — comma-separate several. A li_temp_* ref amends what this chat staged and must be passed on its own.\",\n required: false,\n },\n \"ids-file\": { type: \"string\", description: \"File of creative ids, one per line or comma-separated\" },\n ...accountArgs,\n \"intended-status\": { type: \"string\", description: \"ACTIVE|PAUSED|ARCHIVED|DRAFT\" },\n name: { type: \"string\", description: \"New creative name\" },\n campaign: {\n type: \"string\",\n description: \"Re-parent to a different ad set (id/URN or li_temp_*) — staged creatives only\",\n },\n intro: { type: \"string\", description: \"Commentary / intro text\" },\n headline: { type: \"string\", description: \"New headline\" },\n description: { type: \"string\", description: \"Description (text/spotlight ads)\" },\n \"landing-url\": { type: \"string\", description: \"New https destination URL\" },\n cta: { type: \"string\", description: \"New CTA (LEARN_MORE|REQUEST_DEMO|…)\" },\n \"cta-label\": { type: \"string\", description: \"Spotlight custom CTA label\" },\n \"image-id\": { type: \"string\", description: \"Baker image library id\" },\n \"image-urn\": { type: \"string\", description: \"Existing urn:li:image:*\" },\n \"video-id\": {\n type: \"string\",\n description: \"Baker video library id — not sent to LinkedIn yet; staging refuses it, use --video-urn\",\n },\n \"video-urn\": { type: \"string\", description: \"Existing urn:li:video:*\" },\n \"logo-image-id\": { type: \"string\", description: \"Baker image id for the logo\" },\n \"thumbnail-image-id\": { type: \"string\", description: \"Baker image id for the article thumbnail\" },\n \"thumbnail-urn\": { type: \"string\", description: \"Existing urn:li:image:* thumbnail\" },\n title: { type: \"string\", description: \"Media or article title\" },\n file: { type: \"string\", description: \"JSON file with fields to change; flags override file keys\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const targets = requireTargets(args as Record<string, unknown>, \"creative\");\n const file = loadJsonFileArg(args.file);\n const contentPatch = creativeContentPatch(args as Record<string, unknown>);\n const intendedStatus = args[\"intended-status\"] ? String(args[\"intended-status\"]).toUpperCase() : undefined;\n const fileContent =\n file.content !== null && typeof file.content === \"object\" && !Array.isArray(file.content)\n ? (file.content as Record<string, unknown>)\n : {};\n const content = { ...fileContent, ...contentPatch };\n const payload = mergePayload(file, {\n intendedStatus,\n name: args.name,\n campaign: args.campaign,\n content: Object.keys(content).length > 0 ? content : undefined,\n });\n await stageLinkedinOps(targets.map((target) => ({ kind: \"creative.update\", accountId, target, payload })));\n },\n});\n\n// --- Audiences ---\n\nconst AUDIENCE_TYPES = [\"company-list\", \"user-list\", \"retargeting\", \"engagement\"] as const;\nconst INLINE_ROWS_MAX = 10_000;\n\nconst audiencesCreateCommand = defineCommand({\n meta: {\n name: \"create\",\n description: `Stage a new matched audience. ${STAGED_NOTE}\nList audiences take --list-file (CSV: companyName,domain,organizationUrn for companies — organizationUrn matches the company page exactly; email,… for contacts — emails are SHA-256 hashed locally). LinkedIn needs 300+ MATCHED members to serve.\nExample: baker ads linkedin audiences create --name \"ABM Tier-1\" --type company-list --list-file accounts.csv`,\n },\n args: {\n ...accountArgs,\n name: { type: \"string\", description: \"Audience name (≤100 chars)\" },\n type: { type: \"string\", description: AUDIENCE_TYPES.join(\"|\") },\n \"list-file\": { type: \"string\", description: \"CSV file with the list rows (header row required)\" },\n file: {\n type: \"string\",\n description:\n 'JSON file with a raw source config (retargeting/engagement) — sourcePlatform, type USER and at least one engagementRules entry, e.g. {\"sourcePlatform\":\"VIDEO_ADS\",\"type\":\"USER\",\"engagementRules\":[{\"engagementSource\":\"urn:li:sponsoredCampaign:123\",\"engagementTrigger\":\"urn:li:dmpEngagementTrigger:(urn:li:dmpEngagementSourceType:VIDEO_ADS,FIRST_QUARTILE)\",\"timeFrame\":{\"timeSpan\":{\"duration\":90,\"unit\":\"DAY\"}}}]}',\n },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const list = parseListFileArg(args[\"list-file\"], INLINE_ROWS_MAX);\n const raw = args.file ? loadJsonFileArg(args.file) : undefined;\n await stageOp({\n kind: \"audience.create\",\n accountId,\n payload: {\n name: args.name,\n audienceType: args.type,\n ...(list ? { listColumns: list.columns, listRows: list.rows } : {}),\n ...(raw ? { raw } : {}),\n },\n });\n },\n});\n\nconst audiencesUploadCommand = defineCommand({\n meta: {\n name: \"upload\",\n description: `Stage a list upload into an existing audience segment. ${STAGED_NOTE}\nExample: baker ads linkedin audiences upload urn:li:dmpSegment:42 --list-file more-accounts.csv`,\n },\n args: {\n id: { type: \"positional\", description: \"Segment URN/id, or li_temp_* ref staged in this chat\", required: true },\n ...accountArgs,\n \"list-file\": { type: \"string\", description: \"CSV file with the rows to add\", required: true },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const list = parseListFileArg(args[\"list-file\"], INLINE_ROWS_MAX);\n if (!list) {\n failWriteValidation(\"--list-file is required\");\n }\n await stageOp({\n kind: \"audience.uploadList\",\n accountId,\n payload: {\n segment: requireTarget(args as Record<string, unknown>, \"audience segment\"),\n listColumns: list.columns,\n listRows: list.rows,\n },\n });\n },\n});\n\nexport const audiencesCommand = defineCommand({\n meta: {\n name: \"audiences\",\n description:\n \"Stage LinkedIn matched-audience changes (create lists, upload rows). Staged until publish — never hits the API directly.\",\n },\n subCommands: {\n create: audiencesCreateCommand,\n upload: audiencesUploadCommand,\n },\n});\n\n// --- Conversions ---\n\nexport const conversionsCreateCommand = defineCommand({\n meta: {\n name: \"create\",\n description: `Stage a new conversion rule. ${STAGED_NOTE}\nExample: baker ads linkedin conversions create --name \"Demo booked\" --type LEAD --method INSIGHT_TAG --post-click-window 30 --view-window 7`,\n },\n args: {\n ...accountArgs,\n name: { type: \"string\", description: \"Conversion rule name\" },\n type: {\n type: \"string\",\n description:\n \"Conversion type. Common: LEAD, QUALIFIED_LEAD, MARKETING_QUALIFIED_LEAD, SALES_QUALIFIED_LEAD, SIGN_UP, DOWNLOAD, PURCHASE, KEY_PAGE_VIEW, ADD_TO_CART, BOOK_APPOINTMENT, SUBMIT_APPLICATION, OTHER — `baker schema ads.linkedin.conversions.create` lists all 34\",\n },\n method: { type: \"string\", description: \"INSIGHT_TAG|CONVERSIONS_API\" },\n \"post-click-window\": {\n type: \"string\",\n description:\n \"1|7|30|90 days (playbook default 30); 180|365 only for LEAD, QUALIFIED_LEAD, MARKETING_QUALIFIED_LEAD, SALES_QUALIFIED_LEAD, PURCHASE, ADD_TO_CART, SUBMIT_APPLICATION\",\n },\n \"view-window\": {\n type: \"string\",\n description:\n \"1|7|30|90 days (playbook default 7); 180|365 only for LEAD, QUALIFIED_LEAD, MARKETING_QUALIFIED_LEAD, SALES_QUALIFIED_LEAD, PURCHASE, ADD_TO_CART, SUBMIT_APPLICATION\",\n },\n \"attribution-type\": { type: \"string\", description: \"LAST_TOUCH_BY_CAMPAIGN|LAST_TOUCH_BY_CONVERSION\" },\n \"associate-all-campaigns\": { type: \"boolean\", description: \"Auto-associate with active campaigns\" },\n file: { type: \"string\", description: \"JSON file with the full payload (e.g. urlMatchRuleExpression)\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload(loadJsonFileArg(args.file), {\n name: args.name,\n type: args.type ? String(args.type).toUpperCase() : undefined,\n conversionMethod: args.method ? String(args.method).toUpperCase() : undefined,\n postClickAttributionWindowSize: args[\"post-click-window\"] ? Number(args[\"post-click-window\"]) : undefined,\n viewThroughAttributionWindowSize: args[\"view-window\"] ? Number(args[\"view-window\"]) : undefined,\n attributionType: args[\"attribution-type\"] ? String(args[\"attribution-type\"]).toUpperCase() : undefined,\n associateAllCampaigns: args[\"associate-all-campaigns\"] === true ? true : undefined,\n });\n await stageOp({ kind: \"conversion.create\", accountId, payload });\n },\n});\n\nexport const conversionsUpdateCommand = defineCommand({\n meta: {\n name: \"update\",\n description: `Stage changes to a conversion rule (windows, name, enabled). ${STAGED_NOTE}\nExample: baker ads linkedin conversions update 104988516 --post-click-window 30 --view-window 7`,\n },\n args: {\n id: { type: \"positional\", description: \"Conversion rule id or URN\", required: true },\n ...accountArgs,\n name: { type: \"string\", description: \"New name\" },\n \"post-click-window\": {\n type: \"string\",\n description:\n \"1|7|30|90 days; 180|365 only for LEAD, QUALIFIED_LEAD, MARKETING_QUALIFIED_LEAD, SALES_QUALIFIED_LEAD, PURCHASE, ADD_TO_CART, SUBMIT_APPLICATION\",\n },\n \"view-window\": {\n type: \"string\",\n description:\n \"1|7|30|90 days; 180|365 only for LEAD, QUALIFIED_LEAD, MARKETING_QUALIFIED_LEAD, SALES_QUALIFIED_LEAD, PURCHASE, ADD_TO_CART, SUBMIT_APPLICATION\",\n },\n \"attribution-type\": { type: \"string\", description: \"LAST_TOUCH_BY_CAMPAIGN|LAST_TOUCH_BY_CONVERSION\" },\n enabled: { type: \"string\", description: \"on|off\" },\n file: { type: \"string\", description: \"JSON file with fields to change\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload(loadJsonFileArg(args.file), {\n name: args.name,\n postClickAttributionWindowSize: args[\"post-click-window\"] ? Number(args[\"post-click-window\"]) : undefined,\n viewThroughAttributionWindowSize: args[\"view-window\"] ? Number(args[\"view-window\"]) : undefined,\n attributionType: args[\"attribution-type\"] ? String(args[\"attribution-type\"]).toUpperCase() : undefined,\n enabled: parseOnOffFlag(args.enabled, \"--enabled\"),\n });\n await stageOp({\n kind: \"conversion.update\",\n accountId,\n target: requireTarget(args as Record<string, unknown>, \"conversion rule\"),\n payload,\n });\n },\n});\n\nconst CONVERSION_CAMPAIGN_EXPLAINER = `Which ad sets a conversion rule counts for is a separate LinkedIn record, not a field on the rule — \\`conversions update\\` cannot change it, and \\`--associate-all-campaigns\\` only exists on create.`;\n\nfunction conversionCampaignArgs() {\n return {\n id: { type: \"positional\" as const, description: \"Conversion rule id or URN\", required: true },\n ...accountArgs,\n campaign: { type: \"string\" as const, description: \"Ad set (campaign) id or URN\", required: true },\n };\n}\n\nfunction requireCampaignArg(args: Record<string, unknown>): string {\n const campaign = args.campaign;\n if (typeof campaign !== \"string\" || campaign.length === 0) {\n failWriteValidation(\"--campaign is required — pass the ad set id or URN this conversion should count for\");\n }\n return campaign as string;\n}\n\nexport const conversionsAssociateCommand = defineCommand({\n meta: {\n name: \"associate-campaign\",\n description: `Count an existing conversion rule for one ad set. ${STAGED_NOTE}\n${CONVERSION_CAMPAIGN_EXPLAINER}\nExample: baker ads linkedin conversions associate-campaign 104988516 --campaign 337643194`,\n },\n args: conversionCampaignArgs(),\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n await stageOp({\n kind: \"conversion.associateCampaign\",\n accountId,\n target: requireTarget(args as Record<string, unknown>, \"conversion rule\"),\n payload: { campaign: requireCampaignArg(args as Record<string, unknown>) },\n });\n },\n});\n\nexport const conversionsDissociateCommand = defineCommand({\n meta: {\n name: \"dissociate-campaign\",\n description: `Stop counting an existing conversion rule for one ad set. ${STAGED_NOTE}\n${CONVERSION_CAMPAIGN_EXPLAINER}\nExample: baker ads linkedin conversions dissociate-campaign 104988516 --campaign 337643194`,\n },\n args: conversionCampaignArgs(),\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n await stageOp({\n kind: \"conversion.dissociateCampaign\",\n accountId,\n target: requireTarget(args as Record<string, unknown>, \"conversion rule\"),\n payload: { campaign: requireCampaignArg(args as Record<string, unknown>) },\n });\n },\n});\n\n// --- Lead gen forms (file-first — deeply nested) ---\n\nconst leadFormsCreateCommand = defineCommand({\n meta: {\n name: \"create\",\n description: `Stage a new Lead Gen Form from a JSON file. ${STAGED_NOTE}\nRequired: name, headline (≤60), privacyPolicyUrl, questions[] (≤12; playbook: ≤4 for completion).\nEach question is a predefined profile field ({ name, predefinedField: \"EMAIL\" }) or a custom question ({ name, questionType: \"MULTIPLE_CHOICE\", options: [...] }; ≤3 custom).\nBest-practice fields the preview will nudge for if missing: 1-3 qualifying questions, consents[] (disclosure checkboxes), thankYou.message + thankYou.landingUrl|appointmentUrl.\nAlso supported: locale, formImageId|formImageUrn, hiddenFields[], legalDisclaimer, thankYou.cta. Example: baker ads linkedin lead-forms create --file form.json`,\n },\n args: {\n ...accountArgs,\n file: { type: \"string\", description: \"JSON file with the form definition\", required: true },\n name: { type: \"string\", description: \"Override the form name\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload(loadJsonFileArg(args.file), { name: args.name });\n await stageOp({ kind: \"leadForm.create\", accountId, payload });\n },\n});\n\nconst leadFormsUpdateCommand = defineCommand({\n meta: {\n name: \"update\",\n description: `Stage changes to a Lead Gen Form from a JSON file. ${STAGED_NOTE}`,\n },\n args: {\n id: { type: \"positional\", description: \"Lead form id or URN\", required: true },\n ...accountArgs,\n file: { type: \"string\", description: \"JSON file with the fields to change\", required: true },\n name: { type: \"string\", description: \"New form name\" },\n },\n run: async ({ args }) => {\n const accountId = bareAccountId(args as Record<string, unknown>);\n const payload = mergePayload({ raw: loadJsonFileArg(args.file) }, { name: args.name });\n await stageOp({\n kind: \"leadForm.update\",\n accountId,\n target: requireTarget(args as Record<string, unknown>, \"lead form\"),\n payload,\n });\n },\n});\n\nexport const leadFormsCommand = defineCommand({\n meta: {\n name: \"lead-forms\",\n description:\n \"Stage LinkedIn Lead Gen Form changes (file-first). Staged until publish — never hits the API directly.\",\n },\n subCommands: {\n create: leadFormsCreateCommand,\n update: leadFormsUpdateCommand,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,qBAAqB;AAgC9B,IAAM,cAAc;AAEpB,IAAM,cAAc;AAAA,EAClB,cAAc,EAAE,MAAM,UAAU,aAAa,kDAAkD;AAAA,EAC/F,eAAe,EAAE,MAAM,UAAU,aAAa,yBAAyB;AACzE;AAEA,SAAS,qBAAqB,MAA6E;AACzG,QAAM,QAAQ,cAAc,KAAK,OAAO,SAAS;A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sDAAsD,WAAW;AAAA,EAChF;AAAA,EACA,MAAM;AAAA,IACJ,IAAI,EAAE,MAAM,cAAc,aAAa,uBAAuB,UAAU,KAAK;AAAA,IAC7E,GAAG;AAAA,IACH,MAAM,EAAE,MAAM,UAAU,aAAa,uCAAuC,UAAU,KAAK;AAAA,IAC3F,MAAM,EAAE,MAAM,UAAU,aAAa,gBAAgB;AAAA,EACvD;AAAA,EACA,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,UAAM,YAAY,cAAc,IAA+B;AAC/D,UAAM,UAAU,aAAa,EAAE,KAAK,gBAAgB,KAAK,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,KAAK,CAAC;AACrF,UAAM,QAAQ;AAAA,MACZ,MAAM;AAAA,MACN;AAAA,MACA,QAAQ,cAAc,MAAiC,WAAW;AAAA,MAClE;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;AAEM,IAAM,mBAAmB,cAAc;AAAA,EAC5C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/command-loading.ts","../src/profile-help.ts","../src/agent-profile.ts"],"sourcesContent":["import type { Resolvable, SubCommandsDef } from \"citty\";\n\n/**\n * Which command families one `baker` invocation has to load.\n *\n * Loading every family is what made each `baker` process hold ~135 MB of heap\n * while it waited on one HTTP call: twenty parallel agents ran sixty of them and\n * filled an 8 GB Runtime. A command needs its own family and nothing else.\n */\nexport function familiesToLoad(argv: readonly string[], families: readonly string[]): string[] | \"all\" {\n const first = argv.find((token) => !token.startsWith(\"-\"));\n // `schema` reads the registry every family fills as it loads.\n if (first !== undefined && first !== \"schema\" && families.includes(first)) return [first];\n return \"all\";\n}\n\nexport type LoadableCommand = { meta?: Resolvable<unknown>; subCommands?: Resolvable<SubCommandsDef> };\n\nasync function resolved<T>(value: Resolvable<T>): Promise<T> {\n return typeof value === \"function\" ? await (value as () => T | Promise<T>)() : await value;\n}\n\n/** The command's subcommands, loaded in place if they were declared lazily. */\nasync function subCommandsOf(command: LoadableCommand): Promise<SubCommandsDef | undefined> {\n if (command.subCommands === undefined) return undefined;\n const subCommands = await resolved(command.subCommands);\n command.subCommands = subCommands;\n return subCommands;\n}\n\n/**\n * The subcommand of `command` that `token` names, by its name or an alias, as\n * citty finds it — loaded in place. An alias lives in the subcommand's own\n * meta, so a token that is no name loads the siblings to read theirs.\n */\nexport async function loadSubCommandNamed(\n command: LoadableCommand,\n token: string,\n): Promise<[string, LoadableCommand] | null> {\n const subCommands = await subCommandsOf(command);\n if (!subCommands) return null;\n const named = subCommands[token];\n if (named !== undefined) {\n const loaded = await resolved(named);\n subCommands[token] = loaded;\n return [token, loaded];\n }\n for (const [name, sub] of Object.entries(subCommands)) {\n const loaded = await resolved(sub);\n subCommands[name] = loaded;\n const meta = (await resolved(loaded.meta ?? {})) as { alias?: unknown };\n const aliases = Array.isArray(meta.alias) ? meta.alias : meta.alias === undefined ? [] : [meta.alias];\n if (aliases.includes(token)) return [name, loaded];\n }\n return null;\n}\n\n/** Loads, in place, every command at every depth. */\nexport async function loadAllCommands(command: LoadableCommand): Promise<void> {\n const subCommands = await subCommandsOf(command);\n if (!subCommands) return;\n for (const [name, sub] of Object.entries(subCommands)) {\n const loaded = await resolved(sub);\n subCommands[name] = loaded;\n await loadAllCommands(loaded);\n }\n}\n\n/**\n * Loads, in place, the command `argv` names and every parent on the way — and\n * nothing else, so the flag guards in `cli.ts` see the command they judge while\n * its siblings stay unloaded. Everything loads for `schema` and an unknown\n * name, which need the whole tree. It stops at the first flag: the organization\n * guard (`agent-profile.ts`) walks on past one itself, and loads the subtree a\n * `--help` lists.\n */\nexport async function loadCommands<T extends LoadableCommand>(root: T, argv: readonly string[]): Promise<T> {\n const families = Object.keys((await subCommandsOf(root)) ?? {});\n if (familiesToLoad(argv, families) === \"all\") {\n await loadAllCommands(root);\n return root;\n }\n let command: LoadableCommand = root;\n for (const token of argv) {\n if (token === \"--\" || token.startsWith(\"-\")) break;\n const subCommands = await subCommandsOf(command);\n const sub = subCommands?.[token];\n if (!subCommands || sub === undefined) break;\n const loaded = await resolved(sub);\n subCommands[token] = loaded;\n command = loaded;\n }\n return root;\n}\n","/**\n * What a command's help says, for the agent reading it.\n *\n * Descriptions are written for a company's agent, which may run every command:\n * they cite writes as examples (`baker ads meta campaigns create …`) and say a\n * family \"lists campaigns, or stages writes\". Read by the organization's agent,\n * which may only read, each is a call it would make and be refused. So a line\n * that names a command the reader may not run leaves its help, and where a\n * family holds commands the reader may not run, so does the talk of staging\n * them. A family the reader may change whole (the organization's own Scheduled\n * agents) keeps its staging, because it is how that family works.\n */\n\nimport type { AgentProfile } from \"./agent-profile.ts\";\n\ntype HelpNode = { meta?: unknown; subCommands?: unknown };\ntype Offers = (path: string) => boolean;\n\nfunction loadedSubCommands(node: HelpNode): Array<[string, HelpNode]> {\n const subCommands = node.subCommands;\n if (typeof subCommands !== \"object\" || subCommands === null) return [];\n return Object.entries(subCommands as Record<string, unknown>).flatMap(([name, sub]) =>\n typeof sub === \"object\" && sub !== null ? [[name, sub as HelpNode] as [string, HelpNode]] : [],\n );\n}\n\nfunction subCommandNames(node: HelpNode): string[] {\n const subCommands = node.subCommands;\n return typeof subCommands === \"object\" && subCommands !== null ? Object.keys(subCommands) : [];\n}\n\n/**\n * The command words name (`baker <words>`, or a family's command in backticks),\n * as far as the tree reaches; none when the first is no family. Where the tree\n * is not loaded this far (another family, a sibling this call never needed),\n * the words as written stand for the command: `offers` reads a command by its\n * leading words, so an argument after them changes nothing.\n */\nfunction commandOf(root: HelpNode, mention: string): string[] {\n const words = mention.trim().split(/\\s+/);\n let node: HelpNode = root;\n const path: string[] = [];\n for (const word of words) {\n const loaded = loadedSubCommands(node).find(([name]) => name === word)?.[1];\n if (!loaded) {\n // Not loaded is not \"not there\": a lazy entry of that name stands for the words written.\n return subCommandNames(node).includes(word) ? [words.join(\" \")] : path.length > 0 ? [path.join(\" \")] : [];\n }\n node = loaded;\n path.push(word);\n }\n return [path.join(\" \")];\n}\n\nfunction indentOf(line: string): number {\n return line.length - line.trimStart().length;\n}\n\n/**\n * The lines without those `drops` says go, each taken with what continues it:\n * the lines indented under it, the next line after a trailing `\\`, and the rest\n * of a sentence wrapped onto the lines below. `drops` returns the kept text of\n * a line, or null to drop it.\n */\nfunction dropping(lines: string[], drops: (line: string) => string | null): string[] {\n const kept: string[] = [];\n let carried: ((line: string) => boolean) | null = null;\n for (const line of lines) {\n if (carried?.(line)) continue;\n carried = null;\n const rest = drops(line);\n if (rest !== null) {\n kept.push(rest);\n continue;\n }\n const indent = indentOf(line);\n if (/\\\\\\s*$/.test(line)) {\n let open = true;\n carried = (next) => {\n const continues = open;\n open = /\\\\\\s*$/.test(next);\n return continues;\n };\n } else if (indent === 0 && !/[.:!?)]\\s*$/.test(line)) {\n let open = true;\n carried = (next) => {\n const continues = open && next.trim() !== \"\" && indentOf(next) === 0;\n open = continues && !/[.:!?)]\\s*$/.test(next);\n return continues;\n };\n } else if (indent > 0) {\n carried = (next) => next.trim() !== \"\" && indentOf(next) > indent;\n }\n }\n return kept;\n}\n\n/** A line that stands alone — an example, a table row, a \"Label: …\" entry — goes whole. */\nconst STANDALONE_LINE = /^(?:\\s|baker\\b|[A-Z][\\w ]{0,30}:\\s)/;\n\nfunction balanced(text: string): boolean {\n return (text.match(/\\(/g)?.length ?? 0) === (text.match(/\\)/g)?.length ?? 0);\n}\n\n/** Each command the text names, at where it names it: `baker <words>`, or a family's `<words>` in backticks. */\nfunction commandMentions(root: HelpNode, text: string): Array<{ at: number; words: string }> {\n const families = new Set(subCommandNames(root));\n const quoted = [...text.matchAll(/`([a-z][\\w-]*(?:[ \\t][a-z][\\w-]*)*)(?=[`\\s<])/g)].filter((match) =>\n families.has((match[1] ?? \"\").split(/\\s+/)[0] ?? \"\"),\n );\n return [...text.matchAll(/`?\\bbaker ((?:[a-z][\\w-]*[ \\t]?)+)/g), ...quoted].map((match) => ({\n at: match.index,\n words: match[1] ?? \"\",\n }));\n}\n\n/**\n * Where the text first mentions something the reader may not use — a command\n * it is not offered, or a flag it is refused (`--add-trigger`) — or -1.\n */\nfunction firstUnusable(root: HelpNode, text: string, offered: Offers, refusedFlags: readonly string[]): number {\n const commands = commandMentions(root, text)\n .filter(({ words }) => commandOf(root, words).some((path) => !offered(path)))\n .map(({ at }) => at);\n const flags = refusedFlags.flatMap((flag) => {\n const match = new RegExp(`--${flag}(?![\\\\w-])`).exec(text);\n return match ? [match.index] : [];\n });\n const at = [...commands, ...flags];\n return at.length > 0 ? Math.min(...at) : -1;\n}\n\n/**\n * The sentence without what it says about something the reader may not use:\n * cut back to the clause before the mention when one stands on its own, else\n * dropped.\n */\nfunction sentenceWithout(sentence: string, unusableAt: number): string {\n if (unusableAt === -1) return sentence;\n const before = sentence.slice(0, unusableAt).replace(/`$/, \"\");\n const cut = Math.max(before.lastIndexOf(\", \"), before.lastIndexOf(\" — \"), before.lastIndexOf(\"; \"));\n const clause = cut === -1 ? \"\" : before.slice(0, cut).trim();\n // \"To undo one, `baker …`\" only led to the command.\n const leadsIn = /^(?:to|use|run|call|for|with)\\b/i.test(clause);\n return clause.split(/\\s+/).length >= 3 && balanced(clause) && !leadsIn ? `${clause}.` : \"\";\n}\n\n/** A sentence that leans on the one before it (\"It never touches a live tag.\"). */\nconst LEANS_BACK = /^(?:it|they|this|that|these|those)\\b/i;\n\n/** The text without any mention of a command the reader may not run, or a flag it is refused. */\nexport function withoutUnoffered(\n root: HelpNode,\n text: string,\n offered: Offers,\n refusedFlags: readonly string[] = [],\n): string {\n const unusable = (part: string) => firstUnusable(root, part, offered, refusedFlags);\n return dropping(text.split(\"\\n\"), (line) => {\n if (unusable(line) === -1) return line;\n if (STANDALONE_LINE.test(line)) return null;\n const kept: string[] = [];\n let dropped = false;\n for (const sentence of line.split(/(?<=[.!?])\\s+/)) {\n const rest: string = dropped && LEANS_BACK.test(sentence) ? \"\" : sentenceWithout(sentence, unusable(sentence));\n dropped = rest === \"\";\n if (rest !== \"\") kept.push(rest);\n }\n return kept.length === 0 ? null : kept.join(\" \");\n }).join(\"\\n\");\n}\n\n/** Whether anything loaded under `path` is a command the reader may not run. */\nfunction holdsUnoffered(node: HelpNode, path: string[], offered: Offers): boolean {\n return loadedSubCommands(node).some(\n ([name, sub]) => !offered([...path, name].join(\" \")) || holdsUnoffered(sub, [...path, name], offered),\n );\n}\n\n/** A sentence or line that is about staging a change, from its first words. */\nconst WRITE_TALK =\n /^(?:stage\\b|staged\\b|staging\\b|write subcommands\\b|writes\\b|then stage\\b|drafts:|staged vs published\\b|lifecycle:|nothing staged\\b|on publish\\b|\\w+(?: \\/ \\w+)*\\s+—\\s+stage\\b)/i;\n\n/** The tail of a sentence offering a change: \"List campaigns, or stage writes (…)\". */\nconst WRITE_CLAUSE =\n /(?:\\s*(?:[,;]|\\s—|\\s-)\\s*(?:(?:or|plus|and)\\s+)?|\\s+(?:or|plus|and)\\s+)(?:stage[sd]?|staged)\\b[^.]*/gi;\n\n/** \"List, show, amend or clear …\": a sentence opening on a list of this command's own verbs. */\nconst VERB_LIST = /^((?:[A-Za-z]+, )*[A-Za-z]+,? (?:or|and) [a-z]+)\\b/;\n\n/** The sentence naming, of the verbs it opens on, only those the reader may run; \"\" when none. */\nfunction withOfferedVerbs(sentence: string, children: ReadonlySet<string>, unoffered: ReadonlySet<string>): string {\n const list = VERB_LIST.exec(sentence)?.[1];\n if (!list) return sentence;\n const verbs = list.split(/,\\s*(?:(?:or|and)\\s+)?|\\s+(?:or|and)\\s+/).map((verb) => verb.toLowerCase());\n if (!verbs.every((verb) => children.has(verb))) return sentence;\n const kept = verbs.filter((verb) => !unoffered.has(verb));\n if (kept.length === 0) return \"\";\n const named = kept.length === 1 ? (kept[0] ?? \"\") : `${kept.slice(0, -1).join(\", \")} or ${kept.at(-1)}`;\n return `${named.charAt(0).toUpperCase()}${named.slice(1)}${sentence.slice(list.length)}`;\n}\n\n/** Whether text opens on the name of a command here the reader may not run (\"Release if…\", \" associate-campaign / …\"). */\nfunction opensOnUnoffered(text: string, unoffered: ReadonlySet<string>): boolean {\n const first =\n text\n .trim()\n .split(/[\\s/]+/)[0]\n ?.toLowerCase() ?? \"\";\n return unoffered.has(first);\n}\n\n/** A line that is about a change: staging talk, a command it may not run, or \"Library writes (…):\" over reads. */\nfunction isWriteLine(line: string, unoffered: ReadonlySet<string>): boolean {\n if (WRITE_TALK.test(line.trim())) return true;\n if (indentOf(line) > 0) return opensOnUnoffered(line, unoffered);\n return /:\\s*$/.test(line) && /\\bwrites?\\b/i.test(line);\n}\n\nfunction withoutWriteTalk(paragraph: string, children: ReadonlySet<string>, unoffered: ReadonlySet<string>): string {\n const prose = (text: string) =>\n text\n .replace(WRITE_CLAUSE, \"\")\n .split(/(?<=[.!?])\\s+/)\n .map((sentence) => withOfferedVerbs(sentence, children, unoffered))\n .filter(\n (sentence) => sentence !== \"\" && !WRITE_TALK.test(sentence.trim()) && !opensOnUnoffered(sentence, unoffered),\n )\n .join(\" \");\n const lines = paragraph.split(\"\\n\");\n // Examples, tables and headings are kept line by line, and a line of prose among them sentence by sentence.\n if (lines.some((line) => /^\\s/.test(line) || STANDALONE_LINE.test(line) || /:\\s*$/.test(line))) {\n return dropping(lines, (line) => {\n if (isWriteLine(line, unoffered)) return null;\n if (indentOf(line) > 0 || STANDALONE_LINE.test(line) || !/[.!?]\\s*$/.test(line)) return line;\n const kept = prose(line);\n return kept === \"\" ? null : kept;\n }).join(\"\\n\");\n }\n return prose(lines.join(\" \"));\n}\n\n/** \"Subcommands: list (default), remove, clear.\" names only the ones the reader may run. */\nfunction withOfferedSubcommands(text: string, path: string[], offered: Offers): string {\n return text.replace(/Subcommands: ([^.]*)\\./g, (_whole, list: string) => {\n const kept = list.split(/,\\s*/).filter((item) => offered([...path, item.split(/\\s/)[0] ?? \"\"].join(\" \")));\n return kept.length > 0 ? `Subcommands: ${kept.join(\", \")}.` : \"\";\n });\n}\n\n/** Drops a heading whose block below it was emptied, and the blank lines left behind. */\nfunction tidy(text: string): string {\n const lines = text.split(\"\\n\");\n const kept = lines.filter((line, index) => {\n if (!/:\\s*$/.test(line)) return true;\n const next = lines.slice(index + 1).find((later) => later.trim() !== \"\");\n return next !== undefined && /^\\s/.test(next) && lines[index + 1]?.trim() !== \"\";\n });\n return kept\n .join(\"\\n\")\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .replace(/^(?:[ \\t]*\\n)+/, \"\")\n .trimEnd();\n}\n\nexport function describedFor(\n root: HelpNode,\n description: string,\n path: string[],\n node: HelpNode,\n profile: AgentProfile,\n offered: Offers,\n refusedFlags: readonly string[] = [],\n): string {\n const cited = withoutUnoffered(root, description, offered, refusedFlags);\n if (profile === \"company\" || !holdsUnoffered(node, path, offered)) return tidy(cited);\n const children = new Set(subCommandNames(node));\n const unoffered = new Set([...children].filter((name) => !offered([...path, name].join(\" \"))));\n const shaped = cited\n .split(/\\n\\s*\\n/)\n .map((paragraph) => withoutWriteTalk(withOfferedSubcommands(paragraph, path, offered), children, unoffered))\n .join(\"\\n\\n\");\n const text = tidy(shaped);\n if (text !== \"\") return text;\n const reads = loadedSubCommands(node).flatMap(([name]) => (offered([...path, name].join(\" \")) ? [name] : []));\n return reads.length > 0 ? `Read: ${reads.join(\", \")}.` : \"\";\n}\n","import { type LoadableCommand, loadAllCommands, loadSubCommandNamed } from \"./command-loading.ts\";\nimport { optionalWorkspaceKind } from \"./env.ts\";\nimport { describedFor, withoutUnoffered } from \"./profile-help.ts\";\n\n/**\n * Which commands this CLI offers the agent running it.\n *\n * One CLI serves two agents. A company's agent works inside its own workspace\n * and changes it; it is offered everything, except the organization family,\n * which is for reading other companies and means nothing to it. The\n * organization workspace's agent reads every company of its organization and\n * changes none of them: it is offered the reads alone, plus the research and\n * judgment it runs as itself, and its own Scheduled agents.\n *\n * This is what the agent is shown, not what it is allowed: the backend refuses\n * a write naming a company whatever the CLI does (`readNamedCompany`). Kept as\n * an explicit list so a new command is hidden from the organization until\n * someone decides it only reads.\n */\n\nexport type AgentProfile = \"company\" | \"organization\";\n\n/** Set on the organization workspace's Runtime (`runtimeSession/nodeActions.ts`). */\nexport function agentProfile(workspaceKind: string | undefined = optionalWorkspaceKind()): AgentProfile {\n return workspaceKind === \"organization\" ? \"organization\" : \"company\";\n}\n\n/** Families only the organization workspace runs: hidden from a company's agent. */\nconst ORGANIZATION_ONLY = [\"organization\"];\n\n/**\n * Every command the organization workspace's agent is offered, as typed. An\n * entry offers that command and everything under it.\n */\nexport const ORGANIZATION_COMMANDS: readonly string[] = [\n \"schema\",\n \"capabilities\",\n \"organization\",\n // What a company did and has.\n \"chats\",\n \"history\",\n \"actions list\",\n \"actions log\",\n \"actions get\",\n \"actions status\",\n \"actions draft list\",\n \"actions tags list\",\n // The organization's own Scheduled agents, which live in this workspace:\n // staged like a company's, applied at Publish. Naming a company is still a\n // read only (`readNamedCompany`), so none of these reaches one.\n \"scheduled-agents\",\n \"experiment status\",\n \"experiment history\",\n \"flows list\",\n \"flows show\",\n \"flows schema\",\n \"testimonials get\",\n \"testimonials search\",\n \"testimonials list\",\n \"testimonials tags list\",\n \"testimonials sources list\",\n \"images get\",\n \"images search\",\n \"images library\",\n \"images tags list\",\n \"videos get\",\n \"videos search\",\n \"videos tags list\",\n \"studio get\",\n \"studio list\",\n \"avatars list\",\n \"avatars get\",\n \"creatives performance\",\n \"creatives feedback read\",\n \"landing export status\",\n \"landing export list\",\n \"site show\",\n \"site domain list\",\n \"credentials list\",\n \"setup-links list\",\n \"media-sources list\",\n \"mcp connected\",\n \"mcp catalog\",\n \"mcp list\",\n // Ads, every platform: accounts, structure, results, staged drafts.\n \"ads google accounts\",\n \"ads google currency\",\n \"ads google url-options\",\n \"ads google changes\",\n \"ads google invoices\",\n \"ads google identity-verification\",\n \"ads google previews\",\n \"ads google brands\",\n \"ads google query\",\n \"ads google keywords discover\",\n \"ads google keywords metrics\",\n \"ads google keywords forecast\",\n \"ads google keywords themes\",\n \"ads google keywords locations\",\n \"ads google keywords languages\",\n \"ads google keywords list\",\n \"ads google budgets list\",\n \"ads google campaigns list\",\n \"ads google ad-groups list\",\n \"ads google negative-keywords list\",\n \"ads google keyword-lists list\",\n \"ads google ads list\",\n \"ads google assets list\",\n \"ads google asset-groups list\",\n \"ads google audiences list\",\n \"ads google audiences targeting\",\n \"ads google conversions list\",\n \"ads google bidding-strategies list\",\n \"ads google labels list\",\n \"ads google campaign-criteria list\",\n \"ads google ad-group-criteria list\",\n \"ads google ad-group-bid-modifiers list\",\n \"ads google account-exclusions list\",\n \"ads google merchant-center list\",\n \"ads google draft list\",\n \"ads google draft show\",\n \"ads meta accounts\",\n \"ads meta account\",\n \"ads meta businesses\",\n \"ads meta pages\",\n \"ads meta lead-forms list\",\n \"ads meta leads\",\n \"ads meta campaigns list\",\n \"ads meta adsets list\",\n \"ads meta ads list\",\n \"ads meta creatives list\",\n \"ads meta audiences list\",\n \"ads meta custom-conversions list\",\n \"ads meta pixels\",\n \"ads meta activities\",\n \"ads meta insights\",\n \"ads meta draft list\",\n \"ads meta draft show\",\n \"ads linkedin accounts\",\n \"ads linkedin account detail\",\n \"ads linkedin campaign-groups list\",\n \"ads linkedin campaigns list\",\n \"ads linkedin creatives list\",\n \"ads linkedin draft list\",\n \"ads linkedin draft show\",\n \"ads linkedin analytics\",\n \"ads linkedin demographics\",\n \"ads linkedin companies\",\n \"ads linkedin top-companies\",\n \"ads linkedin resolve\",\n \"ads linkedin facets list\",\n \"ads linkedin facets values\",\n \"ads linkedin audience-size\",\n \"ads linkedin bid-pricing\",\n \"ads linkedin forecast\",\n \"ads linkedin leads\",\n \"ads linkedin conversions list\",\n \"ads linkedin conversions health\",\n \"ads linkedin conversation\",\n \"ads linkedin audit\",\n \"ads linkedin url-params\",\n \"ads x accounts\",\n \"ads x funding\",\n \"ads x campaigns list\",\n \"ads x line-items list\",\n \"ads x promoted-tweets list\",\n \"ads x tweets\",\n \"ads x cards\",\n \"ads x draft list\",\n \"ads x draft show\",\n \"ads x media\",\n \"ads x audiences\",\n \"ads x targeting-criteria list\",\n \"ads x targeting-constants\",\n \"ads x active-entities\",\n \"ads x stats job-status\",\n \"ads chatgpt account show\",\n \"ads chatgpt campaigns list\",\n \"ads chatgpt ad-groups list\",\n \"ads chatgpt ads list\",\n \"ads chatgpt conversions list\",\n \"ads chatgpt conversions events\",\n \"ads chatgpt conversions report\",\n \"ads chatgpt audiences list\",\n \"ads chatgpt catalogs list\",\n \"ads chatgpt catalogs uploads\",\n \"ads chatgpt catalogs products\",\n \"ads chatgpt history\",\n \"ads chatgpt insights\",\n \"ads chatgpt locations\",\n \"ads chatgpt draft list\",\n \"ads chatgpt draft show\",\n // Pages and measurement.\n \"analytics overview\",\n \"analytics traffic\",\n \"analytics funnel\",\n \"analytics flow\",\n \"analytics page\",\n \"analytics triggers\",\n \"analytics releases\",\n \"analytics paid\",\n \"analytics delivery\",\n \"analytics submissions\",\n \"analytics geo\",\n \"analytics bots\",\n \"analytics landings\",\n \"analytics tags\",\n \"analytics events\",\n \"analytics feed\",\n \"analytics lookup\",\n \"analytics devices\",\n \"analytics ads\",\n \"analytics conversions\",\n \"analytics sends\",\n \"analytics tracking\",\n \"analytics arrivals\",\n \"analytics sending-events\",\n \"analytics sources\",\n \"analytics website-tag\",\n \"analytics sites\",\n \"analytics questionnaire\",\n \"analytics presets\",\n \"funnel\",\n \"ga4 properties\",\n \"ga4 config\",\n \"ga4 audit\",\n \"ga4 query\",\n \"ga4 draft list\",\n \"ga4 draft show\",\n \"gsc\",\n \"tags list\",\n \"tags draft\",\n \"tag-manager containers\",\n \"tag-manager read\",\n \"tag-manager draft list\",\n \"tag-manager draft show\",\n // CRM and accounts.\n \"hubspot\",\n \"accounts influenced\",\n \"accounts engagement\",\n \"accounts warm\",\n \"accounts company\",\n \"accounts campaigns\",\n \"accounts crm status\",\n \"accounts crm check\",\n \"accounts crm contract\",\n // Research and judgment, run as the workspace itself (never with --company).\n // Not `research customers`, which writes into a company's Knowledge, nor\n // `winning-ads fit`, which judges an ad against a company's own COMPANY.md.\n \"research web\",\n \"research fetch\",\n \"research google-ads\",\n \"research reddit\",\n \"research advertisers\",\n \"research autocomplete\",\n \"research countries\",\n \"research intent\",\n \"research keyword-metrics\",\n \"research keywords-for-site\",\n \"research keyword-gap\",\n \"research languages\",\n \"research lighthouse\",\n \"research relevant-pages\",\n \"decide\",\n \"winning-ads search\",\n \"winning-ads advertisers\",\n \"winning-ads following\",\n \"winning-ads feed\",\n \"winning-ads winners\",\n \"winning-ads ads\",\n \"winning-ads profile\",\n \"winning-ads launches\",\n \"winning-ads landings\",\n \"winning-ads search-copy\",\n \"winning-ads content\",\n \"winning-ads hooks\",\n \"winning-ads mechanisms\",\n \"winning-ads formats\",\n];\n\nfunction covers(entry: string, path: string): boolean {\n return path === entry || path.startsWith(`${entry} `);\n}\n\n/**\n * Whether `path` (a command as typed, `\"ads meta campaigns list\"`) is offered\n * to `profile`. A group is offered when anything under it is, so the way to an\n * offered command stays open.\n */\nexport function offers(profile: AgentProfile, path: string): boolean {\n if (path === \"\") return true;\n if (profile === \"company\") {\n return !ORGANIZATION_ONLY.some((family) => covers(family, path));\n }\n return ORGANIZATION_COMMANDS.some((entry) => covers(entry, path) || covers(path, entry));\n}\n\n/**\n * The flags that change something, on commands the organization is offered to\n * read. `funnel` reads the funnel and `funnel --add-trigger` changes it, so the\n * command is offered and these are refused, and left out of its help.\n */\nexport const ORGANIZATION_WRITE_FLAGS: Readonly<Record<string, readonly string[]>> = {\n funnel: [\"steps\", \"step\", \"add-trigger\", \"remove-trigger\", \"event\", \"remove-step\", \"preset\"],\n \"analytics conversions\": [\"event\", \"name\", \"rename\", \"to\", \"remove-name\", \"count-mode\", \"remove\"],\n \"analytics sends\": [\n \"set\",\n \"source-event\",\n \"from\",\n \"platform\",\n \"tag\",\n \"event\",\n \"account\",\n \"parameter\",\n \"id\",\n \"remove\",\n ],\n \"analytics sources\": [\n \"server\",\n \"create\",\n \"create-hubspot\",\n \"create-activecampaign\",\n \"events\",\n \"account\",\n \"set-trigger\",\n \"set-amount\",\n \"amount-property\",\n \"currency\",\n \"write\",\n \"name\",\n \"map\",\n \"field\",\n \"pause\",\n \"resume\",\n \"remove\",\n ],\n \"analytics sites\": [\"add\", \"remove\"],\n};\n\nfunction kebabCase(name: string): string {\n return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/** The first flag in `argv` the organization is refused on the command at `path`, if any. */\nfunction refusedFlagIn(path: string, argv: readonly string[]): string | null {\n const refused = ORGANIZATION_WRITE_FLAGS[path];\n if (!refused) return null;\n const end = argv.indexOf(\"--\");\n for (const token of end === -1 ? argv : argv.slice(0, end)) {\n if (!token.startsWith(\"--\")) continue;\n const name = kebabCase(token.slice(2).split(\"=\")[0] ?? \"\").replace(/^no-/, \"\");\n if (refused.includes(name)) return name;\n }\n return null;\n}\n\ntype ProfiledCommand = { meta?: unknown; subCommands?: unknown };\n\n/** What the organization's agent is told when it reaches for a command it is not offered. */\nexport const ORGANIZATION_REFUSAL =\n \"The organization workspace only reads its companies, and this command changes something. A change to a company is made in that company's own chat; here, read it and show it in a Report.\";\n\nfunction hide(command: ProfiledCommand): void {\n if (typeof command.meta === \"object\" && command.meta !== null) {\n (command.meta as { hidden?: boolean }).hidden = true;\n }\n}\n\n/**\n * Rewrites, in place, what each loaded command `profile` is shown says\n * (`profile-help.ts`), and takes off it the flags `profile` is refused. Args are\n * replaced rather than edited: one definition can be shared between commands.\n */\nfunction describeOffered(root: ProfiledCommand, command: ProfiledCommand, profile: AgentProfile, path: string[]): void {\n const meta = command.meta as { hidden?: boolean; description?: unknown } | undefined;\n if (meta?.hidden === true) return;\n const offered = (cited: string) => offers(profile, cited);\n const refusedFlags = profile === \"organization\" ? (ORGANIZATION_WRITE_FLAGS[path.join(\" \")] ?? []) : [];\n if (typeof meta?.description === \"string\") {\n meta.description = describedFor(root, meta.description, path, command, profile, offered, refusedFlags);\n }\n const shaped = command as { args?: unknown };\n if (typeof shaped.args === \"object\" && shaped.args !== null) {\n shaped.args = Object.fromEntries(\n Object.entries(shaped.args as Record<string, unknown>).flatMap(([name, arg]) => {\n if (refusedFlags.includes(kebabCase(name))) return [];\n const description = (arg as { description?: unknown } | null)?.description;\n return [\n [\n name,\n typeof description === \"string\"\n ? { ...(arg as object), description: withoutUnoffered(root, description, offered, refusedFlags) }\n : arg,\n ],\n ];\n }),\n );\n }\n const subCommands = command.subCommands;\n if (typeof subCommands !== \"object\" || subCommands === null) return;\n for (const [name, sub] of Object.entries(subCommands as Record<string, unknown>)) {\n if (typeof sub === \"object\" && sub !== null)\n describeOffered(root, sub as ProfiledCommand, profile, [...path, name]);\n }\n}\n\n/** Marks, in place, every loaded command `profile` is not offered as hidden from help. */\nfunction hideUnoffered(command: ProfiledCommand, profile: AgentProfile, path: string[]): void {\n const subCommands = command.subCommands;\n if (typeof subCommands !== \"object\" || subCommands === null) return;\n for (const [name, sub] of Object.entries(subCommands as Record<string, unknown>)) {\n if (typeof sub !== \"object\" || sub === null) continue;\n const subPath = [...path, name];\n if (!offers(profile, subPath.join(\" \"))) hide(sub as ProfiledCommand);\n hideUnoffered(sub as ProfiledCommand, profile, subPath);\n }\n}\n\ntype ArgDefinition = { type?: unknown; alias?: unknown };\n\nfunction camelCase(name: string): string {\n return name.replace(/-([a-z0-9])/g, (_, letter: string) => letter.toUpperCase());\n}\n\nfunction aliases(of: unknown): unknown[] {\n return Array.isArray(of) ? of : of === undefined ? [] : [of];\n}\n\n/** Whether `flag` takes the token after it as its value on `command`, as citty reads it. */\nfunction takesValue(command: ProfiledCommand & { args?: unknown }, flag: string): boolean {\n if (flag.includes(\"=\") || typeof command.args !== \"object\" || command.args === null) return false;\n const name = flag.replace(/^-{1,2}/, \"\");\n return Object.entries(command.args as Record<string, ArgDefinition>).some(\n ([key, definition]) =>\n (definition.type === \"string\" || definition.type === \"enum\") &&\n (camelCase(key) === camelCase(name) || aliases(definition.alias).includes(name)),\n );\n}\n\n/**\n * The command `argv` addresses, found the way citty finds it: flags, and the\n * value after one that takes it, are skipped, so a flag before a command's name\n * cannot leave the path at its group. Each step is loaded on the way —\n * `loadCommands` stops at the first flag, and `--company` is taken off only\n * after it ran, so the guard cannot lean on what it loaded.\n */\nasync function addressedCommand(\n root: ProfiledCommand,\n argv: readonly string[],\n): Promise<{ path: string; command: ProfiledCommand }> {\n const path: string[] = [];\n let command: ProfiledCommand = root;\n for (let index = 0; index < argv.length; index++) {\n const token = argv[index] ?? \"\";\n if (token === \"--\") break;\n if (token.startsWith(\"-\")) {\n if (takesValue(command, token)) index++;\n continue;\n }\n const next = await loadSubCommandNamed(command as LoadableCommand, token);\n if (!next) break;\n path.push(next[0]);\n command = next[1] as ProfiledCommand;\n }\n return { path: path.join(\" \"), command };\n}\n\n/**\n * Shapes the loaded command tree for the agent running it: what it is not\n * offered leaves its help, and the organization's agent is refused a command it\n * is not offered (the returned message; `null` when it may run). A company's\n * agent is never refused: the organization's commands are only out of its help,\n * because a Report published from the organization workspace runs them on a\n * runner that has no profile of its own.\n */\nexport async function applyAgentProfile(\n root: ProfiledCommand,\n profile: AgentProfile,\n argv: readonly string[],\n): Promise<string | null> {\n const { path, command } = await addressedCommand(root, argv);\n // A walk that ends on a group prints its usage — `--help` anywhere, past `--`\n // too, or no command or an unknown one — listing its subcommands, which are\n // hidden only once loaded. A walk that reaches a command loads nothing more.\n await loadAllCommands(command as LoadableCommand);\n // Judged before the help is shaped, which takes the refused flags off the command.\n const refused = profile === \"organization\" && (!offers(profile, path) || refusedFlagIn(path, argv) !== null);\n hideUnoffered(root, profile, []);\n describeOffered(root, root, profile, []);\n return refused ? ORGANIZATION_REFUSAL : null;\n}\n"],"mappings":";;;;;AASO,SAAS,eAAe,MAAyB,UAA+C;AACrG,QAAM,QAAQ,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM,WAAW,GAAG,CAAC;AAEzD,MAAI,UAAU,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A,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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AK,KAAK;AAC7B,QAAI,UAAU,KAAM;AACpB,QAAI,MAAM,WAAW,GAAG,GAAG;AACzB,UAAI,WAAW,SAAS,KAAK,EAAG;AAChC;AAAA,IACF;AACA,UAAM,OAAO,MAAM,oBAAoB,SAA4B,KAAK;AACxE,QAAI,CAAC,KAAM;AACX,SAAK,KAAK,KAAK,CAAC,CAAC;AACjB,cAAU,KAAK,CAAC;AAAA,EAClB;AACA,SAAO,EAAE,MAAM,KAAK,KAAK,GAAG,GAAG,QAAQ;AACzC;AAUA,eAAsB,kBACpB,MACA,SACA,MACwB;AACxB,QAAM,EAAE,MAAM,QAAQ,IAAI,MAAM,iBAAiB,MAAM,IAAI;AAI3D,QAAM,gBAAgB,OAA0B;AAEhD,QAAM,UAAU,YAAY,mBAAmB,CAAC,OAAO,SAAS,IAAI,KAAK,cAAc,MAAM,IAAI,MAAM;AACvG,gBAAc,MAAM,SAAS,CAAC,CAAC;AAC/B,kBAAgB,MAAM,MAAM,SAAS,CAAC,CAAC;AACvC,SAAO,UAAU,uBAAuB;AAC1C;","names":["aliases","at"]}
|
package/dist/mcp-T6SAG4XB.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../api/src/mcp-catalog.ts","../src/commands/mcp/index.ts","../src/commands/mcp/catalog.ts","../src/commands/mcp/platforms.ts"],"sourcesContent":["/**\n * Contract for `GET /api/mcp/catalog` — searching the managed-app catalog the\n * sandbox agent can ask the user to connect when a vendor publishes no MCP\n * server of its own.\n *\n * `connect` mirrors `ToolkitConnectMode` in `convex/composio/types.ts`, folded\n * to what the user will be asked for: a sign-in or a key. Apps that need no\n * sign-in are left out — Composio refuses to connect them.\n */\nimport { z } from \"zod\";\n\nexport const MCP_CATALOG_DEFAULT_LIMIT = 8;\nexport const MCP_CATALOG_DESCRIPTION_MAX = 160;\n\nexport const mcpCatalogRequestSchema = z.object({\n search: z.string().trim().min(1, \"Provide --search\").max(100),\n limit: z.coerce.number().int().min(1).max(20).default(MCP_CATALOG_DEFAULT_LIMIT),\n});\nexport type McpCatalogRequest = z.infer<typeof mcpCatalogRequestSchema>;\n\nexport const mcpCatalogConnectSchema = z.enum([\"sign-in\", \"key\"]);\nexport type McpCatalogConnect = z.infer<typeof mcpCatalogConnectSchema>;\n\nexport const mcpCatalogEntrySchema = z.object({\n /** The toolkit slug — what request_connection `{ app }` takes. */\n app: z.string(),\n name: z.string(),\n description: z.string().max(MCP_CATALOG_DESCRIPTION_MAX),\n connect: mcpCatalogConnectSchema,\n connected: z.boolean(),\n});\nexport type McpCatalogEntry = z.infer<typeof mcpCatalogEntrySchema>;\n\nexport const mcpCatalogResponseSchema = z.object({\n apps: z.array(mcpCatalogEntrySchema),\n /** Baker's own connections this search matched — ask for these with `{ platform }`, never a managed copy. */\n platforms: z.array(z.string()).optional(),\n});\nexport type McpCatalogResponse = z.infer<typeof mcpCatalogResponseSchema>;\n","import {\n type CustomMcpDisableResponse,\n type CustomMcpVerifyResponse,\n customMcpServerNameRequestSchema,\n} from \"@baker/api\";\nimport { type McpCatalogResponse, mcpCatalogRequestSchema } from \"@baker/api/mcp-catalog\";\nimport { defineCommand } from \"citty\";\nimport { ApiError, apiGet, apiPost } from \"../../client.ts\";\nimport { getEnv } from \"../../env.ts\";\nimport { repeatedValues } from \"../../lib/repeatedFlags.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { catalogHints } from \"./catalog.ts\";\nimport { type ConnectedPlatform, platformEntry } from \"./platforms.ts\";\n\nconst SCOPES = [\"user\", \"user_org\", \"company\", \"org\"] as const;\ntype Scope = (typeof SCOPES)[number];\n\nfunction parseScope(raw: unknown): Scope {\n const scope = raw === undefined ? \"company\" : String(raw);\n if (!(SCOPES as readonly string[]).includes(scope)) {\n throw new ApiError(\"VALIDATION_ERROR\", `Invalid --scope \"${scope}\". Use user | user_org | company | org.`);\n }\n return scope as Scope;\n}\n\n/** The turn's message sender, injected by the bridge — required only for user scope. */\nfunction actingUserId(): string | undefined {\n return getEnv().BAKER_ACTING_USER_ID;\n}\n\ntype CustomMcpServer = {\n _id: string;\n scope: \"user\" | \"user_org\" | \"company\" | \"org\";\n name: string;\n url: string;\n headerKeys: string[];\n enabled: boolean;\n /** Absent until the address has been checked; `ok: false` means it serves no tools. */\n health?: { ok: boolean; message?: string; suggestedUrl?: string; transient?: boolean; checkedAt: number };\n createdAt: number;\n};\n\n/**\n * What to report for one custom server. `problem` is the whole point: a server can\n * be signed in, enabled and still serve nothing (wrong address), and reporting it\n * as plain \"connected\" is how an agent ends up promising tools it does not have.\n * A `transient` failure is reported separately — the tool may well answer, so\n * declaring it broken would be its own kind of lie.\n */\nfunction customEntry(server: CustomMcpServer): Record<string, unknown> {\n const failed = server.health && !server.health.ok;\n const problem = server.health?.message ?? \"This server's address is not serving tools.\";\n return {\n name: server.name,\n scope: server.scope,\n enabled: server.enabled,\n ...(failed && !server.health?.transient ? { usable: false, problem } : {}),\n ...(failed && server.health?.transient ? { lastCheck: \"failed\", problem } : {}),\n ...(failed && server.health?.suggestedUrl ? { suggestedAddress: server.health.suggestedUrl } : {}),\n };\n}\n\n/** The hint an unusable server earns — the agent must not offer its tools or invent a reason. */\nconst BROKEN_SERVER_HINT =\n \"A server marked usable=false will NOT answer: its tools are absent from this turn. Say plainly that the tool is not working and relay `problem`; never claim its tools are loading, coming next message, or temporarily unavailable. `problem` names what a person has to fix — the address, the sign-in, or the key the server was added with — so pass on that fix and no other: never tell the user to reconnect a server whose `problem` is its address or its key. The user makes the fix in the dashboard (Brain → Integrations → More apps). If `suggestedAddress` is present, that is the address to use.\";\n\n/** The hint for a server whose last check failed for a reason that may already have passed. */\nconst LAST_CHECK_FAILED_HINT =\n \"A server with lastCheck=failed was unreachable or erroring when it was last checked — that may already have passed, and its tools ARE loaded this turn. Try the tool; if it works, say nothing about the check. If it fails, report `problem` as what happened rather than guessing.\";\n\n/** Turn repeated `--header \"K: V\"` (or `K=V`) flags into a headers record. */\n/** `--header` is repeatable, so its values come off the command line — citty keeps only the last. */\nfunction parseHeaders(raw: unknown, rawArgs?: readonly string[]): Record<string, string> | undefined {\n const list = repeatedValues(rawArgs, \"header\", raw);\n const headers: Record<string, string> = {};\n for (const entry of list) {\n const text = String(entry);\n const sep = text.indexOf(\":\") >= 0 && (text.indexOf(\":\") < text.indexOf(\"=\") || text.indexOf(\"=\") < 0) ? \":\" : \"=\";\n const at = text.indexOf(sep);\n if (at <= 0) {\n throw new ApiError(\"VALIDATION_ERROR\", `Invalid header \"${text}\". Use \"Key: Value\".`);\n }\n headers[text.slice(0, at).trim()] = text.slice(at + 1).trim();\n }\n return Object.keys(headers).length > 0 ? headers : undefined;\n}\n\nfunction fail(err: unknown): never {\n if (err instanceof ApiError) {\n writeJson({ ok: false, error: { code: err.code, message: err.message } });\n process.exit(1);\n }\n writeJson({ ok: false, error: { code: \"NETWORK_ERROR\", message: \"Unexpected error\" } });\n process.exit(1);\n}\n\ntype ManagedConnection = {\n toolkitSlug: string;\n scope: \"user\" | \"user_org\" | \"company\" | \"org\";\n status: string;\n accountLabel: string | null;\n readOnly: boolean;\n};\n\ntype ConnectedResponse = {\n managed: ManagedConnection[];\n custom: CustomMcpServer[];\n platforms: ConnectedPlatform[];\n};\n\n/** The one thing an agent must not do with this list: infer a platform's state from the MCP half. */\nconst PLATFORMS_HINT =\n \"`platforms` are connected accounts you reach through `baker` commands (HubSpot, Google Ads, GA4, Search Console, Tag Manager, …), NOT mcp__* tools — there is no tool to call for them. A platform listed here IS connected: never tell the user to connect it, and never conclude it is missing because it has no mcp__* entry. Read what it holds with its own command family (`baker hubspot …`, `baker ads google …`, `baker ga4 …`, and so on).\";\n\nregisterSchema({\n command: \"mcp.connected\",\n description:\n \"List everything this chat can reach: managed integrations (Attio, Slack, Gmail, Google Sheets, …), custom MCP servers, and the platforms the company signed in to (HubSpot, Google Ads, GA4, Search Console, Tag Manager) which you read through their own `baker` commands. Start here when the user mentions an external tool or platform.\",\n args: {},\n});\n\nconst connectedCommand = defineCommand({\n meta: {\n name: \"connected\",\n description: `Everything this chat can reach — managed integrations, custom MCP servers, and connected platforms.\n\nManaged tools ride the composio servers (mcp__composio_<scope>__*); custom servers expose mcp__<name>__*.\nPlatforms (HubSpot, Google Ads, GA4, …) have no mcp__* tools at all — you read them with their own\n\\`baker\\` command family, and one listed here is connected and ready to use.\nA tool or platform the user names that is NOT listed anywhere here is simply not connected yet.`,\n },\n run: async () => {\n try {\n const user = actingUserId();\n const data = await apiGet<ConnectedResponse>(\"/api/mcp/connected\", user ? { actingUserId: user } : undefined);\n const managed = data.managed.map((c) => ({\n toolkit: c.toolkitSlug,\n scope: c.scope,\n ...(c.status !== \"ACTIVE\" ? { status: c.status } : {}),\n ...(c.accountLabel ? { account: c.accountLabel } : {}),\n ...(c.readOnly ? { readOnly: true } : {}),\n }));\n const custom = data.custom.map(customEntry);\n const platforms = (data.platforms ?? []).map(platformEntry);\n const hints: string[] = [];\n if (platforms.length > 0) {\n hints.push(PLATFORMS_HINT);\n }\n if (data.custom.some((s) => s.health && !s.health.ok && !s.health.transient)) {\n hints.push(BROKEN_SERVER_HINT);\n }\n if (data.custom.some((s) => s.health && !s.health.ok && s.health.transient)) {\n hints.push(LAST_CHECK_FAILED_HINT);\n }\n if ([...data.managed, ...data.custom].some((e) => e.scope === \"user\" || e.scope === \"user_org\")) {\n hints.push(\n \"user/user_org entries are personal: they belong to the current message sender and load only in their turns — other users in this chat won't have them.\",\n );\n }\n hints.push(\n \"Not listed anywhere = not connected — connect it from the chat with request_connection, never by sending the user to the dashboard: a Baker platform (HubSpot, Google Ads, GA4, …) → { platform }; anything else → the vendor's own MCP server FIRST: use the address the user gave you, or WebSearch '<vendor> MCP server' and WebFetch its official docs for the remote https address and how it signs in, then { server: { name, url, auth, keyHeader } }; only when the vendor has none → `baker mcp catalog --search <name>`, then { app }. Research before you ask the user anything. What they connect loads into this same turn.\",\n );\n writeJson({\n ok: true,\n data: { managed, custom, platforms },\n hints,\n });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nconst catalogArgs = {\n search: { type: \"string\", description: \"App or vendor name, e.g. notion, clarity, pipedrive\", required: true },\n limit: { type: \"string\", description: \"Max apps to return, 1-20 (default 8)\", required: false },\n} as const;\n\nregisterSchema({\n command: \"mcp.catalog\",\n description:\n \"Search the managed apps you can ask the user to connect when a vendor has no MCP server of its own. Each app says how the user connects it (sign-in | key) and whether this chat already reaches it. Example: baker mcp catalog --search notion\",\n args: catalogArgs,\n});\n\nconst catalogCommand = defineCommand({\n meta: {\n name: \"catalog\",\n description: `Managed apps you can ask the user to connect when a vendor has no MCP server of its own.\n\nFor a tool \\`baker mcp connected\\` does not list whose vendor has no official remote MCP server:\n baker mcp catalog --search notion\n baker mcp catalog --search \"microsoft clarity\" --limit 3\n\nEach app: app (slug for request_connection), name, description, connect (sign-in | key), connected.\nPrefer the vendor's own MCP server when it publishes one; a catalog app is the fallback.`,\n },\n args: catalogArgs,\n run: async ({ args }) => {\n const parsed = mcpCatalogRequestSchema.safeParse({ search: args.search, limit: args.limit });\n if (!parsed.success) {\n writeJson({\n ok: false,\n error: { code: \"VALIDATION_ERROR\", message: parsed.error.issues[0]?.message ?? \"Invalid arguments\" },\n });\n process.exit(1);\n }\n try {\n const user = actingUserId();\n const data = await apiGet<McpCatalogResponse>(\"/api/mcp/catalog\", {\n search: parsed.data.search,\n limit: String(parsed.data.limit),\n ...(user ? { actingUserId: user } : {}),\n });\n writeJson({\n ok: true,\n data: {\n apps: data.apps,\n ...(data.platforms?.length ? { platforms: data.platforms } : {}),\n },\n hints: catalogHints(data.apps, { platforms: data.platforms ?? [] }),\n });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nregisterSchema({\n command: \"mcp.list\",\n description: \"List the custom MCP servers this company's chats see (org + company + your own user scope).\",\n args: {},\n});\n\nconst listCommand = defineCommand({\n meta: { name: \"list\", description: \"List custom MCP servers visible to this company's chats.\" },\n run: async () => {\n try {\n const user = actingUserId();\n const data = await apiGet<{ servers: CustomMcpServer[] }>(\n \"/api/mcp/custom\",\n user ? { actingUserId: user } : undefined,\n );\n writeJson({\n ok: true,\n // Detail view: the full row (address included) plus the usability verdict.\n // `health` itself is folded into `usable`/`problem` by `customEntry`.\n data: data.servers.map((server) => ({ ...server, health: undefined, ...customEntry(server) })),\n ...(data.servers.some((s) => s.health && !s.health.ok)\n ? {\n hints: data.servers.some((s) => s.health && !s.health.ok && !s.health.transient)\n ? [BROKEN_SERVER_HINT]\n : [LAST_CHECK_FAILED_HINT],\n }\n : {}),\n });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nregisterSchema({\n command: \"mcp.add\",\n description:\n \"Register a custom MCP server. Tools appear as mcp__<name>__* on the next message. URL must be HTTPS. Scope: company (default, all chats) | org (org admin key) | user (only the current sender).\",\n args: {\n name: { type: \"string\", description: \"Server name → tools appear as mcp__<name>__*\", required: true },\n url: {\n type: \"string\",\n description: \"Full HTTPS MCP endpoint (commonly ends in /mcp, not just the domain)\",\n required: true,\n },\n scope: { type: \"string\", description: \"user | user_org | company | org (default company)\", required: false },\n header: { type: \"string\", description: 'Auth header \"Key: Value\" (repeatable)', required: false },\n },\n});\n\nconst addCommand = defineCommand({\n meta: {\n name: \"add\",\n description: `Register a custom MCP server. Tools appear as mcp__<name>__* on the NEXT message.\nFor a server the USER asks for, use request_connection { server } instead: they confirm who can use it,\ntype any key into the card (never the chat), and its tools load in this same turn.\n\nScope: company (default — every chat in the company) | org (all companies in the org; needs an admin key) | user (only the current message sender).\n\nExamples:\n baker mcp add --name weather --url https://mcp.example.com/mcp\n baker mcp add --name acme --url https://acme.dev/mcp --header \"Authorization: Bearer sk-…\"\n baker mcp add --name mine --url https://my.dev/mcp --scope user`,\n },\n args: {\n name: { type: \"string\", description: \"Server name (mcp__<name>__*)\", required: true },\n url: {\n type: \"string\",\n description: \"Full HTTPS MCP endpoint (commonly ends in /mcp, not just the domain)\",\n required: true,\n },\n scope: { type: \"string\", description: \"user | user_org | company | org (default company)\", required: false },\n header: { type: \"string\", description: 'Auth header \"Key: Value\" (repeatable)', required: false },\n },\n run: async ({ args, rawArgs }) => {\n try {\n const scope = parseScope(args.scope);\n const user = actingUserId();\n const headers = parseHeaders(args.header, rawArgs);\n const data = await apiPost<{ name: string }>(\"/api/mcp/custom\", {\n name: args.name as string,\n url: args.url as string,\n scope,\n ...(user ? { actingUserId: user } : {}),\n ...(headers ? { headers } : {}),\n });\n writeJson({\n ok: true,\n data,\n hints: [\n \"The address must be the full MCP endpoint (commonly ending in /mcp), not just the domain — a domain on its own usually answers sign-in and then serves no tools.\",\n \"The address is checked in the background. Run `baker mcp connected` on the next message to confirm it serves tools before promising the user anything.\",\n ],\n });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nregisterSchema({\n command: \"mcp.remove\",\n description: \"Remove a company custom MCP server by name.\",\n args: { name: { type: \"string\", description: \"Server name to remove\", required: true } },\n});\n\nconst removeCommand = defineCommand({\n meta: {\n name: \"remove\",\n description: `Remove a company custom MCP server by name.\n\nExample:\n baker mcp remove --name weather`,\n },\n args: { name: { type: \"string\", description: \"Server name to remove\", required: true } },\n run: async ({ args }) => {\n try {\n const user = actingUserId();\n const data = await apiPost<{ removed: boolean }>(\"/api/mcp/custom/remove\", {\n name: args.name as string,\n ...(user ? { actingUserId: user } : {}),\n });\n writeJson({ ok: true, data });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nconst serverNameArgs = {\n name: { type: \"string\", description: \"Custom server name, as `baker mcp list` shows it\", required: true },\n} as const;\n\nregisterSchema({\n command: \"mcp.verify\",\n description:\n \"Check a custom MCP server now (the dashboard's 'Check now') and store the result. Use after the user fixed its address or sign-in, or when its tools failed this turn.\",\n args: serverNameArgs,\n});\n\nconst verifyCommand = defineCommand({\n meta: {\n name: \"verify\",\n description: `Check a custom MCP server now and store the result.\n\nExample:\n baker mcp verify --name weather`,\n },\n args: serverNameArgs,\n run: async ({ args }) => {\n const parsed = customMcpServerNameRequestSchema.safeParse({ name: args.name, actingUserId: actingUserId() });\n if (!parsed.success) {\n fail(new ApiError(\"VALIDATION_ERROR\", parsed.error.issues[0]?.message ?? \"Invalid arguments\"));\n }\n try {\n const data = await apiPost<CustomMcpVerifyResponse>(\"/api/mcp/custom/verify\", parsed.data);\n writeJson({\n ok: true,\n data,\n hints: [\n data.ok\n ? \"The server answers and serves tools. Its tools load on the next message.\"\n : data.transient\n ? LAST_CHECK_FAILED_HINT\n : BROKEN_SERVER_HINT,\n ],\n });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nregisterSchema({\n command: \"mcp.disable\",\n description:\n \"Switch a custom MCP server off so its tools stop loading; its address and sign-in are kept. Turning it back on is done by a person in the dashboard, never by the agent.\",\n args: serverNameArgs,\n});\n\nconst disableCommand = defineCommand({\n meta: {\n name: \"disable\",\n description: `Switch a custom MCP server off (its tools stop loading). Only a person can turn it back on, in the dashboard.\n\nExample:\n baker mcp disable --name weather`,\n },\n args: serverNameArgs,\n run: async ({ args }) => {\n const parsed = customMcpServerNameRequestSchema.safeParse({ name: args.name, actingUserId: actingUserId() });\n if (!parsed.success) {\n fail(new ApiError(\"VALIDATION_ERROR\", parsed.error.issues[0]?.message ?? \"Invalid arguments\"));\n }\n try {\n const data = await apiPost<CustomMcpDisableResponse>(\"/api/mcp/custom/disable\", parsed.data);\n writeJson({\n ok: true,\n data,\n hints: [\n \"Its tools stop loading from the next message, and this applies right away — publishing or discarding this chat does not undo it. Tell the user they can turn it back on in Brain → Integrations → More apps.\",\n ],\n });\n } catch (err) {\n fail(err);\n }\n },\n});\n\nexport const mcpCommand = defineCommand({\n meta: {\n name: \"mcp\",\n description: `Third-party tools for this company — see what's connected, register custom HTTPS MCP endpoints.\n\nTools from a registered server appear as mcp__<name>__* on the next message.\nManaged here are **company-scoped** servers; user- and org-scoped servers are managed in the dashboard.\n\nStart here:\n baker mcp connected # everything this chat can reach: managed integrations, custom servers, connected platforms\n baker mcp catalog --search notion # managed apps you can connect when a vendor has no MCP server of its own\n\nExamples:\n baker mcp add --name weather --url https://mcp.example.com/mcp\n baker mcp add --name acme --url https://acme.dev/mcp --header \"Authorization: Bearer sk-…\"\n baker mcp remove --name weather\n baker mcp verify --name weather # check it now after the user fixed it\n baker mcp disable --name weather # stop its tools loading (only a person turns it back on)\nFull guide: __tooling__/docs/tools/baker/mcp.md`,\n },\n subCommands: {\n connected: connectedCommand,\n catalog: catalogCommand,\n list: listCommand,\n add: addCommand,\n remove: removeCommand,\n verify: verifyCommand,\n disable: disableCommand,\n },\n});\n","/**\n * What `baker mcp catalog` tells the agent to do next with the managed apps it\n * found — the fallback when a vendor publishes no MCP server of its own.\n */\nimport type { McpCatalogEntry } from \"@baker/api/mcp-catalog\";\n\nconst PREFER_VENDOR_HINT =\n 'The vendor\\'s own MCP server comes before any app here. If you have not yet, WebSearch \"<vendor> MCP server\" and WebFetch its official docs for the remote https address and how it signs in, then ask for it with request_connection `{ server: { name, url, auth, keyHeader } }`. Only when the vendor has none, ask for an app from this catalog with request_connection `{ app: \"<slug>\", reason }` — the user connects it in the chat and its tools load right after, in this same turn.';\n\nconst ALREADY_CONNECTED_HINT =\n \"An app marked connected is already reachable — use its mcp__composio_* tools; do not ask again.\";\n\nconst NO_MATCH_HINT =\n \"Nothing in the catalog matches. WebSearch for the vendor's official remote MCP server (its docs, its developer site) before telling the user it can't be connected — if one exists, ask for it with request_connection `{ server }`. Only when the web shows no official remote server either, say plainly this tool can't be connected yet and offer a Task.\";\n\n/** Baker's own connection always wins over a catalog app or anyone's MCP server for the same tool. */\nfunction firstPartyHint(platforms: readonly string[]): string {\n const asks = platforms.map((p) => `request_connection \\`{ platform: \"${p}\" }\\``).join(\" or \");\n return `This is one of Baker's own connections — ask for it with ${asks}. It is the one Baker's commands, staging and publish work with, so never connect it as a catalog app or as an MCP server, even one the vendor publishes or the user names. If it is already connected, read it with its own baker command family instead.`;\n}\n\n/** What the agent should do next with a catalog answer. */\nexport function catalogHints(\n apps: readonly McpCatalogEntry[],\n { platforms = [] }: { platforms?: readonly string[] } = {},\n): string[] {\n if (platforms.length > 0) {\n return [firstPartyHint(platforms)];\n }\n const hints = [PREFER_VENDOR_HINT];\n if (apps.some((a) => a.connected)) {\n hints.push(ALREADY_CONNECTED_HINT);\n }\n if (apps.length === 0) {\n hints.push(NO_MATCH_HINT);\n }\n return hints;\n}\n","/**\n * How a connected platform reads back to the agent.\n *\n * A platform (HubSpot, Google Ads, GA4, …) is an account the company signed in\n * to, reached through its own `baker` command family rather than an `mcp__*`\n * tool. It rides `mcp connected` because that is the one answer to \"what can\n * this chat reach\" — and because an agent that only saw the tool half had no\n * way to tell a working HubSpot connection from a missing one.\n */\n\nexport interface ConnectedPlatform {\n type: string;\n label: string;\n account: string | null;\n reads: string[];\n readsLabel: string | null;\n}\n\n/** \"Ad Accounts\" -> `adAccounts`, \"Properties\" -> `properties`. */\nfunction readsKey(label: string): string {\n const [first = \"\", ...rest] = label.split(\" \");\n return [first.toLowerCase(), ...rest].join(\"\");\n}\n\n/**\n * One platform as the agent sees it. The resources are keyed by the platform's\n * own word for them — `properties` for GA4, `containers` for Tag Manager,\n * `adAccounts` for the ad platforms — so what the agent reads back matches what\n * the user sees in the dashboard.\n */\nexport function platformEntry(platform: ConnectedPlatform): Record<string, unknown> {\n return {\n platform: platform.label,\n ...(platform.account ? { account: platform.account } : {}),\n ...(platform.readsLabel && platform.reads.length > 0 ? { [readsKey(platform.readsLabel)]: platform.reads } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAS,SAAS;AAEX,IAAM,4BAA4B;AAClC,IAAM,8BAA8B;AAEpC,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,kBAAkB,EAAE,IAAI,GAAG;AAAA,EAC5D,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,yBAAyB;AACjF,CAAC;AAGM,IAAM,0BAA0B,EAAE,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