mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-08 00:54:49 +08:00
feat: b6-pdf-extract-v2 — batch 6
This commit is contained in:
@@ -69,6 +69,7 @@ pub struct RuntimePluginConfig {
|
|||||||
install_root: Option<String>,
|
install_root: Option<String>,
|
||||||
registry_path: Option<String>,
|
registry_path: Option<String>,
|
||||||
bundled_root: Option<String>,
|
bundled_root: Option<String>,
|
||||||
|
max_output_tokens: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structured feature configuration consumed by runtime subsystems.
|
/// Structured feature configuration consumed by runtime subsystems.
|
||||||
@@ -541,6 +542,15 @@ impl RuntimePluginConfig {
|
|||||||
self.bundled_root.as_deref()
|
self.bundled_root.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn max_output_tokens(&self) -> Option<u32> {
|
||||||
|
self.max_output_tokens
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_max_output_tokens(&mut self, max_output_tokens: Option<u32>) {
|
||||||
|
self.max_output_tokens = max_output_tokens;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_plugin_state(&mut self, plugin_id: String, enabled: bool) {
|
pub fn set_plugin_state(&mut self, plugin_id: String, enabled: bool) {
|
||||||
self.enabled_plugins.insert(plugin_id, enabled);
|
self.enabled_plugins.insert(plugin_id, enabled);
|
||||||
}
|
}
|
||||||
@@ -823,6 +833,7 @@ fn parse_optional_plugin_config(root: &JsonValue) -> Result<RuntimePluginConfig,
|
|||||||
optional_string(plugins, "registryPath", "merged settings.plugins")?.map(str::to_string);
|
optional_string(plugins, "registryPath", "merged settings.plugins")?.map(str::to_string);
|
||||||
config.bundled_root =
|
config.bundled_root =
|
||||||
optional_string(plugins, "bundledRoot", "merged settings.plugins")?.map(str::to_string);
|
optional_string(plugins, "bundledRoot", "merged settings.plugins")?.map(str::to_string);
|
||||||
|
config.max_output_tokens = optional_u32(plugins, "maxOutputTokens", "merged settings.plugins")?;
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,6 +1094,27 @@ fn optional_u16(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn optional_u32(
|
||||||
|
object: &BTreeMap<String, JsonValue>,
|
||||||
|
key: &str,
|
||||||
|
context: &str,
|
||||||
|
) -> Result<Option<u32>, ConfigError> {
|
||||||
|
match object.get(key) {
|
||||||
|
Some(value) => {
|
||||||
|
let Some(number) = value.as_i64() else {
|
||||||
|
return Err(ConfigError::Parse(format!(
|
||||||
|
"{context}: field {key} must be a non-negative integer"
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
let number = u32::try_from(number).map_err(|_| {
|
||||||
|
ConfigError::Parse(format!("{context}: field {key} is out of range"))
|
||||||
|
})?;
|
||||||
|
Ok(Some(number))
|
||||||
|
}
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn optional_u64(
|
fn optional_u64(
|
||||||
object: &BTreeMap<String, JsonValue>,
|
object: &BTreeMap<String, JsonValue>,
|
||||||
key: &str,
|
key: &str,
|
||||||
|
|||||||
@@ -242,6 +242,10 @@ const PLUGINS_FIELDS: &[FieldSpec] = &[
|
|||||||
name: "bundledRoot",
|
name: "bundledRoot",
|
||||||
expected: FieldType::String,
|
expected: FieldType::String,
|
||||||
},
|
},
|
||||||
|
FieldSpec {
|
||||||
|
name: "maxOutputTokens",
|
||||||
|
expected: FieldType::Number,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const SANDBOX_FIELDS: &[FieldSpec] = &[
|
const SANDBOX_FIELDS: &[FieldSpec] = &[
|
||||||
|
|||||||
Reference in New Issue
Block a user