agent-uri 0.5.0

Parser and validator for agent:// URI scheme
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
//! Main agent URI type.
//!
//! # Grammar Reference
//!
//! The URI grammar is defined in `grammar.abnf` at the crate root:
//!
//! ```abnf
//! agent-uri = scheme "://" trust-root "/" capability-path "/" agent-id
//!             [ "?" query ] [ "#" fragment ]
//! scheme    = "agent"
//! ```
//!
//! Maximum URI length: 512 characters.

use std::cmp::Ordering;
use std::fmt;
use std::str::FromStr;

use crate::agent_id::AgentId;
use crate::capability_path::CapabilityPath;
use crate::constants::{MAX_URI_LENGTH, SCHEME};
use crate::error::{ParseError, ParseErrorKind};
use crate::fragment::Fragment;
use crate::query::QueryParams;
use crate::trust_root::TrustRoot;

/// A parsed and validated agent URI.
///
/// Agent URIs provide topology-independent identity for agents with
/// capability-based discovery.
///
/// # Structure
///
/// ```text
/// agent://<trust-root>/<capability-path>/<agent-id>[?query][#fragment]
/// ```
///
/// # Examples
///
/// ```
/// use agent_uri::AgentUri;
///
/// let uri = AgentUri::parse("agent://anthropic.com/assistant/chat/llm_chat_01h455vb4pex5vsknk084sn02q").unwrap();
/// assert_eq!(uri.trust_root().host_str(), "anthropic.com");
/// assert_eq!(uri.capability_path().as_str(), "assistant/chat");
/// assert_eq!(uri.agent_id().prefix().as_str(), "llm_chat");
///
/// // With query and fragment
/// let uri = AgentUri::parse("agent://openai.com/tool/code/llm_01h455vb4pex5vsknk084sn02q?version=2.0#summarization").unwrap();
/// assert_eq!(uri.query().version(), Some("2.0"));
/// assert_eq!(uri.fragment().map(|f| f.as_str()), Some("summarization"));
/// ```
#[derive(Debug, Clone)]
pub struct AgentUri {
    trust_root: TrustRoot,
    capability_path: CapabilityPath,
    agent_id: AgentId,
    query: QueryParams,
    fragment: Option<Fragment>,
    /// Normalized string representation
    normalized: String,
}

impl PartialEq for AgentUri {
    fn eq(&self, other: &Self) -> bool {
        self.trust_root == other.trust_root
            && self.capability_path == other.capability_path
            && self.agent_id == other.agent_id
    }
}

impl Eq for AgentUri {}

impl AgentUri {
    /// Parses an agent URI from a string.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if:
    /// - The URI is empty
    /// - The URI exceeds 512 characters
    /// - The scheme is not "agent://"
    /// - Any component (trust root, path, agent ID, query, fragment) is invalid
    pub fn parse(input: &str) -> Result<Self, ParseError> {
        Self::parse_inner(input).map_err(|kind| ParseError {
            input: input.to_string(),
            kind,
        })
    }

    /// Creates a new agent URI from its components.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the resulting URI would exceed the maximum length.
    pub fn new(
        trust_root: TrustRoot,
        capability_path: CapabilityPath,
        agent_id: AgentId,
        query: QueryParams,
        fragment: Option<Fragment>,
    ) -> Result<Self, ParseError> {
        let normalized = Self::normalize(
            &trust_root,
            &capability_path,
            &agent_id,
            &query,
            fragment.as_ref(),
        );
        let len = normalized.len();

        if len > MAX_URI_LENGTH {
            return Err(ParseError {
                input: normalized,
                kind: ParseErrorKind::TooLong {
                    max: MAX_URI_LENGTH,
                    actual: len,
                },
            });
        }

        Ok(Self {
            trust_root,
            capability_path,
            agent_id,
            query,
            fragment,
            normalized,
        })
    }

    /// Returns the trust root.
    #[must_use]
    pub const fn trust_root(&self) -> &TrustRoot {
        &self.trust_root
    }

