@erdoai/cli 0.282.1 → 0.284.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/dist/index.js +25 -150
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/ads-container.ts
|
|
4
|
-
function advertiserVerificationAction(container) {
|
|
5
|
-
const verification = container.advertiser_verification;
|
|
6
|
-
if (!verification || verification.action_url) return void 0;
|
|
7
|
-
if (verification.status === "check_in_google_ads") {
|
|
8
|
-
return `Google cannot expose advertiser verification for card-billed account ${container.customer_id} through the API. Open Admin \u2192 Policy \u2192 Account in Google Ads to check its status, and complete verification there only if Google shows it is pending.`;
|
|
9
|
-
}
|
|
10
|
-
if (verification.status === "PENDING_USER_ACTION" || verification.status === "FAILURE") {
|
|
11
|
-
return `Google shows no business name or logo on ${container.customer_id}'s ads until the advertiser is verified. Get a link with: erdo org managed ads-container ${container.org_slug} --provision --start-verification`;
|
|
12
|
-
}
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
3
|
// src/refresh.ts
|
|
17
4
|
function keepRunningCommand(state) {
|
|
18
5
|
return `erdo datasets refresh keep-running ${state.dataset_slug || "<slug>"}`;
|
|
@@ -789,39 +776,6 @@ var ErdoClient = class {
|
|
|
789
776
|
{ successor_manager_slug: successorManagerSlug }
|
|
790
777
|
);
|
|
791
778
|
}
|
|
792
|
-
// Reads the Google Ads container a managed org already has under this manager
|
|
793
|
-
// and creates nothing, so it is safe to run against an org mid-setup: a 404
|
|
794
|
-
// means the org has no container here, not that anything is broken.
|
|
795
|
-
getManagedOrganizationAdsContainer(slug) {
|
|
796
|
-
return this.request(
|
|
797
|
-
"GET",
|
|
798
|
-
`/v1/managed-organizations/${encodeURIComponent(slug)}/ads-container`
|
|
799
|
-
);
|
|
800
|
-
}
|
|
801
|
-
// Creates the container — a sub-account under the manager's MCC plus the
|
|
802
|
-
// delegated connection inside the managed org. `customerId` switches the call
|
|
803
|
-
// from creating an account to adopting one that already sits directly under
|
|
804
|
-
// the manager, which is the only way to attach a sub-account somebody made by
|
|
805
|
-
// hand: Google Ads cannot delete an account, so creating a second one beside
|
|
806
|
-
// it is permanent. `replaceCurrentAccount` is the one input with consequences:
|
|
807
|
-
// provisioning refuses outright when the org is already running campaigns in
|
|
808
|
-
// another account, and passing this accepts that those campaigns are left
|
|
809
|
-
// behind, so the key is sent only when it is asked for rather than as a
|
|
810
|
-
// `false` the server has to read.
|
|
811
|
-
provisionManagedOrganizationAdsContainer(slug, input) {
|
|
812
|
-
const body = {};
|
|
813
|
-
if (input.customerId) body.customer_id = input.customerId;
|
|
814
|
-
if (input.descriptiveName) body.descriptive_name = input.descriptiveName;
|
|
815
|
-
if (input.currencyCode) body.currency_code = input.currencyCode;
|
|
816
|
-
if (input.timeZone) body.time_zone = input.timeZone;
|
|
817
|
-
if (input.replaceCurrentAccount) body.replace_current_account = true;
|
|
818
|
-
if (input.startAdvertiserVerification) body.start_advertiser_verification = true;
|
|
819
|
-
return this.request(
|
|
820
|
-
"POST",
|
|
821
|
-
`/v1/managed-organizations/${encodeURIComponent(slug)}/ads-container`,
|
|
822
|
-
body
|
|
823
|
-
);
|
|
824
|
-
}
|
|
825
779
|
// --- Custom page domains: the branded hostnames the org's pages serve from ---
|
|
826
780
|
listCustomDomains() {
|
|
827
781
|
return this.request("GET", "/v1/custom-domains");
|
|
@@ -2987,6 +2941,26 @@ async function promptLine(question) {
|
|
|
2987
2941
|
}
|
|
2988
2942
|
}
|
|
2989
2943
|
|
|
2944
|
+
// src/mcp-header-input.ts
|
|
2945
|
+
function parseMCPHeaders(values) {
|
|
2946
|
+
const entries = /* @__PURE__ */ new Map();
|
|
2947
|
+
const names = /* @__PURE__ */ new Set();
|
|
2948
|
+
for (const header of values) {
|
|
2949
|
+
const separator = header.indexOf(":");
|
|
2950
|
+
if (separator < 1) throw new Error("invalid --mcp-header; expected Name: value");
|
|
2951
|
+
const name = header.slice(0, separator).trim();
|
|
2952
|
+
const value = header.slice(separator + 1).trim();
|
|
2953
|
+
if (!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(name) || /[\r\n\0]/.test(value)) {
|
|
2954
|
+
throw new Error("invalid --mcp-header name or value");
|
|
2955
|
+
}
|
|
2956
|
+
const key = name.toLowerCase();
|
|
2957
|
+
if (names.has(key)) throw new Error("duplicate --mcp-header name");
|
|
2958
|
+
names.add(key);
|
|
2959
|
+
entries.set(name, value);
|
|
2960
|
+
}
|
|
2961
|
+
return Object.fromEntries(entries);
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2990
2964
|
// src/integration-credential-input.ts
|
|
2991
2965
|
var PROMPT_FIELD = /^[A-Za-z0-9_.-]+$/;
|
|
2992
2966
|
async function resolveIntegrationCredentials(options) {
|
|
@@ -4047,7 +4021,7 @@ businessProfileCmd.command("set").description("Save the organization's business
|
|
|
4047
4021
|
}
|
|
4048
4022
|
}
|
|
4049
4023
|
);
|
|
4050
|
-
var managed = org.command("managed").description("Operate client orgs
|
|
4024
|
+
var managed = org.command("managed").description("Operate client orgs through manager authority");
|
|
4051
4025
|
managed.command("list").description("List the client orgs your org manages").action(async () => {
|
|
4052
4026
|
try {
|
|
4053
4027
|
const { organizations } = await new ErdoClient().listManagedOrganizations();
|
|
@@ -4130,108 +4104,6 @@ managed.command("add-member <orgSlug> <email>").description("Seat a person in a
|
|
|
4130
4104
|
fail(e);
|
|
4131
4105
|
}
|
|
4132
4106
|
});
|
|
4133
|
-
function printAdsContainer(c) {
|
|
4134
|
-
console.log(`org: ${c.org_slug}`);
|
|
4135
|
-
console.log(`customer id: ${c.customer_id}`);
|
|
4136
|
-
console.log(`manager (login customer id): ${c.login_customer_id}`);
|
|
4137
|
-
console.log(`integration: ${c.integration_id}`);
|
|
4138
|
-
if (c.descriptive_name) {
|
|
4139
|
-
console.log(`name: ${c.descriptive_name}`);
|
|
4140
|
-
}
|
|
4141
|
-
console.log(`billing: ${c.billing_status}`);
|
|
4142
|
-
if (c.billing_status === "unknown") {
|
|
4143
|
-
process.stderr.write(
|
|
4144
|
-
`Billing could not be checked for ${c.customer_id} \u2014 open the account in the Google Ads UI and confirm; this is not evidence that billing is missing.
|
|
4145
|
-
`
|
|
4146
|
-
);
|
|
4147
|
-
} else if (!c.billing_configured) {
|
|
4148
|
-
process.stderr.write(
|
|
4149
|
-
`Billing is ${c.billing_status}: ${c.customer_id} cannot serve until a payments profile is linked to it in the Google Ads UI.
|
|
4150
|
-
`
|
|
4151
|
-
);
|
|
4152
|
-
}
|
|
4153
|
-
const v = c.advertiser_verification;
|
|
4154
|
-
if (v) {
|
|
4155
|
-
console.log(`advertiser verification: ${v.status}`);
|
|
4156
|
-
if (v.action_url) console.log(`verification link: ${v.action_url}`);
|
|
4157
|
-
if (v.completion_deadline) console.log(`verification deadline: ${v.completion_deadline}`);
|
|
4158
|
-
const action = advertiserVerificationAction(c);
|
|
4159
|
-
if (action) process.stderr.write(`${action}
|
|
4160
|
-
`);
|
|
4161
|
-
}
|
|
4162
|
-
}
|
|
4163
|
-
managed.command("ads-container <orgSlug>").description(
|
|
4164
|
-
"Read the Google Ads account a managed org runs its campaigns in, or --provision one under your manager account"
|
|
4165
|
-
).option("--provision", "create the account and the org's delegated google_ads connection instead of reading them").option(
|
|
4166
|
-
"--adopt <customerId>",
|
|
4167
|
-
"with --provision: connect an existing client account already sitting directly under your manager account instead of creating a new one \u2014 for a sub-account created by hand in the Google Ads UI"
|
|
4168
|
-
).option(
|
|
4169
|
-
"--replace-current-account",
|
|
4170
|
-
"with --provision: go ahead even though the org already runs campaigns in another account. Google Ads cannot move a campaign, so those campaigns stay behind and have to be rebuilt"
|
|
4171
|
-
).option("--name <descriptiveName>", "display name for the new account (default: the org's name and slug)").option("--currency <code>", "ISO currency code for the new account, e.g. USD").option("--time-zone <tz>", "IANA time zone for the new account, e.g. America/New_York").option(
|
|
4172
|
-
"--start-verification",
|
|
4173
|
-
"with --provision: open a Google advertiser-verification session when the account still needs one, so the output carries the link a person finishes it on"
|
|
4174
|
-
).action(
|
|
4175
|
-
async (orgSlug, opts) => {
|
|
4176
|
-
try {
|
|
4177
|
-
if (opts.replaceCurrentAccount && !opts.provision) {
|
|
4178
|
-
fail(new Error("--replace-current-account only applies with --provision"));
|
|
4179
|
-
}
|
|
4180
|
-
if (opts.startVerification && !opts.provision) {
|
|
4181
|
-
fail(new Error("--start-verification only applies with --provision"));
|
|
4182
|
-
}
|
|
4183
|
-
if (opts.adopt && !opts.provision) {
|
|
4184
|
-
fail(new Error("--adopt only applies with --provision"));
|
|
4185
|
-
}
|
|
4186
|
-
if (opts.adopt && (opts.name || opts.currency || opts.timeZone)) {
|
|
4187
|
-
fail(
|
|
4188
|
-
new Error(
|
|
4189
|
-
"--adopt takes an account that already exists, so --name, --currency and --time-zone do not apply \u2014 they describe an account being created"
|
|
4190
|
-
)
|
|
4191
|
-
);
|
|
4192
|
-
}
|
|
4193
|
-
const api = new ErdoClient();
|
|
4194
|
-
if (!opts.provision) {
|
|
4195
|
-
try {
|
|
4196
|
-
printAdsContainer(await api.getManagedOrganizationAdsContainer(orgSlug));
|
|
4197
|
-
} catch (e) {
|
|
4198
|
-
if (e instanceof ErdoApiError && e.status === 404) {
|
|
4199
|
-
fail(
|
|
4200
|
-
new Error(
|
|
4201
|
-
`${orgSlug} has no Google Ads container under this manager. Create one with: erdo org managed ads-container ${orgSlug} --provision`
|
|
4202
|
-
)
|
|
4203
|
-
);
|
|
4204
|
-
}
|
|
4205
|
-
throw e;
|
|
4206
|
-
}
|
|
4207
|
-
return;
|
|
4208
|
-
}
|
|
4209
|
-
const c = await api.provisionManagedOrganizationAdsContainer(orgSlug, {
|
|
4210
|
-
customerId: opts.adopt,
|
|
4211
|
-
descriptiveName: opts.name,
|
|
4212
|
-
currencyCode: opts.currency,
|
|
4213
|
-
timeZone: opts.timeZone,
|
|
4214
|
-
replaceCurrentAccount: opts.replaceCurrentAccount,
|
|
4215
|
-
startAdvertiserVerification: opts.startVerification
|
|
4216
|
-
});
|
|
4217
|
-
let outcome;
|
|
4218
|
-
if (c.already_provisioned) outcome = `Google Ads container already existed for ${c.org_slug}`;
|
|
4219
|
-
else if (c.adopted) outcome = `Adopted Google Ads account ${c.customer_id} as the container for ${c.org_slug}`;
|
|
4220
|
-
else outcome = `Created Google Ads container for ${c.org_slug}`;
|
|
4221
|
-
console.log(outcome);
|
|
4222
|
-
printAdsContainer(c);
|
|
4223
|
-
const leftBehind = c.previous_campaign_count ?? 0;
|
|
4224
|
-
if (c.previous_customer_id && leftBehind > 0) {
|
|
4225
|
-
process.stderr.write(
|
|
4226
|
-
`${leftBehind} campaign${leftBehind === 1 ? "" : "s"} stayed in ${c.previous_customer_id}, the account this replaced. Google Ads cannot move a campaign between accounts and nothing in ${c.org_slug} resolves that account any more, so they have to be rebuilt in ${c.customer_id}.
|
|
4227
|
-
`
|
|
4228
|
-
);
|
|
4229
|
-
}
|
|
4230
|
-
} catch (e) {
|
|
4231
|
-
fail(e);
|
|
4232
|
-
}
|
|
4233
|
-
}
|
|
4234
|
-
);
|
|
4235
4107
|
managed.command("handoff-token <orgSlug>").description("Mint a one-time token offering an ownerless managed org to another manager; shown ONCE").requiredOption("--successor <managerOrgSlug>", "the manager org allowed to redeem the token").action(async (orgSlug, opts) => {
|
|
4236
4108
|
try {
|
|
4237
4109
|
const res = await new ErdoClient().createManagedOrganizationHandoffToken(orgSlug, opts.successor);
|
|
@@ -11330,7 +11202,7 @@ integrationsCmd.command("apps [query]").description("Search connectable apps (na
|
|
|
11330
11202
|
fail(e);
|
|
11331
11203
|
}
|
|
11332
11204
|
});
|
|
11333
|
-
integrationsCmd.command("connect <app>").description("Connect an app \u2014 pass credentials with -c or --prompt-credential, or omit them to get a browser connect URL for OAuth apps").option("-c, --credential <key=value...>", "credential field, e.g. -c api_key=\u2026 (repeatable); rejected by OAuth apps, which have no credential to pass", (v, acc) => acc.concat(v), []).option("--prompt-credential <field>", "prompt securely for a credential field (repeatable; interactive terminals only)", (v, acc) => acc.concat(v), []).option("-n, --name <name>", "display name for the connection").option("--rotate", "replace the credentials of the app's existing connection instead of adding a second one \u2014 for a key that was rotated at the provider; requires -c
|
|
11205
|
+
integrationsCmd.command("connect <app>").option("--mcp-url <url>", "Streamable HTTP MCP endpoint; use with app=mcp and --name").option("--mcp-header <header>", "static MCP header as Name: value (repeatable); --rotate replaces all headers", (v, acc) => acc.concat(v), []).option("--member-access <read_only|full>", "access for shared MCP members (default read_only)").description("Connect an app \u2014 pass credentials with -c or --prompt-credential, or omit them to get a browser connect URL for OAuth apps").option("-c, --credential <key=value...>", "credential field, e.g. -c api_key=\u2026 (repeatable); rejected by OAuth apps, which have no credential to pass", (v, acc) => acc.concat(v), []).option("--prompt-credential <field>", "prompt securely for a credential field (repeatable; interactive terminals only)", (v, acc) => acc.concat(v), []).option("-n, --name <name>", "display name for the connection").option("--rotate", "replace the credentials of the app's existing connection instead of adding a second one \u2014 for a key that was rotated at the provider; requires -c, --prompt-credential or MCP headers").option("--share", "share the connection with the whole organization instead of keeping it private to you \u2014 for org-level credentials teammates and agents should see").option(
|
|
11334
11206
|
"--provide-to-managed",
|
|
11335
11207
|
"let the organizations you manage use this connection as if it were their own \u2014 for a vendor key your agency pays for. Key-authenticated native integrations only, connected in a manager organization"
|
|
11336
11208
|
).option(
|
|
@@ -11355,6 +11227,9 @@ integrationsCmd.command("connect <app>").description("Connect an app \u2014 pass
|
|
|
11355
11227
|
const res = await new ErdoClient().connectIntegration({
|
|
11356
11228
|
app,
|
|
11357
11229
|
name: opts.name,
|
|
11230
|
+
mcp_url: opts.mcpUrl,
|
|
11231
|
+
mcp_headers: opts.mcpHeader.length ? parseMCPHeaders(opts.mcpHeader) : app === "mcp" && opts.rotate ? {} : void 0,
|
|
11232
|
+
member_access: opts.memberAccess,
|
|
11358
11233
|
credentials,
|
|
11359
11234
|
rotate_credentials: opts.rotate || void 0,
|
|
11360
11235
|
share_with_org: opts.share || void 0,
|