adport 0.6.0 → 0.7.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 ADDED
@@ -0,0 +1,16 @@
1
+ # adport
2
+
3
+ The Adport CLI: manage advertising accounts from the terminal with previewed writes.
4
+
5
+ ```sh
6
+ npm install -g adport
7
+ adport --demo accounts
8
+ adport connect google
9
+ adport mcp
10
+ ```
11
+
12
+ Requires Node.js 22.13 or newer. Local connections use your own provider applications and credentials. Every advertising mutation passes through the shared preview/apply policy engine.
13
+
14
+ [Quick start and MCP setup](https://github.com/ynnickw/adport#quick-start) · [Provider guides](https://github.com/ynnickw/adport/blob/main/docs/providers.md) · [Security](https://github.com/ynnickw/adport/blob/main/SECURITY.md)
15
+
16
+ Licensed under Apache-2.0.
@@ -30,9 +30,9 @@ async function connectGoogle({ openBrowser, io }) {
30
30
  io.out("is expected for BYO personal use; a verified Adport screen is Cloud-only.");
31
31
  io.out("");
32
32
  const existing = await store.get("google");
33
- if (existing?.data.developer_token && existing.data.client_id && existing.data.client_secret) {
33
+ if (existing?.data.client_id && existing.data.client_secret) {
34
34
  const answer = (await rl.question(
35
- "Existing Google connection found. Re-authorize with the same developer token and OAuth client? [Y/n] "
35
+ "Existing Google connection found. Re-authorize with the same OAuth client? [Y/n] "
36
36
  )).trim().toLowerCase();
37
37
  if (answer !== "n" && answer !== "no") {
38
38
  const refreshToken = await runOAuthFlow(
@@ -43,7 +43,6 @@ async function connectGoogle({ openBrowser, io }) {
43
43
  );
44
44
  await verifyAndSave(
45
45
  {
46
- developerToken: existing.data.developer_token,
47
46
  clientId: existing.data.client_id,
48
47
  clientSecret: existing.data.client_secret,
49
48
  refreshToken,
@@ -56,9 +55,9 @@ async function connectGoogle({ openBrowser, io }) {
56
55
  }
57
56
  }
58
57
  io.out("Connecting Google Ads. You need (the wizard guides each step):");
59
- io.out(" 1. A manager account (MCC) \u2014 free, instant: https://ads.google.com/home/tools/manager-accounts/");
60
- io.out(" 2. A developer token from the MCC API Center (Explorer access is automatic): https://ads.google.com/aw/apicenter");
61
- io.out(' 3. A Google Cloud OAuth "Desktop app" client: https://console.cloud.google.com/apis/credentials');
58
+ io.out(" 1. A Google Cloud project with Google Ads API access: https://console.cloud.google.com/apis/api/googleads.googleapis.com/overview");
59
+ io.out(" For production accounts, the project needs Explorer, Basic, or Standard access.");
60
+ io.out(' 2. An OAuth "Desktop app" client in that project: https://console.cloud.google.com/apis/credentials');
62
61
  io.out(" Enable Google Ads API; choose External; add yourself as a test user.");
63
62
  io.out(' Suggested private app name: "Adport Local \u2013 <your organization>".');
64
63
  io.out("");
@@ -67,7 +66,6 @@ async function connectGoogle({ openBrowser, io }) {
67
66
  if (imported) {
68
67
  creds = imported;
69
68
  } else {
70
- const developerToken = (await rl.question("Developer token (from the MCC API Center): ")).trim();
71
69
  let clientId = "";
72
70
  let clientSecret = "";
73
71
  const secretPath = (await rl.question("Path to downloaded client_secret_*.json (or press Enter to type id/secret manually): ")).trim();
@@ -79,14 +77,14 @@ async function connectGoogle({ openBrowser, io }) {
79
77
  clientId = (await rl.question("OAuth client id: ")).trim();
80
78
  clientSecret = (await rl.question("OAuth client secret: ")).trim();
81
79
  }
82
- if (!developerToken || !clientId || !clientSecret) {
83
- io.err("Missing developer token or OAuth client credentials \u2014 aborting.");
80
+ if (!clientId || !clientSecret) {
81
+ io.err("Missing OAuth client credentials \u2014 aborting.");
84
82
  process.exitCode = 1;
85
83
  return;
86
84
  }
87
85
  const loginCustomerId = (await rl.question("Manager (MCC) customer id for login-customer-id (Enter to skip): ")).trim() || void 0;
88
86
  const refreshToken = await runOAuthFlow(clientId, clientSecret, openBrowser, io);
89
- creds = { developerToken, clientId, clientSecret, refreshToken, loginCustomerId };
87
+ creds = { clientId, clientSecret, refreshToken, loginCustomerId };
90
88
  }
91
89
  await verifyAndSave(creds, store, io);
92
90
  } finally {
@@ -131,7 +129,6 @@ async function verifyAndSave(creds, store, io) {
131
129
  provider: "google",
132
130
  source: "byo",
133
131
  data: {
134
- developer_token: creds.developerToken,
135
132
  client_id: creds.clientId,
136
133
  client_secret: creds.clientSecret,
137
134
  refresh_token: creds.refreshToken,
@@ -161,16 +158,14 @@ async function tryImportGoogleAdsYaml(rl, io) {
161
158
  continue;
162
159
  }
163
160
  const parsed = YAML.parse(raw);
164
- const developerToken = str(parsed?.developer_token);
165
161
  const clientId = str(parsed?.client_id);
166
162
  const clientSecret = str(parsed?.client_secret);
167
163
  const refreshToken = str(parsed?.refresh_token);
168
- if (!developerToken || !clientId || !clientSecret || !refreshToken) continue;
164
+ if (!clientId || !clientSecret || !refreshToken) continue;
169
165
  const answer = (await rl.question(`Found ${candidate} \u2014 import it? [Y/n] `)).trim().toLowerCase();
170
166
  if (answer === "n" || answer === "no") continue;
171
167
  io.out(`Importing credentials from ${candidate}.`);
172
168
  return {
173
- developerToken,
174
169
  clientId,
175
170
  clientSecret,
176
171
  refreshToken,
@@ -188,4 +183,4 @@ function expandHome(p) {
188
183
  export {
189
184
  connectGoogle
190
185
  };
191
- //# sourceMappingURL=google-YRYPPXWU.js.map
186
+ //# sourceMappingURL=google-ULSSOSIA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/connect/google.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport readline from 'node:readline/promises';\nimport YAML from 'yaml';\nimport { CredentialStore } from '@adport/core';\nimport { GoogleAdsRestClient, type GoogleCredentials } from '@adport/provider-google';\nimport type { ProgramIO } from '../program.js';\nimport {\n buildGoogleAuthUrl,\n exchangeCodeForTokens,\n generateOAuthState,\n generatePkce,\n openInBrowser,\n parseClientSecretJson,\n startLoopbackServer,\n} from './oauth.js';\nimport { printLocalConnectionIntro, printLocalConnectionSaved } from './local.js';\n\nexport interface ConnectGoogleOptions {\n openBrowser: boolean;\n io: ProgramIO;\n}\n\n/**\n * Guided Google Ads connection using Cloud project API access and OAuth.\n */\nexport async function connectGoogle({ openBrowser, io }: ConnectGoogleOptions): Promise<void> {\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const store = new CredentialStore();\n try {\n printLocalConnectionIntro(io, 'Google Ads');\n io.out('Google may show \"Google has not verified this app\" for a private/unverified');\n io.out('OAuth project. The developer shown will be your project contact. That warning');\n io.out('is expected for BYO personal use; a verified Adport screen is Cloud-only.');\n io.out('');\n // Re-auth fast path: keep the stored OAuth client and\n // only redo the browser consent (covers expired/revoked refresh tokens).\n const existing = await store.get('google');\n if (existing?.data.client_id && existing.data.client_secret) {\n const answer = (\n await rl.question(\n 'Existing Google connection found. Re-authorize with the same OAuth client? [Y/n] ',\n )\n )\n .trim()\n .toLowerCase();\n if (answer !== 'n' && answer !== 'no') {\n const refreshToken = await runOAuthFlow(\n existing.data.client_id,\n existing.data.client_secret,\n openBrowser,\n io,\n );\n await verifyAndSave(\n {\n clientId: existing.data.client_id,\n clientSecret: existing.data.client_secret,\n refreshToken,\n loginCustomerId: existing.data.login_customer_id || undefined,\n },\n store,\n io,\n );\n return;\n }\n }\n\n io.out('Connecting Google Ads. You need (the wizard guides each step):');\n io.out(' 1. A Google Cloud project with Google Ads API access: https://console.cloud.google.com/apis/api/googleads.googleapis.com/overview');\n io.out(' For production accounts, the project needs Explorer, Basic, or Standard access.');\n io.out(' 2. An OAuth \"Desktop app\" client in that project: https://console.cloud.google.com/apis/credentials');\n io.out(' Enable Google Ads API; choose External; add yourself as a test user.');\n io.out(' Suggested private app name: \"Adport Local – <your organization>\".');\n io.out('');\n\n // Fast path: import an existing google-ads.yaml (the ecosystem convention).\n const imported = await tryImportGoogleAdsYaml(rl, io);\n let creds: GoogleCredentials;\n if (imported) {\n creds = imported;\n } else {\n let clientId = '';\n let clientSecret = '';\n const secretPath = (\n await rl.question('Path to downloaded client_secret_*.json (or press Enter to type id/secret manually): ')\n ).trim();\n if (secretPath) {\n const parsed = parseClientSecretJson(await fs.readFile(expandHome(secretPath), 'utf8'));\n clientId = parsed.clientId;\n clientSecret = parsed.clientSecret;\n } else {\n clientId = (await rl.question('OAuth client id: ')).trim();\n clientSecret = (await rl.question('OAuth client secret: ')).trim();\n }\n\n if (!clientId || !clientSecret) {\n io.err('Missing OAuth client credentials — aborting.');\n process.exitCode = 1;\n return;\n }\n\n const loginCustomerId =\n (await rl.question('Manager (MCC) customer id for login-customer-id (Enter to skip): ')).trim() || undefined;\n\n const refreshToken = await runOAuthFlow(clientId, clientSecret, openBrowser, io);\n creds = { clientId, clientSecret, refreshToken, loginCustomerId };\n }\n\n await verifyAndSave(creds, store, io);\n } finally {\n rl.close();\n }\n}\n\nasync function runOAuthFlow(\n clientId: string,\n clientSecret: string,\n openBrowser: boolean,\n io: ProgramIO,\n): Promise<string> {\n io.out('');\n io.out('Starting the OAuth flow (scope: Google Ads). A browser window should open;');\n io.out('sign in with the Google account that can access your ad accounts.');\n const pkce = generatePkce();\n const state = generateOAuthState();\n const loopback = await startLoopbackServer('127.0.0.1', state);\n const authUrl = buildGoogleAuthUrl(clientId, loopback.redirectUri, pkce.challenge, state);\n if (openBrowser) {\n openInBrowser(authUrl);\n io.out(`If the browser did not open, visit:\\n ${authUrl}`);\n } else {\n io.out(`Open this URL in a browser on this machine (or SSH port-forward the shown port):\\n ${authUrl}`);\n }\n try {\n const code = await loopback.waitForCode;\n const tokens = await exchangeCodeForTokens({\n clientId,\n clientSecret,\n code,\n redirectUri: loopback.redirectUri,\n codeVerifier: pkce.verifier,\n });\n return tokens.refreshToken;\n } finally {\n loopback.close();\n }\n}\n\nasync function verifyAndSave(creds: GoogleCredentials, store: CredentialStore, io: ProgramIO): Promise<void> {\n io.out('Verifying access…');\n const client = new GoogleAdsRestClient(creds);\n const customers = await client.listAccessibleCustomers();\n await store.set({\n provider: 'google',\n source: 'byo',\n data: {\n client_id: creds.clientId,\n client_secret: creds.clientSecret,\n refresh_token: creds.refreshToken,\n ...(creds.loginCustomerId ? { login_customer_id: creds.loginCustomerId } : {}),\n },\n });\n io.out('');\n io.out(`✓ Connected. ${customers.length} accessible customer id(s): ${customers.join(', ')}`);\n printLocalConnectionSaved(io);\n io.out('');\n io.out('If this token expires again in ~7 days: your OAuth consent screen is in \"Testing\"');\n io.out('status — set it to \"In production\" at console.cloud.google.com/apis/credentials/consent');\n io.out('(no verification needed for your own use; refresh tokens then stop expiring weekly).');\n io.out('');\n io.out('Try: adport accounts · adport report --provider google · adport mcp');\n}\n\nasync function tryImportGoogleAdsYaml(\n rl: readline.Interface,\n io: ProgramIO,\n): Promise<GoogleCredentials | undefined> {\n const candidates = [\n process.env.GOOGLE_ADS_CONFIGURATION_FILE_PATH,\n path.join(os.homedir(), 'google-ads.yaml'),\n ].filter((p): p is string => Boolean(p));\n for (const candidate of candidates) {\n let raw: string;\n try {\n raw = await fs.readFile(candidate, 'utf8');\n } catch {\n continue;\n }\n const parsed = YAML.parse(raw) as Record<string, unknown> | null;\n const clientId = str(parsed?.client_id);\n const clientSecret = str(parsed?.client_secret);\n const refreshToken = str(parsed?.refresh_token);\n if (!clientId || !clientSecret || !refreshToken) continue;\n const answer = (await rl.question(`Found ${candidate} — import it? [Y/n] `)).trim().toLowerCase();\n if (answer === 'n' || answer === 'no') continue;\n io.out(`Importing credentials from ${candidate}.`);\n return {\n clientId,\n clientSecret,\n refreshToken,\n loginCustomerId: str(parsed?.login_customer_id) || undefined,\n };\n }\n return undefined;\n}\n\nfunction str(value: unknown): string {\n return value === undefined || value === null ? '' : String(value);\n}\n\nfunction expandHome(p: string): string {\n return p.startsWith('~/') ? path.join(os.homedir(), p.slice(2)) : p;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,SAAS,uBAAuB;AAChC,SAAS,2BAAmD;AAqB5D,eAAsB,cAAc,EAAE,aAAa,GAAG,GAAwC;AAC5F,QAAM,KAAK,SAAS,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ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AAG,IAAI,8BAA8B,SAAS,GAAG;AACjD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,IAAI,QAAQ,iBAAiB,KAAK;AAAA,IACrD;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,IAAI,OAAwB;AACnC,SAAO,UAAU,UAAa,UAAU,OAAO,KAAK,OAAO,KAAK;AAClE;AAEA,SAAS,WAAW,GAAmB;AACrC,SAAO,EAAE,WAAW,IAAI,IAAI,KAAK,KAAK,GAAG,QAAQ,GAAG,EAAE,MAAM,CAAC,CAAC,IAAI;AACpE;","names":[]}
package/dist/index.js CHANGED
@@ -6,14 +6,16 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "adport",
9
- version: "0.6.0",
9
+ version: "0.7.0",
10
10
  description: "adport CLI \u2014 the open control plane for paid media",
11
11
  license: "Apache-2.0",
12
12
  type: "module",
13
13
  bin: {
14
14
  adport: "./dist/index.js"
15
15
  },
16
- files: ["dist"],
16
+ files: [
17
+ "dist"
18
+ ],
17
19
  scripts: {
18
20
  build: "tsup src/index.ts --format esm --sourcemap --clean",
19
21
  test: "vitest run",
@@ -43,6 +45,21 @@ var package_default = {
43
45
  tsup: "^8.3.0",
44
46
  typescript: "^5.8.0",
45
47
  vitest: "^4.1.10"
48
+ },
49
+ repository: {
50
+ type: "git",
51
+ url: "git+https://github.com/ynnickw/adport.git",
52
+ directory: "packages/cli"
53
+ },
54
+ homepage: "https://github.com/ynnickw/adport#readme",
55
+ bugs: {
56
+ url: "https://github.com/ynnickw/adport/issues"
57
+ },
58
+ engines: {
59
+ node: ">=22.13"
60
+ },
61
+ publishConfig: {
62
+ access: "public"
46
63
  }
47
64
  };
48
65
 
@@ -193,7 +210,7 @@ function buildProgram(io = defaultIO) {
193
210
  });
194
211
  program.command("connect <provider>").description("Connect an ad account (guided wizard)").option("--no-browser", "Print auth URLs instead of opening a browser").action(async (provider, opts) => {
195
212
  if (provider === "google") {
196
- const { connectGoogle } = await import("./google-YRYPPXWU.js");
213
+ const { connectGoogle } = await import("./google-ULSSOSIA.js");
197
214
  await connectGoogle({ openBrowser: opts.browser, io });
198
215
  return;
199
216
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/program.ts","../package.json","../src/index.ts"],"sourcesContent":["import { Command } from 'commander';\nimport packageJson from '../package.json';\nimport {\n AdportError,\n AuditLog,\n CredentialStore,\n type AdportRuntime,\n type AnyToolDefinition,\n} from '@adport/core';\n\nexport interface ProgramIO {\n out: (line: string) => void;\n err: (line: string) => void;\n}\n\nconst defaultIO: ProgramIO = {\n out: (line) => console.log(line),\n err: (line) => console.error(line),\n};\n\nfunction json(value: unknown): string {\n return JSON.stringify(value, null, 2);\n}\n\nfunction table(rows: Array<Record<string, unknown>>): string {\n if (rows.length === 0) return '(empty)';\n const keys = Object.keys(rows[0]!);\n const widths = keys.map((k) => Math.max(k.length, ...rows.map((r) => String(r[k] ?? '').length)));\n const line = (values: string[]) => values.map((v, i) => v.padEnd(widths[i]!)).join(' ');\n return [line(keys), line(widths.map((w) => '-'.repeat(w))), ...rows.map((r) => line(keys.map((k) => String(r[k] ?? ''))))].join('\\n');\n}\n\nasync function runtime(includeMock?: boolean): Promise<AdportRuntime> {\n const { assembleRuntime } = await import('@adport/mcp');\n return assembleRuntime({ includeMock });\n}\n\nexport function buildProgram(io: ProgramIO = defaultIO): Command {\n const program = new Command('adport');\n program\n .description('The open control plane for paid media (MCP + CLI)')\n .option('--demo', 'Use synthetic mock accounts and tools (never real provider data)')\n .version(packageJson.version)\n .configureOutput({ writeOut: (s) => io.out(s.trimEnd()), writeErr: (s) => io.err(s.trimEnd()) });\n const commandRuntime = () => runtime(program.opts<{ demo?: boolean }>().demo === true ? true : undefined);\n\n const tools = program.command('tools').description('Inspect and invoke the shared tool registry');\n\n tools\n .command('list')\n .description('List available tools')\n .option('--json', 'JSON output')\n .action(async (opts: { json?: boolean }) => {\n const { registry } = await commandRuntime();\n const defs = registry.list();\n if (opts.json) {\n io.out(\n json(\n defs.map((t: AnyToolDefinition) => ({\n name: t.name,\n namespace: t.namespace,\n readOnly: t.annotations.readOnly ?? false,\n destructive: t.annotations.destructive ?? false,\n })),\n ),\n );\n return;\n }\n io.out(\n table(\n defs.map((t) => ({\n name: t.name,\n namespace: t.namespace,\n mode: t.annotations.readOnly ? 'read' : t.annotations.destructive ? 'DESTRUCTIVE' : 'write',\n })),\n ),\n );\n });\n\n tools\n .command('run <name>')\n .description('Invoke a tool with JSON input (the same tools the MCP server exposes)')\n .option('--input <json>', 'JSON object with the tool arguments', '{}')\n .action(async (name: string, opts: { input: string }) => {\n const rt = await commandRuntime();\n const result = await rt.registry.call(name, JSON.parse(opts.input), rt.ctx);\n io.out(json(result));\n });\n\n program\n .command('accounts')\n .description('List connected ad accounts across providers')\n .option('--provider <id>', 'Limit to one provider')\n .option('--json', 'JSON output')\n .action(async (opts: { provider?: string; json?: boolean }) => {\n const rt = await commandRuntime();\n const result = (await rt.registry.call('accounts_list', { provider: opts.provider }, rt.ctx)) as {\n accounts: Array<Record<string, unknown>>;\n };\n io.out(opts.json ? json(result.accounts) : table(result.accounts));\n });\n\n program\n .command('report')\n .description('Normalized cross-platform performance report')\n .option('--provider <id>', 'Limit to one provider')\n .option('--level <level>', 'account | campaign | ad_group | ad', 'campaign')\n .option('--metrics <list>', 'Comma-separated metrics', 'spend,impressions,clicks,conversions')\n .option('--range <range>', 'Preset (last_7_days, ...) or START..END', 'last_7_days')\n .option('--limit <n>', 'Max rows', '100')\n .option('--json', 'JSON output')\n .action(async (opts: { provider?: string; level: string; metrics: string; range: string; limit: string; json?: boolean }) => {\n const rt = await commandRuntime();\n const dateRange = opts.range.includes('..')\n ? { start: opts.range.split('..')[0]!, end: opts.range.split('..')[1]! }\n : opts.range;\n const result = (await rt.registry.call(\n 'report',\n {\n provider: opts.provider,\n level: opts.level,\n metrics: opts.metrics.split(',').map((m) => m.trim()),\n date_range: dateRange,\n limit: Number(opts.limit),\n },\n rt.ctx,\n )) as { rows: Array<{ provider: string; accountId: string; entity: { name: string; status?: string }; metrics: Record<string, number> }>; truncated: boolean };\n if (opts.json) {\n io.out(json(result));\n return;\n }\n io.out(\n table(\n result.rows.map((r) => ({\n provider: r.provider,\n account: r.accountId,\n entity: r.entity.name,\n status: r.entity.status ?? '',\n ...r.metrics,\n })),\n ),\n );\n if (result.truncated) io.err('(truncated — raise --limit for more rows)');\n });\n\n program\n .command('policy')\n .description('Show the active write policy and where it was loaded from')\n .action(async () => {\n const rt = await commandRuntime();\n io.out(json({ source: rt.policySource, policy: rt.ctx.engine.policy }));\n });\n\n const audit = program.command('audit').description('Inspect or extend the write-audit trail');\n\n audit\n .command('show', { isDefault: true })\n .description('Show recent write-audit entries')\n .option('--limit <n>', 'Max entries', '20')\n .action(async (opts: { limit: string }) => {\n const entries = await new AuditLog().read(Number(opts.limit));\n if (entries.length === 0) {\n io.out('No audit entries yet.');\n return;\n }\n io.out(entries.map((e) => JSON.stringify(e)).join('\\n'));\n });\n\n audit\n .command('export')\n .description('Export write-audit entries to stdout for archival or compliance ingestion')\n .option('--limit <n>', 'Max entries', '10000')\n .option('--format <format>', 'jsonl | json', 'jsonl')\n .action(async (opts: { limit: string; format: string }) => {\n const limit = Number(opts.limit);\n if (!Number.isInteger(limit) || limit < 1) {\n throw new AdportError('INVALID_INPUT', '--limit must be a positive integer');\n }\n if (opts.format !== 'jsonl' && opts.format !== 'json') {\n throw new AdportError('INVALID_INPUT', '--format must be jsonl or json');\n }\n const entries = await new AuditLog().read(limit);\n io.out(opts.format === 'json' ? json(entries) : entries.map((e) => JSON.stringify(e)).join('\\n'));\n });\n\n audit\n .command('run')\n .description('Run the audit rule packs over connected accounts and persist findings')\n .option('--provider <id>', 'Limit to one provider')\n .option('--range <range>', 'Preset or START..END', 'last_30_days')\n .action(async (opts: { provider?: string; range: string }) => {\n const rt = await commandRuntime();\n const dateRange = opts.range.includes('..')\n ? { start: opts.range.split('..')[0]!, end: opts.range.split('..')[1]! }\n : opts.range;\n const result = (await rt.registry.call(\n 'audit_run',\n { provider: opts.provider, date_range: dateRange },\n rt.ctx,\n )) as { findings: Array<{ id: string; severity: string; title: string }>; counts: Record<string, number>; evaluatedAccounts: number };\n io.out(`Evaluated ${result.evaluatedAccounts} account(s): ${result.counts.critical} critical, ${result.counts.warn} warn, ${result.counts.info} info`);\n for (const finding of result.findings) {\n io.out(` [${finding.severity.toUpperCase()}] ${finding.id}\\n ${finding.title}`);\n }\n if (result.findings.length > 0) io.out('Next: adport recommendations · adport recommendations apply <id>');\n });\n\n audit\n .command('note <text>')\n .description('Record an external/manual change in the audit trail (e.g. a change made in the platform UI)')\n .option('--provider <id>', 'Provider the change concerns', 'external')\n .option('--account <id>', 'Account id the change concerns', '-')\n .action(async (text: string, opts: { provider: string; account: string }) => {\n await new AuditLog().append({\n event: 'note',\n provider: opts.provider,\n tool: 'audit_note',\n accountId: opts.account,\n summary: text,\n });\n io.out('Noted.');\n });\n\n program\n .command('connect <provider>')\n .description('Connect an ad account (guided wizard)')\n .option('--no-browser', 'Print auth URLs instead of opening a browser')\n .action(async (provider: string, opts: { browser: boolean }) => {\n if (provider === 'google') {\n const { connectGoogle } = await import('./connect/google.js');\n await connectGoogle({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'meta') {\n const { connectMeta } = await import('./connect/meta.js');\n await connectMeta({ io });\n return;\n }\n if (provider === 'tiktok') {\n const { connectTikTok } = await import('./connect/tiktok.js');\n await connectTikTok({ io });\n return;\n }\n if (provider === 'apple') {\n const { connectApple } = await import('./connect/apple.js');\n await connectApple({ io });\n return;\n }\n if (provider === 'microsoft') {\n const { connectMicrosoft } = await import('./connect/microsoft.js');\n await connectMicrosoft({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'reddit') {\n const { connectReddit } = await import('./connect/reddit.js');\n await connectReddit({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'snapchat') {\n const { connectSnapchat } = await import('./connect/snapchat.js');\n await connectSnapchat({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'spotify') {\n const { connectSpotify } = await import('./connect/spotify.js');\n await connectSpotify({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'pinterest') {\n const { connectPinterest } = await import('./connect/pinterest.js');\n await connectPinterest({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'linkedin') {\n const { connectLinkedIn } = await import('./connect/linkedin.js');\n await connectLinkedIn({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'mock') {\n io.out('The mock provider is explicit demo mode, not a connection. Try: adport --demo accounts');\n return;\n }\n if (provider === 'x') {\n const { connectX } = await import('./connect/x.js');\n await connectX({ openBrowser: opts.browser, io });\n return;\n }\n io.err(`Provider \"${provider}\" is not supported. Available: google, meta, tiktok, apple, microsoft, reddit, snapchat, spotify, pinterest, linkedin, x, mock.`);\n process.exitCode = 1;\n });\n\n program\n .command('disconnect <provider>')\n .description('Remove a provider connection from this machine')\n .action(async (provider: string) => {\n if (!['google', 'meta', 'tiktok', 'apple', 'microsoft', 'reddit', 'snapchat', 'spotify', 'pinterest', 'linkedin', 'x'].includes(provider)) {\n io.err(`Provider \"${provider}\" is not supported. Available: google, meta, tiktok, apple, microsoft, reddit, snapchat, spotify, pinterest, linkedin, x.`);\n process.exitCode = 1;\n return;\n }\n const removed = await new CredentialStore().delete(provider);\n if (!removed) {\n io.out(`No local ${provider} credentials were stored.`);\n return;\n }\n io.out(`Removed local ${provider} credentials.`);\n io.out('Provider-side access was not revoked. Revoke the token or key at the provider if needed.');\n });\n\n const recommendations = program.command('recommendations').description('Review and act on audit findings');\n\n recommendations\n .command('list', { isDefault: true })\n .description('List findings (default: open), most severe first')\n .option('--status <status>', 'open | dismissed | applied', 'open')\n .option('--json', 'JSON output')\n .action(async (opts: { status: string; json?: boolean }) => {\n const rt = await commandRuntime();\n const result = (await rt.registry.call('recommendations_list', { status: opts.status }, rt.ctx)) as {\n findings: Array<{ id: string; severity: string; title: string; recommendation: string; proposedAction?: unknown }>;\n };\n if (opts.json) {\n io.out(json(result.findings));\n return;\n }\n if (result.findings.length === 0) {\n io.out(`No ${opts.status} findings. Run: adport audit run`);\n return;\n }\n for (const f of result.findings) {\n io.out(`[${f.severity.toUpperCase()}] ${f.id}`);\n io.out(` ${f.title}`);\n io.out(` → ${f.recommendation}${f.proposedAction ? ' (has ready-to-apply action)' : ''}`);\n }\n });\n\n recommendations\n .command('apply <findingId>')\n .description('Run a finding\\'s proposed action through the two-step validate→apply flow')\n .option('--pending <id>', 'pending_operation_id from the validation step')\n .action(async (findingId: string, opts: { pending?: string }) => {\n const rt = await commandRuntime();\n const result = await rt.registry.call(\n 'recommendation_apply',\n { finding_id: findingId, pending_operation_id: opts.pending },\n rt.ctx,\n );\n io.out(json(result));\n });\n\n recommendations\n .command('dismiss <findingId>')\n .description('Dismiss a finding (never reopened by future runs)')\n .action(async (findingId: string) => {\n const rt = await commandRuntime();\n const result = await rt.registry.call('recommendation_dismiss', { finding_id: findingId }, rt.ctx);\n io.out(json(result));\n });\n\n program\n .command('doctor')\n .description('Check credential and connection health for every provider')\n .action(async () => {\n const store = new CredentialStore();\n const records = await store.list();\n const rt = await commandRuntime();\n io.out(`policy: ${rt.policySource}`);\n io.out(`providers loaded: ${rt.ctx.providers.list().map((p) => p.id).join(', ') || '(none)'}`);\n for (const record of records) {\n io.out(`${record.provider}: credentials stored (source: ${record.source}, updated ${record.updatedAt})`);\n }\n for (const id of ['google', 'meta', 'tiktok', 'apple', 'microsoft', 'reddit', 'snapchat', 'spotify', 'pinterest', 'linkedin', 'x'] as const) {\n const provider = rt.ctx.providers.list().find((p) => p.id === id);\n if (!provider) {\n io.out(`${id}: not connected (run \\`adport connect ${id}\\`)`);\n continue;\n }\n try {\n const accounts = await provider.listAccounts();\n io.out(`${id}: OK — ${accounts.length} accessible account(s)`);\n } catch (err) {\n io.err(`${id}: FAILED — ${err instanceof Error ? err.message : String(err)}`);\n process.exitCode = 1;\n }\n }\n });\n\n program\n .command('mcp')\n .description('Start the adport MCP server on stdio')\n .action(async () => {\n const { runStdioServer } = await import('@adport/mcp');\n await runStdioServer(await commandRuntime());\n // Keep the process alive for the stdio transport.\n await new Promise(() => {});\n });\n\n return program;\n}\n\nexport async function main(argv: string[]): Promise<void> {\n const program = buildProgram();\n try {\n await program.parseAsync(argv);\n } catch (err) {\n if (err instanceof AdportError) {\n console.error(JSON.stringify(err.toJSON(), null, 2));\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n","{\n \"name\": \"adport\",\n \"version\": \"0.6.0\",\n \"description\": \"adport CLI — the open control plane for paid media\",\n \"license\": \"Apache-2.0\",\n \"type\": \"module\",\n \"bin\": {\n \"adport\": \"./dist/index.js\"\n },\n \"files\": [\"dist\"],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --format esm --sourcemap --clean\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist\"\n },\n \"dependencies\": {\n \"@adport/core\": \"workspace:*\",\n \"@adport/mcp\": \"workspace:*\",\n \"@adport/provider-apple\": \"workspace:*\",\n \"@adport/provider-google\": \"workspace:*\",\n \"@adport/provider-meta\": \"workspace:*\",\n \"@adport/provider-microsoft\": \"workspace:*\",\n \"@adport/provider-reddit\": \"workspace:*\",\n \"@adport/provider-snapchat\": \"workspace:*\",\n \"@adport/provider-spotify\": \"workspace:*\",\n \"@adport/provider-pinterest\": \"workspace:*\",\n \"@adport/provider-linkedin\": \"workspace:*\",\n \"@adport/provider-x\": \"workspace:*\",\n \"@adport/provider-tiktok\": \"workspace:*\",\n \"commander\": \"^13.0.0\",\n \"yaml\": \"^2.6.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.1.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.8.0\",\n \"vitest\": \"^4.1.10\"\n }\n}\n","#!/usr/bin/env node\nimport { main } from './program.js';\n\nawait main(process.argv);\n"],"mappings":";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AAC,UAAU,QAAQ,UAAU,SAAS,aAAa,UAAU,YAAY,WAAW,aAAa,YAAY,GAAG,GAAY;AAC3I,YAAM,WAAW,GAAG,IAAI,UAAU,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AAChE,UAAI,CAAC,UAAU;AACb,WAAG,IAAI,GAAG,EAAE,yCAAyC,EAAE,KAAK;AAC5D;AAAA,MACF;AACA,UAAI;AACF,cAAM,WAAW,MAAM,SAAS,aAAa;AAC7C,WAAG,IAAI,GAAG,EAAE,eAAU,SAAS,MAAM,wBAAwB;AAAA,MAC/D,SAAS,KAAK;AACZ,WAAG,IAAI,GAAG,EAAE,mBAAc,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAC5E,gBAAQ,WAAW;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AAEH,UACG,QAAQ,KAAK,EACb,YAAY,sCAAsC,EAClD,OAAO,YAAY;AAClB,UAAM,EAAE,eAAe,IAAI,MAAM,OAAO,aAAa;AACrD,UAAM,eAAe,MAAM,eAAe,CAAC;AAE3C,UAAM,IAAI,QAAQ,MAAM;AAAA,IAAC,CAAC;AAAA,EAC5B,CAAC;AAEH,SAAO;AACT;AAEA,eAAsB,KAAK,MAA+B;AACxD,QAAM,UAAU,aAAa;AAC7B,MAAI;AACF,UAAM,QAAQ,WAAW,IAAI;AAAA,EAC/B,SAAS,KAAK;AACZ,QAAI,eAAe,aAAa;AAC9B,cAAQ,MAAM,KAAK,UAAU,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC;AACnD,cAAQ,WAAW;AACnB;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACF;;;AEzZA,MAAM,KAAK,QAAQ,IAAI;","names":[]}
1
+ {"version":3,"sources":["../src/program.ts","../package.json","../src/index.ts"],"sourcesContent":["import { Command } from 'commander';\nimport packageJson from '../package.json';\nimport {\n AdportError,\n AuditLog,\n CredentialStore,\n type AdportRuntime,\n type AnyToolDefinition,\n} from '@adport/core';\n\nexport interface ProgramIO {\n out: (line: string) => void;\n err: (line: string) => void;\n}\n\nconst defaultIO: ProgramIO = {\n out: (line) => console.log(line),\n err: (line) => console.error(line),\n};\n\nfunction json(value: unknown): string {\n return JSON.stringify(value, null, 2);\n}\n\nfunction table(rows: Array<Record<string, unknown>>): string {\n if (rows.length === 0) return '(empty)';\n const keys = Object.keys(rows[0]!);\n const widths = keys.map((k) => Math.max(k.length, ...rows.map((r) => String(r[k] ?? '').length)));\n const line = (values: string[]) => values.map((v, i) => v.padEnd(widths[i]!)).join(' ');\n return [line(keys), line(widths.map((w) => '-'.repeat(w))), ...rows.map((r) => line(keys.map((k) => String(r[k] ?? ''))))].join('\\n');\n}\n\nasync function runtime(includeMock?: boolean): Promise<AdportRuntime> {\n const { assembleRuntime } = await import('@adport/mcp');\n return assembleRuntime({ includeMock });\n}\n\nexport function buildProgram(io: ProgramIO = defaultIO): Command {\n const program = new Command('adport');\n program\n .description('The open control plane for paid media (MCP + CLI)')\n .option('--demo', 'Use synthetic mock accounts and tools (never real provider data)')\n .version(packageJson.version)\n .configureOutput({ writeOut: (s) => io.out(s.trimEnd()), writeErr: (s) => io.err(s.trimEnd()) });\n const commandRuntime = () => runtime(program.opts<{ demo?: boolean }>().demo === true ? true : undefined);\n\n const tools = program.command('tools').description('Inspect and invoke the shared tool registry');\n\n tools\n .command('list')\n .description('List available tools')\n .option('--json', 'JSON output')\n .action(async (opts: { json?: boolean }) => {\n const { registry } = await commandRuntime();\n const defs = registry.list();\n if (opts.json) {\n io.out(\n json(\n defs.map((t: AnyToolDefinition) => ({\n name: t.name,\n namespace: t.namespace,\n readOnly: t.annotations.readOnly ?? false,\n destructive: t.annotations.destructive ?? false,\n })),\n ),\n );\n return;\n }\n io.out(\n table(\n defs.map((t) => ({\n name: t.name,\n namespace: t.namespace,\n mode: t.annotations.readOnly ? 'read' : t.annotations.destructive ? 'DESTRUCTIVE' : 'write',\n })),\n ),\n );\n });\n\n tools\n .command('run <name>')\n .description('Invoke a tool with JSON input (the same tools the MCP server exposes)')\n .option('--input <json>', 'JSON object with the tool arguments', '{}')\n .action(async (name: string, opts: { input: string }) => {\n const rt = await commandRuntime();\n const result = await rt.registry.call(name, JSON.parse(opts.input), rt.ctx);\n io.out(json(result));\n });\n\n program\n .command('accounts')\n .description('List connected ad accounts across providers')\n .option('--provider <id>', 'Limit to one provider')\n .option('--json', 'JSON output')\n .action(async (opts: { provider?: string; json?: boolean }) => {\n const rt = await commandRuntime();\n const result = (await rt.registry.call('accounts_list', { provider: opts.provider }, rt.ctx)) as {\n accounts: Array<Record<string, unknown>>;\n };\n io.out(opts.json ? json(result.accounts) : table(result.accounts));\n });\n\n program\n .command('report')\n .description('Normalized cross-platform performance report')\n .option('--provider <id>', 'Limit to one provider')\n .option('--level <level>', 'account | campaign | ad_group | ad', 'campaign')\n .option('--metrics <list>', 'Comma-separated metrics', 'spend,impressions,clicks,conversions')\n .option('--range <range>', 'Preset (last_7_days, ...) or START..END', 'last_7_days')\n .option('--limit <n>', 'Max rows', '100')\n .option('--json', 'JSON output')\n .action(async (opts: { provider?: string; level: string; metrics: string; range: string; limit: string; json?: boolean }) => {\n const rt = await commandRuntime();\n const dateRange = opts.range.includes('..')\n ? { start: opts.range.split('..')[0]!, end: opts.range.split('..')[1]! }\n : opts.range;\n const result = (await rt.registry.call(\n 'report',\n {\n provider: opts.provider,\n level: opts.level,\n metrics: opts.metrics.split(',').map((m) => m.trim()),\n date_range: dateRange,\n limit: Number(opts.limit),\n },\n rt.ctx,\n )) as { rows: Array<{ provider: string; accountId: string; entity: { name: string; status?: string }; metrics: Record<string, number> }>; truncated: boolean };\n if (opts.json) {\n io.out(json(result));\n return;\n }\n io.out(\n table(\n result.rows.map((r) => ({\n provider: r.provider,\n account: r.accountId,\n entity: r.entity.name,\n status: r.entity.status ?? '',\n ...r.metrics,\n })),\n ),\n );\n if (result.truncated) io.err('(truncated — raise --limit for more rows)');\n });\n\n program\n .command('policy')\n .description('Show the active write policy and where it was loaded from')\n .action(async () => {\n const rt = await commandRuntime();\n io.out(json({ source: rt.policySource, policy: rt.ctx.engine.policy }));\n });\n\n const audit = program.command('audit').description('Inspect or extend the write-audit trail');\n\n audit\n .command('show', { isDefault: true })\n .description('Show recent write-audit entries')\n .option('--limit <n>', 'Max entries', '20')\n .action(async (opts: { limit: string }) => {\n const entries = await new AuditLog().read(Number(opts.limit));\n if (entries.length === 0) {\n io.out('No audit entries yet.');\n return;\n }\n io.out(entries.map((e) => JSON.stringify(e)).join('\\n'));\n });\n\n audit\n .command('export')\n .description('Export write-audit entries to stdout for archival or compliance ingestion')\n .option('--limit <n>', 'Max entries', '10000')\n .option('--format <format>', 'jsonl | json', 'jsonl')\n .action(async (opts: { limit: string; format: string }) => {\n const limit = Number(opts.limit);\n if (!Number.isInteger(limit) || limit < 1) {\n throw new AdportError('INVALID_INPUT', '--limit must be a positive integer');\n }\n if (opts.format !== 'jsonl' && opts.format !== 'json') {\n throw new AdportError('INVALID_INPUT', '--format must be jsonl or json');\n }\n const entries = await new AuditLog().read(limit);\n io.out(opts.format === 'json' ? json(entries) : entries.map((e) => JSON.stringify(e)).join('\\n'));\n });\n\n audit\n .command('run')\n .description('Run the audit rule packs over connected accounts and persist findings')\n .option('--provider <id>', 'Limit to one provider')\n .option('--range <range>', 'Preset or START..END', 'last_30_days')\n .action(async (opts: { provider?: string; range: string }) => {\n const rt = await commandRuntime();\n const dateRange = opts.range.includes('..')\n ? { start: opts.range.split('..')[0]!, end: opts.range.split('..')[1]! }\n : opts.range;\n const result = (await rt.registry.call(\n 'audit_run',\n { provider: opts.provider, date_range: dateRange },\n rt.ctx,\n )) as { findings: Array<{ id: string; severity: string; title: string }>; counts: Record<string, number>; evaluatedAccounts: number };\n io.out(`Evaluated ${result.evaluatedAccounts} account(s): ${result.counts.critical} critical, ${result.counts.warn} warn, ${result.counts.info} info`);\n for (const finding of result.findings) {\n io.out(` [${finding.severity.toUpperCase()}] ${finding.id}\\n ${finding.title}`);\n }\n if (result.findings.length > 0) io.out('Next: adport recommendations · adport recommendations apply <id>');\n });\n\n audit\n .command('note <text>')\n .description('Record an external/manual change in the audit trail (e.g. a change made in the platform UI)')\n .option('--provider <id>', 'Provider the change concerns', 'external')\n .option('--account <id>', 'Account id the change concerns', '-')\n .action(async (text: string, opts: { provider: string; account: string }) => {\n await new AuditLog().append({\n event: 'note',\n provider: opts.provider,\n tool: 'audit_note',\n accountId: opts.account,\n summary: text,\n });\n io.out('Noted.');\n });\n\n program\n .command('connect <provider>')\n .description('Connect an ad account (guided wizard)')\n .option('--no-browser', 'Print auth URLs instead of opening a browser')\n .action(async (provider: string, opts: { browser: boolean }) => {\n if (provider === 'google') {\n const { connectGoogle } = await import('./connect/google.js');\n await connectGoogle({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'meta') {\n const { connectMeta } = await import('./connect/meta.js');\n await connectMeta({ io });\n return;\n }\n if (provider === 'tiktok') {\n const { connectTikTok } = await import('./connect/tiktok.js');\n await connectTikTok({ io });\n return;\n }\n if (provider === 'apple') {\n const { connectApple } = await import('./connect/apple.js');\n await connectApple({ io });\n return;\n }\n if (provider === 'microsoft') {\n const { connectMicrosoft } = await import('./connect/microsoft.js');\n await connectMicrosoft({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'reddit') {\n const { connectReddit } = await import('./connect/reddit.js');\n await connectReddit({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'snapchat') {\n const { connectSnapchat } = await import('./connect/snapchat.js');\n await connectSnapchat({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'spotify') {\n const { connectSpotify } = await import('./connect/spotify.js');\n await connectSpotify({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'pinterest') {\n const { connectPinterest } = await import('./connect/pinterest.js');\n await connectPinterest({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'linkedin') {\n const { connectLinkedIn } = await import('./connect/linkedin.js');\n await connectLinkedIn({ openBrowser: opts.browser, io });\n return;\n }\n if (provider === 'mock') {\n io.out('The mock provider is explicit demo mode, not a connection. Try: adport --demo accounts');\n return;\n }\n if (provider === 'x') {\n const { connectX } = await import('./connect/x.js');\n await connectX({ openBrowser: opts.browser, io });\n return;\n }\n io.err(`Provider \"${provider}\" is not supported. Available: google, meta, tiktok, apple, microsoft, reddit, snapchat, spotify, pinterest, linkedin, x, mock.`);\n process.exitCode = 1;\n });\n\n program\n .command('disconnect <provider>')\n .description('Remove a provider connection from this machine')\n .action(async (provider: string) => {\n if (!['google', 'meta', 'tiktok', 'apple', 'microsoft', 'reddit', 'snapchat', 'spotify', 'pinterest', 'linkedin', 'x'].includes(provider)) {\n io.err(`Provider \"${provider}\" is not supported. Available: google, meta, tiktok, apple, microsoft, reddit, snapchat, spotify, pinterest, linkedin, x.`);\n process.exitCode = 1;\n return;\n }\n const removed = await new CredentialStore().delete(provider);\n if (!removed) {\n io.out(`No local ${provider} credentials were stored.`);\n return;\n }\n io.out(`Removed local ${provider} credentials.`);\n io.out('Provider-side access was not revoked. Revoke the token or key at the provider if needed.');\n });\n\n const recommendations = program.command('recommendations').description('Review and act on audit findings');\n\n recommendations\n .command('list', { isDefault: true })\n .description('List findings (default: open), most severe first')\n .option('--status <status>', 'open | dismissed | applied', 'open')\n .option('--json', 'JSON output')\n .action(async (opts: { status: string; json?: boolean }) => {\n const rt = await commandRuntime();\n const result = (await rt.registry.call('recommendations_list', { status: opts.status }, rt.ctx)) as {\n findings: Array<{ id: string; severity: string; title: string; recommendation: string; proposedAction?: unknown }>;\n };\n if (opts.json) {\n io.out(json(result.findings));\n return;\n }\n if (result.findings.length === 0) {\n io.out(`No ${opts.status} findings. Run: adport audit run`);\n return;\n }\n for (const f of result.findings) {\n io.out(`[${f.severity.toUpperCase()}] ${f.id}`);\n io.out(` ${f.title}`);\n io.out(` → ${f.recommendation}${f.proposedAction ? ' (has ready-to-apply action)' : ''}`);\n }\n });\n\n recommendations\n .command('apply <findingId>')\n .description('Run a finding\\'s proposed action through the two-step validate→apply flow')\n .option('--pending <id>', 'pending_operation_id from the validation step')\n .action(async (findingId: string, opts: { pending?: string }) => {\n const rt = await commandRuntime();\n const result = await rt.registry.call(\n 'recommendation_apply',\n { finding_id: findingId, pending_operation_id: opts.pending },\n rt.ctx,\n );\n io.out(json(result));\n });\n\n recommendations\n .command('dismiss <findingId>')\n .description('Dismiss a finding (never reopened by future runs)')\n .action(async (findingId: string) => {\n const rt = await commandRuntime();\n const result = await rt.registry.call('recommendation_dismiss', { finding_id: findingId }, rt.ctx);\n io.out(json(result));\n });\n\n program\n .command('doctor')\n .description('Check credential and connection health for every provider')\n .action(async () => {\n const store = new CredentialStore();\n const records = await store.list();\n const rt = await commandRuntime();\n io.out(`policy: ${rt.policySource}`);\n io.out(`providers loaded: ${rt.ctx.providers.list().map((p) => p.id).join(', ') || '(none)'}`);\n for (const record of records) {\n io.out(`${record.provider}: credentials stored (source: ${record.source}, updated ${record.updatedAt})`);\n }\n for (const id of ['google', 'meta', 'tiktok', 'apple', 'microsoft', 'reddit', 'snapchat', 'spotify', 'pinterest', 'linkedin', 'x'] as const) {\n const provider = rt.ctx.providers.list().find((p) => p.id === id);\n if (!provider) {\n io.out(`${id}: not connected (run \\`adport connect ${id}\\`)`);\n continue;\n }\n try {\n const accounts = await provider.listAccounts();\n io.out(`${id}: OK — ${accounts.length} accessible account(s)`);\n } catch (err) {\n io.err(`${id}: FAILED — ${err instanceof Error ? err.message : String(err)}`);\n process.exitCode = 1;\n }\n }\n });\n\n program\n .command('mcp')\n .description('Start the adport MCP server on stdio')\n .action(async () => {\n const { runStdioServer } = await import('@adport/mcp');\n await runStdioServer(await commandRuntime());\n // Keep the process alive for the stdio transport.\n await new Promise(() => {});\n });\n\n return program;\n}\n\nexport async function main(argv: string[]): Promise<void> {\n const program = buildProgram();\n try {\n await program.parseAsync(argv);\n } catch (err) {\n if (err instanceof AdportError) {\n console.error(JSON.stringify(err.toJSON(), null, 2));\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n","{\n \"name\": \"adport\",\n \"version\": \"0.7.0\",\n \"description\": \"adport CLI — the open control plane for paid media\",\n \"license\": \"Apache-2.0\",\n \"type\": \"module\",\n \"bin\": {\n \"adport\": \"./dist/index.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/index.ts --format esm --sourcemap --clean\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist\"\n },\n \"dependencies\": {\n \"@adport/core\": \"workspace:*\",\n \"@adport/mcp\": \"workspace:*\",\n \"@adport/provider-apple\": \"workspace:*\",\n \"@adport/provider-google\": \"workspace:*\",\n \"@adport/provider-meta\": \"workspace:*\",\n \"@adport/provider-microsoft\": \"workspace:*\",\n \"@adport/provider-reddit\": \"workspace:*\",\n \"@adport/provider-snapchat\": \"workspace:*\",\n \"@adport/provider-spotify\": \"workspace:*\",\n \"@adport/provider-pinterest\": \"workspace:*\",\n \"@adport/provider-linkedin\": \"workspace:*\",\n \"@adport/provider-x\": \"workspace:*\",\n \"@adport/provider-tiktok\": \"workspace:*\",\n \"commander\": \"^13.0.0\",\n \"yaml\": \"^2.6.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.1.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.8.0\",\n \"vitest\": \"^4.1.10\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/ynnickw/adport.git\",\n \"directory\": \"packages/cli\"\n },\n \"homepage\": \"https://github.com/ynnickw/adport#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/ynnickw/adport/issues\"\n },\n \"engines\": {\n \"node\": \">=22.13\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","#!/usr/bin/env node\nimport { main } from './program.js';\n\nawait main(process.argv);\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA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AK,QAAQ,IAAI;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adport",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "adport CLI — the open control plane for paid media",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -14,19 +14,19 @@
14
14
  "commander": "^13.0.0",
15
15
  "yaml": "^2.6.0",
16
16
  "zod": "^4.4.3",
17
- "@adport/core": "0.6.0",
18
- "@adport/mcp": "0.6.0",
19
- "@adport/provider-apple": "0.6.0",
20
- "@adport/provider-meta": "0.6.0",
21
- "@adport/provider-google": "0.6.0",
22
- "@adport/provider-microsoft": "0.6.0",
23
- "@adport/provider-reddit": "0.6.0",
24
- "@adport/provider-snapchat": "0.6.0",
25
- "@adport/provider-spotify": "0.6.0",
26
- "@adport/provider-pinterest": "0.6.0",
27
- "@adport/provider-linkedin": "0.6.0",
28
- "@adport/provider-tiktok": "0.6.0",
29
- "@adport/provider-x": "0.6.0"
17
+ "@adport/core": "0.7.0",
18
+ "@adport/mcp": "0.7.0",
19
+ "@adport/provider-google": "0.7.0",
20
+ "@adport/provider-apple": "0.7.0",
21
+ "@adport/provider-meta": "0.7.0",
22
+ "@adport/provider-microsoft": "0.7.0",
23
+ "@adport/provider-reddit": "0.7.0",
24
+ "@adport/provider-spotify": "0.7.0",
25
+ "@adport/provider-snapchat": "0.7.0",
26
+ "@adport/provider-linkedin": "0.7.0",
27
+ "@adport/provider-x": "0.7.0",
28
+ "@adport/provider-tiktok": "0.7.0",
29
+ "@adport/provider-pinterest": "0.7.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.1.2",
@@ -34,6 +34,21 @@
34
34
  "typescript": "^5.8.0",
35
35
  "vitest": "^4.1.10"
36
36
  },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/ynnickw/adport.git",
40
+ "directory": "packages/cli"
41
+ },
42
+ "homepage": "https://github.com/ynnickw/adport#readme",
43
+ "bugs": {
44
+ "url": "https://github.com/ynnickw/adport/issues"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.13"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
37
52
  "scripts": {
38
53
  "build": "tsup src/index.ts --format esm --sourcemap --clean",
39
54
  "test": "vitest run",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/connect/google.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport readline from 'node:readline/promises';\nimport YAML from 'yaml';\nimport { CredentialStore } from '@adport/core';\nimport { GoogleAdsRestClient, type GoogleCredentials } from '@adport/provider-google';\nimport type { ProgramIO } from '../program.js';\nimport {\n buildGoogleAuthUrl,\n exchangeCodeForTokens,\n generateOAuthState,\n generatePkce,\n openInBrowser,\n parseClientSecretJson,\n startLoopbackServer,\n} from './oauth.js';\nimport { printLocalConnectionIntro, printLocalConnectionSaved } from './local.js';\n\nexport interface ConnectGoogleOptions {\n openBrowser: boolean;\n io: ProgramIO;\n}\n\n/**\n * Guided Google Ads connection. Since Google's Explorer access tier (Oct 2025),\n * a fresh developer token works on production accounts the same day — the wizard's\n * job is navigation, not waiting.\n */\nexport async function connectGoogle({ openBrowser, io }: ConnectGoogleOptions): Promise<void> {\n const rl = readline.createInterface({ input: process.stdin, output: process.stdout });\n const store = new CredentialStore();\n try {\n printLocalConnectionIntro(io, 'Google Ads');\n io.out('Google may show \"Google has not verified this app\" for a private/unverified');\n io.out('OAuth project. The developer shown will be your project contact. That warning');\n io.out('is expected for BYO personal use; a verified Adport screen is Cloud-only.');\n io.out('');\n // Re-auth fast path: keep the stored developer token + OAuth client and\n // only redo the browser consent (covers expired/revoked refresh tokens).\n const existing = await store.get('google');\n if (existing?.data.developer_token && existing.data.client_id && existing.data.client_secret) {\n const answer = (\n await rl.question(\n 'Existing Google connection found. Re-authorize with the same developer token and OAuth client? [Y/n] ',\n )\n )\n .trim()\n .toLowerCase();\n if (answer !== 'n' && answer !== 'no') {\n const refreshToken = await runOAuthFlow(\n existing.data.client_id,\n existing.data.client_secret,\n openBrowser,\n io,\n );\n await verifyAndSave(\n {\n developerToken: existing.data.developer_token,\n clientId: existing.data.client_id,\n clientSecret: existing.data.client_secret,\n refreshToken,\n loginCustomerId: existing.data.login_customer_id || undefined,\n },\n store,\n io,\n );\n return;\n }\n }\n\n io.out('Connecting Google Ads. You need (the wizard guides each step):');\n io.out(' 1. A manager account (MCC) — free, instant: https://ads.google.com/home/tools/manager-accounts/');\n io.out(' 2. A developer token from the MCC API Center (Explorer access is automatic): https://ads.google.com/aw/apicenter');\n io.out(' 3. A Google Cloud OAuth \"Desktop app\" client: https://console.cloud.google.com/apis/credentials');\n io.out(' Enable Google Ads API; choose External; add yourself as a test user.');\n io.out(' Suggested private app name: \"Adport Local – <your organization>\".');\n io.out('');\n\n // Fast path: import an existing google-ads.yaml (the ecosystem convention).\n const imported = await tryImportGoogleAdsYaml(rl, io);\n let creds: GoogleCredentials;\n if (imported) {\n creds = imported;\n } else {\n const developerToken = (await rl.question('Developer token (from the MCC API Center): ')).trim();\n\n let clientId = '';\n let clientSecret = '';\n const secretPath = (\n await rl.question('Path to downloaded client_secret_*.json (or press Enter to type id/secret manually): ')\n ).trim();\n if (secretPath) {\n const parsed = parseClientSecretJson(await fs.readFile(expandHome(secretPath), 'utf8'));\n clientId = parsed.clientId;\n clientSecret = parsed.clientSecret;\n } else {\n clientId = (await rl.question('OAuth client id: ')).trim();\n clientSecret = (await rl.question('OAuth client secret: ')).trim();\n }\n\n if (!developerToken || !clientId || !clientSecret) {\n io.err('Missing developer token or OAuth client credentials — aborting.');\n process.exitCode = 1;\n return;\n }\n\n const loginCustomerId =\n (await rl.question('Manager (MCC) customer id for login-customer-id (Enter to skip): ')).trim() || undefined;\n\n const refreshToken = await runOAuthFlow(clientId, clientSecret, openBrowser, io);\n creds = { developerToken, clientId, clientSecret, refreshToken, loginCustomerId };\n }\n\n await verifyAndSave(creds, store, io);\n } finally {\n rl.close();\n }\n}\n\nasync function runOAuthFlow(\n clientId: string,\n clientSecret: string,\n openBrowser: boolean,\n io: ProgramIO,\n): Promise<string> {\n io.out('');\n io.out('Starting the OAuth flow (scope: Google Ads). A browser window should open;');\n io.out('sign in with the Google account that can access your ad accounts.');\n const pkce = generatePkce();\n const state = generateOAuthState();\n const loopback = await startLoopbackServer('127.0.0.1', state);\n const authUrl = buildGoogleAuthUrl(clientId, loopback.redirectUri, pkce.challenge, state);\n if (openBrowser) {\n openInBrowser(authUrl);\n io.out(`If the browser did not open, visit:\\n ${authUrl}`);\n } else {\n io.out(`Open this URL in a browser on this machine (or SSH port-forward the shown port):\\n ${authUrl}`);\n }\n try {\n const code = await loopback.waitForCode;\n const tokens = await exchangeCodeForTokens({\n clientId,\n clientSecret,\n code,\n redirectUri: loopback.redirectUri,\n codeVerifier: pkce.verifier,\n });\n return tokens.refreshToken;\n } finally {\n loopback.close();\n }\n}\n\nasync function verifyAndSave(creds: GoogleCredentials, store: CredentialStore, io: ProgramIO): Promise<void> {\n io.out('Verifying access…');\n const client = new GoogleAdsRestClient(creds);\n const customers = await client.listAccessibleCustomers();\n await store.set({\n provider: 'google',\n source: 'byo',\n data: {\n developer_token: creds.developerToken,\n client_id: creds.clientId,\n client_secret: creds.clientSecret,\n refresh_token: creds.refreshToken,\n ...(creds.loginCustomerId ? { login_customer_id: creds.loginCustomerId } : {}),\n },\n });\n io.out('');\n io.out(`✓ Connected. ${customers.length} accessible customer id(s): ${customers.join(', ')}`);\n printLocalConnectionSaved(io);\n io.out('');\n io.out('If this token expires again in ~7 days: your OAuth consent screen is in \"Testing\"');\n io.out('status — set it to \"In production\" at console.cloud.google.com/apis/credentials/consent');\n io.out('(no verification needed for your own use; refresh tokens then stop expiring weekly).');\n io.out('');\n io.out('Try: adport accounts · adport report --provider google · adport mcp');\n}\n\nasync function tryImportGoogleAdsYaml(\n rl: readline.Interface,\n io: ProgramIO,\n): Promise<GoogleCredentials | undefined> {\n const candidates = [\n process.env.GOOGLE_ADS_CONFIGURATION_FILE_PATH,\n path.join(os.homedir(), 'google-ads.yaml'),\n ].filter((p): p is string => Boolean(p));\n for (const candidate of candidates) {\n let raw: string;\n try {\n raw = await fs.readFile(candidate, 'utf8');\n } catch {\n continue;\n }\n const parsed = YAML.parse(raw) as Record<string, unknown> | null;\n const developerToken = str(parsed?.developer_token);\n const clientId = str(parsed?.client_id);\n const clientSecret = str(parsed?.client_secret);\n const refreshToken = str(parsed?.refresh_token);\n if (!developerToken || !clientId || !clientSecret || !refreshToken) continue;\n const answer = (await rl.question(`Found ${candidate} — import it? [Y/n] `)).trim().toLowerCase();\n if (answer === 'n' || answer === 'no') continue;\n io.out(`Importing credentials from ${candidate}.`);\n return {\n developerToken,\n clientId,\n clientSecret,\n refreshToken,\n loginCustomerId: str(parsed?.login_customer_id) || undefined,\n };\n }\n return undefined;\n}\n\nfunction str(value: unknown): string {\n return value === undefined || value === null ? '' : String(value);\n}\n\nfunction expandHome(p: string): string {\n return p.startsWith('~/') ? path.join(os.homedir(), p.slice(2)) : p;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,SAAS,uBAAuB;AAChC,SAAS,2BAAmD;AAuB5D,eAAsB,cAAc,EAAE,aAAa,GAAG,GAAwC;AAC5F,QAAM,KAAK,SAAS,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AACpF,QAAM,QAAQ,IAAI,gBAAgB;AAClC,MAAI;AACF,8BAA0B,IAAI,YAAY;AAC1C,OAAG,IAAI,6EAA6E;AACpF,OAAG,IAAI,+EAA+E;AACtF,OAAG,IAAI,2EAA2E;AAClF,OAAG,IAAI,EAAE;AAGT,UAAM,WAAW,MAAM,MAAM,IAAI,QAAQ;AACzC,QAAI,UAAU,KAAK,mBAAmB,SAAS,KAAK,aAAa,SAAS,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