Skip to main content

systemprompt_identifiers/
bridge.rs

1//! Identifiers the bridge binary carries between coding-agent hosts and the
2//! gateway: the MCP transport session a probe negotiated, the hook session a
3//! host reports, the id of a comms announcement, the Claude Desktop
4//! deployment organisation, and the UUID that pairs an elevated helper job's
5//! request with its result.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10use crate::error::IdValidationError;
11
12crate::define_id!(McpSessionId, checked, |value| {
13    crate::macros::validate_non_empty("McpSessionId", value)
14});
15crate::define_id!(HookSessionId, checked, |value| {
16    crate::macros::validate_non_empty("HookSessionId", value)
17});
18crate::define_id!(CommsMessageId, checked, |value| {
19    crate::macros::validate_non_empty("CommsMessageId", value)
20});
21crate::define_id!(ElevatedJobId, uuid);
22crate::define_id!(
23    DeploymentOrganizationUuid,
24    checked,
25    validate_deployment_organization_uuid
26);
27
28fn validate_deployment_organization_uuid(value: &str) -> Result<(), IdValidationError> {
29    let hyphenated = value.len() == 36 && value.bytes().filter(|&b| b == b'-').count() == 4;
30    if hyphenated && uuid::Uuid::try_parse(value).is_ok() {
31        return Ok(());
32    }
33    Err(IdValidationError::invalid(
34        "DeploymentOrganizationUuid",
35        "expected a hyphenated UUID",
36    ))
37}