Skip to main content

systemprompt_models/bridge/
manifest.rs

1//! Signed manifest wire format.
2//!
3//! [`SignedManifest`] is the JSON document the gateway returns from
4//! `GET /v1/bridge/manifest` and the bridge consumes to drive its
5//! plugin / skill / agent / managed-MCP sync. Every public type in
6//! this module is part of that wire contract — the gateway server
7//! (in `crates/entry/api`) emits these structs and the bridge
8//! deserialises them, so any change here is a wire-format change.
9//!
10//! Signing, signature verification, and manifest construction live in
11//! the bridge crate (`bin/bridge/src/gateway/manifest.rs`) alongside
12//! the gateway client. Those layers pull in `ed25519-dalek` and
13//! `serde_jcs` which are not appropriate dependencies for this
14//! foundation crate.
15//!
16//! Copyright (c) systemprompt.io — Business Source License 1.1.
17//! See <https://systemprompt.io> for licensing details.
18
19use std::collections::BTreeMap;
20
21use serde::{Deserialize, Serialize};
22
23pub use crate::bridge::ids::ManifestSignature;
24use crate::bridge::ids::{
25    LibraryArtifactId, ManagedMcpServerName, PluginId, Sha256Digest, SkillId, SkillName, ToolName,
26    ToolPolicy,
27};
28use crate::bridge::manifest_version::ManifestVersion;
29use crate::services::hooks::{HookCategory, HookEvent};
30use crate::services::plugin::{PluginComponentRef, PluginHooksRef};
31use systemprompt_identifiers::{AgentId, AgentName, HookId, TenantId, UserId, ValidatedUrl};
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct SignedManifest {
35    pub manifest_version: ManifestVersion,
36    pub issued_at: String,
37    pub not_before: String,
38    pub user_id: UserId,
39    pub tenant_id: Option<TenantId>,
40    #[serde(default)]
41    pub user: Option<UserInfo>,
42    pub plugins: Vec<PluginEntry>,
43    #[serde(default)]
44    pub skills: Vec<SkillEntry>,
45    #[serde(default)]
46    pub agents: Vec<AgentEntry>,
47    #[serde(default)]
48    pub hooks: Vec<HookEntry>,
49    pub managed_mcp_servers: Vec<ManagedMcpServer>,
50    pub revocations: Vec<String>,
51    #[serde(default)]
52    pub enabled_hosts: Vec<String>,
53    /// Optional per-host wire-protocol filter, keyed by host id. A present
54    /// entry overrides the host's built-in default `accepted_protocols`; an
55    /// empty value means "all models" (no restriction). An absent entry leaves
56    /// the host on its default.
57    #[serde(default)]
58    pub host_model_protocols: BTreeMap<String, Vec<String>>,
59    /// Cowork global-library HTML documents — distinct from the in-chat MCP
60    /// artifacts in [`crate::artifacts`].
61    #[serde(default)]
62    pub artifacts: Vec<ArtifactEntry>,
63    /// Detached ed25519 signature of the canonicalised payload (every
64    /// field above this one). Always present on the wire even for
65    /// unsigned manifests, where it is the empty string.
66    pub signature: ManifestSignature,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct UserInfo {
71    pub id: UserId,
72    pub name: String,
73    pub email: String,
74    #[serde(default)]
75    pub display_name: Option<String>,
76    #[serde(default)]
77    pub roles: Vec<String>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct PluginEntry {
82    pub id: PluginId,
83    pub version: String,
84    pub sha256: Sha256Digest,
85    pub files: Vec<PluginFile>,
86    #[serde(default)]
87    pub hooks: PluginHooksRef,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct PluginFile {
92    pub path: String,
93    pub sha256: Sha256Digest,
94    pub size: u64,
95}
96
97/// A Cowork-native library document (raw HTML in the desktop app's Artifacts
98/// library) — not one of the in-chat MCP artifacts in [`crate::artifacts`].
99#[derive(Debug, Clone, Serialize, Deserialize)]
100pub struct ArtifactEntry {
101    pub id: LibraryArtifactId,
102    pub name: String,
103    pub description: String,
104    pub version: String,
105    pub mcp_tools: Vec<String>,
106    pub content: String,
107    pub starred: bool,
108    pub sha256: Sha256Digest,
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize)]
112pub struct SkillEntry {
113    pub id: SkillId,
114    pub name: SkillName,
115    pub description: String,
116    pub file_path: String,
117    #[serde(default)]
118    pub tags: Vec<String>,
119    pub sha256: Sha256Digest,
120    pub instructions: String,
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
124pub struct AgentEntry {
125    pub id: AgentId,
126    pub name: AgentName,
127    pub display_name: String,
128    pub description: String,
129    pub version: String,
130    pub endpoint: String,
131    pub enabled: bool,
132    pub is_default: bool,
133    pub is_primary: bool,
134    #[serde(default)]
135    pub provider: Option<String>,
136    #[serde(default)]
137    pub model: Option<String>,
138    #[serde(default)]
139    pub mcp_servers: PluginComponentRef,
140    #[serde(default)]
141    pub skills: PluginComponentRef,
142    #[serde(default)]
143    pub tags: Vec<String>,
144    #[serde(default)]
145    pub system_prompt: Option<String>,
146}
147
148#[derive(Debug, Clone, Serialize, Deserialize)]
149pub struct HookEntry {
150    pub id: HookId,
151    pub name: String,
152    pub description: String,
153    pub version: String,
154    pub event: HookEvent,
155    pub matcher: String,
156    pub command: String,
157    #[serde(default)]
158    pub is_async: bool,
159    pub category: HookCategory,
160    #[serde(default)]
161    pub tags: Vec<String>,
162    pub sha256: Sha256Digest,
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize)]
166pub struct ManagedMcpServer {
167    pub name: ManagedMcpServerName,
168    pub url: ValidatedUrl,
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub transport: Option<String>,
171    #[serde(skip_serializing_if = "Option::is_none")]
172    pub headers: Option<BTreeMap<String, String>>,
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub oauth: Option<bool>,
175    #[serde(skip_serializing_if = "Option::is_none")]
176    pub tool_policy: Option<BTreeMap<ToolName, ToolPolicy>>,
177}