Add Grant, Mode and Constraints to proto
Implemented-By: Laguna S 2.1 (OpenCode)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//! Grant file schema. A grant is TOML written by the owner to allow one kind of tool call.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{DataClass, Timestamp};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Mode {
|
||||
Auto,
|
||||
Ask,
|
||||
Deny,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase", deny_unknown_fields)]
|
||||
pub struct Constraints {
|
||||
#[serde(default)]
|
||||
pub paths: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub hosts: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub patterns: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Grant {
|
||||
pub tool: String,
|
||||
pub mode: Mode,
|
||||
pub max_taint: DataClass,
|
||||
#[serde(default = "default_result_class")]
|
||||
pub result_class: DataClass,
|
||||
#[serde(default = "default_untrusted")]
|
||||
pub untrusted: bool,
|
||||
#[serde(default)]
|
||||
pub expires: Option<Timestamp>,
|
||||
#[serde(default)]
|
||||
pub secret: Option<String>,
|
||||
#[serde(default)]
|
||||
pub constraints: Constraints,
|
||||
}
|
||||
|
||||
fn default_result_class() -> DataClass {
|
||||
DataClass::Private
|
||||
}
|
||||
|
||||
fn default_untrusted() -> bool {
|
||||
true
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
pub mod class;
|
||||
pub mod frame;
|
||||
pub mod grant;
|
||||
pub mod ids;
|
||||
pub mod wire;
|
||||
|
||||
pub use class::DataClass;
|
||||
pub use frame::{FrameError, MAX_FRAME, read_frame, write_frame};
|
||||
pub use grant::{Constraints, Grant, Mode};
|
||||
pub use ids::{CallId, Epoch, Hash32, SessionId, Timestamp, ValueError};
|
||||
pub use wire::{
|
||||
DenyReason, Envelope, ErrorCode, Message, PROTOCOL_VERSION, ToolRequest, ToolResponse,
|
||||
|
||||
Reference in New Issue
Block a user