    /// Returns the capability path.
    #[must_use]
    pub const fn capability_path(&self) -> &CapabilityPath {
        &self.capability_path
    }

    /// Returns the agent ID.
    #[must_use]
    pub const fn agent_id(&self) -> &AgentId {
        &self.agent_id
    }

    /// Returns the query parameters.
    #[must_use]
    pub const fn query(&self) -> &QueryParams {
        &self.query
    }

    /// Returns the fragment, if present.
    #[must_use]
    pub const fn fragment(&self) -> Option<&Fragment> {
        self.fragment.as_ref()
    }

    /// Returns the normalized URI string.
    #[must_use]
    pub fn as_str(&self) -> &str {
        &self.normalized
    }

    /// Returns the canonical URI (without query and fragment).
    #[must_use]
    pub fn canonical(&self) -> String {
        format!(
            "{SCHEME}://{}/{}/{}",
            self.trust_root, self.capability_path, self.agent_id
        )
    }

    /// Returns true if this URI references a localhost agent.
    #[must_use]
    pub fn is_localhost(&self) -> bool {
        self.trust_root.is_localhost()
    }

    /// Returns a new URI with the given query parameters.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the resulting URI would exceed the maximum length.
    ///
    /// # Examples
    ///
    /// ```
    /// use agent_uri::{AgentUri, QueryParams};
    ///
    /// let uri = AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
    /// let query = QueryParams::parse("version=2.0").unwrap();
    /// let updated = uri.with_query(query).unwrap();
    /// assert_eq!(updated.query().version(), Some("2.0"));
    /// ```
    pub fn with_query(&self, query: QueryParams) -> Result<Self, ParseError> {
        Self::new(
            self.trust_root.clone(),
            self.capability_path.clone(),
            self.agent_id.clone(),
            query,
            self.fragment.clone(),
        )
    }

    /// Returns a new URI with query parameters parsed from a string.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the query string is invalid or the resulting URI
    /// would exceed the maximum length.
    ///
    /// # Examples
    ///
    /// ```
    /// use agent_uri::AgentUri;
    ///
    /// let uri = AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
    /// let updated = uri.with_query_str("version=2.0&ttl=300").unwrap();
    /// assert_eq!(updated.query().version(), Some("2.0"));
    /// assert_eq!(updated.query().ttl(), Some(300));
    /// ```
    pub fn with_query_str(&self, s: &str) -> Result<Self, ParseError> {
        let query = QueryParams::parse(s).map_err(|e| ParseError {
            input: s.to_string(),
            kind: ParseErrorKind::InvalidQuery(e),
        })?;
        self.with_query(query)
    }

    /// Returns a new URI without query parameters.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the resulting URI would exceed the maximum length.
    /// (This is unlikely but possible in edge cases.)
    ///
    /// # Examples
    ///
    /// ```
    /// use agent_uri::AgentUri;
    ///
    /// let uri = AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q?version=2.0").unwrap();
    /// let updated = uri.without_query().unwrap();
    /// assert!(updated.query().is_empty());
    /// ```
    pub fn without_query(&self) -> Result<Self, ParseError> {
        self.with_query(QueryParams::new())
    }

    /// Returns a new URI with the given fragment.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the resulting URI would exceed the maximum length.
    ///
    /// # Examples
    ///
    /// ```
    /// use agent_uri::{AgentUri, Fragment};
    ///
    /// let uri = AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
    /// let fragment = Fragment::parse("summarization").unwrap();
    /// let updated = uri.with_fragment(fragment).unwrap();
    /// assert_eq!(updated.fragment().map(|f| f.as_str()), Some("summarization"));
    /// ```
    pub fn with_fragment(&self, fragment: Fragment) -> Result<Self, ParseError> {
        Self::new(
            self.trust_root.clone(),
            self.capability_path.clone(),
            self.agent_id.clone(),
            self.query.clone(),
            Some(fragment),
        )
    }

