Skip to content

Commit 3e3d8e9

Browse files
authored
feat(agent): adds agent config validation (#2357)
* adds schema validation * adds better error surfacing * better formmatting * fixes typo * fixes tests * adds MIT-0 to allowlist * only performs post parse validation on active agent * denies unknown fields from config * adds root command to for config validation * adds doc comment to function * fixes typo
1 parent cc1fa65 commit 3e3d8e9

File tree

9 files changed

+396
-250
lines changed

9 files changed

+396
-250
lines changed

Cargo.lock

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ windows = { version = "0.61.1", features = ["Foundation", "Win32_System_ProcessS
128128
winnow = "=0.6.2"
129129
winreg = "0.55.0"
130130
schemars = "1.0.4"
131+
jsonschema = "0.30.0"
131132

132133
[workspace.lints.rust]
133134
future_incompatible = "warn"

crates/chat-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ webpki-roots.workspace = true
121121
whoami.workspace = true
122122
winnow.workspace = true
123123
schemars.workspace = true
124+
jsonschema.workspace = true
124125

125126
[target.'cfg(unix)'.dependencies]
126127
nix.workspace = true

crates/chat-cli/src/cli/agent/legacy/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub async fn migrate(os: &mut Os) -> eyre::Result<Vec<Agent>> {
138138
name: LEGACY_GLOBAL_AGENT_NAME.to_string(),
139139
description: Some(DEFAULT_DESC.to_string()),
140140
path: Some(directories::chat_global_agent_path(os)?.join(format!("{LEGACY_GLOBAL_AGENT_NAME}.json"))),
141-
resources: context.paths.iter().map(|p| format!("file://{p}")).collect(),
141+
resources: context.paths.iter().map(|p| format!("file://{p}").into()).collect(),
142142
hooks: HashMap::from([
143143
(
144144
super::HookTrigger::AgentSpawn,
@@ -175,7 +175,7 @@ pub async fn migrate(os: &mut Os) -> eyre::Result<Vec<Agent>> {
175175
path: Some(global_agent_path.join(format!("{profile_name}.json"))),
176176
name: profile_name,
177177
description: Some(PROFILE_DESC.to_string()),
178-
resources: context.paths.iter().map(|p| format!("file://{p}")).collect(),
178+
resources: context.paths.iter().map(|p| format!("file://{p}").into()).collect(),
179179
hooks: HashMap::from([
180180
(
181181
super::HookTrigger::AgentSpawn,

0 commit comments

Comments
 (0)