// Console steps without an API, agent-first (`storebound console plan
--json`, offline): the start page (a // deep link when the ids are known), the steps in order with what to click, the answer sheet from the config (certain, // ask the owner, owner check), the buttons never to press and the final one that stays the owner's, then a read-only // check of the result (`console verify `: the page text pasted here, or the App Store Connect API for the app // record and the age rating). Nothing here clicks in a console: the owner's AI agent (or the owner) drives the page // with this plan, `Copy plan` hands it over as JSON; "Fill in console" (ui/ConsoleFill.tsx) is the scripted fast path // where it exists. Every form of `console plan`, including the Play pages added for the first production release. import { failureText } from '../lib/results'; import { type KeyboardEvent, useEffect, useRef, useState } from 'react'; import { api, errorText, newJob, type Project, type ToolResult } from '../api'; import { type Key, t } from '../i18n'; import { useData } from '../store'; import { Icon, StoreGlyph } from './icons'; import { Chip, Notice } from './kit'; /** The forms of `console plan` (cli/mcp-tools.ts CONSOLE_PLAN_FORMS). */ export type PlanForm = 'apple-app-record' | 'apple-age-rating' | 'apple-app-privacy' | 'play-app-record' | 'play-content-rating' | 'play-target-audience' | 'play-store-settings' | 'play-app-content' | 'play-privacy-policy' | 'play-ads' | 'play-sign-in-details' | 'play-advertising-id' | 'play-government-apps' | 'play-financial-features' | 'play-health-apps' | 'play-production-countries' | 'play-production-release'; /** `console plan --json` (cli/lib/console-plan.ts ConsolePlan), the parts shown here. */ export interface Plan { form: PlanForm; store: 'apple' | 'play'; title: string; start: { url: string; deepLink: boolean; reach: string[] }; steps: { n: number; text: string; click?: string[] }[]; answers: { id: string; question: string; text: string; status: string; label?: string; note?: string }[]; askOwner: string[]; buttons: { neverPress: string[]; final: string }; } /** `console verify --json` (cli/lib/console-verify.ts VerifyResult). */ export interface VerifyResult { form: PlanForm; rows: { item: string; expected: string; seen: string; status: string }[]; mismatches: number; matched: number; ok: boolean; notes: string[] } /** Every form `console plan` knows, with its name and one line (cli/mcp-tools.ts CONSOLE_PLAN_FORMS). */ export const PLAN_FORMS: { form: PlanForm; store: 'apple' | 'play'; name: Key; text: Key }[] = [ { form: 'apple-app-record', store: 'apple', name: 'cf.appleAppRecord', text: 'cp.appleAppRecordText' }, { form: 'apple-age-rating', store: 'apple', name: 'cf.appleAgeRating', text: 'cp.appleAgeRatingText' }, { form: 'apple-app-privacy', store: 'apple', name: 'cf.appleAppPrivacy', text: 'cp.appleAppPrivacyText' }, { form: 'play-app-record', store: 'play', name: 'cf.playAppRecord', text: 'cf.playAppRecordText' }, { form: 'play-store-settings', store: 'play', name: 'cp.playStoreSettings', text: 'cp.playStoreSettingsText' }, { form: 'play-app-content', store: 'play', name: 'cp.playAppContent', text: 'cp.playAppContentText' }, { form: 'play-privacy-policy', store: 'play', name: 'cp.playPrivacyPolicy', text: 'cp.cardText' }, { form: 'play-ads', store: 'play', name: 'cp.playAds', text: 'cp.cardText' }, { form: 'play-sign-in-details', store: 'play', name: 'cp.playSignIn', text: 'cp.playSignInText' }, { form: 'play-advertising-id', store: 'play', name: 'cp.playAdId', text: 'cp.cardText' }, { form: 'play-government-apps', store: 'play', name: 'cp.playGovernment', text: 'cp.cardText' }, { form: 'play-financial-features', store: 'play', name: 'cp.playFinancial', text: 'cp.cardText' }, { form: 'play-health-apps', store: 'play', name: 'cp.playHealth', text: 'cp.cardText' }, { form: 'play-content-rating', store: 'play', name: 'cf.playContentRating', text: 'cf.playContentRatingText' }, { form: 'play-target-audience', store: 'play', name: 'cf.playTargetAudience', text: 'cf.playTargetAudienceText' }, { form: 'play-production-countries', store: 'play', name: 'cp.playCountries', text: 'cp.playCountriesText' }, { form: 'play-production-release', store: 'play', name: 'cp.playProductionRelease', text: 'cp.playProductionReleaseText' }, ]; const nameOf = (form: PlanForm): string => t(PLAN_FORMS.find(f => f.form === form)?.name ?? 'cp.title'); /** Forms whose result `console verify` reads from the App Store Connect API (no page text needed). */ const API_VERIFY = new Set(['apple-app-record', 'apple-age-rating']); const STATUS: Record = { certain: ['ok', 'cp.sCertain'], 'ask-owner': ['warn', 'cp.sAsk'], 'owner-check': ['info', 'cp.sCheck'], agreement: ['bad', 'cp.sAgreement'] }; const ROW: Record = { match: ['ok', 'cp.vMatch'], mismatch: ['bad', 'cp.vMismatch'], 'not-found': ['warn', 'cp.vNotFound'], 'ask-owner': ['warn', 'cp.sAsk'] }; export function ConsolePlanButton({ project, form, primary, label }: { project: Project; form: PlanForm; primary?: boolean; label?: string }) { const d = useData(); const [plan, setPlan] = useState(null); const [busy, setBusy] = useState(false); const open = async () => { setBusy(true); try { const r = await api.call('console.plan', project.id, { args: { form } }, newJob('console.plan')); if (!r.ok || !r.data) d.toast({ kind: 'bad', title: t('cp.failed', { form: nameOf(form) }), detail: failureText(r) }); else setPlan(r.data); } catch (e) { d.toast({ kind: 'bad', title: t('cp.failed', { form: nameOf(form) }), detail: errorText(e) }); } finally { setBusy(false); } }; return ( <> {plan && setPlan(null)} />} ); } function PlanPanel({ project, plan, onClose }: { project: Project; plan: Plan; onClose: () => void }) { const d = useData(); const root = useRef(null); const [text, setText] = useState(''); const [verify, setVerify] = useState<{ busy: boolean; result?: VerifyResult; error?: string }>({ busy: false }); useEffect(() => { root.current?.focus(); }, []); const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') { e.preventDefault(); onClose(); } }; const apiVerify = API_VERIFY.has(plan.form); const check = async () => { setVerify({ busy: true }); try { const r = await api.call('console.verify', project.id, { args: { form: plan.form, ...(text.trim() ? { text: text.trim() } : {}) } }, newJob('console.verify')); if (r.data) setVerify({ busy: false, result: r.data }); else setVerify({ busy: false, error: failureText(r) }); } catch (e) { setVerify({ busy: false, error: errorText(e) }); } }; const copy = () => { navigator.clipboard?.writeText(JSON.stringify(plan, null, 2)).then(() => d.toast({ kind: 'ok', title: t('cp.copied') }), () => {}); }; const asks = plan.answers.filter(a => a.status !== 'certain'); return (
{ if (e.target === e.currentTarget) onClose(); }}>

{plan.title}

{t('cp.agentFirst')}
api.openExternal(plan.start.url).catch(e => d.toast({ kind: 'bad', title: t('cp.openFailed'), detail: errorText(e) }))}>{t('cp.openPage')}}>
{plan.start.url} {plan.start.reach.length > 0 && {plan.start.reach.join(' > ')}}
{t('cp.steps', { count: plan.steps.length })}
    {plan.steps.map(s => (
  1. {s.text}{s.click && s.click.length > 0 && {s.click.map((c, i) => {c})}}
  2. ))}
{plan.answers.length > 0 && (
{t('cp.answers', { count: plan.answers.length })}{asks.length > 0 && {t('cf.uncertain', { count: asks.length })}}
{plan.answers.map(a => { const [tone, key] = STATUS[a.status] ?? STATUS['ask-owner']!; return ( ); })}
{a.label ?? a.question}
{a.note &&
{a.note}
}
{a.status === 'certain' ? {a.text} : {a.text}} {t(key)}
)}
{t('cp.final', { button: plan.buttons.final || '—' })} {plan.buttons.neverPress.slice(0, 14).map(b => {b})}
{t('cp.verify')} {apiVerify ? t('cp.verifyApi') : t('cp.verifyText')} {!apiVerify &&