    /// Returns a new URI with a fragment parsed from a string.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the fragment is invalid or the resulting URI
    /// would exceed the maximum length.
    ///
    /// # Examples
    ///
    /// ```
    /// use agent_uri::AgentUri;
    ///
    /// let uri = AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
    /// let updated = uri.with_fragment_str("summarization").unwrap();
    /// assert_eq!(updated.fragment().map(|f| f.as_str()), Some("summarization"));
    /// ```
    pub fn with_fragment_str(&self, s: &str) -> Result<Self, ParseError> {
        let fragment = Fragment::parse(s).map_err(|e| ParseError {
            input: s.to_string(),
            kind: ParseErrorKind::InvalidFragment(e),
        })?;
        self.with_fragment(fragment)
    }

    /// Returns a new URI without a fragment.
    ///
    /// # Errors
    ///
    /// Returns `ParseError` if the resulting URI would exceed the maximum length.
    /// (This is unlikely but possible in edge cases.)
    ///
    /// # Examples
    ///
    /// ```
    /// use agent_uri::AgentUri;
    ///
    /// let uri = AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q#test").unwrap();
    /// let updated = uri.without_fragment().unwrap();
    /// assert!(updated.fragment().is_none());
    /// ```
    pub fn without_fragment(&self) -> Result<Self, ParseError> {
        Self::new(
            self.trust_root.clone(),
            self.capability_path.clone(),
            self.agent_id.clone(),
            self.query.clone(),
            None,
        )
    }

    fn parse_inner(input: &str) -> Result<Self, ParseErrorKind> {
        if input.is_empty() {
            return Err(ParseErrorKind::Empty);
        }

        if input.len() > MAX_URI_LENGTH {
            return Err(ParseErrorKind::TooLong {
                max: MAX_URI_LENGTH,
                actual: input.len(),
            });
        }

        // Check and strip scheme
        let scheme_prefix = format!("{SCHEME}://");
        if !input.starts_with(&scheme_prefix) {
            let found = input.split("://").next().map(str::to_string);
            return Err(ParseErrorKind::InvalidScheme { found });
        }
        let rest = &input[scheme_prefix.len()..];

        // Split off fragment
        let (rest, fragment) = Self::split_fragment(rest)?;

        // Split off query
        let (rest, query) = Self::split_query(rest)?;

        // Split trust root from path
        let (trust_root_str, path_with_id) = Self::split_trust_root(rest)?;

        // Parse trust root
        let trust_root =
            TrustRoot::parse(trust_root_str).map_err(ParseErrorKind::InvalidTrustRoot)?;

        // Split capability path from agent ID (agent ID is always the last segment)
        let (cap_path_str, agent_id_str) = Self::split_path_and_id(path_with_id)?;

        // Parse capability path
        let capability_path =
            CapabilityPath::parse(cap_path_str).map_err(ParseErrorKind::InvalidCapabilityPath)?;

        // Parse agent ID
        let agent_id = AgentId::parse(agent_id_str).map_err(ParseErrorKind::InvalidAgentId)?;

        let normalized = Self::normalize(
            &trust_root,
            &capability_path,
            &agent_id,
            &query,
            fragment.as_ref(),
        );

        Ok(Self {
            trust_root,
            capability_path,
            agent_id,
            query,
            fragment,
            normalized,
        })
    }

    fn split_fragment(input: &str) -> Result<(&str, Option<Fragment>), ParseErrorKind> {
        if let Some(hash_idx) = input.find('#') {
            let rest = &input[..hash_idx];
            let frag_str = &input[hash_idx + 1..];
            if frag_str.is_empty() {
                Ok((rest, None)) // Empty fragment is stripped
            } else {
                let fragment =
                    Fragment::parse(frag_str).map_err(ParseErrorKind::InvalidFragment)?;
                Ok((rest, Some(fragment)))
            }
        } else {
            Ok((input, None))
        }
    }

