mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
feat: add multi-actions to presentation tool (#13357)
This commit is contained in:
committed by
GitHub
Unverified
parent
ad393fa753
commit
1df040e62b
@@ -2,7 +2,7 @@ use async_trait::async_trait;
|
||||
use codex_artifact_presentation::PathAccessKind;
|
||||
use codex_artifact_presentation::PathAccessRequirement;
|
||||
use codex_artifact_presentation::PresentationArtifactError;
|
||||
use codex_artifact_presentation::PresentationArtifactRequest;
|
||||
use codex_artifact_presentation::PresentationArtifactToolRequest;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::protocol::ReviewDecision;
|
||||
use serde_json::to_string;
|
||||
@@ -37,23 +37,10 @@ impl ToolHandler for PresentationArtifactHandler {
|
||||
let ToolPayload::Function { arguments } = &invocation.payload else {
|
||||
return true;
|
||||
};
|
||||
let Ok(request) = parse_arguments::<PresentationArtifactRequest>(arguments) else {
|
||||
let Ok(request) = parse_arguments::<PresentationArtifactToolRequest>(arguments) else {
|
||||
return true;
|
||||
};
|
||||
!matches!(
|
||||
request.action.as_str(),
|
||||
"get_summary"
|
||||
| "list_slides"
|
||||
| "list_layouts"
|
||||
| "list_layout_placeholders"
|
||||
| "list_slide_placeholders"
|
||||
| "inspect"
|
||||
| "resolve"
|
||||
| "to_proto"
|
||||
| "get_style"
|
||||
| "describe_styles"
|
||||
| "record_patch"
|
||||
)
|
||||
request.is_mutating().unwrap_or(true)
|
||||
}
|
||||
|
||||
async fn handle(&self, invocation: ToolInvocation) -> Result<ToolOutput, FunctionCallError> {
|
||||
@@ -80,7 +67,7 @@ impl ToolHandler for PresentationArtifactHandler {
|
||||
}
|
||||
};
|
||||
|
||||
let request: PresentationArtifactRequest = parse_arguments(&arguments)?;
|
||||
let request: PresentationArtifactToolRequest = parse_arguments(&arguments)?;
|
||||
for access in request
|
||||
.required_path_accesses(&turn.cwd)
|
||||
.map_err(presentation_error)?
|
||||
@@ -89,7 +76,12 @@ impl ToolHandler for PresentationArtifactHandler {
|
||||
}
|
||||
|
||||
let response = session
|
||||
.execute_presentation_artifact(request, &turn.cwd)
|
||||
.execute_presentation_artifact(
|
||||
request
|
||||
.into_execution_request()
|
||||
.map_err(presentation_error)?,
|
||||
&turn.cwd,
|
||||
)
|
||||
.await
|
||||
.map_err(presentation_error)?;
|
||||
|
||||
|
||||
@@ -567,6 +567,26 @@ fn create_view_image_tool() -> ToolSpec {
|
||||
}
|
||||
|
||||
fn create_presentation_artifact_tool() -> ToolSpec {
|
||||
let action_step_schema = JsonSchema::Object {
|
||||
properties: BTreeMap::from([
|
||||
(
|
||||
"action".to_string(),
|
||||
JsonSchema::String {
|
||||
description: Some("Action name to run for this step.".to_string()),
|
||||
},
|
||||
),
|
||||
(
|
||||
"args".to_string(),
|
||||
JsonSchema::Object {
|
||||
properties: BTreeMap::new(),
|
||||
required: None,
|
||||
additional_properties: Some(true.into()),
|
||||
},
|
||||
),
|
||||
]),
|
||||
required: Some(vec!["action".to_string(), "args".to_string()]),
|
||||
additional_properties: Some(false.into()),
|
||||
};
|
||||
let properties = BTreeMap::from([
|
||||
(
|
||||
"artifact_id".to_string(),
|
||||
@@ -577,17 +597,12 @@ fn create_presentation_artifact_tool() -> ToolSpec {
|
||||
},
|
||||
),
|
||||
(
|
||||
"action".to_string(),
|
||||
JsonSchema::String {
|
||||
description: Some("Action name to run against the artifact.".to_string()),
|
||||
},
|
||||
),
|
||||
(
|
||||
"args".to_string(),
|
||||
JsonSchema::Object {
|
||||
properties: BTreeMap::new(),
|
||||
required: None,
|
||||
additional_properties: Some(true.into()),
|
||||
"actions".to_string(),
|
||||
JsonSchema::Array {
|
||||
items: Box::new(action_step_schema),
|
||||
description: Some(
|
||||
"Array of `(action, args)` steps to execute sequentially.".to_string(),
|
||||
),
|
||||
},
|
||||
),
|
||||
]);
|
||||
@@ -598,7 +613,7 @@ fn create_presentation_artifact_tool() -> ToolSpec {
|
||||
strict: false,
|
||||
parameters: JsonSchema::Object {
|
||||
properties,
|
||||
required: Some(vec!["action".to_string(), "args".to_string()]),
|
||||
required: Some(vec!["actions".to_string()]),
|
||||
additional_properties: Some(false.into()),
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user