Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:59:22.753Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

since_v0_6_0.rs

737 lines · 24.8 KB · rust
1use crate::wasm_host::WasmState;
2use anyhow::Result;
3use extension::{KeyValueStoreDelegate, ProjectDelegate, WorktreeDelegate};
4use gpui::BackgroundExecutor;
5use semver::Version;
6use std::sync::{Arc, OnceLock};
7use wasmtime::component::{Linker, Resource};
8
9use super::latest;
10
11pub const MIN_VERSION: Version = Version::new(0, 6, 0);
12pub const MAX_VERSION: Version = Version::new(0, 7, 0);
13
14wasmtime::component::bindgen!({
15    imports: {
16        default: async | trappable,
17    },
18    exports: {
19        default: async,
20    },
21    path: "../extension_api/wit/since_v0.6.0",
22    with: {
23        "worktree": ExtensionWorktree,
24        "project": ExtensionProject,
25        "key-value-store": ExtensionKeyValueStore,
26        "zed:extension/common": latest::zed::extension::common,
27        "zed:extension/http-client": latest::zed::extension::http_client,
28        "zed:extension/nodejs": latest::zed::extension::nodejs,
29        "zed:extension/process": latest::zed::extension::process,
30        "zed:extension/slash-command": latest::zed::extension::slash_command,
31        "zed:extension/context-server": latest::zed::extension::context_server,
32    },
33});
34
35pub use self::zed::extension::*;
36
37mod settings {
38    #![allow(dead_code)]
39    include!(concat!(env!("OUT_DIR"), "/since_v0.6.0/settings.rs"));
40}
41
42pub type ExtensionWorktree = Arc<dyn WorktreeDelegate>;
43pub type ExtensionProject = Arc<dyn ProjectDelegate>;
44pub type ExtensionKeyValueStore = Arc<dyn KeyValueStoreDelegate>;
45
46pub fn linker(executor: &BackgroundExecutor) -> &'static Linker<WasmState> {
47    static LINKER: OnceLock<Linker<WasmState>> = OnceLock::new();
48    LINKER.get_or_init(|| {
49        super::new_linker(executor, |linker| {
50            Extension::add_to_linker::<_, WasmState>(linker, |s| s)
51        })
52    })
53}
54
55impl From<CodeLabel> for latest::CodeLabel {
56    fn from(value: CodeLabel) -> Self {
57        Self {
58            code: value.code,
59            spans: value.spans.into_iter().map(Into::into).collect(),
60            filter_range: value.filter_range,
61        }
62    }
63}
64
65impl From<CodeLabelSpan> for latest::CodeLabelSpan {
66    fn from(value: CodeLabelSpan) -> Self {
67        match value {
68            CodeLabelSpan::CodeRange(range) => Self::CodeRange(range),
69            CodeLabelSpan::Literal(literal) => Self::Literal(literal.into()),
70        }
71    }
72}
73
74impl From<CodeLabelSpanLiteral> for latest::CodeLabelSpanLiteral {
75    fn from(value: CodeLabelSpanLiteral) -> Self {
76        Self {
77            text: value.text,
78            highlight_name: value.highlight_name,
79        }
80    }
81}
82
83impl From<SettingsLocation> for latest::SettingsLocation {
84    fn from(value: SettingsLocation) -> Self {
85        Self {
86            worktree_id: value.worktree_id,
87            path: value.path,
88        }
89    }
90}
91
92impl From<LanguageServerInstallationStatus> for latest::LanguageServerInstallationStatus {
93    fn from(value: LanguageServerInstallationStatus) -> Self {
94        match value {
95            LanguageServerInstallationStatus::None => Self::None,
96            LanguageServerInstallationStatus::Downloading => Self::Downloading,
97            LanguageServerInstallationStatus::CheckingForUpdate => Self::CheckingForUpdate,
98            LanguageServerInstallationStatus::Failed(message) => Self::Failed(message),
99        }
100    }
101}
102
103impl From<DownloadedFileType> for latest::DownloadedFileType {
104    fn from(value: DownloadedFileType) -> Self {
105        match value {
106            DownloadedFileType::Gzip => Self::Gzip,
107            DownloadedFileType::GzipTar => Self::GzipTar,
108            DownloadedFileType::Zip => Self::Zip,
109            DownloadedFileType::Uncompressed => Self::Uncompressed,
110        }
111    }
112}
113
114impl From<latest::github::GithubReleaseAsset> for github::GithubReleaseAsset {
115    fn from(value: latest::github::GithubReleaseAsset) -> Self {
116        Self {
117            name: value.name,
118            download_url: value.download_url,
119        }
120    }
121}
122
123impl From<latest::github::GithubRelease> for github::GithubRelease {
124    fn from(value: latest::github::GithubRelease) -> Self {
125        Self {
126            version: value.version,
127            assets: value.assets.into_iter().map(Into::into).collect(),
128        }
129    }
130}
131
132impl From<github::GithubReleaseOptions> for latest::github::GithubReleaseOptions {
133    fn from(value: github::GithubReleaseOptions) -> Self {
134        Self {
135            require_assets: value.require_assets,
136            pre_release: value.pre_release,
137        }
138    }
139}
140
141impl zed::extension::github::Host for WasmState {
142    async fn github_release_by_tag_name(
143        &mut self,
144        repo: String,
145        tag: String,
146    ) -> wasmtime::Result<Result<github::GithubRelease, String>> {
147        latest::github::Host::github_release_by_tag_name(self, repo, tag)
148            .await
149            .map(|result| result.map(Into::into))
150    }
151
152    async fn latest_github_release(
153        &mut self,
154        repo: String,
155        options: github::GithubReleaseOptions,
156    ) -> wasmtime::Result<Result<github::GithubRelease, String>> {
157        latest::github::Host::latest_github_release(self, repo, options.into())
158            .await
159            .map(|result| result.map(Into::into))
160    }
161}
162
163impl From<latest::lsp::Completion> for lsp::Completion {
164    fn from(value: latest::lsp::Completion) -> Self {
165        Self {
166            label: value.label,
167            label_details: value.label_details.map(Into::into),
168            detail: value.detail,
169            kind: value.kind.map(Into::into),
170            insert_text_format: value.insert_text_format.map(Into::into),
171        }
172    }
173}
174
175impl From<latest::lsp::Symbol> for lsp::Symbol {
176    fn from(value: latest::lsp::Symbol) -> Self {
177        Self {
178            name: value.name,
179            kind: value.kind.into(),
180        }
181    }
182}
183
184impl From<latest::lsp::CompletionLabelDetails> for lsp::CompletionLabelDetails {
185    fn from(value: latest::lsp::CompletionLabelDetails) -> Self {
186        Self {
187            detail: value.detail,
188            description: value.description,
189        }
190    }
191}
192
193impl From<latest::lsp::CompletionKind> for lsp::CompletionKind {
194    fn from(value: latest::lsp::CompletionKind) -> Self {
195        match value {
196            latest::lsp::CompletionKind::Text => Self::Text,
197            latest::lsp::CompletionKind::Method => Self::Method,
198            latest::lsp::CompletionKind::Function => Self::Function,
199            latest::lsp::CompletionKind::Constructor => Self::Constructor,
200            latest::lsp::CompletionKind::Field => Self::Field,
201            latest::lsp::CompletionKind::Variable => Self::Variable,
202            latest::lsp::CompletionKind::Class => Self::Class,
203            latest::lsp::CompletionKind::Interface => Self::Interface,
204            latest::lsp::CompletionKind::Module => Self::Module,
205            latest::lsp::CompletionKind::Property => Self::Property,
206            latest::lsp::CompletionKind::Unit => Self::Unit,
207            latest::lsp::CompletionKind::Value => Self::Value,
208            latest::lsp::CompletionKind::Enum => Self::Enum,
209            latest::lsp::CompletionKind::Keyword => Self::Keyword,
210            latest::lsp::CompletionKind::Snippet => Self::Snippet,
211            latest::lsp::CompletionKind::Color => Self::Color,
212            latest::lsp::CompletionKind::File => Self::File,
213            latest::lsp::CompletionKind::Reference => Self::Reference,
214            latest::lsp::CompletionKind::Folder => Self::Folder,
215            latest::lsp::CompletionKind::EnumMember => Self::EnumMember,
216            latest::lsp::CompletionKind::Constant => Self::Constant,
217            latest::lsp::CompletionKind::Struct => Self::Struct,
218            latest::lsp::CompletionKind::Event => Self::Event,
219            latest::lsp::CompletionKind::Operator => Self::Operator,
220            latest::lsp::CompletionKind::TypeParameter => Self::TypeParameter,
221            latest::lsp::CompletionKind::Other(kind) => Self::Other(kind),
222        }
223    }
224}
225
226impl From<latest::lsp::InsertTextFormat> for lsp::InsertTextFormat {
227    fn from(value: latest::lsp::InsertTextFormat) -> Self {
228        match value {
229            latest::lsp::InsertTextFormat::PlainText => Self::PlainText,
230            latest::lsp::InsertTextFormat::Snippet => Self::Snippet,
231            latest::lsp::InsertTextFormat::Other(value) => Self::Other(value),
232        }
233    }
234}
235
236impl From<latest::lsp::SymbolKind> for lsp::SymbolKind {
237    fn from(value: latest::lsp::SymbolKind) -> Self {
238        match value {
239            latest::lsp::SymbolKind::File => Self::File,
240            latest::lsp::SymbolKind::Module => Self::Module,
241            latest::lsp::SymbolKind::Namespace => Self::Namespace,
242            latest::lsp::SymbolKind::Package => Self::Package,
243            latest::lsp::SymbolKind::Class => Self::Class,
244            latest::lsp::SymbolKind::Method => Self::Method,
245            latest::lsp::SymbolKind::Property => Self::Property,
246            latest::lsp::SymbolKind::Field => Self::Field,
247            latest::lsp::SymbolKind::Constructor => Self::Constructor,
248            latest::lsp::SymbolKind::Enum => Self::Enum,
249            latest::lsp::SymbolKind::Interface => Self::Interface,
250            latest::lsp::SymbolKind::Function => Self::Function,
251            latest::lsp::SymbolKind::Variable => Self::Variable,
252            latest::lsp::SymbolKind::Constant => Self::Constant,
253            latest::lsp::SymbolKind::String => Self::String,
254            latest::lsp::SymbolKind::Number => Self::Number,
255            latest::lsp::SymbolKind::Boolean => Self::Boolean,
256            latest::lsp::SymbolKind::Array => Self::Array,
257            latest::lsp::SymbolKind::Object => Self::Object,
258            latest::lsp::SymbolKind::Key => Self::Key,
259            latest::lsp::SymbolKind::Null => Self::Null,
260            latest::lsp::SymbolKind::EnumMember => Self::EnumMember,
261            latest::lsp::SymbolKind::Struct => Self::Struct,
262            latest::lsp::SymbolKind::Event => Self::Event,
263            latest::lsp::SymbolKind::Operator => Self::Operator,
264            latest::lsp::SymbolKind::TypeParameter => Self::TypeParameter,
265            latest::lsp::SymbolKind::Other(kind) => Self::Other(kind),
266        }
267    }
268}
269
270impl lsp::Host for WasmState {}
271
272impl HostKeyValueStore for WasmState {
273    async fn insert(
274        &mut self,
275        kv_store: Resource<ExtensionKeyValueStore>,
276        key: String,
277        value: String,
278    ) -> wasmtime::Result<Result<(), String>> {
279        latest::HostKeyValueStore::insert(self, kv_store, key, value).await
280    }
281
282    async fn drop(&mut self, _worktree: Resource<ExtensionKeyValueStore>) -> Result<()> {
283        // We only ever hand out borrows of key-value stores.
284        Ok(())
285    }
286}
287
288impl HostProject for WasmState {
289    async fn worktree_ids(
290        &mut self,
291        project: Resource<ExtensionProject>,
292    ) -> wasmtime::Result<Vec<u64>> {
293        latest::HostProject::worktree_ids(self, project).await
294    }
295
296    async fn drop(&mut self, _project: Resource<Project>) -> Result<()> {
297        // We only ever hand out borrows of projects.
298        Ok(())
299    }
300}
301
302impl HostWorktree for WasmState {
303    async fn id(&mut self, delegate: Resource<Arc<dyn WorktreeDelegate>>) -> wasmtime::Result<u64> {
304        latest::HostWorktree::id(self, delegate).await
305    }
306
307    async fn root_path(
308        &mut self,
309        delegate: Resource<Arc<dyn WorktreeDelegate>>,
310    ) -> wasmtime::Result<String> {
311        latest::HostWorktree::root_path(self, delegate).await
312    }
313
314    async fn read_text_file(
315        &mut self,
316        delegate: Resource<Arc<dyn WorktreeDelegate>>,
317        path: String,
318    ) -> wasmtime::Result<Result<String, String>> {
319        latest::HostWorktree::read_text_file(self, delegate, path).await
320    }
321
322    async fn shell_env(
323        &mut self,
324        delegate: Resource<Arc<dyn WorktreeDelegate>>,
325    ) -> wasmtime::Result<EnvVars> {
326        latest::HostWorktree::shell_env(self, delegate).await
327    }
328
329    async fn which(
330        &mut self,
331        delegate: Resource<Arc<dyn WorktreeDelegate>>,
332        binary_name: String,
333    ) -> wasmtime::Result<Option<String>> {
334        latest::HostWorktree::which(self, delegate, binary_name).await
335    }
336
337    async fn drop(&mut self, _worktree: Resource<Worktree>) -> Result<()> {
338        // We only ever hand out borrows of worktrees.
339        Ok(())
340    }
341}
342
343impl ExtensionImports for WasmState {
344    async fn get_settings(
345        &mut self,
346        location: Option<self::SettingsLocation>,
347        category: String,
348        key: Option<String>,
349    ) -> wasmtime::Result<Result<String, String>> {
350        latest::ExtensionImports::get_settings(
351            self,
352            location.map(|location| location.into()),
353            category,
354            key,
355        )
356        .await
357    }
358
359    async fn set_language_server_installation_status(
360        &mut self,
361        server_name: String,
362        status: LanguageServerInstallationStatus,
363    ) -> wasmtime::Result<()> {
364        latest::ExtensionImports::set_language_server_installation_status(
365            self,
366            server_name,
367            status.into(),
368        )
369        .await
370    }
371
372    async fn download_file(
373        &mut self,
374        url: String,
375        path: String,
376        file_type: DownloadedFileType,
377    ) -> wasmtime::Result<Result<(), String>> {
378        latest::ExtensionImports::download_file(self, url, path, file_type.into()).await
379    }
380
381    async fn make_file_executable(&mut self, path: String) -> wasmtime::Result<Result<(), String>> {
382        latest::ExtensionImports::make_file_executable(self, path).await
383    }
384}
385
386impl From<latest::platform::Architecture> for platform::Architecture {
387    fn from(value: latest::platform::Architecture) -> Self {
388        match value {
389            latest::platform::Architecture::Aarch64 => Self::Aarch64,
390            latest::platform::Architecture::X8664 => Self::X8664,
391        }
392    }
393}
394
395impl From<latest::platform::Os> for platform::Os {
396    fn from(value: latest::platform::Os) -> Self {
397        match value {
398            latest::platform::Os::Linux => Self::Linux,
399            latest::platform::Os::Mac => Self::Mac,
400            latest::platform::Os::Windows => Self::Windows,
401        }
402    }
403}
404
405impl platform::Host for WasmState {
406    async fn current_platform(&mut self) -> Result<(platform::Os, platform::Architecture)> {
407        latest::platform::Host::current_platform(self)
408            .await
409            .map(|(os, arch)| (os.into(), arch.into()))
410    }
411}
412
413impl From<dap::TcpArguments> for latest::dap::TcpArguments {
414    fn from(value: dap::TcpArguments) -> Self {
415        let [a, b, c, d] = std::net::Ipv4Addr::from_bits(value.host).octets();
416        Self {
417            host: latest::dap::IpAddress::Ipv4((a, b, c, d)),
418            port: value.port,
419            timeout: value.timeout,
420        }
421    }
422}
423
424impl TryFrom<latest::dap::TcpArguments> for dap::TcpArguments {
425    type Error = anyhow::Error;
426
427    fn try_from(value: latest::dap::TcpArguments) -> Result<Self> {
428        let host = match value.host {
429            latest::dap::IpAddress::Ipv4((a, b, c, d)) => {
430                std::net::Ipv4Addr::new(a, b, c, d).to_bits()
431            }
432            latest::dap::IpAddress::Ipv6((a, b, c, d, e, f, g, h)) => {
433                let addr = std::net::Ipv6Addr::new(a, b, c, d, e, f, g, h);
434                anyhow::bail!(
435                    "DAP returned IPv6 host {addr}, which the v0.6.0 extension API cannot represent; the extension must be updated to v0.8.0 or later"
436                );
437            }
438        };
439        Ok(Self {
440            host,
441            port: value.port,
442            timeout: value.timeout,
443        })
444    }
445}
446
447impl From<dap::TcpArgumentsTemplate> for latest::dap::TcpArgumentsTemplate {
448    fn from(value: dap::TcpArgumentsTemplate) -> Self {
449        Self {
450            host: value.host.map(|host| {
451                let [a, b, c, d] = std::net::Ipv4Addr::from_bits(host).octets();
452                latest::dap::IpAddress::Ipv4((a, b, c, d))
453            }),
454            port: value.port,
455            timeout: value.timeout,
456        }
457    }
458}
459
460impl From<latest::dap::TcpArgumentsTemplate> for dap::TcpArgumentsTemplate {
461    fn from(value: latest::dap::TcpArgumentsTemplate) -> Self {
462        Self {
463            host: value.host.and_then(|host| match host {
464                latest::dap::IpAddress::Ipv4((a, b, c, d)) => {
465                    Some(std::net::Ipv4Addr::new(a, b, c, d).to_bits())
466                }
467                latest::dap::IpAddress::Ipv6((a, b, c, d, e, f, g, h)) => {
468                    let addr = std::net::Ipv6Addr::new(a, b, c, d, e, f, g, h);
469                    log::warn!(
470                        "Dropping IPv6 host {addr} when handing TCP arguments back to a v0.6.0 extension; update the extension to v0.8.0 or later for IPv6 support"
471                    );
472                    None
473                }
474            }),
475            port: value.port,
476            timeout: value.timeout,
477        }
478    }
479}
480
481impl From<dap::LaunchRequest> for latest::dap::LaunchRequest {
482    fn from(value: dap::LaunchRequest) -> Self {
483        Self {
484            program: value.program,
485            cwd: value.cwd,
486            args: value.args,
487            envs: value.envs,
488        }
489    }
490}
491
492impl From<latest::dap::LaunchRequest> for dap::LaunchRequest {
493    fn from(value: latest::dap::LaunchRequest) -> Self {
494        Self {
495            program: value.program,
496            cwd: value.cwd,
497            args: value.args,
498            envs: value.envs,
499        }
500    }
501}
502
503impl From<dap::AttachRequest> for latest::dap::AttachRequest {
504    fn from(value: dap::AttachRequest) -> Self {
505        Self {
506            process_id: value.process_id,
507        }
508    }
509}
510
511impl From<latest::dap::AttachRequest> for dap::AttachRequest {
512    fn from(value: latest::dap::AttachRequest) -> Self {
513        Self {
514            process_id: value.process_id,
515        }
516    }
517}
518
519impl From<DebugRequest> for latest::DebugRequest {
520    fn from(value: DebugRequest) -> Self {
521        match value {
522            DebugRequest::Launch(req) => Self::Launch(req.into()),
523            DebugRequest::Attach(req) => Self::Attach(req.into()),
524        }
525    }
526}
527
528impl From<latest::DebugRequest> for DebugRequest {
529    fn from(value: latest::DebugRequest) -> Self {
530        match value {
531            latest::DebugRequest::Launch(req) => Self::Launch(req.into()),
532            latest::DebugRequest::Attach(req) => Self::Attach(req.into()),
533        }
534    }
535}
536
537impl From<DebugConfig> for latest::DebugConfig {
538    fn from(value: DebugConfig) -> Self {
539        Self {
540            label: value.label,
541            adapter: value.adapter,
542            request: value.request.into(),
543            stop_on_entry: value.stop_on_entry,
544        }
545    }
546}
547
548impl From<latest::DebugConfig> for DebugConfig {
549    fn from(value: latest::DebugConfig) -> Self {
550        Self {
551            label: value.label,
552            adapter: value.adapter,
553            request: value.request.into(),
554            stop_on_entry: value.stop_on_entry,
555        }
556    }
557}
558
559impl From<dap::TaskTemplate> for latest::dap::TaskTemplate {
560    fn from(value: dap::TaskTemplate) -> Self {
561        Self {
562            label: value.label,
563            command: value.command,
564            args: value.args,
565            env: value.env,
566            cwd: value.cwd,
567        }
568    }
569}
570
571impl From<latest::dap::TaskTemplate> for dap::TaskTemplate {
572    fn from(value: latest::dap::TaskTemplate) -> Self {
573        Self {
574            label: value.label,
575            command: value.command,
576            args: value.args,
577            env: value.env,
578            cwd: value.cwd,
579        }
580    }
581}
582
583impl From<dap::BuildTaskDefinition> for latest::dap::BuildTaskDefinition {
584    fn from(value: dap::BuildTaskDefinition) -> Self {
585        match value {
586            dap::BuildTaskDefinition::ByName(name) => Self::ByName(name),
587            dap::BuildTaskDefinition::Template(payload) => {
588                Self::Template(latest::dap::BuildTaskDefinitionTemplatePayload {
589                    locator_name: payload.locator_name,
590                    template: payload.template.into(),
591                })
592            }
593        }
594    }
595}
596
597impl From<latest::dap::BuildTaskDefinition> for dap::BuildTaskDefinition {
598    fn from(value: latest::dap::BuildTaskDefinition) -> Self {
599        match value {
600            latest::dap::BuildTaskDefinition::ByName(name) => Self::ByName(name),
601            latest::dap::BuildTaskDefinition::Template(payload) => {
602                Self::Template(dap::BuildTaskDefinitionTemplatePayload {
603                    locator_name: payload.locator_name,
604                    template: payload.template.into(),
605                })
606            }
607        }
608    }
609}
610
611impl From<DebugScenario> for latest::DebugScenario {
612    fn from(value: DebugScenario) -> Self {
613        Self {
614            label: value.label,
615            adapter: value.adapter,
616            build: value.build.map(Into::into),
617            config: value.config,
618            tcp_connection: value.tcp_connection.map(Into::into),
619        }
620    }
621}
622
623impl From<latest::DebugScenario> for DebugScenario {
624    fn from(value: latest::DebugScenario) -> Self {
625        Self {
626            label: value.label,
627            adapter: value.adapter,
628            build: value.build.map(Into::into),
629            config: value.config,
630            tcp_connection: value.tcp_connection.map(Into::into),
631        }
632    }
633}
634
635impl From<DebugTaskDefinition> for latest::DebugTaskDefinition {
636    fn from(value: DebugTaskDefinition) -> Self {
637        Self {
638            label: value.label,
639            adapter: value.adapter,
640            config: value.config,
641            tcp_connection: value.tcp_connection.map(Into::into),
642        }
643    }
644}
645
646impl From<latest::DebugTaskDefinition> for DebugTaskDefinition {
647    fn from(value: latest::DebugTaskDefinition) -> Self {
648        Self {
649            label: value.label,
650            adapter: value.adapter,
651            config: value.config,
652            tcp_connection: value.tcp_connection.map(Into::into),
653        }
654    }
655}
656
657impl From<dap::StartDebuggingRequestArgumentsRequest>
658    for latest::dap::StartDebuggingRequestArgumentsRequest
659{
660    fn from(value: dap::StartDebuggingRequestArgumentsRequest) -> Self {
661        match value {
662            dap::StartDebuggingRequestArgumentsRequest::Launch => Self::Launch,
663            dap::StartDebuggingRequestArgumentsRequest::Attach => Self::Attach,
664        }
665    }
666}
667
668impl From<latest::dap::StartDebuggingRequestArgumentsRequest>
669    for dap::StartDebuggingRequestArgumentsRequest
670{
671    fn from(value: latest::dap::StartDebuggingRequestArgumentsRequest) -> Self {
672        match value {
673            latest::dap::StartDebuggingRequestArgumentsRequest::Launch => Self::Launch,
674            latest::dap::StartDebuggingRequestArgumentsRequest::Attach => Self::Attach,
675        }
676    }
677}
678
679impl From<dap::StartDebuggingRequestArguments> for latest::dap::StartDebuggingRequestArguments {
680    fn from(value: dap::StartDebuggingRequestArguments) -> Self {
681        Self {
682            configuration: value.configuration,
683            request: value.request.into(),
684        }
685    }
686}
687
688impl From<latest::dap::StartDebuggingRequestArguments> for dap::StartDebuggingRequestArguments {
689    fn from(value: latest::dap::StartDebuggingRequestArguments) -> Self {
690        Self {
691            configuration: value.configuration,
692            request: value.request.into(),
693        }
694    }
695}
696
697impl From<DebugAdapterBinary> for latest::DebugAdapterBinary {
698    fn from(value: DebugAdapterBinary) -> Self {
699        Self {
700            command: value.command,
701            arguments: value.arguments,
702            envs: value.envs,
703            cwd: value.cwd,
704            connection: value.connection.map(Into::into),
705            request_args: value.request_args.into(),
706        }
707    }
708}
709
710impl TryFrom<latest::DebugAdapterBinary> for DebugAdapterBinary {
711    type Error = anyhow::Error;
712
713    fn try_from(value: latest::DebugAdapterBinary) -> Result<Self> {
714        Ok(Self {
715            command: value.command,
716            arguments: value.arguments,
717            envs: value.envs,
718            cwd: value.cwd,
719            connection: value.connection.map(TryInto::try_into).transpose()?,
720            request_args: value.request_args.into(),
721        })
722    }
723}
724
725impl zed::extension::dap::Host for WasmState {
726    async fn resolve_tcp_template(
727        &mut self,
728        template: dap::TcpArgumentsTemplate,
729    ) -> wasmtime::Result<Result<dap::TcpArguments, String>> {
730        let result = latest::dap::Host::resolve_tcp_template(self, template.into()).await?;
731        Ok(
732            result
733                .and_then(|args| dap::TcpArguments::try_from(args).map_err(|err| err.to_string())),
734        )
735    }
736}
737
Served at tenant.openagents/omega Member data and write actions are omitted.