Skip to main content

Mountain/RPC/CocoonService/
mod.rs

1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3// # CocoonServiceImpl - thin-wrapper dispatcher
4//
5// Domain files hold all typed RPC implementations. This module keeps:
6// - CocoonServiceImpl struct + helper methods
7// - process_mountain_request (legacy generic router, ~600 lines)
8// - send_mountain_notification (push dispatcher, ~400 lines)
9// - One-line delegates for all 78 typed RPCs
10
11pub mod Auth;
12pub mod Command;
13pub mod Debug;
14pub mod Extension;
15pub mod FileSystem;
16pub mod Initialization;
17pub mod Output;
18pub mod Provider;
19pub mod Save;
20pub mod SCM;
21pub mod Secret;
22pub mod Task;
23pub mod Terminal;
24pub mod TreeView;
25pub mod Window;
26pub mod Workspace;
27
28#[allow(unused_imports)]
29use std::{
30	collections::HashMap,
31	sync::Arc,
32	time::{SystemTime, UNIX_EPOCH},
33};
34
35use async_trait::async_trait;
36use CommonLibrary::{
37	Command::CommandExecutor::CommandExecutor,
38	LanguageFeature::{
39		DTO::{PositionDTO::PositionDTO, ProviderType::ProviderType},
40		LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
41	},
42	Secret::SecretProvider::SecretProvider,
43	Terminal::TerminalProvider::TerminalProvider,
44	UserInterface::{
45		DTO::{
46			InputBoxOptionsDTO::InputBoxOptionsDTO,
47			QuickPickItemDTO::QuickPickItemDTO,
48			QuickPickOptionsDTO::QuickPickOptionsDTO,
49		},
50		UserInterfaceProvider::UserInterfaceProvider,
51	},
52};
53use serde_json::json;
54use tokio::sync::RwLock;
55use tonic::{Request, Response, Status};
56use url::Url;
57
58use crate::{
59	ApplicationState::DTO::{
60		ProviderRegistrationDTO::ProviderRegistrationDTO,
61		WorkspaceFolderStateDTO::WorkspaceFolderStateDTO,
62	},
63	Environment::MountainEnvironment::MountainEnvironment,
64};
65// Import generated protobuf types
66use crate::dev_log;
67use crate::Vine::Generated::{
68	// Service trait
69	// Extended Language + Window + FS + Output + Task + Auth + Debug + Extension types
70	AppendOutputRequest,
71	ApplyEditRequest,
72	ApplyEditResponse,
73	Argument,
74	CancelOperationRequest,
75
76	ClearOutputRequest,
77	CloseTerminalRequest,
78	CodeAction,
79
80	CompletionItem,
81	CopyFileRequest,
82	CreateDirectoryRequest,
83	CreateOutputChannelRequest,
84	CreateOutputChannelResponse,
85	CreateStatusBarItemRequest,
86	CreateStatusBarItemResponse,
87	CreateWebviewPanelRequest,
88	CreateWebviewPanelResponse,
89	DebugConfiguration,
90	DeleteFileRequest,
91	DeleteSecretRequest,
92	DisposeOutputRequest,
93	DisposeWebviewPanelRequest,
94	// Common types
95	Empty,
96	ExecuteCommandRequest,
97	ExecuteCommandResponse,
98	ExecuteTaskRequest,
99	ExecuteTaskResponse,
100	ExtensionInfo,
101	// Workspace Operations
102	FindFilesRequest,
103	FindFilesResponse,
104	FindTextInFilesRequest,
105	FindTextInFilesResponse,
106	GenericNotification,
107	// Common generic types
108	GenericRequest,
109	GenericResponse,
110	GetAllExtensionsResponse,
111	GetAuthenticationSessionRequest,
112	GetAuthenticationSessionResponse,
113	GetConfigurationRequest,
114	GetConfigurationResponse,
115	GetExtensionRequest,
116	GetExtensionResponse,
117	// Secret Storage
118	GetSecretRequest,
119	GetSecretResponse,
120	GetTreeChildrenRequest,
121	GetTreeChildrenResponse,
122	GitExecRequest,
123	GitExecResponse,
124
125	// Initialization
126	InitExtensionHostRequest,
127
128	Location,
129	OnDidReceiveMessageRequest,
130
131	OpenDocumentRequest,
132	OpenDocumentResponse,
133	OpenExternalRequest,
134	// Terminal
135	OpenTerminalRequest,
136	// Save Participants
137	ParticipateInSaveRequest,
138	ParticipateInSaveResponse,
139	Position,
140	PostWebviewMessageRequest,
141	ProvideCallHierarchyRequest,
142	ProvideCallHierarchyResponse,
143	ProvideCodeActionsRequest,
144	ProvideCodeActionsResponse,
145	ProvideCodeLensesRequest,
146	ProvideCodeLensesResponse,
147	ProvideCompletionItemsRequest,
148	ProvideCompletionItemsResponse,
149	ProvideDefinitionRequest,
150	ProvideDefinitionResponse,
151	ProvideDocumentFormattingRequest,
152	ProvideDocumentFormattingResponse,
153	ProvideDocumentHighlightsRequest,
154	ProvideDocumentHighlightsResponse,
155	ProvideDocumentRangeFormattingRequest,
156	ProvideDocumentRangeFormattingResponse,
157	ProvideDocumentSymbolsRequest,
158	ProvideDocumentSymbolsResponse,
159	ProvideFoldingRangesRequest,
160	ProvideFoldingRangesResponse,
161	ProvideHoverRequest,
162	ProvideHoverResponse,
163	ProvideInlayHintsRequest,
164	ProvideInlayHintsResponse,
165	ProvideLinkedEditingRangesRequest,
166	ProvideLinkedEditingRangesResponse,
167	ProvideOnTypeFormattingRequest,
168	ProvideOnTypeFormattingResponse,
169	ProvideReferencesRequest,
170	ProvideReferencesResponse,
171	ProvideRenameEditsRequest,
172	ProvideRenameEditsResponse,
173	ProvideSelectionRangesRequest,
174	ProvideSelectionRangesResponse,
175	ProvideSemanticTokensRequest,
176	ProvideSemanticTokensResponse,
177	ProvideSignatureHelpRequest,
178	ProvideSignatureHelpResponse,
179	ProvideTypeHierarchyRequest,
180	ProvideTypeHierarchyResponse,
181	ProvideWorkspaceSymbolsRequest,
182	ProvideWorkspaceSymbolsResponse,
183	Range,
184	// File System
185	ReadFileRequest,
186	ReadFileResponse,
187	ReaddirRequest,
188	ReaddirResponse,
189	RegisterAuthenticationProviderRequest,
190	// Commands
191	RegisterCommandRequest,
192	// Debug
193	RegisterDebugAdapterRequest,
194	RegisterOnTypeFormattingProviderRequest,
195	// Language Features
196	RegisterProviderRequest,
197	// SCM
198	RegisterScmProviderRequest,
199	RegisterSemanticTokensProviderRequest,
200	RegisterSignatureHelpProviderRequest,
201	RegisterTaskProviderRequest,
202	// Tree View
203	RegisterTreeViewProviderRequest,
204	RenameFileRequest,
205	ReportProgressRequest,
206	ResizeTerminalRequest,
207	RpcError,
208	SaveAllRequest,
209	SaveAllResponse,
210	SetStatusBarTextRequest,
211	SetWebviewHtmlRequest,
212	ShowInputBoxRequest,
213	ShowInputBoxResponse,
214	ShowMessageRequest,
215	ShowMessageResponse,
216	ShowOutputRequest,
217	ShowProgressRequest,
218	ShowProgressResponse,
219	ShowQuickPickRequest,
220	ShowQuickPickResponse,
221	// Window Operations
222	ShowTextDocumentRequest,
223	ShowTextDocumentResponse,
224	SourceControlResourceState,
225	StartDebuggingRequest,
226	StartDebuggingResponse,
227
228	StatRequest,
229	StatResponse,
230	StopDebuggingRequest,
231	StoreSecretRequest,
232	TerminalClosedNotification,
233	TerminalDataNotification,
234
235	TerminalInputRequest,
236	TerminalOpenedNotification,
237	TerminalProcessIdNotification,
238	TerminateTaskRequest,
239	TextDocumentSaveReason,
240	TextEdit,
241	TextEditForSave,
242
243	TextMatch,
244	TreeItem,
245
246	UnregisterCommandRequest,
247
248	UpdateConfigurationRequest,
249	UpdateScmGroupRequest,
250	UpdateWorkspaceFoldersRequest,
251
252	Uri,
253	ViewColumn,
254
255	WatchFileRequest,
256
257	WorkspaceFolder,
258	WriteFileRequest,
259
260	cocoon_service_server::CocoonService,
261	on_did_receive_message_request,
262	post_webview_message_request,
263};
264
265/// Implementation of the CocoonService gRPC server
266///
267/// This struct handles all incoming requests from the Cocoon extension host
268/// sidecar and dispatches them to the appropriate Mountain services.
269#[derive(Clone)]
270pub struct CocoonServiceImpl {
271	/// Mountain environment providing access to all services
272	environment:Arc<MountainEnvironment>,
273
274	/// Registry of active operations with their cancellation tokens
275	/// Maps request ID to cancellation token for operation cancellation
276	ActiveOperations:Arc<RwLock<HashMap<u64, tokio_util::sync::CancellationToken>>>,
277}
278
279impl CocoonServiceImpl {
280	/// Creates a new instance of the CocoonService server
281	///
282	/// # Parameters
283	/// - `environment`: Mountain environment with access to all services
284	///
285	/// # Returns
286	/// A new CocoonService instance
287	pub fn new(environment:Arc<MountainEnvironment>) -> Self {
288		dev_log!("cocoon", "[CocoonService] New instance created");
289
290		Self { environment, ActiveOperations:Arc::new(RwLock::new(HashMap::new())) }
291	}
292
293	/// Registers an operation for potential cancellation
294	///
295	/// # Parameters
296	/// - `request_id`: The request identifier for the operation
297	///
298	/// # Returns
299	/// A cancellation token that can be used to cancel the operation
300	pub async fn RegisterOperation(&self, request_id:u64) -> tokio_util::sync::CancellationToken {
301		let token = tokio_util::sync::CancellationToken::new();
302		self.ActiveOperations.write().await.insert(request_id, token.clone());
303		dev_log!("cocoon", "[CocoonService] Registered operation {} for cancellation", request_id);
304		token
305	}
306
307	/// Unregisters an operation after completion
308	///
309	/// # Parameters
310	/// - `request_id`: The request identifier to unregister
311	pub async fn UnregisterOperation(&self, request_id:u64) {
312		self.ActiveOperations.write().await.remove(&request_id);
313		dev_log!("cocoon", "[CocoonService] Unregistered operation {}", request_id);
314	}
315
316	/// Registers a language feature provider in ApplicationState.
317	///
318	/// Converts the gRPC request fields into a `ProviderRegistrationDTO` and
319	/// stores it in `ApplicationState.Extension.ProviderRegistration`.
320	///
321	/// # Parameters
322	/// - `handle`: Unique provider handle
323	/// - `provider_type`: The type of language feature
324	/// - `language_selector`: Language scope (e.g. "typescript")
325	/// - `extension_id`: Extension that registered this provider
326	fn RegisterProvider(&self, handle:u32, provider_type:ProviderType, language_selector:&str, extension_id:&str) {
327		// SideCarIdentifier = "cocoon-main" so FeatureMethods::invoke_provider can
328		// route back via Vine::Client::SendRequestToSideCar("cocoon-main", ...).
329		// Selector stored as array so ProviderLookup::get_matching_provider's
330		// `.as_array()` call finds the language entry: [{ "language": "typescript" }].
331		let dto = ProviderRegistrationDTO {
332			Handle:handle,
333			ProviderType:provider_type,
334			Selector:json!([{ "language": language_selector }]),
335			SideCarIdentifier:"cocoon-main".to_string(),
336			ExtensionIdentifier:json!(extension_id),
337			Options:None,
338		};
339		self.environment
340			.ApplicationState
341			.Extension
342			.ProviderRegistration
343			.RegisterProvider(handle, dto);
344		dev_log!(
345			"cocoon",
346			"[CocoonService] Provider {:?} registered: handle={}, language={}",
347			provider_type,
348			handle,
349			language_selector
350		);
351	}
352
353	/// Extracts a filesystem path from a URI proto message.
354	///
355	/// Handles both `file://` URIs and bare paths. Returns `None` if the URI
356	/// is absent or the path cannot be extracted.
357	fn UriToPath(uri_opt:Option<&Uri>) -> Option<std::path::PathBuf> {
358		let value = uri_opt?.value.as_str();
359		if value.is_empty() {
360			return None;
361		}
362		// Strip file:// prefix if present
363		let path_str = if let Some(Stripped) = value.strip_prefix("file://") {
364			Stripped
365		} else if value.starts_with('/') || (value.len() > 1 && value.as_bytes()[1] == b':') {
366			// Bare absolute path (Unix or Windows)
367			value
368		} else {
369			// Unknown scheme - return as-is
370			value
371		};
372		Some(std::path::PathBuf::from(path_str))
373	}
374}
375
376#[async_trait]
377
378impl CocoonService for CocoonServiceImpl {
379	// LAND-PATCH B7-S6 P2: bidirectional streaming channel mirror.
380	// Stub matching MountainService::open_channel_from_cocoon. The
381	// multiplexer wiring lands with Patch 14; until then this
382	// returns `Unimplemented` and callers fall back to the unary
383	// methods.
384	type OpenChannelFromMountainStream = std::pin::Pin<
385		Box<
386			dyn tonic::codegen::tokio_stream::Stream<Item = Result<crate::Vine::Generated::Envelope, tonic::Status>>
387				+ Send
388				+ 'static,
389		>,
390	>;
391
392	async fn open_channel_from_mountain(
393		&self,
394		_request:tonic::Request<tonic::Streaming<crate::Vine::Generated::Envelope>>,
395	) -> Result<tonic::Response<Self::OpenChannelFromMountainStream>, tonic::Status> {
396		Err(tonic::Status::unimplemented(
397			"OpenChannelFromMountain: streaming multiplexer not yet wired (Patch 14); use unary endpoints",
398		))
399	}
400
401	/// Process Mountain requests from Cocoon (generic request-response).
402	///
403	/// Routes legacy `fs.*` / `commands.*` / `secrets.*` method names used by
404	/// Cocoon's `FileSystemService` and other services that call Mountain via
405	/// the generic `ProcessCocoonRequest` RPC instead of the typed methods.
406	///
407	/// Parameters are JSON-encoded bytes in `request.parameter`. Results are
408	/// JSON-encoded bytes in `response.result`.
409	async fn process_mountain_request(
410		&self,
411		request:Request<GenericRequest>,
412	) -> Result<Response<GenericResponse>, Status> {
413		let Req = request.into_inner();
414		let RequestId = Req.request_identifier;
415
416		dev_log!(
417			"cocoon",
418			"[CocoonService] generic request: method={} id={}",
419			Req.method,
420			RequestId
421		);
422
423		/// Serialise a value into the `result` bytes of a GenericResponse.
424		fn OkResponse(RequestId:u64, Value:&impl serde::Serialize) -> Response<GenericResponse> {
425			let Bytes = serde_json::to_vec(Value).unwrap_or_default();
426			Response::new(GenericResponse { request_identifier:RequestId, result:Bytes, error:None })
427		}
428
429		/// Build an error GenericResponse.
430		fn ErrResponse(RequestId:u64, Code:i32, Message:String) -> Response<GenericResponse> {
431			Response::new(GenericResponse {
432				request_identifier:RequestId,
433				result:Vec::new(),
434				error:Some(RpcError { code:Code, message:Message, data:Vec::new() }),
435			})
436		}
437
438		// Deserialise the generic parameter bytes as a JSON value
439		let Params:serde_json::Value = if Req.parameter.is_empty() {
440			serde_json::Value::Null
441		} else {
442			serde_json::from_slice(&Req.parameter).unwrap_or(serde_json::Value::Null)
443		};
444
445		match Req.method.as_str() {
446			// ---- File System ---- (Cocoon FileSystemService uses these paths)
447			"fs.readFile" | "file:read" => {
448				let Path = Params
449					.as_str()
450					.or_else(|| Params.get("path").and_then(|V| V.as_str()))
451					.unwrap_or("");
452				match tokio::fs::read(Path).await {
453					Ok(Content) => Ok(OkResponse(RequestId, &Content)),
454					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.readFile: {}", Error))),
455				}
456			},
457			"fs.writeFile" | "file:write" => {
458				let Path = Params.get("path").and_then(|V| V.as_str()).unwrap_or("");
459				let Content:Vec<u8> = Params
460					.get("content")
461					.and_then(|V| V.as_array())
462					.map(|A| A.iter().filter_map(|B| B.as_u64().map(|N| N as u8)).collect())
463					.unwrap_or_default();
464				match tokio::fs::write(Path, &Content).await {
465					Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
466					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.writeFile: {}", Error))),
467				}
468			},
469			"fs.stat" | "file:stat" => {
470				let Path = Params
471					.as_str()
472					.or_else(|| Params.get("path").and_then(|V| V.as_str()))
473					.unwrap_or("");
474				match tokio::fs::metadata(Path).await {
475					Ok(Meta) => {
476						let Mtime = Meta
477							.modified()
478							.ok()
479							.and_then(|T| T.duration_since(UNIX_EPOCH).ok())
480							.map(|D| D.as_millis() as u64)
481							.unwrap_or(0);
482						Ok(OkResponse(
483							RequestId,
484							&json!({
485								"type": if Meta.is_dir() { 2 } else { 1 },
486								"is_file": Meta.is_file(),
487								"is_directory": Meta.is_dir(),
488								"size": Meta.len(),
489								"mtime": Mtime,
490							}),
491						))
492					},
493					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.stat: {}", Error))),
494				}
495			},
496			"fs.listDir" | "fs.readdir" | "file:readdir" => {
497				let Path = Params
498					.as_str()
499					.or_else(|| Params.get("path").and_then(|V| V.as_str()))
500					.unwrap_or("");
501				match tokio::fs::read_dir(Path).await {
502					Ok(mut Entries) => {
503						// Return [{name, type}] where type 1=File 2=Directory
504						let mut Items:Vec<serde_json::Value> = Vec::new();
505						while let Ok(Some(Entry)) = Entries.next_entry().await {
506							if let Some(Name) = Entry.file_name().to_str() {
507								let IsDir = Entry.file_type().await.map(|T| T.is_dir()).unwrap_or(false);
508								Items.push(json!({ "name": Name, "type": if IsDir { 2u32 } else { 1u32 } }));
509							}
510						}
511						Ok(OkResponse(RequestId, &Items))
512					},
513					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.listDir: {}", Error))),
514				}
515			},
516			"fs.createDir" | "file:mkdir" => {
517				let Path = Params
518					.as_str()
519					.or_else(|| Params.get("path").and_then(|V| V.as_str()))
520					.unwrap_or("");
521				match tokio::fs::create_dir_all(Path).await {
522					Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
523					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.createDir: {}", Error))),
524				}
525			},
526			"fs.delete" | "file:delete" => {
527				let Path = Params
528					.as_str()
529					.or_else(|| Params.get("path").and_then(|V| V.as_str()))
530					.unwrap_or("");
531				let Result = if std::path::Path::new(Path).is_dir() {
532					tokio::fs::remove_dir_all(Path).await
533				} else {
534					tokio::fs::remove_file(Path).await
535				};
536				match Result {
537					Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
538					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.delete: {}", Error))),
539				}
540			},
541			"fs.rename" | "file:move" => {
542				let From = Params.get("from").and_then(|V| V.as_str()).unwrap_or("");
543				let To = Params.get("to").and_then(|V| V.as_str()).unwrap_or("");
544				match tokio::fs::rename(From, To).await {
545					Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
546					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.rename: {}", Error))),
547				}
548			},
549			// ---- Commands ----
550			"commands.execute" => {
551				let CommandId = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
552				let Arg = Params.get("arg").cloned().unwrap_or(serde_json::Value::Null);
553				match self.environment.ExecuteCommand(CommandId, Arg).await {
554					Ok(Value) => Ok(OkResponse(RequestId, &Value)),
555					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
556				}
557			},
558			// ---- Commands (Cocoon MountainGRPCClient format) ----
559			"executeCommand" => {
560				let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
561				let Arg = Params
562					.get("arguments")
563					.and_then(|A| A.as_array())
564					.and_then(|A| A.first())
565					.cloned()
566					.unwrap_or(serde_json::Value::Null);
567				match self.environment.ExecuteCommand(CommandId, Arg).await {
568					Ok(Value) => Ok(OkResponse(RequestId, &json!({ "result": Value }))),
569					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
570				}
571			},
572			"unregisterCommand" => {
573				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
574				let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
575				match self.environment.UnregisterCommand(ExtensionId, CommandId).await {
576					Ok(()) => Ok(OkResponse(RequestId, &json!({ "success": true }))),
577					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
578				}
579			},
580			// ---- Window dialogs (Window.ts method names) ----
581			"UserInterface.ShowOpenDialog" => {
582				use CommonLibrary::UserInterface::{
583					DTO::OpenDialogOptionsDTO::OpenDialogOptionsDTO,
584					UserInterfaceProvider::UserInterfaceProvider,
585				};
586				let Title = Params
587					.get(0)
588					.and_then(|V| V.get("title"))
589					.and_then(|T| T.as_str())
590					.map(|S| S.to_string());
591				let Options = OpenDialogOptionsDTO {
592					Base:CommonLibrary::UserInterface::DTO::DialogOptionsDTO::DialogOptionsDTO {
593						Title,
594						..Default::default()
595					},
596					..OpenDialogOptionsDTO::default()
597				};
598				match self.environment.ShowOpenDialog(Some(Options)).await {
599					Ok(Some(Paths)) => {
600						let Uris:Vec<String> = Paths.iter().map(|P| format!("file://{}", P.display())).collect();
601						Ok(OkResponse(RequestId, &json!(Uris)))
602					},
603					Ok(None) => Ok(OkResponse(RequestId, &json!(serde_json::Value::Array(vec![])))),
604					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
605				}
606			},
607			"UserInterface.ShowSaveDialog" => {
608				use CommonLibrary::UserInterface::{
609					DTO::SaveDialogOptionsDTO::SaveDialogOptionsDTO,
610					UserInterfaceProvider::UserInterfaceProvider,
611				};
612				let Title = Params
613					.get(0)
614					.and_then(|V| V.get("title"))
615					.and_then(|T| T.as_str())
616					.map(|S| S.to_string());
617				let Options = SaveDialogOptionsDTO {
618					Base:CommonLibrary::UserInterface::DTO::DialogOptionsDTO::DialogOptionsDTO {
619						Title,
620						..Default::default()
621					},
622					..SaveDialogOptionsDTO::default()
623				};
624				match self.environment.ShowSaveDialog(Some(Options)).await {
625					Ok(Some(Path)) => Ok(OkResponse(RequestId, &json!(format!("file://{}", Path.display())))),
626					Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
627					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
628				}
629			},
630			"UserInterface.ShowInputBox" => {
631				use CommonLibrary::UserInterface::{
632					DTO::InputBoxOptionsDTO::InputBoxOptionsDTO,
633					UserInterfaceProvider::UserInterfaceProvider,
634				};
635				let Opts = Params.get(0);
636				let Options = InputBoxOptionsDTO {
637					Prompt:Opts
638						.and_then(|V| V.get("prompt"))
639						.and_then(|P| P.as_str())
640						.map(|S| S.to_string()),
641					PlaceHolder:Opts
642						.and_then(|V| V.get("placeHolder"))
643						.and_then(|P| P.as_str())
644						.map(|S| S.to_string()),
645					IsPassword:Some(Opts.and_then(|V| V.get("password")).and_then(|B| B.as_bool()).unwrap_or(false)),
646					Value:Opts
647						.and_then(|V| V.get("value"))
648						.and_then(|V| V.as_str())
649						.map(|S| S.to_string()),
650					Title:None,
651					IgnoreFocusOut:None,
652				};
653				match self.environment.ShowInputBox(Some(Options)).await {
654					Ok(Some(Text)) => Ok(OkResponse(RequestId, &json!(Text))),
655					Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
656					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
657				}
658			},
659			// ---- Native shell operations ----
660			"openExternal" => {
661				use tauri::Emitter;
662				let Url = Params
663					.as_str()
664					.or_else(|| Params.get("url").and_then(|V| V.as_str()))
665					.unwrap_or("")
666					.to_string();
667				// Emit to Sky - Sky uses Tauri shell plugin to open the URL
668				let _ = self
669					.environment
670					.ApplicationHandle
671					.emit("sky://native/openExternal", json!({ "url": Url }));
672				Ok(OkResponse(RequestId, &json!({ "success": true })))
673			},
674			// ---- Window (Cocoon MountainGRPCClient format) ----
675			"showTextDocument" => {
676				use tauri::Emitter;
677				let Uri = Params
678					.get("uri")
679					.and_then(|V| V.get("value").or(Some(V)))
680					.and_then(|V| V.as_str())
681					.unwrap_or("")
682					.to_string();
683				let ViewColumn = Params.get("viewColumn").and_then(|V| V.as_i64()).map(|N| N + 2);
684				let PreserveFocus = Params.get("preserveFocus").and_then(|V| V.as_bool()).unwrap_or(false);
685				let _ = self.environment.ApplicationHandle.emit(
686					"sky://editor/openDocument",
687					json!({ "uri": Uri, "viewColumn": ViewColumn, "preserveFocus": PreserveFocus }),
688				);
689				Ok(OkResponse(RequestId, &json!({ "success": true })))
690			},
691			"showInformation" => {
692				use CommonLibrary::UserInterface::{
693					DTO::MessageSeverity::MessageSeverity,
694					UserInterfaceProvider::UserInterfaceProvider,
695				};
696				let Message = Params.get("message").and_then(|V| V.as_str()).unwrap_or("").to_string();
697				let Items:Option<serde_json::Value> = Params
698					.get("items")
699					.cloned()
700					.filter(|V| V.is_array() && !V.as_array().unwrap().is_empty());
701				match self.environment.ShowMessage(MessageSeverity::Info, Message, Items).await {
702					Ok(Some(Selected)) => Ok(OkResponse(RequestId, &json!({ "selectedItem": Selected }))),
703					Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
704					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
705				}
706			},
707			"showWarning" => {
708				use CommonLibrary::UserInterface::{
709					DTO::MessageSeverity::MessageSeverity,
710					UserInterfaceProvider::UserInterfaceProvider,
711				};
712				let Message = Params.get("message").and_then(|V| V.as_str()).unwrap_or("").to_string();
713				let Items:Option<serde_json::Value> = Params
714					.get("items")
715					.cloned()
716					.filter(|V| V.is_array() && !V.as_array().unwrap().is_empty());
717				match self.environment.ShowMessage(MessageSeverity::Warning, Message, Items).await {
718					Ok(Some(Selected)) => Ok(OkResponse(RequestId, &json!({ "selectedItem": Selected }))),
719					Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
720					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
721				}
722			},
723			"showError" => {
724				use CommonLibrary::UserInterface::{
725					DTO::MessageSeverity::MessageSeverity,
726					UserInterfaceProvider::UserInterfaceProvider,
727				};
728				let Message = Params.get("message").and_then(|V| V.as_str()).unwrap_or("").to_string();
729				let Items:Option<serde_json::Value> = Params
730					.get("items")
731					.cloned()
732					.filter(|V| V.is_array() && !V.as_array().unwrap().is_empty());
733				match self.environment.ShowMessage(MessageSeverity::Error, Message, Items).await {
734					Ok(Some(Selected)) => Ok(OkResponse(RequestId, &json!({ "selectedItem": Selected }))),
735					Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
736					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
737				}
738			},
739			"createStatusBarItem" => {
740				use tauri::Emitter;
741				let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
742				let Text = Params.get("text").and_then(|V| V.as_str()).unwrap_or("").to_string();
743				let Tooltip = Params.get("tooltip").and_then(|V| V.as_str()).unwrap_or("").to_string();
744				// Sky's `SetOrUpdateEntry` (`SkyBridge.ts:744`) listens on
745				// `sky://statusbar/set-entry` and `sky://statusbar/update`
746				// - both route through the same upsert. There is no
747				// `sky://statusbar/create` listener; emit the canonical
748				// `set-entry` channel so the entry materialises on first
749				// register.
750				let _ = self.environment.ApplicationHandle.emit(
751					"sky://statusbar/set-entry",
752					json!({ "id": Id, "text": Text, "tooltip": Tooltip }),
753				);
754				Ok(OkResponse(RequestId, &json!({ "itemId": Id })))
755			},
756			"setStatusBarText" => {
757				use tauri::Emitter;
758				let ItemId = Params.get("itemId").and_then(|V| V.as_str()).unwrap_or("").to_string();
759				let Text = Params.get("text").and_then(|V| V.as_str()).unwrap_or("").to_string();
760				let _ = self
761					.environment
762					.ApplicationHandle
763					.emit("sky://statusbar/update", json!({ "id": ItemId, "text": Text }));
764				Ok(OkResponse(RequestId, &json!({ "success": true })))
765			},
766			"createWebviewPanel" => {
767				use tauri::Emitter;
768				let ViewType = Params.get("viewType").and_then(|V| V.as_str()).unwrap_or("").to_string();
769				let Title = Params.get("title").and_then(|V| V.as_str()).unwrap_or("").to_string();
770				let Handle = std::time::SystemTime::now()
771					.duration_since(std::time::UNIX_EPOCH)
772					.map(|D| D.as_millis() as u64)
773					.unwrap_or(0);
774				let _ = self.environment.ApplicationHandle.emit("sky://webview/create", json!({ "handle": Handle, "viewType": ViewType, "title": Title, "viewColumn": Params.get("viewColumn"), "preserveFocus": Params.get("preserveFocus").and_then(|V| V.as_bool()).unwrap_or(false) }));
775				Ok(OkResponse(RequestId, &json!({ "handle": Handle })))
776			},
777			"setWebviewHtml" => {
778				use tauri::Emitter;
779				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0);
780				let Html = Params.get("html").and_then(|V| V.as_str()).unwrap_or("").to_string();
781				// Canonical kebab-case channel; `sky://webview/setHtml` retired.
782				let _ = self
783					.environment
784					.ApplicationHandle
785					.emit("sky://webview/set-html", json!({ "handle": Handle, "html": Html }));
786				Ok(OkResponse(RequestId, &json!({ "success": true })))
787			},
788			// ---- Workspace (Cocoon MountainGRPCClient format) ----
789			// `findFiles` / `findTextInFiles` are called by Cocoon's
790			// `workspace.findFiles()` / `workspace.findTextInFiles()`
791			// API shims. Delegate to the real trait implementations
792			// (`WorkspaceProvider::FindFilesInWorkspace`,
793			// `SearchProvider::TextSearch`) which use `ignore::WalkBuilder`
794			// + `grep-searcher` - respecting `.gitignore`, doing parallel
795			// walks, and producing properly-constructed `Url` results.
796			// Prior inline implementations used naive dir-walks, hidden-
797			// dot skipping, and `format!("file://{}", path)` URI
798			// construction that mangled non-ASCII paths.
799			"findFiles" => {
800				use CommonLibrary::Workspace::WorkspaceProvider::WorkspaceProvider;
801				let Include = Params
802					.get("pattern")
803					.cloned()
804					.or_else(|| Params.get("include").cloned())
805					.unwrap_or(serde_json::Value::String("**".into()));
806				let Exclude = Params.get("exclude").cloned().filter(|V| !V.is_null());
807				let MaxResults = Params.get("maxResults").and_then(|V| V.as_u64()).map(|N| N as usize);
808				let UseIgnoreFiles = Params.get("useIgnoreFiles").and_then(|V| V.as_bool()).unwrap_or(true);
809				let FollowSymlinks = Params.get("followSymlinks").and_then(|V| V.as_bool()).unwrap_or(false);
810				match self
811					.environment
812					.FindFilesInWorkspace(Include, Exclude, MaxResults, UseIgnoreFiles, FollowSymlinks)
813					.await
814				{
815					Ok(Urls) => {
816						Ok(OkResponse(
817							RequestId,
818							&json!({ "uris": Urls.into_iter().map(|U| U.to_string()).collect::<Vec<_>>() }),
819						))
820					},
821					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("findFiles: {}", Error))),
822				}
823			},
824			"findTextInFiles" => {
825				use CommonLibrary::Search::SearchProvider::SearchProvider;
826				// VS Code's `workspace.findTextInFiles` takes a
827				// `TextSearchQuery` in field `pattern` (or passed flat
828				// at the top level). Accept both shapes.
829				let QueryValue = if Params.get("pattern").map(|V| V.is_object()).unwrap_or(false) {
830					Params.get("pattern").cloned().unwrap_or(serde_json::Value::Null)
831				} else if Params.get("pattern").map(|V| V.is_string()).unwrap_or(false) {
832					json!({
833						"pattern": Params.get("pattern").and_then(|V| V.as_str()).unwrap_or(""),
834						"isRegExp": Params.get("isRegExp").and_then(|V| V.as_bool()).unwrap_or(false),
835						"isCaseSensitive": Params.get("isCaseSensitive").and_then(|V| V.as_bool()).unwrap_or(false),
836						"isWordMatch": Params.get("isWordMatch").and_then(|V| V.as_bool()).unwrap_or(false),
837					})
838				} else {
839					Params.clone()
840				};
841				let OptionsValue = Params.get("options").cloned().unwrap_or(serde_json::Value::Null);
842				match self.environment.TextSearch(QueryValue, OptionsValue).await {
843					Ok(Matches) => Ok(OkResponse(RequestId, &json!({ "matches": Matches }))),
844					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("findTextInFiles: {}", Error))),
845				}
846			},
847			"openDocument" => {
848				use tauri::Emitter;
849				let Uri = Params
850					.get("uri")
851					.and_then(|V| V.get("value").or(Some(V)))
852					.and_then(|V| V.as_str())
853					.unwrap_or("")
854					.to_string();
855				let ViewColumn = Params.get("viewColumn").and_then(|V| V.as_i64());
856				let _ = self
857					.environment
858					.ApplicationHandle
859					.emit("sky://editor/openDocument", json!({ "uri": Uri, "viewColumn": ViewColumn }));
860				Ok(OkResponse(RequestId, &json!({ "success": true })))
861			},
862			"saveAll" => {
863				use tauri::Emitter;
864				let IncludeUntitled = Params.get("includeUntitled").and_then(|V| V.as_bool()).unwrap_or(false);
865				let _ = self
866					.environment
867					.ApplicationHandle
868					.emit("sky://editor/saveAll", json!({ "includeUntitled": IncludeUntitled }));
869				Ok(OkResponse(RequestId, &json!({ "success": true })))
870			},
871			"applyEdit" => {
872				use tauri::Emitter;
873				let Uri = Params
874					.get("uri")
875					.and_then(|V| V.get("value").or(Some(V)))
876					.and_then(|V| V.as_str())
877					.unwrap_or("")
878					.to_string();
879				let Edits = Params.get("edits").cloned().unwrap_or(json!([]));
880				let _ = self
881					.environment
882					.ApplicationHandle
883					.emit("sky://editor/applyEdits", json!({ "uri": Uri, "edits": Edits }));
884				Ok(OkResponse(RequestId, &json!({ "success": true })))
885			},
886			// ---- Secret Storage (Cocoon MountainGRPCClient format) ----
887			"getSecret" => {
888				use CommonLibrary::Secret::SecretProvider::SecretProvider;
889				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
890				let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
891				match self.environment.GetSecret(ExtensionId, Key).await {
892					Ok(Some(Value)) => Ok(OkResponse(RequestId, &json!({ "value": Value }))),
893					Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
894					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
895				}
896			},
897			"storeSecret" => {
898				use CommonLibrary::Secret::SecretProvider::SecretProvider;
899				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
900				let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
901				let Value = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
902				match self.environment.StoreSecret(ExtensionId, Key, Value).await {
903					Ok(()) => Ok(OkResponse(RequestId, &json!({ "success": true }))),
904					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
905				}
906			},
907			"deleteSecret" => {
908				use CommonLibrary::Secret::SecretProvider::SecretProvider;
909				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
910				let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
911				match self.environment.DeleteSecret(ExtensionId, Key).await {
912					Ok(()) => Ok(OkResponse(RequestId, &json!({ "success": true }))),
913					Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
914				}
915			},
916			// ---- FS aliases (Cocoon MountainGRPCClient uses different key names) ----
917			"readFile" => {
918				let Uri = Params
919					.get("uri")
920					.and_then(|V| V.as_str())
921					.or_else(|| Params.as_str())
922					.unwrap_or("")
923					.replace("file://", "");
924				match tokio::fs::read(&Uri).await {
925					Ok(Content) => Ok(OkResponse(RequestId, &Content)),
926					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("readFile: {}", Error))),
927				}
928			},
929			"writeFile" => {
930				let Uri = Params.get("uri").and_then(|V| V.as_str()).unwrap_or("").replace("file://", "");
931				let Content:Vec<u8> = Params
932					.get("content")
933					.and_then(|V| V.as_array())
934					.map(|A| A.iter().filter_map(|B| B.as_u64().map(|N| N as u8)).collect())
935					.unwrap_or_default();
936				match tokio::fs::write(&Uri, &Content).await {
937					Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
938					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("writeFile: {}", Error))),
939				}
940			},
941			"stat" => {
942				let Uri = Params
943					.get("uri")
944					.and_then(|V| V.as_str())
945					.or_else(|| Params.as_str())
946					.unwrap_or("")
947					.replace("file://", "");
948				match tokio::fs::metadata(&Uri).await {
949					Ok(Meta) => {
950						let Mtime = Meta
951							.modified()
952							.ok()
953							.and_then(|T| T.duration_since(UNIX_EPOCH).ok())
954							.map(|D| D.as_millis() as u64)
955							.unwrap_or(0);
956						Ok(OkResponse(
957							RequestId,
958							&json!({ "type": if Meta.is_dir() { 2 } else { 1 }, "is_file": Meta.is_file(), "is_directory": Meta.is_dir(), "size": Meta.len(), "mtime": Mtime }),
959						))
960					},
961					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("stat: {}", Error))),
962				}
963			},
964			"readdir" => {
965				let Uri = Params
966					.get("uri")
967					.and_then(|V| V.as_str())
968					.or_else(|| Params.as_str())
969					.unwrap_or("")
970					.replace("file://", "");
971				match tokio::fs::read_dir(&Uri).await {
972					Ok(mut Entries) => {
973						let mut Names:Vec<String> = Vec::new();
974						while let Ok(Some(Entry)) = Entries.next_entry().await {
975							if let Some(Name) = Entry.file_name().to_str() {
976								Names.push(Name.to_string());
977							}
978						}
979						Ok(OkResponse(RequestId, &Names))
980					},
981					Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("readdir: {}", Error))),
982				}
983			},
984			// ---- Unknown ----
985			_ => {
986				dev_log!("cocoon", "warn: [CocoonService] Unknown generic method: {}", Req.method);
987				Ok(ErrResponse(RequestId, -32601, format!("Method '{}' not found", Req.method)))
988			},
989		}
990	}
991
992	/// Send Mountain notifications to Cocoon (generic fire-and-forget)
993	/// Routes by notification.method string to the appropriate Mountain
994	/// handler. Called by Cocoon's
995	/// `MountainGRPCClient.sendNotification(method, params)`.
996	async fn send_mountain_notification(
997		&self,
998		request:Request<GenericNotification>,
999	) -> Result<Response<Empty>, Status> {
1000		let notification = request.into_inner();
1001		dev_log!(
1002			"cocoon",
1003			"[CocoonService] Notification router: method='{}'",
1004			notification.method
1005		);
1006
1007		// Deserialise notification parameters as JSON
1008		let Params:serde_json::Value = if notification.parameter.is_empty() {
1009			serde_json::Value::Null
1010		} else {
1011			serde_json::from_slice(&notification.parameter).unwrap_or(serde_json::Value::Null)
1012		};
1013
1014		match notification.method.as_str() {
1015			// ---- Commands ----
1016			"registerCommand" => {
1017				let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1018				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1019				if let Err(Error) = self.environment.RegisterCommand(ExtensionId, CommandId.clone()).await {
1020					dev_log!(
1021						"cocoon",
1022						"warn: [CocoonService] notification: registerCommand '{}' failed: {:?}",
1023						CommandId,
1024						Error
1025					);
1026				}
1027			},
1028			"unregisterCommand" => {
1029				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1030				let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1031				let _ = self.environment.UnregisterCommand(ExtensionId, CommandId).await;
1032			},
1033			// ---- Language Providers (APIFactoryService.ts register_*_provider strings) ----
1034			"register_hover_provider" => {
1035				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1036				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1037				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1038				self.RegisterProvider(Handle, ProviderType::Hover, Selector, ExtId);
1039			},
1040			"register_completion_item_provider" => {
1041				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1042				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1043				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1044				self.RegisterProvider(Handle, ProviderType::Completion, Selector, ExtId);
1045			},
1046			"register_definition_provider" => {
1047				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1048				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1049				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1050				self.RegisterProvider(Handle, ProviderType::Definition, Selector, ExtId);
1051			},
1052			"register_reference_provider" => {
1053				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1054				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1055				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1056				self.RegisterProvider(Handle, ProviderType::References, Selector, ExtId);
1057			},
1058			"register_code_actions_provider" => {
1059				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1060				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1061				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1062				self.RegisterProvider(Handle, ProviderType::CodeAction, Selector, ExtId);
1063			},
1064			"register_document_highlight_provider" => {
1065				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1066				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1067				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1068				self.RegisterProvider(Handle, ProviderType::DocumentHighlight, Selector, ExtId);
1069			},
1070			"register_document_symbol_provider" => {
1071				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1072				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1073				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1074				self.RegisterProvider(Handle, ProviderType::DocumentSymbol, Selector, ExtId);
1075			},
1076			"register_workspace_symbol_provider" => {
1077				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1078				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1079				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1080				self.RegisterProvider(Handle, ProviderType::WorkspaceSymbol, Selector, ExtId);
1081			},
1082			"register_rename_provider" => {
1083				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1084				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1085				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1086				self.RegisterProvider(Handle, ProviderType::Rename, Selector, ExtId);
1087			},
1088			"register_document_formatting_provider" => {
1089				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1090				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1091				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1092				self.RegisterProvider(Handle, ProviderType::DocumentFormatting, Selector, ExtId);
1093			},
1094			"register_document_range_formatting_provider" => {
1095				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1096				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1097				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1098				self.RegisterProvider(Handle, ProviderType::DocumentRangeFormatting, Selector, ExtId);
1099			},
1100			"register_on_type_formatting_provider" => {
1101				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1102				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1103				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1104				self.RegisterProvider(Handle, ProviderType::OnTypeFormatting, Selector, ExtId);
1105			},
1106			"register_signature_help_provider" => {
1107				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1108				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1109				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1110				self.RegisterProvider(Handle, ProviderType::SignatureHelp, Selector, ExtId);
1111			},
1112			"register_code_lens_provider" => {
1113				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1114				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1115				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1116				self.RegisterProvider(Handle, ProviderType::CodeLens, Selector, ExtId);
1117			},
1118			"register_folding_range_provider" => {
1119				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1120				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1121				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1122				self.RegisterProvider(Handle, ProviderType::FoldingRange, Selector, ExtId);
1123			},
1124			"register_selection_range_provider" => {
1125				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1126				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1127				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1128				self.RegisterProvider(Handle, ProviderType::SelectionRange, Selector, ExtId);
1129			},
1130			"register_semantic_tokens_provider" => {
1131				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1132				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1133				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1134				self.RegisterProvider(Handle, ProviderType::SemanticTokens, Selector, ExtId);
1135			},
1136			"register_inlay_hints_provider" => {
1137				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1138				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1139				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1140				self.RegisterProvider(Handle, ProviderType::InlayHint, Selector, ExtId);
1141			},
1142			"register_type_hierarchy_provider" => {
1143				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1144				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1145				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1146				self.RegisterProvider(Handle, ProviderType::TypeHierarchy, Selector, ExtId);
1147			},
1148			"register_call_hierarchy_provider" => {
1149				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1150				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1151				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1152				self.RegisterProvider(Handle, ProviderType::CallHierarchy, Selector, ExtId);
1153			},
1154			"register_linked_editing_range_provider" => {
1155				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1156				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1157				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1158				self.RegisterProvider(Handle, ProviderType::LinkedEditingRange, Selector, ExtId);
1159			},
1160			"register_document_link_provider" => {
1161				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1162				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1163				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1164				self.RegisterProvider(Handle, ProviderType::DocumentLink, Selector, ExtId);
1165			},
1166			"register_color_provider" => {
1167				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1168				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1169				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1170				self.RegisterProvider(Handle, ProviderType::Color, Selector, ExtId);
1171			},
1172			"register_implementation_provider" => {
1173				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1174				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1175				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1176				self.RegisterProvider(Handle, ProviderType::Implementation, Selector, ExtId);
1177			},
1178			"register_type_definition_provider" => {
1179				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1180				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1181				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1182				self.RegisterProvider(Handle, ProviderType::TypeDefinition, Selector, ExtId);
1183			},
1184			"register_declaration_provider" => {
1185				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1186				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1187				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1188				self.RegisterProvider(Handle, ProviderType::Declaration, Selector, ExtId);
1189			},
1190			"register_evaluatable_expression_provider" => {
1191				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1192				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1193				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1194				self.RegisterProvider(Handle, ProviderType::EvaluatableExpression, Selector, ExtId);
1195			},
1196			"register_inline_values_provider" => {
1197				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1198				let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1199				let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1200				self.RegisterProvider(Handle, ProviderType::InlineValues, Selector, ExtId);
1201			},
1202			// ---- Webview ----
1203			"onDidReceiveMessage" => {
1204				use tauri::Emitter;
1205				let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0);
1206				let Message = Params
1207					.get("stringMessage")
1208					.and_then(|V| V.as_str())
1209					.map(|S| S.to_string())
1210					.or_else(|| Params.get("bytesMessage").map(|_| "[binary]".to_string()))
1211					.unwrap_or_default();
1212				let _ = self
1213					.environment
1214					.ApplicationHandle
1215					.emit("sky://webview/post-message", json!({ "handle": Handle, "message": Message }));
1216			},
1217			// ---- Secrets (fire-and-forget variants) ----
1218			"storeSecret" => {
1219				use CommonLibrary::Secret::SecretProvider::SecretProvider;
1220				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1221				let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1222				let Value = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1223				let _ = self.environment.StoreSecret(ExtensionId, Key, Value).await;
1224			},
1225			"deleteSecret" => {
1226				use CommonLibrary::Secret::SecretProvider::SecretProvider;
1227				let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1228				let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1229				let _ = self.environment.DeleteSecret(ExtensionId, Key).await;
1230			},
1231			// ---- File system (fire-and-forget write) ----
1232			"writeFile" => {
1233				let Uri = Params
1234					.get("uri")
1235					.and_then(|V| V.get("value").or(Some(V)))
1236					.and_then(|V| V.as_str())
1237					.unwrap_or("")
1238					.replace("file://", "");
1239				let Content:Vec<u8> = Params
1240					.get("content")
1241					.and_then(|V| V.as_array())
1242					.map(|A| A.iter().filter_map(|B| B.as_u64().map(|N| N as u8)).collect())
1243					.unwrap_or_default();
1244				let _ = tokio::fs::write(&Uri, &Content).await;
1245			},
1246			// ---- Webview panel ----
1247			"webview.postMessage" => {
1248				use tauri::Emitter;
1249				let PanelId = Params.get("panelId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1250				let Method = Params.get("method").and_then(|V| V.as_str()).unwrap_or("").to_string();
1251				let MsgParams = Params.get("params").cloned().unwrap_or(serde_json::Value::Null);
1252				let _ = self.environment.ApplicationHandle.emit(
1253					"sky://webview/message",
1254					json!({ "panelId": PanelId, "method": Method, "params": MsgParams }),
1255				);
1256			},
1257			"webview.dispose" => {
1258				use tauri::Emitter;
1259				let PanelId = Params.get("panelId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1260				let _ = self
1261					.environment
1262					.ApplicationHandle
1263					.emit("sky://webview/dispose", json!({ "panelId": PanelId }));
1264			},
1265			// ---- Progress indicator ----
1266			"progress.start" => {
1267				use tauri::Emitter;
1268				let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1269				let Title = Params.get("title").and_then(|V| V.as_str()).map(|S| S.to_string());
1270				let Location = Params.get("location").cloned();
1271				let Cancellable = Params.get("cancellable").and_then(|V| V.as_bool()).unwrap_or(false);
1272				let _ = self.environment.ApplicationHandle.emit(
1273					"sky://progress/start",
1274					json!({ "id": Id, "title": Title, "location": Location, "cancellable": Cancellable }),
1275				);
1276			},
1277			"progress.update" => {
1278				use tauri::Emitter;
1279				let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1280				let Message = Params.get("message").and_then(|V| V.as_str()).map(|S| S.to_string());
1281				let Increment = Params.get("increment").and_then(|V| V.as_f64());
1282				let _ = self.environment.ApplicationHandle.emit(
1283					"sky://progress/update",
1284					json!({ "id": Id, "message": Message, "increment": Increment }),
1285				);
1286			},
1287			"progress.complete" => {
1288				use tauri::Emitter;
1289				let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1290				let _ = self
1291					.environment
1292					.ApplicationHandle
1293					.emit("sky://progress/complete", json!({ "id": Id }));
1294			},
1295			// ---- Native shell ----
1296			"openExternal" => {
1297				use tauri::Emitter;
1298				let Url = Params.get("url").and_then(|V| V.as_str()).unwrap_or("").to_string();
1299				let _ = self
1300					.environment
1301					.ApplicationHandle
1302					.emit("sky://native/openExternal", json!({ "url": Url }));
1303			},
1304			// ---- StatusBar updates (fire-and-forget from Window.ts setters) ----
1305			"setStatusBarText" | "statusBar.setText" => {
1306				use tauri::Emitter;
1307				let ItemId = Params.get("itemId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1308				let Text = Params.get("text").and_then(|V| V.as_str()).unwrap_or("").to_string();
1309				let _ = self
1310					.environment
1311					.ApplicationHandle
1312					.emit("sky://statusbar/update", json!({ "id": ItemId, "text": Text }));
1313			},
1314			"disposeStatusBarItem" | "statusBar.dispose" => {
1315				use tauri::Emitter;
1316				let ItemId = Params.get("itemId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1317				let _ = self
1318					.environment
1319					.ApplicationHandle
1320					.emit("sky://statusbar/dispose", json!({ "id": ItemId }));
1321			},
1322			// ---- Output channel (fire-and-forget from Window.ts OutputChannel proxy) ----
1323			"output.create" => {
1324				use tauri::Emitter;
1325				let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1326				let Name = Params.get("name").and_then(|V| V.as_str()).unwrap_or("").to_string();
1327				let _ = self
1328					.environment
1329					.ApplicationHandle
1330					.emit("sky://output/create", json!({ "id": Id, "name": Name }));
1331			},
1332			"output.append" => {
1333				use tauri::Emitter;
1334				let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1335				let Text = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1336				let _ = self
1337					.environment
1338					.ApplicationHandle
1339					.emit("sky://output/append", json!({ "channel": Channel, "text": Text }));
1340			},
1341			"output.appendLine" => {
1342				use tauri::Emitter;
1343				let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1344				let Line = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1345				let _ = self.environment.ApplicationHandle.emit(
1346					"sky://output/append",
1347					json!({ "channel": Channel, "text": format!("{}\n", Line) }),
1348				);
1349			},
1350			"output.clear" => {
1351				use tauri::Emitter;
1352				let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1353				let _ = self
1354					.environment
1355					.ApplicationHandle
1356					.emit("sky://output/clear", json!({ "channel": Channel }));
1357			},
1358			"output.show" => {
1359				use tauri::Emitter;
1360				let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1361				let _ = self
1362					.environment
1363					.ApplicationHandle
1364					.emit("sky://output/show", json!({ "channel": Channel }));
1365			},
1366			"output.dispose" => {
1367				use tauri::Emitter;
1368				let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1369				let _ = self
1370					.environment
1371					.ApplicationHandle
1372					.emit("sky://output/dispose", json!({ "channel": Channel }));
1373			},
1374			// ---- Language configuration ----
1375			"set_language_configuration" => {
1376				// Language configuration is consumed by Sky - emit for workbench to pick up
1377				use tauri::Emitter;
1378				let Language = Params.get("language").and_then(|V| V.as_str()).unwrap_or("").to_string();
1379				let _ = self
1380					.environment
1381					.ApplicationHandle
1382					.emit("sky://language/configure", json!({ "language": Language }));
1383			},
1384			_ => {
1385				dev_log!(
1386					"cocoon",
1387					"[CocoonService] Unknown notification method: '{}'",
1388					notification.method
1389				);
1390			},
1391		}
1392
1393		Ok(Response::new(Empty {}))
1394	}
1395
1396	/// Cancel operations requested by Mountain
1397
1398	async fn cancel_operation(&self, request:Request<CancelOperationRequest>) -> Result<Response<Empty>, Status> {
1399		Initialization::CancelOperation::Fn(self, request.into_inner()).await
1400	}
1401
1402	async fn initial_handshake(&self, request:Request<Empty>) -> Result<Response<Empty>, Status> {
1403		Initialization::InitialHandshake::Fn(self, request.into_inner()).await
1404	}
1405
1406	async fn init_extension_host(&self, request:Request<InitExtensionHostRequest>) -> Result<Response<Empty>, Status> {
1407		Initialization::InitExtensionHost::Fn(self, request.into_inner()).await
1408	}
1409
1410	async fn register_command(&self, request:Request<RegisterCommandRequest>) -> Result<Response<Empty>, Status> {
1411		Command::RegisterCommand::Fn(self, request.into_inner()).await
1412	}
1413
1414	async fn execute_contributed_command(
1415		&self,
1416		request:Request<ExecuteCommandRequest>,
1417	) -> Result<Response<ExecuteCommandResponse>, Status> {
1418		Command::ExecuteContributedCommand::Fn(self, request.into_inner()).await
1419	}
1420
1421	async fn unregister_command(&self, request:Request<UnregisterCommandRequest>) -> Result<Response<Empty>, Status> {
1422		Command::UnregisterCommand::Fn(self, request.into_inner()).await
1423	}
1424
1425	async fn register_hover_provider(
1426		&self,
1427		request:Request<RegisterProviderRequest>,
1428	) -> Result<Response<Empty>, Status> {
1429		Provider::RegisterHoverProvider::Fn(self, request.into_inner()).await
1430	}
1431
1432	async fn provide_hover(
1433		&self,
1434		request:Request<ProvideHoverRequest>,
1435	) -> Result<Response<ProvideHoverResponse>, Status> {
1436		Provider::ProvideHover::Fn(self, request.into_inner()).await
1437	}
1438
1439	async fn register_completion_item_provider(
1440		&self,
1441		request:Request<RegisterProviderRequest>,
1442	) -> Result<Response<Empty>, Status> {
1443		Provider::RegisterCompletionItemProvider::Fn(self, request.into_inner()).await
1444	}
1445
1446	async fn provide_completion_items(
1447		&self,
1448		request:Request<ProvideCompletionItemsRequest>,
1449	) -> Result<Response<ProvideCompletionItemsResponse>, Status> {
1450		Provider::ProvideCompletionItems::Fn(self, request.into_inner()).await
1451	}
1452
1453	async fn register_definition_provider(
1454		&self,
1455		request:Request<RegisterProviderRequest>,
1456	) -> Result<Response<Empty>, Status> {
1457		Provider::RegisterDefinitionProvider::Fn(self, request.into_inner()).await
1458	}
1459
1460	async fn provide_definition(
1461		&self,
1462		request:Request<ProvideDefinitionRequest>,
1463	) -> Result<Response<ProvideDefinitionResponse>, Status> {
1464		Provider::ProvideDefinition::Fn(self, request.into_inner()).await
1465	}
1466
1467	async fn register_reference_provider(
1468		&self,
1469		request:Request<RegisterProviderRequest>,
1470	) -> Result<Response<Empty>, Status> {
1471		Provider::RegisterReferenceProvider::Fn(self, request.into_inner()).await
1472	}
1473
1474	async fn provide_references(
1475		&self,
1476		request:Request<ProvideReferencesRequest>,
1477	) -> Result<Response<ProvideReferencesResponse>, Status> {
1478		Provider::ProvideReferences::Fn(self, request.into_inner()).await
1479	}
1480
1481	async fn register_code_actions_provider(
1482		&self,
1483		request:Request<RegisterProviderRequest>,
1484	) -> Result<Response<Empty>, Status> {
1485		Provider::RegisterCodeActionsProvider::Fn(self, request.into_inner()).await
1486	}
1487
1488	async fn provide_code_actions(
1489		&self,
1490		request:Request<ProvideCodeActionsRequest>,
1491	) -> Result<Response<ProvideCodeActionsResponse>, Status> {
1492		Provider::ProvideCodeActions::Fn(self, request.into_inner()).await
1493	}
1494
1495	async fn show_text_document(
1496		&self,
1497		request:Request<ShowTextDocumentRequest>,
1498	) -> Result<Response<ShowTextDocumentResponse>, Status> {
1499		Window::ShowTextDocument::Fn(self, request.into_inner()).await
1500	}
1501
1502	async fn show_information_message(
1503		&self,
1504		request:Request<ShowMessageRequest>,
1505	) -> Result<Response<ShowMessageResponse>, Status> {
1506		Window::ShowInformationMessage::Fn(self, request.into_inner()).await
1507	}
1508
1509	async fn show_warning_message(
1510		&self,
1511		request:Request<ShowMessageRequest>,
1512	) -> Result<Response<ShowMessageResponse>, Status> {
1513		Window::ShowWarningMessage::Fn(self, request.into_inner()).await
1514	}
1515
1516	async fn show_error_message(
1517		&self,
1518		request:Request<ShowMessageRequest>,
1519	) -> Result<Response<ShowMessageResponse>, Status> {
1520		Window::ShowErrorMessage::Fn(self, request.into_inner()).await
1521	}
1522
1523	async fn create_status_bar_item(
1524		&self,
1525		request:Request<CreateStatusBarItemRequest>,
1526	) -> Result<Response<CreateStatusBarItemResponse>, Status> {
1527		Window::CreateStatusBarItem::Fn(self, request.into_inner()).await
1528	}
1529
1530	async fn set_status_bar_text(&self, request:Request<SetStatusBarTextRequest>) -> Result<Response<Empty>, Status> {
1531		Window::SetStatusBarText::Fn(self, request.into_inner()).await
1532	}
1533
1534	async fn create_webview_panel(
1535		&self,
1536		request:Request<CreateWebviewPanelRequest>,
1537	) -> Result<Response<CreateWebviewPanelResponse>, Status> {
1538		Window::CreateWebviewPanel::Fn(self, request.into_inner()).await
1539	}
1540
1541	async fn set_webview_html(&self, request:Request<SetWebviewHtmlRequest>) -> Result<Response<Empty>, Status> {
1542		Window::SetWebviewHtml::Fn(self, request.into_inner()).await
1543	}
1544
1545	async fn on_did_receive_message(
1546		&self,
1547		request:Request<OnDidReceiveMessageRequest>,
1548	) -> Result<Response<Empty>, Status> {
1549		Window::OnDidReceiveMessage::Fn(self, request.into_inner()).await
1550	}
1551
1552	async fn post_webview_message(
1553		&self,
1554		request:Request<PostWebviewMessageRequest>,
1555	) -> Result<Response<Empty>, Status> {
1556		Window::PostWebviewMessage::Fn(self, request.into_inner()).await
1557	}
1558
1559	async fn dispose_webview_panel(
1560		&self,
1561		request:Request<DisposeWebviewPanelRequest>,
1562	) -> Result<Response<Empty>, Status> {
1563		Window::DisposeWebviewPanel::Fn(self, request.into_inner()).await
1564	}
1565
1566	async fn read_file(&self, request:Request<ReadFileRequest>) -> Result<Response<ReadFileResponse>, Status> {
1567		FileSystem::ReadFile::Fn(self, request.into_inner()).await
1568	}
1569
1570	async fn write_file(&self, request:Request<WriteFileRequest>) -> Result<Response<Empty>, Status> {
1571		FileSystem::WriteFile::Fn(self, request.into_inner()).await
1572	}
1573
1574	async fn stat(&self, request:Request<StatRequest>) -> Result<Response<StatResponse>, Status> {
1575		FileSystem::Stat::Fn(self, request.into_inner()).await
1576	}
1577
1578	async fn readdir(&self, request:Request<ReaddirRequest>) -> Result<Response<ReaddirResponse>, Status> {
1579		FileSystem::Readdir::Fn(self, request.into_inner()).await
1580	}
1581
1582	async fn watch_file(&self, request:Request<WatchFileRequest>) -> Result<Response<Empty>, Status> {
1583		FileSystem::WatchFile::Fn(self, request.into_inner()).await
1584	}
1585
1586	async fn find_files(&self, request:Request<FindFilesRequest>) -> Result<Response<FindFilesResponse>, Status> {
1587		FileSystem::FindFiles::Fn(self, request.into_inner()).await
1588	}
1589
1590	async fn find_text_in_files(
1591		&self,
1592		request:Request<FindTextInFilesRequest>,
1593	) -> Result<Response<FindTextInFilesResponse>, Status> {
1594		FileSystem::FindTextInFiles::Fn(self, request.into_inner()).await
1595	}
1596
1597	async fn delete_file(&self, request:Request<DeleteFileRequest>) -> Result<Response<Empty>, Status> {
1598		FileSystem::DeleteFile::Fn(self, request.into_inner()).await
1599	}
1600
1601	async fn rename_file(&self, request:Request<RenameFileRequest>) -> Result<Response<Empty>, Status> {
1602		FileSystem::RenameFile::Fn(self, request.into_inner()).await
1603	}
1604
1605	async fn copy_file(&self, request:Request<CopyFileRequest>) -> Result<Response<Empty>, Status> {
1606		FileSystem::CopyFile::Fn(self, request.into_inner()).await
1607	}
1608
1609	async fn create_directory(&self, request:Request<CreateDirectoryRequest>) -> Result<Response<Empty>, Status> {
1610		FileSystem::CreateDirectory::Fn(self, request.into_inner()).await
1611	}
1612
1613	async fn open_document(
1614		&self,
1615		request:Request<OpenDocumentRequest>,
1616	) -> Result<Response<OpenDocumentResponse>, Status> {
1617		Workspace::OpenDocument::Fn(self, request.into_inner()).await
1618	}
1619
1620	async fn save_all(&self, request:Request<SaveAllRequest>) -> Result<Response<SaveAllResponse>, Status> {
1621		Workspace::SaveAll::Fn(self, request.into_inner()).await
1622	}
1623
1624	async fn apply_edit(&self, request:Request<ApplyEditRequest>) -> Result<Response<ApplyEditResponse>, Status> {
1625		Workspace::ApplyEdit::Fn(self, request.into_inner()).await
1626	}
1627
1628	async fn update_configuration(
1629		&self,
1630		request:Request<UpdateConfigurationRequest>,
1631	) -> Result<Response<Empty>, Status> {
1632		Workspace::UpdateConfiguration::Fn(self, request.into_inner()).await
1633	}
1634
1635	async fn update_workspace_folders(
1636		&self,
1637		request:Request<UpdateWorkspaceFoldersRequest>,
1638	) -> Result<Response<Empty>, Status> {
1639		Workspace::UpdateWorkspaceFolders::Fn(self, request.into_inner()).await
1640	}
1641
1642	async fn open_terminal(&self, request:Request<OpenTerminalRequest>) -> Result<Response<Empty>, Status> {
1643		Terminal::OpenTerminal::Fn(self, request.into_inner()).await
1644	}
1645
1646	async fn terminal_input(&self, request:Request<TerminalInputRequest>) -> Result<Response<Empty>, Status> {
1647		Terminal::TerminalInput::Fn(self, request.into_inner()).await
1648	}
1649
1650	async fn close_terminal(&self, request:Request<CloseTerminalRequest>) -> Result<Response<Empty>, Status> {
1651		Terminal::CloseTerminal::Fn(self, request.into_inner()).await
1652	}
1653
1654	async fn accept_terminal_opened(
1655		&self,
1656		request:Request<TerminalOpenedNotification>,
1657	) -> Result<Response<Empty>, Status> {
1658		Terminal::AcceptTerminalOpened::Fn(self, request.into_inner()).await
1659	}
1660
1661	async fn accept_terminal_closed(
1662		&self,
1663		request:Request<TerminalClosedNotification>,
1664	) -> Result<Response<Empty>, Status> {
1665		Terminal::AcceptTerminalClosed::Fn(self, request.into_inner()).await
1666	}
1667
1668	async fn accept_terminal_process_id(
1669		&self,
1670		request:Request<TerminalProcessIdNotification>,
1671	) -> Result<Response<Empty>, Status> {
1672		Terminal::AcceptTerminalProcessId::Fn(self, request.into_inner()).await
1673	}
1674
1675	async fn accept_terminal_process_data(
1676		&self,
1677		request:Request<TerminalDataNotification>,
1678	) -> Result<Response<Empty>, Status> {
1679		Terminal::AcceptTerminalProcessData::Fn(self, request.into_inner()).await
1680	}
1681
1682	async fn resize_terminal(&self, request:Request<ResizeTerminalRequest>) -> Result<Response<Empty>, Status> {
1683		Terminal::ResizeTerminal::Fn(self, request.into_inner()).await
1684	}
1685
1686	async fn register_tree_view_provider(
1687		&self,
1688		request:Request<RegisterTreeViewProviderRequest>,
1689	) -> Result<Response<Empty>, Status> {
1690		TreeView::RegisterTreeViewProvider::Fn(self, request.into_inner()).await
1691	}
1692
1693	async fn get_tree_children(
1694		&self,
1695		request:Request<GetTreeChildrenRequest>,
1696	) -> Result<Response<GetTreeChildrenResponse>, Status> {
1697		TreeView::GetTreeChildren::Fn(self, request.into_inner()).await
1698	}
1699
1700	async fn register_scm_provider(
1701		&self,
1702		request:Request<RegisterScmProviderRequest>,
1703	) -> Result<Response<Empty>, Status> {
1704		SCM::RegisterScmProvider::Fn(self, request.into_inner()).await
1705	}
1706
1707	async fn update_scm_group(&self, request:Request<UpdateScmGroupRequest>) -> Result<Response<Empty>, Status> {
1708		SCM::UpdateScmGroup::Fn(self, request.into_inner()).await
1709	}
1710
1711	async fn git_exec(&self, request:Request<GitExecRequest>) -> Result<Response<GitExecResponse>, Status> {
1712		SCM::GitExec::Fn(self, request.into_inner()).await
1713	}
1714
1715	async fn register_debug_adapter(
1716		&self,
1717		request:Request<RegisterDebugAdapterRequest>,
1718	) -> Result<Response<Empty>, Status> {
1719		Debug::RegisterDebugAdapter::Fn(self, request.into_inner()).await
1720	}
1721
1722	async fn start_debugging(
1723		&self,
1724		request:Request<StartDebuggingRequest>,
1725	) -> Result<Response<StartDebuggingResponse>, Status> {
1726		Debug::StartDebugging::Fn(self, request.into_inner()).await
1727	}
1728
1729	async fn stop_debugging(&self, request:Request<StopDebuggingRequest>) -> Result<Response<Empty>, Status> {
1730		Debug::StopDebugging::Fn(self, request.into_inner()).await
1731	}
1732
1733	async fn participate_in_save(
1734		&self,
1735		request:Request<ParticipateInSaveRequest>,
1736	) -> Result<Response<ParticipateInSaveResponse>, Status> {
1737		Save::ParticipateInSave(self, request.into_inner()).await
1738	}
1739
1740	async fn get_secret(&self, request:Request<GetSecretRequest>) -> Result<Response<GetSecretResponse>, Status> {
1741		Secret::GetSecret::Fn(self, request.into_inner()).await
1742	}
1743
1744	async fn store_secret(&self, request:Request<StoreSecretRequest>) -> Result<Response<Empty>, Status> {
1745		Secret::StoreSecret::Fn(self, request.into_inner()).await
1746	}
1747
1748	async fn delete_secret(&self, request:Request<DeleteSecretRequest>) -> Result<Response<Empty>, Status> {
1749		Secret::DeleteSecret::Fn(self, request.into_inner()).await
1750	}
1751
1752	async fn register_document_highlight_provider(
1753		&self,
1754		request:Request<RegisterProviderRequest>,
1755	) -> Result<Response<Empty>, Status> {
1756		Provider::RegisterDocumentHighlightProvider::Fn(self, request.into_inner()).await
1757	}
1758
1759	async fn provide_document_highlights(
1760		&self,
1761		request:Request<ProvideDocumentHighlightsRequest>,
1762	) -> Result<Response<ProvideDocumentHighlightsResponse>, Status> {
1763		Provider::ProvideDocumentHighlights::Fn(self, request.into_inner()).await
1764	}
1765
1766	async fn register_document_symbol_provider(
1767		&self,
1768		request:Request<RegisterProviderRequest>,
1769	) -> Result<Response<Empty>, Status> {
1770		Provider::RegisterDocumentSymbolProvider::Fn(self, request.into_inner()).await
1771	}
1772
1773	async fn provide_document_symbols(
1774		&self,
1775		request:Request<ProvideDocumentSymbolsRequest>,
1776	) -> Result<Response<ProvideDocumentSymbolsResponse>, Status> {
1777		Provider::ProvideDocumentSymbols::Fn(self, request.into_inner()).await
1778	}
1779
1780	async fn register_workspace_symbol_provider(
1781		&self,
1782		request:Request<RegisterProviderRequest>,
1783	) -> Result<Response<Empty>, Status> {
1784		Provider::RegisterWorkspaceSymbolProvider::Fn(self, request.into_inner()).await
1785	}
1786
1787	async fn provide_workspace_symbols(
1788		&self,
1789		request:Request<ProvideWorkspaceSymbolsRequest>,
1790	) -> Result<Response<ProvideWorkspaceSymbolsResponse>, Status> {
1791		Provider::ProvideWorkspaceSymbols::Fn(self, request.into_inner()).await
1792	}
1793
1794	async fn register_rename_provider(
1795		&self,
1796		request:Request<RegisterProviderRequest>,
1797	) -> Result<Response<Empty>, Status> {
1798		Provider::RegisterRenameProvider::Fn(self, request.into_inner()).await
1799	}
1800
1801	async fn provide_rename_edits(
1802		&self,
1803		request:Request<ProvideRenameEditsRequest>,
1804	) -> Result<Response<ProvideRenameEditsResponse>, Status> {
1805		Provider::ProvideRenameEdits::Fn(self, request.into_inner()).await
1806	}
1807
1808	async fn register_document_formatting_provider(
1809		&self,
1810		request:Request<RegisterProviderRequest>,
1811	) -> Result<Response<Empty>, Status> {
1812		Provider::RegisterDocumentFormattingProvider::Fn(self, request.into_inner()).await
1813	}
1814
1815	async fn provide_document_formatting(
1816		&self,
1817		request:Request<ProvideDocumentFormattingRequest>,
1818	) -> Result<Response<ProvideDocumentFormattingResponse>, Status> {
1819		Provider::ProvideDocumentFormatting::Fn(self, request.into_inner()).await
1820	}
1821
1822	async fn register_document_range_formatting_provider(
1823		&self,
1824		request:Request<RegisterProviderRequest>,
1825	) -> Result<Response<Empty>, Status> {
1826		Provider::RegisterDocumentRangeFormattingProvider::Fn(self, request.into_inner()).await
1827	}
1828
1829	async fn provide_document_range_formatting(
1830		&self,
1831		request:Request<ProvideDocumentRangeFormattingRequest>,
1832	) -> Result<Response<ProvideDocumentRangeFormattingResponse>, Status> {
1833		Provider::ProvideDocumentRangeFormatting::Fn(self, request.into_inner()).await
1834	}
1835
1836	async fn register_on_type_formatting_provider(
1837		&self,
1838		request:Request<RegisterOnTypeFormattingProviderRequest>,
1839	) -> Result<Response<Empty>, Status> {
1840		Provider::RegisterOnTypeFormattingProvider::Fn(self, request.into_inner()).await
1841	}
1842
1843	async fn provide_on_type_formatting(
1844		&self,
1845		request:Request<ProvideOnTypeFormattingRequest>,
1846	) -> Result<Response<ProvideOnTypeFormattingResponse>, Status> {
1847		Provider::ProvideOnTypeFormatting::Fn(self, request.into_inner()).await
1848	}
1849
1850	async fn register_signature_help_provider(
1851		&self,
1852		request:Request<RegisterSignatureHelpProviderRequest>,
1853	) -> Result<Response<Empty>, Status> {
1854		Provider::RegisterSignatureHelpProvider::Fn(self, request.into_inner()).await
1855	}
1856
1857	async fn provide_signature_help(
1858		&self,
1859		request:Request<ProvideSignatureHelpRequest>,
1860	) -> Result<Response<ProvideSignatureHelpResponse>, Status> {
1861		Provider::ProvideSignatureHelp::Fn(self, request.into_inner()).await
1862	}
1863
1864	async fn register_code_lens_provider(
1865		&self,
1866		request:Request<RegisterProviderRequest>,
1867	) -> Result<Response<Empty>, Status> {
1868		Provider::RegisterCodeLensProvider::Fn(self, request.into_inner()).await
1869	}
1870
1871	async fn provide_code_lenses(
1872		&self,
1873		request:Request<ProvideCodeLensesRequest>,
1874	) -> Result<Response<ProvideCodeLensesResponse>, Status> {
1875		Provider::ProvideCodeLenses::Fn(self, request.into_inner()).await
1876	}
1877
1878	async fn register_folding_range_provider(
1879		&self,
1880		request:Request<RegisterProviderRequest>,
1881	) -> Result<Response<Empty>, Status> {
1882		Provider::RegisterFoldingRangeProvider::Fn(self, request.into_inner()).await
1883	}
1884
1885	async fn provide_folding_ranges(
1886		&self,
1887		request:Request<ProvideFoldingRangesRequest>,
1888	) -> Result<Response<ProvideFoldingRangesResponse>, Status> {
1889		Provider::ProvideFoldingRanges::Fn(self, request.into_inner()).await
1890	}
1891
1892	async fn register_selection_range_provider(
1893		&self,
1894		request:Request<RegisterProviderRequest>,
1895	) -> Result<Response<Empty>, Status> {
1896		Provider::RegisterSelectionRangeProvider::Fn(self, request.into_inner()).await
1897	}
1898
1899	async fn provide_selection_ranges(
1900		&self,
1901		request:Request<ProvideSelectionRangesRequest>,
1902	) -> Result<Response<ProvideSelectionRangesResponse>, Status> {
1903		Provider::ProvideSelectionRanges::Fn(self, request.into_inner()).await
1904	}
1905
1906	async fn register_semantic_tokens_provider(
1907		&self,
1908		request:Request<RegisterSemanticTokensProviderRequest>,
1909	) -> Result<Response<Empty>, Status> {
1910		Provider::RegisterSemanticTokensProvider::Fn(self, request.into_inner()).await
1911	}
1912
1913	async fn provide_semantic_tokens_full(
1914		&self,
1915		request:Request<ProvideSemanticTokensRequest>,
1916	) -> Result<Response<ProvideSemanticTokensResponse>, Status> {
1917		Provider::ProvideSemanticTokensFull::Fn(self, request.into_inner()).await
1918	}
1919
1920	async fn register_inlay_hints_provider(
1921		&self,
1922		request:Request<RegisterProviderRequest>,
1923	) -> Result<Response<Empty>, Status> {
1924		Provider::RegisterInlayHintsProvider::Fn(self, request.into_inner()).await
1925	}
1926
1927	async fn provide_inlay_hints(
1928		&self,
1929		request:Request<ProvideInlayHintsRequest>,
1930	) -> Result<Response<ProvideInlayHintsResponse>, Status> {
1931		Provider::ProvideInlayHints::Fn(self, request.into_inner()).await
1932	}
1933
1934	async fn register_type_hierarchy_provider(
1935		&self,
1936		request:Request<RegisterProviderRequest>,
1937	) -> Result<Response<Empty>, Status> {
1938		Provider::RegisterTypeHierarchyProvider::Fn(self, request.into_inner()).await
1939	}
1940
1941	async fn provide_type_hierarchy_supertypes(
1942		&self,
1943		request:Request<ProvideTypeHierarchyRequest>,
1944	) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
1945		Provider::ProvideTypeHierarchySupertypes::Fn(self, request.into_inner()).await
1946	}
1947
1948	async fn provide_type_hierarchy_subtypes(
1949		&self,
1950		request:Request<ProvideTypeHierarchyRequest>,
1951	) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
1952		Provider::ProvideTypeHierarchySubtypes::Fn(self, request.into_inner()).await
1953	}
1954
1955	async fn register_call_hierarchy_provider(
1956		&self,
1957		request:Request<RegisterProviderRequest>,
1958	) -> Result<Response<Empty>, Status> {
1959		Provider::RegisterCallHierarchyProvider::Fn(self, request.into_inner()).await
1960	}
1961
1962	async fn provide_call_hierarchy_incoming_calls(
1963		&self,
1964		request:Request<ProvideCallHierarchyRequest>,
1965	) -> Result<Response<ProvideCallHierarchyResponse>, Status> {
1966		Provider::ProvideCallHierarchyIncomingCalls::Fn(self, request.into_inner()).await
1967	}
1968
1969	async fn provide_call_hierarchy_outgoing_calls(
1970		&self,
1971		request:Request<ProvideCallHierarchyRequest>,
1972	) -> Result<Response<ProvideCallHierarchyResponse>, Status> {
1973		Provider::ProvideCallHierarchyOutgoingCalls::Fn(self, request.into_inner()).await
1974	}
1975
1976	async fn register_linked_editing_range_provider(
1977		&self,
1978		request:Request<RegisterProviderRequest>,
1979	) -> Result<Response<Empty>, Status> {
1980		Provider::RegisterLinkedEditingRangeProvider::Fn(self, request.into_inner()).await
1981	}
1982
1983	async fn provide_linked_editing_ranges(
1984		&self,
1985		request:Request<ProvideLinkedEditingRangesRequest>,
1986	) -> Result<Response<ProvideLinkedEditingRangesResponse>, Status> {
1987		Provider::ProvideLinkedEditingRanges::Fn(self, request.into_inner()).await
1988	}
1989
1990	async fn show_quick_pick(
1991		&self,
1992		request:Request<ShowQuickPickRequest>,
1993	) -> Result<Response<ShowQuickPickResponse>, Status> {
1994		Window::ShowQuickPick::Fn(self, request.into_inner()).await
1995	}
1996
1997	async fn show_input_box(
1998		&self,
1999		request:Request<ShowInputBoxRequest>,
2000	) -> Result<Response<ShowInputBoxResponse>, Status> {
2001		Window::ShowInputBox::Fn(self, request.into_inner()).await
2002	}
2003
2004	async fn show_progress(
2005		&self,
2006		request:Request<ShowProgressRequest>,
2007	) -> Result<Response<ShowProgressResponse>, Status> {
2008		Window::ShowProgress::Fn(self, request.into_inner()).await
2009	}
2010
2011	async fn report_progress(&self, request:Request<ReportProgressRequest>) -> Result<Response<Empty>, Status> {
2012		Window::ReportProgress::Fn(self, request.into_inner()).await
2013	}
2014
2015	async fn open_external(&self, request:Request<OpenExternalRequest>) -> Result<Response<Empty>, Status> {
2016		Window::OpenExternal::Fn(self, request.into_inner()).await
2017	}
2018
2019	async fn create_output_channel(
2020		&self,
2021		request:Request<CreateOutputChannelRequest>,
2022	) -> Result<Response<CreateOutputChannelResponse>, Status> {
2023		Output::CreateOutputChannel::Fn(self, request.into_inner()).await
2024	}
2025
2026	async fn append_output(&self, request:Request<AppendOutputRequest>) -> Result<Response<Empty>, Status> {
2027		Output::AppendOutput::Fn(self, request.into_inner()).await
2028	}
2029
2030	async fn clear_output(&self, request:Request<ClearOutputRequest>) -> Result<Response<Empty>, Status> {
2031		Output::ClearOutput::Fn(self, request.into_inner()).await
2032	}
2033
2034	async fn show_output(&self, request:Request<ShowOutputRequest>) -> Result<Response<Empty>, Status> {
2035		Output::ShowOutput::Fn(self, request.into_inner()).await
2036	}
2037
2038	async fn dispose_output(&self, request:Request<DisposeOutputRequest>) -> Result<Response<Empty>, Status> {
2039		Output::DisposeOutput::Fn(self, request.into_inner()).await
2040	}
2041
2042	async fn register_task_provider(
2043		&self,
2044		request:Request<RegisterTaskProviderRequest>,
2045	) -> Result<Response<Empty>, Status> {
2046		Task::RegisterTaskProvider::Fn(self, request.into_inner()).await
2047	}
2048
2049	async fn execute_task(&self, request:Request<ExecuteTaskRequest>) -> Result<Response<ExecuteTaskResponse>, Status> {
2050		Task::ExecuteTask::Fn(self, request.into_inner()).await
2051	}
2052
2053	async fn terminate_task(&self, request:Request<TerminateTaskRequest>) -> Result<Response<Empty>, Status> {
2054		Task::TerminateTask::Fn(self, request.into_inner()).await
2055	}
2056
2057	async fn get_authentication_session(
2058		&self,
2059		request:Request<GetAuthenticationSessionRequest>,
2060	) -> Result<Response<GetAuthenticationSessionResponse>, Status> {
2061		Auth::GetAuthenticationSession::Fn(self, request.into_inner()).await
2062	}
2063
2064	async fn register_authentication_provider(
2065		&self,
2066		request:Request<RegisterAuthenticationProviderRequest>,
2067	) -> Result<Response<Empty>, Status> {
2068		Auth::RegisterAuthenticationProvider::Fn(self, request.into_inner()).await
2069	}
2070
2071	async fn get_extension(
2072		&self,
2073		request:Request<GetExtensionRequest>,
2074	) -> Result<Response<GetExtensionResponse>, Status> {
2075		Extension::GetExtension::Fn(self, request.into_inner()).await
2076	}
2077
2078	async fn get_all_extensions(&self, request:Request<Empty>) -> Result<Response<GetAllExtensionsResponse>, Status> {
2079		Extension::GetAllExtensions::Fn(self, request.into_inner()).await
2080	}
2081
2082	async fn get_configuration(
2083		&self,
2084		request:Request<GetConfigurationRequest>,
2085	) -> Result<Response<GetConfigurationResponse>, Status> {
2086		Extension::GetConfiguration::Fn(self, request.into_inner()).await
2087	}
2088}