| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- import { IGenUiService } from "@zcode/services";
- import { ProxyChannel, type IChannelClient } from "@zcode/rpc";
- import {
- IFileService,
- IMediaPreviewService,
- IGitService,
- IGitCheckpointService,
- ISystemService,
- ITerminalService,
- ISettingService,
- IOnboardingRecordService,
- ICredentialService,
- IBroadcastService,
- IZCodeTaskService,
- IZCodeAgentService,
- IZCodeSessionService,
- ICuaPermissionService,
- IConversationShareService,
- IBotsService,
- IFileWatcherService,
- IOAuthService,
- IModelSelectionService,
- IProviderSettingsService,
- IProviderProvisioningTargetService,
- IUsageStatsService,
- ICodingPlanSubscriptionService,
- IClientConfigService,
- IClientScenesService,
- ICloudContentService,
- IMarketingTouchService,
- IOffPeakTaskService,
- IHighspeedCardService,
- ISkillsService,
- ISkillSyncService,
- IMcpSyncService,
- IPluginUiAppToolsService,
- IPluginUiSamplingService,
- IPluginUiBridgeService,
- IPluginSyncService,
- IPluginsService,
- IPluginManagementService,
- ISubagentsService,
- ICommandsService,
- IHooksService,
- IMemoryService,
- IOutputStyleService,
- ISettingsSyncService,
- IFeedbackService,
- IPromptAttachmentTransferService,
- IWindowControllerService,
- type IServiceAccessor,
- } from "@zcode/services";
- /**
- * RemoteServiceAccess — 通过 ChannelClient 自动创建类型安全的服务代理
- *
- * 新增服务只需在此添加一个 getter。
- */
- export class RemoteServiceAccess implements IServiceAccessor {
- readonly fileService: IFileService;
- readonly mediaPreviewService: IMediaPreviewService;
- readonly gitService: IGitService;
- readonly gitCheckpointService: IGitCheckpointService;
- readonly systemService: ISystemService;
- readonly terminalService: ITerminalService;
- readonly settingService: ISettingService;
- readonly onboardingRecordService: IOnboardingRecordService;
- readonly credentialService: ICredentialService;
- readonly broadcastService: IBroadcastService;
- readonly zcodeTaskService: IZCodeTaskService;
- readonly windowControllerService: IWindowControllerService;
- readonly zcodeAgentService: IZCodeAgentService;
- readonly zcodeSessionService: IZCodeSessionService;
- // cuaPermissionService 在 IServiceAccessor 上是可选(远端/bots host 不提供),但桌面 renderer
- // 经 RPC 一定能拿到(main host 始终注册此 descriptor;非 macOS / 未启用时方法返回 available:false)。
- readonly cuaPermissionService: ICuaPermissionService;
- readonly conversationShareService: IConversationShareService;
- readonly botsService: IBotsService;
- readonly fileWatcherService: IFileWatcherService;
- readonly oauthService: IOAuthService;
- readonly providerSettingsService: IProviderSettingsService;
- readonly modelSelectionService: IModelSelectionService;
- /** Host-only target proxy;不属于 IServiceAccessor,避免向 Renderer 暴露 Secret 写入接口。 */
- readonly providerProvisioningTargetService!: IProviderProvisioningTargetService;
- readonly usageStatsService: IUsageStatsService;
- readonly codingPlanSubscriptionService: ICodingPlanSubscriptionService;
- readonly clientConfigService: IClientConfigService;
- readonly clientScenesService: IClientScenesService;
- readonly cloudContentService: ICloudContentService;
- readonly marketingTouchService: IMarketingTouchService;
- readonly offPeakTaskService: IOffPeakTaskService;
- readonly highspeedCardService: IHighspeedCardService;
- readonly skillsService: ISkillsService;
- readonly skillSyncService: ISkillSyncService;
- readonly mcpSyncService: IMcpSyncService;
- readonly genUiService: IGenUiService;
- readonly pluginUiBridgeService: IPluginUiBridgeService;
- readonly pluginUiSamplingService: IPluginUiSamplingService;
- readonly pluginUiAppToolsService: IPluginUiAppToolsService;
- readonly pluginSyncService: IPluginSyncService;
- readonly pluginsService: IPluginsService;
- readonly pluginManagementService: IPluginManagementService;
- readonly subagentsService: ISubagentsService;
- readonly commandsService: ICommandsService;
- readonly hooksService: IHooksService;
- readonly memoryService: IMemoryService;
- readonly outputStyleService: IOutputStyleService;
- readonly settingsSyncService: ISettingsSyncService;
- readonly feedbackService: IFeedbackService;
- readonly promptAttachmentTransferService: IPromptAttachmentTransferService;
- constructor(channelClient: IChannelClient) {
- this.fileService = ProxyChannel.toService<IFileService>(
- channelClient.getChannel(IFileService.channelName),
- );
- // Host 已注册 media-preview channel,但遗漏 renderer proxy 时,PreviewPane
- // 会静默回退到 8 MiB 的 file.readMediaPreview,导致大 MP4 无法打开。
- this.mediaPreviewService = ProxyChannel.toService<IMediaPreviewService>(
- channelClient.getChannel(IMediaPreviewService.channelName),
- );
- this.gitService = ProxyChannel.toService<IGitService>(
- channelClient.getChannel(IGitService.channelName),
- );
- this.gitCheckpointService = ProxyChannel.toService<IGitCheckpointService>(
- channelClient.getChannel(IGitCheckpointService.channelName),
- );
- this.systemService = ProxyChannel.toService<ISystemService>(
- channelClient.getChannel(ISystemService.channelName),
- );
- this.terminalService = ProxyChannel.toService<ITerminalService>(
- channelClient.getChannel(ITerminalService.channelName),
- );
- this.settingService = ProxyChannel.toService<ISettingService>(
- channelClient.getChannel(ISettingService.channelName),
- );
- this.onboardingRecordService = ProxyChannel.toService<IOnboardingRecordService>(
- channelClient.getChannel(IOnboardingRecordService.channelName),
- );
- this.credentialService = ProxyChannel.toService<ICredentialService>(
- channelClient.getChannel(ICredentialService.channelName),
- );
- this.broadcastService = ProxyChannel.toService<IBroadcastService>(
- channelClient.getChannel(IBroadcastService.channelName),
- );
- this.zcodeTaskService = ProxyChannel.toService<IZCodeTaskService>(
- channelClient.getChannel(IZCodeTaskService.channelName),
- );
- this.windowControllerService = ProxyChannel.toService<IWindowControllerService>(
- channelClient.getChannel(IWindowControllerService.channelName),
- );
- this.zcodeAgentService = ProxyChannel.toService<IZCodeAgentService>(
- channelClient.getChannel(IZCodeAgentService.channelName),
- );
- this.zcodeSessionService = ProxyChannel.toService<IZCodeSessionService>(
- channelClient.getChannel(IZCodeSessionService.channelName),
- );
- this.cuaPermissionService = ProxyChannel.toService<ICuaPermissionService>(
- channelClient.getChannel(ICuaPermissionService.channelName),
- );
- this.conversationShareService = ProxyChannel.toService<IConversationShareService>(
- channelClient.getChannel(IConversationShareService.channelName),
- );
- this.botsService = ProxyChannel.toService<IBotsService>(
- channelClient.getChannel(IBotsService.channelName),
- );
- this.fileWatcherService = ProxyChannel.toService<IFileWatcherService>(
- channelClient.getChannel(IFileWatcherService.channelName),
- );
- this.oauthService = ProxyChannel.toService<IOAuthService>(
- channelClient.getChannel(IOAuthService.channelName),
- );
- this.providerSettingsService = ProxyChannel.toService<IProviderSettingsService>(
- channelClient.getChannel(IProviderSettingsService.channelName),
- );
- this.modelSelectionService = ProxyChannel.toService<IModelSelectionService>(
- channelClient.getChannel(IModelSelectionService.channelName),
- );
- Object.defineProperty(this, "providerProvisioningTargetService", {
- value: ProxyChannel.toService<IProviderProvisioningTargetService>(
- channelClient.getChannel(IProviderProvisioningTargetService.channelName),
- ),
- enumerable: false,
- });
- this.usageStatsService = ProxyChannel.toService<IUsageStatsService>(
- channelClient.getChannel(IUsageStatsService.channelName),
- );
- this.codingPlanSubscriptionService = ProxyChannel.toService<ICodingPlanSubscriptionService>(
- channelClient.getChannel(ICodingPlanSubscriptionService.channelName),
- );
- this.clientConfigService = ProxyChannel.toService<IClientConfigService>(
- channelClient.getChannel(IClientConfigService.channelName),
- );
- this.clientScenesService = ProxyChannel.toService<IClientScenesService>(
- channelClient.getChannel(IClientScenesService.channelName),
- );
- this.cloudContentService = ProxyChannel.toService<ICloudContentService>(
- channelClient.getChannel(ICloudContentService.channelName),
- );
- this.marketingTouchService = ProxyChannel.toService<IMarketingTouchService>(
- channelClient.getChannel(IMarketingTouchService.channelName),
- );
- this.offPeakTaskService = ProxyChannel.toService<IOffPeakTaskService>(
- channelClient.getChannel(IOffPeakTaskService.channelName),
- );
- this.highspeedCardService = ProxyChannel.toService<IHighspeedCardService>(
- channelClient.getChannel(IHighspeedCardService.channelName),
- );
- this.skillsService = ProxyChannel.toService<ISkillsService>(
- channelClient.getChannel(ISkillsService.channelName),
- );
- this.skillSyncService = ProxyChannel.toService<ISkillSyncService>(
- channelClient.getChannel(ISkillSyncService.channelName),
- );
- this.mcpSyncService = ProxyChannel.toService<IMcpSyncService>(
- channelClient.getChannel(IMcpSyncService.channelName),
- );
- this.genUiService = ProxyChannel.toService<IGenUiService>(
- channelClient.getChannel(IGenUiService.channelName),
- );
- this.pluginUiBridgeService = ProxyChannel.toService<IPluginUiBridgeService>(
- channelClient.getChannel(IPluginUiBridgeService.channelName),
- );
- this.pluginUiSamplingService = ProxyChannel.toService<IPluginUiSamplingService>(
- channelClient.getChannel(IPluginUiSamplingService.channelName),
- );
- this.pluginUiAppToolsService = ProxyChannel.toService<IPluginUiAppToolsService>(
- channelClient.getChannel(IPluginUiAppToolsService.channelName),
- );
- this.pluginSyncService = ProxyChannel.toService<IPluginSyncService>(
- channelClient.getChannel(IPluginSyncService.channelName),
- );
- this.pluginsService = ProxyChannel.toService<IPluginsService>(
- channelClient.getChannel(IPluginsService.channelName),
- );
- this.pluginManagementService = ProxyChannel.toService<IPluginManagementService>(
- channelClient.getChannel(IPluginManagementService.channelName),
- );
- this.subagentsService = ProxyChannel.toService<ISubagentsService>(
- channelClient.getChannel(ISubagentsService.channelName),
- );
- this.commandsService = ProxyChannel.toService<ICommandsService>(
- channelClient.getChannel(ICommandsService.channelName),
- );
- this.hooksService = ProxyChannel.toService<IHooksService>(
- channelClient.getChannel(IHooksService.channelName),
- );
- this.memoryService = ProxyChannel.toService<IMemoryService>(
- channelClient.getChannel(IMemoryService.channelName),
- );
- this.outputStyleService = ProxyChannel.toService<IOutputStyleService>(
- channelClient.getChannel(IOutputStyleService.channelName),
- );
- this.settingsSyncService = ProxyChannel.toService<ISettingsSyncService>(
- channelClient.getChannel(ISettingsSyncService.channelName),
- );
- this.feedbackService = ProxyChannel.toService<IFeedbackService>(
- channelClient.getChannel(IFeedbackService.channelName),
- );
- this.promptAttachmentTransferService = ProxyChannel.toService<IPromptAttachmentTransferService>(
- channelClient.getChannel(IPromptAttachmentTransferService.channelName),
- );
- }
- }
|