import type { AgentSkillShareOperation, AgentSkillShareRequest } from '../../shared/agent-skill-sharing-contract' import type { DiscoveredSkill } from '../../shared/skills' import type { ExecutionHostId } from '../../shared/execution-host' import type { SkillBundleInstallPreview, SkillBundleInstallPreviewRequest, SkillBundleInstallProgress, SkillBundleInstallRequest, SkillBundleInstallResult } from '../../shared/skill-bundle-install-contract' import type { SkillUploadBeginRequest, SkillUploadChunkRequest } from '../../shared/skill-upload-session-contract' import type { SkillUploadSessionService } from '../skills/skill-upload-session-service' import type { RuntimeSkillCommands } from './runtime-skill-command-surface' import type { SkillCloudDownloadGrant, SkillCloudOperation, SkillCloudOptions, SkillCloudPackageDetails, SkillCloudPublishRequest, SkillCloudPublishResult, SkillCloudVersion } from '../../shared/skill-cloud-contract' import type { SkillCloudService } from '../skills/skill-cloud-service' import type { ManagedSkillInstall, SkillInstallPreview, SkillInstallPreviewRequest, SkillInstallRequest, SkillInstallResult, SkillRemoveRequest } from '../../shared/skill-install-contract' import type { SkillProviderRootOverrides } from '../skills/skill-provider-destinations' import type { BundledSkillExecuteRequest, BundledSkillInstallResult, BundledSkillPlan, BundledSkillPlanRequest } from '../../shared/bundled-skill-plan' export type RuntimeSkillCommandSurface = { setSkillCloudService(service: SkillCloudService): void assertAgentSkillSharingAllowed(): void publishDiscoveredSkillsFromAgent( request: AgentSkillShareRequest, discoveredSkills: readonly DiscoveredSkill[], signal?: AbortSignal ): Promise publishSkillPackage( request: SkillCloudPublishRequest ): Promise> publishSkillPackageVersion( request: SkillCloudPublishRequest ): Promise> findOwnedSkillPackageId( name: string, options: SkillCloudOptions ): ReturnType createSkillPackageShare( packageId: string, request: SkillCloudOptions & { pinnedVersionId?: string; idempotencyKey?: string } ): ReturnType resolveSkillShare( shareId: string, options: SkillCloudOptions ): ReturnType createSkillDownloadGrant( shareId: string, options: SkillCloudOptions & { versionId?: string; installTarget?: 'local' | 'remote' } ): Promise> createSkillPackageVersionDownloadGrant( packageId: string, versionId: string, options: SkillCloudOptions & { installTarget?: 'local' | 'remote' } ): Promise> getSkillPackage( packageId: string, options: SkillCloudOptions ): Promise> listOwnedSkillShares(options: SkillCloudOptions): ReturnType revokeSkillShare( shareId: string, options: SkillCloudOptions ): ReturnType deleteSkillPackage( packageId: string, options: SkillCloudOptions ): ReturnType installSharedSkillRequest( request: SkillInstallRequest, signal?: AbortSignal ): Promise installSharedSkillBundleRequest( request: SkillBundleInstallRequest, signal?: AbortSignal, onProgress?: (progress: SkillBundleInstallProgress) => void ): Promise planLocalBundledSkills(request: BundledSkillPlanRequest): Promise executeLocalBundledSkills(request: BundledSkillExecuteRequest): Promise getSharedSkillInstallProgress(operationId: string): SkillBundleInstallProgress | null cancelSharedSkillInstall(operationId: string): boolean previewSharedSkillInstallRequest( request: SkillInstallPreviewRequest ): Promise previewSharedSkillBundleInstallRequest( request: SkillBundleInstallPreviewRequest ): Promise removeSharedSkillInstallRequest(request: SkillRemoveRequest): Promise listManagedSkillInstalls(connectionId?: string): Promise skillInstallDestinationUsesSsh(destination: SkillInstallRequest['destination']): Promise resolveSkillDiscoveryProviderRoots(target: { kind: 'native-host' | 'wsl' distro?: string }): Promise beginSkillUpload(request: SkillUploadBeginRequest): ReturnType appendSkillUploadChunk( request: SkillUploadChunkRequest ): ReturnType commitSkillUpload(uploadId: string): ReturnType cancelSkillUpload(uploadId: string): ReturnType disposeSkillUploadSessions(): Promise } export function installRuntimeSkillCommandSurface( target: RuntimeSkillCommandSurface, commands: RuntimeSkillCommands ): void { const targetMethods = target as unknown as Record unknown> const ownerMethods = commands as unknown as Record unknown> let prototype: object | null = Object.getPrototypeOf(commands) while (prototype && prototype !== Object.prototype) { for (const name of Object.getOwnPropertyNames(prototype)) { if (name !== 'constructor') { targetMethods[name] = ownerMethods[name]!.bind(commands) } } prototype = Object.getPrototypeOf(prototype) } } export type RuntimeSkillCommandHost = { getRuntimeId(): string getUserDataPath(): string isPackaged(): boolean getSettings(): { agentSkillSharingEnabled?: boolean } listRepos(): { id: string path: string connectionId?: string | null executionHostId?: ExecutionHostId | null }[] listFolderWorkspaces(): { id: string folderPath: string connectionId?: string | null executionHostId?: ExecutionHostId | null }[] listResolvedWorktrees(): Promise<{ id: string; path: string; hostId?: ExecutionHostId }[]> showManagedWorktree(selector: string): Promise<{ id: string; path: string }> resolveProjectRuntimeForWorktree?( worktreeId: string ): { status: string; runtime?: { kind: string; distro?: string } } | undefined getClaudeConfigDirectory?( target: { runtime: 'host' } | { runtime: 'wsl'; wslDistro: string } ): string | null skillTransactionRecovery: Promise }