serve --stdio: desktop JSON-RPC profile on the MCP core, confirm tokens, --json results, sidecar builds
- cli/serve.ts: session.hello with a per-session secret, typed methods per tool, project.inspect, portfolio.status over many project folders, progress notifications, cancellation - cli/lib/confirm-token.ts: single-use HMAC tokens bound to method + canonical params + expiry; writes are dry runs without one; no submit / release / publish method exists - cli/lib/runner.ts: shared child runner for mcp and serve, works from a compiled binary - --json on check, testflight / ppo status, next-build, next-version-code, analytics compare, prices import; inspect command; confirm() always answers no under serve - tools/build-sidecars.ts: bun build --compile for five targets, ad-hoc re-sign on macOS, path leak check - tests/serve.test.ts: methods, token binding / expiry / replay, shared vector, stdio and compiled smoke
This commit is contained in:
parent
c6360812b8
commit
3454a9aadb
28 changed files with 1048 additions and 42 deletions
99
cli/lib/desktop-protocol.ts
Normal file
99
cli/lib/desktop-protocol.ts
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
// 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;
|
||||
kind: 'read' | 'write' | 'session' | 'system' | 'portfolio';
|
||||
/** 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<string, JsonSchemaLite>; 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<string, unknown>;
|
||||
/** 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;
|
||||
products: number;
|
||||
shots: boolean;
|
||||
testflightGroups: number;
|
||||
}
|
||||
|
||||
export interface PortfolioParams { projects: string[]; live?: boolean; credentials?: Credentials }
|
||||
|
||||
export interface PortfolioEntry {
|
||||
project: string;
|
||||
ok: boolean;
|
||||
summary: ProjectSummary | null;
|
||||
check: { ok: boolean; problems: string[]; warnings: string[] } | null;
|
||||
/** live only: `apple status --json` / `play status --json` data, or the error text. */
|
||||
apple?: { data?: unknown; error?: string };
|
||||
play?: { data?: unknown; error?: string };
|
||||
errors: string[];
|
||||
}
|
||||
|
||||
export interface PortfolioResult { projects: PortfolioEntry[]; at: string }
|
||||
Loading…
Add table
Add a link
Reference in a new issue