Skip to main content

core_api/
external_rpc.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::{AuthRequest, AuthenticatedSession, ServiceCoreInput, ServiceCoreOutput};
5use std::collections::HashMap;
6
7pub const EXTERNAL_CORE_PROTOCOL_VERSION: u32 = 17;
8pub const ARTIFACT_CONTENT_PATH_PREFIX: &str = "/artifact/v1/content/";
9pub const ARTIFACT_UPLOAD_PATH_PREFIX: &str = "/artifact/v1/upload/";
10
11/// Derive a bounded, workdir-specific Windows IPC name from the metadata socket path.
12/// The metadata itself stays in the ordinary runtime directory on every platform.
13pub fn external_core_pipe_name(socket_path: &std::path::Path) -> String {
14    use sha2::{Digest, Sha256};
15    let normalized = socket_path
16        .to_string_lossy()
17        .replace('/', "\\")
18        .to_lowercase();
19    format!(
20        r"\\.\pipe\meowcore-{:x}",
21        Sha256::digest(normalized.as_bytes())
22    )
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct ExternalCoreRequest {
27    pub id: String,
28    pub method: ExternalCoreMethod,
29    pub payload: Value,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct ExternalCoreResponse {
34    pub id: String,
35    pub ok: bool,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub result: Option<Value>,
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub error: Option<ExternalCoreError>,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct ExternalCoreError {
44    pub code: String,
45    pub message: String,
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    pub details: Option<Value>,
48}
49
50impl From<crate::ErrorResponse> for ExternalCoreError {
51    fn from(error: crate::ErrorResponse) -> Self {
52        Self {
53            code: error.error,
54            message: error.message,
55            details: error.details,
56        }
57    }
58}
59
60impl From<ExternalCoreError> for crate::ErrorResponse {
61    fn from(error: ExternalCoreError) -> Self {
62        Self {
63            error: error.code,
64            message: error.message,
65            details: error.details,
66        }
67    }
68}
69
70impl std::fmt::Display for ExternalCoreError {
71    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
72        write!(f, "[{}] {}", self.code, self.message)
73    }
74}
75
76impl std::error::Error for ExternalCoreError {}
77
78/// A completed JSON HTTP handler response, including non-2xx responses.
79/// This is an RPC result, not an RPC error. Hosts must preserve both fields.
80#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
81#[serde(rename_all = "camelCase")]
82pub struct HttpPayloadResponse {
83    pub status_code: u16,
84    pub body: Value,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub enum ExternalCoreMethod {
89    HandleCoreInput,
90    RegisterLocalAppClient,
91    RegisterNodeConnection,
92    CleanupWsState,
93    UpdateCallbackBase,
94    PutArtifact,
95    OpenArtifact,
96    AuthorizeArtifactRead,
97    AuthorizeArtifactUpload,
98    CommitArtifactUpload,
99    DeviceIdentity,
100    CommissionFingerprint,
101    CommissionPublicKeyBase64,
102    ListMdnsRecords,
103    PollEvents,
104    CompleteEvents,
105    CommissionChallengePayload,
106    PairingStartPayload,
107    SetupStartPayload,
108    GeneralWebhookPayload,
109    InvokeWasmPayload,
110    Health,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct HandleCoreInputRequest {
115    pub input: ServiceCoreInput,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct HandleCoreInputResponse {
120    pub output: ServiceCoreOutput,
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
124pub struct RegisterLocalAppClientRequest {
125    pub ws_id: String,
126    pub auth_request: AuthRequest,
127    pub session: AuthenticatedSession,
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct RegisterNodeConnectionRequest {
132    pub ws_id: String,
133    pub session_id: String,
134    pub node_type: String,
135    pub node_id: String,
136    #[serde(default, skip_serializing_if = "Option::is_none")]
137    pub host_name: Option<String>,
138    pub tenant_id: String,
139    pub scope_id: String,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
143pub struct CleanupWsStateRequest {
144    pub ws_id: String,
145}
146
147#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
148pub struct UpdateCallbackBaseRequest {
149    /// Host observation, never an independently discovered or fallback address.
150    pub network: crate::host::network::HostNetworkSnapshot,
151    /// Actual bound native HTTPS listener port. Zero means it is not ready.
152    pub port: u16,
153    /// Restricted third-party HTTP listener. Zero disables compatibility URLs.
154    #[serde(default)]
155    pub third_party_port: u16,
156}
157
158impl UpdateCallbackBaseRequest {
159    pub fn callback_base(&self, now_ms: i64) -> Option<String> {
160        if self.third_party_port == 0 {
161            return None;
162        }
163        self.network
164            .available_ipv4(now_ms)
165            .map(|ip| format!("http://{ip}:{}", self.third_party_port))
166    }
167    pub fn native_base(&self, now_ms: i64) -> Option<String> {
168        if self.port == 0 {
169            return None;
170        }
171        self.network
172            .available_ipv4(now_ms)
173            .map(|ip| format!("https://{ip}:{}", self.port))
174    }
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(rename_all = "camelCase")]
179pub struct ExternalCoreDeviceIdentity {
180    pub device_id: String,
181    pub device_name: String,
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(rename_all = "camelCase")]
186pub struct ListMdnsRecordsRequest {
187    pub port: u16,
188    pub addresses: Vec<String>,
189    pub host_type: String,
190}
191
192#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(rename_all = "camelCase")]
194pub struct ExternalCoreMdnsRecord {
195    pub service_type: String,
196    pub instance_name: String,
197    pub port: u16,
198    pub properties: HashMap<String, String>,
199}
200
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(rename_all = "camelCase")]
203pub struct PollExternalCoreEventsRequest {
204    pub consumer_id: String,
205    pub max_events: u16,
206    pub timeout_ms: u64,
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
210#[serde(rename_all = "camelCase")]
211pub struct PollExternalCoreEventsResponse {
212    pub events: Vec<ExternalCoreEvent>,
213    pub timed_out: bool,
214}
215
216#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(rename_all = "camelCase")]
218pub struct CompleteExternalCoreEventsRequest {
219    pub consumer_id: String,
220    pub completions: Vec<ExternalCoreEventCompletion>,
221}
222
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(rename_all = "camelCase")]
225pub struct CompleteExternalCoreEventsResponse {
226    pub completed_event_ids: Vec<String>,
227    pub missing_event_ids: Vec<String>,
228}
229
230#[derive(Debug, Clone, Serialize, Deserialize)]
231#[serde(rename_all = "camelCase")]
232pub struct ExternalCoreEvent {
233    pub event_id: String,
234    pub kind: ExternalCoreEventKind,
235    pub payload: Value,
236    pub expects_response: bool,
237}
238
239#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
240#[serde(rename_all = "camelCase")]
241pub enum ExternalCoreEventKind {
242    MdnsRecordsChanged,
243    DeliveryRequested,
244    ConnectionControlRequested,
245    HostRuntimeRequest,
246    ServiceAppFacadeRequest,
247    ScopeOwnedDataPurgeRequested,
248    ArtifactDeliveryProjectionRequested,
249    ArtifactUploadProjectionRequested,
250}
251
252/// Messaging-only Core -> Host request. A successful response means delivery was accepted by
253/// the provider implementation, not merely queued in the Core event pump or read by a user.
254#[derive(Debug, Clone, Serialize, Deserialize)]
255#[serde(rename_all = "camelCase", deny_unknown_fields)]
256pub struct MessagingDeliveryRequest {
257    pub tenant_id: String,
258    pub scope_id: String,
259    pub surface_id: String,
260    pub target: String,
261    pub payload: String,
262}
263
264#[derive(Debug, Clone, Serialize, Deserialize)]
265#[serde(rename_all = "camelCase", deny_unknown_fields)]
266pub struct MessagingDeliveryResponse {
267    pub outcome: crate::DeliveryOutcome,
268}
269
270#[derive(Debug, Clone, Serialize, Deserialize)]
271#[serde(rename_all = "camelCase", deny_unknown_fields)]
272pub struct ExternalArtifactRequestContext {
273    pub tenant_id: String,
274    pub scope_id: String,
275    pub actor_user_id: String,
276    pub client_id: String,
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize)]
280#[serde(rename_all = "camelCase", deny_unknown_fields)]
281pub struct ExternalPutArtifactRequest {
282    pub context: ExternalArtifactRequestContext,
283    pub artifact: artifact_api::PutArtifactRequest,
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize)]
287#[serde(rename_all = "camelCase", deny_unknown_fields)]
288pub struct ExternalOpenArtifactRequest {
289    pub context: ExternalArtifactRequestContext,
290    pub uri: String,
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize)]
294#[serde(rename_all = "camelCase", deny_unknown_fields)]
295pub struct ExternalAuthorizeArtifactReadRequest {
296    pub grant: String,
297}
298
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(rename_all = "camelCase", deny_unknown_fields)]
301pub struct ExternalAuthorizeArtifactUploadRequest {
302    pub grant: String,
303}
304
305#[derive(Debug, Clone, Serialize, Deserialize)]
306#[serde(rename_all = "camelCase", deny_unknown_fields)]
307pub struct ExternalCommitArtifactUploadRequest {
308    #[serde(default, skip_serializing_if = "Option::is_none")]
309    pub data_base64: Option<String>,
310    pub grant: String,
311}
312
313#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
314#[serde(rename_all = "camelCase", deny_unknown_fields)]
315pub struct ExternalArtifactReadDescriptor {
316    #[serde(default, skip_serializing_if = "Option::is_none")]
317    pub data_base64: Option<String>,
318    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
319    pub temporary: bool,
320    pub path: String,
321    pub kind: artifact_api::ArtifactKind,
322    pub mime_type: String,
323    pub size_bytes: u64,
324    #[serde(default, skip_serializing_if = "Option::is_none")]
325    pub width: Option<u32>,
326    #[serde(default, skip_serializing_if = "Option::is_none")]
327    pub height: Option<u32>,
328    #[serde(default, skip_serializing_if = "Option::is_none")]
329    pub duration_millis: Option<u64>,
330    pub sha256: String,
331}
332
333#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
334#[serde(rename_all = "camelCase", deny_unknown_fields)]
335pub struct ExternalArtifactUploadDescriptor {
336    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
337    pub temporary: bool,
338    pub upload_id: String,
339    pub path: String,
340    pub kind: artifact_api::ArtifactKind,
341    pub mime_type: String,
342    pub size_bytes: u64,
343    pub sha256: String,
344    #[serde(default, skip_serializing_if = "Option::is_none")]
345    pub duration_millis: Option<u64>,
346    pub expires_at_unix_ms: u64,
347}
348
349#[derive(Debug, Clone, Serialize, Deserialize)]
350#[serde(rename_all = "camelCase", deny_unknown_fields)]
351pub struct ArtifactDeliveryProjectionRequest {
352    /// Explicit compatibility request; native traffic must remain HTTPS.
353    #[serde(default)]
354    pub third_party: bool,
355    pub grant: String,
356    pub expires_at_unix_ms: u64,
357    pub client_id: String,
358}
359
360#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
361#[serde(rename_all = "camelCase", deny_unknown_fields)]
362pub struct ArtifactDeliveryProjectionResponse {
363    #[serde(default, skip_serializing_if = "Option::is_none")]
364    pub host_identity: Option<artifact_api::HostTlsIdentity>,
365    pub url: String,
366}
367
368#[derive(Debug, Clone, Serialize, Deserialize)]
369#[serde(rename_all = "camelCase", deny_unknown_fields)]
370pub struct ArtifactUploadProjectionRequest {
371    pub grant: String,
372    pub expires_at_unix_ms: u64,
373    pub client_id: String,
374}
375
376#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
377#[serde(rename_all = "camelCase", deny_unknown_fields)]
378pub struct ArtifactUploadProjectionResponse {
379    #[serde(default, skip_serializing_if = "Option::is_none")]
380    pub host_identity: Option<artifact_api::HostTlsIdentity>,
381    pub url: String,
382}
383
384/// An App Facade request delegated by an externally hosted Core to the
385/// application service that owns the target's business logic.
386#[derive(Debug, Clone, Serialize, Deserialize)]
387#[serde(rename_all = "camelCase")]
388pub struct ExternalServiceAppFacadeRequest {
389    pub target: String,
390    pub tenant_id: String,
391    pub scope_id: String,
392    pub user_id: String,
393    #[serde(default, skip_serializing_if = "Option::is_none")]
394    pub client_id: Option<String>,
395    pub payload: Value,
396}
397
398/// A platform capability request emitted by an externally hosted Core.
399///
400/// Core owns the onboarding workflow. The native host owns LAN discovery and
401/// transport to a discovered candidate, so Android can satisfy this contract
402/// without moving application logic into the mobile shell.
403#[derive(Debug, Clone, Serialize, Deserialize)]
404#[serde(rename_all = "camelCase")]
405pub struct ExternalHostRuntimeRequest {
406    #[serde(default, skip_serializing_if = "Option::is_none")]
407    pub host_public_key: Option<crate::host::auth::PublicKey>,
408    pub method: ExternalHostRuntimeMethod,
409    #[serde(default, skip_serializing_if = "Option::is_none")]
410    pub candidate_id: Option<String>,
411    #[serde(default, skip_serializing_if = "Option::is_none")]
412    pub action: Option<String>,
413    #[serde(default, skip_serializing_if = "Option::is_none")]
414    pub payload: Option<Value>,
415}
416
417#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
418#[serde(rename_all = "camelCase")]
419pub enum ExternalHostRuntimeMethod {
420    Discovery,
421    CandidateRequest,
422}
423
424#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
425#[serde(rename_all = "camelCase")]
426pub struct ScopeOwnedDataPurgeRequest {
427    pub tenant_id: String,
428    pub scope_id: String,
429}
430
431#[derive(Debug, Clone, Serialize, Deserialize)]
432#[serde(rename_all = "camelCase")]
433pub struct ExternalCoreEventCompletion {
434    pub event_id: String,
435    pub ok: bool,
436    #[serde(default, skip_serializing_if = "Option::is_none")]
437    pub response: Option<Value>,
438    #[serde(default, skip_serializing_if = "Option::is_none")]
439    pub error: Option<ExternalCoreError>,
440}
441
442#[derive(Debug, Clone, Serialize, Deserialize)]
443pub struct HttpPayloadRequest {
444    pub payload: Value,
445}
446
447#[derive(Debug, Clone, Serialize, Deserialize)]
448pub struct EndpointPayloadRequest {
449    pub endpoint_id: String,
450    pub payload: Value,
451}
452
453#[derive(Debug, Clone, Serialize, Deserialize)]
454#[serde(rename_all = "camelCase")]
455pub struct ExternalCoreRuntimeMetadata {
456    pub backend: String,
457    pub instance_id: String,
458    pub pid: u32,
459    pub state: String,
460    pub started_at: String,
461    pub protocol_version: u32,
462    pub binary_version: String,
463    pub socket_path: String,
464}
465
466#[derive(Debug, Clone, Serialize, Deserialize)]
467#[serde(rename_all = "camelCase")]
468pub struct ExternalCoreHealth {
469    pub ok: bool,
470    pub ready: bool,
471    pub backend: String,
472    pub binary_version: String,
473    pub agent_version: String,
474    pub protocol_version: u32,
475    #[serde(skip_serializing_if = "Option::is_none")]
476    pub instance_id: Option<String>,
477    #[serde(skip_serializing_if = "Option::is_none")]
478    pub pid: Option<u32>,
479    #[serde(skip_serializing_if = "Option::is_none")]
480    pub state: Option<String>,
481    #[serde(skip_serializing_if = "Option::is_none")]
482    pub started_at: Option<String>,
483    #[serde(default)]
484    pub capabilities: Vec<String>,
485}
486
487impl ExternalArtifactReadDescriptor {
488    /// Decode the bounded inline variant. File descriptors return None.
489    pub fn inline_content(&self) -> Result<Option<Vec<u8>>, String> {
490        use base64::Engine as _;
491        use sha2::{Digest, Sha256};
492        let Some(encoded) = &self.data_base64 else {
493            return if self.path.is_empty() {
494                Err("artifact descriptor has no content".into())
495            } else {
496                Ok(None)
497            };
498        };
499        if !self.path.is_empty()
500            || self.size_bytes > artifact_api::MAX_MEMORY_ARTIFACT_BYTES as u64
501            || encoded.len() > artifact_api::MAX_MEMORY_ARTIFACT_BYTES.div_ceil(3) * 4
502        {
503            return Err("invalid inline artifact descriptor".into());
504        }
505        let bytes = base64::engine::general_purpose::STANDARD
506            .decode(encoded)
507            .map_err(|_| "invalid inline artifact base64")?;
508        if bytes.len() as u64 != self.size_bytes
509            || format!("{:x}", Sha256::digest(&bytes)) != self.sha256
510        {
511            return Err("inline artifact failed its integrity check".into());
512        }
513        Ok(Some(bytes))
514    }
515}
516
517#[cfg(test)]
518mod tests {
519    use super::*;
520
521    #[test]
522    fn callback_address_requires_a_fresh_host_observation_and_bound_port() {
523        let mut request = UpdateCallbackBaseRequest {
524            third_party_port: 0,
525            network: crate::host::network::HostNetworkSnapshot {
526                lan_ipv4: Some("192.168.1.5".parse().unwrap()),
527                observed_at_ms: 100_000,
528            },
529            port: 3210,
530        };
531        assert_eq!(
532            request.native_base(100_000).as_deref(),
533            Some("https://192.168.1.5:3210")
534        );
535        let roundtrip: UpdateCallbackBaseRequest =
536            serde_json::from_value(serde_json::to_value(&request).unwrap()).unwrap();
537        assert_eq!(request, roundtrip);
538        assert_eq!(request.callback_base(100_000), None);
539        request.third_party_port = 3211;
540        assert_eq!(
541            request.callback_base(100_000).as_deref(),
542            Some("http://192.168.1.5:3211")
543        );
544        assert_eq!(request.callback_base(145_000), None);
545        assert_eq!(request.native_base(145_000), None);
546        request.port = 0;
547        assert_eq!(request.native_base(100_000), None);
548        assert_eq!(
549            UpdateCallbackBaseRequest::default().native_base(100_000),
550            None
551        );
552    }
553
554    #[test]
555    fn messaging_delivery_is_a_closed_request_response_contract() {
556        let request = serde_json::json!({"tenantId":"t", "scopeId":"s", "surfaceId":"m",
557            "target":"/chat/event", "payload":"{}"});
558        let decoded: MessagingDeliveryRequest = serde_json::from_value(request.clone()).unwrap();
559        assert_eq!(serde_json::to_value(decoded).unwrap(), request);
560        let mut invalid = request;
561        invalid["unknown"] = serde_json::json!(true);
562        assert!(serde_json::from_value::<MessagingDeliveryRequest>(invalid).is_err());
563        assert!(
564            serde_json::from_value::<MessagingDeliveryResponse>(serde_json::json!({})).is_err()
565        );
566        assert_eq!(
567            serde_json::to_value(ExternalCoreEventKind::DeliveryRequested).unwrap(),
568            "deliveryRequested"
569        );
570    }
571
572    #[test]
573    fn external_events_use_the_current_wire_shape() {
574        let event = ExternalCoreEvent {
575            event_id: "event-1".to_string(),
576            kind: ExternalCoreEventKind::ScopeOwnedDataPurgeRequested,
577            payload: serde_json::to_value(ScopeOwnedDataPurgeRequest {
578                tenant_id: "tenant-1".to_string(),
579                scope_id: "scope-1".to_string(),
580            })
581            .unwrap(),
582            expects_response: true,
583        };
584
585        let value = serde_json::to_value(event).unwrap();
586        assert_eq!(EXTERNAL_CORE_PROTOCOL_VERSION, 17);
587        assert_eq!(value["kind"], "scopeOwnedDataPurgeRequested");
588        assert_eq!(value["payload"]["tenantId"], "tenant-1");
589        assert_eq!(value["payload"]["scopeId"], "scope-1");
590        assert_eq!(value["expectsResponse"], true);
591
592        let facade = ExternalCoreEvent {
593            event_id: "event-2".to_string(),
594            kind: ExternalCoreEventKind::ServiceAppFacadeRequest,
595            payload: serde_json::to_value(ExternalServiceAppFacadeRequest {
596                target: "/app/messaging/provider/list".to_string(),
597                tenant_id: "tenant-1".to_string(),
598                scope_id: "scope-1".to_string(),
599                user_id: "user-1".to_string(),
600                client_id: None,
601                payload: serde_json::json!({"placement": "local"}),
602            })
603            .unwrap(),
604            expects_response: true,
605        };
606        let value = serde_json::to_value(facade).unwrap();
607        assert_eq!(value["kind"], "serviceAppFacadeRequest");
608        assert_eq!(value["payload"]["target"], "/app/messaging/provider/list");
609        assert_eq!(value["payload"]["userId"], "user-1");
610        assert!(value["payload"].get("clientId").is_none());
611    }
612
613    #[test]
614    fn artifact_host_contract_uses_canonical_wire_types() {
615        let descriptor = ExternalArtifactReadDescriptor {
616            temporary: false,
617            data_base64: None,
618            path: "/runtime/artifacts/blob".to_string(),
619            kind: artifact_api::ArtifactKind::Audio,
620            mime_type: "audio/ogg".to_string(),
621            size_bytes: 42,
622            width: None,
623            height: None,
624            duration_millis: Some(1_500),
625            sha256: "a".repeat(64),
626        };
627        let value = serde_json::to_value(descriptor).unwrap();
628        assert_eq!(value["kind"], "AUDIO");
629        assert_eq!(value["mimeType"], "audio/ogg");
630        assert_eq!(value["durationMillis"], 1_500);
631        assert!(value.get("width").is_none());
632
633        let request = ArtifactDeliveryProjectionRequest {
634            third_party: false,
635            grant: "payload.signature".to_string(),
636            expires_at_unix_ms: 123,
637            client_id: "L:client".to_string(),
638        };
639        let value = serde_json::to_value(request).unwrap();
640        assert_eq!(value["expiresAtUnixMs"], 123);
641        assert_eq!(value["clientId"], "L:client");
642    }
643
644    #[test]
645    fn playground_uses_only_the_general_webhook_contract() {
646        let general = serde_json::to_value(ExternalCoreMethod::GeneralWebhookPayload).unwrap();
647        assert_eq!(general, serde_json::json!("GeneralWebhookPayload"));
648        assert!(
649            serde_json::from_value::<ExternalCoreMethod>(serde_json::json!(
650                "PlaygroundWebhookPayload"
651            ))
652            .is_err()
653        );
654    }
655}