    fn split_query(input: &str) -> Result<(&str, QueryParams), ParseErrorKind> {
        if let Some(q_idx) = input.find('?') {
            let rest = &input[..q_idx];
            let query_str = &input[q_idx + 1..];
            if query_str.is_empty() {
                Ok((rest, QueryParams::new())) // Empty query is stripped
            } else {
                let query = QueryParams::parse(query_str).map_err(ParseErrorKind::InvalidQuery)?;
                Ok((rest, query))
            }
        } else {
            Ok((input, QueryParams::new()))
        }
    }

    fn split_trust_root(input: &str) -> Result<(&str, &str), ParseErrorKind> {
        // Find the first '/' which separates trust root from path
        let slash_idx = input.find('/').ok_or(ParseErrorKind::MissingComponent {
            component: "capability path",
        })?;

        let trust_root = &input[..slash_idx];
        let path = &input[slash_idx + 1..];

        if trust_root.is_empty() {
            return Err(ParseErrorKind::MissingComponent {
                component: "trust root",
            });
        }

        if path.is_empty() {
            return Err(ParseErrorKind::MissingComponent {
                component: "capability path",
            });
        }

        Ok((trust_root, path))
    }

    fn split_path_and_id(input: &str) -> Result<(&str, &str), ParseErrorKind> {
        // The agent ID is the last segment
        let last_slash_idx = input.rfind('/').ok_or(ParseErrorKind::MissingComponent {
            component: "agent ID",
        })?;

        let path = &input[..last_slash_idx];
        let agent_id = &input[last_slash_idx + 1..];

        if path.is_empty() {
            return Err(ParseErrorKind::MissingComponent {
                component: "capability path",
            });
        }

        if agent_id.is_empty() {
            return Err(ParseErrorKind::MissingComponent {
                component: "agent ID",
            });
        }

        Ok((path, agent_id))
    }

    fn normalize(
        trust_root: &TrustRoot,
        capability_path: &CapabilityPath,
        agent_id: &AgentId,
        query: &QueryParams,
        fragment: Option<&Fragment>,
    ) -> String {
        let mut result = format!("{SCHEME}://{trust_root}/{capability_path}/{agent_id}");

        if !query.is_empty() {
            result.push('?');
            result.push_str(&query.to_string());
        }

        if let Some(frag) = fragment {
            result.push('#');
            result.push_str(frag.as_str());
        }

        result
    }
}

impl fmt::Display for AgentUri {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.normalized)
    }
}

impl FromStr for AgentUri {
    type Err = ParseError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Self::parse(s)
    }
}

impl AsRef<str> for AgentUri {
    fn as_ref(&self) -> &str {
        &self.normalized
    }
}

impl TryFrom<&str> for AgentUri {
    type Error = ParseError;

    fn try_from(s: &str) -> Result<Self, Self::Error> {
        Self::parse(s)
    }
}

impl PartialOrd for AgentUri {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for AgentUri {
    fn cmp(&self, other: &Self) -> Ordering {
        self.canonical().cmp(&other.canonical())
    }
}

#[cfg(feature = "serde")]
impl serde::Serialize for AgentUri {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(&self.normalized)
    }
}

