import { type LocalAppResourceScopes, type LocalAppPreviewSnapshot, type MobileAppAccentPreset, type SpaceRecord, type StoreAppCatalogResponse, type StoreAppDetail, type StoreAppRemoveResult } from '@xopcai/gateway-contract'; import { type StoreAppListParams } from './store-catalog.js'; import { LocalAppPreviewSessions } from './preview-sessions.js'; import type { Config } from '../config/schema.js'; import type { ExtensionLoader } from '../extensions/index.js'; import type { ProjectService } from '../projects/index.js'; import { SpacesLayoutStore } from './layout-store.js'; import { SpaceRecordsStore } from './records-store.js'; import { LocalAppStore } from './store.js'; import { LocalAppSnapshotStore } from './snapshot-store.js'; import type { CreateLocalAppInput, LocalApp, LocalAppAcceptanceRun, LocalAppDetail, LocalAppFixGuidance, LocalAppFixGuidanceInput, LocalAppPreviewTarget, LocalAppValidationResult, LocalAppUiGrant, RecordLocalAppAcceptanceInput } from './types.js'; export declare class LocalAppRevisionConflictError extends Error { } export declare class LocalAppAcceptanceValidationError extends Error { } export interface LocalAppServiceOptions { projects: ProjectService; workspaceRoot: string; getConfig: () => Config; saveConfig: (config: Config) => Promise<{ saved: boolean; error?: string; }>; getExtensionLoader: () => ExtensionLoader | null; emit: (type: string, payload: unknown) => void; } export declare class LocalAppService { private readonly options; private readonly store; private readonly snapshots; readonly records: SpaceRecordsStore; readonly layout: SpacesLayoutStore; readonly previews: LocalAppPreviewSessions; constructor(options: LocalAppServiceOptions, store?: LocalAppStore, snapshots?: LocalAppSnapshotStore); private recoveryRoot; private recoveryMarker; /** Reconcile interrupted mutations before any extension code or request can run. */ recoverPendingReleases(): Promise; private recoverReleases; private recoverRelease; private mutateRelease; /** Run a mutation after recovery while holding the release lock. */ private runReleaseMutation; private readWorkspaceIconDataUrl; private readWorkspaceExtras; list(): LocalApp[]; private previewSource; isLocalApp(extensionId: string): boolean; resolveUiAsset(extensionId: string, assetPath: string): string | null | undefined; get(id: string): LocalAppDetail | null; getUiGrant(extensionId: string): LocalAppUiGrant; getCapabilityAccess(extensionId: string, expectedManifestDigest: string, expectedGrantRevision?: string): { releaseId: string; grantRevision: string | undefined; resourceScopes: { notesRead: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; notesWrite: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; tasksRead: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; tasksWrite: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; projectsRead: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; projectsWrite: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; filesRead: { mode: "none"; } | { mode: "selected"; ids: string[]; }; filesExport: boolean; filesImport: boolean; connectors: { mode: "none"; } | { mode: "selected"; bindings: { toolRef: string; connectorId: string; accountId: string; connectionId: string; revision: string; scope: "read" | "write"; }[]; }; automationsRead: { mode: "none"; } | { mode: "workspace"; } | { mode: "selected"; ids: string[]; projectIds: string[]; includeCreated: boolean; }; automationProposals: boolean; automationsRun: { mode: "none"; } | { mode: "selected"; approvals: { id: string; configurationDigest: string; authority: { model: boolean; tools: boolean; dataWrite: boolean; externalSend: boolean; expiresAt: number; maxRuns: number; maxCostMicrousd: number; }; }[]; }; agentDelegate: boolean; }; bindings: { id: "xopc.notes.get" | "xopc.notes.list" | "xopc.tasks.get" | "xopc.tasks.list" | "xopc.notes.create" | "xopc.notes.update" | "xopc.notes.append" | "xopc.agent.delegate" | "xopc.automations.list" | "xopc.automations.get" | "xopc.automations.run" | "xopc.automations.get_run" | "xopc.automations.cancel" | "xopc.automations.simulate" | "xopc.automations.propose" | "xopc.automations.get_proposal" | "xopc.automations.history" | "xopc.automations.run_events" | "xopc.projects.get" | "xopc.projects.list" | "xopc.projects.list_milestones" | "xopc.projects.list_updates" | "xopc.projects.update" | "xopc.projects.create_milestone" | "xopc.projects.update_milestone" | "xopc.projects.create_update" | "xopc.tasks.create" | "xopc.tasks.update" | "xopc.files.read" | "xopc.files.propose_export" | "xopc.connectors.describe" | "xopc.connectors.read" | "xopc.connectors.propose_write" | "xopc.apps.get_request"; majorVersion: number; descriptorDigest: string; }[]; }; grantUiPermissions(extensionId: string, expectedManifestDigest: string, resourceScopes?: LocalAppResourceScopes): LocalAppUiGrant; revokeUiPermissions(extensionId: string, expectedManifestDigest: string): LocalAppUiGrant; assertUiPermission(extensionId: string, manifestDigest: string | undefined, grantRevision: string | undefined, permission: string): void; create(input: CreateLocalAppInput, conversationId?: string): LocalAppDetail; private findDevelopmentConversation; resolveDevelopmentConversation(id: string): string; createFromPreview(input: CreateLocalAppInput & { markup: string; styles: string; script: string; }): LocalAppDetail; private deriveNameFromIdea; private createInternal; resolveDraftPreview(previewToken: string): LocalAppPreviewTarget | null; resolveSnapshotPreview(previewToken: string, sourceHash: string): LocalAppPreviewTarget | null; private validateRoot; validate(id: string): LocalAppValidationResult; materializeSnapshot(id: string): LocalAppPreviewSnapshot; getSnapshot(id: string, sourceHash: string): LocalAppPreviewSnapshot | null; private withSnapshotPreviewUrl; getFixGuidance(id: string, input: LocalAppFixGuidanceInput): LocalAppFixGuidance; recordAcceptance(id: string, input: RecordLocalAppAcceptanceInput): LocalAppAcceptanceRun; flushAcceptanceEvents(): void; private releaseRoot; private refreshExtensions; private assertInstalledRuntime; private activateArtifact; install(id: string): Promise; private installRelease; rollback(id: string, releaseId: string): Promise; private rollbackRelease; setEnabled(id: string, enabled: boolean): Promise; private setReleaseEnabled; uninstall(id: string): Promise; private uninstallRelease; findByExtensionId(extensionId: string): { id: string; extensionId: string; projectId: string; name: string; idea: string; status: "preview_ready" | "installed" | "degraded"; workspaceRoot: string; draftVersion: number; installationState: "installed" | "not_installed"; enabled: boolean; createdAt: number; updatedAt: number; description?: string | undefined; activeVersion?: number | undefined; activeReleaseId?: string | undefined; installedAt?: number | undefined; sourceKind?: "authored" | "store" | undefined; storePackageName?: string | undefined; storeVersion?: string | undefined; storeSourceHash?: string | undefined; customized?: boolean | undefined; icon?: string | undefined; iconUrl?: string | undefined; accentPreset?: "default" | "emerald" | "clay" | "slate" | undefined; seedRecordCount?: number | undefined; suggestedRefinements?: string[] | undefined; } | null; getBundleManifest(appId: string, releaseId: string): { appId: string; extensionId: string; releaseId: string; version: number; sourceHash: string; entrypoint: string; permissions: string[]; collections: { name: string; title: string; fields: { key: string; type: "string" | "number" | "boolean" | "json" | "date" | "enum"; label?: string | undefined; required?: boolean | undefined; values?: string[] | undefined; default?: import("zod/index.cjs").JSONType | undefined; }[]; }[]; etag: string; files: { path: string; mimeType: string; sha256: string; size: number; encoding: "utf8" | "base64"; content: string; }[]; }; updateMetadata(id: string, patch: { name?: string; description?: string; }): LocalAppDetail; updateQuickSettings(id: string, patch: { name?: string; description?: string; icon?: string; accentPreset?: MobileAppAccentPreset; }): LocalAppDetail; seedFromWorkspaceIfPresent(id: string): number; clearSeedRecords(id: string): { appId: string; extensionId: string; clearedCount: number; }; rollbackToPrevious(id: string, releaseId?: string): Promise; markCustomizedIfStore(id: string): void; deleteDraft(id: string): { deleted: true; appId: string; extensionId: string; }; listStoreApps(params?: StoreAppListParams): Promise; getStoreAppDetail(packageName: string): Promise; installFromStore(input: { packageName: string; version?: string; remix?: boolean; verifiedOnly?: boolean; }): Promise<{ app: LocalAppDetail; alreadyInstalled: boolean; }>; upgradeFromStore(id: string, input?: { version?: string; verifiedOnly?: boolean; }): Promise; patchSpacesLayout(rawPatch: Parameters[0]): { desktopPins: string[]; mobilePins: { slot: 0 | 1; extensionId: string; mode: "fixed" | "scheduled"; }[]; replacedMobileTabs: ("workbench" | "notes" | "conversations" | "library")[]; mobileTabOrder: string[]; dynamicSlotIndex: 0 | 1 | null; schedules: Record; updatedAtMs: number; }; emitRecordDelta(event: { appId: string; extensionId: string; collection: string; records: SpaceRecord[]; }): void; removeStoreApp(id: string, options?: { deleteRecords?: boolean; }): Promise; }