// Types of the `storebound serve --stdio` protocol (desktop profile). Type-only, no runtime code: the desktop app // (apps/desktop) imports this file so both sides agree on shapes. Newline-delimited JSON-RPC 2.0 on stdio. // // Session: the first request must be `session.hello` with the per-session secret (hex, >= 32 bytes) the host // generated. Every other method answers -32002 before that. One hello per process. // Progress: notifications `progress` { requestId, line?, stream?, n?, total?, project? } while a request runs. // Cancel: notification `$/cancelRequest` { id } (or MCP-style `notifications/cancelled` { requestId }); the request // then answers -32800. // Writes: every write method is a dry run unless `dryRun: false` comes with a `confirmToken` minted by the host for // exactly (method, { project, args }) (cli/lib/confirm-token.ts). No method submits, releases or publishes anything. export const DESKTOP_PROTOCOL = 'storebound-desktop/1'; export const ERR = { parse: -32700, invalidRequest: -32600, methodNotFound: -32601, invalidParams: -32602, internal: -32603, notInitialized: -32002, confirmRequired: -32010, confirmInvalid: -32011, cancelled: -32800, } as const; export interface JsonSchemaLite { type: string; description?: string; enum?: (string | number)[]; default?: unknown; minimum?: number; maximum?: number; pattern?: string } export interface MethodDescriptor { method: string; title: string; description: string; /** owner: a desktop-only write the owner decides (rollout, phased release, sending one reply); always a dry run * unless the host's confirm token comes with it, and then the command's own confirmation is answered by that token. */ kind: 'read' | 'write' | 'session' | 'system' | 'portfolio' | 'account' | 'owner'; /** Talks to a store API or the internet. */ network: boolean; /** Replaces existing data on a store (screenshots, whole forms). */ destructive: boolean; /** Result carries structured `data` (the command's --json output). */ json: boolean; /** Schema of `params.args` (tool methods), or of `params` (other methods). */ args: { type: 'object'; properties: Record; required?: string[]; additionalProperties: false }; } export interface HelloParams { secret: string; client?: { name: string; version: string } } export interface HelloResult { protocol: typeof DESKTOP_PROTOCOL; server: { name: 'storebound'; version: string; compiled: boolean }; methods: MethodDescriptor[] } export interface Credentials { PLAY_SERVICE_ACCOUNT?: string; ASC_KEY_ID?: string; ASC_ISSUER_ID?: string; ASC_P8?: string } export interface ToolParams { /** Absolute path of a folder that contains storebound.config.ts. */ project: string; args?: Record; /** Write methods: false runs for real and needs confirmToken. Default true. */ dryRun?: boolean; confirmToken?: string; /** Per-call credentials (kept in memory, passed to the command's env only). Not part of the token. */ credentials?: Credentials; } export interface ToolResult { method: string; ok: boolean; exitCode: number; dryRun: boolean; /** The CLI line it ran, for logs ("storebound play listing --dry"). */ command: string; /** Text output (log lines), trimmed to the last 60 000 characters. */ output: string; /** Structured result of a --json capable command. */ data?: unknown; } export interface ProgressParams { requestId: string | number; line?: string; stream?: 'stdout' | 'stderr'; n?: number; total?: number; project?: string } export interface ProjectSummary { dir: string; config: string; name: string; languages: string[]; play: { packageName: string } | null; apple: { bundleId: string; appId: string | null } | null; /** app.platforms (default: from the apple / play sections). */ platforms: ('ios' | 'android')[]; /** One-time in-app products in the config (one shared catalog). */ products: number; productIds: string[]; /** Auto-renewable subscriptions in the config (all groups). */ subscriptions: number; subscriptionIds: string[]; /** Product and subscription ids each store should sell (items may be limited to one platform). */ catalog: { ios: string[]; android: string[] }; shots: boolean; testflightGroups: number; /** App profile from the config (app, game, subscription-app). */ profile?: string; /** Absolute path of the app icon the config or the usual places point at (project.icon reads it), or null. */ icon?: string | null; } // ---- App-centric model (one app = one product on up to two platforms; a workspace holds many apps) ---- /** One product across platforms. id = its project folder (one storebound.config.ts per app). */ export interface AppIdentity { id: string; name: string; platforms: { ios: { bundleId: string; ascAppId: string | null } | null; android: { packageName: string } | null }; } /** Where a version is on one store. */ export type ReleasePhase = 'live' | 'rollout' | 'halted' | 'approved' | 'review' | 'rejected' | 'testing' | 'draft' | 'other'; export interface StoreRelease { store: 'ios' | 'android'; version: string | null; /** iOS build number (CFBundleVersion) / highest Android versionCode. */ build: string | null; /** The store's own state word (READY_FOR_SALE, inProgress ...). */ state: string; phase: ReleasePhase; /** Rollout share (0-1): Android staged rollout user fraction, iOS phased release day -> 1, 2, 5, 10, 20, 50, 100 %. */ fraction: number | null; /** Android track (production, beta, internal ...). */ track: string | null; /** iOS phased release: day 1-7 and its state (ACTIVE, PAUSED, COMPLETE); null without one. */ phased?: { state: string; day: number | null } | null; /** When the store record was made (iOS version createdDate), if the store says. */ date?: string | null; } /** A release train: one version (e.g. 2.3.0) across both stores. */ export interface ReleaseTrain { version: string; ios: StoreRelease | null; android: StoreRelease | null } /** In-app catalog parity between the config and both stores. */ export interface CatalogParity { checked: 'config' | 'live'; products: number; subscriptions: number; /** Live: ids on one store only, and config ids missing on a store the app is on. */ onlyIos: string[]; onlyAndroid: string[]; missingIos: string[]; missingAndroid: string[]; ok: boolean; } export interface PortfolioParams { projects: string[]; live?: boolean; credentials?: Credentials } export interface AppStatus { /** Project folder as given. */ project: string; ok: boolean; app: AppIdentity | null; summary: ProjectSummary | null; check: { ok: boolean; problems: string[]; warnings: string[] } | null; /** Release trains; `source: none` offline (no store data read). `all`: every store release read (live only). */ release: { source: 'none' | 'live'; current: ReleaseTrain | null; next: ReleaseTrain | null; all?: StoreRelease[] }; catalog: CatalogParity | null; /** A store-only app read through a generated config (no app folder). */ virtual?: boolean; /** live only: per-platform read errors ("unknown, never false"). */ storeErrors: { ios?: string; android?: string }; errors: string[]; } export interface PortfolioResult { apps: AppStatus[]; at: string } // ---- Offline project reads (D2) ---- /** One listing field of one language on one store: length against the store limit. */ export interface ListingField { field: string; length: number; limit: number; required: boolean; state: 'ok' | 'missing' | 'over' | 'empty-optional' } /** Listing completeness of one language (config language id) on both stores. */ export interface ListingLocale { lang: string; rtl: boolean; play: { code: string | null; fields: ListingField[] } | null; apple: { code: string | null; fields: ListingField[] } | null; /** Rendered screenshots found for this language (renders folder), null when there is no renders folder. */ screenshots: number | null; /** Required fields present and within limits, 0-1 (both stores). */ complete: number; } export interface ListingsResult { files: { play: string | null; apple: string | null }; /** File-level problems (missing file, unreadable section). */ problems: string[]; locales: ListingLocale[]; } /** A local review reply draft (.storebound/replies/-.md) with its checks. */ export interface ReplyDraft { file: string; store: 'apple' | 'play'; reviewId: string; approved: boolean; sent: string | null; reply: string; rating: number | null; title: string | null; body: string | null; date: string | null; issues: { level: 'error' | 'warn'; msg: string }[]; } export interface DraftsResult { dir: string; drafts: ReplyDraft[]; problems: string[] } /** project.icon: the icon as a data: URL (PNG / JPEG / WebP / SVG, at most 1.5 MB), or null. */ export interface IconResult { path: string | null; dataUrl: string | null } // ---- Store accounts and the apps on them (D3: many studios, many accounts) ---- /** One app record on a store, as `storebound apps list` reads it. */ export interface StoreApp { store: 'ios' | 'android'; /** App Store Connect app id (numeric) / Play package name. */ id: string; /** iOS bundle id / Android package name. */ bundleId: string; name: string; /** App Store version platforms (IOS, MAC_OS, TV_OS, VISION_OS); ["ANDROID"] on Play. */ platforms: string[]; sku?: string | null; primaryLocale?: string | null; /** Newest App Store version and its state (App Store only). */ latest?: { version: string; state: string; platform?: string | null } | null; /** 128 px icon as a data: URL (with --icons), else null. */ icon?: string | null; } export interface AppsListResult { store: 'ios' | 'android'; apps: StoreApp[]; warnings: string[]; at: string } /** Health of one store account: does the key work, and can it see apps. */ export interface AccountCheck { store: 'ios' | 'android'; status: 'ok' | 'no-apps' | 'permission' | 'revoked' | 'api-disabled' | 'error'; /** Play: the service account email (to invite in Play Console). Never a secret. */ principal: string | null; apps: number | null; message: string; /** What to do, in words. */ fix: string | null; docs: string | null; } /** * A store-only app (no app folder yet): the sidecar reads it through a generated minimal config (store ids only) in * its temp folder. Read methods only. */ export interface VirtualProject { name: string; apple?: { bundleId: string; appId?: string | null } | null; play?: { packageName: string } | null }