/** * Build, boot, install, and launch an iOS app on the iOS Simulator with * `MallocStackLogging=1` (and any caller-supplied env vars) applied. Returns * the host PID + simulator UDID + bundle id ready to chain into * `captureMemgraph`. * * Why this exists: `leaks --outputGraph` regressed on macOS 26.x and aborts * with `Failed to get DYLD info for task` when the target was not launched * with malloc-stack-logging in its environment. Capturing a memgraph after * the fact does not work; the env vars must be set at launch. This tool * gives users a single MCP call that produces a leak-investigable process * without requiring them to wire up xcodebuild + simctl manually. * * Out of scope: UI driving (Phase 3), composite snapshots (Phase 3), physical * iOS devices (`leaks --outputGraph` does not support them). */ import { z } from "zod"; import type { NextCallSuggestion } from "../types.js"; import { type PlatformAdvisory } from "../runtime/platformCheck.js"; export declare const bootAndLaunchForLeakInvestigationShape: { readonly workspace: z.ZodOptional; readonly project: z.ZodOptional; readonly scheme: z.ZodString; readonly configuration: z.ZodDefault; readonly bundleId: z.ZodOptional; readonly derivedDataPath: z.ZodOptional; readonly simulator: z.ZodOptional; name: z.ZodOptional; os: z.ZodOptional; }, "strip", z.ZodTypeAny, { name?: string | undefined; udid?: string | undefined; os?: string | undefined; }, { name?: string | undefined; udid?: string | undefined; os?: string | undefined; }>>; readonly envVars: z.ZodOptional>; readonly launchArgs: z.ZodDefault>; readonly buildBeforeLaunch: z.ZodDefault; readonly warmupSeconds: z.ZodDefault; }; export declare const bootAndLaunchForLeakInvestigationSchema: z.ZodEffects; readonly project: z.ZodOptional; readonly scheme: z.ZodString; readonly configuration: z.ZodDefault; readonly bundleId: z.ZodOptional; readonly derivedDataPath: z.ZodOptional; readonly simulator: z.ZodOptional; name: z.ZodOptional; os: z.ZodOptional; }, "strip", z.ZodTypeAny, { name?: string | undefined; udid?: string | undefined; os?: string | undefined; }, { name?: string | undefined; udid?: string | undefined; os?: string | undefined; }>>; readonly envVars: z.ZodOptional>; readonly launchArgs: z.ZodDefault>; readonly buildBeforeLaunch: z.ZodDefault; readonly warmupSeconds: z.ZodDefault; }, "strip", z.ZodTypeAny, { scheme: string; configuration: string; launchArgs: string[]; buildBeforeLaunch: boolean; warmupSeconds: number; workspace?: string | undefined; project?: string | undefined; simulator?: { name?: string | undefined; udid?: string | undefined; os?: string | undefined; } | undefined; bundleId?: string | undefined; derivedDataPath?: string | undefined; envVars?: Record | undefined; }, { scheme: string; workspace?: string | undefined; project?: string | undefined; simulator?: { name?: string | undefined; udid?: string | undefined; os?: string | undefined; } | undefined; bundleId?: string | undefined; configuration?: string | undefined; derivedDataPath?: string | undefined; envVars?: Record | undefined; launchArgs?: string[] | undefined; buildBeforeLaunch?: boolean | undefined; warmupSeconds?: number | undefined; }>, { scheme: string; configuration: string; launchArgs: string[]; buildBeforeLaunch: boolean; warmupSeconds: number; workspace?: string | undefined; project?: string | undefined; simulator?: { name?: string | undefined; udid?: string | undefined; os?: string | undefined; } | undefined; bundleId?: string | undefined; derivedDataPath?: string | undefined; envVars?: Record | undefined; }, { scheme: string; workspace?: string | undefined; project?: string | undefined; simulator?: { name?: string | undefined; udid?: string | undefined; os?: string | undefined; } | undefined; bundleId?: string | undefined; configuration?: string | undefined; derivedDataPath?: string | undefined; envVars?: Record | undefined; launchArgs?: string[] | undefined; buildBeforeLaunch?: boolean | undefined; warmupSeconds?: number | undefined; }>; export type BootAndLaunchForLeakInvestigationInput = z.infer; export type LaunchState = "launched" | "buildFailed" | "installFailed" | "launchFailed" | "pidNotFound" | "noSimulatorAvailable" | "launchNotAllowed"; export interface BootAndLaunchForLeakInvestigationResult { ok: boolean; state: LaunchState; simulatorUDID?: string; pid?: number; bundleId?: string; appName?: string; appPath?: string; appliedEnvVars: Record; steps: string[]; warnings?: string[]; failureReason?: string; suggestedNextCalls?: NextCallSuggestion[]; /** * Present on hosts where a platform-side regression affects the downstream * leak/capture flow this tool prepares for (today: macOS 26.x * `task_for_pid` kernel regression). Surfaced even when boot + launch * succeed, so the caller knows captureMemgraph may still fail with * `minimal-corpse` and which fallback path to try first. */ platformAdvisory?: PlatformAdvisory; } export declare function bootAndLaunchForLeakInvestigation(input: BootAndLaunchForLeakInvestigationInput): Promise; /** * Resolve the host-side PID for an app running inside the target simulator. * * Strategy: list every host process with `ps -Ao pid,command`, then pick lines * whose command path includes the simulator UDID (i.e. lives under * `~/Library/Developer/CoreSimulator/Devices//...`) AND whose path ends * with `/`. This handles two cases natively: * 1. Multi-simulator: filtering by UDID disambiguates from same-named apps in other simulators. * 2. Long executable names: we match on full path, so the 15-char `comm` truncation that breaks `pgrep -x` is irrelevant. * * Returns the PID, or null when nothing matched (the typical reasons: app * still launching, or executable name does not appear in the path because * the user passed a custom override). */ export declare function resolveHostPid(udid: string, executableName: string): Promise; /** Pure: filter `ps` output for the simulator's app process. Exposed for tests. */ export declare function pickHostPidFromPs(psOutput: string, udid: string, executableName: string): number | null;