#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for AgentUri {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = String::deserialize(deserializer)?;
        Self::parse(&s).map_err(serde::de::Error::custom)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn parse_valid_uri() {
        let input = "agent://anthropic.com/assistant/chat/llm_chat_01h455vb4pex5vsknk084sn02q";
        let uri = AgentUri::parse(input).unwrap();

        assert_eq!(uri.trust_root().host_str(), "anthropic.com");
        assert_eq!(uri.capability_path().as_str(), "assistant/chat");
        assert_eq!(uri.agent_id().prefix().as_str(), "llm_chat");
    }

    #[test]
    fn parse_empty_returns_error() {
        let result = AgentUri::parse("");
        assert!(matches!(
            result,
            Err(ParseError {
                kind: ParseErrorKind::Empty,
                ..
            })
        ));
    }

    #[test]
    fn parse_too_long_returns_error() {
        let long_path = "a".repeat(500);
        let input = format!("agent://x.com/{long_path}/llm_01h455vb4pex5vsknk084sn02q");
        let result = AgentUri::parse(&input);
        assert!(matches!(
            result,
            Err(ParseError {
                kind: ParseErrorKind::TooLong { .. },
                ..
            })
        ));
    }

    #[test]
    fn parse_wrong_scheme_returns_error() {
        let result = AgentUri::parse("http://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q");
        assert!(matches!(
            result,
            Err(ParseError {
                kind: ParseErrorKind::InvalidScheme { .. },
                ..
            })
        ));
    }

    #[test]
    fn parse_with_query_params() {
        let input = "agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q?version=2.0&ttl=300";
        let uri = AgentUri::parse(input).unwrap();

        assert_eq!(uri.query().version(), Some("2.0"));
        assert_eq!(uri.query().ttl(), Some(300));
    }

    #[test]
    fn parse_with_fragment() {
        let input = "agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q#summarization";
        let uri = AgentUri::parse(input).unwrap();

        assert_eq!(
            uri.fragment().map(crate::Fragment::as_str),
            Some("summarization")
        );
    }

    #[test]
    fn empty_query_is_stripped() {
        let input = "agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q?";
        let uri = AgentUri::parse(input).unwrap();
        assert!(uri.query().is_empty());
    }

    #[test]
    fn empty_fragment_is_stripped() {
        let input = "agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q#";
        let uri = AgentUri::parse(input).unwrap();
        assert!(uri.fragment().is_none());
    }

    #[test]
    fn canonical_strips_query_and_fragment() {
        let input = "agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q?version=2.0#test";
        let uri = AgentUri::parse(input).unwrap();
        let canonical = uri.canonical();

        assert!(!canonical.contains('?'));
        assert!(!canonical.contains('#'));
    }

    #[test]
    fn query_and_fragment_do_not_change_identity_equality() {
        let base =
            AgentUri::parse("agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
        let decorated = AgentUri::parse(
            "agent://anthropic.com/chat/llm_01h455vb4pex5vsknk084sn02q?version=2.0#task",
        )
        .unwrap();

        assert_eq!(base, decorated);
        assert_eq!(base.cmp(&decorated), Ordering::Equal);
    }

    #[test]
    fn is_localhost() {
        let uri =
            AgentUri::parse("agent://localhost:8472/test/llm_01h455vb4pex5vsknk084sn02q").unwrap();
        assert!(uri.is_localhost());

        let uri = AgentUri::parse("agent://127.0.0.1/test/llm_01h455vb4pex5vsknk084sn02q").unwrap();
        assert!(uri.is_localhost());

        let uri =
            AgentUri::parse("agent://anthropic.com/test/llm_01h455vb4pex5vsknk084sn02q").unwrap();
        assert!(!uri.is_localhost());
    }

    #[test]
    fn parse_missing_capability_path() {
        let result = AgentUri::parse("agent://anthropic.com/llm_01h455vb4pex5vsknk084sn02q");
        assert!(matches!(
            result,
            Err(ParseError {
                kind: ParseErrorKind::MissingComponent {
                    component: "agent ID"
                },
                ..
            })
        ));
    }

    #[test]
    fn display_roundtrip() {
        let input = "agent://anthropic.com/assistant/chat/llm_chat_01h455vb4pex5vsknk084sn02q";
        let uri = AgentUri::parse(input).unwrap();
        assert_eq!(uri.to_string(), input);
    }

    #[test]
    fn new_from_components() {
        let trust_root = TrustRoot::parse("anthropic.com").unwrap();
        let cap_path = CapabilityPath::parse("assistant/chat").unwrap();
        let agent_id = AgentId::parse("llm_01h455vb4pex5vsknk084sn02q").unwrap();

        let uri = AgentUri::new(trust_root, cap_path, agent_id, QueryParams::new(), None).unwrap();

        assert_eq!(uri.trust_root().host_str(), "anthropic.com");
        assert_eq!(uri.capability_path().as_str(), "assistant/chat");
    }
}